From b4ccfb56095092d95fb4cc73b93703de740ab5d9 Mon Sep 17 00:00:00 2001 From: karan Date: Thu, 7 May 2020 11:57:39 -0700 Subject: [PATCH 1/5] try reducing number of envvars --- package.json | 2 +- pipeline/scripts/download-electron-mirror.js | 14 ++++++++++++- yarn.lock | 22 ++++++++++---------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 6bdc244c75e..50619005ad1 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ }, "devDependencies": { "7zip-bin": "^5.0.3", - "@electron/get": "^1.10.0", + "@electron/get": "1.12.0", "@types/applicationinsights-js": "^1.0.7", "@types/chrome": "0.0.107", "@types/enzyme": "^3.10.5", diff --git a/pipeline/scripts/download-electron-mirror.js b/pipeline/scripts/download-electron-mirror.js index 0b1b74d91eb..ce9b552d2e3 100644 --- a/pipeline/scripts/download-electron-mirror.js +++ b/pipeline/scripts/download-electron-mirror.js @@ -36,8 +36,9 @@ const downloadElectronArtifact = async (artifactName, destinationPath) => { version: `${pkg.dependencies.electron}`, artifactName, mirrorOptions: { - mirror: process.env.ELECTRON_MIRROR_VAR, + mirror: process.env.ELECTRON_MIRROR_BASE_VAR, customDir: process.env.ELECTRON_CUSTOM_DIR_VAR, + resolveAssetURL: resolveCustomAssetURL, }, force: true, }); @@ -49,6 +50,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}/electron/${opts.customDir}/${file}`; +}; + downloadMirrors().catch(err => { console.error(err); process.exit(1); diff --git a/yarn.lock b/yarn.lock index fa3ace8b7d8..128fe66c131 100644 --- a/yarn.lock +++ b/yarn.lock @@ -338,33 +338,33 @@ ajv "^6.12.0" ajv-keywords "^3.4.1" -"@electron/get@^1.0.1": - version "1.7.0" - resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.7.0.tgz#be5cd8cfd142964fb3d8d2f4c895790a3f4c4804" - integrity sha512-Xzo+xLQ+gwmGywFnFuG7HNIALPVJOCkvKagGxSXU1LC3s/j3h2Nku9OdwJ4KDkITeUuXfvAO5KS8rLGcmAunNQ== +"@electron/get@1.12.0": + version "1.12.0" + resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.12.0.tgz#df559d2d1b7ead327fa3eac03c6e88330283d0ea" + integrity sha512-tBACjjmdEz2PmnawnHHACSoihicuo8TVEwmdzwJsXHzR2oyz6KpatP3+BUIgZeuFxoISvp8OTQPBIWdXqfAtkQ== dependencies: debug "^4.1.1" env-paths "^2.2.0" fs-extra "^8.1.0" got "^9.6.0" + progress "^2.0.3" sanitize-filename "^1.6.2" - sumchecker "^3.0.0" + sumchecker "^3.0.1" optionalDependencies: global-agent "^2.0.2" global-tunnel-ng "^2.7.1" -"@electron/get@^1.10.0": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.10.0.tgz#258fdda22bbd5a247e0b663ba9c525dedc1bdfff" - integrity sha512-hlueNXU51c3CwQjBw/i5fwt+VfQgSQVUTdicpCHkhEjNZaa4CXJ5W1GaxSwtLE2dvRmAHjpIjUMHTqJ53uojfg== +"@electron/get@^1.0.1": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@electron/get/-/get-1.7.0.tgz#be5cd8cfd142964fb3d8d2f4c895790a3f4c4804" + integrity sha512-Xzo+xLQ+gwmGywFnFuG7HNIALPVJOCkvKagGxSXU1LC3s/j3h2Nku9OdwJ4KDkITeUuXfvAO5KS8rLGcmAunNQ== dependencies: debug "^4.1.1" env-paths "^2.2.0" fs-extra "^8.1.0" got "^9.6.0" - progress "^2.0.3" sanitize-filename "^1.6.2" - sumchecker "^3.0.1" + sumchecker "^3.0.0" optionalDependencies: global-agent "^2.0.2" global-tunnel-ng "^2.7.1" From 00bea36909882e87b18519ea542e42edee2ae1b0 Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 22 May 2020 10:42:43 -0700 Subject: [PATCH 2/5] refactor --- pipeline/scripts/download-electron-mirror.js | 16 +++++++++------- pipeline/unified/download-electron-mirror.yaml | 3 --- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pipeline/scripts/download-electron-mirror.js b/pipeline/scripts/download-electron-mirror.js index ce9b552d2e3..b315a64b325 100644 --- a/pipeline/scripts/download-electron-mirror.js +++ b/pipeline/scripts/download-electron-mirror.js @@ -8,8 +8,8 @@ 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 +with mirror dependencies specified by ELECTRON_MIRROR_BASE_VAR +and ELECTRON_MIRROR_CUSTOM_DIR_VAR, and `assetNumber`. 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 @@ -17,13 +17,15 @@ 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('ELECTRON_MIRROR_BASE_VAR and ELECTRON_MIRROR_CUSTOM_DIR_VAR must be defined'); process.exit(1); } +const assetNumber = '4658637'; + const downloadMirrors = async () => { await downloadElectronArtifact('electron', 'node_modules/electron/dist'); await downloadElectronArtifact('chromedriver', 'node_modules/electron-chromedriver/bin'); @@ -37,7 +39,7 @@ const downloadElectronArtifact = async (artifactName, destinationPath) => { artifactName, mirrorOptions: { mirror: process.env.ELECTRON_MIRROR_BASE_VAR, - customDir: process.env.ELECTRON_CUSTOM_DIR_VAR, + customDir: process.env.ELECTRON_MIRROR_CUSTOM_DIR_VAR, resolveAssetURL: resolveCustomAssetURL, }, force: true, @@ -58,7 +60,7 @@ const resolveCustomAssetURL = details => { '-', )}.zip`; const strippedVer = details.version.replace(/^v/, ''); - return `${opts.mirror}/${strippedVer}/electron/${opts.customDir}/${file}`; + return `${opts.mirror}/${strippedVer}/${opts.customDir}/${assetNumber}/${file}`; }; downloadMirrors().catch(err => { 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) From 726b1ea8c9878590591cc54c6f2a77bf2bd6dca8 Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 22 May 2020 11:21:41 -0700 Subject: [PATCH 3/5] undo unintentional yarnlock changes --- yarn.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 93b3f26cc8d..aa50ba7f399 100644 --- a/yarn.lock +++ b/yarn.lock @@ -331,8 +331,9 @@ env-paths "^2.2.0" fs-extra "^8.1.0" got "^9.6.0" + progress "^2.0.3" sanitize-filename "^1.6.2" - sumchecker "^3.0.0" + sumchecker "^3.0.1" optionalDependencies: global-agent "^2.0.2" global-tunnel-ng "^2.7.1" From 8c5946505a11fb1cdc67fe507c89fc321787b9d3 Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 22 May 2020 12:42:02 -0700 Subject: [PATCH 4/5] reword comment --- pipeline/scripts/download-electron-mirror.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pipeline/scripts/download-electron-mirror.js b/pipeline/scripts/download-electron-mirror.js index b315a64b325..9a5ed0953db 100644 --- a/pipeline/scripts/download-electron-mirror.js +++ b/pipeline/scripts/download-electron-mirror.js @@ -20,7 +20,11 @@ if ( process.env.ELECTRON_MIRROR_BASE_VAR === undefined || process.env.ELECTRON_MIRROR_CUSTOM_DIR_VAR === undefined ) { - console.error('ELECTRON_MIRROR_BASE_VAR and ELECTRON_MIRROR_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); } From 661491528c354235e0586c60a7cb1a0d45caca1e Mon Sep 17 00:00:00 2001 From: karan Date: Fri, 22 May 2020 12:42:49 -0700 Subject: [PATCH 5/5] reword comment --- pipeline/scripts/download-electron-mirror.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pipeline/scripts/download-electron-mirror.js b/pipeline/scripts/download-electron-mirror.js index 9a5ed0953db..3a2ed35be6a 100644 --- a/pipeline/scripts/download-electron-mirror.js +++ b/pipeline/scripts/download-electron-mirror.js @@ -8,11 +8,10 @@ const path = require('path'); /* This script replaces existing electron & chromedriver modules -with mirror dependencies specified by ELECTRON_MIRROR_BASE_VAR -and ELECTRON_MIRROR_CUSTOM_DIR_VAR, and `assetNumber`. 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. */