Skip to content

Commit

Permalink
fix: make build work on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Oct 11, 2020
1 parent 922b2e5 commit da99041
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 31 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ jobs:
with:
node-version: 12.x

- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Restore .cache
uses: actions/cache@v2
id: cache
Expand All @@ -39,20 +32,26 @@ jobs:
${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
${{ runner.os }}-
- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: npm run ci:install

- name: Run postinstall if cached
if: steps.yarn-cache.outputs.cache-hit == 'true'
run: npx yarn postinstall

- name: Build
run: npm run build

- name: Show build/
run: du -sh build/ && ls -l build/

- name: Show dist/bundles/*
run: du -h add-on/dist/bundles/*

- name: Test
run: npm run test

Expand Down
4 changes: 2 additions & 2 deletions DEVELOPER-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ To run your extension in [Firefox for Android](https://www.mozilla.org/en-US/fir

- [Set up your computer and Android emulator or device](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Developing_WebExtensions_for_Firefox_for_Android#Set_up_your_computer_and_Android_emulator_or_device) (enable Developer Mode, USB debugging, etc.)

Build everything, and switch `add-on/manifest.json` to the Fennec profile:
Build everything, and switch `add-on/manifest.json` to the Firefox profile:

```
npm run dev-build
npm run bundle:fennec
npm run bundle:firefox
```

Then, with your device connected to your development computer, run:
Expand Down
22 changes: 9 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@
"build:js": "run-s build:js:*",
"build:js:webpack": "webpack --mode production",
"build:minimize-dist": "shx rm -rf add-on/dist/lib add-on/dist/contentScripts/ add-on/dist/bundles/ipfsProxyContentScriptPayload.bundle.js",
"build:bundle-all": "cross-env RELEASE_CHANNEL=${RELEASE_CHANNEL:=dev} run-s bundle:chromium bundle:brave:$RELEASE_CHANNEL bundle:firefox:$RELEASE_CHANNEL",
"build:rename-artifacts": "./scripts/rename-artifacts.js",
"build:bundle-all": "cross-env run-s bundle:chromium bundle:brave:$RELEASE_CHANNEL bundle:firefox:$RELEASE_CHANNEL",
"build:rename-artifacts": "node scripts/rename-artifacts.js",
"precache:clean": "shx rm -rf add-on/dist/precache",
"bundle": "run-s bundle:*",
"bundle:chromium": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/chromium && run-s build:rename-artifacts",
"bundle:firefox": "shx cat add-on/manifest.common.json add-on/manifest.firefox.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/firefox/ && run-s build:rename-artifacts",
"bundle:firefox:dev": "npm run bundle:firefox",
"bundle:firefox:": "npm run bundle:firefox",
"bundle:firefox:stable": "npm run bundle:firefox",
"bundle:firefox:beta": "shx cat add-on/manifest.common.json add-on/manifest.firefox.json add-on/manifest.firefox-beta.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/firefox/ && run-s build:rename-artifacts",
"bundle:fennec": "npm run bundle:firefox",
"bundle:fennec:dev": "npm run bundle:firefox:dev",
"bundle:fennec:stable": "npm run bundle:firefox:stable",
"bundle:fennec:beta": "npm run bundle:firefox:beta",
"bundle:brave": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json add-on/manifest.brave.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/brave/ && run-s build:rename-artifacts",
"bundle:brave:dev": "npm run bundle:brave",
"bundle:brave:": "npm run bundle:brave",
"bundle:brave:stable": "npm run bundle:brave",
"bundle:brave:beta": "shx cat add-on/manifest.common.json add-on/manifest.chromium.json add-on/manifest.brave.json add-on/manifest.brave-beta.json | json --deep-merge > add-on/manifest.json && web-ext build -a build/brave/ && run-s build:rename-artifacts",
"watch": "npm-run-all build:copy --parallel watch:*",
Expand All @@ -56,13 +52,13 @@
"get-firefox-nightly": "shx test -e ./firefox/firefox || get-firefox -b nightly -e",
"changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s",
"ci": "run-s ci:*",
"ci:install": "npx yarn@1.22.4 install --frozen-lockfile --no-progress --non-interactive",
"ci:build": "./ci/update-manifest.sh && npx yarn@1.22.4 build",
"ci:test": "npx yarn@1.22.4 test",
"ci:lint": "npx yarn@1.22.4 lint",
"ci:install": "npx yarn@1.22.10 install --frozen-lockfile --no-progress --non-interactive",
"ci:build": "./ci/update-manifest.sh && npx yarn@1.22.10 build",
"ci:test": "npx yarn@1.22.10 test",
"ci:lint": "npx yarn@1.22.10 lint",
"beta-build": "docker rmi -f ipfs-companion-beta-build && docker build -t ipfs-companion-beta-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm -it --net=host -e RELEASE_CHANNEL=beta -v $(pwd)/build:/home/node/app/build ipfs-companion-beta-build yarn ci:build",
"release-build": "docker rmi -f ipfs-companion-release-build && docker build -t ipfs-companion-release-build --build-arg USER_ID=$(id -u ${USER}) --build-arg GROUP_ID=$(id -g ${USER}) . && mkdir -p build && docker run --rm -it --net=host -e RELEASE_CHANNEL=stable -v $(pwd)/build:/home/node/app/build ipfs-companion-release-build yarn ci:build",
"dev-build": "npx yarn@1.22.4 && npx yarn@1.22.4 build",
"dev-build": "npx yarn@1.22.10 && npx yarn@1.22.10 build",
"yarn-build": "npm run dev-build"
},
"private": true,
Expand Down
6 changes: 3 additions & 3 deletions scripts/rename-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
const fs = require('fs')
const glob = require('glob')

const files = glob.sync('./build/*/*.zip')
const files = glob.sync('build/*/*.zip')

files.map(async file => {
const path = file.split('/')
const name = path.pop().split('.zip').shift()
const target = path.pop()
const newFile = `./build/${name}_${target}.zip`
const newFile = `build/${name}_${target}.zip`
// remove old artifact, if exists
if (fs.existsSync(newFile)) fs.unlinkSync(newFile)
// rename artifact
console.log(`${file}${newFile}`)
fs.renameSync(file, newFile)
// remove empty dir
fs.rmdirSync(`./build/${target}`, { recursive: true })
fs.rmdirSync(`build/${target}`, { recursive: true })
})
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const commonConfig = {
},
{
// hapijs is node-centric and needs additional handling
include: /node_modules\/(@hapi|joi)/,
include: /node_modules[/\\](@hapi|joi)/,
test: /\.js$/,
use: [
'remove-hashbag-loader',
Expand Down Expand Up @@ -162,7 +162,7 @@ const bgConfig = merge(commonConfig, {
priority: 10,
enforce: true,
// Include js-ipfs and js-ipfs-http-client
test: /\/node_modules\/(ipfs|ipfs-http-client|ipfs-postmsg-proxy|peer-info|bcrypto)\//
test: /\/node_modules\/(ipfs|ipfs-http-client|ipfs-postmsg-proxy|peer-info|bcrypto|ipfsx|libp2p*)\//
}
}
}
Expand Down

0 comments on commit da99041

Please sign in to comment.