summaryrefslogtreecommitdiffhomepage
path: root/gui/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'gui/tasks')
-rw-r--r--gui/tasks/assets.js46
-rw-r--r--gui/tasks/distribution.js547
-rw-r--r--gui/tasks/electron.js35
-rw-r--r--gui/tasks/scripts.js124
-rw-r--r--gui/tasks/watch.js49
5 files changed, 0 insertions, 801 deletions
diff --git a/gui/tasks/assets.js b/gui/tasks/assets.js
deleted file mode 100644
index 8028124180..0000000000
--- a/gui/tasks/assets.js
+++ /dev/null
@@ -1,46 +0,0 @@
-const { parallel, src, dest } = require('gulp');
-
-function copyStaticAssets() {
- return src('assets/**').pipe(dest('build/assets'));
-}
-
-function copyConfig() {
- return src('src/config.json').pipe(dest('build/src'));
-}
-
-function copyCss() {
- return src('src/renderer/**/*.css').pipe(dest('build/src/renderer'));
-}
-
-function copyHtml() {
- return src('src/renderer/index.html').pipe(dest('build/src/renderer'));
-}
-
-function copyLocales() {
- return src('locales/**/*.po').pipe(dest('build/locales'));
-}
-
-function copyGeoData() {
- return src('../dist-assets/geo/*.gl').pipe(dest('build/assets/geo'));
-}
-
-copyStaticAssets.displayName = 'copy-static-assets';
-copyConfig.displayName = 'copy-config';
-copyCss.displayName = 'copy-css';
-copyHtml.displayName = 'copy-html';
-copyLocales.displayName = 'copy-locales';
-copyGeoData.displayName = 'copy-geo-data';
-
-exports.copyAll = parallel(
- copyStaticAssets,
- copyConfig,
- copyCss,
- copyHtml,
- copyLocales,
- copyGeoData,
-);
-exports.copyStaticAssets = copyStaticAssets;
-exports.copyCss = copyCss;
-exports.copyHtml = copyHtml;
-exports.copyConfig = copyConfig;
-exports.copyGeoData = copyGeoData;
diff --git a/gui/tasks/distribution.js b/gui/tasks/distribution.js
deleted file mode 100644
index dab7b9d9e7..0000000000
--- a/gui/tasks/distribution.js
+++ /dev/null
@@ -1,547 +0,0 @@
-const path = require('path');
-const fs = require('fs');
-const builder = require('electron-builder');
-const { Arch } = require('electron-builder');
-const { execFileSync } = require('child_process');
-
-const noCompression = process.argv.includes('--no-compression');
-const shouldNotarize = process.argv.includes('--notarize');
-
-const universal = process.argv.includes('--universal');
-const release = process.argv.includes('--release');
-
-const targets = getOptionValue('--targets');
-const hostTargetTriple = getOptionValue('--host-target-triple');
-
-function getOptionValue(option) {
- const optionIndex = process.argv.indexOf(option);
- if (optionIndex !== -1) {
- return process.argv[optionIndex + 1];
- }
-}
-
-const config = {
- appId: 'net.mullvad.vpn',
- copyright: 'Mullvad VPN AB',
- productName: 'Mullvad VPN',
- publish: null,
- asar: true,
- compression: noCompression ? 'store' : 'normal',
- extraResources: [
- { from: distAssets('ca.crt'), to: '.' },
- { from: buildAssets('relays.json'), to: '.' },
- { from: root('CHANGELOG.md'), to: '.' },
- ],
-
- directories: {
- buildResources: root('dist-assets'),
- output: root('dist'),
- },
-
- extraMetadata: {
- name: 'mullvad-vpn',
- // We have to stick to semver on Windows for now due to:
- // https://github.com/electron-userland/electron-builder/issues/7173
- version: productVersion(process.platform === 'win32' ? ['semver'] : []),
- },
-
- files: [
- 'package.json',
- 'changes.txt',
- 'init.js',
- 'build/',
- '!build/src/renderer',
- 'build/src/renderer/index.html',
- 'build/src/renderer/bundle.js',
- 'build/src/renderer/preloadBundle.js',
- '!**/*.tsbuildinfo',
- '!test/',
- '!playwright.config.ts',
- 'node_modules/',
- '!node_modules/grpc-tools',
- '!node_modules/@types',
- '!node_modules/nseventmonitor/build/Release',
- ],
-
- // Make sure that all files declared in "extraResources" exists and abort if they don't.
- afterPack: (context) => {
- if (context.arch !== Arch.universal) {
- const resources = context.packager.platformSpecificBuildOptions.extraResources;
- for (const resource of resources) {
- const filePath = resource.from.replace(/\$\{env\.(.*)\}/, function (match, captureGroup) {
- return process.env[captureGroup];
- });
-
- if (!fs.existsSync(filePath)) {
- throw new Error(`Can't find file: ${filePath}`);
- }
- }
- }
- },
-
- mac: {
- target: {
- target: 'pkg',
- arch: getMacArch(),
- },
- singleArchFiles: 'node_modules/nseventmonitor/lib/binding/Release/**',
- artifactName: 'MullvadVPN-${version}.${ext}',
- category: 'public.app-category.tools',
- icon: distAssets('icon-macos.icns'),
- notarize: shouldNotarize,
- extendInfo: {
- LSUIElement: true,
- NSUserNotificationAlertStyle: 'banner',
- },
- extraResources: [
- { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad')), to: '.' },
- { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad-problem-report')), to: '.' },
- { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad-daemon')), to: '.' },
- { from: distAssets(path.join('${env.BINARIES_PATH}', 'mullvad-setup')), to: '.' },
- {
- from: distAssets(path.join('${env.BINARIES_PATH}', 'libtalpid_openvpn_plugin.dylib')),
- to: '.',
- },
- { from: distAssets(path.join('binaries', '${env.TARGET_TRIPLE}', 'openvpn')), to: '.' },
- { from: distAssets(path.join('binaries', '${env.TARGET_TRIPLE}', 'apisocks5')), to: '.' },
- { from: distAssets('uninstall_macos.sh'), to: './uninstall.sh' },
- { from: buildAssets('shell-completions/_mullvad'), to: '.' },
- { from: buildAssets('shell-completions/mullvad.fish'), to: '.' },
- { from: distAssets('maybenot_machines'), to: '.' },
- ],
- },
-
- pkg: {
- allowAnywhere: false,
- allowCurrentUserHome: false,
- isRelocatable: false,
- isVersionChecked: false,
- },
-
- nsis: {
- guid: '2A356FD4-03B7-4F45-99B4-737BE580DC82',
- oneClick: false,
- perMachine: true,
- allowElevation: true,
- allowToChangeInstallationDirectory: false,
- include: distAssets('windows/installer.nsh'),
- installerSidebar: distAssets('windows/installersidebar.bmp'),
- },
-
- win: {
- target: [
- {
- target: 'nsis',
- arch: getWindowsTargetArch(),
- },
- ],
- artifactName: getWindowsArtifactName(),
- publisherName: 'Mullvad VPN AB',
- extraResources: [
- { from: distAssets(path.join(getWindowsDistSubdir(), 'mullvad.exe')), to: '.' },
- {
- from: distAssets(path.join(getWindowsDistSubdir(), 'mullvad-problem-report.exe')),
- to: '.',
- },
- { from: distAssets(path.join(getWindowsDistSubdir(), 'mullvad-daemon.exe')), to: '.' },
- { from: distAssets(path.join(getWindowsDistSubdir(), 'talpid_openvpn_plugin.dll')), to: '.' },
- {
- from: root(
- path.join(
- 'windows',
- 'winfw',
- 'bin',
- getWindowsTargetArch() + '-${env.CPP_BUILD_MODE}',
- 'winfw.dll',
- ),
- ),
- to: '.',
- },
- // TODO: OpenVPN does not have an ARM64 build yet.
- { from: distAssets('binaries/x86_64-pc-windows-msvc/openvpn.exe'), to: '.' },
- {
- from: distAssets(path.join('binaries', getWindowsTargetSubdir(), 'apisocks5.exe')),
- to: '.',
- },
- {
- from: distAssets(path.join('binaries', getWindowsTargetSubdir(), 'wintun/wintun.dll')),
- to: '.',
- },
- {
- from: distAssets(
- path.join('binaries', getWindowsTargetSubdir(), 'split-tunnel/mullvad-split-tunnel.sys'),
- ),
- to: '.',
- },
- {
- from: distAssets(
- path.join('binaries', getWindowsTargetSubdir(), 'wireguard-nt/mullvad-wireguard.dll'),
- ),
- to: '.',
- },
- { from: distAssets('maybenot_machines'), to: '.' },
- ],
- },
-
- linux: {
- target: [
- {
- target: 'deb',
- arch: getLinuxTargetArch(),
- },
- {
- target: 'rpm',
- arch: getLinuxTargetArch(),
- },
- ],
- artifactName: 'MullvadVPN-${version}_${arch}.${ext}',
- category: 'Network',
- icon: distAssets('icon.icns'),
- extraFiles: [{ from: distAssets('linux/mullvad-gui-launcher.sh'), to: '.' }],
- extraResources: [
- { from: distAssets(path.join(getLinuxTargetSubdir(), 'mullvad-problem-report')), to: '.' },
- { from: distAssets(path.join(getLinuxTargetSubdir(), 'mullvad-setup')), to: '.' },
- {
- from: distAssets(path.join(getLinuxTargetSubdir(), 'libtalpid_openvpn_plugin.so')),
- to: '.',
- },
- { from: distAssets(path.join('linux', 'apparmor_mullvad')), to: '.' },
- { from: distAssets(path.join('binaries', '${env.TARGET_TRIPLE}', 'openvpn')), to: '.' },
- { from: distAssets(path.join('binaries', '${env.TARGET_TRIPLE}', 'apisocks5')), to: '.' },
- { from: distAssets('maybenot_machines'), to: '.' },
- ],
- },
-
- deb: {
- fpm: [
- '--no-depends',
- '--version',
- getLinuxVersion(),
- '--before-install',
- distAssets('linux/before-install.sh'),
- '--before-remove',
- distAssets('linux/before-remove.sh'),
- distAssets('linux/mullvad-daemon.service') +
- '=/usr/lib/systemd/system/mullvad-daemon.service',
- distAssets('linux/mullvad-early-boot-blocking.service') +
- '=/usr/lib/systemd/system/mullvad-early-boot-blocking.service',
- distAssets(path.join(getLinuxTargetSubdir(), 'mullvad')) + '=/usr/bin/',
- distAssets(path.join(getLinuxTargetSubdir(), 'mullvad-daemon')) + '=/usr/bin/',
- distAssets(path.join(getLinuxTargetSubdir(), 'mullvad-exclude')) + '=/usr/bin/',
- distAssets('linux/problem-report-link') + '=/usr/bin/mullvad-problem-report',
- buildAssets('shell-completions/mullvad.bash') +
- '=/usr/share/bash-completion/completions/mullvad',
- buildAssets('shell-completions/_mullvad') + '=/usr/local/share/zsh/site-functions/_mullvad',
- buildAssets('shell-completions/mullvad.fish') +
- '=/usr/share/fish/vendor_completions.d/mullvad.fish',
- ],
- afterInstall: distAssets('linux/after-install.sh'),
- afterRemove: distAssets('linux/after-remove.sh'),
- },
-
- rpm: {
- fpm: [
- '--version',
- getLinuxVersion(),
- // Prevents RPM from packaging build-id metadata, some of which is the
- // same across all electron-builder applications, which causes package
- // conflicts
- '--rpm-rpmbuild-define=_build_id_links none',
- '--directories=/opt/Mullvad VPN/',
- '--before-install',
- distAssets('linux/before-install.sh'),
- '--before-remove',
- distAssets('linux/before-remove.sh'),
- '--rpm-posttrans',
- distAssets('linux/post-transaction.sh'),
- distAssets('linux/mullvad-daemon.service') +
- '=/usr/lib/systemd/system/mullvad-daemon.service',
- distAssets('linux/mullvad-early-boot-blocking.service') +
- '=/usr/lib/systemd/system/mullvad-early-boot-blocking.service',
- distAssets(path.join(getLinuxTargetSubdir(), 'mullvad')) + '=/usr/bin/',
- distAssets(path.join(getLinuxTargetSubdir(), 'mullvad-daemon')) + '=/usr/bin/',
- distAssets(path.join(getLinuxTargetSubdir(), 'mullvad-exclude')) + '=/usr/bin/',
- distAssets('linux/problem-report-link') + '=/usr/bin/mullvad-problem-report',
- buildAssets('shell-completions/mullvad.bash') +
- '=/usr/share/bash-completion/completions/mullvad',
- buildAssets('shell-completions/_mullvad') + '=/usr/share/zsh/site-functions/_mullvad',
- buildAssets('shell-completions/mullvad.fish') +
- '=/usr/share/fish/vendor_completions.d/mullvad.fish',
- ],
- afterInstall: distAssets('linux/after-install.sh'),
- afterRemove: distAssets('linux/after-remove.sh'),
- depends: ['libXScrnSaver', 'libnotify', 'dbus-libs'],
- },
-};
-
-function packWin() {
- return builder.build({
- targets: builder.Platform.WINDOWS.createTarget(),
- config: {
- ...config,
- asarUnpack: ['build/assets/images/menubar-icons/win32/lock-*.ico'],
- beforeBuild: (options) => {
- process.env.CPP_BUILD_MODE = release ? 'Release' : 'Debug';
- process.env.CPP_BUILD_TARGET = options.arch;
- process.env.TARGET_ARCHITECTURE = options.arch;
- switch (options.arch) {
- case 'x64':
- process.env.TARGET_TRIPLE = 'x86_64-pc-windows-msvc';
- process.env.SETUP_SUBDIR = '.';
- break;
- case 'arm64':
- process.env.TARGET_TRIPLE = 'aarch64-pc-windows-msvc';
- process.env.SETUP_SUBDIR = 'aarch64-pc-windows-msvc';
- break;
- default:
- throw new Error('Invalid or unknown target (only one may be specified)');
- }
- return true;
- },
- afterAllArtifactBuild: (buildResult) => {
- // All of this is a hack to work around the limitation in:
- // https://github.com/electron-userland/electron-builder/issues/7173
- const productSemverVersion = productVersion(['semver']);
- const productTargetVersion = productVersion([]);
-
- // Rename the artifacts so that they don't have the .0 (semver format)
- for (const artifactPath of buildResult.artifactPaths) {
- const artifactDir = path.dirname(artifactPath);
- const artifactSemverFilename = path.basename(artifactPath);
- const artifactDesiredFilename = artifactSemverFilename.replace(
- productSemverVersion,
- productTargetVersion,
- );
- const targetArtifactPath = path.join(artifactDir, artifactDesiredFilename);
- console.log('Moving', artifactSemverFilename, '=>', artifactDesiredFilename);
- fs.renameSync(artifactPath, targetArtifactPath);
- }
- },
- },
- });
-}
-
-function packMac() {
- const appOutDirs = [];
-
- return builder.build({
- targets: builder.Platform.MAC.createTarget(),
- config: {
- ...config,
- asarUnpack: ['**/*.node'],
- beforeBuild: (options) => {
- switch (options.arch) {
- case 'x64':
- process.env.TARGET_TRIPLE = 'x86_64-apple-darwin';
- break;
- case 'arm64':
- process.env.TARGET_TRIPLE = 'aarch64-apple-darwin';
- break;
- default:
- delete process.env.TARGET_TRIPLE;
- break;
- }
-
- process.env.BINARIES_PATH =
- hostTargetTriple !== process.env.TARGET_TRIPLE ? process.env.TARGET_TRIPLE : '';
-
- return true;
- },
- beforePack: async (context) => {
- try {
- // `@electron/universal` tries to lipo together libraries built for the same architecture
- // if they're present for both targets. So make sure we remove libraries for other archs.
- // Remove the workaround once the issue has been fixed:
- // https://github.com/electron/universal/issues/41#issuecomment-1496288834
- await fs.promises.rm('node_modules/nseventmonitor/lib/binding/Release', {
- recursive: true,
- });
- } catch {
- // noop
- }
- config.beforePack?.(context);
- },
- afterPack: (context) => {
- config.afterPack?.(context);
-
- if (context.arch !== Arch.universal) {
- delete process.env.TARGET_TRIPLE;
- appOutDirs.push(context.appOutDir);
- }
-
- return Promise.resolve();
- },
- afterAllArtifactBuild: async (_buildResult) => {
- // Remove the folder that contains the unpacked app. Electron builder cleans up some of
- // these directories and it's changed between versions without a mention in the changelog.
- for (const dir of appOutDirs) {
- try {
- await fs.promises.rm(dir, { recursive: true });
- } catch {
- // noop
- }
- }
- },
- afterSign: (context) => {
- const appOutDir = context.appOutDir;
- appOutDirs.push(appOutDir);
- },
- },
- });
-}
-
-function packLinux() {
- if (noCompression) {
- config.rpm.fpm.unshift('--rpm-compression', 'none');
- }
-
- if (targets && targets === 'aarch64-unknown-linux-gnu') {
- config.rpm.fpm.unshift('--architecture', 'aarch64');
- }
-
- return builder.build({
- targets: builder.Platform.LINUX.createTarget(),
- config: {
- ...config,
- beforeBuild: (options) => {
- switch (options.arch) {
- case 'x64':
- process.env.TARGET_TRIPLE = 'x86_64-unknown-linux-gnu';
- break;
- case 'arm64':
- process.env.TARGET_TRIPLE = 'aarch64-unknown-linux-gnu';
- break;
- default:
- delete process.env.TARGET_TRIPLE;
- break;
- }
-
- return true;
- },
- afterPack: async (context) => {
- config.afterPack?.(context);
-
- const sourceExecutable = path.join(context.appOutDir, 'mullvad-vpn');
- const targetExecutable = path.join(context.appOutDir, 'mullvad-gui');
- const launcherScript = path.join(context.appOutDir, 'mullvad-gui-launcher.sh');
-
- // rename mullvad-vpn to mullvad-gui
- await fs.promises.rename(sourceExecutable, targetExecutable);
- // rename launcher script to mullvad-vpn
- await fs.promises.rename(launcherScript, sourceExecutable);
- },
- },
- });
-}
-
-function buildAssets(relativePath) {
- return path.join(path.resolve(__dirname, '../../build'), relativePath);
-}
-
-function distAssets(relativePath) {
- return path.join(path.resolve(__dirname, '../../dist-assets'), relativePath);
-}
-
-function root(relativePath) {
- return path.join(path.resolve(__dirname, '../../'), relativePath);
-}
-
-function getWindowsDistSubdir() {
- if (targets === 'aarch64-pc-windows-msvc') {
- return targets;
- } else {
- return '';
- }
-}
-
-function getWindowsTargetArch() {
- if (targets && process.platform === 'win32') {
- if (targets === 'aarch64-pc-windows-msvc') {
- return 'arm64';
- }
- throw new Error('Invalid or unknown target (only one may be specified)');
- }
- // Use host architecture (we assume this is x64 since building on Arm64 isn't supported).
- return 'x64';
-}
-
-function getWindowsArtifactName() {
- if (targets === 'aarch64-pc-windows-msvc') {
- return 'MullvadVPN-${version}_${arch}.${ext}';
- }
- return 'MullvadVPN-${version}.${ext}';
-}
-
-function getWindowsTargetSubdir() {
- if (targets && process.platform === 'win32') {
- if (targets === 'aarch64-pc-windows-msvc') {
- return targets;
- }
- throw new Error('Invalid or unknown target (only one may be specified)');
- }
- // Use host architecture (we assume this is x64 since building on Arm64 isn't supported).
- return 'x86_64-pc-windows-msvc';
-}
-
-function getLinuxTargetArch() {
- if (targets && process.platform === 'linux') {
- if (targets === 'aarch64-unknown-linux-gnu') {
- return 'arm64';
- }
- throw new Error('Invalid or unknown target (only one may be specified)');
- }
- // Use host architecture.
- return undefined;
-}
-
-function getLinuxTargetSubdir() {
- if (targets && process.platform === 'linux') {
- if (targets === 'aarch64-unknown-linux-gnu') {
- return targets;
- }
- throw new Error('Invalid or unknown target (only one may be specified)');
- }
- return '';
-}
-
-function getMacArch() {
- if (universal) {
- return 'universal';
- } else {
- // Not specifying an arch makes Electron builder build for the arch it's running on.
- return undefined;
- }
-}
-
-// Replace '-' with `~` (tilde) before the beta component, to make the version comparison
-// understand that stable `YYYY.NN` is newer than beta `YYYY.NN-betaN`. Both Debian and
-// Fedora do this where a tilde denotes a version component that must be sorted as earlier
-// than a non-tilde version component
-// https://docs.fedoraproject.org/en-US/packaging-guidelines/Versioning/#_complex_versioning
-function getLinuxVersion() {
- const [version, ...prereleaseParts] = productVersion([]).split('-');
- const [major, minor] = version.split('.');
- const prerelease = prereleaseParts.join('-');
- if (prerelease) {
- if (prerelease.toLowerCase().startsWith('beta')) {
- return `${major}.${minor}~${prerelease}`;
- }
- return `${major}.${minor}-${prerelease}`;
- }
- return `${major}.${minor}`;
-}
-
-// Returns the product version. The `args` argument is optional. Set it to `'semver'`
-// to get the version in semver format.
-function productVersion(extraArgs) {
- const args = ['run', '-q', '--bin', 'mullvad-version', ...extraArgs];
- return execFileSync('cargo', args, { encoding: 'utf-8' }).trim();
-}
-
-packWin.displayName = 'builder-win';
-packMac.displayName = 'builder-mac';
-packLinux.displayName = 'builder-linux';
-
-exports.packWin = packWin;
-exports.packMac = packMac;
-exports.packLinux = packLinux;
diff --git a/gui/tasks/electron.js b/gui/tasks/electron.js
deleted file mode 100644
index e3360f36fb..0000000000
--- a/gui/tasks/electron.js
+++ /dev/null
@@ -1,35 +0,0 @@
-const { spawn } = require('child_process');
-const electron = require('electron');
-
-let subprocess;
-
-function startElectron(done) {
- const args = process.argv.slice(3);
- subprocess = spawn(electron, ['.', ...args], {
- env: { ...process.env, NODE_ENV: 'development' },
- stdio: 'inherit',
- });
- done();
-}
-
-function stopElectron() {
- subprocess.kill();
- return subprocess;
-}
-
-function reloadMain(done) {
- stopElectron();
- startElectron(done);
-}
-
-function reloadRenderer() {
- subprocess.kill('SIGUSR2');
-}
-
-startElectron.displayName = 'start-electron';
-reloadMain.displayName = 'reload-main-process';
-reloadRenderer.displayName = 'reload-renderer-process';
-
-exports.start = startElectron;
-exports.reloadMain = reloadMain;
-exports.reloadRenderer = reloadRenderer;
diff --git a/gui/tasks/scripts.js b/gui/tasks/scripts.js
deleted file mode 100644
index 20acc69c35..0000000000
--- a/gui/tasks/scripts.js
+++ /dev/null
@@ -1,124 +0,0 @@
-const { exec } = require('child_process');
-const fs = require('fs');
-const { dest, series, parallel } = require('gulp');
-const ts = require('gulp-typescript');
-const inject = require('gulp-inject-string');
-const sourcemaps = require('gulp-sourcemaps');
-const TscWatchClient = require('tsc-watch/client');
-const browserify = require('browserify');
-const buffer = require('vinyl-buffer');
-const source = require('vinyl-source-stream');
-
-function makeWatchCompiler(onFirstSuccess, onSuccess) {
- let firstBuild = true;
- let lastBundle;
- let lastPreloadBundle;
-
- const compileScripts = function () {
- const watch = new TscWatchClient();
- watch.on('success', () =>
- parallel(
- makeBrowserifyRenderer(true),
- makeBrowserifyPreload(true),
- )(async () => {
- const wasFirstBuild = firstBuild;
- if (firstBuild) {
- firstBuild = false;
- onFirstSuccess();
- }
-
- let bundle = await fs.promises.readFile('./build/src/renderer/bundle.js');
- let preloadBundle = await fs.promises.readFile('./build/src/renderer/preloadBundle.js');
- if (
- !lastBundle ||
- !preloadBundle ||
- !lastBundle.equals(bundle) ||
- !lastPreloadBundle.equals(preloadBundle)
- ) {
- lastBundle = bundle;
- lastPreloadBundle = preloadBundle;
- if (!wasFirstBuild) {
- onSuccess();
- }
- }
- }),
- );
- watch.start(
- '--noClear',
- '--sourceMap',
- '--inlineSources',
- '--incremental',
- '--project',
- './tsconfig.dev.json',
- );
- return watch.tsc;
- };
- compileScripts.displayName = 'compile-scripts-watch';
-
- return compileScripts;
-}
-
-function compileScripts() {
- const tsProject = ts.createProject('tsconfig.json');
-
- return tsProject
- .src()
- .pipe(tsProject())
- .pipe(inject.replace('process.env.NODE_ENV', '"production"'))
- .pipe(dest('build'));
-}
-
-function makeBrowserifyRenderer(debug) {
- const browserifyRenderer = () => {
- let stream = browserify({ entries: './build/src/renderer/index.js', debug })
- .bundle()
- .pipe(source('bundle.js'))
- .pipe(buffer());
-
- if (debug) {
- stream = stream.pipe(sourcemaps.init({ loadMaps: true })).pipe(sourcemaps.write());
- }
-
- return stream.pipe(dest('./build/src/renderer/'));
- };
-
- browserifyRenderer.displayName = 'browserify-renderer';
- return browserifyRenderer;
-}
-
-function makeBrowserifyPreload(debug) {
- const browserifyPreload = () => {
- let stream = browserify({
- entries: './build/src/renderer/preload.js',
- debug,
- detectGlobals: false,
- })
- .exclude('electron')
- .bundle()
- .pipe(source('preloadBundle.js'))
- .pipe(buffer());
-
- if (debug) {
- stream = stream.pipe(sourcemaps.init({ loadMaps: true })).pipe(sourcemaps.write());
- }
-
- return stream.pipe(dest('./build/src/renderer/'));
- };
-
- browserifyPreload.displayName = 'browserify-preload';
- return browserifyPreload;
-}
-
-function buildProto(callback) {
- exec('bash ./scripts/build-proto.sh', (err) => callback(err));
-}
-
-compileScripts.displayName = 'compile-scripts';
-buildProto.displayName = 'build-proto';
-
-exports.build = series(
- compileScripts,
- parallel(makeBrowserifyPreload(false), makeBrowserifyRenderer(false)),
-);
-exports.buildProto = buildProto;
-exports.makeWatchCompiler = makeWatchCompiler;
diff --git a/gui/tasks/watch.js b/gui/tasks/watch.js
deleted file mode 100644
index c64c4d48d3..0000000000
--- a/gui/tasks/watch.js
+++ /dev/null
@@ -1,49 +0,0 @@
-const { parallel, series, watch } = require('gulp');
-const electron = require('./electron');
-const assets = require('./assets');
-const scripts = require('./scripts');
-
-function watchMainScripts() {
- return watch(['build/src/main/**/*.js'], series(electron.reloadMain));
-}
-
-function watchCss() {
- return watch(['src/renderer/**/*.css'], series(assets.copyCss, electron.reloadRenderer));
-}
-
-function watchConfig() {
- return watch(['src/config.json'], series(assets.copyConfig, electron.reloadRenderer));
-}
-
-function watchHtml() {
- return watch(['src/renderer/index.html'], series(assets.copyHtml, electron.reloadRenderer));
-}
-
-function watchStaticAssets() {
- return watch(
- ['assets/**', '../dist-assets/geo/*.gl'],
- series(assets.copyStaticAssets, assets.copyGeoData, electron.reloadRenderer),
- );
-}
-
-watchMainScripts.displayName = 'watch-main-scripts';
-watchCss.displayName = 'watch-css';
-watchConfig.displayName = 'watch-config';
-watchHtml.displayName = 'watch-html';
-watchStaticAssets.displayName = 'watch-static-assets';
-
-exports.start = series(
- // copy all assets first
- assets.copyAll,
-
- // make an incremental script compiler running in watch mode
- scripts.makeWatchCompiler(
- // set up hotreload, run electron and begin watching filesystem for changes, after the first
- // successful build
- series(
- electron.start,
- parallel(watchMainScripts, watchCss, watchConfig, watchHtml, watchStaticAssets),
- ),
- electron.reloadRenderer,
- ),
-);