chore: Clean up SETUP guides

This commit is contained in:
Ananth Bhaskararaman 2023-12-10 02:45:51 +05:30 committed by Thomas Buckley-Houston
parent c191b34201
commit f9c6fcf4cc
2 changed files with 121 additions and 86 deletions

View File

@ -1,86 +1,91 @@
# How to setup the build environment for browsh on a generic Linux system # How to setup the build environment for browsh on a generic Linux system
This guide was made for x86-64 based Linux systems. You may try to adapt it to other systems. You can follow this guide as-is on x86-64 based Linux distributions.
In this guide, it is assumed that you can't install the required go, nodejs and firefox versions from your distribution's repositories. You may try to adapt it to other systems.
In case they are available, you should try to install go, nodejs and firefox using your distribution's package manager. This guide assumes that you cannot install the required Go, NodeJS and Firefox packages
from your distribution's repositories.
In case they are available, you should install them using your system's package manager.
## Installing golang ## Installing golang
Get the latest amd64 binary for Linux on the [golang download page](https://golang.org/dl/). Get the latest binary for your target Linux system from the [golang download page](https://golang.org/dl/).
Extract to `/usr/local` with: Extract to `/usr/local` with:
``` ```shell
$ tar -C /usr/local -xzf go1.11.linux-amd64.tar.gz tar -C /usr/local -xzf go1.11.linux-amd64.tar.gz
``` ```
Add `/usr/local/go/bin` to your `PATH` in `~/.profile` Add `/usr/local/go/bin` to your `PATH` in `~/.profile`
## Installing nodejs/npm ## Installing nodejs/npm
Go to the [nodejs download page](https://nodejs.org/download) and select the LTS version of the Linux x86 64bit binaries. Go to the [nodejs download page](https://nodejs.org/download)
and select the LTS version of the Linux x86 64bit binaries.
``` ```shell
$ mkdir /usr/local/lib/nodejs mkdir /usr/local/lib/nodejs
$ VERSION=v8.11.4 VERSION=v8.11.4
$ DISTRO=linux-x64 DISTRO=linux-x64
$ tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs
$ mv /usr/local/lib/nodejs/node-$VERSION-$DISTRO /usr/local/lib/nodejs/node-$VERSION mv /usr/local/lib/nodejs/node-$VERSION-$DISTRO /usr/local/lib/nodejs/node-$VERSION
``` ```
Edit your `~/.profile` to add `/usr/local/lib/nodejs/node-v8.11.4/bin` to your `PATH`, then reload your profile: Edit your `~/.profile` to add `/usr/local/lib/nodejs/node-v8.11.4/bin` to your `PATH`,
then reload your profile:
``` ```shell
$ source ~/.profile source ~/.profile
``` ```
Create symlinks for *node* and *npm*: Create symlinks for *node* and *npm*:
``` ```shell
$ sudo ln -s /usr/local/lib/nodejs/node-$VERSION/bin/node /usr/local/bin/node sudo ln -s /usr/local/lib/nodejs/node-$VERSION/bin/node /usr/local/bin/node
$ sudo ln -s /usr/local/lib/nodejs/node-$VERSION/bin/npm /usr/local/bin/npm sudo ln -s /usr/local/lib/nodejs/node-$VERSION/bin/npm /usr/local/bin/npm
``` ```
Now you should be able to call the *go* and *node* binaries: Now you should be able to call the *go* and *node* binaries:
``` ```shell
$ go version go version
$ node --version node --version
``` ```
## Installing webpack and webpack-cli ## Installing webpack and webpack-cli
(`--no-audit` is used to get around errors, may not be needed) The `--no-audit` flag gets around errors. You may not need it.
``` ```shell
$ npm install -g --no-audit webpack npm install -g --no-audit webpack
$ npm install -g webpack-cli npm install -g webpack-cli
``` ```
## Installing web-ext ## Installing web-ext
(`--no-audit` is used to get around errors, may not be needed) The `--no-audit` flag gets around errors. You may not need it.
``` ```shell
$ npm install -g --ignore-scripts web-ext npm install -g --no-audit --ignore-scripts web-ext
``` ```
## Installing Firefox ## Installing Firefox
You may install *firefox* from your distribution's repositories. **Version 57 or higher is required.** You may install *firefox* from your distribution's repositories.
**Browsh requires Version 57 or higher.**
### Installing firefox from mozilla's binaries ### Installing firefox from mozilla's binaries
See `interfacer/contrib/setup_firefox.sh` for reference. See `interfacer/contrib/setup_firefox.sh` for reference.
``` ```shell
$ export FIREFOX_VERSION=60.0 export FIREFOX_VERSION=60.0
$ mkdir -p $HOME/bin mkdir -p $HOME/bin
$ pushd $HOME/bin pushd $HOME/bin
$ curl -L -o firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2 curl -L -o firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2
$ bzip2 -d firefox.tar.bz2 bzip2 -d firefox.tar.bz2
$ tar xf firefox.tar tar xf firefox.tar
$ popd popd
``` ```
## Cloning the browsh repository ## Cloning the browsh repository
@ -89,58 +94,59 @@ It's assumed that you already have *git* installed.
Run this anywhere you want: Run this anywhere you want:
``` ```shell
$ git clone https://github.com/browsh-org/browsh.git git clone https://github.com/browsh-org/browsh.git
``` ```
## Setting up the build environment in the cloned repository ## Setting up the build environment in the cloned repository
### Setting up dependencies ### Setting up dependencies
```shell
browsh=/path/to/browsh
cd "$browsh/webext"
source ~/.nvm/nvm.sh # this is optional
npm run get-gobindata
npm install
npm run build
diff -u <(echo -n) <(gofmt -d ./)
./node_modules/.bin/prettier --list-different "{src,test}/**/*.js"
``` ```
$ REPO_ROOT=/path/to/browsh
$ cd $REPO_ROOT/webext
$ source ~/.nvm/nvm.sh # this is optional
$ npm run get-gobindata
$ npm install
$ npm run build
$ diff -u <(echo -n) <(gofmt -d ./)
$ ./node_modules/.bin/prettier --list-different "{src,test}/**/*.js"
```
### Building browsh ### Building browsh
``` ```shell
$ cd $REPO_ROOT/interfacer cd "$browsh/interfacer"
$ go build -o browsh src/main.go go build -o browsh src/main.go
``` ```
### Building the web extension ### Building the web extension
In `$REPO_ROOT/webext`: In `$browsh/webext`:
``` ```shell
$ webpack --watch webpack --watch
``` ```
This will continuously watch for changes made to the web extension and rebuild it. This will continuously watch for changes made to the web extension and rebuild it.
## Run firefox and the webextension ## Run firefox and the webextension
In `$REPO_ROOT/webext/dist`: In `$browsh/webext/dist`:
``` ```shell
$ web-ext run --verbose --firefox path/to/firefox web-ext run --verbose --firefox path/to/firefox
``` ```
## Run browsh ## Run browsh
``` ```shell
$ cd $REPO_ROOT/interfacer cd "$browsh/interfacer"
$ go run ./cmd/browsh --firefox.use-existing --debug go run ./cmd/browsh --firefox.use-existing --debug
``` ```
Or after building: Or after building:
``` ```shell
$ ./browsh --firefox.use-existing --debug ./browsh --firefox.use-existing --debug
``` ```

View File

@ -1,8 +1,11 @@
# How to set up the build environment for Browsh on Windows # How to set up the build environment for Browsh on Windows
This guide is for those who want to set up the build environment on Windows Command Prompt or Powershell. Since some of the shell scripts are needed to set up the environment, you can just use **Git Bash** to run these scripts.
This guide is for those who want to set up the build environment on Windows
Command Prompt or Powershell.
Setup depends on running shell scripts. You can use **Git Bash** to run those scripts.
## Setting up Go, NodeJs, and GOPATH ## Setting up Go, NodeJs, and GOPATH
Download and install Go for Windows at [Go download page](https://golang.org/dl/). Download and install Go for Windows at [Go download page](https://golang.org/dl/).
Download and install NodeJs for Windows at [NodeJs download page](https://nodejs.org/en/download/) Download and install NodeJs for Windows at [NodeJs download page](https://nodejs.org/en/download/)
@ -10,17 +13,24 @@ Download and install NodeJs for Windows at [NodeJs download page](https://nodejs
Using Command Prompt or Powershell: Using Command Prompt or Powershell:
Create a go workspace: Create a go workspace:
> mkdir go
> cd go ```shell
mkdir go
cd go
```
Set GOPATH to current directory. Set GOPATH to current directory.
> set GOPATH=%cd%
```shell
set GOPATH=%cd%
```
Create subdirectories bin and src within your go directory: Create subdirectories bin and src within your go directory:
> mkdir bin
> mkdir src ```shell
mkdir bin
mkdir src
```
Add %GOPATH%/bin to your PATH. Add %GOPATH%/bin to your PATH.
@ -29,44 +39,63 @@ Add %GOPATH%/bin to your PATH.
Download and install Chocolatey package manager at [Chocolatey download page](https://chocolatey.org/install). Download and install Chocolatey package manager at [Chocolatey download page](https://chocolatey.org/install).
Using chocolatey package manager run: Using chocolatey package manager run:
> choco install dep
```shell
choco install dep
```
## Installing webpack, web-ext, and Firefox ## Installing webpack, web-ext, and Firefox
> npm install -g --no-audit webpack
> npm install -g --ignore-scripts web-ext ```shell
npm install -g --no-audit webpack
npm install -g --ignore-scripts web-ext
```
Download and install Firefox for Windows at [Firefox download page](https://www.mozilla.org/en-US/firefox/new/). Download and install Firefox for Windows at [Firefox download page](https://www.mozilla.org/en-US/firefox/new/).
Note: **Version 57 or higher is required.** Note: **Browsh requires Firefox versions 57 or higher.**
## Cloning the browsh repository ## Cloning the browsh repository
Navigate to GOPATH/src and run:
> git clone https://github.com/browsh-org/browsh.git
Navigate to GOPATH/src and run:
```shell
git clone https://github.com/browsh-org/browsh.git
```
## Setting up dependencies ## Setting up dependencies
Navigate to browsh/webext and run: Navigate to browsh/webext and run:
> npm install
```shell
npm install
```
## Building browsh with Git Bash ## Building browsh with Git Bash
Using Git Bash, navigate to browsh/interfacer/contrib and run: Using Git Bash, navigate to browsh/interfacer/contrib and run:
> ./build_browsh.sh
```shell
./build_browsh.sh
```
## Running browsh ## Running browsh
Using three Command Prompts or Powershells: Using three Command Prompts or Powershells:
Navigate to GOPATH/browsh and run: Navigate to GOPATH/browsh and run:
> go run ./interfacer/src/main.go --firefox.use-existing --debug
```shell
go run ./interfacer/src/main.go --firefox.use-existing --debug
```
Navigate to browsh/webext and run: Navigate to browsh/webext and run:
> webpack --watch
```shell
webpack --watch
```
Navigate to browsh/webext/dist and run: Navigate to browsh/webext/dist and run:
> web-ext run --verbose
```shell
web-ext run --verbose
```