Skip to content

Commit

Permalink
fix: allow building in macos catalina
Browse files Browse the repository at this point in the history
Build Windows distributions within a Docker container and
change the way we handle web security to allow for the
build to run within macOS Catalina.

closes #194
  • Loading branch information
juancarlosfarah committed Oct 26, 2019
1 parent af20a10 commit 69aff4e
Show file tree
Hide file tree
Showing 4 changed files with 2,552 additions and 2,458 deletions.
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
"prestart": "env-cmd -f ./.env.local node scripts/setup.js",
"prebuild": "env-cmd -f ./.env node scripts/setup.js",
"predist": "yarn build",
"predist:windows": "yarn build",
"predist:win": "yarn build",
"predist:mac": "yarn build",
"predist:linux": "yarn build",
"predist:posix": "yarn build",
"predist:all": "yarn build",
"prerelease": "yarn test:once && yarn build",
"setup": "node scripts/setup.js",
Expand All @@ -46,12 +47,12 @@
"prettier:write": "prettier --write '{src,public}/**/*.js'",
"test": "react-scripts test",
"dist": "env-cmd -f ./.env electron-builder",
"dist:windows": "env-cmd -f ./.env build -w --x64 --ia32",
"dist:mac": "env-cmd -f ./.env build -m",
"dist:linux": "env-cmd -f ./.env build -l",
"dist:all": "run-p dist:x64 dist:x64ia32",
"dist:x64": "env-cmd -f ./.env build -ml",
"dist:x64ia32": "env-cmd -f ./.env build -w --x64 --ia32",
"dist:win": "env-cmd -f ./.env electron-builder -w --x64 --ia32",
"dist:mac": "env-cmd -f ./.env electron-builder -m",
"dist:linux": "env-cmd -f ./.env electron-builder -l",
"dist:posix": "env-cmd -f ./.env electron-builder -ml",
"dist:win:docker": "./scripts/buildWindowsWithDocker.sh",
"dist:all": "run-s dist:posix dist:win:docker",
"release": "run-s version dist:all",
"hooks:uninstall": "node node_modules/husky/husky.js uninstall",
"hooks:install": "node node_modules/husky/husky.js install",
Expand Down Expand Up @@ -128,16 +129,16 @@
"codacy-coverage": "3.4.0",
"concurrently": "4.1.0",
"cross-env": "5.2.0",
"electron": "5.0.3",
"electron-builder": "20.43.0",
"env-cmd": "9.0.3",
"electron": "7.0.0",
"electron-builder": "21.2.0",
"env-cmd": "10.0.1",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "4.2.0",
"husky": "2.1.0",
"npm-run-all": "4.1.5",
"prettier": "1.17.0",
"pretty-quick": "1.10.0",
"react-scripts": "3.0.1",
"react-scripts": "3.2.0",
"redux-mock-store": "1.5.3",
"standard-version": "5.0.2",
"wait-on": "3.2.0"
Expand All @@ -154,10 +155,8 @@
"icon": "assets/icon.icns",
"type": "distribution",
"target": [
"pkg",
"dmg",
"mas",
"zip"
"mas"
],
"category": "public.app-category.education",
"publish": [
Expand Down
6 changes: 5 additions & 1 deletion public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ Sentry.init({ dsn: SENTRY_DSN });
// get unique identifier for this machine
const machineId = machineIdSync();

// disable web security
// see: https://github.com/electron/electron/issues/20710
app.commandLine.appendSwitch('disable-web-security');

const createWindow = () => {
mainWindow = new BrowserWindow({
backgroundColor: '#F7F7F7',
Expand All @@ -98,7 +102,7 @@ const createWindow = () => {
webPreferences: {
nodeIntegration: false,
preload: `${__dirname}/app/preload.js`,
webSecurity: false,
// webSecurity: false,
},
height: 860,
width: 1280,
Expand Down
12 changes: 12 additions & 0 deletions scripts/buildWindowsWithDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
docker run --rm -ti \
--env-file <(env | grep -iE 'DEBUG|NODE_|ELECTRON_|YARN_|NPM_|CI|CIRCLE|TRAVIS_TAG|TRAVIS|TRAVIS_REPO_|TRAVIS_BUILD_|TRAVIS_BRANCH|TRAVIS_PULL_REQUEST_|APPVEYOR_|CSC_|GH_|GITHUB_|BT_|AWS_|STRIP|BUILD_') \
--env ELECTRON_CACHE="/root/.cache/electron" \
--env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder" \
--env NODE_VERSION="12.3.0" \
-v ${PWD}:/project \
-v ${PWD##*/}-node-modules:/project/node_modules \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:wine \
/bin/bash -c "apt-get -qq update && curl -L https://nodejs.org/dist/v12.3.0/node-v12.3.0-linux-x64.tar.gz | tar xz -C /usr/local --strip-components=1 && unlink /usr/local/CHANGELOG.md && unlink /usr/local/LICENSE && unlink /usr/local/README.md && npm config set unsafe-perm true && yarn && yarn dist:win"
Loading

0 comments on commit 69aff4e

Please sign in to comment.