Merge pull request #2932 from balena-io/electron6

Electron6
This commit is contained in:
Alexis Svinartchouk 2019-12-03 17:28:09 +01:00 committed by GitHub
commit 082025f0b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 3390 additions and 3968 deletions

View File

@ -17,69 +17,29 @@
"copyright": "Copyright 2016-2019 Balena Ltd", "copyright": "Copyright 2016-2019 Balena Ltd",
"productName": "balenaEtcher", "productName": "balenaEtcher",
"nodeGypRebuild": true, "nodeGypRebuild": true,
"afterPack": "./afterPack.js",
"files": [ "files": [
"!node_modules/**/*.js.map", "build/Release/elevator.node",
"!node_modules/**/*.h",
"!node_modules/**/*.hpp",
"!node_modules/**/*.cpp",
"!node_modules/**/*.md",
"!node_modules/**/*.ts",
"!node_modules/**/*.coffee",
"!node_modules/**/*.scss",
"!node_modules/**/*.less",
"!node_modules/**/*.hbs",
"!node_modules/**/*.mkd",
"!node_modules/**/LICENSE",
"!node_modules/**/LICENCE",
"!node_modules/**/license",
"!node_modules/**/License",
"!node_modules/**/LICENSE.txt",
"!node_modules/**/Makefile",
"!node_modules/**/.editorconfig",
"!node_modules/**/.babelrc",
"!node_modules/**/.prettierrc",
"!node_modules/**/.prettierrc-*",
"!node_modules/**/.eslintrc.yml",
"!node_modules/**/.eslintignore",
"!node_modules/**/.publishrc",
"assets/icon.png",
"build/**/*.node",
"lib",
"!lib/gui/app",
"lib/gui/app/index.html",
"generated", "generated",
"!node_modules/chart.js/dist/docs", "lib/shared/catalina-sudo/sudo-askpass.osascript.js",
"!node_modules/ext2fs/config", "lib/gui/app/index.html",
"!node_modules/ext2fs/deps", "lib/gui/css/*.css",
"!node_modules/ext2fs/LICENSE", "lib/gui/css/fonts/*.woff2",
"!node_modules/ext2fs/src", "lib/gui/assets/*.svg",
"!node_modules/winusb-driver-generator/src", "assets/icon.png",
"!node_modules/winusb-driver-generator/deps", "!node_modules/**/**",
"!node_modules/winusb-driver-generator/ci", "node_modules/**/*.js",
"!node_modules/rendition/__screenshots__", "node_modules/**/*.json",
"!node_modules/polished/docs", "node_modules/**/*.node",
"!node_modules/mermaid/src", "node_modules/**/*.dll",
"!node_modules/mermaid/dist", "node_modules/node-raspberrypi-usbboot/blobs/**",
"node_modules/mermaid/dist/mermaid.core.js", "node_modules/flexboxgrid/dist/flexboxgrid.css",
"!node_modules/raven-js/src",
"!node_modules/raven-js/dist",
"node_modules/raven-js/dist/raven.js",
"!node_modules/raven-js/plugins",
"!node_modules/react-jsonschema-form/dist",
"!node_modules/xxhash/deps",
"!node_modules/xxhash/src",
"!node_modules/unzip-stream/testData*",
"!node_modules/usb",
"node_modules/usb/usb.js",
"node_modules/usb/package.json",
"node_modules/usb/build",
"node_modules/usb/src/binding",
"!node_modules/roboto-fontface/fonts",
"node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff", "node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff",
"node_modules/roboto-fontface/fonts/roboto/Roboto-Light.woff", "node_modules/roboto-fontface/fonts/roboto/Roboto-Light.woff",
"node_modules/roboto-fontface/fonts/roboto/Roboto-Regular.woff", "node_modules/roboto-fontface/fonts/roboto/Roboto-Regular.woff",
"node_modules/roboto-fontface/fonts/roboto/Roboto-Medium.woff", "node_modules/roboto-fontface/fonts/roboto/Roboto-Medium.woff",
"node_modules/roboto-fontface/fonts/roboto/Roboto-Bold.woff" "node_modules/roboto-fontface/fonts/roboto/Roboto-Bold.woff",
"node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2"
], ],
"afterSign": "./afterSignHook.js", "afterSign": "./afterSignHook.js",
"mac": { "mac": {

View File

@ -182,11 +182,10 @@ test-spectron:
ETCHER_SPECTRON_ENTRYPOINT="$(ETCHER_SPECTRON_ENTRYPOINT)" mocha $(MOCHA_OPTIONS) tests/spectron ETCHER_SPECTRON_ENTRYPOINT="$(ETCHER_SPECTRON_ENTRYPOINT)" mocha $(MOCHA_OPTIONS) tests/spectron
test-gui: test-gui:
electron-mocha $(MOCHA_OPTIONS) --renderer tests/gui electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox --renderer tests/gui
test-sdk: test-sdk:
electron-mocha $(MOCHA_OPTIONS) \ electron-mocha $(MOCHA_OPTIONS) --full-trace --no-sandbox tests/shared
tests/shared
test: test-gui test-sdk test-spectron test: test-gui test-sdk test-spectron

27
afterPack.js Normal file
View File

@ -0,0 +1,27 @@
'use strict'
const cp = require('child_process')
const fs = require('fs')
const outdent = require('outdent')
const path = require('path')
exports.default = function(context) {
if (context.packager.platform.name !== 'linux') {
return
}
const scriptPath = path.join(context.appOutDir, context.packager.executableName)
const binPath = scriptPath + '.bin'
cp.execFileSync('mv', [scriptPath, binPath])
fs.writeFileSync(
scriptPath,
outdent`
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
"\${BASH_SOURCE%/*}"/${context.packager.executableName}.bin "$@"
else
"\${BASH_SOURCE%/*}"/${context.packager.executableName}.bin "$@" --no-sandbox
fi
`
)
cp.execFileSync('chmod', ['+x', scriptPath])
}

View File

@ -4,13 +4,29 @@ productName: balenaEtcher
npmRebuild: true npmRebuild: true
nodeGypRebuild: true nodeGypRebuild: true
publish: null publish: null
afterPack: "./afterPack.js"
files: files:
- lib - build/Release/elevator.node
- lib/gui/app/index.html
- generated - generated
- build/**/*.node - lib/shared/catalina-sudo/sudo-askpass.osascript.js
- lib/gui/app/index.html
- lib/gui/css/*.css
- lib/gui/css/fonts/*.woff2
- lib/gui/assets/*.svg
- assets/icon.png - assets/icon.png
- node_modules/**/* - "!node_modules/**/**"
- "node_modules/**/*.js"
- "node_modules/**/*.json"
- "node_modules/**/*.node"
- "node_modules/**/*.dll"
- node_modules/node-raspberrypi-usbboot/blobs/**
- node_modules/flexboxgrid/dist/flexboxgrid.css
- node_modules/roboto-fontface/fonts/roboto/Roboto-Thin.woff
- node_modules/roboto-fontface/fonts/roboto/Roboto-Light.woff
- node_modules/roboto-fontface/fonts/roboto/Roboto-Regular.woff
- node_modules/roboto-fontface/fonts/roboto/Roboto-Medium.woff
- node_modules/roboto-fontface/fonts/roboto/Roboto-Bold.woff
- node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2
mac: mac:
asar: false asar: false
icon: assets/icon.icns icon: assets/icon.icns

View File

@ -167,27 +167,6 @@ class SafeWebview extends react.PureComponent {
this.session.webRequest.onCompleted(null) this.session.webRequest.onCompleted(null)
} }
/**
* @summary Refresh the webview if we are navigating away from the success page
* @param {Object} nextProps - upcoming properties
*/
componentWillReceiveProps (nextProps) {
if (nextProps.refreshNow && !this.props.refreshNow) {
// Reload the page if it hasn't changed, otherwise reset the source URL,
// because reload interferes with 'src' setting, resetting the 'src' attribute
// to what it was was just prior.
if (this.refs.webview.src === this.entryHref) {
this.refs.webview.reload()
} else {
this.refs.webview.src = this.entryHref
}
this.setState({
shouldShow: true
})
}
}
/** /**
* @summary Set the element state to hidden * @summary Set the element state to hidden
*/ */

View File

@ -139,9 +139,16 @@ interface SettingsModalProps {
toggleModal: (value: boolean) => void; toggleModal: (value: boolean) => void;
} }
interface Dictionary<T> {
[key: string]: T;
}
export const SettingsModal: any = styled( export const SettingsModal: any = styled(
({ toggleModal }: SettingsModalProps) => { ({ toggleModal }: SettingsModalProps) => {
const [currentSettings, setCurrentSettings] = useState(settings.getAll()); const [currentSettings, setCurrentSettings]: [
Dictionary<any>,
React.Dispatch<React.SetStateAction<Dictionary<any>>>,
] = useState(settings.getAll());
const [warning, setWarning]: [ const [warning, setWarning]: [
any, any,
React.Dispatch<React.SetStateAction<any>>, React.Dispatch<React.SetStateAction<any>>,
@ -155,6 +162,7 @@ export const SettingsModal: any = styled(
setting, setting,
value, value,
dangerous, dangerous,
// @ts-ignore
applicationSessionUuid: store.getState().toJS().applicationSessionUuid, applicationSessionUuid: store.getState().toJS().applicationSessionUuid,
}); });

View File

@ -133,15 +133,6 @@ class SVGIcon extends react.Component {
disabled: this.props.disabled disabled: this.props.disabled
}) })
} }
/**
* @summary Cause a re-render due to changed element properties
* @param {Object} nextProps - the new properties
*/
componentWillReceiveProps (nextProps) {
// This will update the element if the properties change
this.setState(nextProps)
}
} }
SVGIcon.propTypes = { SVGIcon.propTypes = {

View File

@ -38,9 +38,8 @@
ng-class="{ ng-class="{
isFinish: state.currentName === 'success' isFinish: state.currentName === 'success'
}"> }">
<safe-webview <safe-webview src="'https://www.balena.io/etcher/success-banner/'">
src="'https://www.balena.io/etcher/success-banner/'" </safe-webview>
refresh-now="state.previousName === 'success'"></safe-webview>
</div> </div>
</body> </body>
</html> </html>

View File

@ -15,8 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
/*! /*!
* Bootstrap v3.4.0 (https://getbootstrap.com/) * Bootstrap v3.4.1 (https://getbootstrap.com/)
* Copyright 2011-2018 Twitter, Inc. * Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/ */
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */ /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */

View File

@ -91,7 +91,9 @@ const createMainWindow = () => {
icon: path.join(__dirname, '..', '..', 'assets', 'icon.png'), icon: path.join(__dirname, '..', '..', 'assets', 'icon.png'),
darkTheme: true, darkTheme: true,
webPreferences: { webPreferences: {
backgroundThrottling: false backgroundThrottling: false,
nodeIntegration: true,
webviewTag: true
} }
}) })

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
const { execFile } = require('child_process') const { execFile } = require('child_process')
const { env } = require('process') const { env, resourcesPath } = require('process')
const { join } = require('path') const { join } = require('path')
const { promisify } = require('util') const { promisify } = require('util')
@ -19,7 +19,7 @@ exports.sudo = async (command) => {
encoding: 'utf8', encoding: 'utf8',
env: { env: {
PATH: env.PATH, PATH: env.PATH,
SUDO_ASKPASS: join(__dirname, 'sudo-askpass.osascript.js') SUDO_ASKPASS: join(resourcesPath, 'app', __dirname, 'sudo-askpass.osascript.js')
} }
} }
) )

