node-install-release 1.15.8 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
- var _fsremovecompat = require("fs-remove-compat");
13
12
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
14
13
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
15
14
  var _constantsts = require("../constants.js");
@@ -22,7 +21,6 @@ function _interop_require_default(obj) {
22
21
  };
23
22
  }
24
23
  function installCompressed(distPath, dest, options, callback) {
25
- var platform = options.platform;
26
24
  var downloadPath = "".concat(_constantsts.NODE_DIST_BASE_URL, "/").concat(distPath);
27
25
  var cachePath = _path.default.join(options.cachePath, _path.default.basename(downloadPath));
28
26
  _fs.default.stat(dest, function(err) {
@@ -41,12 +39,7 @@ function installCompressed(distPath, dest, options, callback) {
41
39
  time: 1000
42
40
  }));
43
41
  queue.await(function(err) {
44
- // some compressed versions of node come with npm pre-installed, but we want to override with a specific version
45
- var libPath = platform === 'win32' ? dest : _path.default.join(dest, 'lib');
46
- var installPath = _path.default.join(libPath, 'node_modules', 'npm');
47
- (0, _fsremovecompat.safeRm)(installPath, function() {
48
- return callback(err, checksum);
49
- });
42
+ return callback(err, checksum);
50
43
  });
51
44
  });
