From 36562eaea1778f50eb8f61a8bb017acb405ca2bd Mon Sep 17 00:00:00 2001 From: sadick254 Date: Fri, 3 Dec 2021 14:19:52 +0300 Subject: [PATCH 1/3] Install using npm installed during installation of script dependencies --- script/config.js | 8 ++------ script/lib/install-script-dependencies.js | 2 +- script/lib/verify-machine-requirements.js | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/script/config.js b/script/config.js index 67d522e558f..bb5e5dc8978 100644 --- a/script/config.js +++ b/script/config.js @@ -77,7 +77,7 @@ function getAppName(channel) { return channel === 'stable' ? 'Atom' : `Atom ${process.env.ATOM_CHANNEL_DISPLAY_NAME || - channel.charAt(0).toUpperCase() + channel.slice(1)}`; + channel.charAt(0).toUpperCase() + channel.slice(1)}`; } function getExecutableName(channel, appName) { @@ -113,8 +113,6 @@ function getApmBinPath() { } function getNpmBinPath(external = false) { - if (process.env.NPM_BIN_PATH) return process.env.NPM_BIN_PATH; - const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm'; const localNpmBinPath = path.resolve( repositoryRootPath, @@ -123,7 +121,5 @@ function getNpmBinPath(external = false) { '.bin', npmBinName ); - return !external && fs.existsSync(localNpmBinPath) - ? localNpmBinPath - : npmBinName; + return localNpmBinPath; } diff --git a/script/lib/install-script-dependencies.js b/script/lib/install-script-dependencies.js index bb026b35a35..98fee5aaf8f 100644 --- a/script/lib/install-script-dependencies.js +++ b/script/lib/install-script-dependencies.js @@ -10,7 +10,7 @@ process.env.ELECTRON_CUSTOM_VERSION = CONFIG.appMetadata.electronVersion; module.exports = function(ci) { console.log('Installing script dependencies'); childProcess.execFileSync( - CONFIG.getNpmBinPath(ci), + 'npm', ['--loglevel=error', ci ? 'ci' : 'install'], { env: process.env, cwd: CONFIG.scriptRootPath } ); diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index 8b8420aac14..d327a0855cc 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -7,7 +7,7 @@ const CONFIG = require('../config'); module.exports = function(ci) { verifyNode(); - verifyNpm(ci); + // verifyNpm(ci); verifyPython(); }; From 22c3e44d108135235f6e50a5640f342e21cdbbd3 Mon Sep 17 00:00:00 2001 From: sadick254 Date: Fri, 3 Dec 2021 16:22:25 +0300 Subject: [PATCH 2/3] We don't need to verify npm version We have defaulted to using npm that installed as part of the script dependancies. This is to increase predictability on what version of npm was used to install atom dependencies --- script/config.js | 3 +-- script/lib/verify-machine-requirements.js | 21 --------------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/script/config.js b/script/config.js index bb5e5dc8978..4fb052b4928 100644 --- a/script/config.js +++ b/script/config.js @@ -3,7 +3,6 @@ 'use strict'; -const fs = require('fs'); const path = require('path'); const spawnSync = require('./lib/spawn-sync'); @@ -77,7 +76,7 @@ function getAppName(channel) { return channel === 'stable' ? 'Atom' : `Atom ${process.env.ATOM_CHANNEL_DISPLAY_NAME || - channel.charAt(0).toUpperCase() + channel.slice(1)}`; + channel.charAt(0).toUpperCase() + channel.slice(1)}`; } function getExecutableName(channel, appName) { diff --git a/script/lib/verify-machine-requirements.js b/script/lib/verify-machine-requirements.js index d327a0855cc..afac015d513 100644 --- a/script/lib/verify-machine-requirements.js +++ b/script/lib/verify-machine-requirements.js @@ -3,11 +3,8 @@ const childProcess = require('child_process'); const path = require('path'); -const CONFIG = require('../config'); - module.exports = function(ci) { verifyNode(); - // verifyNpm(ci); verifyPython(); }; @@ -24,24 +21,6 @@ function verifyNode() { } } -function verifyNpm(ci) { - const stdout = childProcess.execFileSync( - CONFIG.getNpmBinPath(ci), - ['--version'], - { env: process.env } - ); - const fullVersion = stdout.toString().trim(); - const majorVersion = fullVersion.split('.')[0]; - const oldestMajorVersionSupported = ci ? 6 : 3; - if (majorVersion >= oldestMajorVersionSupported) { - console.log(`Npm:\tv${fullVersion}`); - } else { - throw new Error( - `npm v${oldestMajorVersionSupported}+ is required to build Atom. npm v${fullVersion} was detected.` - ); - } -} - function verifyPython() { // This function essentially re-implements node-gyp's "find-python.js" library, // but in a synchronous, bootstrap-script-friendly way. From 309ecff84d2635bb4d615e4867ed967c9a8b8a60 Mon Sep 17 00:00:00 2001 From: sadick254 Date: Fri, 3 Dec 2021 16:26:23 +0300 Subject: [PATCH 3/3] Use correct npm bin name depending on the OS --- script/lib/install-script-dependencies.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/lib/install-script-dependencies.js b/script/lib/install-script-dependencies.js index 98fee5aaf8f..11a01cd8675 100644 --- a/script/lib/install-script-dependencies.js +++ b/script/lib/install-script-dependencies.js @@ -9,8 +9,9 @@ process.env.ELECTRON_CUSTOM_VERSION = CONFIG.appMetadata.electronVersion; module.exports = function(ci) { console.log('Installing script dependencies'); + const npmBinName = process.platform === 'win32' ? 'npm.cmd' : 'npm'; childProcess.execFileSync( - 'npm', + npmBinName, ['--loglevel=error', ci ? 'ci' : 'install'], { env: process.env, cwd: CONFIG.scriptRootPath } );