View File

@ -1,41 +0,0 @@
/*
* Copyright 2017 resin.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict'
const path = require('path')
const bindings = require('bindings')
/**
* @summary Load a native module
* @function
* @public
*
* @param {String} moduleName - native module name
* @returns {Object} native module
*
* @example
* const elevator = nativeModule.load('elevator');
*/
exports.load = (moduleName) => {
return bindings({
bindings: moduleName,
// eslint-disable-next-line camelcase
module_root: path.join(__dirname, '..', '..')
})
}

View File

@ -18,6 +18,7 @@
'use strict' 'use strict'
const bindings = require('bindings')
const Bluebird = require('bluebird') const Bluebird = require('bluebird')
const childProcess = Bluebird.promisifyAll(require('child_process')) const childProcess = Bluebird.promisifyAll(require('child_process'))
const fs = require('fs') const fs = require('fs')
@ -136,10 +137,9 @@ exports.createLaunchScript = (command, argv, environment) => {
} }
const elevateScriptWindows = async (path) => { const elevateScriptWindows = async (path) => {
// './nativeModule' imported here as it only exists on windows // 'elevator' imported here as it only exists on windows
// TODO: replace this with sudo-prompt once https://github.com/jorangreef/sudo-prompt/issues/96 is fixed // TODO: replace this with sudo-prompt once https://github.com/jorangreef/sudo-prompt/issues/96 is fixed
const nativeModule = require('./native-module') const elevateAsync = promisify(bindings({ bindings: 'elevator' }).elevate)
const elevateAsync = promisify(nativeModule.load('elevator').elevate)
// '&' needs to be escaped here (but not when written to a .cmd file) // '&' needs to be escaped here (but not when written to a .cmd file)
const cmd = [ 'cmd', '/c', escapeParamCmd(path).replace(/&/g, '^&') ] const cmd = [ 'cmd', '/c', escapeParamCmd(path).replace(/&/g, '^&') ]

View File

@ -22,12 +22,9 @@
// *won't* attempt to load the `app.asar` application by default, therefore // *won't* attempt to load the `app.asar` application by default, therefore
// if passing `ELECTRON_RUN_AS_NODE`, you have to pass the path to the asar // if passing `ELECTRON_RUN_AS_NODE`, you have to pass the path to the asar
// or the entry point file (this file) manually as an argument. // or the entry point file (this file) manually as an argument.
//
// We also consider `ATOM_SHELL_INTERNAL_RUN_AS_NODE`, which is basically if (process.env.ELECTRON_RUN_AS_NODE) {
// an older equivalent of `ELECTRON_RUN_AS_NODE` that still gets set when
// using `child_process.fork()`.
if (process.env.ELECTRON_RUN_AS_NODE || process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE) {
require('./gui/modules/child-writer') require('./gui/modules/child-writer')
} else { } else {
require('../generated/etcher') require('./gui/etcher')
} }

6858
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
"sleepDays": 7, "sleepDays": 7,
"semverRange": "<2.0.0" "semverRange": "<2.0.0"
}, },
"main": "lib/start.js", "main": "generated/etcher.js",
"description": "Flash OS images to SD cards and USB drives, safely and easily.", "description": "Flash OS images to SD cards and USB drives, safely and easily.",
"productDescription": "Etcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more.", "productDescription": "Etcher is a powerful OS image flasher built with web technologies to ensure flashing an SDCard or USB drive is a pleasant and safe experience. It protects you from accidentally writing to your hard-drives, ensures every byte of data was written correctly and much more.",
"homepage": "https://github.com/balena-io/etcher", "homepage": "https://github.com/balena-io/etcher",
@ -56,13 +56,13 @@
"d3": "^4.13.0", "d3": "^4.13.0",
"debug": "^3.1.0", "debug": "^3.1.0",
"electron-updater": "4.0.6", "electron-updater": "4.0.6",
"etcher-sdk": "^2.0.13", "etcher-sdk": "^2.0.15",
"flexboxgrid": "^6.3.0", "flexboxgrid": "^6.3.0",
"immutable": "^3.8.1", "immutable": "^3.8.1",
"inactivity-timer": "^1.0.0", "inactivity-timer": "^1.0.0",
"lodash": "^4.17.10", "lodash": "^4.17.10",
"mime-types": "^2.1.18", "mime-types": "^2.1.18",
"nan": "^2.9.2", "nan": "^2.14.0",
"node-ipc": "^9.1.1", "node-ipc": "^9.1.1",
"path-is-inside": "^1.0.2", "path-is-inside": "^1.0.2",
"pretty-bytes": "^1.0.4", "pretty-bytes": "^1.0.4",
@ -80,22 +80,20 @@
"styled-system": "^4.1.0", "styled-system": "^4.1.0",
"sudo-prompt": "^9.0.0", "sudo-prompt": "^9.0.0",
"tmp": "^0.1.0", "tmp": "^0.1.0",
"uuid": "^3.0.1", "uuid": "^3.0.1"
"xml2js": "^0.4.17"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.2.0", "@babel/core": "^7.6.0",
"@babel/plugin-proposal-function-bind": "^7.2.0", "@babel/plugin-proposal-function-bind": "^7.2.0",
"@babel/preset-env": "^7.2.0", "@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"@types/react-dom": "^16.8.4", "@types/react-dom": "^16.8.4",
"acorn": "^6.0.5",
"angular-mocks": "1.7.6", "angular-mocks": "1.7.6",
"babel-loader": "^8.0.4", "babel-loader": "^8.0.4",
"chalk": "^1.1.3", "chalk": "^1.1.3",
"electron": "3.1.9", "electron": "6.1.4",
"electron-builder": "^22.1.0", "electron-builder": "^22.1.0",
"electron-mocha": "^6.0.4", "electron-mocha": "^8.1.2",
"electron-notarize": "^0.1.1", "electron-notarize": "^0.1.1",
"eslint": "^4.17.0", "eslint": "^4.17.0",
"eslint-config-standard": "^10.2.1", "eslint-config-standard": "^10.2.1",
@ -108,22 +106,20 @@
"eslint-plugin-standard": "^3.0.1", "eslint-plugin-standard": "^3.0.1",
"html-angular-validate": "^0.2.3", "html-angular-validate": "^0.2.3",
"html-loader": "^0.5.1", "html-loader": "^0.5.1",
"mocha": "^5.0.1", "mocha": "^6.2.1",
"mochainon": "^2.0.0", "mochainon": "^2.0.0",
"nock": "^9.2.3",
"node-gyp": "^3.8.0", "node-gyp": "^3.8.0",
"node-sass": "^4.7.2", "node-sass": "^4.12.0",
"omit-deep-lodash": "1.1.4", "omit-deep-lodash": "1.1.4",
"pkg": "^4.3.0",
"resin-lint": "^3.1.0", "resin-lint": "^3.1.0",
"sass-lint": "^1.12.1", "sass-lint": "^1.12.1",
"simple-progress-webpack-plugin": "^1.1.2", "simple-progress-webpack-plugin": "^1.1.2",
"spectron": "^5.0.0", "spectron": "^8.0.0",
"ts-loader": "^6.0.4", "ts-loader": "^6.0.4",
"ts-node": "^8.3.0", "ts-node": "^8.3.0",
"typescript": "^3.5.3", "typescript": "^3.5.3",
"webpack": "^4.31.0", "webpack": "^4.40.2",
"webpack-cli": "^3.1.2", "webpack-cli": "^3.3.9",
"webpack-node-externals": "^1.7.2" "webpack-node-externals": "^1.7.2"
} }
} }