52
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/installCompressed.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport conditionalExtract from '../lib/conditionalExtract.ts';\nimport type { ChecksumCallback, ChecksumResult, InstallOptions } from '../types.ts';\nimport validateDownload from './validateDownload.ts';\n\nexport default function installCompressed(distPath: string, dest: string, options: InstallOptions, callback: ChecksumCallback): undefined {\n const platform = options.platform;\n const downloadPath = `${NODE_DIST_BASE_URL}/${distPath}`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n let checksum: ChecksumResult | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n validateDownload(distPath, cachePath, (err, result) => {\n checksum = result;\n cb(err);\n });\n });\n queue.defer(conditionalExtract.bind(null, cachePath, dest, { strip: 1, time: 1000 }));\n queue.await((err) => {\n // some compressed versions of node come with npm pre-installed, but we want to override with a specific version\n const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');\n const installPath = path.join(libPath, 'node_modules', 'npm');\n safeRm(installPath, () => callback(err, checksum));\n });\n });\n}\n"],"names":["installCompressed","distPath","dest","options","callback","platform","downloadPath","NODE_DIST_BASE_URL","cachePath","path","join","basename","fs","stat","err","checksum","queue","Queue","defer","conditionalCache","bind","cb","validateDownload","result","conditionalExtract","strip","time","await","libPath","installPath","safeRm"],"mappings":";;;;+BAWA;;;eAAwBA;;;yDAXT;8BACQ;2DACN;8DACC;2BAEiB;yEACN;2EACE;yEAEF;;;;;;AAEd,SAASA,kBAAkBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC3H,IAAMC,WAAWF,QAAQE,QAAQ;IACjC,IAAMC,eAAe,AAAC,GAAwBL,OAAtBM,+BAAkB,EAAC,KAAY,OAATN;IAC9C,IAAMO,YAAYC,aAAI,CAACC,IAAI,CAACP,QAAQK,SAAS,EAAEC,aAAI,CAACE,QAAQ,CAACL;IAE7DM,WAAE,CAACC,IAAI,CAACX,MAAM,SAACY;QACb,IAAI,CAACA,KAAK,OAAOV,YAAY,iBAAiB;QAE9C,IAAIW;QACJ,IAAMC,QAAQ,IAAIC,gBAAK,CAAC;QACxBD,MAAME,KAAK,CAACC,2BAAgB,CAACC,IAAI,CAAC,MAAMd,cAAcE;QACtDQ,MAAME,KAAK,CAAC,SAACG;YACXC,IAAAA,2BAAgB,EAACrB,UAAUO,WAAW,SAACM,KAAKS;gBAC1CR,WAAWQ;gBACXF,GAAGP;YACL;QACF;QACAE,MAAME,KAAK,CAACM,6BAAkB,CAACJ,IAAI,CAAC,MAAMZ,WAAWN,MAAM;YAAEuB,OAAO;YAAGC,MAAM;QAAK;QAClFV,MAAMW,KAAK,CAAC,SAACb;YACX,gHAAgH;YAChH,IAAMc,UAAUvB,aAAa,UAAUH,OAAOO,aAAI,CAACC,IAAI,CAACR,MAAM;YAC9D,IAAM2B,cAAcpB,aAAI,CAACC,IAAI,CAACkB,SAAS,gBAAgB;YACvDE,IAAAA,sBAAM,EAACD,aAAa;uBAAMzB,SAASU,KAAKC;;QAC1C;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/installCompressed.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport conditionalExtract from '../lib/conditionalExtract.ts';\nimport type { ChecksumCallback, ChecksumResult, InstallOptions } from '../types.ts';\nimport validateDownload from './validateDownload.ts';\n\nexport default function installCompressed(distPath: string, dest: string, options: InstallOptions, callback: ChecksumCallback): undefined {\n const downloadPath = `${NODE_DIST_BASE_URL}/${distPath}`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n let checksum: ChecksumResult | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n validateDownload(distPath, cachePath, (err, result) => {\n checksum = result;\n cb(err);\n });\n });\n queue.defer(conditionalExtract.bind(null, cachePath, dest, { strip: 1, time: 1000 }));\n queue.await((err) => callback(err, checksum));\n });\n}\n"],"names":["installCompressed","distPath","dest","options","callback","downloadPath","NODE_DIST_BASE_URL","cachePath","path","join","basename","fs","stat","err","checksum","queue","Queue","defer","conditionalCache","bind","cb","validateDownload","result","conditionalExtract","strip","time","await"],"mappings":";;;;+BAUA;;;eAAwBA;;;yDAVT;2DACE;8DACC;2BAEiB;yEACN;2EACE;yEAEF;;;;;;AAEd,SAASA,kBAAkBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC3H,IAAMC,eAAe,AAAC,GAAwBJ,OAAtBK,+BAAkB,EAAC,KAAY,OAATL;IAC9C,IAAMM,YAAYC,aAAI,CAACC,IAAI,CAACN,QAAQI,SAAS,EAAEC,aAAI,CAACE,QAAQ,CAACL;IAE7DM,WAAE,CAACC,IAAI,CAACV,MAAM,SAACW;QACb,IAAI,CAACA,KAAK,OAAOT,YAAY,iBAAiB;QAE9C,IAAIU;QACJ,IAAMC,QAAQ,IAAIC,gBAAK,CAAC;QACxBD,MAAME,KAAK,CAACC,2BAAgB,CAACC,IAAI,CAAC,MAAMd,cAAcE;QACtDQ,MAAME,KAAK,CAAC,SAACG;YACXC,IAAAA,2BAAgB,EAACpB,UAAUM,WAAW,SAACM,KAAKS;gBAC1CR,WAAWQ;gBACXF,GAAGP;YACL;QACF;QACAE,MAAME,KAAK,CAACM,6BAAkB,CAACJ,IAAI,CAAC,MAAMZ,WAAWL,MAAM;YAAEsB,OAAO;YAAGC,MAAM;QAAK;QAClFV,MAAMW,KAAK,CAAC,SAACb;mBAAQT,SAASS,KAAKC;;IACrC;AACF"}
@@ -8,9 +8,12 @@ Object.defineProperty(exports, "default", {
8
8
  return install;
9
9
  }
10
10
  });
11
+ var _fsremovecompat = require("fs-remove-compat");
11
12
  var _isversion = /*#__PURE__*/ _interop_require_default(require("is-version"));
12
13
  var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
14
+ var _nodefilenametodistpaths = require("node-filename-to-dist-paths");
13
15
  var _noderesolveversions = /*#__PURE__*/ _interop_require_default(require("node-resolve-versions"));
16
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
14
17
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
15
18
  var _constantsts = require("../constants.js");
16
19
  var _createResultts = /*#__PURE__*/ _interop_require_default(require("../createResult.js"));
@@ -79,16 +82,50 @@ function install(versionExpression, options, callback) {
79
82
  }
80
83
  var version = versions[0];
81
84
  var result = (0, _createResultts.default)(options, version);
85
+ // Check if node is missing first
82
86
  (0, _checkMissingts.default)(result.installPath, options, function(err, missing) {
83
- if (err || !missing.length) {
84
- callback(err, result);
87
+ if (err) {
88
+ callback(err);
89
+ return;
90
+ }
91
+ // Early exit if both node and npm are already present
92
+ if (!missing.length) {
93
+ callback(null, result);
85
94
  return;
86
95
  }
87
96
  var queue = new _queuecb.default(1);
88
97
  queue.defer(_mkdirpclassic.default.bind(null, options.cachePath));
89
98
  queue.defer(_ensureDestinationParentts.default.bind(null, result.installPath));
99
+ // Install node if missing
90
100
  !~missing.indexOf('node') || queue.defer(_indexts.default.bind(null, version, result.installPath, options));
91
- !~missing.indexOf('npm') || queue.defer(_indexts1.default.bind(null, version, result.installPath, options));
101
+ // Check and install npm AFTER node (so bundled npm is detected)
102
+ // Skip npm download only if bundled npm is modern (6+); old npm (<6) was buggy
103
+ queue.defer(function(cb) {
104
+ (0, _checkMissingts.default)(result.installPath, options, function(err, npmMissing) {
105
+ if (err) {
106
+ cb(err);
107
+ return;
108
+ }
109
+ if (!~npmMissing.indexOf('npm')) {
110
+ // npm is present - check if it's modern enough to keep (npm >= 3 is stable)
111
+ var dist = (0, _nodefilenametodistpaths.getDist)(version);
112
+ var bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;
113
+ if (bundledNpmMajor >= 3) {
114
+ cb(); // npm >= 3 bundled, skip download
115
+ return;
116
+ }
117
+ // old npm (<3) is buggy - delete it so installNPM can override
118
+ var platform = options.platform;
119
+ var libPath = platform === 'win32' ? result.installPath : _path.default.join(result.installPath, 'lib');
120
+ var npmPath = _path.default.join(libPath, 'node_modules', 'npm');
121
+ (0, _fsremovecompat.safeRm)(npmPath, function() {
122
+ return (0, _indexts1.default)(version, result.installPath, options, cb);
123
+ });
124
+ return;
125
+ }
126
+ (0, _indexts1.default)(version, result.installPath, options, cb);
127
+ });
128
+ });
92
129
  queue.await(function(err) {
93
130
  return err ? callback(err) : callback(null, result);
94
131
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport resolveVersions from 'node-resolve-versions';\nimport Queue from 'queue-cb';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n checkMissing(result.installPath, options, (err, missing): undefined => {\n if (err || !missing.length) {\n callback(err, result);\n return;\n }\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, options.cachePath));\n queue.defer(ensureDestinationParent.bind(null, result.installPath));\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, result.installPath, options));\n !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, result.installPath, options));\n queue.await((err) => (err ? callback(err) : callback(null, result)));\n });\n });\n}\n"],"names":["install","getVersions","versionExpression","options","callback","isVersion","resolveVersions","storagePaths","storagePath","createStoragePaths","DEFAULT_STORAGE_PATHS","getTarget","err","versions","length","Error","map","x","version","result","createResult","checkMissing","installPath","missing","queue","Queue","defer","mkdirp","bind","cachePath","ensureDestinationParent","indexOf","installNode","installNPM","await"],"mappings":";;;;+BAwBA;;;eAAwBA;;;gEAxBF;oEACH;0EACS;8DACV;2BAEoB;qEAEb;2EACM;8DACP;+DAED;qEACE;gFACW;kEACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKtB,SAASC,YAAYC,iBAAyB,EAAEC,OAAuB,EAAEC,QAA6B;IACpG,gBAAgB;IAChBC,IAAAA,kBAAS,EAACH,qBAAqBE,SAAS,MAAM;QAACF;KAAkB,IAAII,IAAAA,4BAAe,EAACJ,mBAAmBC,SAASC;AACnH;AAEe,SAASJ,QAAQE,iBAAyB,EAAEC,OAAuB,EAAEC,QAAyB;IAC3G,IAAMG,eAAeJ,QAAQK,WAAW,GAAGC,IAAAA,6BAAkB,EAACN,QAAQK,WAAW,IAAIE,kCAAqB;IAC1GP,UAAU,mBAAKI,cAAiBJ,SAAYQ,IAAAA,oBAAS,EAACR;IACtDF,YAAYC,mBAAmBC,SAAS,SAACS,KAAaC;QACpD,IAAID,KAAK;YACPR,SAASQ;YACT;QACF;QACA,IAAI,CAACC,SAASC,MAAM,EAAE;YACpBV,SAAS,IAAIW,MAAM,AAAC,mCAAoD,OAAlBb;YACtD;QACF;QACA,IAAIW,SAASC,MAAM,KAAK,GAAG;YACzBV,SAAS,IAAIW,MAAM,AAAC,WAA8DF,OAApDX,mBAAkB,oCAAyD,OAAvBW,SAASG,GAAG,CAAC,SAACC;uBAAMA;gBAAG;YACzG;QACF;QAEA,IAAMC,UAAUL,QAAQ,CAAC,EAAE;QAC3B,IAAMM,SAASC,IAAAA,uBAAY,EAACjB,SAASe;QAErCG,IAAAA,uBAAY,EAACF,OAAOG,WAAW,EAAEnB,SAAS,SAACS,KAAKW;YAC9C,IAAIX,OAAO,CAACW,QAAQT,MAAM,EAAE;gBAC1BV,SAASQ,KAAKO;gBACd;YACF;YAEA,IAAMK,QAAQ,IAAIC,gBAAK,CAAC;YACxBD,MAAME,KAAK,CAACC,sBAAM,CAACC,IAAI,CAAC,MAAMzB,QAAQ0B,SAAS;YAC/CL,MAAME,KAAK,CAACI,kCAAuB,CAACF,IAAI,CAAC,MAAMT,OAAOG,WAAW;YACjE,CAAC,CAACC,QAAQQ,OAAO,CAAC,WAAWP,MAAME,KAAK,CAACM,gBAAW,CAACJ,IAAI,CAAC,MAAMV,SAASC,OAAOG,WAAW,EAAEnB;YAC7F,CAAC,CAACoB,QAAQQ,OAAO,CAAC,UAAUP,MAAME,KAAK,CAACO,iBAAU,CAACL,IAAI,CAAC,MAAMV,SAASC,OAAOG,WAAW,EAAEnB;YAC3FqB,MAAMU,KAAK,CAAC,SAACtB;uBAASA,MAAMR,SAASQ,OAAOR,SAAS,MAAMe;;QAC7D;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import { safeRm } from 'fs-remove-compat';\nimport isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport resolveVersions from 'node-resolve-versions';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n // Check if node is missing first\n checkMissing(result.installPath, options, (err, missing): undefined => {\n if (err) {\n callback(err);\n return;\n }\n\n // Early exit if both node and npm are already present\n if (!missing.length) {\n callback(null, result);\n return;\n }\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, options.cachePath));\n queue.defer(ensureDestinationParent.bind(null, result.installPath));\n\n // Install node if missing\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, result.installPath, options));\n\n // Check and install npm AFTER node (so bundled npm is detected)\n // Skip npm download only if bundled npm is modern (6+); old npm (<6) was buggy\n queue.defer((cb) => {\n checkMissing(result.installPath, options, (err, npmMissing): undefined => {\n if (err) {\n cb(err);\n return;\n }\n if (!~npmMissing.indexOf('npm')) {\n // npm is present - check if it's modern enough to keep (npm >= 3 is stable)\n const dist = getDist(version);\n const bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;\n if (bundledNpmMajor >= 3) {\n cb(); // npm >= 3 bundled, skip download\n return;\n }\n // old npm (<3) is buggy - delete it so installNPM can override\n const platform = options.platform;\n const libPath = platform === 'win32' ? result.installPath : path.join(result.installPath, 'lib');\n const npmPath = path.join(libPath, 'node_modules', 'npm');\n safeRm(npmPath, () => installNPM(version, result.installPath, options, cb));\n return;\n }\n installNPM(version, result.installPath, options, cb);\n });\n });\n\n queue.await((err) => (err ? callback(err) : callback(null, result)));\n });\n });\n}\n"],"names":["install","getVersions","versionExpression","options","callback","isVersion","resolveVersions","storagePaths","storagePath","createStoragePaths","DEFAULT_STORAGE_PATHS","getTarget","err","versions","length","Error","map","x","version","result","createResult","checkMissing","installPath","missing","queue","Queue","defer","mkdirp","bind","cachePath","ensureDestinationParent","indexOf","installNode","cb","npmMissing","dist","getDist","bundledNpmMajor","npm","split","platform","libPath","path","join","npmPath","safeRm","installNPM","await"],"mappings":";;;;+BA2BA;;;eAAwBA;;;8BA3BD;gEACD;oEACH;uCACK;0EACI;2DACX;8DACC;2BAEoB;qEAEb;2EACM;8DACP;+DAED;qEACE;gFACW;kEACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKtB,SAASC,YAAYC,iBAAyB,EAAEC,OAAuB,EAAEC,QAA6B;IACpG,gBAAgB;IAChBC,IAAAA,kBAAS,EAACH,qBAAqBE,SAAS,MAAM;QAACF;KAAkB,IAAII,IAAAA,4BAAe,EAACJ,mBAAmBC,SAASC;AACnH;AAEe,SAASJ,QAAQE,iBAAyB,EAAEC,OAAuB,EAAEC,QAAyB;IAC3G,IAAMG,eAAeJ,QAAQK,WAAW,GAAGC,IAAAA,6BAAkB,EAACN,QAAQK,WAAW,IAAIE,kCAAqB;IAC1GP,UAAU,mBAAKI,cAAi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C,QAAQ;wBAC/B,4EAA4E;wBAC5E,IAAMI,OAAOC,IAAAA,gCAAO,EAAClB;wBACrB,IAAMmB,kBAAkBF,QAAQA,KAAKG,GAAG,GAAG,CAACH,KAAKG,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG;wBACrE,IAAIF,mBAAmB,GAAG;4BACxBJ,MAAM,kCAAkC;4BACxC;wBACF;wBACA,+DAA+D;wBAC/D,IAAMO,WAAWrC,QAAQqC,QAAQ;wBACjC,IAAMC,UAAUD,aAAa,UAAUrB,OAAOG,WAAW,GAAGoB,aAAI,CAACC,IAAI,CAACxB,OAAOG,WAAW,EAAE;wBAC1F,IAAMsB,UAAUF,aAAI,CAACC,IAAI,CAACF,SAAS,gBAAgB;wBACnDI,IAAAA,sBAAM,EAACD,SAAS;mCAAME,IAAAA,iBAAU,EAAC5B,SAASC,OAAOG,WAAW,EAAEnB,SAAS8B;;wBACvE;oBACF;oBACAa,IAAAA,iBAAU,EAAC5B,SAASC,OAAOG,WAAW,EAAEnB,SAAS8B;gBACnD;YACF;YAEAT,MAAMuB,KAAK,CAAC,SAACnC;uBAASA,MAAMR,SAASQ,OAAOR,SAAS,MAAMe;;QAC7D;IACF;AACF"}
@@ -1,5 +1,4 @@
1
1
  import fs from 'fs';
