node-install-release 1.7.0 → 1.7.2

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.cjs CHANGED
@@ -22,7 +22,8 @@ var _default = function(argv) {
22
22
  platform: 'p',
23
23
  arch: 'a',
24
24
  filename: 'f',
25
- cachePath: 'c',
25
+ installPath: 'i',
26
+ storagePath: 'c',
26
27
  silent: 's'
27
28
  },
28
29
  boolean: [
@@ -38,14 +39,11 @@ var _default = function(argv) {
38
39
  console.log('Missing command. Example usage: nir version [directory]');
39
40
  return (0, _exit.default)(-1);
40
41
  }
41
- var installPath = args.length > 1 ? args[1] : process.cwd();
42
- (0, _index.default)(args[0], installPath, {
43
- addVersion: true
44
- }, function(err, result) {
42
+ (0, _index.default)(args[0], options, function(err, result) {
45
43
  if (!options.silent) {
46
44
  console.log('\n======================');
47
45
  if (err) console.log("".concat(args[0], " not installed. Error: ").concat(err.message));
48
- else console.log("".concat(result.version, " installed in: ").concat(installPath));
46
+ else console.log("".concat(result.version, " installed in: ").concat(result.installPath));
49
47
  console.log('======================');
50
48
  }
51
49
  (0, _exit.default)(err ? -1 : 0);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nir from './index';\n\nexport default (argv) => {\n const options = getopts(argv.slice(1), {\n alias: { platform: 'p', arch: 'a', filename: 'f', cachePath: 'c', silent: 's' },\n boolean: ['silent'],\n });\n\n // define.option('-p, --platform [platform]', 'Platform like darwin');\n // define.option('-a, --arch [arch]', 'Architecure x64, x86, arm-pi');\n // define.option('-f, --filename [filename]', 'Distribution filename from https://nodejs.org/dist/index.json');\n // define.option('-c, --cachePath [cachePath]', 'Cache directory');\n\n const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log('Missing command. Example usage: nir version [directory]');\n return exit(-1);\n }\n\n const installPath = args.length > 1 ? args[1] : process.cwd();\n nir(args[0], installPath, { addVersion: true }, (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: ${installPath}`);\n console.log('======================');\n }\n exit(err ? -1 : 0);\n });\n};\n"],"names":["argv","options","getopts","slice","alias","platform","arch","filename","cachePath","silent","boolean","args","concat","_","length","console","log","exit","installPath","process","cwd","nir","addVersion","err","result","message","version"],"mappings":";;;;+BAIA;;;eAAA;;;2DAJiB;oEACG;4DACJ;;;;;;IAEhB,WAAe,SAACA;IACd,IAAMC,UAAUC,IAAAA,sBAAO,EAACF,KAAKG,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,UAAU;YAAKC,MAAM;YAAKC,UAAU;YAAKC,WAAW;YAAKC,QAAQ;QAAI;QAC9EC,SAAS;YAAC;SAAS;IACrB;IAEA,sEAAsE;IACtE,sEAAsE;IACtE,+GAA+G;IAC/G,mEAAmE;IAEnE,IAAMC,OAAOX,KAAKG,KAAK,CAAC,GAAG,GAAGS,MAAM,CAACX,QAAQY,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC;QACZ,OAAOC,IAAAA,aAAI,EAAC,CAAC;IACf;IAEA,IAAMC,cAAcP,KAAKG,MAAM,GAAG,IAAIH,IAAI,CAAC,EAAE,GAAGQ,QAAQC,GAAG;IAC3DC,IAAAA,cAAG,EAACV,IAAI,CAAC,EAAE,EAAEO,aAAa;QAAEI,YAAY;IAAK,GAAG,SAACC,KAAKC;QACpD,IAAI,CAACvB,QAAQQ,MAAM,EAAE;YACnBM,QAAQC,GAAG,CAAC;YACZ,IAAIO,KAAKR,QAAQC,GAAG,CAAC,AAAC,GAAmCO,OAAjCZ,IAAI,CAAC,EAAE,EAAC,2BAAqC,OAAZY,IAAIE,OAAO;iBAC/DV,QAAQC,GAAG,CAAC,AAAC,GAAkCE,OAAhCM,OAAOE,OAAO,EAAC,mBAA6B,OAAZR;YACpDH,QAAQC,GAAG,CAAC;QACd;QACAC,IAAAA,aAAI,EAACM,MAAM,CAAC,IAAI;IAClB;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nir, { type InstallOptions } from './index';\n\nexport default (argv) => {\n const options = getopts(argv.slice(1), {\n alias: { platform: 'p', arch: 'a', filename: 'f', installPath: 'i', storagePath: 'c', silent: 's' },\n boolean: ['silent'],\n });\n\n // define.option('-p, --platform [platform]', 'Platform like darwin');\n // define.option('-a, --arch [arch]', 'Architecure x64, x86, arm-pi');\n // define.option('-f, --filename [filename]', 'Distribution filename from https://nodejs.org/dist/index.json');\n // define.option('-c, --cachePath [cachePath]', 'Cache directory');\n\n const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log('Missing command. Example usage: nir version [directory]');\n return exit(-1);\n }\n nir(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 ? -1 : 0);\n });\n};\n"],"names":["argv","options","getopts","slice","alias","platform","arch","filename","installPath","storagePath","silent","boolean","args","concat","_","length","console","log","exit","nir","err","result","message","version"],"mappings":";;;;+BAIA;;;eAAA;;;2DAJiB;oEACG;4DACqB;;;;;;IAEzC,WAAe,SAACA;IACd,IAAMC,UAAUC,IAAAA,sBAAO,EAACF,KAAKG,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,UAAU;YAAKC,MAAM;YAAKC,UAAU;YAAKC,aAAa;YAAKC,aAAa;YAAKC,QAAQ;QAAI;QAClGC,SAAS;YAAC;SAAS;IACrB;IAEA,sEAAsE;IACtE,sEAAsE;IACtE,+GAA+G;IAC/G,mEAAmE;IAEnE,IAAMC,OAAOZ,KAAKG,KAAK,CAAC,GAAG,GAAGU,MAAM,CAACZ,QAAQa,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC;QACZ,OAAOC,IAAAA,aAAI,EAAC,CAAC;IACf;IACAC,IAAAA,cAAG,EAACP,IAAI,CAAC,EAAE,EAAEX,SAA2B,SAACmB,KAAKC;QAC5C,IAAI,CAACpB,QAAQS,MAAM,EAAE;YACnBM,QAAQC,GAAG,CAAC;YACZ,IAAIG,KAAKJ,QAAQC,GAAG,CAAC,AAAC,GAAmCG,OAAjCR,IAAI,CAAC,EAAE,EAAC,2BAAqC,OAAZQ,IAAIE,OAAO;iBAC/DN,QAAQC,GAAG,CAAC,AAAC,GAAkCI,OAAhCA,OAAOE,OAAO,EAAC,mBAAoC,OAAnBF,OAAOb,WAAW;YACtEQ,QAAQC,GAAG,CAAC;QACd;QACAC,IAAAA,aAAI,EAACE,MAAM,CAAC,IAAI;IAClB;AACF"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return createStoragePaths;
9
+ }
10
+ });
11
+ var _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function createStoragePaths(storagePath) {
18
+ return {
19
+ cachePath: _path.default.join(storagePath, 'cache'),
20
+ buildPath: _path.default.join(storagePath, 'build'),
21
+ installPath: _path.default.join(storagePath, 'build')
22
+ };
23
+ }
24
+ /* 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; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/createStoragePaths.ts"],"sourcesContent":["import path from 'path';\n\nimport type { StorageLocations } from './types';\n\nexport default function createStoragePaths(storagePath: string): StorageLocations {\n return {\n cachePath: path.join(storagePath, 'cache'),\n buildPath: path.join(storagePath, 'build'),\n installPath: path.join(storagePath, 'build'),\n };\n}\n"],"names":["createStoragePaths","storagePath","cachePath","path","join","buildPath","installPath"],"mappings":";;;;+BAIA;;;eAAwBA;;;2DAJP;;;;;;AAIF,SAASA,mBAAmBC,WAAmB;IAC5D,OAAO;QACLC,WAAWC,aAAI,CAACC,IAAI,CAACH,aAAa;QAClCI,WAAWF,aAAI,CAACC,IAAI,CAACH,aAAa;QAClCK,aAAaH,aAAI,CAACC,IAAI,CAACH,aAAa;IACtC;AACF"}
@@ -2,28 +2,37 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ createStoragePaths: function() {
13
+ return _createStoragePaths.default;
14
+ },
15
+ default: function() {
8
16
  return install;
9
17
  }
10
18
  });
11
19
  require("./polyfills.cjs");
12
20
  var _install = /*#__PURE__*/ _interop_require_default(require("./workers/install.cjs"));
21
+ var _createStoragePaths = /*#__PURE__*/ _interop_require_default(require("./createStoragePaths.cjs"));
13
22
  function _interop_require_default(obj) {
14
23
  return obj && obj.__esModule ? obj : {
15
24
  default: obj
16
25
  };
17
26
  }
18
- function install(versionExpression, dest, options, callback) {
27
+ function install(versionExpression, options, callback) {
19
28
  if (typeof options === 'function') {
20
29
  callback = options;
21
30
  options = {};
22
31
  }
23
32
  options = options || {};
24
- if (typeof callback === 'function') return (0, _install.default)(versionExpression, dest, options, callback);
33
+ if (typeof callback === 'function') return (0, _install.default)(versionExpression, options, callback);
25
34
  return new Promise(function(resolve, reject) {
26
- return (0, _install.default)(versionExpression, dest, options, function(err, result) {
35
+ return (0, _install.default)(versionExpression, options, function(err, result) {
27
36
  return err ? reject(err) : resolve(result);
28
37
  });
29
38
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/index.ts"],"sourcesContent":["import './polyfills.cjs';\nimport worker from './workers/install';\n\nimport type { InstallCallback, InstallOptions, InstallResult } from './types';\n\nexport type * from './types';\nexport default function install(versionExpression: string, dest: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): undefined | Promise<InstallResult> {\n if (typeof options === 'function') {\n callback = options as InstallCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(versionExpression, dest, options, callback) as undefined;\n return new Promise((resolve, reject) => worker(versionExpression, dest, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["install","versionExpression","dest","options","callback","worker","Promise","resolve","reject","err","result"],"mappings":";;;;+BAMA;;;eAAwBA;;;QANjB;8DACY;;;;;;AAKJ,SAASA,QAAQC,iBAAyB,EAAEC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;IAC7I,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,IAAAA,gBAAM,EAACJ,mBAAmBC,MAAMC,SAASC;IACpF,OAAO,IAAIE,QAAQ,SAACC,SAASC;eAAWH,IAAAA,gBAAM,EAACJ,mBAAmBC,MAAMC,SAAS,SAACM,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACjI"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/index.ts"],"sourcesContent":["import './polyfills.cjs';\nimport worker from './workers/install';\n\nimport type { InstallCallback, InstallOptions, InstallResult } from './types';\n\nexport type * from './types';\nexport default function install(versionExpression: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): undefined | Promise<InstallResult> {\n if (typeof options === 'function') {\n callback = options as InstallCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(versionExpression, options, callback) as undefined;\n return new Promise((resolve, reject) => worker(versionExpression, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\nexport { default as createStoragePaths } from './createStoragePaths';\n"],"names":["createStoragePaths","install","versionExpression","options","callback","worker","Promise","resolve","reject","err","result"],"mappings":";;;;;;;;;;;IAgBoBA,kBAAkB;eAAlBA,2BAAkB;;IAVtC,OASC;eATuBC;;;QANjB;8DACY;yEAe2B;;;;;;AAV/B,SAASA,QAAQC,iBAAyB,EAAEC,OAA0C,EAAEC,QAA0B;IAC/H,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOC,IAAAA,gBAAM,EAACH,mBAAmBC,SAASC;IAC9E,OAAO,IAAIE,QAAQ,SAACC,SAASC;eAAWH,IAAAA,gBAAM,EAACH,mBAAmBC,SAAS,SAACM,KAAKC;mBAAYD,MAAMD,OAAOC,OAAOF,QAAQG;;;AAC3H"}
@@ -9,10 +9,11 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
- var _homedirpolyfill = /*#__PURE__*/ _interop_require_default(require("homedir-polyfill"));
13
12
  var _mkdirpclassic = /*#__PURE__*/ _interop_require_default(require("mkdirp-classic"));
14
13
  var _queuecb = /*#__PURE__*/ _interop_require_default(require("queue-cb"));
15
14
  var _constants = require("../constants.cjs");
15
+ var _homedirpolyfill = /*#__PURE__*/ _interop_require_default(require("homedir-polyfill"));
16
+ var _createStoragePaths = /*#__PURE__*/ _interop_require_default(require("../createStoragePaths.cjs"));
16
17
  var _noderesolveversions = /*#__PURE__*/ _interop_require_default(require("node-resolve-versions"));
17
18
  var _index = /*#__PURE__*/ _interop_require_default(require("../installNPM/index.cjs"));
18
19
  var _index1 = /*#__PURE__*/ _interop_require_default(require("../installNode/index.cjs"));
@@ -75,16 +76,17 @@ function _object_spread_props(target, source) {
75
76
  }
76
77
  return target;
77
78
  }
78
- var DEFAULT_INSTALL_PATH = _path.default.join((0, _homedirpolyfill.default)(), '.nir');
79
+ var DEFAULT_ROOT_PATH = _path.default.join((0, _homedirpolyfill.default)(), '.nir');
80
+ var DEFAULT_STORAGE_PATHS = (0, _createStoragePaths.default)(DEFAULT_ROOT_PATH);
79
81
  var DEFAULT_OPTIONS = {
80
- cachePath: _path.default.join(DEFAULT_INSTALL_PATH, 'cache'),
81
- buildPath: _path.default.join(DEFAULT_INSTALL_PATH, 'build'),
82
82
  downloadURL: function downloadURL(relativePath) {
83
83
  return "https://nodejs.org/dist/".concat(relativePath);
84
84
  }
85
85
  };
86
- function install(versionExpression, dest, options, callback) {
87
- options = _object_spread_props(_object_spread({}, DEFAULT_OPTIONS, options), {
86
+ function install(versionExpression, options, callback) {
87
+ var storagePaths = options.storagePath ? (0, _createStoragePaths.default)(options.storagePath) : DEFAULT_STORAGE_PATHS;
88
+ var dest = options.installPath ? options.installPath : storagePaths.installPath;
89
+ options = _object_spread_props(_object_spread({}, storagePaths, DEFAULT_OPTIONS, options), {
88
90
  path: 'raw'
89
91
  });
90
92
  (0, _noderesolveversions.default)(versionExpression, options, function(err, versions) {
@@ -96,10 +98,11 @@ function install(versionExpression, dest, options, callback) {
96
98
  (0, _mkdirpclassic.default)(options.cachePath, function(err) {
97
99
  if (err) return callback(err);
98
100
  var version = versions[0];
99
- var installPath = dest && versions.length > 1 ? _path.default.join(dest, version.version) : dest;
101
+ var installPath = dest;
102
+ if (options.name) installPath = _path.default.join(installPath, options.name);
103
+ else if (!options.installPath) installPath = _path.default.join(installPath, version.version);
100
104
  var binRoot = _constants.isWindows ? installPath : _path.default.join(installPath, 'bin');
101
105
  var execPath = _path.default.join(binRoot, _constants.NODE);
102
- if (options.addVersion) dest = _path.default.join(dest, version.version);
103
106
  (0, _checkMissing.default)(dest, options, function(err, missing) {
104
107
  if (err || !missing.length) return callback(err, dest);
105
108
  var queue = new _queuecb.default(1);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import path from 'path';\nimport homedir from 'homedir-polyfill';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport { NODE, isWindows } from '../constants';\n\nimport resolveVersions from 'node-resolve-versions';\n\nimport installNPM from '../installNPM/index';\nimport installNode from '../installNode/index';\nimport checkMissing from '../lib/checkMissing';\nimport ensureDestinationParent from '../lib/ensureDestinationParent';\n\nconst DEFAULT_INSTALL_PATH = path.join(homedir(), '.nir');\nconst DEFAULT_OPTIONS = {\n cachePath: path.join(DEFAULT_INSTALL_PATH, 'cache'),\n buildPath: path.join(DEFAULT_INSTALL_PATH, 'build'),\n downloadURL: function downloadURL(relativePath) {\n return `https://nodejs.org/dist/${relativePath}`;\n },\n};\n\nexport default function install(versionExpression, dest, options, callback) {\n options = { ...DEFAULT_OPTIONS, ...options, path: 'raw' };\n resolveVersions(versionExpression, options, (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n if (versions.length !== 1) return callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x.version)}. Expecting one.`));\n\n mkdirp(options.cachePath, (err) => {\n if (err) return callback(err);\n const version = versions[0];\n\n const installPath = dest && versions.length > 1 ? path.join(dest, version.version) : dest;\n const binRoot = isWindows ? installPath : path.join(installPath, 'bin');\n const execPath = path.join(binRoot, NODE);\n\n if (options.addVersion) dest = path.join(dest, version.version);\n\n checkMissing(dest, options, (err, missing) => {\n if (err || !missing.length) return callback(err, dest);\n\n const queue = new Queue(1);\n queue.defer(ensureDestinationParent.bind(null, dest));\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, dest, options));\n !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, dest, options));\n queue.await((err) => {\n err ? callback(err) : callback(null, { version: version.version, installPath, execPath });\n });\n });\n });\n });\n}\n"],"names":["install","DEFAULT_INSTALL_PATH","path","join","homedir","DEFAULT_OPTIONS","cachePath","buildPath","downloadURL","relativePath","versionExpression","dest","options","callback","resolveVersions","err","versions","length","Error","map","x","version","mkdirp","installPath","binRoot","isWindows","execPath","NODE","addVersion","checkMissing","missing","queue","Queue","defer","ensureDestinationParent","bind","indexOf","installNode","installNPM","await"],"mappings":";;;;+BAsBA;;;eAAwBA;;;2DAtBP;sEACG;oEACD;8DACD;yBACc;0EAEJ;4DAEL;6DACC;mEACC;8EACW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpC,IAAMC,uBAAuBC,aAAI,CAACC,IAAI,CAACC,IAAAA,wBAAO,KAAI;AAClD,IAAMC,kBAAkB;IACtBC,WAAWJ,aAAI,CAACC,IAAI,CAACF,sBAAsB;IAC3CM,WAAWL,aAAI,CAACC,IAAI,CAACF,sBAAsB;IAC3CO,aAAa,SAASA,YAAYC,YAAY;QAC5C,OAAO,AAAC,2BAAuC,OAAbA;IACpC;AACF;AAEe,SAAST,QAAQU,iBAAiB,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACxED,UAAU,wCAAKP,iBAAoBO;QAASV,MAAM;;IAClDY,IAAAA,4BAAe,EAACJ,mBAAmBE,SAAS,SAACG,KAAKC;QAChD,IAAID,KAAK,OAAOF,SAASE;QACzB,IAAI,CAACC,SAASC,MAAM,EAAE,OAAOJ,SAAS,IAAIK,MAAM,AAAC,mCAAoD,OAAlBR;QACnF,IAAIM,SAASC,MAAM,KAAK,GAAG,OAAOJ,SAAS,IAAIK,MAAM,AAAC,WAA8DF,OAApDN,mBAAkB,oCAAiE,OAA/BM,SAASG,GAAG,CAAC,SAACC;mBAAMA,EAAEC,OAAO;YAAE;QAEnJC,IAAAA,sBAAM,EAACV,QAAQN,SAAS,EAAE,SAACS;YACzB,IAAIA,KAAK,OAAOF,SAASE;YACzB,IAAMM,UAAUL,QAAQ,CAAC,EAAE;YAE3B,IAAMO,cAAcZ,QAAQK,SAASC,MAAM,GAAG,IAAIf,aAAI,CAACC,IAAI,CAACQ,MAAMU,QAAQA,OAAO,IAAIV;YACrF,IAAMa,UAAUC,oBAAS,GAAGF,cAAcrB,aAAI,CAACC,IAAI,CAACoB,aAAa;YACjE,IAAMG,WAAWxB,aAAI,CAACC,IAAI,CAACqB,SAASG,eAAI;YAExC,IAAIf,QAAQgB,UAAU,EAAEjB,OAAOT,aAAI,CAACC,IAAI,CAACQ,MAAMU,QAAQA,OAAO;YAE9DQ,IAAAA,qBAAY,EAAClB,MAAMC,SAAS,SAACG,KAAKe;gBAChC,IAAIf,OAAO,CAACe,QAAQb,MAAM,EAAE,OAAOJ,SAASE,KAAKJ;gBAEjD,IAAMoB,QAAQ,IAAIC,gBAAK,CAAC;gBACxBD,MAAME,KAAK,CAACC,gCAAuB,CAACC,IAAI,CAAC,MAAMxB;gBAC/C,CAAC,CAACmB,QAAQM,OAAO,CAAC,WAAWL,MAAME,KAAK,CAACI,eAAW,CAACF,IAAI,CAAC,MAAMd,SAASV,MAAMC;gBAC/E,CAAC,CAACkB,QAAQM,OAAO,CAAC,UAAUL,MAAME,KAAK,CAACK,cAAU,CAACH,IAAI,CAAC,MAAMd,SAASV,MAAMC;gBAC7EmB,MAAMQ,KAAK,CAAC,SAACxB;oBACXA,MAAMF,SAASE,OAAOF,SAAS,MAAM;wBAAEQ,SAASA,QAAQA,OAAO;wBAAEE,aAAAA;wBAAaG,UAAAA;oBAAS;gBACzF;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import path from 'path';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport { NODE, isWindows } from '../constants';\n\nimport home from 'homedir-polyfill';\nimport createStoragePaths from '../createStoragePaths';\nconst DEFAULT_ROOT_PATH = path.join(home(), '.nir');\nconst DEFAULT_STORAGE_PATHS = createStoragePaths(DEFAULT_ROOT_PATH);\n\nimport resolveVersions from 'node-resolve-versions';\n\nimport installNPM from '../installNPM/index';\nimport installNode from '../installNode/index';\nimport checkMissing from '../lib/checkMissing';\nimport ensureDestinationParent from '../lib/ensureDestinationParent';\n\nconst DEFAULT_OPTIONS = {\n downloadURL: function downloadURL(relativePath) {\n return `https://nodejs.org/dist/${relativePath}`;\n },\n};\n\nexport default function install(versionExpression, options, callback) {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n const dest = options.installPath ? options.installPath : storagePaths.installPath;\n\n options = { ...storagePaths, ...DEFAULT_OPTIONS, ...options, path: 'raw' };\n resolveVersions(versionExpression, options, (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n if (versions.length !== 1) return callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x.version)}. Expecting one.`));\n\n mkdirp(options.cachePath, (err) => {\n if (err) return callback(err);\n const version = versions[0];\n\n let installPath = dest;\n if (options.name) installPath = path.join(installPath, options.name);\n else if (!options.installPath) installPath = path.join(installPath, version.version);\n const binRoot = isWindows ? installPath : path.join(installPath, 'bin');\n const execPath = path.join(binRoot, NODE);\n\n checkMissing(dest, options, (err, missing) => {\n if (err || !missing.length) return callback(err, dest);\n\n const queue = new Queue(1);\n queue.defer(ensureDestinationParent.bind(null, dest));\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, dest, options));\n !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, dest, options));\n queue.await((err) => {\n err ? callback(err) : callback(null, { version: version.version, installPath, execPath });\n });\n });\n });\n });\n}\n"],"names":["install","DEFAULT_ROOT_PATH","path","join","home","DEFAULT_STORAGE_PATHS","createStoragePaths","DEFAULT_OPTIONS","downloadURL","relativePath","versionExpression","options","callback","storagePaths","storagePath","dest","installPath","resolveVersions","err","versions","length","Error","map","x","version","mkdirp","cachePath","name","binRoot","isWindows","execPath","NODE","checkMissing","missing","queue","Queue","defer","ensureDestinationParent","bind","indexOf","installNode","installNPM","await"],"mappings":";;;;+BAuBA;;;eAAwBA;;;2DAvBP;oEACE;8DACD;yBACc;sEAEf;yEACc;0EAIH;4DAEL;6DACC;mEACC;8EACW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AARpC,IAAMC,oBAAoBC,aAAI,CAACC,IAAI,CAACC,IAAAA,wBAAI,KAAI;AAC5C,IAAMC,wBAAwBC,IAAAA,2BAAkB,EAACL;AASjD,IAAMM,kBAAkB;IACtBC,aAAa,SAASA,YAAYC,YAAY;QAC5C,OAAO,AAAC,2BAAuC,OAAbA;IACpC;AACF;AAEe,SAAST,QAAQU,iBAAiB,EAAEC,OAAO,EAAEC,QAAQ;IAClE,IAAMC,eAAeF,QAAQG,WAAW,GAAGR,IAAAA,2BAAkB,EAACK,QAAQG,WAAW,IAAIT;IACrF,IAAMU,OAAOJ,QAAQK,WAAW,GAAGL,QAAQK,WAAW,GAAGH,aAAaG,WAAW;IAEjFL,UAAU,wCAAKE,cAAiBN,iBAAoBI;QAAST,MAAM;;IACnEe,IAAAA,4BAAe,EAACP,mBAAmBC,SAAS,SAACO,KAAKC;QAChD,IAAID,KAAK,OAAON,SAASM;QACzB,IAAI,CAACC,SAASC,MAAM,EAAE,OAAOR,SAAS,IAAIS,MAAM,AAAC,mCAAoD,OAAlBX;QACnF,IAAIS,SAASC,MAAM,KAAK,GAAG,OAAOR,SAAS,IAAIS,MAAM,AAAC,WAA8DF,OAApDT,mBAAkB,oCAAiE,OAA/BS,SAASG,GAAG,CAAC,SAACC;mBAAMA,EAAEC,OAAO;YAAE;QAEnJC,IAAAA,sBAAM,EAACd,QAAQe,SAAS,EAAE,SAACR;YACzB,IAAIA,KAAK,OAAON,SAASM;YACzB,IAAMM,UAAUL,QAAQ,CAAC,EAAE;YAE3B,IAAIH,cAAcD;YAClB,IAAIJ,QAAQgB,IAAI,EAAEX,cAAcd,aAAI,CAACC,IAAI,CAACa,aAAaL,QAAQgB,IAAI;iBAC9D,IAAI,CAAChB,QAAQK,WAAW,EAAEA,cAAcd,aAAI,CAACC,IAAI,CAACa,aAAaQ,QAAQA,OAAO;YACnF,IAAMI,UAAUC,oBAAS,GAAGb,cAAcd,aAAI,CAACC,IAAI,CAACa,aAAa;YACjE,IAAMc,WAAW5B,aAAI,CAACC,IAAI,CAACyB,SAASG,eAAI;YAExCC,IAAAA,qBAAY,EAACjB,MAAMJ,SAAS,SAACO,KAAKe;gBAChC,IAAIf,OAAO,CAACe,QAAQb,MAAM,EAAE,OAAOR,SAASM,KAAKH;gBAEjD,IAAMmB,QAAQ,IAAIC,gBAAK,CAAC;gBACxBD,MAAME,KAAK,CAACC,gCAAuB,CAACC,IAAI,CAAC,MAAMvB;gBAC/C,CAAC,CAACkB,QAAQM,OAAO,CAAC,WAAWL,MAAME,KAAK,CAACI,eAAW,CAACF,IAAI,CAAC,MAAMd,SAAST,MAAMJ;gBAC/E,CAAC,CAACsB,QAAQM,OAAO,CAAC,UAAUL,MAAME,KAAK,CAACK,cAAU,CAACH,IAAI,CAAC,MAAMd,SAAST,MAAMJ;gBAC7EuB,MAAMQ,KAAK,CAAC,SAACxB;oBACXA,MAAMN,SAASM,OAAON,SAAS,MAAM;wBAAEY,SAASA,QAAQA,OAAO;wBAAER,aAAAA;wBAAac,UAAAA;oBAAS;gBACzF;YACF;QACF;IACF;AACF"}
package/dist/esm/cli.mjs CHANGED
@@ -7,7 +7,8 @@ export default ((argv)=>{
7
7
  platform: 'p',
8
8
  arch: 'a',
9
9
  filename: 'f',
10
- cachePath: 'c',
10
+ installPath: 'i',
11
+ storagePath: 'c',
11
12
  silent: 's'
12
13
  },
13
14
  boolean: [
@@ -23,14 +24,11 @@ export default ((argv)=>{
23
24
  console.log('Missing command. Example usage: nir version [directory]');
24
25
  return exit(-1);
25
26
  }
26
- const installPath = args.length > 1 ? args[1] : process.cwd();
27
- nir(args[0], installPath, {
28
- addVersion: true
29
- }, (err, result)=>{
27
+ nir(args[0], options, (err, result)=>{
30
28
  if (!options.silent) {
31
29
  console.log('\n======================');
32
30
  if (err) console.log(`${args[0]} not installed. Error: ${err.message}`);
33
- else console.log(`${result.version} installed in: ${installPath}`);
31
+ else console.log(`${result.version} installed in: ${result.installPath}`);
34
32
  console.log('======================');
35
33
  }
36
34
  exit(err ? -1 : 0);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nir from './index';\n\nexport default (argv) => {\n const options = getopts(argv.slice(1), {\n alias: { platform: 'p', arch: 'a', filename: 'f', cachePath: 'c', silent: 's' },\n boolean: ['silent'],\n });\n\n // define.option('-p, --platform [platform]', 'Platform like darwin');\n // define.option('-a, --arch [arch]', 'Architecure x64, x86, arm-pi');\n // define.option('-f, --filename [filename]', 'Distribution filename from https://nodejs.org/dist/index.json');\n // define.option('-c, --cachePath [cachePath]', 'Cache directory');\n\n const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log('Missing command. Example usage: nir version [directory]');\n return exit(-1);\n }\n\n const installPath = args.length > 1 ? args[1] : process.cwd();\n nir(args[0], installPath, { addVersion: true }, (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: ${installPath}`);\n console.log('======================');\n }\n exit(err ? -1 : 0);\n });\n};\n"],"names":["exit","getopts","nir","argv","options","slice","alias","platform","arch","filename","cachePath","silent","boolean","args","concat","_","length","console","log","installPath","process","cwd","addVersion","err","result","message","version"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,SAAS,UAAU;AAE1B,eAAe,CAAA,CAACC;IACd,MAAMC,UAAUH,QAAQE,KAAKE,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,UAAU;YAAKC,MAAM;YAAKC,UAAU;YAAKC,WAAW;YAAKC,QAAQ;QAAI;QAC9EC,SAAS;YAAC;SAAS;IACrB;IAEA,sEAAsE;IACtE,sEAAsE;IACtE,+GAA+G;IAC/G,mEAAmE;IAEnE,MAAMC,OAAOV,KAAKE,KAAK,CAAC,GAAG,GAAGS,MAAM,CAACV,QAAQW,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC;QACZ,OAAOlB,KAAK,CAAC;IACf;IAEA,MAAMmB,cAAcN,KAAKG,MAAM,GAAG,IAAIH,IAAI,CAAC,EAAE,GAAGO,QAAQC,GAAG;IAC3DnB,IAAIW,IAAI,CAAC,EAAE,EAAEM,aAAa;QAAEG,YAAY;IAAK,GAAG,CAACC,KAAKC;QACpD,IAAI,CAACpB,QAAQO,MAAM,EAAE;YACnBM,QAAQC,GAAG,CAAC;YACZ,IAAIK,KAAKN,QAAQC,GAAG,CAAC,GAAGL,IAAI,CAAC,EAAE,CAAC,uBAAuB,EAAEU,IAAIE,OAAO,EAAE;iBACjER,QAAQC,GAAG,CAAC,GAAGM,OAAOE,OAAO,CAAC,eAAe,EAAEP,aAAa;YACjEF,QAAQC,GAAG,CAAC;QACd;QACAlB,KAAKuB,MAAM,CAAC,IAAI;IAClB;AACF,CAAA,EAAE"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/cli.ts"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nir, { type InstallOptions } from './index';\n\nexport default (argv) => {\n const options = getopts(argv.slice(1), {\n alias: { platform: 'p', arch: 'a', filename: 'f', installPath: 'i', storagePath: 'c', silent: 's' },\n boolean: ['silent'],\n });\n\n // define.option('-p, --platform [platform]', 'Platform like darwin');\n // define.option('-a, --arch [arch]', 'Architecure x64, x86, arm-pi');\n // define.option('-f, --filename [filename]', 'Distribution filename from https://nodejs.org/dist/index.json');\n // define.option('-c, --cachePath [cachePath]', 'Cache directory');\n\n const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log('Missing command. Example usage: nir version [directory]');\n return exit(-1);\n }\n nir(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 ? -1 : 0);\n });\n};\n"],"names":["exit","getopts","nir","argv","options","slice","alias","platform","arch","filename","installPath","storagePath","silent","boolean","args","concat","_","length","console","log","err","result","message","version"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,aAAa,iBAAiB;AACrC,OAAOC,SAAkC,UAAU;AAEnD,eAAe,CAAA,CAACC;IACd,MAAMC,UAAUH,QAAQE,KAAKE,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,UAAU;YAAKC,MAAM;YAAKC,UAAU;YAAKC,aAAa;YAAKC,aAAa;YAAKC,QAAQ;QAAI;QAClGC,SAAS;YAAC;SAAS;IACrB;IAEA,sEAAsE;IACtE,sEAAsE;IACtE,+GAA+G;IAC/G,mEAAmE;IAEnE,MAAMC,OAAOX,KAAKE,KAAK,CAAC,GAAG,GAAGU,MAAM,CAACX,QAAQY,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC;QACZ,OAAOnB,KAAK,CAAC;IACf;IACAE,IAAIY,IAAI,CAAC,EAAE,EAAEV,SAA2B,CAACgB,KAAKC;QAC5C,IAAI,CAACjB,QAAQQ,MAAM,EAAE;YACnBM,QAAQC,GAAG,CAAC;YACZ,IAAIC,KAAKF,QAAQC,GAAG,CAAC,GAAGL,IAAI,CAAC,EAAE,CAAC,uBAAuB,EAAEM,IAAIE,OAAO,EAAE;iBACjEJ,QAAQC,GAAG,CAAC,GAAGE,OAAOE,OAAO,CAAC,eAAe,EAAEF,OAAOX,WAAW,EAAE;YACxEQ,QAAQC,GAAG,CAAC;QACd;QACAnB,KAAKoB,MAAM,CAAC,IAAI;IAClB;AACF,CAAA,EAAE"}
@@ -0,0 +1,8 @@
1
+ import path from 'path';
2
+ export default function createStoragePaths(storagePath) {
3
+ return {
4
+ cachePath: path.join(storagePath, 'cache'),
5
+ buildPath: path.join(storagePath, 'build'),
6
+ installPath: path.join(storagePath, 'build')
7
+ };
8
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/createStoragePaths.ts"],"sourcesContent":["import path from 'path';\n\nimport type { StorageLocations } from './types';\n\nexport default function createStoragePaths(storagePath: string): StorageLocations {\n return {\n cachePath: path.join(storagePath, 'cache'),\n buildPath: path.join(storagePath, 'build'),\n installPath: path.join(storagePath, 'build'),\n };\n}\n"],"names":["path","createStoragePaths","storagePath","cachePath","join","buildPath","installPath"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AAIxB,eAAe,SAASC,mBAAmBC,WAAmB;IAC5D,OAAO;QACLC,WAAWH,KAAKI,IAAI,CAACF,aAAa;QAClCG,WAAWL,KAAKI,IAAI,CAACF,aAAa;QAClCI,aAAaN,KAAKI,IAAI,CAACF,aAAa;IACtC;AACF"}
@@ -1,11 +1,12 @@
1
1
  import './polyfills.cjs';
2
2
  import worker from './workers/install.mjs';
3
- export default function install(versionExpression, dest, options, callback) {
3
+ export default function install(versionExpression, options, callback) {
4
4
  if (typeof options === 'function') {
5
5
  callback = options;
6
6
  options = {};
7
7
  }
8
8
  options = options || {};
9
- if (typeof callback === 'function') return worker(versionExpression, dest, options, callback);
10
- return new Promise((resolve, reject)=>worker(versionExpression, dest, options, (err, result)=>err ? reject(err) : resolve(result)));
9
+ if (typeof callback === 'function') return worker(versionExpression, options, callback);
10
+ return new Promise((resolve, reject)=>worker(versionExpression, options, (err, result)=>err ? reject(err) : resolve(result)));
11
11
  }
12
+ export { default as createStoragePaths } from './createStoragePaths.mjs';
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/index.ts"],"sourcesContent":["import './polyfills.cjs';\nimport worker from './workers/install';\n\nimport type { InstallCallback, InstallOptions, InstallResult } from './types';\n\nexport type * from './types';\nexport default function install(versionExpression: string, dest: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): undefined | Promise<InstallResult> {\n if (typeof options === 'function') {\n callback = options as InstallCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(versionExpression, dest, options, callback) as undefined;\n return new Promise((resolve, reject) => worker(versionExpression, dest, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\n"],"names":["worker","install","versionExpression","dest","options","callback","Promise","resolve","reject","err","result"],"mappings":"AAAA,OAAO,kBAAkB;AACzB,OAAOA,YAAY,oBAAoB;AAKvC,eAAe,SAASC,QAAQC,iBAAyB,EAAEC,IAAY,EAAEC,OAA0C,EAAEC,QAA0B;IAC7I,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOL,OAAOE,mBAAmBC,MAAMC,SAASC;IACpF,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWR,OAAOE,mBAAmBC,MAAMC,SAAS,CAACK,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AACjI"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/index.ts"],"sourcesContent":["import './polyfills.cjs';\nimport worker from './workers/install';\n\nimport type { InstallCallback, InstallOptions, InstallResult } from './types';\n\nexport type * from './types';\nexport default function install(versionExpression: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): undefined | Promise<InstallResult> {\n if (typeof options === 'function') {\n callback = options as InstallCallback;\n options = {};\n }\n options = options || {};\n\n if (typeof callback === 'function') return worker(versionExpression, options, callback) as undefined;\n return new Promise((resolve, reject) => worker(versionExpression, options, (err, result) => (err ? reject(err) : resolve(result))));\n}\nexport { default as createStoragePaths } from './createStoragePaths';\n"],"names":["worker","install","versionExpression","options","callback","Promise","resolve","reject","err","result","default","createStoragePaths"],"mappings":"AAAA,OAAO,kBAAkB;AACzB,OAAOA,YAAY,oBAAoB;AAKvC,eAAe,SAASC,QAAQC,iBAAyB,EAAEC,OAA0C,EAAEC,QAA0B;IAC/H,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,IAAI,OAAOC,aAAa,YAAY,OAAOJ,OAAOE,mBAAmBC,SAASC;IAC9E,OAAO,IAAIC,QAAQ,CAACC,SAASC,SAAWP,OAAOE,mBAAmBC,SAAS,CAACK,KAAKC,SAAYD,MAAMD,OAAOC,OAAOF,QAAQG;AAC3H;AACA,SAASC,WAAWC,kBAAkB,QAAQ,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/types.ts"],"sourcesContent":["export type InstallPaths = {\n cachePath: string;\n buildPath: string;\n installPath: string;\n};\n\nexport type InstallResult = {\n version: string;\n installPath: string;\n execPath: string;\n};\n\nexport interface InstallOptions {\n addVersion?: boolean;\n}\n\nexport type InstallCallback = (err?: Error, result?: InstallResult) => void;\n"],"names":[],"mappings":"AAgBA,WAA4E"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/types.ts"],"sourcesContent":["export type StorageLocations = {\n cachePath: string;\n buildPath: string;\n installPath: string;\n};\n\nexport type InstallResult = {\n version: string;\n installPath: string;\n execPath: string;\n};\n\nexport interface InstallOptions {\n installPath?: string;\n name?: string;\n storagePath?: string;\n filename?: string;\n}\n\nexport type InstallCallback = (err?: Error, result?: InstallResult) => void;\n"],"names":[],"mappings":"AAmBA,WAA4E"}
@@ -1,23 +1,26 @@
1
1
  import path from 'path';
2
- import homedir from 'homedir-polyfill';
3
2
  import mkdirp from 'mkdirp-classic';
4
3
  import Queue from 'queue-cb';
5
4
  import { NODE, isWindows } from '../constants.mjs';
5
+ import home from 'homedir-polyfill';
6
+ import createStoragePaths from '../createStoragePaths.mjs';
7
+ const DEFAULT_ROOT_PATH = path.join(home(), '.nir');
8
+ const DEFAULT_STORAGE_PATHS = createStoragePaths(DEFAULT_ROOT_PATH);
6
9
  import resolveVersions from 'node-resolve-versions';
7
10
  import installNPM from '../installNPM/index.mjs';
8
11
  import installNode from '../installNode/index.mjs';
9
12
  import checkMissing from '../lib/checkMissing.mjs';
10
13
  import ensureDestinationParent from '../lib/ensureDestinationParent.mjs';
11
- const DEFAULT_INSTALL_PATH = path.join(homedir(), '.nir');
12
14
  const DEFAULT_OPTIONS = {
13
- cachePath: path.join(DEFAULT_INSTALL_PATH, 'cache'),
14
- buildPath: path.join(DEFAULT_INSTALL_PATH, 'build'),
15
15
  downloadURL: function downloadURL(relativePath) {
16
16
  return `https://nodejs.org/dist/${relativePath}`;
17
17
  }
18
18
  };
19
- export default function install(versionExpression, dest, options, callback) {
19
+ export default function install(versionExpression, options, callback) {
20
+ const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;
21
+ const dest = options.installPath ? options.installPath : storagePaths.installPath;
20
22
  options = {
23
+ ...storagePaths,
21
24
  ...DEFAULT_OPTIONS,
22
25
  ...options,
23
26
  path: 'raw'
@@ -29,10 +32,11 @@ export default function install(versionExpression, dest, options, callback) {
29
32
  mkdirp(options.cachePath, (err)=>{
30
33
  if (err) return callback(err);
31
34
  const version = versions[0];
32
- const installPath = dest && versions.length > 1 ? path.join(dest, version.version) : dest;
35
+ let installPath = dest;
36
+ if (options.name) installPath = path.join(installPath, options.name);
37
+ else if (!options.installPath) installPath = path.join(installPath, version.version);
33
38
  const binRoot = isWindows ? installPath : path.join(installPath, 'bin');
34
39
  const execPath = path.join(binRoot, NODE);
35
- if (options.addVersion) dest = path.join(dest, version.version);
36
40
  checkMissing(dest, options, (err, missing)=>{
37
41
  if (err || !missing.length) return callback(err, dest);
38
42
  const queue = new Queue(1);
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import path from 'path';\nimport homedir from 'homedir-polyfill';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport { NODE, isWindows } from '../constants';\n\nimport resolveVersions from 'node-resolve-versions';\n\nimport installNPM from '../installNPM/index';\nimport installNode from '../installNode/index';\nimport checkMissing from '../lib/checkMissing';\nimport ensureDestinationParent from '../lib/ensureDestinationParent';\n\nconst DEFAULT_INSTALL_PATH = path.join(homedir(), '.nir');\nconst DEFAULT_OPTIONS = {\n cachePath: path.join(DEFAULT_INSTALL_PATH, 'cache'),\n buildPath: path.join(DEFAULT_INSTALL_PATH, 'build'),\n downloadURL: function downloadURL(relativePath) {\n return `https://nodejs.org/dist/${relativePath}`;\n },\n};\n\nexport default function install(versionExpression, dest, options, callback) {\n options = { ...DEFAULT_OPTIONS, ...options, path: 'raw' };\n resolveVersions(versionExpression, options, (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n if (versions.length !== 1) return callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x.version)}. Expecting one.`));\n\n mkdirp(options.cachePath, (err) => {\n if (err) return callback(err);\n const version = versions[0];\n\n const installPath = dest && versions.length > 1 ? path.join(dest, version.version) : dest;\n const binRoot = isWindows ? installPath : path.join(installPath, 'bin');\n const execPath = path.join(binRoot, NODE);\n\n if (options.addVersion) dest = path.join(dest, version.version);\n\n checkMissing(dest, options, (err, missing) => {\n if (err || !missing.length) return callback(err, dest);\n\n const queue = new Queue(1);\n queue.defer(ensureDestinationParent.bind(null, dest));\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, dest, options));\n !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, dest, options));\n queue.await((err) => {\n err ? callback(err) : callback(null, { version: version.version, installPath, execPath });\n });\n });\n });\n });\n}\n"],"names":["path","homedir","mkdirp","Queue","NODE","isWindows","resolveVersions","installNPM","installNode","checkMissing","ensureDestinationParent","DEFAULT_INSTALL_PATH","join","DEFAULT_OPTIONS","cachePath","buildPath","downloadURL","relativePath","install","versionExpression","dest","options","callback","err","versions","length","Error","map","x","version","installPath","binRoot","execPath","addVersion","missing","queue","defer","bind","indexOf","await"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,aAAa,mBAAmB;AACvC,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAC7B,SAASC,IAAI,EAAEC,SAAS,QAAQ,eAAe;AAE/C,OAAOC,qBAAqB,wBAAwB;AAEpD,OAAOC,gBAAgB,sBAAsB;AAC7C,OAAOC,iBAAiB,uBAAuB;AAC/C,OAAOC,kBAAkB,sBAAsB;AAC/C,OAAOC,6BAA6B,iCAAiC;AAErE,MAAMC,uBAAuBX,KAAKY,IAAI,CAACX,WAAW;AAClD,MAAMY,kBAAkB;IACtBC,WAAWd,KAAKY,IAAI,CAACD,sBAAsB;IAC3CI,WAAWf,KAAKY,IAAI,CAACD,sBAAsB;IAC3CK,aAAa,SAASA,YAAYC,YAAY;QAC5C,OAAO,CAAC,wBAAwB,EAAEA,cAAc;IAClD;AACF;AAEA,eAAe,SAASC,QAAQC,iBAAiB,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACxED,UAAU;QAAE,GAAGR,eAAe;QAAE,GAAGQ,OAAO;QAAErB,MAAM;IAAM;IACxDM,gBAAgBa,mBAAmBE,SAAS,CAACE,KAAKC;QAChD,IAAID,KAAK,OAAOD,SAASC;QACzB,IAAI,CAACC,SAASC,MAAM,EAAE,OAAOH,SAAS,IAAII,MAAM,CAAC,gCAAgC,EAAEP,mBAAmB;QACtG,IAAIK,SAASC,MAAM,KAAK,GAAG,OAAOH,SAAS,IAAII,MAAM,CAAC,QAAQ,EAAEP,kBAAkB,gCAAgC,EAAEK,SAASG,GAAG,CAAC,CAACC,IAAMA,EAAEC,OAAO,EAAE,gBAAgB,CAAC;QAEpK3B,OAAOmB,QAAQP,SAAS,EAAE,CAACS;YACzB,IAAIA,KAAK,OAAOD,SAASC;YACzB,MAAMM,UAAUL,QAAQ,CAAC,EAAE;YAE3B,MAAMM,cAAcV,QAAQI,SAASC,MAAM,GAAG,IAAIzB,KAAKY,IAAI,CAACQ,MAAMS,QAAQA,OAAO,IAAIT;YACrF,MAAMW,UAAU1B,YAAYyB,cAAc9B,KAAKY,IAAI,CAACkB,aAAa;YACjE,MAAME,WAAWhC,KAAKY,IAAI,CAACmB,SAAS3B;YAEpC,IAAIiB,QAAQY,UAAU,EAAEb,OAAOpB,KAAKY,IAAI,CAACQ,MAAMS,QAAQA,OAAO;YAE9DpB,aAAaW,MAAMC,SAAS,CAACE,KAAKW;gBAChC,IAAIX,OAAO,CAACW,QAAQT,MAAM,EAAE,OAAOH,SAASC,KAAKH;gBAEjD,MAAMe,QAAQ,IAAIhC,MAAM;gBACxBgC,MAAMC,KAAK,CAAC1B,wBAAwB2B,IAAI,CAAC,MAAMjB;gBAC/C,CAAC,CAACc,QAAQI,OAAO,CAAC,WAAWH,MAAMC,KAAK,CAAC5B,YAAY6B,IAAI,CAAC,MAAMR,SAAST,MAAMC;gBAC/E,CAAC,CAACa,QAAQI,OAAO,CAAC,UAAUH,MAAMC,KAAK,CAAC7B,WAAW8B,IAAI,CAAC,MAAMR,SAAST,MAAMC;gBAC7Ec,MAAMI,KAAK,CAAC,CAAChB;oBACXA,MAAMD,SAASC,OAAOD,SAAS,MAAM;wBAAEO,SAASA,QAAQA,OAAO;wBAAEC;wBAAaE;oBAAS;gBACzF;YACF;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import path from 'path';\nimport mkdirp from 'mkdirp-classic';\nimport Queue from 'queue-cb';\nimport { NODE, isWindows } from '../constants';\n\nimport home from 'homedir-polyfill';\nimport createStoragePaths from '../createStoragePaths';\nconst DEFAULT_ROOT_PATH = path.join(home(), '.nir');\nconst DEFAULT_STORAGE_PATHS = createStoragePaths(DEFAULT_ROOT_PATH);\n\nimport resolveVersions from 'node-resolve-versions';\n\nimport installNPM from '../installNPM/index';\nimport installNode from '../installNode/index';\nimport checkMissing from '../lib/checkMissing';\nimport ensureDestinationParent from '../lib/ensureDestinationParent';\n\nconst DEFAULT_OPTIONS = {\n downloadURL: function downloadURL(relativePath) {\n return `https://nodejs.org/dist/${relativePath}`;\n },\n};\n\nexport default function install(versionExpression, options, callback) {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n const dest = options.installPath ? options.installPath : storagePaths.installPath;\n\n options = { ...storagePaths, ...DEFAULT_OPTIONS, ...options, path: 'raw' };\n resolveVersions(versionExpression, options, (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n if (versions.length !== 1) return callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x.version)}. Expecting one.`));\n\n mkdirp(options.cachePath, (err) => {\n if (err) return callback(err);\n const version = versions[0];\n\n let installPath = dest;\n if (options.name) installPath = path.join(installPath, options.name);\n else if (!options.installPath) installPath = path.join(installPath, version.version);\n const binRoot = isWindows ? installPath : path.join(installPath, 'bin');\n const execPath = path.join(binRoot, NODE);\n\n checkMissing(dest, options, (err, missing) => {\n if (err || !missing.length) return callback(err, dest);\n\n const queue = new Queue(1);\n queue.defer(ensureDestinationParent.bind(null, dest));\n !~missing.indexOf('node') || queue.defer(installNode.bind(null, version, dest, options));\n !~missing.indexOf('npm') || queue.defer(installNPM.bind(null, version, dest, options));\n queue.await((err) => {\n err ? callback(err) : callback(null, { version: version.version, installPath, execPath });\n });\n });\n });\n });\n}\n"],"names":["path","mkdirp","Queue","NODE","isWindows","home","createStoragePaths","DEFAULT_ROOT_PATH","join","DEFAULT_STORAGE_PATHS","resolveVersions","installNPM","installNode","checkMissing","ensureDestinationParent","DEFAULT_OPTIONS","downloadURL","relativePath","install","versionExpression","options","callback","storagePaths","storagePath","dest","installPath","err","versions","length","Error","map","x","version","cachePath","name","binRoot","execPath","missing","queue","defer","bind","indexOf","await"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,YAAY,iBAAiB;AACpC,OAAOC,WAAW,WAAW;AAC7B,SAASC,IAAI,EAAEC,SAAS,QAAQ,eAAe;AAE/C,OAAOC,UAAU,mBAAmB;AACpC,OAAOC,wBAAwB,wBAAwB;AACvD,MAAMC,oBAAoBP,KAAKQ,IAAI,CAACH,QAAQ;AAC5C,MAAMI,wBAAwBH,mBAAmBC;AAEjD,OAAOG,qBAAqB,wBAAwB;AAEpD,OAAOC,gBAAgB,sBAAsB;AAC7C,OAAOC,iBAAiB,uBAAuB;AAC/C,OAAOC,kBAAkB,sBAAsB;AAC/C,OAAOC,6BAA6B,iCAAiC;AAErE,MAAMC,kBAAkB;IACtBC,aAAa,SAASA,YAAYC,YAAY;QAC5C,OAAO,CAAC,wBAAwB,EAAEA,cAAc;IAClD;AACF;AAEA,eAAe,SAASC,QAAQC,iBAAiB,EAAEC,OAAO,EAAEC,QAAQ;IAClE,MAAMC,eAAeF,QAAQG,WAAW,GAAGjB,mBAAmBc,QAAQG,WAAW,IAAId;IACrF,MAAMe,OAAOJ,QAAQK,WAAW,GAAGL,QAAQK,WAAW,GAAGH,aAAaG,WAAW;IAEjFL,UAAU;QAAE,GAAGE,YAAY;QAAE,GAAGP,eAAe;QAAE,GAAGK,OAAO;QAAEpB,MAAM;IAAM;IACzEU,gBAAgBS,mBAAmBC,SAAS,CAACM,KAAKC;QAChD,IAAID,KAAK,OAAOL,SAASK;QACzB,IAAI,CAACC,SAASC,MAAM,EAAE,OAAOP,SAAS,IAAIQ,MAAM,CAAC,gCAAgC,EAAEV,mBAAmB;QACtG,IAAIQ,SAASC,MAAM,KAAK,GAAG,OAAOP,SAAS,IAAIQ,MAAM,CAAC,QAAQ,EAAEV,kBAAkB,gCAAgC,EAAEQ,SAASG,GAAG,CAAC,CAACC,IAAMA,EAAEC,OAAO,EAAE,gBAAgB,CAAC;QAEpK/B,OAAOmB,QAAQa,SAAS,EAAE,CAACP;YACzB,IAAIA,KAAK,OAAOL,SAASK;YACzB,MAAMM,UAAUL,QAAQ,CAAC,EAAE;YAE3B,IAAIF,cAAcD;YAClB,IAAIJ,QAAQc,IAAI,EAAET,cAAczB,KAAKQ,IAAI,CAACiB,aAAaL,QAAQc,IAAI;iBAC9D,IAAI,CAACd,QAAQK,WAAW,EAAEA,cAAczB,KAAKQ,IAAI,CAACiB,aAAaO,QAAQA,OAAO;YACnF,MAAMG,UAAU/B,YAAYqB,cAAczB,KAAKQ,IAAI,CAACiB,aAAa;YACjE,MAAMW,WAAWpC,KAAKQ,IAAI,CAAC2B,SAAShC;YAEpCU,aAAaW,MAAMJ,SAAS,CAACM,KAAKW;gBAChC,IAAIX,OAAO,CAACW,QAAQT,MAAM,EAAE,OAAOP,SAASK,KAAKF;gBAEjD,MAAMc,QAAQ,IAAIpC,MAAM;gBACxBoC,MAAMC,KAAK,CAACzB,wBAAwB0B,IAAI,CAAC,MAAMhB;gBAC/C,CAAC,CAACa,QAAQI,OAAO,CAAC,WAAWH,MAAMC,KAAK,CAAC3B,YAAY4B,IAAI,CAAC,MAAMR,SAASR,MAAMJ;gBAC/E,CAAC,CAACiB,QAAQI,OAAO,CAAC,UAAUH,MAAMC,KAAK,CAAC5B,WAAW6B,IAAI,CAAC,MAAMR,SAASR,MAAMJ;gBAC7EkB,MAAMI,KAAK,CAAC,CAAChB;oBACXA,MAAML,SAASK,OAAOL,SAAS,MAAM;wBAAEW,SAASA,QAAQA,OAAO;wBAAEP;wBAAaW;oBAAS;gBACzF;YACF;QACF;IACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import type { StorageLocations } from './types';
2
+ export default function createStoragePaths(storagePath: string): StorageLocations;
@@ -1,4 +1,5 @@
1
1
  import './polyfills.cjs';
2
2
  import type { InstallCallback, InstallOptions, InstallResult } from './types';
3
3
  export type * from './types';
4
- export default function install(versionExpression: string, dest: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): undefined | Promise<InstallResult>;
4
+ export default function install(versionExpression: string, options?: InstallOptions | InstallCallback, callback?: InstallCallback): undefined | Promise<InstallResult>;
5
+ export { default as createStoragePaths } from './createStoragePaths';
@@ -1,4 +1,4 @@
1
- export type InstallPaths = {
1
+ export type StorageLocations = {
2
2
  cachePath: string;
3
3
  buildPath: string;
4
4
  installPath: string;
@@ -9,6 +9,9 @@ export type InstallResult = {
9
9
  execPath: string;
10
10
  };
11
11
  export interface InstallOptions {
12
- addVersion?: boolean;
12
+ installPath?: string;
13
+ name?: string;
14
+ storagePath?: string;
15
+ filename?: string;
13
16
  }
14
17
  export type InstallCallback = (err?: Error, result?: InstallResult) => void;
@@ -1 +1 @@
1
- export default function install(versionExpression: any, dest: any, options: any, callback: any): void;
1
+ export default function install(versionExpression: any, options: any, callback: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-install-release",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Cross-platform solution for installing releases of Node.js",
5
5
  "keywords": [
6
6
  "node",