View File

@ -1,28 +0,0 @@
--- a/node_modules/node-pre-gyp/lib/util/versioning.js
+++ b/node_modules/node-pre-gyp/lib/util/versioning.js
@@ -80,7 +80,14 @@ function get_runtime_abi(runtime, target_version) {
if (runtime === 'node-webkit') {
return get_node_webkit_abi(runtime, target_version || process.versions['node-webkit']);
} else if (runtime === 'electron') {
- return get_electron_abi(runtime, target_version || process.versions.electron);
+ var electron_version = target_version || process.versions.electron;
+ if (!electron_version) {
+ // TODO PR something to electron to pass in the version number for forks
+ // https://github.com/electron/electron/issues/9058
+ try { electron_version = require('electron/package.json').version; }
+ catch (_) { electron_version = '3.1.9'; }
+ }
+ return get_electron_abi(runtime, electron_version);
} else {
if (runtime != 'node') {
throw new Error("Unknown Runtime: '" + runtime + "'");
@@ -263,7 +270,8 @@ function get_process_runtime(versions) {
var runtime = 'node';
if (versions['node-webkit']) {
runtime = 'node-webkit';
- } else if (versions.electron) {
+ } else if (versions.electron || process.env.ELECTRON_RUN_AS_NODE) {
+ // Running in electron or a childProcess.fork of electron
runtime = 'electron';
}
return runtime;

View File

@ -1,83 +0,0 @@
#!/bin/bash
###
# Copyright 2016 resin.io
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###
set -u
set -e
function usage() {
echo "Usage: $0"
echo ""
echo "Options"
echo ""
echo " -d <dockerfile>"
echo " -s <source code directory>"
echo " -c <command>"
exit 1
}
ARGV_DOCKERFILE=""
ARGV_SOURCE_CODE_DIRECTORY=""
ARGV_COMMAND=""
while getopts ":d:s:c:" option; do
case $option in
d) ARGV_DOCKERFILE=$OPTARG ;;
s) ARGV_SOURCE_CODE_DIRECTORY=$OPTARG ;;
c) ARGV_COMMAND=$OPTARG ;;
*) usage ;;
esac
done
if [ -z "$ARGV_DOCKERFILE" ] \
|| [ -z "$ARGV_SOURCE_CODE_DIRECTORY" ] \
|| [ -z "$ARGV_COMMAND" ]
then
usage
fi
IMAGE_ID="etcher-build-$(basename "$ARGV_DOCKERFILE")"
docker build -f "$ARGV_DOCKERFILE" -t "$IMAGE_ID" "$ARGV_SOURCE_CODE_DIRECTORY"
# Docker complains with: ". includes invalid characters for a local
# volume name, only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed" otherwise
if [ "$ARGV_SOURCE_CODE_DIRECTORY" == "." ] ||
[ "$ARGV_SOURCE_CODE_DIRECTORY" == "./" ]
then
ARGV_SOURCE_CODE_DIRECTORY="$PWD"
fi
# Fairly ugly code that only passes environment variables into Docker when they're actually set
# see http://stackoverflow.com/a/13864829
# and http://mywiki.wooledge.org/BashFAQ/050
# and http://stackoverflow.com/a/7577209
DOCKER_ENVVARS=()
for COPYVAR in AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY ANALYTICS_SENTRY_TOKEN ANALYTICS_MIXPANEL_TOKEN CI; do
eval "if [ ! -z \${$COPYVAR+x} ]; then DOCKER_ENVVARS+=(\"--env\" \"$COPYVAR=\$$COPYVAR\"); fi"
done
# The SYS_ADMIN capability and FUSE host device declarations
# are needed to be able to build an AppImage
# The `-t` and TERM setup is needed to display coloured output.
docker run -t \
--env "TERM=xterm-256color" \
${DOCKER_ENVVARS[@]+"${DOCKER_ENVVARS[@]}"} \
--privileged \
--cap-add SYS_ADMIN \
--device /dev/fuse:/dev/fuse:mrw \
--volume "$ARGV_SOURCE_CODE_DIRECTORY:/etcher" \
"$IMAGE_ID" /bin/bash -c "cd /etcher && $ARGV_COMMAND"