2
- import { safeRm } from 'fs-remove-compat';
3
2
  import path from 'path';
4
3
  import Queue from 'queue-cb';
5
4
  import { NODE_DIST_BASE_URL } from '../constants.js';
@@ -7,7 +6,6 @@ import conditionalCache from '../lib/conditionalCache.js';
7
6
  import conditionalExtract from '../lib/conditionalExtract.js';
8
7
  import validateDownload from './validateDownload.js';
9
8
  export default function installCompressed(distPath, dest, options, callback) {
10
- const platform = options.platform;
11
9
  const downloadPath = `${NODE_DIST_BASE_URL}/${distPath}`;
12
10
  const cachePath = path.join(options.cachePath, path.basename(downloadPath));
13
11
  fs.stat(dest, (err)=>{
@@ -25,11 +23,6 @@ export default function installCompressed(distPath, dest, options, callback) {
25
23
  strip: 1,
26
24
  time: 1000
27
25
  }));
28
- queue.await((err)=>{
29
- // some compressed versions of node come with npm pre-installed, but we want to override with a specific version
30
- const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
31
- const installPath = path.join(libPath, 'node_modules', 'npm');
32
- safeRm(installPath, ()=>callback(err, checksum));
33
- });
26
+ queue.await((err)=>callback(err, checksum));
34
27
  });
