mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 11:16:39 +00:00
Migrate build pipeline to Electron Forge
Change-type: minor
This commit is contained in:
parent
2cdf65b244
commit
bd33c5b092
2
.github/actions/test/action.yml
vendored
2
.github/actions/test/action.yml
vendored
@ -39,7 +39,7 @@ runs:
|
|||||||
|
|
||||||
npm run flowzone-preinstall-${runner_os}
|
npm run flowzone-preinstall-${runner_os}
|
||||||
npm ci
|
npm ci
|
||||||
npm run build
|
npm run package
|
||||||
npm run test-${runner_os}
|
npm run test-${runner_os}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
110
.gitignore
vendored
110
.gitignore
vendored
@ -1,41 +1,100 @@
|
|||||||
|
|
||||||
|
# -- ADD NEW ENTRIES AT THE END OF THE FILE ---
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
/logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
# Runtime data
|
# Runtime data
|
||||||
pids
|
pids
|
||||||
*.pid
|
*.pid
|
||||||
*.seed
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
/lib-cov
|
lib-cov
|
||||||
|
|
||||||
# Image stream output directory
|
|
||||||
/tests/image-stream/output
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
/coverage
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
# nyc test coverage
|
||||||
.grunt
|
.nyc_output
|
||||||
|
|
||||||
# node-waf configuration
|
# node-waf configuration
|
||||||
.lock-wscript
|
.lock-wscript
|
||||||
|
|
||||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
/build
|
build/Release
|
||||||
|
|
||||||
# Generated files
|
# Dependency directories
|
||||||
/generated
|
node_modules/
|
||||||
/binaries
|
jspm_packages/
|
||||||
|
|
||||||
# Dependency directory
|
# TypeScript v1 declaration files
|
||||||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
typings/
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Compiled Etcher releases
|
# TypeScript cache
|
||||||
/dist
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Webpack
|
||||||
|
.webpack/
|
||||||
|
|
||||||
|
# Vite
|
||||||
|
.vite/
|
||||||
|
|
||||||
|
# Electron-Forge
|
||||||
|
out/
|
||||||
|
|
||||||
|
# ---- Do not modify entries above this line ----
|
||||||
|
|
||||||
# Certificates
|
# Certificates
|
||||||
*.spc
|
*.spc
|
||||||
@ -45,16 +104,17 @@ node_modules
|
|||||||
*.crt
|
*.crt
|
||||||
*.pem
|
*.pem
|
||||||
|
|
||||||
# OSX files
|
# Secrets
|
||||||
|
|
||||||
.DS_Store
|
|
||||||
|
|
||||||
# VSCode files
|
|
||||||
|
|
||||||
.vscode
|
|
||||||
.gitsecret/keys/random_seed
|
.gitsecret/keys/random_seed
|
||||||
!*.secret
|
!*.secret
|
||||||
secrets/APPLE_SIGNING_PASSWORD.txt
|
secrets/APPLE_SIGNING_PASSWORD.txt
|
||||||
secrets/WINDOWS_SIGNING_PASSWORD.txt
|
secrets/WINDOWS_SIGNING_PASSWORD.txt
|
||||||
secrets/XCODE_APP_LOADER_PASSWORD.txt
|
secrets/XCODE_APP_LOADER_PASSWORD.txt
|
||||||
secrets/WINDOWS_SIGNING.pfx
|
secrets/WINDOWS_SIGNING.pfx
|
||||||
|
|
||||||
|
# Image stream output directory
|
||||||
|
/tests/image-stream/output
|
||||||
|
|
||||||
|
#local development
|
||||||
|
.yalc
|
||||||
|
yalc.lock
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -1,4 +0,0 @@
|
|||||||
[submodule "scripts/resin"]
|
|
||||||
path = scripts/resin
|
|
||||||
url = https://github.com/balena-io/scripts.git
|
|
||||||
branch = master
|
|
152
Makefile
152
Makefile
@ -1,152 +0,0 @@
|
|||||||
# ---------------------------------------------------------------------
|
|
||||||
# Build configuration
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
RESIN_SCRIPTS ?= ./scripts/resin
|
|
||||||
export NPM_VERSION ?= 6.14.8
|
|
||||||
S3_BUCKET = artifacts.ci.balena-cloud.com
|
|
||||||
|
|
||||||
# This directory will be completely deleted by the `clean` rule
|
|
||||||
BUILD_DIRECTORY ?= dist
|
|
||||||
|
|
||||||
BUILD_TEMPORARY_DIRECTORY = $(BUILD_DIRECTORY)/.tmp
|
|
||||||
|
|
||||||
$(BUILD_DIRECTORY):
|
|
||||||
mkdir $@
|
|
||||||
|
|
||||||
$(BUILD_TEMPORARY_DIRECTORY): | $(BUILD_DIRECTORY)
|
|
||||||
mkdir $@
|
|
||||||
|
|
||||||
SHELL := /bin/bash
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
# Operating system and architecture detection
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
# http://stackoverflow.com/a/12099167
|
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
PLATFORM = win32
|
|
||||||
|
|
||||||
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
|
|
||||||
HOST_ARCH = x64
|
|
||||||
else
|
|
||||||
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
|
||||||
HOST_ARCH = x64
|
|
||||||
endif
|
|
||||||
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
|
|
||||||
HOST_ARCH = x86
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
ifeq ($(shell uname -s),Linux)
|
|
||||||
PLATFORM = linux
|
|
||||||
|
|
||||||
ifeq ($(shell uname -m),x86_64)
|
|
||||||
HOST_ARCH = x64
|
|
||||||
endif
|
|
||||||
ifneq ($(filter %86,$(shell uname -m)),)
|
|
||||||
HOST_ARCH = x86
|
|
||||||
endif
|
|
||||||
ifeq ($(shell uname -m),armv7l)
|
|
||||||
HOST_ARCH = armv7hf
|
|
||||||
endif
|
|
||||||
ifeq ($(shell uname -m),aarch64)
|
|
||||||
HOST_ARCH = aarch64
|
|
||||||
endif
|
|
||||||
ifeq ($(shell uname -m),armv8)
|
|
||||||
HOST_ARCH = aarch64
|
|
||||||
endif
|
|
||||||
ifeq ($(shell uname -m),arm64)
|
|
||||||
HOST_ARCH = aarch64
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
ifeq ($(shell uname -s),Darwin)
|
|
||||||
PLATFORM = darwin
|
|
||||||
|
|
||||||
ifeq ($(shell uname -m),x86_64)
|
|
||||||
HOST_ARCH = x64
|
|
||||||
endif
|
|
||||||
ifeq ($(shell uname -m),arm64)
|
|
||||||
HOST_ARCH = aarch64
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifndef PLATFORM
|
|
||||||
$(error We could not detect your host platform)
|
|
||||||
endif
|
|
||||||
ifndef HOST_ARCH
|
|
||||||
$(error We could not detect your host architecture)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Default to host architecture. You can override by doing:
|
|
||||||
#
|
|
||||||
# make <target> TARGET_ARCH=<arch>
|
|
||||||
#
|
|
||||||
TARGET_ARCH ?= $(HOST_ARCH)
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
# Electron
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
electron-develop:
|
|
||||||
git submodule update --init && \
|
|
||||||
npm ci && \
|
|
||||||
npm run webpack
|
|
||||||
|
|
||||||
electron-test:
|
|
||||||
$(RESIN_SCRIPTS)/electron/test.sh \
|
|
||||||
-b $(shell pwd) \
|
|
||||||
-s $(PLATFORM)
|
|
||||||
|
|
||||||
assets/dmg/background.tiff: assets/dmg/background.png assets/dmg/background@2x.png
|
|
||||||
tiffutil -cathidpicheck $^ -out $@
|
|
||||||
|
|
||||||
electron-build: assets/dmg/background.tiff | $(BUILD_TEMPORARY_DIRECTORY)
|
|
||||||
$(RESIN_SCRIPTS)/electron/build.sh \
|
|
||||||
-b $(shell pwd) \
|
|
||||||
-r $(TARGET_ARCH) \
|
|
||||||
-s $(PLATFORM) \
|
|
||||||
-v production \
|
|
||||||
-n $(BUILD_TEMPORARY_DIRECTORY)/npm
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
# Phony targets
|
|
||||||
# ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
TARGETS = \
|
|
||||||
help \
|
|
||||||
info \
|
|
||||||
lint \
|
|
||||||
test \
|
|
||||||
clean \
|
|
||||||
distclean \
|
|
||||||
electron-develop \
|
|
||||||
electron-test \
|
|
||||||
electron-build
|
|
||||||
|
|
||||||
.PHONY: $(TARGETS)
|
|
||||||
|
|
||||||
lint:
|
|
||||||
npm run lint
|
|
||||||
|
|
||||||
test:
|
|
||||||
npm run test
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo "Available targets: $(TARGETS)"
|
|
||||||
|
|
||||||
info:
|
|
||||||
@echo "Platform : $(PLATFORM)"
|
|
||||||
@echo "Host arch : $(HOST_ARCH)"
|
|
||||||
@echo "Target arch : $(TARGET_ARCH)"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf $(BUILD_DIRECTORY)
|
|
||||||
|
|
||||||
distclean: clean
|
|
||||||
rm -rf node_modules
|
|
||||||
rm -rf dist
|
|
||||||
rm -rf generated
|
|
||||||
rm -rf $(BUILD_TEMPORARY_DIRECTORY)
|
|
||||||
|
|
||||||
.DEFAULT_GOAL = help
|
|
31
afterPack.js
31
afterPack.js
@ -1,31 +0,0 @@
|
|||||||
'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({trimTrailingNewline: false})`
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Resolve symlinks. Warning, readlink -f doesn't work on MacOS/BSD
|
|
||||||
script_dir="$(dirname "$(readlink -f "\${BASH_SOURCE[0]}")")"
|
|
||||||
|
|
||||||
if [[ $EUID -ne 0 ]] || [[ $ELECTRON_RUN_AS_NODE ]]; then
|
|
||||||
"\${script_dir}"/${context.packager.executableName}.bin "$@"
|
|
||||||
else
|
|
||||||
"\${script_dir}"/${context.packager.executableName}.bin "$@" --no-sandbox
|
|
||||||
fi
|
|
||||||
`
|
|
||||||
)
|
|
||||||
cp.execFileSync('chmod', ['+x', scriptPath])
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
boolen->boolean
|
|
||||||
aknowledge->acknowledge
|
|
||||||
seleted->selected
|
|
||||||
reming->remind
|
|
||||||
locl->local
|
|
||||||
subsribe->subscribe
|
|
||||||
unsubsribe->unsubscribe
|
|
||||||
calcluate->calculate
|
|
||||||
dictionaty->dictionary
|
|
@ -1,110 +0,0 @@
|
|||||||
# https://www.electron.build/configuration/configuration
|
|
||||||
appId: io.balena.etcher
|
|
||||||
copyright: Copyright 2016-2023 Balena Ltd
|
|
||||||
productName: balenaEtcher
|
|
||||||
afterPack: ./afterPack.js
|
|
||||||
afterSign: ./afterSignHook.js
|
|
||||||
asar: false
|
|
||||||
files:
|
|
||||||
- generated
|
|
||||||
- lib/shared/catalina-sudo/sudo-askpass.osascript-zh.js
|
|
||||||
- lib/shared/catalina-sudo/sudo-askpass.osascript-en.js
|
|
||||||
mac:
|
|
||||||
icon: assets/icon.icns
|
|
||||||
category: public.app-category.developer-tools
|
|
||||||
hardenedRuntime: true
|
|
||||||
entitlements: "entitlements.mac.plist"
|
|
||||||
entitlementsInherit: "entitlements.mac.plist"
|
|
||||||
artifactName: "${productName}-${version}.${ext}"
|
|
||||||
target:
|
|
||||||
- dmg
|
|
||||||
dmg:
|
|
||||||
background: assets/dmg/background.tiff
|
|
||||||
icon: assets/icon.icns
|
|
||||||
iconSize: 110
|
|
||||||
contents:
|
|
||||||
- x: 140
|
|
||||||
y: 225
|
|
||||||
- x: 415
|
|
||||||
y: 225
|
|
||||||
type: link
|
|
||||||
path: /Applications
|
|
||||||
window:
|
|
||||||
width: 540
|
|
||||||
height: 405
|
|
||||||
win:
|
|
||||||
icon: assets/icon.ico
|
|
||||||
target:
|
|
||||||
- zip
|
|
||||||
- nsis
|
|
||||||
- portable
|
|
||||||
nsis:
|
|
||||||
oneClick: true
|
|
||||||
runAfterFinish: true
|
|
||||||
installerIcon: assets/icon.ico
|
|
||||||
uninstallerIcon: assets/icon.ico
|
|
||||||
deleteAppDataOnUninstall: true
|
|
||||||
license: LICENSE
|
|
||||||
artifactName: "${productName}-Setup-${version}.${ext}"
|
|
||||||
portable:
|
|
||||||
artifactName: "${productName}-Portable-${version}.${ext}"
|
|
||||||
requestExecutionLevel: user
|
|
||||||
linux:
|
|
||||||
icon: assets/iconset
|
|
||||||
target:
|
|
||||||
- AppImage
|
|
||||||
- rpm
|
|
||||||
- deb
|
|
||||||
category: Utility
|
|
||||||
packageCategory: utils
|
|
||||||
executableName: balena-etcher
|
|
||||||
synopsis: balenaEtcher 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.
|
|
||||||
appImage:
|
|
||||||
artifactName: ${productName}-${version}-${env.ELECTRON_BUILDER_ARCHITECTURE}.${ext}
|
|
||||||
deb:
|
|
||||||
priority: optional
|
|
||||||
compression: bzip2
|
|
||||||
depends:
|
|
||||||
- gconf-service
|
|
||||||
- gconf2
|
|
||||||
- libasound2
|
|
||||||
- libatk1.0-0
|
|
||||||
- libc6
|
|
||||||
- libcairo2
|
|
||||||
- libcups2
|
|
||||||
- libdbus-1-3
|
|
||||||
- libexpat1
|
|
||||||
- libfontconfig1
|
|
||||||
- libfreetype6
|
|
||||||
- libgbm1
|
|
||||||
- libgcc1
|
|
||||||
- libgconf-2-4
|
|
||||||
- libgdk-pixbuf2.0-0
|
|
||||||
- libglib2.0-0
|
|
||||||
- libgtk-3-0
|
|
||||||
- liblzma5
|
|
||||||
- libnotify4
|
|
||||||
- libnspr4
|
|
||||||
- libnss3
|
|
||||||
- libpango1.0-0 | libpango-1.0-0
|
|
||||||
- libstdc++6
|
|
||||||
- libx11-6
|
|
||||||
- libxcomposite1
|
|
||||||
- libxcursor1
|
|
||||||
- libxdamage1
|
|
||||||
- libxext6
|
|
||||||
- libxfixes3
|
|
||||||
- libxi6
|
|
||||||
- libxrandr2
|
|
||||||
- libxrender1
|
|
||||||
- libxss1
|
|
||||||
- libxtst6
|
|
||||||
- polkit-1-auth-agent | policykit-1-gnome | polkit-kde-1
|
|
||||||
afterInstall: "./after-install.tpl"
|
|
||||||
rpm:
|
|
||||||
depends:
|
|
||||||
- util-linux
|
|
||||||
protocols:
|
|
||||||
name: etcher
|
|
||||||
schemes:
|
|
||||||
- etcher
|
|
49
forge.config.ts
Normal file
49
forge.config.ts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import type { ForgeConfig } from '@electron-forge/shared-types';
|
||||||
|
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
|
||||||
|
import { MakerZIP } from '@electron-forge/maker-zip';
|
||||||
|
import { MakerDeb } from '@electron-forge/maker-deb';
|
||||||
|
import { MakerRpm } from '@electron-forge/maker-rpm';
|
||||||
|
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
|
||||||
|
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
|
||||||
|
|
||||||
|
import { mainConfig, rendererConfig } from './webpack.config';
|
||||||
|
|
||||||
|
const config: ForgeConfig = {
|
||||||
|
packagerConfig: {
|
||||||
|
asar: true,
|
||||||
|
icon: './assets/icon',
|
||||||
|
extraResource: [
|
||||||
|
'lib/shared/catalina-sudo/sudo-askpass.osascript-zh.js',
|
||||||
|
'lib/shared/catalina-sudo/sudo-askpass.osascript-en.js',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
rebuildConfig: {},
|
||||||
|
makers: [
|
||||||
|
new MakerSquirrel({}),
|
||||||
|
new MakerZIP({}, ['darwin']),
|
||||||
|
new MakerRpm({}),
|
||||||
|
new MakerDeb({}),
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
new AutoUnpackNativesPlugin({}),
|
||||||
|
new WebpackPlugin({
|
||||||
|
mainConfig,
|
||||||
|
renderer: {
|
||||||
|
config: rendererConfig,
|
||||||
|
nodeIntegration: true,
|
||||||
|
entryPoints: [
|
||||||
|
{
|
||||||
|
html: './lib/gui/app/index.html',
|
||||||
|
js: './lib/gui/app/renderer.ts',
|
||||||
|
name: 'main_window',
|
||||||
|
preload: {
|
||||||
|
js: './lib/gui/app/preload.ts',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>balenaEtcher</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="index.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main id="main"></main>
|
|
||||||
<script src="http://localhost:3030/gui.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -3,10 +3,8 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>balenaEtcher</title>
|
<title>balenaEtcher</title>
|
||||||
<link rel="stylesheet" type="text/css" href="index.css">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main id="main"></main>
|
<main id="main"></main>
|
||||||
<script src="gui.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
2
lib/gui/app/preload.ts
Normal file
2
lib/gui/app/preload.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// See the Electron documentation for details on how to use preload scripts:
|
||||||
|
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
@ -6,10 +6,4 @@ import { ipcRenderer } from 'electron';
|
|||||||
|
|
||||||
ipcRenderer.send('change-lng', langParser());
|
ipcRenderer.send('change-lng', langParser());
|
||||||
|
|
||||||
if (module.hot) {
|
|
||||||
module.hot.accept('./app', () => {
|
|
||||||
main();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
|
||||||
|
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
|
||||||
|
// whether you're running in development or production).
|
||||||
|
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
|
||||||
|
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
|
||||||
|
|
||||||
import * as electron from 'electron';
|
import * as electron from 'electron';
|
||||||
import * as remoteMain from '@electron/remote/main';
|
import * as remoteMain from '@electron/remote/main';
|
||||||
import { autoUpdater } from 'electron-updater';
|
import { autoUpdater } from 'electron-updater';
|
||||||
@ -176,6 +182,7 @@ async function createMainWindow() {
|
|||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
zoomFactor: width / defaultWidth,
|
zoomFactor: width / defaultWidth,
|
||||||
|
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -199,13 +206,7 @@ async function createMainWindow() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.loadURL(
|
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
|
||||||
`file://${path.join(
|
|
||||||
'/',
|
|
||||||
...__dirname.split(path.sep).map(encodeURIComponent),
|
|
||||||
'index.html',
|
|
||||||
)}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
const page = mainWindow.webContents;
|
const page = mainWindow.webContents;
|
||||||
remoteMain.enable(page);
|
remoteMain.enable(page);
|
||||||
|
@ -19,7 +19,6 @@ import { join } from 'path';
|
|||||||
import { env } from 'process';
|
import { env } from 'process';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
import { getAppPath } from '../get-app-path';
|
|
||||||
import { supportedLocales } from '../../gui/app/i18n';
|
import { supportedLocales } from '../../gui/app/i18n';
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
@ -27,6 +26,15 @@ const execFileAsync = promisify(execFile);
|
|||||||
const SUCCESSFUL_AUTH_MARKER = 'AUTHENTICATION SUCCEEDED';
|
const SUCCESSFUL_AUTH_MARKER = 'AUTHENTICATION SUCCEEDED';
|
||||||
const EXPECTED_SUCCESSFUL_AUTH_MARKER = `${SUCCESSFUL_AUTH_MARKER}\n`;
|
const EXPECTED_SUCCESSFUL_AUTH_MARKER = `${SUCCESSFUL_AUTH_MARKER}\n`;
|
||||||
|
|
||||||
|
function getAskPassScriptPath(lang: string): string {
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
// Force webpack's hand to bundle the script.
|
||||||
|
return require.resolve(`./sudo-askpass.osascript-${lang}.js`);
|
||||||
|
}
|
||||||
|
// Otherwise resolve the script relative to resources path.
|
||||||
|
return join(process.resourcesPath, `sudo-askpass.osascript-${lang}.js`);
|
||||||
|
}
|
||||||
|
|
||||||
export async function sudo(
|
export async function sudo(
|
||||||
command: string,
|
command: string,
|
||||||
): Promise<{ cancelled: boolean; stdout?: string; stderr?: string }> {
|
): Promise<{ cancelled: boolean; stdout?: string; stderr?: string }> {
|
||||||
@ -47,11 +55,7 @@ export async function sudo(
|
|||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
env: {
|
env: {
|
||||||
PATH: env.PATH,
|
PATH: env.PATH,
|
||||||
SUDO_ASKPASS: join(
|
SUDO_ASKPASS: getAskPassScriptPath(lang),
|
||||||
getAppPath(),
|
|
||||||
__dirname,
|
|
||||||
`sudo-askpass.osascript-${lang}.js`,
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
export function getAppPath(): string {
|
|
||||||
return (
|
|
||||||
(require('electron').app || require('@electron/remote').app)
|
|
||||||
.getAppPath()
|
|
||||||
// With macOS universal builds, getAppPath() returns the path to an app.asar file containing an index.js file which will
|
|
||||||
// include the app-x64 or app-arm64 folder depending on the arch.
|
|
||||||
// We don't care about the app.asar file, we want the actual folder.
|
|
||||||
.replace(/\.asar$/, () =>
|
|
||||||
process.platform === 'darwin' ? '-' + process.arch : '',
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
11651
npm-shrinkwrap.json
generated
11651
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
101
package.json
101
package.json
@ -4,7 +4,7 @@
|
|||||||
"displayName": "balenaEtcher",
|
"displayName": "balenaEtcher",
|
||||||
"version": "1.18.14",
|
"version": "1.18.14",
|
||||||
"packageType": "local",
|
"packageType": "local",
|
||||||
"main": "generated/etcher.js",
|
"main": ".webpack/main",
|
||||||
"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",
|
||||||
@ -13,7 +13,6 @@
|
|||||||
"url": "git@github.com:balena-io/etcher.git"
|
"url": "git@github.com:balena-io/etcher.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run webpack && npm run build:sidecar",
|
|
||||||
"build:rebuild-mountutils": "cd node_modules/mountutils && npm rebuild",
|
"build:rebuild-mountutils": "cd node_modules/mountutils && npm rebuild",
|
||||||
"build:sidecar": "npm run build:rebuild-mountutils && tsc --project tsconfig.sidecar.json && pkg build/util/api.js -c pkg-sidecar.json --target node18 --output generated/etcher-util",
|
"build:sidecar": "npm run build:rebuild-mountutils && tsc --project tsconfig.sidecar.json && pkg build/util/api.js -c pkg-sidecar.json --target node18 --output generated/etcher-util",
|
||||||
"flowzone-preinstall-linux": "sudo apt-get update && sudo apt-get install -y xvfb libudev-dev && cat < electron-builder.yml | yq e .deb.depends[] - | xargs -L1 echo | sed 's/|//g' | xargs -L1 sudo apt-get --ignore-missing install || true",
|
"flowzone-preinstall-linux": "sudo apt-get update && sudo apt-get install -y xvfb libudev-dev && cat < electron-builder.yml | yq e .deb.depends[] - | xargs -L1 echo | sed 's/|//g' | xargs -L1 sudo apt-get --ignore-missing install || true",
|
||||||
@ -21,19 +20,17 @@
|
|||||||
"flowzone-preinstall-windows": "npx node-gyp install",
|
"flowzone-preinstall-windows": "npx node-gyp install",
|
||||||
"flowzone-preinstall": "npm run flowzone-preinstall-linux",
|
"flowzone-preinstall": "npm run flowzone-preinstall-linux",
|
||||||
"lint-css": "prettier --write lib/**/*.css",
|
"lint-css": "prettier --write lib/**/*.css",
|
||||||
"lint-ts": "balena-lint --fix --typescript typings lib tests scripts/clean-shrinkwrap.ts webpack.config.ts",
|
"lint-ts": "balena-lint --fix --typescript typings lib tests forge.config.ts webpack.config.ts",
|
||||||
"lint": "npm run lint-ts && npm run lint-css",
|
"lint": "npm run lint-ts && npm run lint-css",
|
||||||
"postinstall": "electron-rebuild -t prod,dev,optional",
|
|
||||||
"sanity-checks": "bash scripts/ci/ensure-all-file-extensions-in-gitattributes.sh",
|
|
||||||
"start": "./node_modules/.bin/electron .",
|
|
||||||
"test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
|
"test-gui": "electron-mocha --recursive --reporter spec --window-config tests/gui/window-config.json --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox --renderer tests/gui/**/*.ts",
|
||||||
"test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts",
|
"test-shared": "electron-mocha --recursive --reporter spec --require ts-node/register/transpile-only --require-main tests/gui/allow-renderer-process-reuse.ts --full-trace --no-sandbox tests/shared/**/*.ts",
|
||||||
"test-macos": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks",
|
"test-windows": "npm run lint && npm run test-gui && npm run test-shared",
|
||||||
"test-linux": "npm run lint && xvfb-run --auto-servernum npm run test-gui && xvfb-run --auto-servernum npm run test-shared && npm run sanity-checks",
|
"test-macos": "npm run lint && npm run test-gui && npm run test-shared",
|
||||||
"test-windows": "npm run lint && npm run test-gui && npm run test-shared && npm run sanity-checks",
|
"test-linux": "npm run lint && xvfb-run --auto-servernum npm run test-gui && xvfb-run --auto-servernum npm run test-shared",
|
||||||
"test": "echo npm run test-{linux,windows,macos}",
|
"test": "echo npm run test-{linux,windows,macos}",
|
||||||
"watch": "webpack serve --no-optimization-minimize --config ./webpack.dev.config.ts",
|
"package": "electron-forge package",
|
||||||
"webpack": "webpack"
|
"start": "electron-forge start",
|
||||||
|
"make": "electron-forge make"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
@ -50,13 +47,44 @@
|
|||||||
},
|
},
|
||||||
"author": "Balena Ltd. <hello@balena.io>",
|
"author": "Balena Ltd. <hello@balena.io>",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"dependencies": {
|
||||||
"@babel/register": "^7.22.15",
|
|
||||||
"@balena/lint": "5.4.2",
|
|
||||||
"@balena/sudo-prompt": "9.2.1-workaround-windows-amperstand-in-username-0849e215b947987a643fe5763902aea201255534",
|
"@balena/sudo-prompt": "9.2.1-workaround-windows-amperstand-in-username-0849e215b947987a643fe5763902aea201255534",
|
||||||
"@electron/remote": "^2.0.9",
|
"@electron/remote": "^2.0.9",
|
||||||
"@fortawesome/fontawesome-free": "5.15.4",
|
"@fortawesome/fontawesome-free": "5.15.4",
|
||||||
"@sentry/electron": "^4.1.2",
|
"@sentry/electron": "^4.1.2",
|
||||||
|
"analytics-client": "^2.0.1",
|
||||||
|
"axios": "^0.27.2",
|
||||||
|
"d3": "4.13.0",
|
||||||
|
"debug": "4.3.4",
|
||||||
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
|
"electron-updater": "5.3.0",
|
||||||
|
"etcher-sdk": "8.3.1",
|
||||||
|
"i18next": "21.10.0",
|
||||||
|
"immutable": "3.8.2",
|
||||||
|
"lodash": "4.17.21",
|
||||||
|
"node-ipc": "9.2.1",
|
||||||
|
"outdent": "0.8.0",
|
||||||
|
"path-is-inside": "1.0.2",
|
||||||
|
"pretty-bytes": "5.6.0",
|
||||||
|
"react": "16.8.5",
|
||||||
|
"react-dom": "16.8.5",
|
||||||
|
"react-i18next": "11.18.6",
|
||||||
|
"redux": "4.2.0",
|
||||||
|
"rendition": "19.3.2",
|
||||||
|
"semver": "7.3.8",
|
||||||
|
"styled-components": "5.3.6",
|
||||||
|
"sys-class-rgb-led": "3.0.1",
|
||||||
|
"uuid": "8.3.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@balena/lint": "5.4.2",
|
||||||
|
"@electron-forge/cli": "6.4.2",
|
||||||
|
"@electron-forge/maker-deb": "6.4.2",
|
||||||
|
"@electron-forge/maker-rpm": "6.4.2",
|
||||||
|
"@electron-forge/maker-squirrel": "6.4.2",
|
||||||
|
"@electron-forge/maker-zip": "6.4.2",
|
||||||
|
"@electron-forge/plugin-auto-unpack-natives": "6.4.2",
|
||||||
|
"@electron-forge/plugin-webpack": "6.4.2",
|
||||||
"@svgr/webpack": "5.5.0",
|
"@svgr/webpack": "5.5.0",
|
||||||
"@types/chai": "4.3.4",
|
"@types/chai": "4.3.4",
|
||||||
"@types/copy-webpack-plugin": "6.4.3",
|
"@types/copy-webpack-plugin": "6.4.3",
|
||||||
@ -69,62 +97,29 @@
|
|||||||
"@types/react-dom": "16.9.17",
|
"@types/react-dom": "16.9.17",
|
||||||
"@types/semver": "7.3.13",
|
"@types/semver": "7.3.13",
|
||||||
"@types/sinon": "9.0.11",
|
"@types/sinon": "9.0.11",
|
||||||
"@types/terser-webpack-plugin": "5.0.4",
|
|
||||||
"@types/tmp": "0.2.3",
|
"@types/tmp": "0.2.3",
|
||||||
"@types/webpack-node-externals": "2.5.3",
|
"@vercel/webpack-asset-relocator-loader": "1.7.3",
|
||||||
"analytics-client": "^2.0.1",
|
|
||||||
"axios": "^0.27.2",
|
|
||||||
"chai": "4.3.7",
|
"chai": "4.3.7",
|
||||||
"copy-webpack-plugin": "7.0.0",
|
|
||||||
"css-loader": "5.2.7",
|
"css-loader": "5.2.7",
|
||||||
"d3": "4.13.0",
|
"electron": "25.8.2",
|
||||||
"debug": "4.3.4",
|
|
||||||
"electron": "^25.8.2",
|
|
||||||
"electron-builder": "^23.6.0",
|
|
||||||
"electron-mocha": "^11.0.2",
|
"electron-mocha": "^11.0.2",
|
||||||
"electron-notarize": "1.2.2",
|
|
||||||
"electron-rebuild": "^3.2.9",
|
|
||||||
"electron-updater": "5.3.0",
|
|
||||||
"esbuild-loader": "2.20.0",
|
|
||||||
"etcher-sdk": "8.3.1",
|
|
||||||
"file-loader": "6.2.0",
|
"file-loader": "6.2.0",
|
||||||
"husky": "4.3.8",
|
"husky": "4.3.8",
|
||||||
"i18next": "21.10.0",
|
|
||||||
"immutable": "3.8.2",
|
|
||||||
"lint-staged": "10.5.4",
|
"lint-staged": "10.5.4",
|
||||||
"lodash": "4.17.21",
|
|
||||||
"mini-css-extract-plugin": "1.6.2",
|
"mini-css-extract-plugin": "1.6.2",
|
||||||
"mocha": "^9.1.1",
|
"mocha": "^9.1.1",
|
||||||
"native-addon-loader": "2.0.1",
|
"native-addon-loader": "2.0.1",
|
||||||
"node-ipc": "9.2.1",
|
"node-loader": "^2.0.0",
|
||||||
"omit-deep-lodash": "1.1.7",
|
"omit-deep-lodash": "1.1.7",
|
||||||
"outdent": "0.8.0",
|
|
||||||
"path-is-inside": "1.0.2",
|
|
||||||
"pkg": "^5.8.1",
|
"pkg": "^5.8.1",
|
||||||
"pnp-webpack-plugin": "1.7.0",
|
|
||||||
"pretty-bytes": "5.6.0",
|
|
||||||
"react": "16.8.5",
|
|
||||||
"react-dom": "16.8.5",
|
|
||||||
"react-i18next": "11.18.6",
|
|
||||||
"redux": "4.2.0",
|
|
||||||
"rendition": "19.3.2",
|
|
||||||
"semver": "7.3.8",
|
|
||||||
"simple-progress-webpack-plugin": "1.1.2",
|
|
||||||
"sinon": "9.2.4",
|
"sinon": "9.2.4",
|
||||||
"string-replace-loader": "3.1.0",
|
"string-replace-loader": "3.1.0",
|
||||||
"style-loader": "2.0.0",
|
"style-loader": "2.0.0",
|
||||||
"styled-components": "5.3.6",
|
"ts-loader": "^9.5.0",
|
||||||
"sys-class-rgb-led": "3.0.1",
|
"ts-node": "^10.9.1",
|
||||||
"terser-webpack-plugin": "5.3.6",
|
|
||||||
"ts-loader": "8.4.0",
|
|
||||||
"ts-node": "9.1.1",
|
|
||||||
"tslib": "2.4.1",
|
"tslib": "2.4.1",
|
||||||
"typescript": "4.4.4",
|
"typescript": "4.4.4",
|
||||||
"url-loader": "4.1.1",
|
"url-loader": "4.1.1"
|
||||||
"uuid": "8.3.2",
|
|
||||||
"webpack": "5.75.0",
|
|
||||||
"webpack-cli": "4.10.0",
|
|
||||||
"webpack-dev-server": "4.11.1"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18 <20"
|
"node": ">=18 <20"
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
awscli==1.27.28
|
|
||||||
shyaml==0.6.2
|
|
@ -1,52 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
###
|
|
||||||
# Copyright 2017 balena.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
|
|
||||||
|
|
||||||
# Read list of wildcards from .gitattributes
|
|
||||||
wildcards=()
|
|
||||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
||||||
if [[ -n "$line" ]]; then
|
|
||||||
if [[ ! "$line" =~ "^#" ]]; then
|
|
||||||
filetype=$(echo "$line" | cut -d ' ' -f 2)
|
|
||||||
if [[ "$filetype" == "text" ]] || [[ "$filetype" == "binary" ]]; then
|
|
||||||
wildcards+=("$(echo "$line" | cut -d ' ' -f 1)")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done < .gitattributes
|
|
||||||
|
|
||||||
# Verify those wildcards against all files stored in the repo
|
|
||||||
git ls-tree -r HEAD | while IFS='' read line; do
|
|
||||||
if [[ "$(echo $line | cut -d ' ' -f 2)" == "blob" ]]; then
|
|
||||||
# the cut delimiter in the line below is actually a tab character, not a space
|
|
||||||
filename=$(basename $(echo "$line" | cut -d ' ' -f 2))
|
|
||||||
found_match=0
|
|
||||||
for wildcard in "${wildcards[@]}"; do
|
|
||||||
if [[ "$filename" = $wildcard ]]; then
|
|
||||||
found_match=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [[ $found_match -eq 0 ]]; then
|
|
||||||
echo "No wildcards match $filename"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
* This script is in charge of cleaning the `shrinkwrap` file.
|
|
||||||
*
|
|
||||||
* `npm shrinkwrap` has a bug where it will add optional dependencies
|
|
||||||
* to `npm-shrinkwrap.json`, therefore causing errors if these optional
|
|
||||||
* dependendencies are platform dependent and you then try to build
|
|
||||||
* the project in another platform.
|
|
||||||
*
|
|
||||||
* As a workaround, we keep a list of platform dependent dependencies in
|
|
||||||
* the `platformSpecificDependencies` property of `package.json`,
|
|
||||||
* and manually remove them from `npm-shrinkwrap.json` if they exist.
|
|
||||||
*
|
|
||||||
* See: https://github.com/npm/npm/issues/2679
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { writeFile } from 'fs';
|
|
||||||
import * as omit from 'omit-deep-lodash';
|
|
||||||
import * as path from 'path';
|
|
||||||
import { promisify } from 'util';
|
|
||||||
|
|
||||||
import * as shrinkwrap from '../npm-shrinkwrap.json';
|
|
||||||
import * as packageInfo from '../package.json';
|
|
||||||
|
|
||||||
const writeFileAsync = promisify(writeFile);
|
|
||||||
|
|
||||||
const JSON_INDENT = 2;
|
|
||||||
const SHRINKWRAP_FILENAME = path.join(__dirname, '..', 'npm-shrinkwrap.json');
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
try {
|
|
||||||
const cleaned = omit(shrinkwrap, packageInfo.platformSpecificDependencies);
|
|
||||||
for (const item of Object.values(cleaned.dependencies)) {
|
|
||||||
// @ts-ignore
|
|
||||||
item.dev = true;
|
|
||||||
}
|
|
||||||
await writeFileAsync(
|
|
||||||
SHRINKWRAP_FILENAME,
|
|
||||||
JSON.stringify(cleaned, null, JSON_INDENT),
|
|
||||||
);
|
|
||||||
} catch (error: any) {
|
|
||||||
console.log(`[ERROR] Couldn't write shrinkwrap file: ${error.stack}`);
|
|
||||||
process.exitCode = 1;
|
|
||||||
}
|
|
||||||
console.log(
|
|
||||||
`[OK] Wrote shrinkwrap file to ${path.relative(
|
|
||||||
__dirname,
|
|
||||||
SHRINKWRAP_FILENAME,
|
|
||||||
)}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 8dfa21cfc23b1dbc0eaa22b5dbdf1f5c796b0c2c
|
|
@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"strict": true,
|
|
||||||
"noUnusedLocals": true,
|
|
||||||
"noUnusedParameters": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"module": "es2015",
|
|
||||||
"target": "es2019",
|
|
||||||
"jsx": "react",
|
|
||||||
"typeRoots": ["./node_modules/@types", "./typings"],
|
|
||||||
"importHelpers": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"lib": ["dom", "esnext"],
|
|
||||||
"declaration": true,
|
|
||||||
"declarationMap": true,
|
|
||||||
"pretty": true,
|
|
||||||
"sourceMap": true,
|
|
||||||
"baseUrl": "./src",
|
|
||||||
"noImplicitReturns": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"allowJs": true
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"lib/**/*.ts",
|
|
||||||
"node_modules/electron/**/*.d.ts"
|
|
||||||
]
|
|
||||||
}
|
|
1
typings/pnp-webpack-plugin/index.d.ts
vendored
1
typings/pnp-webpack-plugin/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
declare module 'pnp-webpack-plugin';
|
|
1
typings/resin-corvus/index.d.ts
vendored
1
typings/resin-corvus/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
declare module 'resin-corvus/browser';
|
|
@ -1 +0,0 @@
|
|||||||
declare module 'simple-progress-webpack-plugin';
|
|
@ -14,48 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as CopyPlugin from 'copy-webpack-plugin';
|
import type { Configuration, ModuleOptions } from 'webpack';
|
||||||
|
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as path from 'path';
|
|
||||||
import * as SimpleProgressWebpackPlugin from 'simple-progress-webpack-plugin';
|
|
||||||
import * as TerserPlugin from 'terser-webpack-plugin';
|
|
||||||
import {
|
import {
|
||||||
BannerPlugin,
|
BannerPlugin,
|
||||||
IgnorePlugin,
|
IgnorePlugin,
|
||||||
NormalModuleReplacementPlugin,
|
NormalModuleReplacementPlugin,
|
||||||
} from 'webpack';
|
} from 'webpack';
|
||||||
import * as PnpWebpackPlugin from 'pnp-webpack-plugin';
|
|
||||||
|
|
||||||
import * as tsconfigRaw from './tsconfig.webpack.json';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Don't webpack package.json as sentry tokens
|
|
||||||
* will be inserted in it after webpacking
|
|
||||||
*/
|
|
||||||
function externalPackageJson(packageJsonPath: string) {
|
|
||||||
return (
|
|
||||||
{ request }: { context: string; request: string },
|
|
||||||
callback: (error?: Error | null, result?: string) => void,
|
|
||||||
) => {
|
|
||||||
if (_.endsWith(request, 'package.json')) {
|
|
||||||
return callback(null, `commonjs ${packageJsonPath}`);
|
|
||||||
}
|
|
||||||
return callback();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function renameNodeModules(resourcePath: string) {
|
|
||||||
// electron-builder excludes the node_modules folder even if you specifically include it
|
|
||||||
// Work around by renaming it to "modules"
|
|
||||||
// See https://github.com/electron-userland/electron-builder/issues/4545
|
|
||||||
return (
|
|
||||||
path
|
|
||||||
.relative(__dirname, resourcePath)
|
|
||||||
.replace('node_modules', 'modules')
|
|
||||||
// file-loader expects posix paths, even on Windows
|
|
||||||
.replace(/\\/g, '/')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ReplacementRule {
|
interface ReplacementRule {
|
||||||
search: string;
|
search: string;
|
||||||
@ -75,74 +41,58 @@ function replace(test: RegExp, ...replacements: ReplacementRule[]) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const commonConfig = {
|
const rules: Required<ModuleOptions>['rules'] = [
|
||||||
mode: 'production',
|
// Add support for native node modules
|
||||||
optimization: {
|
{
|
||||||
moduleIds: 'natural',
|
// We're specifying native_modules in the test because the asset relocator loader generates a
|
||||||
minimize: true,
|
// "fake" .node file which is really a cjs file.
|
||||||
minimizer: [
|
test: /native_modules[/\\].+\.node$/,
|
||||||
new TerserPlugin({
|
use: 'node-loader',
|
||||||
parallel: true,
|
|
||||||
terserOptions: {
|
|
||||||
compress: false,
|
|
||||||
mangle: false,
|
|
||||||
format: {
|
|
||||||
comments: false,
|
|
||||||
ecma: 2020,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
extractComments: false,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
test: /[/\\]node_modules[/\\].+\.(m?js|node)$/,
|
||||||
|
parser: { amd: false },
|
||||||
|
use: {
|
||||||
|
loader: '@vercel/webpack-asset-relocator-loader',
|
||||||
|
options: {
|
||||||
|
outputAssetBase: 'native_modules',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.tsx?$/,
|
||||||
|
exclude: /(node_modules|\.webpack)/,
|
||||||
|
use: {
|
||||||
|
loader: 'ts-loader',
|
||||||
|
options: {
|
||||||
|
transpileOnly: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: ['style-loader', 'css-loader'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
||||||
|
loader: 'file-loader',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.svg$/,
|
||||||
|
use: '@svgr/webpack',
|
||||||
|
},
|
||||||
|
// force axios to use http backend (not xhr) to support streams
|
||||||
|
replace(/node_modules\/axios\/lib\/defaults\.js$/, {
|
||||||
|
search: './adapters/xhr',
|
||||||
|
replace: './adapters/http',
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
export const rendererConfig: Configuration = {
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules,
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: ['style-loader', 'css-loader'],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
||||||
loader: 'file-loader',
|
|
||||||
options: { name: renameNodeModules },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.svg$/,
|
|
||||||
use: '@svgr/webpack',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.tsx?$/,
|
|
||||||
use: [
|
|
||||||
{
|
|
||||||
loader: 'esbuild-loader',
|
|
||||||
options: {
|
|
||||||
loader: 'tsx',
|
|
||||||
target: 'es2021',
|
|
||||||
tsconfigRaw,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
// don't import WeakMap polyfill in deep-map-keys (required in corvus)
|
|
||||||
replace(/node_modules\/deep-map-keys\/lib\/deep-map-keys\.js$/, {
|
|
||||||
search: "var WeakMap = require('es6-weak-map');",
|
|
||||||
replace: '',
|
|
||||||
}),
|
|
||||||
// force axios to use http backend (not xhr) to support streams
|
|
||||||
replace(/node_modules\/axios\/lib\/defaults\.js$/, {
|
|
||||||
search: './adapters/xhr',
|
|
||||||
replace: './adapters/http',
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.js', '.json', '.ts', '.tsx'],
|
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
PnpWebpackPlugin,
|
|
||||||
new SimpleProgressWebpackPlugin({
|
|
||||||
format: process.env.WEBPACK_PROGRESS || 'verbose',
|
|
||||||
}),
|
|
||||||
// Force axios to use http.js, not xhr.js as we need stream support
|
// Force axios to use http.js, not xhr.js as we need stream support
|
||||||
// (its package.json file replaces http with xhr for browser targets).
|
// (its package.json file replaces http with xhr for browser targets).
|
||||||
new NormalModuleReplacementPlugin(
|
new NormalModuleReplacementPlugin(
|
||||||
@ -157,62 +107,25 @@ const commonConfig = {
|
|||||||
new IgnorePlugin({
|
new IgnorePlugin({
|
||||||
resourceRegExp: /^aws-crt$/,
|
resourceRegExp: /^aws-crt$/,
|
||||||
}),
|
}),
|
||||||
],
|
|
||||||
resolveLoader: {
|
|
||||||
plugins: [PnpWebpackPlugin.moduleLoader(module)],
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: path.join(__dirname, 'generated'),
|
|
||||||
filename: '[name].js',
|
|
||||||
},
|
|
||||||
externals: [
|
|
||||||
// '../package.json' because we are in 'generated'
|
|
||||||
externalPackageJson('../package.json'),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const guiConfig = {
|
|
||||||
...commonConfig,
|
|
||||||
target: 'electron-renderer',
|
|
||||||
node: {
|
|
||||||
__dirname: true,
|
|
||||||
__filename: true,
|
|
||||||
},
|
|
||||||
entry: {
|
|
||||||
gui: path.join(__dirname, 'lib', 'gui', 'app', 'renderer.ts'),
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
...commonConfig.plugins,
|
|
||||||
new CopyPlugin({
|
|
||||||
patterns: [
|
|
||||||
{ from: 'lib/gui/app/index.html', to: 'index.html' },
|
|
||||||
// electron-builder doesn't bundle folders named "assets"
|
|
||||||
// See https://github.com/electron-userland/electron-builder/issues/4545
|
|
||||||
{ from: 'assets/icon.png', to: 'media/icon.png' },
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
// Remove "Download the React DevTools for a better development experience" message
|
// Remove "Download the React DevTools for a better development experience" message
|
||||||
new BannerPlugin({
|
new BannerPlugin({
|
||||||
banner: '__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: true };',
|
banner: '__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: true };',
|
||||||
raw: true,
|
raw: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
};
|
resolve: {
|
||||||
|
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
|
||||||
const mainConfig = {
|
|
||||||
...commonConfig,
|
|
||||||
target: 'electron-main',
|
|
||||||
node: {
|
|
||||||
__dirname: false,
|
|
||||||
__filename: true,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const etcherConfig = {
|
export const mainConfig: Configuration = {
|
||||||
...mainConfig,
|
|
||||||
entry: {
|
entry: {
|
||||||
etcher: path.join(__dirname, 'lib', 'gui', 'etcher.ts'),
|
etcher: './lib/gui/etcher.ts',
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules,
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default [guiConfig, etcherConfig];
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
import configs from './webpack.config';
|
|
||||||
import { WebpackOptionsNormalized } from 'webpack';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
|
|
||||||
const [
|
|
||||||
guiConfig,
|
|
||||||
etcherConfig,
|
|
||||||
childWriterConfig,
|
|
||||||
] = (configs as unknown) as WebpackOptionsNormalized[];
|
|
||||||
|
|
||||||
configs.forEach((config) => {
|
|
||||||
config.mode = 'development';
|
|
||||||
// @ts-ignore
|
|
||||||
config.devtool = 'source-map';
|
|
||||||
});
|
|
||||||
|
|
||||||
guiConfig.devServer = {
|
|
||||||
hot: true,
|
|
||||||
port: 3030,
|
|
||||||
};
|
|
||||||
|
|
||||||
fs.copyFileSync('./lib/gui/app/index.dev.html', './generated/index.html');
|
|
||||||
|
|
||||||
export default [guiConfig, etcherConfig, childWriterConfig];
|
|
Loading…
x
Reference in New Issue
Block a user