View File

@ -19,14 +19,9 @@
const _ = require('lodash') const _ = require('lodash')
const m = require('mochainon') const m = require('mochainon')
const angular = require('angular') const angular = require('angular')
require('angular-mocks')
const utils = require('../../../lib/shared/utils') const utils = require('../../../lib/shared/utils')
describe('Browser: DriveSelector', function () { describe('Browser: DriveSelector', function () {
beforeEach(angular.mock.module(
require('../../../lib/gui/app/components/drive-selector/drive-selector')
))
describe('DriveSelectorController', function () { describe('DriveSelectorController', function () {
describe('.memoize()', function () { describe('.memoize()', function () {
it('should handle equal angular objects with different hashes', function () { it('should handle equal angular objects with different hashes', function () {

View File

@ -21,7 +21,6 @@ const _ = require('lodash')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const angular = require('angular') const angular = require('angular')
require('angular-mocks')
describe('Browser: SVGIcon', function () { describe('Browser: SVGIcon', function () {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(

View File

@ -18,7 +18,6 @@
const m = require('mochainon') const m = require('mochainon')
const angular = require('angular') const angular = require('angular')
require('angular-mocks')
describe('Browser: OSDropzone', function () { describe('Browser: OSDropzone', function () {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(

View File

@ -19,7 +19,6 @@
const m = require('mochainon') const m = require('mochainon')
const angular = require('angular') const angular = require('angular')
const electron = require('electron') const electron = require('electron')
require('angular-mocks')
describe('Browser: OSOpenExternal', function () { describe('Browser: OSOpenExternal', function () {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(

View File

@ -19,7 +19,6 @@
const m = require('mochainon') const m = require('mochainon')
const fs = require('fs') const fs = require('fs')
const angular = require('angular') const angular = require('angular')
require('angular-mocks')
describe('Browser: FinishPage', function () { describe('Browser: FinishPage', function () {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(

View File

@ -25,7 +25,6 @@ const angular = require('angular')
const flashState = require('../../../lib/gui/app/models/flash-state') const flashState = require('../../../lib/gui/app/models/flash-state')
const availableDrives = require('../../../lib/gui/app/models/available-drives') const availableDrives = require('../../../lib/gui/app/models/available-drives')
const selectionState = require('../../../lib/gui/app/models/selection-state') const selectionState = require('../../../lib/gui/app/models/selection-state')
require('angular-mocks')
// Mock HTML requires by reading from the file-system // Mock HTML requires by reading from the file-system
// eslint-disable-next-line node/no-deprecated-api // eslint-disable-next-line node/no-deprecated-api

View File

@ -18,7 +18,6 @@
const m = require('mochainon') const m = require('mochainon')
const angular = require('angular') const angular = require('angular')
require('angular-mocks')
const units = require('../../../lib/shared/units') const units = require('../../../lib/shared/units')
describe('Browser: ByteSize', function () { describe('Browser: ByteSize', function () {

View File

@ -19,7 +19,6 @@
const m = require('mochainon') const m = require('mochainon')
const angular = require('angular') const angular = require('angular')
const packageJSON = require('../../../package.json') const packageJSON = require('../../../package.json')
require('angular-mocks')
describe('Browser: ManifestBind', function () { describe('Browser: ManifestBind', function () {
beforeEach(angular.mock.module( beforeEach(angular.mock.module(

View File

@ -36,8 +36,7 @@ describe('Spectron', function () {
before('app:start', function () { before('app:start', function () {
app = new spectron.Application({ app = new spectron.Application({
path: entrypoint, path: entrypoint,
port: 9995, args: [ '--no-sandbox', '.' ]
args: [ '.' ]
}) })
return app.start() return app.start()

View File

@ -16,7 +16,6 @@
'use strict' 'use strict'
const _ = require('lodash')
const path = require('path') const path = require('path')
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin') const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin')
const nodeExternals = require('webpack-node-externals') const nodeExternals = require('webpack-node-externals')
@ -27,18 +26,17 @@ const commonConfig = {
// Minification breaks angular. // Minification breaks angular.
minimize: false minimize: false
}, },
target: 'electron-main',
module: { module: {
rules: [ rules: [
{ {
test: /\.jsx?$/, test: /\.jsx?$/,
include: [ path.resolve(__dirname, 'lib/gui') ], include: [ path.resolve(__dirname, 'lib', 'gui') ],
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
presets: [ presets: [
'@babel/preset-react', '@babel/preset-react',
[ '@babel/preset-env', { targets: { electron: '3' } } ] [ '@babel/preset-env', { targets: { electron: '6' } } ]
], ],
plugins: [ '@babel/plugin-proposal-function-bind' ], plugins: [ '@babel/plugin-proposal-function-bind' ],
cacheDirectory: true cacheDirectory: true
@ -47,15 +45,11 @@ const commonConfig = {
}, },
{ {
test: /\.html$/, test: /\.html$/,
include: [ path.resolve(__dirname, 'lib/gui/app') ], use: 'html-loader'
use: {
loader: 'html-loader'
}
}, },
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
use: 'ts-loader', use: 'ts-loader'
exclude: /node_modules/
} }
] ]
}, },
@ -66,92 +60,39 @@ const commonConfig = {
new SimpleProgressWebpackPlugin({ new SimpleProgressWebpackPlugin({
format: process.env.WEBPACK_PROGRESS || 'verbose' format: process.env.WEBPACK_PROGRESS || 'verbose'
}) })
] ],
externals: [
nodeExternals()
],
output: {
path: path.join(__dirname, 'generated'),
filename: '[name].js'
}
} }
const guiConfig = _.assign({ const guiConfig = {
...commonConfig,
target: 'electron-renderer',
node: { node: {
__dirname: true, __dirname: true,
__filename: true __filename: true
}, },
externals: [
nodeExternals(),
(context, request, callback) => {
// eslint-disable-next-line lodash/prefer-lodash-method
const absoluteContext = path.resolve(context)
const absoluteNodeModules = path.resolve('node_modules')
// We shouldn't rewrite any node_modules import paths
// eslint-disable-next-line lodash/prefer-lodash-method
if (!path.relative(absoluteNodeModules, absoluteContext).startsWith('..')) {
return callback()
}
// We want to keep the SDK code outside the GUI bundle.
// This piece of code allows us to run the GUI directly
// on the tree (for testing purposes) or inside a generated
// bundle (for production purposes), by translating
// relative require paths within the bundle.
if (/\/(sdk|shared)/i.test(request) || /package\.json$/.test(request)) {
const output = path.join(__dirname, 'generated')
const dirname = path.join(context, request)
const relative = path.relative(output, dirname)
return callback(null, `commonjs ${path.join('..', '..', relative)}`)
}
return callback()
}
],
entry: { entry: {
gui: path.join(__dirname, 'lib', 'gui', 'app', 'app.js') gui: path.join(__dirname, 'lib', 'gui', 'app', 'app.js')
},
output: {
path: path.join(__dirname, 'generated'),
filename: '[name].js'
} }
}, commonConfig) }
const etcherConfig = _.assign({ const etcherConfig = {
...commonConfig,
target: 'electron-main',
node: { node: {
__dirname: false, __dirname: false,
__filename: true __filename: true
}, },
externals: [
nodeExternals(),
(context, request, callback) => {
// eslint-disable-next-line lodash/prefer-lodash-method
const absoluteContext = path.resolve(context)
const absoluteNodeModules = path.resolve('node_modules')
// We shouldn't rewrite any node_modules import paths
// eslint-disable-next-line lodash/prefer-lodash-method
if (!path.relative(absoluteNodeModules, absoluteContext).startsWith('..')) {
return callback()
}
// We want to keep the SDK code outside the GUI bundle.
// This piece of code allows us to run the GUI directly
// on the tree (for testing purposes) or inside a generated
// bundle (for production purposes), by translating
// relative require paths within the bundle.
if (/\/shared/i.test(request) || /package\.json$/.test(request)) {
const output = path.join(__dirname, 'generated')
const dirname = path.join(context, request)
const relative = path.relative(output, dirname)
return callback(null, `commonjs ${path.join('..', 'lib', relative)}`)
}
return callback()
}
],
entry: { entry: {
etcher: path.join(__dirname, 'lib', 'gui', 'etcher.js') etcher: path.join(__dirname, 'lib', 'start.js')
},
output: {
path: path.join(__dirname, 'generated'),
filename: '[name].js'
} }
}, commonConfig) }
module.exports = [ module.exports = [
guiConfig, guiConfig,