35
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/installCompressed.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport conditionalExtract from '../lib/conditionalExtract.ts';\nimport type { ChecksumCallback, ChecksumResult, InstallOptions } from '../types.ts';\nimport validateDownload from './validateDownload.ts';\n\nexport default function installCompressed(distPath: string, dest: string, options: InstallOptions, callback: ChecksumCallback): undefined {\n const platform = options.platform;\n const downloadPath = `${NODE_DIST_BASE_URL}/${distPath}`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n let checksum: ChecksumResult | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n validateDownload(distPath, cachePath, (err, result) => {\n checksum = result;\n cb(err);\n });\n });\n queue.defer(conditionalExtract.bind(null, cachePath, dest, { strip: 1, time: 1000 }));\n queue.await((err) => {\n // some compressed versions of node come with npm pre-installed, but we want to override with a specific version\n const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');\n const installPath = path.join(libPath, 'node_modules', 'npm');\n safeRm(installPath, () => callback(err, checksum));\n });\n });\n}\n"],"names":["fs","safeRm","path","Queue","NODE_DIST_BASE_URL","conditionalCache","conditionalExtract","validateDownload","installCompressed","distPath","dest","options","callback","platform","downloadPath","cachePath","join","basename","stat","err","checksum","queue","defer","bind","cb","result","strip","time","await","libPath","installPath"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,OAAOC,sBAAsB,6BAA6B;AAC1D,OAAOC,wBAAwB,+BAA+B;AAE9D,OAAOC,sBAAsB,wBAAwB;AAErD,eAAe,SAASC,kBAAkBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC3H,MAAMC,WAAWF,QAAQE,QAAQ;IACjC,MAAMC,eAAe,GAAGV,mBAAmB,CAAC,EAAEK,UAAU;IACxD,MAAMM,YAAYb,KAAKc,IAAI,CAACL,QAAQI,SAAS,EAAEb,KAAKe,QAAQ,CAACH;IAE7Dd,GAAGkB,IAAI,CAACR,MAAM,CAACS;QACb,IAAI,CAACA,KAAK,OAAOP,YAAY,iBAAiB;QAE9C,IAAIQ;QACJ,MAAMC,QAAQ,IAAIlB,MAAM;QACxBkB,MAAMC,KAAK,CAACjB,iBAAiBkB,IAAI,CAAC,MAAMT,cAAcC;QACtDM,MAAMC,KAAK,CAAC,CAACE;YACXjB,iBAAiBE,UAAUM,WAAW,CAACI,KAAKM;gBAC1CL,WAAWK;gBACXD,GAAGL;YACL;QACF;QACAE,MAAMC,KAAK,CAAChB,mBAAmBiB,IAAI,CAAC,MAAMR,WAAWL,MAAM;YAAEgB,OAAO;YAAGC,MAAM;QAAK;QAClFN,MAAMO,KAAK,CAAC,CAACT;YACX,gHAAgH;YAChH,MAAMU,UAAUhB,aAAa,UAAUH,OAAOR,KAAKc,IAAI,CAACN,MAAM;YAC9D,MAAMoB,cAAc5B,KAAKc,IAAI,CAACa,SAAS,gBAAgB;YACvD5B,OAAO6B,aAAa,IAAMlB,SAASO,KAAKC;QAC1C;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/installCompressed.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport conditionalExtract from '../lib/conditionalExtract.ts';\nimport type { ChecksumCallback, ChecksumResult, InstallOptions } from '../types.ts';\nimport validateDownload from './validateDownload.ts';\n\nexport default function installCompressed(distPath: string, dest: string, options: InstallOptions, callback: ChecksumCallback): undefined {\n const downloadPath = `${NODE_DIST_BASE_URL}/${distPath}`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n let checksum: ChecksumResult | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n validateDownload(distPath, cachePath, (err, result) => {\n checksum = result;\n cb(err);\n });\n });\n queue.defer(conditionalExtract.bind(null, cachePath, dest, { strip: 1, time: 1000 }));\n queue.await((err) => callback(err, checksum));\n });\n}\n"],"names":["fs","path","Queue","NODE_DIST_BASE_URL","conditionalCache","conditionalExtract","validateDownload","installCompressed","distPath","dest","options","callback","downloadPath","cachePath","join","basename","stat","err","checksum","queue","defer","bind","cb","result","strip","time","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,kBAAkB,QAAQ,kBAAkB;AACrD,OAAOC,sBAAsB,6BAA6B;AAC1D,OAAOC,wBAAwB,+BAA+B;AAE9D,OAAOC,sBAAsB,wBAAwB;AAErD,eAAe,SAASC,kBAAkBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC3H,MAAMC,eAAe,GAAGT,mBAAmB,CAAC,EAAEK,UAAU;IACxD,MAAMK,YAAYZ,KAAKa,IAAI,CAACJ,QAAQG,SAAS,EAAEZ,KAAKc,QAAQ,CAACH;IAE7DZ,GAAGgB,IAAI,CAACP,MAAM,CAACQ;QACb,IAAI,CAACA,KAAK,OAAON,YAAY,iBAAiB;QAE9C,IAAIO;QACJ,MAAMC,QAAQ,IAAIjB,MAAM;QACxBiB,MAAMC,KAAK,CAAChB,iBAAiBiB,IAAI,CAAC,MAAMT,cAAcC;QACtDM,MAAMC,KAAK,CAAC,CAACE;YACXhB,iBAAiBE,UAAUK,WAAW,CAACI,KAAKM;gBAC1CL,WAAWK;gBACXD,GAAGL;YACL;QACF;QACAE,MAAMC,KAAK,CAACf,mBAAmBgB,IAAI,CAAC,MAAMR,WAAWJ,MAAM;YAAEe,OAAO;YAAGC,MAAM;QAAK;QAClFN,MAAMO,KAAK,CAAC,CAACT,MAAQN,SAASM,KAAKC;IACrC;AACF"}
@@ -1,6 +1,9 @@
1
+ import { safeRm } from 'fs-remove-compat';
1
2
  import isVersion from 'is-version';
2
3
  import mkdirp from 'mkdirp-classic';
4
+ import { getDist } from 'node-filename-to-dist-paths';
3
5
  import resolveVersions from 'node-resolve-versions';
6
+ import path from 'path';
4
7
  import Queue from 'queue-cb';
5
8
  import { DEFAULT_STORAGE_PATHS } from '../constants.js';
6
9
  import createResult from '../createResult.js';
@@ -38,16 +41,48 @@ export default function install(versionExpression, options, callback) {
38
41
  }
39
42
  const version = versions[0];
40
43
  const result = createResult(options, version);
44
+ // Check if node is missing first
41
45
  checkMissing(result.installPath, options, (err, missing)=>{
42
- if (err || !missing.length) {
43
- callback(err, result);
46
+ if (err) {
47
+ callback(err);
48
+ return;
49
+ }
50
+ // Early exit if both node and npm are already present
51
+ if (!missing.length) {
52
+ callback(null, result);
44
53
  return;
45
54
  }
46
55
  const queue = new Queue(1);
47
56
  queue.defer(mkdirp.bind(null, options.cachePath));
48
57
  queue.defer(ensureDestinationParent.bind(null, result.installPath));
58
+ // Install node if missing
49
59
  !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, result.installPath, options));
50
- !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, result.installPath, options));
60
+ // Check and install npm AFTER node (so bundled npm is detected)
61
+ // Skip npm download only if bundled npm is modern (6+); old npm (<6) was buggy
62
+ queue.defer((cb)=>{
63
+ checkMissing(result.installPath, options, (err, npmMissing)=>{
64
+ if (err) {
65
+ cb(err);
66
+ return;
67
+ }
68
+ if (!~npmMissing.indexOf('npm')) {
69
+ // npm is present - check if it's modern enough to keep (npm >= 3 is stable)
70
+ const dist = getDist(version);
71
+ const bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;
72
+ if (bundledNpmMajor >= 3) {
73
+ cb(); // npm >= 3 bundled, skip download
74
+ return;
75
+ }
76
+ // old npm (<3) is buggy - delete it so installNPM can override
77
+ const platform = options.platform;
78
+ const libPath = platform === 'win32' ? result.installPath : path.join(result.installPath, 'lib');
79
+ const npmPath = path.join(libPath, 'node_modules', 'npm');
80
+ safeRm(npmPath, ()=>installNPM(version, result.installPath, options, cb));
81
+ return;
82
+ }
83
+ installNPM(version, result.installPath, options, cb);
84
+ });
85
+ });
51
86
  queue.await((err)=>err ? callback(err) : callback(null, result));
52
87
  });
