node-install-release 1.15.7 → 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.
- package/dist/cjs/cli.js +5 -5
- package/dist/cjs/cli.js.map +1 -1
- package/dist/cjs/installNode/installCompressed.js +1 -8
- package/dist/cjs/installNode/installCompressed.js.map +1 -1
- package/dist/cjs/workers/install.js +40 -3
- package/dist/cjs/workers/install.js.map +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/installNode/installCompressed.js +1 -8
- package/dist/esm/installNode/installCompressed.js.map +1 -1
- package/dist/esm/workers/install.js +38 -3
- package/dist/esm/workers/install.js.map +1 -1
- package/package.json +28 -28
package/dist/cjs/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return _default;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
var
|
|
11
|
+
var _exitcompat = /*#__PURE__*/ _interop_require_default(require("exit-compat"));
|
|
12
12
|
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
13
13
|
var _getoptscompat = /*#__PURE__*/ _interop_require_default(require("getopts-compat"));
|
|
14
14
|
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
@@ -66,18 +66,18 @@ var _default = function(argv, name) {
|
|
|
66
66
|
});
|
|
67
67
|
if (options.version) {
|
|
68
68
|
console.log(getPackageVersion());
|
|
69
|
-
(0,
|
|
69
|
+
(0, _exitcompat.default)(0);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
if (options.help) {
|
|
73
73
|
printHelp(cliName);
|
|
74
|
-
(0,
|
|
74
|
+
(0, _exitcompat.default)(0);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
var args = options._;
|
|
78
78
|
if (args.length < 1) {
|
|
79
79
|
console.log("Missing command. Example usage: ".concat(cliName, " <version> [directory]"));
|
|
80
|
-
(0,
|
|
80
|
+
(0, _exitcompat.default)(ERROR_CODE);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
(0, _indexts.default)(args[0], options, function(err, result) {
|
|
@@ -87,7 +87,7 @@ var _default = function(argv, name) {
|
|
|
87
87
|
else console.log("".concat(result.version, " installed in: ").concat(result.installPath));
|
|
88
88
|
console.log('======================');
|
|
89
89
|
}
|
|
90
|
-
(0,
|
|
90
|
+
(0, _exitcompat.default)(err ? ERROR_CODE : 0);
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
93
|
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
package/dist/cjs/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport url from 'url';\nimport install, { type InstallOptions } from './index.ts';\n\nconst ERROR_CODE = 9;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nfunction getPackageVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getPackageVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} <version> [options]`);\n console.log('');\n console.log('Arguments:');\n console.log(' version Node.js version to install (e.g., 18.0.0, lts, stable)');\n console.log('');\n console.log('Options:');\n console.log(' -p, --platform Target platform (default: current platform)');\n console.log(' -a, --arch Target architecture (default: current architecture)');\n console.log(' -f, --filename Specific filename to download');\n console.log(' -i, --installPath Installation directory');\n console.log(' -c, --storagePath Cache storage directory');\n console.log(' -si, --silent Suppress output');\n console.log(' -v, --version Show version number');\n console.log(' -h, --help Show this help message');\n}\n\nexport default (argv: string[], name?: string): undefined => {\n const cliName = name || 'nir';\n const options = getopts(argv, {\n alias: { platform: 'p', arch: 'a', filename: 'f', installPath: 'i', storagePath: 'c', silent: 'si', version: 'v', help: 'h' },\n boolean: ['silent', 'version', 'help'],\n });\n\n if (options.version) {\n console.log(getPackageVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(cliName);\n exit(0);\n return;\n }\n\n const args = options._;\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${cliName} <version> [directory]`);\n exit(ERROR_CODE);\n return;\n }\n install(args[0], options as InstallOptions, (err, result) => {\n if (!options.silent) {\n console.log('\\n======================');\n if (err) console.log(`${args[0]} not installed. Error: ${err.message}`);\n else console.log(`${result.version} installed in: ${result.installPath}`);\n console.log('======================');\n }\n exit(err ? ERROR_CODE : 0);\n });\n};\n"],"names":["ERROR_CODE","__dirname","path","dirname","__filename","url","fileURLToPath","getPackageVersion","packagePath","join","packageJson","JSON","parse","fs","readFileSync","version","printHelp","name","console","log","argv","cliName","options","getopts","alias","platform","arch","filename","installPath","storagePath","silent","help","boolean","exit","args","_","length","install","err","result","message"],"mappings":";;;;+BAoCA;;;eAAA;;;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport url from 'url';\nimport install, { type InstallOptions } from './index.ts';\n\nconst ERROR_CODE = 9;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nfunction getPackageVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getPackageVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} <version> [options]`);\n console.log('');\n console.log('Arguments:');\n console.log(' version Node.js version to install (e.g., 18.0.0, lts, stable)');\n console.log('');\n console.log('Options:');\n console.log(' -p, --platform Target platform (default: current platform)');\n console.log(' -a, --arch Target architecture (default: current architecture)');\n console.log(' -f, --filename Specific filename to download');\n console.log(' -i, --installPath Installation directory');\n console.log(' -c, --storagePath Cache storage directory');\n console.log(' -si, --silent Suppress output');\n console.log(' -v, --version Show version number');\n console.log(' -h, --help Show this help message');\n}\n\nexport default (argv: string[], name?: string): undefined => {\n const cliName = name || 'nir';\n const options = getopts(argv, {\n alias: { platform: 'p', arch: 'a', filename: 'f', installPath: 'i', storagePath: 'c', silent: 'si', version: 'v', help: 'h' },\n boolean: ['silent', 'version', 'help'],\n });\n\n if (options.version) {\n console.log(getPackageVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(cliName);\n exit(0);\n return;\n }\n\n const args = options._;\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${cliName} <version> [directory]`);\n exit(ERROR_CODE);\n return;\n }\n install(args[0], options as InstallOptions, (err, result) => {\n if (!options.silent) {\n console.log('\\n======================');\n if (err) console.log(`${args[0]} not installed. Error: ${err.message}`);\n else console.log(`${result.version} installed in: ${result.installPath}`);\n console.log('======================');\n }\n exit(err ? ERROR_CODE : 0);\n });\n};\n"],"names":["ERROR_CODE","__dirname","path","dirname","__filename","url","fileURLToPath","getPackageVersion","packagePath","join","packageJson","JSON","parse","fs","readFileSync","version","printHelp","name","console","log","argv","cliName","options","getopts","alias","platform","arch","filename","installPath","storagePath","silent","help","boolean","exit","args","_","length","install","err","result","message"],"mappings":";;;;+BAoCA;;;eAAA;;;iEApCiB;yDACF;oEACK;2DACH;0DACD;8DAC6B;;;;;;AAE7C,IAAMA,aAAa;AACnB,IAAMC,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAElG,SAASC;IACP,IAAMC,cAAcN,a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,mCAA0C,OAARE,SAAQ;QACvDY,IAAAA,mBAAI,EAACjC;QACL;IACF;IACAqC,IAAAA,gBAAO,EAACH,IAAI,CAAC,EAAE,EAAEZ,SAA2B,SAACgB,KAAKC;QAChD,IAAI,CAACjB,QAAQQ,MAAM,EAAE;YACnBZ,QAAQC,GAAG,CAAC;YACZ,IAAImB,KAAKpB,QAAQC,GAAG,CAAC,AAAC,GAAmCmB,OAAjCJ,IAAI,CAAC,EAAE,EAAC,2BAAqC,OAAZI,IAAIE,OAAO;iBAC/DtB,QAAQC,GAAG,CAAC,AAAC,GAAkCoB,OAAhCA,OAAOxB,OAAO,EAAC,mBAAoC,OAAnBwB,OAAOX,WAAW;YACtEV,QAAQC,GAAG,CAAC;QACd;QACAc,IAAAA,mBAAI,EAACK,MAAMtC,aAAa;IAC1B;AACF"}
|
|
@@ -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
|
-
|
|
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
|
|
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
|
|
84
|
-
callback(err
|
|
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
|
-
|
|
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
|
|
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,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;QAErC,iCAAiC;QACjCG,IAAAA,uBAAY,EAACF,OAAOG,WAAW,EAAEnB,SAAS,SAACS,KAAKW;YAC9C,IAAIX,KAAK;gBACPR,SAASQ;gBACT;YACF;YAEA,sDAAsD;YACtD,IAAI,CAACW,QAAQT,MAAM,E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AEnB,SAAS8B;gBACnD;YACF;YAEAT,MAAMuB,KAAK,CAAC,SAACnC;uBAASA,MAAMR,SAASQ,OAAOR,SAAS,MAAMe;;QAC7D;IACF;AACF"}
|
package/dist/esm/cli.js
CHANGED
package/dist/esm/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport url from 'url';\nimport install, { type InstallOptions } from './index.ts';\n\nconst ERROR_CODE = 9;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nfunction getPackageVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getPackageVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} <version> [options]`);\n console.log('');\n console.log('Arguments:');\n console.log(' version Node.js version to install (e.g., 18.0.0, lts, stable)');\n console.log('');\n console.log('Options:');\n console.log(' -p, --platform Target platform (default: current platform)');\n console.log(' -a, --arch Target architecture (default: current architecture)');\n console.log(' -f, --filename Specific filename to download');\n console.log(' -i, --installPath Installation directory');\n console.log(' -c, --storagePath Cache storage directory');\n console.log(' -si, --silent Suppress output');\n console.log(' -v, --version Show version number');\n console.log(' -h, --help Show this help message');\n}\n\nexport default (argv: string[], name?: string): undefined => {\n const cliName = name || 'nir';\n const options = getopts(argv, {\n alias: { platform: 'p', arch: 'a', filename: 'f', installPath: 'i', storagePath: 'c', silent: 'si', version: 'v', help: 'h' },\n boolean: ['silent', 'version', 'help'],\n });\n\n if (options.version) {\n console.log(getPackageVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(cliName);\n exit(0);\n return;\n }\n\n const args = options._;\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${cliName} <version> [directory]`);\n exit(ERROR_CODE);\n return;\n }\n install(args[0], options as InstallOptions, (err, result) => {\n if (!options.silent) {\n console.log('\\n======================');\n if (err) console.log(`${args[0]} not installed. Error: ${err.message}`);\n else console.log(`${result.version} installed in: ${result.installPath}`);\n console.log('======================');\n }\n exit(err ? ERROR_CODE : 0);\n });\n};\n"],"names":["exit","fs","getopts","path","url","install","ERROR_CODE","__dirname","dirname","__filename","fileURLToPath","getPackageVersion","packagePath","join","packageJson","JSON","parse","readFileSync","version","printHelp","name","console","log","argv","cliName","options","alias","platform","arch","filename","installPath","storagePath","silent","help","boolean","args","_","length","err","result","message"],"mappings":"AAAA,OAAOA,UAAU,
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit-compat';\nimport fs from 'fs';\nimport getopts from 'getopts-compat';\nimport path from 'path';\nimport url from 'url';\nimport install, { type InstallOptions } from './index.ts';\n\nconst ERROR_CODE = 9;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\nfunction getPackageVersion(): string {\n const packagePath = path.join(__dirname, '..', '..', 'package.json');\n const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));\n return packageJson.version;\n}\n\nfunction printHelp(name: string): void {\n const version = getPackageVersion();\n console.log(`${name} v${version}`);\n console.log('');\n console.log(`Usage: ${name} <version> [options]`);\n console.log('');\n console.log('Arguments:');\n console.log(' version Node.js version to install (e.g., 18.0.0, lts, stable)');\n console.log('');\n console.log('Options:');\n console.log(' -p, --platform Target platform (default: current platform)');\n console.log(' -a, --arch Target architecture (default: current architecture)');\n console.log(' -f, --filename Specific filename to download');\n console.log(' -i, --installPath Installation directory');\n console.log(' -c, --storagePath Cache storage directory');\n console.log(' -si, --silent Suppress output');\n console.log(' -v, --version Show version number');\n console.log(' -h, --help Show this help message');\n}\n\nexport default (argv: string[], name?: string): undefined => {\n const cliName = name || 'nir';\n const options = getopts(argv, {\n alias: { platform: 'p', arch: 'a', filename: 'f', installPath: 'i', storagePath: 'c', silent: 'si', version: 'v', help: 'h' },\n boolean: ['silent', 'version', 'help'],\n });\n\n if (options.version) {\n console.log(getPackageVersion());\n exit(0);\n return;\n }\n\n if (options.help) {\n printHelp(cliName);\n exit(0);\n return;\n }\n\n const args = options._;\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${cliName} <version> [directory]`);\n exit(ERROR_CODE);\n return;\n }\n install(args[0], options as InstallOptions, (err, result) => {\n if (!options.silent) {\n console.log('\\n======================');\n if (err) console.log(`${args[0]} not installed. Error: ${err.message}`);\n else console.log(`${result.version} installed in: ${result.installPath}`);\n console.log('======================');\n }\n exit(err ? ERROR_CODE : 0);\n });\n};\n"],"names":["exit","fs","getopts","path","url","install","ERROR_CODE","__dirname","dirname","__filename","fileURLToPath","getPackageVersion","packagePath","join","packageJson","JSON","parse","readFileSync","version","printHelp","name","console","log","argv","cliName","options","alias","platform","arch","filename","installPath","storagePath","silent","help","boolean","args","_","length","err","result","message"],"mappings":"AAAA,OAAOA,UAAU,cAAc;AAC/B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AACtB,OAAOC,aAAsC,aAAa;AAE1D,MAAMC,aAAa;AACnB,MAAMC,YAAYJ,KAAKK,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaL,IAAIM,aAAa,CAAC,YAAYN,GAAG;AAEjH,SAASO;IACP,MAAMC,cAAcT,KAAKU,IAAI,CAACN,WAAW,MAAM,MAAM;IACrD,MAAMO,cAAcC,KAAKC,KAAK,CAACf,GAAGgB,YAAY,CAACL,aAAa;IAC5D,OAAOE,YAAYI,OAAO;AAC5B;AAEA,SAASC,UAAUC,IAAY;IAC7B,MAAMF,UAAUP;IAChBU,QAAQC,GAAG,CAAC,GAAGF,KAAK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CAAC,uBAAuB,EAAEG,IAAIE,OAAO,EAAE;iBACjEnB,QAAQC,GAAG,CAAC,GAAGiB,OAAOrB,OAAO,CAAC,eAAe,EAAEqB,OAAOT,WAAW,EAAE;YACxET,QAAQC,GAAG,CAAC;QACd;QACAtB,KAAKsC,MAAMhC,aAAa;IAC1B;AACF,CAAA,EAAE"}
|
|
@@ -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
|
|
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
|
|
43
|
-
callback(err
|
|
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
|
-
|
|
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
|
|
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","cb","npmMissing","dist","bundledNpmMajor","npm","split","platform","libPath","join","npmPath","await"],"mappings":"AAAA,SAASA,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,eAAe,aAAa;AACnC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,OAAO,QAAQ,8BAA8B;AACtD,OAAOC,qBAAqB,wBAAwB;AACpD,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAE7B,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,OAAOC,kBAAkB,qBAAqB;AAC9C,OAAOC,wBAAwB,2BAA2B;AAC1D,OAAOC,iBAAiB,0BAA0B;AAElD,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,kBAAkB,yBAAyB;AAClD,OAAOC,6BAA6B,oCAAoC;AACxE,OAAOC,eAAe,sBAAsB;AAK5C,SAASC,YAAYC,iBAAyB,EAAEC,OAAuB,EAAEC,QAA6B;IACpG,gBAAgB;IAChBjB,UAAUe,qBAAqBE,SAAS,MAAM;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gE;YAChE,+EAA+E;YAC/Ee,MAAMC,KAAK,CAAC,CAACI;gBACXzB,aAAaiB,OAAOC,WAAW,EAAEb,SAAS,CAACK,KAAKgB;oBAC9C,IAAIhB,KAAK;wBACPe,GAAGf;wBACH;oBACF;oBACA,IAAI,CAAC,CAACgB,WAAWF,OAAO,CAAC,QAAQ;wBAC/B,4EAA4E;wBAC5E,MAAMG,OAAOpC,QAAQyB;wBACrB,MAAMY,kBAAkBD,QAAQA,KAAKE,GAAG,GAAG,CAACF,KAAKE,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG;wBACrE,IAAIF,mBAAmB,GAAG;4BACxBH,MAAM,kCAAkC;4BACxC;wBACF;wBACA,+DAA+D;wBAC/D,MAAMM,WAAW1B,QAAQ0B,QAAQ;wBACjC,MAAMC,UAAUD,aAAa,UAAUd,OAAOC,WAAW,GAAGzB,KAAKwC,IAAI,CAAChB,OAAOC,WAAW,EAAE;wBAC1F,MAAMgB,UAAUzC,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.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Cross-platform solution for installing releases of Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -39,39 +39,39 @@
|
|
|
39
39
|
"format": "tsds format",
|
|
40
40
|
"prepublishOnly": "tsds validate",
|
|
41
41
|
"test": "tsds test:node --no-timeouts",
|
|
42
|
-
"test:engines": "nvu
|
|
42
|
+
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
43
43
|
"version": "tsds version"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"cpu-arch": "^1.0.4",
|
|
47
|
-
"cross-spawn-cb": "
|
|
48
|
-
"exit": "
|
|
49
|
-
"fast-extract": "
|
|
50
|
-
"fs-copy-compat": "
|
|
51
|
-
"fs-remove-compat": "
|
|
52
|
-
"get-remote": "
|
|
53
|
-
"getopts-compat": "
|
|
54
|
-
"homedir-polyfill": "
|
|
55
|
-
"is-version": "
|
|
56
|
-
"lodash.keys": "
|
|
57
|
-
"mkdirp-classic": "
|
|
58
|
-
"node-filename-to-dist-paths": "
|
|
59
|
-
"node-resolve-versions": "
|
|
60
|
-
"on-one": "
|
|
61
|
-
"queue-cb": "
|
|
47
|
+
"cross-spawn-cb": "^2.4.10",
|
|
48
|
+
"exit-compat": "^1.0.0",
|
|
49
|
+
"fast-extract": "^1.8.13",
|
|
50
|
+
"fs-copy-compat": "^0.1.3",
|
|
51
|
+
"fs-remove-compat": "^0.2.1",
|
|
52
|
+
"get-remote": "^2.3.0",
|
|
53
|
+
"getopts-compat": "^2.2.6",
|
|
54
|
+
"homedir-polyfill": "^1.0.3",
|
|
55
|
+
"is-version": "^1.0.7",
|
|
56
|
+
"lodash.keys": "^4.2.0",
|
|
57
|
+
"mkdirp-classic": "^0.5.3",
|
|
58
|
+
"node-filename-to-dist-paths": "^1.3.11",
|
|
59
|
+
"node-resolve-versions": "^1.3.11",
|
|
60
|
+
"on-one": "^1.0.8",
|
|
61
|
+
"queue-cb": "^1.6.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@types/mocha": "
|
|
65
|
-
"@types/node": "
|
|
66
|
-
"cr": "
|
|
67
|
-
"lodash.find": "
|
|
68
|
-
"lodash.values": "
|
|
69
|
-
"node-version-compare": "
|
|
70
|
-
"node-version-use": "
|
|
71
|
-
"node-version-utils": "
|
|
72
|
-
"pinkie-promise": "
|
|
73
|
-
"ts-dev-stack": "
|
|
74
|
-
"tsds-config": "
|
|
64
|
+
"@types/mocha": "^10.0.10",
|
|
65
|
+
"@types/node": "^25.0.0",
|
|
66
|
+
"cr": "^0.1.0",
|
|
67
|
+
"lodash.find": "^4.6.0",
|
|
68
|
+
"lodash.values": "^4.3.0",
|
|
69
|
+
"node-version-compare": "^1.0.3",
|
|
70
|
+
"node-version-use": "^2.1.1",
|
|
71
|
+
"node-version-utils": "^1.3.15",
|
|
72
|
+
"pinkie-promise": "^2.0.1",
|
|
73
|
+
"ts-dev-stack": "^1.21.3",
|
|
74
|
+
"tsds-config": "^0.2.0"
|
|
75
75
|
},
|
|
76
76
|
"engines": {
|
|
77
77
|
"node": ">=0.8"
|