node-version-use 0.4.7 → 0.4.8

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/bin/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/cjs/cli.js')(process.argv.slice(2), 'nvu');
@@ -0,0 +1,78 @@
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 _default;
9
+ }
10
+ });
11
+ var _exit = /*#__PURE__*/ _interop_require_default(require("exit"));
12
+ var _getoptscompat = /*#__PURE__*/ _interop_require_default(require("getopts-compat"));
13
+ var _index = /*#__PURE__*/ _interop_require_default(require("./index.js"));
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ var _default = function(argv, name) {
20
+ var options = (0, _getoptscompat.default)(argv.slice(1), {
21
+ alias: {
22
+ range: "r",
23
+ desc: "d",
24
+ silent: "s"
25
+ },
26
+ default: {
27
+ range: "major,even"
28
+ },
29
+ boolean: [
30
+ "silent",
31
+ "desc"
32
+ ],
33
+ stopEarly: true
34
+ });
35
+ // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');
36
+ // define.option('-s, --silent', 'suppress logging', false);
37
+ options.sort = options.desc ? -1 : 1;
38
+ var args = argv.slice(0, 1).concat(options._);
39
+ if (args.length < 1) {
40
+ console.log("Missing command. Example usage: ".concat(name, " [version expression] [command]"));
41
+ return (0, _exit.default)(-1);
42
+ }
43
+ if (!options.silent) options.header = function(version, command, args) {
44
+ console.log("\n----------------------");
45
+ console.log("".concat([
46
+ command
47
+ ].concat(args).join(" "), " (").concat(version, ")"));
48
+ console.log("----------------------");
49
+ };
50
+ options.stdio = "inherit"; // pass through stdio
51
+ (0, _index.default)(args[0], args[1], args.slice(2), options, function(err, results) {
52
+ if (err) {
53
+ console.log(err.message);
54
+ return (0, _exit.default)(err.code || -1);
55
+ }
56
+ var errors = results.filter(function(result) {
57
+ return !!result.error;
58
+ });
59
+ if (!options.silent) {
60
+ console.log("\n======================");
61
+ if (errors.length) {
62
+ console.log("Errors (".concat(errors.length, ")"));
63
+ for(var index = 0; index < errors.length; index++){
64
+ var result = errors[index];
65
+ console.log("".concat(result.version, " Error: ").concat(result.error.message));
66
+ }
67
+ } else console.log("Success (".concat(results.length, ")"));
68
+ console.log("======================");
69
+ }
70
+ (0, _exit.default)(errors.length ? -1 : 0);
71
+ });
72
+ };
73
+
74
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
75
+ Object.defineProperty(exports.default, '__esModule', { value: true });
76
+ for (var key in exports) exports.default[key] = exports[key];
77
+ module.exports = exports.default;
78
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["cli.js"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport nvu from './index.js';\n\nexport default (argv, name) => {\n const options = getopts(argv.slice(1), {\n alias: { range: 'r', desc: 'd', silent: 's' },\n default: { range: 'major,even' },\n boolean: ['silent', 'desc'],\n stopEarly: true,\n });\n\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');\n // define.option('-s, --silent', 'suppress logging', false);\n options.sort = options.desc ? -1 : 1;\n\n const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log(`Missing command. Example usage: ${name} [version expression] [command]`);\n return exit(-1);\n }\n\n if (!options.silent)\n options.header = (version, command, args) => {\n console.log('\\n----------------------');\n console.log(`${[command].concat(args).join(' ')} (${version})`);\n console.log('----------------------');\n };\n\n options.stdio = 'inherit'; // pass through stdio\n nvu(args[0], args[1], args.slice(2), options, (err, results) => {\n if (err) {\n console.log(err.message);\n return exit(err.code || -1);\n }\n const errors = results.filter((result) => !!result.error);\n\n if (!options.silent) {\n console.log('\\n======================');\n if (errors.length) {\n console.log(`Errors (${errors.length})`);\n for (let index = 0; index < errors.length; index++) {\n const result = errors[index];\n console.log(`${result.version} Error: ${result.error.message}`);\n }\n } else console.log(`Success (${results.length})`);\n console.log('======================');\n }\n\n exit(errors.length ? -1 : 0);\n });\n};\n"],"names":["argv","name","options","getopts","slice","alias","range","desc","silent","default","boolean","stopEarly","sort","args","concat","_","length","console","log","exit","header","version","command","join","stdio","nvu","err","results","message","code","errors","filter","result","error","index"],"mappings":";;;;+BAIA;;;eAAA;;;2DAJiB;oEACG;4DACJ;;;;;;IAEhB,WAAe,SAACA,MAAMC;IACpB,IAAMC,UAAUC,IAAAA,sBAAO,EAACH,KAAKI,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,OAAO;YAAKC,MAAM;YAAKC,QAAQ;QAAI;QAC5CC,SAAS;YAAEH,OAAO;QAAa;QAC/BI,SAAS;YAAC;YAAU;SAAO;QAC3BC,WAAW;IACb;IAEA,4JAA4J;IAC5J,4DAA4D;IAC5DT,QAAQU,IAAI,GAAGV,QAAQK,IAAI,GAAG,CAAC,IAAI;IAEnC,IAAMM,OAAOb,KAAKI,KAAK,CAAC,GAAG,GAAGU,MAAM,CAACZ,QAAQa,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBC,QAAQC,GAAG,CAAC,AAAC,mCAAuC,OAALjB,MAAK;QACpD,OAAOkB,IAAAA,aAAI,EAAC,CAAC;IACf;IAEA,IAAI,CAACjB,QAAQM,MAAM,EACjBN,QAAQkB,MAAM,GAAG,SAACC,SAASC,SAAST;QAClCI,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC,AAAC,GAAuCG,OAArC;YAACC;SAAQ,CAACR,MAAM,CAACD,MAAMU,IAAI,CAAC,MAAK,MAAY,OAARF,SAAQ;QAC5DJ,QAAQC,GAAG,CAAC;IACd;IAEFhB,QAAQsB,KAAK,GAAG,WAAW,qBAAqB;IAChDC,IAAAA,cAAG,EAACZ,IAAI,CAAC,EAAE,EAAEA,IAAI,CAAC,EAAE,EAAEA,KAAKT,KAAK,CAAC,IAAIF,SAAS,SAACwB,KAAKC;QAClD,IAAID,KAAK;YACPT,QAAQC,GAAG,CAACQ,IAAIE,OAAO;YACvB,OAAOT,IAAAA,aAAI,EAACO,IAAIG,IAAI,IAAI,CAAC;QAC3B;QACA,IAAMC,SAASH,QAAQI,MAAM,CAAC,SAACC;mBAAW,CAAC,CAACA,OAAOC,KAAK;;QAExD,IAAI,CAAC/B,QAAQM,MAAM,EAAE;YACnBS,QAAQC,GAAG,CAAC;YACZ,IAAIY,OAAOd,MAAM,EAAE;gBACjBC,QAAQC,GAAG,CAAC,AAAC,WAAwB,OAAdY,OAAOd,MAAM,EAAC;gBACrC,IAAK,IAAIkB,QAAQ,GAAGA,QAAQJ,OAAOd,MAAM,EAAEkB,QAAS;oBAClD,IAAMF,SAASF,MAAM,CAACI,MAAM;oBAC5BjB,QAAQC,GAAG,CAAC,AAAC,GAA2Bc,OAAzBA,OAAOX,OAAO,EAAC,YAA+B,OAArBW,OAAOC,KAAK,CAACL,OAAO;gBAC9D;YACF,OAAOX,QAAQC,GAAG,CAAC,AAAC,YAA0B,OAAfS,QAAQX,MAAM,EAAC;YAC9CC,QAAQC,GAAG,CAAC;QACd;QAEAC,IAAAA,aAAI,EAACW,OAAOd,MAAM,GAAG,CAAC,IAAI;IAC5B;AACF"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var home = require("osenv").home();
4
+ module.exports = {
5
+ cacheDirectory: path.join(home, ".nvu", "cache"),
6
+ installDirectory: path.join(home, ".nvu", "installed")
7
+ };
8
+
9
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
10
+ Object.defineProperty(exports.default, '__esModule', { value: true });
11
+ for (var key in exports) exports.default[key] = exports[key];
12
+ module.exports = exports.default;
13
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["constants.js"],"sourcesContent":["const path = require('path');\nconst home = require('osenv').home();\n\nmodule.exports = {\n cacheDirectory: path.join(home, '.nvu', 'cache'),\n installDirectory: path.join(home, '.nvu', 'installed'),\n};\n"],"names":["path","require","home","module","exports","cacheDirectory","join","installDirectory"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,OAAOD,QAAQ,SAASC,IAAI;AAElCC,OAAOC,OAAO,GAAG;IACfC,gBAAgBL,KAAKM,IAAI,CAACJ,MAAM,QAAQ;IACxCK,kBAAkBP,KAAKM,IAAI,CAACJ,MAAM,QAAQ;AAC5C"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var use = require("./use");
3
+ var constants = require("./constants");
4
+ module.exports = function nodeVersionUse(versionExpression, command, args, options, callback) {
5
+ if (typeof options === "function") {
6
+ callback = options;
7
+ options = {};
8
+ }
9
+ if (typeof callback === "function") return use(versionExpression, command, args, options || {}, callback);
10
+ return new Promise(function(resolve, reject) {
11
+ nodeVersionUse(versionExpression, command, args, options, function nodeVersionUseCallback(err, res) {
12
+ err ? reject(err) : resolve(res);
13
+ });
14
+ });
15
+ };
16
+ module.exports.installDirectory = function installDirectory() {
17
+ return constants.installDirectory;
18
+ };
19
+ module.exports.cacheDirectory = function cacheDirectory(_options) {
20
+ return constants.cacheDirectory;
21
+ };
22
+
23
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
24
+ Object.defineProperty(exports.default, '__esModule', { value: true });
25
+ for (var key in exports) exports.default[key] = exports[key];
26
+ module.exports = exports.default;
27
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["const use = require('./use');\nconst constants = require('./constants');\n\nmodule.exports = function nodeVersionUse(versionExpression, command, args, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n if (typeof callback === 'function') return use(versionExpression, command, args, options || {}, callback);\n return new Promise((resolve, reject) => {\n nodeVersionUse(versionExpression, command, args, options, function nodeVersionUseCallback(err, res) {\n err ? reject(err) : resolve(res);\n });\n });\n};\n\nmodule.exports.installDirectory = function installDirectory() {\n return constants.installDirectory;\n};\n\nmodule.exports.cacheDirectory = function cacheDirectory(_options) {\n return constants.cacheDirectory;\n};\n"],"names":["use","require","constants","module","exports","nodeVersionUse","versionExpression","command","args","options","callback","Promise","resolve","reject","nodeVersionUseCallback","err","res","installDirectory","cacheDirectory","_options"],"mappings":";AAAA,IAAMA,MAAMC,QAAQ;AACpB,IAAMC,YAAYD,QAAQ;AAE1BE,OAAOC,OAAO,GAAG,SAASC,eAAeC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC1F,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACA,IAAI,OAAOC,aAAa,YAAY,OAAOV,IAAIM,mBAAmBC,SAASC,MAAMC,WAAW,CAAC,GAAGC;IAChG,OAAO,IAAIC,QAAQ,SAACC,SAASC;QAC3BR,eAAeC,mBAAmBC,SAASC,MAAMC,SAAS,SAASK,uBAAuBC,GAAG,EAAEC,GAAG;YAChGD,MAAMF,OAAOE,OAAOH,QAAQI;QAC9B;IACF;AACF;AAEAb,OAAOC,OAAO,CAACa,gBAAgB,GAAG,SAASA;IACzC,OAAOf,UAAUe,gBAAgB;AACnC;AAEAd,OAAOC,OAAO,CAACc,cAAc,GAAG,SAASA,eAAeC,QAAQ;IAC9D,OAAOjB,UAAUgB,cAAc;AACjC"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var assign = require("just-extend");
4
+ var Queue = require("queue-cb");
5
+ var installRelease = require("node-install-release");
6
+ var versionUtils = require("node-version-utils");
7
+ var resolveVersions = require("node-resolve-versions");
8
+ var constants = require("./constants");
9
+ var spawnKeys = [
10
+ "encoding",
11
+ "stdio",
12
+ "stdin",
13
+ "stdout",
14
+ "stderr",
15
+ "cwd",
16
+ "env"
17
+ ];
18
+ module.exports = function use(versionExpression, command, args, options, callback) {
19
+ resolveVersions(versionExpression, assign({}, options, {
20
+ path: "raw"
21
+ }), function(err, versions) {
22
+ if (err) return callback(err);
23
+ if (!versions.length) return callback(new Error("No versions found from expression: ".concat(versionExpression)));
24
+ var spawnOptions = {};
25
+ for(var i = 0; i < spawnKeys.length; i++){
26
+ if (options[spawnKeys[i]] !== undefined) spawnOptions[spawnKeys[i]] = options[spawnKeys[i]];
27
+ }
28
+ var results = [];
29
+ var queue = new Queue(1);
30
+ for(var index = 0; index < versions.length; index++){
31
+ (function(version) {
32
+ queue.defer(function(callback) {
33
+ !options.header || options.header(version.version, command, args);
34
+ var installDirectory = options.installDirectory || constants.installDirectory;
35
+ var cacheDirectory = options.cacheDirectory || constants.cacheDirectory;
36
+ var installPath = path.join(installDirectory, version.version);
37
+ installRelease(version, installPath, {
38
+ cacheDirectory: cacheDirectory
39
+ }, function(err) {
40
+ if (err) return callback(err);
41
+ versionUtils.spawn(installPath, command, args, spawnOptions, function(err, res) {
42
+ results.push({
43
+ version: version.version,
44
+ error: err,
45
+ result: res
46
+ });
47
+ callback();
48
+ });
49
+ });
50
+ });
51
+ })(versions[index]);
52
+ }
53
+ queue.await(function(err) {
54
+ err ? callback(err) : callback(null, results);
55
+ });
56
+ });
57
+ };
58
+
59
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
60
+ Object.defineProperty(exports.default, '__esModule', { value: true });
61
+ for (var key in exports) exports.default[key] = exports[key];
62
+ module.exports = exports.default;
63
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["use.js"],"sourcesContent":["const path = require('path');\nconst assign = require('just-extend');\nconst Queue = require('queue-cb');\nconst installRelease = require('node-install-release');\nconst versionUtils = require('node-version-utils');\nconst resolveVersions = require('node-resolve-versions');\n\nconst constants = require('./constants');\nconst spawnKeys = ['encoding', 'stdio', 'stdin', 'stdout', 'stderr', 'cwd', 'env'];\n\nmodule.exports = function use(versionExpression, command, args, options, callback) {\n resolveVersions(versionExpression, assign({}, options, { path: 'raw' }), (err, versions) => {\n if (err) return callback(err);\n if (!versions.length) return callback(new Error(`No versions found from expression: ${versionExpression}`));\n\n const spawnOptions = {};\n for (let i = 0; i < spawnKeys.length; i++) {\n if (options[spawnKeys[i]] !== undefined) spawnOptions[spawnKeys[i]] = options[spawnKeys[i]];\n }\n\n const results = [];\n const queue = new Queue(1);\n for (let index = 0; index < versions.length; index++) {\n ((version) => {\n queue.defer((callback) => {\n !options.header || options.header(version.version, command, args);\n\n const installDirectory = options.installDirectory || constants.installDirectory;\n const cacheDirectory = options.cacheDirectory || constants.cacheDirectory;\n const installPath = path.join(installDirectory, version.version);\n\n installRelease(version, installPath, { cacheDirectory: cacheDirectory }, (err) => {\n if (err) return callback(err);\n\n versionUtils.spawn(installPath, command, args, spawnOptions, (err, res) => {\n results.push({ version: version.version, error: err, result: res });\n callback();\n });\n });\n });\n })(versions[index]);\n }\n queue.await((err) => {\n err ? callback(err) : callback(null, results);\n });\n });\n};\n"],"names":["path","require","assign","Queue","installRelease","versionUtils","resolveVersions","constants","spawnKeys","module","exports","use","versionExpression","command","args","options","callback","err","versions","length","Error","spawnOptions","i","undefined","results","queue","index","version","defer","header","installDirectory","cacheDirectory","installPath","join","spawn","res","push","error","result","await"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,SAASD,QAAQ;AACvB,IAAME,QAAQF,QAAQ;AACtB,IAAMG,iBAAiBH,QAAQ;AAC/B,IAAMI,eAAeJ,QAAQ;AAC7B,IAAMK,kBAAkBL,QAAQ;AAEhC,IAAMM,YAAYN,QAAQ;AAC1B,IAAMO,YAAY;IAAC;IAAY;IAAS;IAAS;IAAU;IAAU;IAAO;CAAM;AAElFC,OAAOC,OAAO,GAAG,SAASC,IAAIC,iBAAiB,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAC/EV,gBAAgBM,mBAAmBV,OAAO,CAAC,GAAGa,SAAS;QAAEf,MAAM;IAAM,IAAI,SAACiB,KAAKC;QAC7E,IAAID,KAAK,OAAOD,SAASC;QACzB,IAAI,CAACC,SAASC,MAAM,EAAE,OAAOH,SAAS,IAAII,MAAM,AAAC,sCAAuD,OAAlBR;QAEtF,IAAMS,eAAe,CAAC;QACtB,IAAK,IAAIC,IAAI,GAAGA,IAAId,UAAUW,MAAM,EAAEG,IAAK;YACzC,IAAIP,OAAO,CAACP,SAAS,CAACc,EAAE,CAAC,KAAKC,WAAWF,YAAY,CAACb,SAAS,CAACc,EAAE,CAAC,GAAGP,OAAO,CAACP,SAAS,CAACc,EAAE,CAAC;QAC7F;QAEA,IAAME,UAAU,EAAE;QAClB,IAAMC,QAAQ,IAAItB,MAAM;QACxB,IAAK,IAAIuB,QAAQ,GAAGA,QAAQR,SAASC,MAAM,EAAEO,QAAS;YACnD,CAAA,SAACC;gBACAF,MAAMG,KAAK,CAAC,SAACZ;oBACX,CAACD,QAAQc,MAAM,IAAId,QAAQc,MAAM,CAACF,QAAQA,OAAO,EAAEd,SAASC;oBAE5D,IAAMgB,mBAAmBf,QAAQe,gBAAgB,IAAIvB,UAAUuB,gBAAgB;oBAC/E,IAAMC,iBAAiBhB,QAAQgB,cAAc,IAAIxB,UAAUwB,cAAc;oBACzE,IAAMC,cAAchC,KAAKiC,IAAI,CAACH,kBAAkBH,QAAQA,OAAO;oBAE/DvB,eAAeuB,SAASK,aAAa;wBAAED,gBAAgBA;oBAAe,GAAG,SAACd;wBACxE,IAAIA,KAAK,OAAOD,SAASC;wBAEzBZ,aAAa6B,KAAK,CAACF,aAAanB,SAASC,MAAMO,cAAc,SAACJ,KAAKkB;4BACjEX,QAAQY,IAAI,CAAC;gCAAET,SAASA,QAAQA,OAAO;gCAAEU,OAAOpB;gCAAKqB,QAAQH;4BAAI;4BACjEnB;wBACF;oBACF;gBACF;YACF,CAAA,EAAGE,QAAQ,CAACQ,MAAM;QACpB;QACAD,MAAMc,KAAK,CAAC,SAACtB;YACXA,MAAMD,SAASC,OAAOD,SAAS,MAAMQ;QACvC;IACF;AACF"}
@@ -0,0 +1,2 @@
1
+ declare function _default(argv: any, name: any): any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ export let cacheDirectory: string;
2
+ export let installDirectory: string;
@@ -0,0 +1,6 @@
1
+ declare function _exports(versionExpression: any, command: any, args: any, options: any, callback: any): void | Promise<any>;
2
+ declare namespace _exports {
3
+ function installDirectory(): string;
4
+ function cacheDirectory(_options: any): string;
5
+ }
6
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ declare function _exports(versionExpression: any, command: any, args: any, options: any, callback: any): void;
2
+ export = _exports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-version-use",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "Cross-platform solution for using multiple versions of node. Useful for compatibility testing",
5
5
  "keywords": [
6
6
  "node",
@@ -17,48 +17,51 @@
17
17
  "url": "git@github.com:kmalakoff/node-version-use.git"
18
18
  },
19
19
  "license": "MIT",
20
- "main": "lib/index.js",
21
20
  "bin": {
22
- "nvu": "./bin/node-version-use.js"
21
+ "nvu": "./bin/cli.js"
23
22
  },
23
+ "main": "dist/cjs/index.js",
24
+ "types": "dist/types/index.d.ts",
24
25
  "files": [
25
- "lib"
26
+ "dist"
26
27
  ],
27
28
  "scripts": {
28
- "build": "",
29
- "compat": "./bin/node-version-use.js engines mocha-compat test/spec/**/*.test.js --no-timeouts",
30
- "format": "prettier --write .",
31
- "lint": "eslint .",
32
- "prepublishOnly": "npm run lint && depcheck",
33
- "test": "mocha-compat test/spec/**/*.test.js --no-timeouts",
34
- "test:engines": "nvu engines npm test"
29
+ "build": "tsds build",
30
+ "deploy": "tsds deploy",
31
+ "format": "biome check --apply-unsafe src/ test/",
32
+ "test": "tsds test:node --timeout=1000000",
33
+ "test:engines": "nvu engines tsds test:node --timeout=1000000",
34
+ "version": "tsds version"
35
35
  },
36
36
  "dependencies": {
37
- "cross-spawn-cb": "^0.6.14",
37
+ "cross-spawn-cb": "^0.6.17",
38
38
  "exit": "^0.1.2",
39
39
  "getopts-compat": "^2.2.5",
40
- "just-extend": "^6.1.1",
41
- "node-install-release": "^0.4.7",
40
+ "just-extend": "^6.2.0",
41
+ "node-install-release": "^0.4.8",
42
42
  "node-resolve-versions": "^0.3.9",
43
43
  "node-version-utils": "^0.5.6",
44
44
  "osenv": "^0.1.5",
45
45
  "queue-cb": "^1.1.7"
46
46
  },
47
47
  "devDependencies": {
48
- "@typescript-eslint/parser": "^5.33.0",
48
+ "@biomejs/biome": "^1.5.3",
49
+ "@types/mocha": "^10.0.6",
50
+ "@types/node": "^20.11.17",
49
51
  "cr": "^0.1.0",
50
- "depcheck": "^1.4.3",
51
- "eslint": "^8.21.0",
52
- "eslint-config-prettier": "^8.5.0",
53
- "eslint-config-standard": "^17.0.0",
54
- "eslint-plugin-import": "^2.26.0",
55
- "eslint-plugin-promise": "^6.0.0",
52
+ "depcheck": "^1.4.7",
56
53
  "is-version": "^0.2.1",
57
- "mocha-compat": "^3.5.5",
58
- "prettier": "^2.7.1",
59
- "rimraf": "^2.7.1"
54
+ "node-version-use": "^0.4.7",
55
+ "rimraf": "^2.7.1",
56
+ "ts-dev-stack": "^0.9.7"
60
57
  },
61
58
  "engines": {
62
59
  "node": ">=0.8"
60
+ },
61
+ "tsds": {
62
+ "source": "src/index.js",
63
+ "targets": [
64
+ "cjs"
65
+ ]
63
66
  }
64
67
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('../lib/cli')(process.argv.slice(2), 'nvu');
package/lib/cli.js DELETED
@@ -1,54 +0,0 @@
1
- var getopts = require('getopts-compat');
2
- var exit = require('exit');
3
- var nvs = require('..');
4
-
5
- module.exports = function cli(argv, name) {
6
- var options = getopts(argv.slice(1), {
7
- alias: { range: 'r', desc: 'd', silent: 's' },
8
- default: { range: 'major,even' },
9
- boolean: ['silent', 'desc'],
10
- stopEarly: true,
11
- });
12
-
13
- // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'major,even');
14
- // define.option('-s, --silent', 'suppress logging', false);
15
- options.sort = options.desc ? -1 : 1;
16
-
17
- var args = argv.slice(0, 1).concat(options._);
18
- if (args.length < 1) {
19
- console.log('Missing command. Example usage: ' + name + ' [version expression] [command]');
20
- return exit(-1);
21
- }
22
-
23
- if (!options.silent)
24
- options.header = function (version, command, args) {
25
- console.log('\n----------------------');
26
- console.log([command].concat(args).join(' ') + ' (' + version + ')');
27
- console.log('----------------------');
28
- };
29
-
30
- options.stdio = 'inherit'; // pass through stdio
31
- nvs(args[0], args[1], args.slice(2), options, function (err, results) {
32
- if (err) {
33
- console.log(err.message);
34
- return exit(err.code || -1);
35
- }
36
- var errors = results.filter(function (result) {
37
- return !!result.error;
38
- });
39
-
40
- if (!options.silent) {
41
- console.log('\n======================');
42
- if (errors.length) {
43
- console.log('Errors (' + errors.length + ')');
44
- for (var index = 0; index < errors.length; index++) {
45
- var result = errors[index];
46
- console.log(result.version + ' Error: ' + result.error.message);
47
- }
48
- } else console.log('Success (' + results.length + ')');
49
- console.log('======================');
50
- }
51
-
52
- exit(errors.length ? -1 : 0);
53
- });
54
- };
package/lib/constants.js DELETED
@@ -1,7 +0,0 @@
1
- var path = require('path');
2
- var home = require('osenv').home();
3
-
4
- module.exports = {
5
- cacheDirectory: path.join(home, '.nvu', 'cache'),
6
- installDirectory: path.join(home, '.nvu', 'installed'),
7
- };
package/lib/index.js DELETED
@@ -1,23 +0,0 @@
1
- var use = require('./use');
2
- var constants = require('./constants');
3
-
4
- module.exports = function nodeVersionUse(versionExpression, command, args, options, callback) {
5
- if (typeof options === 'function') {
6
- callback = options;
7
- options = {};
8
- }
9
- if (typeof callback === 'function') return use(versionExpression, command, args, options || {}, callback);
10
- return new Promise(function (resolve, reject) {
11
- nodeVersionUse(versionExpression, command, args, options, function nodeVersionUseCallback(err, res) {
12
- err ? reject(err) : resolve(res);
13
- });
14
- });
15
- };
16
-
17
- module.exports.installDirectory = function installDirectory() {
18
- return constants.installDirectory;
19
- };
20
-
21
- module.exports.cacheDirectory = function cacheDirectory(options) {
22
- return constants.cacheDirectory;
23
- };
package/lib/use.js DELETED
@@ -1,47 +0,0 @@
1
- var path = require('path');
2
- var assign = require('just-extend');
3
- var Queue = require('queue-cb');
4
- var installRelease = require('node-install-release');
5
- var versionUtils = require('node-version-utils');
6
- var resolveVersions = require('node-resolve-versions');
7
-
8
- var constants = require('./constants');
9
- var spawnKeys = ['encoding', 'stdio', 'stdin', 'stdout', 'stderr', 'cwd', 'env'];
10
-
11
- module.exports = function use(versionExpression, command, args, options, callback) {
12
- resolveVersions(versionExpression, assign({}, options, { path: 'raw' }), function (err, versions) {
13
- if (err) return callback(err);
14
- if (!versions.length) return callback(new Error('No versions found from expression: ' + versionExpression));
15
-
16
- var spawnOptions = {};
17
- for (var i = 0; i < spawnKeys.length; i++) {
18
- if (options[spawnKeys[i]] !== undefined) spawnOptions[spawnKeys[i]] = options[spawnKeys[i]];
19
- }
20
-
21
- var results = [];
22
- var queue = new Queue(1);
23
- for (var index = 0; index < versions.length; index++) {
24
- (function (version) {
25
- queue.defer(function (callback) {
26
- !options.header || options.header(version.version, command, args);
27
-
28
- var installDirectory = options.installDirectory || constants.installDirectory;
29
- var cacheDirectory = options.cacheDirectory || constants.cacheDirectory;
30
- var installPath = path.join(installDirectory, version.version);
31
-
32
- installRelease(version, installPath, { cacheDirectory: cacheDirectory }, function (err) {
33
- if (err) return callback(err);
34
-
35
- versionUtils.spawn(installPath, command, args, spawnOptions, function (err, res) {
36
- results.push({ version: version.version, error: err, result: res });
37
- callback();
38
- });
39
- });
40
- });
41
- })(versions[index]);
42
- }
43
- queue.await(function (err) {
44
- err ? callback(err) : callback(null, results);
45
- });
46
- });
47
- };