53
88
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport resolveVersions from 'node-resolve-versions';\nimport Queue from 'queue-cb';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n checkMissing(result.installPath, options, (err, missing): undefined => {\n if (err || !missing.length) {\n callback(err, result);\n return;\n }\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, options.cachePath));\n queue.defer(ensureDestinationParent.bind(null, result.installPath));\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, result.installPath, options));\n !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, result.installPath, options));\n queue.await((err) => (err ? callback(err) : callback(null, result)));\n });\n });\n}\n"],"names":["isVersion","mkdirp","resolveVersions","Queue","DEFAULT_STORAGE_PATHS","createResult","createStoragePaths","installNode","installNPM","checkMissing","ensureDestinationParent","getTarget","getVersions","versionExpression","options","callback","install","storagePaths","storagePath","err","versions","length","Error","map","x","version","result","installPath","missing","queue","defer","bind","cachePath","indexOf","await"],"mappings":"AAAA,OAAOA,eAAe,aAAa;AACnC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,qBAAqB,wBAAwB;AACpD,OAAOC,WAAW,WAAW;AAE7B,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,OAAOC,kBAAkB,qBAAqB;AAC9C,OAAOC,wBAAwB,2BAA2B;AAC1D,OAAOC,iBAAiB,0BAA0B;AA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C,WAAW;YACjE,CAAC,CAACC,QAAQK,OAAO,CAAC,WAAWJ,MAAMC,KAAK,CAACvB,YAAYwB,IAAI,CAAC,MAAMN,SAASC,OAAOC,WAAW,EAAEb;YAC7F,CAAC,CAACc,QAAQK,OAAO,CAAC,UAAUJ,MAAMC,KAAK,CAACtB,WAAWuB,IAAI,CAAC,MAAMN,SAASC,OAAOC,WAAW,EAAEb;YAC3Fe,MAAMK,KAAK,CAAC,CAACf,MAASA,MAAMJ,SAASI,OAAOJ,SAAS,MAAMW;QAC7D;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import { safeRm } from 'fs-remove-compat';\nimport isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport resolveVersions from 'node-resolve-versions';\nimport path from 'path';\nimport Queue from 'queue-cb';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n // Check if node is missing first\n checkMissing(result.installPath, options, (err, missing): undefined => {\n if (err) {\n callback(err);\n return;\n }\n\n // Early exit if both node and npm are already present\n if (!missing.length) {\n callback(null, result);\n return;\n }\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, options.cachePath));\n queue.defer(ensureDestinationParent.bind(null, result.installPath));\n\n // Install node if missing\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, result.installPath, options));\n\n // Check and install npm AFTER node (so bundled npm is detected)\n // Skip npm download only if bundled npm is modern (6+); old npm (<6) was buggy\n queue.defer((cb) => {\n checkMissing(result.installPath, options, (err, npmMissing): undefined => {\n if (err) {\n cb(err);\n return;\n }\n if (!~npmMissing.indexOf('npm')) {\n // npm is present - check if it's modern enough to keep (npm >= 3 is stable)\n const dist = getDist(version);\n const bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;\n if (bundledNpmMajor >= 3) {\n cb(); // npm >= 3 bundled, skip download\n return;\n }\n // old npm (<3) is buggy - delete it so installNPM can override\n const platform = options.platform;\n const libPath = platform === 'win32' ? result.installPath : path.join(result.installPath, 'lib');\n const npmPath = path.join(libPath, 'node_modules', 'npm');\n safeRm(npmPath, () => installNPM(version, result.installPath, options, cb));\n return;\n }\n installNPM(version, result.installPath, options, cb);\n });\n });\n\n queue.await((err) => (err ? callback(err) : callback(null, result)));\n });\n });\n}\n"],"names":["safeRm","isVersion","mkdirp","getDist","resolveVersions","path","Queue","DEFAULT_STORAGE_PATHS","createResult","createStoragePaths","installNode","installNPM","checkMissing","ensureDestinationParent","getTarget","getVersions","versionExpression","options","callback","install","storagePaths","storagePath","err","versions","length","Error","map","x","version","result","installPath","missing","queue","defer","bind","cachePath","indexOf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UzC,KAAKwC,IAAI,CAACD,SAAS,gBAAgB;wBACnD5C,OAAO8C,SAAS,IAAMnC,WAAWiB,SAASC,OAAOC,WAAW,EAAEb,SAASoB;wBACvE;oBACF;oBACA1B,WAAWiB,SAASC,OAAOC,WAAW,EAAEb,SAASoB;gBACnD;YACF;YAEAL,MAAMe,KAAK,CAAC,CAACzB,MAASA,MAAMJ,SAASI,OAAOJ,SAAS,MAAMW;QAC7D;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-install-release",
3
- "version": "1.15.8",
3
+ "version": "1.16.0",
4
4
  "description": "Cross-platform solution for installing releases of Node.js",
5
5
  "keywords": [
6
6
  "node",
@@ -39,7 +39,7 @@
39
39
  "format": "tsds format",
40
40
  "prepublishOnly": "tsds validate",
41
41
  "test": "tsds test:node --no-timeouts",
42
- "test:engines": "nvu 0.8,0.10,0.12,4,12,16,lts,stable tsds test:node --no-timeouts",
42
+ "test:engines": "nvu engines tsds test:node --no-timeouts",
43
43
  "version": "tsds version"
44
44
  },
45
45
  "dependencies": {
@@ -67,10 +67,10 @@
67
67
  "lodash.find": "^4.6.0",
68
68
  "lodash.values": "^4.3.0",
69
69
  "node-version-compare": "^1.0.3",
70
- "node-version-use": "^2.1.0",
70
+ "node-version-use": "^2.1.1",
71
71
  "node-version-utils": "^1.3.15",
72
72
  "pinkie-promise": "^2.0.1",
73
- "ts-dev-stack": "^1.21.2",
73
+ "ts-dev-stack": "^1.21.3",
74
74
  "tsds-config": "^0.2.0"
75
75
  },
76
76
  "engines": {