diff --git a/pipeline/scripts/download-electron-mirror.js b/pipeline/scripts/download-electron-mirror.js index 0b1b74d91eb..3a2ed35be6a 100644 --- a/pipeline/scripts/download-electron-mirror.js +++ b/pipeline/scripts/download-electron-mirror.js @@ -8,22 +8,27 @@ const path = require('path'); /* This script replaces existing electron & chromedriver modules -with mirror dependencies specified by ELECTRON_MIRROR_VAR -and ELECTRON_CUSTOM_DIR_VAR (see @electron/get). We use this -to avoid bundling non-freely-redistributable media codecs -in our release builds. The version of Electron published to npm -includes these as part of Chromium; our release builds use a +with mirror dependencies specified by `assetNumber` and pipeline +build variables. We use this to avoid bundling non-freely-redistributable +media codecs in our release builds. The version of Electron published to +npm includes these as part of Chromium; our release builds use a Microsoft-maintained build of Electron that removes those codecs. */ if ( - process.env.ELECTRON_MIRROR_VAR === undefined || - process.env.ELECTRON_CUSTOM_DIR_VAR === undefined + process.env.ELECTRON_MIRROR_BASE_VAR === undefined || + process.env.ELECTRON_MIRROR_CUSTOM_DIR_VAR === undefined ) { - console.error('ELECTRON_MIRROR_VAR and ELECTRON_CUSTOM_DIR_VAR must be defined'); + console.error( + `Mirror variables are not set. Please ensure that + ELECTRON_MIRROR_BASE_VAR and ELECTRON_MIRROR_CUSTOM_DIR_VAR + are both set as variables in the pipeline`, + ); process.exit(1); } +const assetNumber = '4658637'; + const downloadMirrors = async () => { await downloadElectronArtifact('electron', 'node_modules/electron/dist'); await downloadElectronArtifact('chromedriver', 'node_modules/electron-chromedriver/bin'); @@ -36,8 +41,9 @@ const downloadElectronArtifact = async (artifactName, destinationPath) => { version: `${pkg.dependencies.electron}`, artifactName, mirrorOptions: { - mirror: process.env.ELECTRON_MIRROR_VAR, - customDir: process.env.ELECTRON_CUSTOM_DIR_VAR, + mirror: process.env.ELECTRON_MIRROR_BASE_VAR, + customDir: process.env.ELECTRON_MIRROR_CUSTOM_DIR_VAR, + resolveAssetURL: resolveCustomAssetURL, }, force: true, }); @@ -49,6 +55,17 @@ const downloadElectronArtifact = async (artifactName, destinationPath) => { await extract(zipFilePath, { dir: destinationPath }); }; +const resolveCustomAssetURL = details => { + const opts = details.mirrorOptions; + const file = details.artifactName.startsWith('SHASUMS256') + ? details.artifactName + : `${[details.artifactName, details.version, details.platform, details.arch].join( + '-', + )}.zip`; + const strippedVer = details.version.replace(/^v/, ''); + return `${opts.mirror}/${strippedVer}/${opts.customDir}/${assetNumber}/${file}`; +}; + downloadMirrors().catch(err => { console.error(err); process.exit(1); diff --git a/pipeline/unified/download-electron-mirror.yaml b/pipeline/unified/download-electron-mirror.yaml index dc8309e9332..2c50e4106ab 100644 --- a/pipeline/unified/download-electron-mirror.yaml +++ b/pipeline/unified/download-electron-mirror.yaml @@ -3,6 +3,3 @@ steps: - script: yarn download:electron-mirror displayName: download custom electron build - env: - ELECTRON_MIRROR_VAR: $(ELECTRON_822_MIRROR_VAR) - ELECTRON_CUSTOM_DIR_VAR: $(ELECTRON_822_CUSTOM_DIR_VAR)