node-semvers 0.6.10 → 1.0.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/bin/cli.js +3 -0
- package/dist/cjs/NodeVersions.js +148 -0
- package/dist/cjs/NodeVersions.js.map +1 -0
- package/dist/cjs/cli.js +79 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/constants.js +8 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +18 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/isNaN.js +7 -0
- package/dist/cjs/isNaN.js.map +1 -0
- package/dist/cjs/keyFunctions.js +8 -0
- package/dist/cjs/keyFunctions.js.map +1 -0
- package/dist/cjs/lineFunctions.js +10 -0
- package/dist/cjs/lineFunctions.js.map +1 -0
- package/dist/cjs/match.js +8 -0
- package/dist/cjs/match.js.map +1 -0
- package/dist/cjs/normalizeSchedule.js +15 -0
- package/dist/cjs/normalizeSchedule.js.map +1 -0
- package/dist/cjs/normalizeVersion.js +26 -0
- package/dist/cjs/normalizeVersion.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/parseExpression/index.js +48 -0
- package/dist/cjs/parseExpression/index.js.map +1 -0
- package/dist/cjs/parseExpression/isLTSFn.js +7 -0
- package/dist/cjs/parseExpression/isLTSFn.js.map +1 -0
- package/dist/cjs/parseExpression/isLatestFn.js +7 -0
- package/dist/cjs/parseExpression/isLatestFn.js.map +1 -0
- package/dist/cjs/parseExpression/schedulesForEach.js +8 -0
- package/dist/cjs/parseExpression/schedulesForEach.js.map +1 -0
- package/dist/cjs/parseExpression/schedulesLatest.js +10 -0
- package/dist/cjs/parseExpression/schedulesLatest.js.map +1 -0
- package/dist/cjs/scripts/cache.js +38 -0
- package/dist/cjs/scripts/cache.js.map +1 -0
- package/dist/types/NodeVersions.d.ts +22 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/isNaN.d.ts +2 -0
- package/dist/types/keyFunctions.d.ts +2 -0
- package/dist/types/lineFunctions.d.ts +2 -0
- package/dist/types/match.d.ts +2 -0
- package/dist/types/normalizeSchedule.d.ts +6 -0
- package/dist/types/normalizeVersion.d.ts +12 -0
- package/dist/types/parseExpression/index.d.ts +32 -0
- package/dist/types/parseExpression/isLTSFn.d.ts +2 -0
- package/dist/types/parseExpression/isLatestFn.d.ts +2 -0
- package/dist/types/parseExpression/schedulesForEach.d.ts +2 -0
- package/dist/types/parseExpression/schedulesLatest.d.ts +2 -0
- package/dist/types/scripts/cache.d.ts +2 -0
- package/package.json +28 -25
- package/scripts/cache.js +3 -0
- package/bin/cache.js +0 -21
- package/bin/node-semvers.js +0 -69
- package/lib/constants.js +0 -7
- package/lib/index.js +0 -112
- package/lib/isNaN.js +0 -4
- package/lib/keyFunctions.js +0 -7
- package/lib/lineFunctions.js +0 -9
- package/lib/match.js +0 -6
- package/lib/normalizeSchedule.js +0 -15
- package/lib/normalizeVersion.js +0 -26
- package/lib/parseExpression/index.js +0 -28
- package/lib/parseExpression/isLTSFn.js +0 -5
- package/lib/parseExpression/isLatestFn.js +0 -5
- package/lib/parseExpression/schedulesForEach.js +0 -6
- package/lib/parseExpression/schedulesLatest.js +0 -9
package/bin/cli.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
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 NodeVersions;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fetchjsoncache = /*#__PURE__*/ _interop_require_default(require("fetch-json-cache"));
|
|
12
|
+
var _semver = /*#__PURE__*/ _interop_require_default(require("semver"));
|
|
13
|
+
var _constants = /*#__PURE__*/ _interop_require_default(require("./constants"));
|
|
14
|
+
var _keyFunctions = /*#__PURE__*/ _interop_require_default(require("./keyFunctions"));
|
|
15
|
+
var _lineFunctions = /*#__PURE__*/ _interop_require_default(require("./lineFunctions"));
|
|
16
|
+
var _match = /*#__PURE__*/ _interop_require_default(require("./match"));
|
|
17
|
+
var _normalizeSchedule = /*#__PURE__*/ _interop_require_default(require("./normalizeSchedule"));
|
|
18
|
+
var _normalizeVersion = /*#__PURE__*/ _interop_require_default(require("./normalizeVersion"));
|
|
19
|
+
var _parseExpression = /*#__PURE__*/ _interop_require_default(require("./parseExpression"));
|
|
20
|
+
function _class_call_check(instance, Constructor) {
|
|
21
|
+
if (!(instance instanceof Constructor)) {
|
|
22
|
+
throw new TypeError("Cannot call a class as a function");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function _defineProperties(target, props) {
|
|
26
|
+
for(var i = 0; i < props.length; i++){
|
|
27
|
+
var descriptor = props[i];
|
|
28
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
29
|
+
descriptor.configurable = true;
|
|
30
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
31
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
35
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
36
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
37
|
+
return Constructor;
|
|
38
|
+
}
|
|
39
|
+
function _interop_require_default(obj) {
|
|
40
|
+
return obj && obj.__esModule ? obj : {
|
|
41
|
+
default: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var NodeVersions = /*#__PURE__*/ function() {
|
|
45
|
+
"use strict";
|
|
46
|
+
function NodeVersions(versions, schedule) {
|
|
47
|
+
_class_call_check(this, NodeVersions);
|
|
48
|
+
if (!versions) throw new Error('Missing option: versions');
|
|
49
|
+
if (!schedule) throw new Error('Missing option: schedule');
|
|
50
|
+
this.schedules = [];
|
|
51
|
+
for(var name in schedule)this.schedules.push((0, _normalizeSchedule.default)(name, schedule[name]));
|
|
52
|
+
this.schedules = this.schedules.sort(function(a, b) {
|
|
53
|
+
return _semver.default.gt(_semver.default.coerce(a.semver), _semver.default.coerce(b.semver)) ? 1 : -1;
|
|
54
|
+
});
|
|
55
|
+
this.versions = [];
|
|
56
|
+
for(var index = 0; index < versions.length; index++)this.versions.push((0, _normalizeVersion.default)(versions[index], this.schedules));
|
|
57
|
+
this.versions = this.versions.sort(function(a, b) {
|
|
58
|
+
return _semver.default.gt(a.semver, b.semver) ? -1 : 1;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
_create_class(NodeVersions, [
|
|
62
|
+
{
|
|
63
|
+
key: "resolve",
|
|
64
|
+
value: function resolve(expression, options) {
|
|
65
|
+
options = options || {};
|
|
66
|
+
var path = options.path || 'version';
|
|
67
|
+
// normalize
|
|
68
|
+
if (typeof expression === 'number') expression = "".concat(expression);
|
|
69
|
+
if (typeof expression !== 'string') return null;
|
|
70
|
+
expression = expression.trim();
|
|
71
|
+
// single result, try a match
|
|
72
|
+
var query = _parseExpression.default.call(this, expression, options.now || new Date());
|
|
73
|
+
if (query) {
|
|
74
|
+
var version = null;
|
|
75
|
+
for(var index = 0; index < this.versions.length; index++){
|
|
76
|
+
var test = this.versions[index];
|
|
77
|
+
if (options.now && options.now < test.date) continue;
|
|
78
|
+
if (!(0, _match.default)(test, query)) continue;
|
|
79
|
+
version = test;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (version) return version[path];
|
|
83
|
+
}
|
|
84
|
+
// filtered expression
|
|
85
|
+
var range = options.range || '';
|
|
86
|
+
var filters = {
|
|
87
|
+
lts: !!~range.indexOf('lts')
|
|
88
|
+
};
|
|
89
|
+
filters.key = ~range.indexOf('major') ? _keyFunctions.default.major : ~range.indexOf('minor') ? _keyFunctions.default.minor : undefined;
|
|
90
|
+
filters.line = ~range.indexOf('even') ? _lineFunctions.default.even : ~range.indexOf('odd') ? _lineFunctions.default.odd : undefined;
|
|
91
|
+
var results = [];
|
|
92
|
+
var founds = {};
|
|
93
|
+
for(var index1 = 0; index1 < this.versions.length; index1++){
|
|
94
|
+
var test1 = this.versions[index1];
|
|
95
|
+
if (options.now && options.now < test1.date) continue;
|
|
96
|
+
if (filters.lts && !test1.lts) continue;
|
|
97
|
+
if (filters.line && !filters.line(test1)) continue;
|
|
98
|
+
if (!_semver.default.satisfies(test1.semver, expression)) continue;
|
|
99
|
+
if (filters.key) {
|
|
100
|
+
if (founds[filters.key(test1)]) continue;
|
|
101
|
+
founds[filters.key(test1)] = true;
|
|
102
|
+
}
|
|
103
|
+
results.unshift(test1[path]);
|
|
104
|
+
}
|
|
105
|
+
return results;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
], [
|
|
109
|
+
{
|
|
110
|
+
key: "load",
|
|
111
|
+
value: function load(options, callback) {
|
|
112
|
+
if (typeof options === 'function') {
|
|
113
|
+
callback = options;
|
|
114
|
+
options = null;
|
|
115
|
+
}
|
|
116
|
+
if (typeof callback === 'function') {
|
|
117
|
+
options = options || {};
|
|
118
|
+
var cache = new _fetchjsoncache.default(options.cacheDirectory || _constants.default.CACHE_DIRECTORY);
|
|
119
|
+
cache.get(_constants.default.DISTS_URL, function(err, versions) {
|
|
120
|
+
if (err) return callback(err);
|
|
121
|
+
cache.get(_constants.default.SCHEDULES_URL, function(err, schedule) {
|
|
122
|
+
err ? callback(err) : callback(null, new NodeVersions(versions, schedule));
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
return new Promise(function(resolve, reject) {
|
|
127
|
+
NodeVersions.load(options, function loadCallback(err, NodeVersions) {
|
|
128
|
+
err ? reject(err) : resolve(NodeVersions);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
key: "loadSync",
|
|
136
|
+
value: function loadSync(options) {
|
|
137
|
+
options = options || {};
|
|
138
|
+
var cache = new _fetchjsoncache.default(options.cacheDirectory || _constants.default.CACHE_DIRECTORY);
|
|
139
|
+
var versions = cache.getSync(_constants.default.DISTS_URL);
|
|
140
|
+
var schedule = cache.getSync(_constants.default.SCHEDULES_URL);
|
|
141
|
+
if (!versions || !schedule) return null;
|
|
142
|
+
return new NodeVersions(versions, schedule);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
]);
|
|
146
|
+
return NodeVersions;
|
|
147
|
+
}();
|
|
148
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["NodeVersions.js"],"sourcesContent":["import Cache from 'fetch-json-cache';\nimport semver from 'semver';\n\nimport constants from './constants';\nimport keyFunctions from './keyFunctions';\nimport lineFunctions from './lineFunctions';\nimport match from './match';\nimport normalizeSchedule from './normalizeSchedule';\nimport normalizeVersion from './normalizeVersion';\nimport parseExpression from './parseExpression';\n\nexport default class NodeVersions {\n constructor(versions, schedule) {\n if (!versions) throw new Error('Missing option: versions');\n if (!schedule) throw new Error('Missing option: schedule');\n\n this.schedules = [];\n for (const name in schedule) this.schedules.push(normalizeSchedule(name, schedule[name]));\n this.schedules = this.schedules.sort((a, b) => (semver.gt(semver.coerce(a.semver), semver.coerce(b.semver)) ? 1 : -1));\n\n this.versions = [];\n for (let index = 0; index < versions.length; index++) this.versions.push(normalizeVersion(versions[index], this.schedules));\n this.versions = this.versions.sort((a, b) => (semver.gt(a.semver, b.semver) ? -1 : 1));\n }\n\n static load(options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n\n if (typeof callback === 'function') {\n options = options || {};\n\n const cache = new Cache(options.cacheDirectory || constants.CACHE_DIRECTORY);\n cache.get(constants.DISTS_URL, (err, versions) => {\n if (err) return callback(err);\n\n cache.get(constants.SCHEDULES_URL, (err, schedule) => {\n err ? callback(err) : callback(null, new NodeVersions(versions, schedule));\n });\n });\n } else {\n return new Promise((resolve, reject) => {\n NodeVersions.load(options, function loadCallback(err, NodeVersions) {\n err ? reject(err) : resolve(NodeVersions);\n });\n });\n }\n }\n\n static loadSync(options) {\n options = options || {};\n const cache = new Cache(options.cacheDirectory || constants.CACHE_DIRECTORY);\n const versions = cache.getSync(constants.DISTS_URL);\n const schedule = cache.getSync(constants.SCHEDULES_URL);\n if (!versions || !schedule) return null;\n return new NodeVersions(versions, schedule);\n }\n\n resolve(expression, options) {\n options = options || {};\n const path = options.path || 'version';\n\n // normalize\n if (typeof expression === 'number') expression = `${expression}`;\n if (typeof expression !== 'string') return null;\n expression = expression.trim();\n\n // single result, try a match\n const query = parseExpression.call(this, expression, options.now || new Date());\n if (query) {\n let version = null;\n for (let index = 0; index < this.versions.length; index++) {\n const test = this.versions[index];\n if (options.now && options.now < test.date) continue;\n if (!match(test, query)) continue;\n version = test;\n break;\n }\n if (version) return version[path];\n }\n\n // filtered expression\n const range = options.range || '';\n const filters = { lts: !!~range.indexOf('lts') };\n filters.key = ~range.indexOf('major') ? keyFunctions.major : ~range.indexOf('minor') ? keyFunctions.minor : undefined;\n filters.line = ~range.indexOf('even') ? lineFunctions.even : ~range.indexOf('odd') ? lineFunctions.odd : undefined;\n\n const results = [];\n const founds = {};\n\n for (let index = 0; index < this.versions.length; index++) {\n const test = this.versions[index];\n if (options.now && options.now < test.date) continue;\n if (filters.lts && !test.lts) continue;\n if (filters.line && !filters.line(test)) continue;\n if (!semver.satisfies(test.semver, expression)) continue;\n if (filters.key) {\n if (founds[filters.key(test)]) continue;\n founds[filters.key(test)] = true;\n }\n results.unshift(test[path]);\n }\n return results;\n }\n}\n"],"names":["NodeVersions","versions","schedule","Error","schedules","name","push","normalizeSchedule","sort","a","b","semver","gt","coerce","index","length","normalizeVersion","resolve","expression","options","path","trim","query","parseExpression","call","now","Date","version","test","date","match","range","filters","lts","indexOf","key","keyFunctions","major","minor","undefined","line","lineFunctions","even","odd","results","founds","satisfies","unshift","load","callback","cache","Cache","cacheDirectory","constants","CACHE_DIRECTORY","get","DISTS_URL","err","SCHEDULES_URL","Promise","reject","loadCallback","loadSync","getSync"],"mappings":"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"}
|
package/dist/cjs/cli.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
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 _NodeVersions = /*#__PURE__*/ _interop_require_default(require("./NodeVersions.js"));
|
|
14
|
+
var _isarray = /*#__PURE__*/ _interop_require_default(require("isarray"));
|
|
15
|
+
var _isNaN = /*#__PURE__*/ _interop_require_default(require("./isNaN.js"));
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var _default = function(argv) {
|
|
22
|
+
var stringify = function stringify(value) {
|
|
23
|
+
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
24
|
+
};
|
|
25
|
+
var options = (0, _getoptscompat.default)(argv.slice(1), {
|
|
26
|
+
alias: {
|
|
27
|
+
path: 'p',
|
|
28
|
+
range: 'r',
|
|
29
|
+
now: 'n'
|
|
30
|
+
},
|
|
31
|
+
stopEarly: true
|
|
32
|
+
});
|
|
33
|
+
if (typeof options.now !== 'undefined') options.now = new Date((0, _isNaN.default)(+options.now) ? Date.parse(options.now) : +options.now);
|
|
34
|
+
// define.option('-p, --path [path]', 'path within version including raw for unprocessed version', 'version');
|
|
35
|
+
// define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'patch');
|
|
36
|
+
// define.option('-n, --now [date]', 'use a specific time as a Date.parse');
|
|
37
|
+
if (options.help) {
|
|
38
|
+
console.log('');
|
|
39
|
+
console.log('Example call:');
|
|
40
|
+
console.log(' $ nv [version string]');
|
|
41
|
+
console.log('');
|
|
42
|
+
console.log('Version Strings:');
|
|
43
|
+
console.log('Any command that calls for a version can be provided any of the');
|
|
44
|
+
console.log('following "version-ish" identifies:');
|
|
45
|
+
console.log('');
|
|
46
|
+
console.log('- x.y.z A specific SemVer tuple');
|
|
47
|
+
console.log('- x.y Major and minor version number');
|
|
48
|
+
console.log('- x Just a major version number');
|
|
49
|
+
console.log('- lts The most recent LTS (long-term support) node version');
|
|
50
|
+
console.log('- lts/<name> The latest in a named LTS set. (argon, boron, etc.)');
|
|
51
|
+
console.log('- lts/* Same as just "lts"');
|
|
52
|
+
console.log('- latest The most recent (non-LTS) version');
|
|
53
|
+
console.log('- stable Backwards-compatible alias for "lts"');
|
|
54
|
+
console.log('- [expression] Engine and semver module expression like "10.1.x || >=12.0.0"');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var args = argv.slice(0, 1).concat(options._);
|
|
58
|
+
if (args.length < 1) {
|
|
59
|
+
console.log('Missing version string. Example usage: nv [version string]. Use nv --help for information on version strings');
|
|
60
|
+
return (0, _exit.default)(-1);
|
|
61
|
+
}
|
|
62
|
+
_NodeVersions.default.load(options, function(err, semvers) {
|
|
63
|
+
if (err) {
|
|
64
|
+
console.log(err.message);
|
|
65
|
+
return (0, _exit.default)(err.code || -1);
|
|
66
|
+
}
|
|
67
|
+
var version = semvers.resolve(args[0], options);
|
|
68
|
+
if (!version || (0, _isarray.default)(version) && !version.length) {
|
|
69
|
+
console.log("Unrecognized: ".concat(args[0]));
|
|
70
|
+
return (0, _exit.default)(-1);
|
|
71
|
+
}
|
|
72
|
+
console.log('versions:');
|
|
73
|
+
if ((0, _isarray.default)(version)) {
|
|
74
|
+
for(var index = 0; index < version.length; index++)console.log(stringify(version[index]));
|
|
75
|
+
} else console.log(stringify(version));
|
|
76
|
+
(0, _exit.default)(0);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["cli.js"],"sourcesContent":["import exit from 'exit';\nimport getopts from 'getopts-compat';\nimport NodeVersions from './NodeVersions.js';\n\nimport isArray from 'isarray';\n// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>\nimport isNaN from './isNaN.js';\n\nexport default (argv) => {\n const options = getopts(argv.slice(1), {\n alias: { path: 'p', range: 'r', now: 'n' },\n stopEarly: true,\n });\n if (typeof options.now !== 'undefined') options.now = new Date(isNaN(+options.now) ? Date.parse(options.now) : +options.now);\n\n // define.option('-p, --path [path]', 'path within version including raw for unprocessed version', 'version');\n // define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'patch');\n // define.option('-n, --now [date]', 'use a specific time as a Date.parse');\n\n if (options.help) {\n console.log('');\n console.log('Example call:');\n console.log(' $ nv [version string]');\n console.log('');\n console.log('Version Strings:');\n console.log('Any command that calls for a version can be provided any of the');\n console.log('following \"version-ish\" identifies:');\n console.log('');\n console.log('- x.y.z A specific SemVer tuple');\n console.log('- x.y Major and minor version number');\n console.log('- x Just a major version number');\n console.log('- lts The most recent LTS (long-term support) node version');\n console.log('- lts/<name> The latest in a named LTS set. (argon, boron, etc.)');\n console.log('- lts/* Same as just \"lts\"');\n console.log('- latest The most recent (non-LTS) version');\n console.log('- stable Backwards-compatible alias for \"lts\"');\n console.log('- [expression] Engine and semver module expression like \"10.1.x || >=12.0.0\"');\n return;\n }\n\n const args = argv.slice(0, 1).concat(options._);\n if (args.length < 1) {\n console.log('Missing version string. Example usage: nv [version string]. Use nv --help for information on version strings');\n return exit(-1);\n }\n\n function stringify(value) {\n return typeof value === 'string' ? value : JSON.stringify(value);\n }\n\n NodeVersions.load(options, (err, semvers) => {\n if (err) {\n console.log(err.message);\n return exit(err.code || -1);\n }\n\n const version = semvers.resolve(args[0], options);\n if (!version || (isArray(version) && !version.length)) {\n console.log(`Unrecognized: ${args[0]}`);\n return exit(-1);\n }\n\n console.log('versions:');\n if (isArray(version)) {\n for (let index = 0; index < version.length; index++) console.log(stringify(version[index]));\n } else console.log(stringify(version));\n exit(0);\n });\n};\n"],"names":["argv","stringify","value","JSON","options","getopts","slice","alias","path","range","now","stopEarly","Date","isNaN","parse","help","console","log","args","concat","_","length","exit","NodeVersions","load","err","semvers","message","code","version","resolve","isArray","index"],"mappings":";;;;+BAQA;;;eAAA;;;2DARiB;oEACG;mEACK;8DAEL;4DAEF;;;;;;IAElB,WAAe,SAACA;QAsCLC,YAAT,SAASA,UAAUC,KAAK;QACtB,OAAO,OAAOA,UAAU,WAAWA,QAAQC,KAAKF,SAAS,CAACC;IAC5D;IAvCA,IAAME,UAAUC,IAAAA,sBAAO,EAACL,KAAKM,KAAK,CAAC,IAAI;QACrCC,OAAO;YAAEC,MAAM;YAAKC,OAAO;YAAKC,KAAK;QAAI;QACzCC,WAAW;IACb;IACA,IAAI,OAAOP,QAAQM,GAAG,KAAK,aAAaN,QAAQM,GAAG,GAAG,IAAIE,KAAKC,IAAAA,cAAK,EAAC,CAACT,QAAQM,GAAG,IAAIE,KAAKE,KAAK,CAACV,QAAQM,GAAG,IAAI,CAACN,QAAQM,GAAG;IAE3H,8GAA8G;IAC9G,uJAAuJ;IACvJ,4EAA4E;IAE5E,IAAIN,QAAQW,IAAI,EAAE;QAChBC,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZD,QAAQC,GAAG,CAAC;QACZ;IACF;IAEA,IAAMC,OAAOlB,KAAKM,KAAK,CAAC,GAAG,GAAGa,MAAM,CAACf,QAAQgB,CAAC;IAC9C,IAAIF,KAAKG,MAAM,GAAG,GAAG;QACnBL,QAAQC,GAAG,CAAC;QACZ,OAAOK,IAAAA,aAAI,EAAC,CAAC;IACf;IAMAC,qBAAY,CAACC,IAAI,CAACpB,SAAS,SAACqB,KAAKC;QAC/B,IAAID,KAAK;YACPT,QAAQC,GAAG,CAACQ,IAAIE,OAAO;YACvB,OAAOL,IAAAA,aAAI,EAACG,IAAIG,IAAI,IAAI,CAAC;QAC3B;QAEA,IAAMC,UAAUH,QAAQI,OAAO,CAACZ,IAAI,CAAC,EAAE,EAAEd;QACzC,IAAI,CAACyB,WAAYE,IAAAA,gBAAO,EAACF,YAAY,CAACA,QAAQR,MAAM,EAAG;YACrDL,QAAQC,GAAG,CAAC,AAAC,iBAAwB,OAARC,IAAI,CAAC,EAAE;YACpC,OAAOI,IAAAA,aAAI,EAAC,CAAC;QACf;QAEAN,QAAQC,GAAG,CAAC;QACZ,IAAIc,IAAAA,gBAAO,EAACF,UAAU;YACpB,IAAK,IAAIG,QAAQ,GAAGA,QAAQH,QAAQR,MAAM,EAAEW,QAAShB,QAAQC,GAAG,CAAChB,UAAU4B,OAAO,CAACG,MAAM;QAC3F,OAAOhB,QAAQC,GAAG,CAAChB,UAAU4B;QAC7BP,IAAAA,aAAI,EAAC;IACP;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var path = require('path');
|
|
3
|
+
module.exports = {
|
|
4
|
+
CACHE_DIRECTORY: path.resolve(path.join(__dirname, '..', '..', '.cache')),
|
|
5
|
+
DISTS_URL: 'https://nodejs.org/dist/index.json',
|
|
6
|
+
SCHEDULES_URL: 'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json'
|
|
7
|
+
};
|
|
8
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["constants.js"],"sourcesContent":["const path = require('path');\n\nmodule.exports = {\n CACHE_DIRECTORY: path.resolve(path.join(__dirname, '..', '..', '.cache')),\n DISTS_URL: 'https://nodejs.org/dist/index.json',\n SCHEDULES_URL: 'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json',\n};\n"],"names":["path","require","module","exports","CACHE_DIRECTORY","resolve","join","__dirname","DISTS_URL","SCHEDULES_URL"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AAErBC,OAAOC,OAAO,GAAG;IACfC,iBAAiBJ,KAAKK,OAAO,CAACL,KAAKM,IAAI,CAACC,WAAW,MAAM,MAAM;IAC/DC,WAAW;IACXC,eAAe;AACjB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 _NodeVersions = /*#__PURE__*/ _interop_require_default(require("./NodeVersions"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
var _default = _NodeVersions.default;
|
|
18
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.mjs"],"sourcesContent":["import NodeVersions from './NodeVersions';\nexport default NodeVersions;\n"],"names":["NodeVersions"],"mappings":";;;;+BACA;;;eAAA;;;mEADyB;;;;;;IACzB,WAAeA,qBAAY"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
|
|
2
|
+
"use strict";
|
|
3
|
+
module.exports = function isNaN(value) {
|
|
4
|
+
// biome-ignore lint/suspicious/noSelfCompare: <explanation>
|
|
5
|
+
return value !== value;
|
|
6
|
+
};
|
|
7
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["isNaN.js"],"sourcesContent":["// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>\nmodule.exports = function isNaN(value) {\n // biome-ignore lint/suspicious/noSelfCompare: <explanation>\n return value !== value;\n};\n"],"names":["module","exports","isNaN","value"],"mappings":"AAAA,sEAAsE;;AACtEA,OAAOC,OAAO,GAAG,SAASC,MAAMC,KAAK;IACnC,4DAA4D;IAC5D,OAAOA,UAAUA;AACnB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports.major = function major(version) {
|
|
3
|
+
return version.major === 0 ? "".concat(version.major, ".").concat(version.minor) : version.major;
|
|
4
|
+
};
|
|
5
|
+
module.exports.minor = function minor(version) {
|
|
6
|
+
return version.major === 0 ? "".concat(version.major, ".").concat(version.minor, ".").concat(version.patch) : "".concat(version.major, ".").concat(version.minor);
|
|
7
|
+
};
|
|
8
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["keyFunctions.js"],"sourcesContent":["module.exports.major = function major(version) {\n return version.major === 0 ? `${version.major}.${version.minor}` : version.major;\n};\n\nmodule.exports.minor = function minor(version) {\n return version.major === 0 ? `${version.major}.${version.minor}.${version.patch}` : `${version.major}.${version.minor}`;\n};\n"],"names":["module","exports","major","version","minor","patch"],"mappings":";AAAAA,OAAOC,OAAO,CAACC,KAAK,GAAG,SAASA,MAAMC,OAAO;IAC3C,OAAOA,QAAQD,KAAK,KAAK,IAAI,AAAC,GAAmBC,OAAjBA,QAAQD,KAAK,EAAC,KAAiB,OAAdC,QAAQC,KAAK,IAAKD,QAAQD,KAAK;AAClF;AAEAF,OAAOC,OAAO,CAACG,KAAK,GAAG,SAASA,MAAMD,OAAO;IAC3C,OAAOA,QAAQD,KAAK,KAAK,IAAI,AAAC,GAAmBC,OAAjBA,QAAQD,KAAK,EAAC,KAAoBC,OAAjBA,QAAQC,KAAK,EAAC,KAAiB,OAAdD,QAAQE,KAAK,IAAK,AAAC,GAAmBF,OAAjBA,QAAQD,KAAK,EAAC,KAAiB,OAAdC,QAAQC,KAAK;AACvH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports.even = function even(version) {
|
|
3
|
+
var major = version.major === 0 ? version.minor : version.major;
|
|
4
|
+
return major % 2 === 0;
|
|
5
|
+
};
|
|
6
|
+
module.exports.odd = function odd(version) {
|
|
7
|
+
var major = version.major === 0 ? version.minor : version.major;
|
|
8
|
+
return major % 2 === 1;
|
|
9
|
+
};
|
|
10
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["lineFunctions.js"],"sourcesContent":["module.exports.even = function even(version) {\n const major = version.major === 0 ? version.minor : version.major;\n return major % 2 === 0;\n};\n\nmodule.exports.odd = function odd(version) {\n const major = version.major === 0 ? version.minor : version.major;\n return major % 2 === 1;\n};\n"],"names":["module","exports","even","version","major","minor","odd"],"mappings":";AAAAA,OAAOC,OAAO,CAACC,IAAI,GAAG,SAASA,KAAKC,OAAO;IACzC,IAAMC,QAAQD,QAAQC,KAAK,KAAK,IAAID,QAAQE,KAAK,GAAGF,QAAQC,KAAK;IACjE,OAAOA,QAAQ,MAAM;AACvB;AAEAJ,OAAOC,OAAO,CAACK,GAAG,GAAG,SAASA,IAAIH,OAAO;IACvC,IAAMC,QAAQD,QAAQC,KAAK,KAAK,IAAID,QAAQE,KAAK,GAAGF,QAAQC,KAAK;IACjE,OAAOA,QAAQ,MAAM;AACvB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function match(test, query) {
|
|
3
|
+
for(var key in query){
|
|
4
|
+
if (test[key] !== query[key]) return false;
|
|
5
|
+
}
|
|
6
|
+
return true;
|
|
7
|
+
};
|
|
8
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["match.js"],"sourcesContent":["module.exports = function match(test, query) {\n for (const key in query) {\n if (test[key] !== query[key]) return false;\n }\n return true;\n};\n"],"names":["module","exports","match","test","query","key"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,MAAMC,IAAI,EAAEC,KAAK;IACzC,IAAK,IAAMC,OAAOD,MAAO;QACvB,IAAID,IAAI,CAACE,IAAI,KAAKD,KAAK,CAACC,IAAI,EAAE,OAAO;IACvC;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function normalizeSchedule(name, raw) {
|
|
3
|
+
var schedule = {
|
|
4
|
+
name: name,
|
|
5
|
+
semver: name.slice(1),
|
|
6
|
+
raw: raw
|
|
7
|
+
};
|
|
8
|
+
schedule.start = new Date(raw.start);
|
|
9
|
+
schedule.end = new Date(raw.end);
|
|
10
|
+
if (raw.codename) schedule.codename = raw.codename.toLowerCase();
|
|
11
|
+
if (raw.lts) schedule.lts = new Date(raw.lts);
|
|
12
|
+
if (raw.maintenance) schedule.maintenance = new Date(raw.maintenance);
|
|
13
|
+
return schedule;
|
|
14
|
+
};
|
|
15
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["normalizeSchedule.js"],"sourcesContent":["module.exports = function normalizeSchedule(name, raw) {\n const schedule = {\n name: name,\n semver: name.slice(1),\n raw: raw,\n };\n\n schedule.start = new Date(raw.start);\n schedule.end = new Date(raw.end);\n if (raw.codename) schedule.codename = raw.codename.toLowerCase();\n if (raw.lts) schedule.lts = new Date(raw.lts);\n if (raw.maintenance) schedule.maintenance = new Date(raw.maintenance);\n\n return schedule;\n};\n"],"names":["module","exports","normalizeSchedule","name","raw","schedule","semver","slice","start","Date","end","codename","toLowerCase","lts","maintenance"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,kBAAkBC,IAAI,EAAEC,GAAG;IACnD,IAAMC,WAAW;QACfF,MAAMA;QACNG,QAAQH,KAAKI,KAAK,CAAC;QACnBH,KAAKA;IACP;IAEAC,SAASG,KAAK,GAAG,IAAIC,KAAKL,IAAII,KAAK;IACnCH,SAASK,GAAG,GAAG,IAAID,KAAKL,IAAIM,GAAG;IAC/B,IAAIN,IAAIO,QAAQ,EAAEN,SAASM,QAAQ,GAAGP,IAAIO,QAAQ,CAACC,WAAW;IAC9D,IAAIR,IAAIS,GAAG,EAAER,SAASQ,GAAG,GAAG,IAAIJ,KAAKL,IAAIS,GAAG;IAC5C,IAAIT,IAAIU,WAAW,EAAET,SAASS,WAAW,GAAG,IAAIL,KAAKL,IAAIU,WAAW;IAEpE,OAAOT;AACT"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function normalizeVersion(raw, schedules) {
|
|
3
|
+
var parts = raw.version.substr(1).split('.');
|
|
4
|
+
var version = {
|
|
5
|
+
version: raw.version,
|
|
6
|
+
name: parts[0] !== 0 ? "v".concat(+parts[0]) : "v".concat(+parts[0], ".").concat(+parts[1]),
|
|
7
|
+
semver: "".concat(parts[0], ".").concat(+parts[1], ".").concat(+parts[2]),
|
|
8
|
+
major: +parts[0],
|
|
9
|
+
minor: +parts[1],
|
|
10
|
+
patch: +parts[2],
|
|
11
|
+
lts: raw.lts,
|
|
12
|
+
date: new Date(raw.date),
|
|
13
|
+
raw: raw
|
|
14
|
+
};
|
|
15
|
+
var schedule = null;
|
|
16
|
+
for(var index = 0; index < schedules.length; index++){
|
|
17
|
+
var test = schedules[index];
|
|
18
|
+
if (test.name === version.name) {
|
|
19
|
+
schedule = test;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (schedule && raw.lts) version.codename = schedule.codename;
|
|
24
|
+
return version;
|
|
25
|
+
};
|
|
26
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["normalizeVersion.js"],"sourcesContent":["module.exports = function normalizeVersion(raw, schedules) {\n const parts = raw.version.substr(1).split('.');\n\n const version = {\n version: raw.version,\n name: parts[0] !== 0 ? `v${+parts[0]}` : `v${+parts[0]}.${+parts[1]}`,\n semver: `${parts[0]}.${+parts[1]}.${+parts[2]}`,\n major: +parts[0],\n minor: +parts[1],\n patch: +parts[2],\n lts: raw.lts,\n date: new Date(raw.date),\n raw: raw,\n };\n\n let schedule = null;\n for (let index = 0; index < schedules.length; index++) {\n const test = schedules[index];\n if (test.name === version.name) {\n schedule = test;\n break;\n }\n }\n if (schedule && raw.lts) version.codename = schedule.codename;\n return version;\n};\n"],"names":["module","exports","normalizeVersion","raw","schedules","parts","version","substr","split","name","semver","major","minor","patch","lts","date","Date","schedule","index","length","test","codename"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,iBAAiBC,GAAG,EAAEC,SAAS;IACvD,IAAMC,QAAQF,IAAIG,OAAO,CAACC,MAAM,CAAC,GAAGC,KAAK,CAAC;IAE1C,IAAMF,UAAU;QACdA,SAASH,IAAIG,OAAO;QACpBG,MAAMJ,KAAK,CAAC,EAAE,KAAK,IAAI,AAAC,IAAa,OAAV,CAACA,KAAK,CAAC,EAAE,IAAK,AAAC,IAAgB,OAAb,CAACA,KAAK,CAAC,EAAE,EAAC,KAAa,OAAV,CAACA,KAAK,CAAC,EAAE;QACnEK,QAAQ,AAAC,GAAc,OAAZL,KAAK,CAAC,EAAE,EAAC,KAAgB,OAAb,CAACA,KAAK,CAAC,EAAE,EAAC,KAAa,OAAV,CAACA,KAAK,CAAC,EAAE;QAC7CM,OAAO,CAACN,KAAK,CAAC,EAAE;QAChBO,OAAO,CAACP,KAAK,CAAC,EAAE;QAChBQ,OAAO,CAACR,KAAK,CAAC,EAAE;QAChBS,KAAKX,IAAIW,GAAG;QACZC,MAAM,IAAIC,KAAKb,IAAIY,IAAI;QACvBZ,KAAKA;IACP;IAEA,IAAIc,WAAW;IACf,IAAK,IAAIC,QAAQ,GAAGA,QAAQd,UAAUe,MAAM,EAAED,QAAS;QACrD,IAAME,OAAOhB,SAAS,CAACc,MAAM;QAC7B,IAAIE,KAAKX,IAAI,KAAKH,QAAQG,IAAI,EAAE;YAC9BQ,WAAWG;YACX;QACF;IACF;IACA,IAAIH,YAAYd,IAAIW,GAAG,EAAER,QAAQe,QAAQ,GAAGJ,SAASI,QAAQ;IAC7D,OAAOf;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
|
|
2
|
+
"use strict";
|
|
3
|
+
var isNaN = require('../isNaN');
|
|
4
|
+
var isLTSFn = require('./isLTSFn');
|
|
5
|
+
var isLatestFn = require('./isLatestFn');
|
|
6
|
+
var schedulesLatest = require('./schedulesLatest');
|
|
7
|
+
module.exports = function parseExpression(expression, now) {
|
|
8
|
+
if (expression[0] === 'v' && !isNaN(+expression.substr(1, 1))) expression = expression.substr(1);
|
|
9
|
+
if (expression.substr(0, 4) === 'lts/') expression = expression.substr(4) === '*' ? 'lts' : expression.substr(4);
|
|
10
|
+
if (expression === 'stable') expression = 'lts';
|
|
11
|
+
if (typeof expression === 'number') return {
|
|
12
|
+
major: expression
|
|
13
|
+
};
|
|
14
|
+
if (~expression.indexOf('.')) {
|
|
15
|
+
var parts = expression.split('.');
|
|
16
|
+
if (parts.length === 1) return isNaN(+parts[0]) ? null : {
|
|
17
|
+
major: +parts[0]
|
|
18
|
+
};
|
|
19
|
+
if (parts.length === 2) return isNaN(+parts[0]) && isNaN(+parts[1]) ? null : {
|
|
20
|
+
major: +parts[0],
|
|
21
|
+
minor: +parts[1]
|
|
22
|
+
};
|
|
23
|
+
return isNaN(+parts[0]) && isNaN(+parts[1]) && isNaN(+parts[2]) ? null : {
|
|
24
|
+
major: +parts[0],
|
|
25
|
+
minor: +parts[1],
|
|
26
|
+
patch: +parts[2]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (!isNaN(+expression)) return {
|
|
30
|
+
major: +expression
|
|
31
|
+
};
|
|
32
|
+
if (expression === 'lts') {
|
|
33
|
+
var lts = schedulesLatest(this.schedules, isLTSFn(now));
|
|
34
|
+
return lts ? {
|
|
35
|
+
name: lts.name
|
|
36
|
+
} : null;
|
|
37
|
+
}
|
|
38
|
+
if (expression === 'latest') {
|
|
39
|
+
var latest = schedulesLatest(this.schedules, isLatestFn(now));
|
|
40
|
+
return latest ? {
|
|
41
|
+
name: latest.name
|
|
42
|
+
} : null;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
codename: expression.toLowerCase()
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>\nconst isNaN = require('../isNaN');\nconst isLTSFn = require('./isLTSFn');\nconst isLatestFn = require('./isLatestFn');\nconst schedulesLatest = require('./schedulesLatest');\n\nmodule.exports = function parseExpression(expression, now) {\n if (expression[0] === 'v' && !isNaN(+expression.substr(1, 1))) expression = expression.substr(1);\n if (expression.substr(0, 4) === 'lts/') expression = expression.substr(4) === '*' ? 'lts' : expression.substr(4);\n if (expression === 'stable') expression = 'lts';\n\n if (typeof expression === 'number') return { major: expression };\n if (~expression.indexOf('.')) {\n const parts = expression.split('.');\n if (parts.length === 1) return isNaN(+parts[0]) ? null : { major: +parts[0] };\n if (parts.length === 2) return isNaN(+parts[0]) && isNaN(+parts[1]) ? null : { major: +parts[0], minor: +parts[1] };\n return isNaN(+parts[0]) && isNaN(+parts[1]) && isNaN(+parts[2]) ? null : { major: +parts[0], minor: +parts[1], patch: +parts[2] };\n }\n if (!isNaN(+expression)) return { major: +expression };\n if (expression === 'lts') {\n const lts = schedulesLatest(this.schedules, isLTSFn(now));\n return lts ? { name: lts.name } : null;\n }\n if (expression === 'latest') {\n const latest = schedulesLatest(this.schedules, isLatestFn(now));\n return latest ? { name: latest.name } : null;\n }\n return { codename: expression.toLowerCase() };\n};\n"],"names":["isNaN","require","isLTSFn","isLatestFn","schedulesLatest","module","exports","parseExpression","expression","now","substr","major","indexOf","parts","split","length","minor","patch","lts","schedules","name","latest","codename","toLowerCase"],"mappings":"AAAA,sEAAsE;;AACtE,IAAMA,QAAQC,QAAQ;AACtB,IAAMC,UAAUD,QAAQ;AACxB,IAAME,aAAaF,QAAQ;AAC3B,IAAMG,kBAAkBH,QAAQ;AAEhCI,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,UAAU,EAAEC,GAAG;IACvD,IAAID,UAAU,CAAC,EAAE,KAAK,OAAO,CAACR,MAAM,CAACQ,WAAWE,MAAM,CAAC,GAAG,KAAKF,aAAaA,WAAWE,MAAM,CAAC;IAC9F,IAAIF,WAAWE,MAAM,CAAC,GAAG,OAAO,QAAQF,aAAaA,WAAWE,MAAM,CAAC,OAAO,MAAM,QAAQF,WAAWE,MAAM,CAAC;IAC9G,IAAIF,eAAe,UAAUA,aAAa;IAE1C,IAAI,OAAOA,eAAe,UAAU,OAAO;QAAEG,OAAOH;IAAW;IAC/D,IAAI,CAACA,WAAWI,OAAO,CAAC,MAAM;QAC5B,IAAMC,QAAQL,WAAWM,KAAK,CAAC;QAC/B,IAAID,MAAME,MAAM,KAAK,GAAG,OAAOf,MAAM,CAACa,KAAK,CAAC,EAAE,IAAI,OAAO;YAAEF,OAAO,CAACE,KAAK,CAAC,EAAE;QAAC;QAC5E,IAAIA,MAAME,MAAM,KAAK,GAAG,OAAOf,MAAM,CAACa,KAAK,CAAC,EAAE,KAAKb,MAAM,CAACa,KAAK,CAAC,EAAE,IAAI,OAAO;YAAEF,OAAO,CAACE,KAAK,CAAC,EAAE;YAAEG,OAAO,CAACH,KAAK,CAAC,EAAE;QAAC;QAClH,OAAOb,MAAM,CAACa,KAAK,CAAC,EAAE,KAAKb,MAAM,CAACa,KAAK,CAAC,EAAE,KAAKb,MAAM,CAACa,KAAK,CAAC,EAAE,IAAI,OAAO;YAAEF,OAAO,CAACE,KAAK,CAAC,EAAE;YAAEG,OAAO,CAACH,KAAK,CAAC,EAAE;YAAEI,OAAO,CAACJ,KAAK,CAAC,EAAE;QAAC;IAClI;IACA,IAAI,CAACb,MAAM,CAACQ,aAAa,OAAO;QAAEG,OAAO,CAACH;IAAW;IACrD,IAAIA,eAAe,OAAO;QACxB,IAAMU,MAAMd,gBAAgB,IAAI,CAACe,SAAS,EAAEjB,QAAQO;QACpD,OAAOS,MAAM;YAAEE,MAAMF,IAAIE,IAAI;QAAC,IAAI;IACpC;IACA,IAAIZ,eAAe,UAAU;QAC3B,IAAMa,SAASjB,gBAAgB,IAAI,CAACe,SAAS,EAAEhB,WAAWM;QAC1D,OAAOY,SAAS;YAAED,MAAMC,OAAOD,IAAI;QAAC,IAAI;IAC1C;IACA,OAAO;QAAEE,UAAUd,WAAWe,WAAW;IAAG;AAC9C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function isLTSFn(now) {
|
|
3
|
+
return function isLTS(item) {
|
|
4
|
+
return item.lts && now >= item.start && now <= item.end;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["isLTSFn.js"],"sourcesContent":["module.exports = function isLTSFn(now) {\n return function isLTS(item) {\n return item.lts && now >= item.start && now <= item.end;\n };\n};\n"],"names":["module","exports","isLTSFn","now","isLTS","item","lts","start","end"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,QAAQC,GAAG;IACnC,OAAO,SAASC,MAAMC,IAAI;QACxB,OAAOA,KAAKC,GAAG,IAAIH,OAAOE,KAAKE,KAAK,IAAIJ,OAAOE,KAAKG,GAAG;IACzD;AACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function isLatestFn(now) {
|
|
3
|
+
return function isLatest(item) {
|
|
4
|
+
return !item.lts && now >= item.start && now <= item.end;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["isLatestFn.js"],"sourcesContent":["module.exports = function isLatestFn(now) {\n return function isLatest(item) {\n return !item.lts && now >= item.start && now <= item.end;\n };\n};\n"],"names":["module","exports","isLatestFn","now","isLatest","item","lts","start","end"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,WAAWC,GAAG;IACtC,OAAO,SAASC,SAASC,IAAI;QAC3B,OAAO,CAACA,KAAKC,GAAG,IAAIH,OAAOE,KAAKE,KAAK,IAAIJ,OAAOE,KAAKG,GAAG;IAC1D;AACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = function schedulesForEach(schedules, filter, fn) {
|
|
3
|
+
for(var index = 0; index < schedules.length; index++){
|
|
4
|
+
var schedule = schedules[index];
|
|
5
|
+
!filter(schedule) || fn(schedule);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["schedulesForEach.js"],"sourcesContent":["module.exports = function schedulesForEach(schedules, filter, fn) {\n for (let index = 0; index < schedules.length; index++) {\n const schedule = schedules[index];\n !filter(schedule) || fn(schedule);\n }\n};\n"],"names":["module","exports","schedulesForEach","schedules","filter","fn","index","length","schedule"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,iBAAiBC,SAAS,EAAEC,MAAM,EAAEC,EAAE;IAC9D,IAAK,IAAIC,QAAQ,GAAGA,QAAQH,UAAUI,MAAM,EAAED,QAAS;QACrD,IAAME,WAAWL,SAAS,CAACG,MAAM;QACjC,CAACF,OAAOI,aAAaH,GAAGG;IAC1B;AACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var schedulesForEach = require('./schedulesForEach');
|
|
3
|
+
module.exports = function schedulesLatest(schedules, filter) {
|
|
4
|
+
var latest = null;
|
|
5
|
+
schedulesForEach(schedules, filter, function(schedule) {
|
|
6
|
+
if (!latest || latest.start < schedule.start) latest = schedule;
|
|
7
|
+
});
|
|
8
|
+
return latest;
|
|
9
|
+
};
|
|
10
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["schedulesLatest.js"],"sourcesContent":["const schedulesForEach = require('./schedulesForEach');\n\nmodule.exports = function schedulesLatest(schedules, filter) {\n let latest = null;\n schedulesForEach(schedules, filter, (schedule) => {\n if (!latest || latest.start < schedule.start) latest = schedule;\n });\n return latest;\n};\n"],"names":["schedulesForEach","require","module","exports","schedulesLatest","schedules","filter","latest","schedule","start"],"mappings":";AAAA,IAAMA,mBAAmBC,QAAQ;AAEjCC,OAAOC,OAAO,GAAG,SAASC,gBAAgBC,SAAS,EAAEC,MAAM;IACzD,IAAIC,SAAS;IACbP,iBAAiBK,WAAWC,QAAQ,SAACE;QACnC,IAAI,CAACD,UAAUA,OAAOE,KAAK,GAAGD,SAASC,KAAK,EAAEF,SAASC;IACzD;IACA,OAAOD;AACT"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 _fetchjsoncache = /*#__PURE__*/ _interop_require_default(require("fetch-json-cache"));
|
|
13
|
+
var _constants = /*#__PURE__*/ _interop_require_default(require("../constants"));
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
var _default = function() {
|
|
20
|
+
var cacheJSON = function cacheJSON(callback) {
|
|
21
|
+
cache.get(_constants.default.DISTS_URL, {
|
|
22
|
+
force: true
|
|
23
|
+
}, function(err) {
|
|
24
|
+
err ? callback(err) : cache.get(_constants.default.SCHEDULES_URL, {
|
|
25
|
+
force: true
|
|
26
|
+
}, callback);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
var cache = new _fetchjsoncache.default(_constants.default.CACHE_DIRECTORY);
|
|
30
|
+
cacheJSON(function(err) {
|
|
31
|
+
if (err) {
|
|
32
|
+
console.log("Failed to cache dists and schedules. Error: ".concat(err.message));
|
|
33
|
+
return (0, _exit.default)(err.code || -1);
|
|
34
|
+
}
|
|
35
|
+
(0, _exit.default)(0);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["cache.js"],"sourcesContent":["import exit from 'exit';\nimport Cache from 'fetch-json-cache';\nimport constants from '../constants';\n\nexport default () => {\n const cache = new Cache(constants.CACHE_DIRECTORY);\n\n function cacheJSON(callback) {\n cache.get(constants.DISTS_URL, { force: true }, (err) => {\n err ? callback(err) : cache.get(constants.SCHEDULES_URL, { force: true }, callback);\n });\n }\n\n cacheJSON((err) => {\n if (err) {\n console.log(`Failed to cache dists and schedules. Error: ${err.message}`);\n return exit(err.code || -1);\n }\n exit(0);\n });\n};\n"],"names":["cacheJSON","callback","cache","get","constants","DISTS_URL","force","err","SCHEDULES_URL","Cache","CACHE_DIRECTORY","console","log","message","exit","code"],"mappings":";;;;+BAIA;;;eAAA;;;2DAJiB;qEACC;gEACI;;;;;;IAEtB,WAAe;QAGJA,YAAT,SAASA,UAAUC,QAAQ;QACzBC,MAAMC,GAAG,CAACC,kBAAS,CAACC,SAAS,EAAE;YAAEC,OAAO;QAAK,GAAG,SAACC;YAC/CA,MAAMN,SAASM,OAAOL,MAAMC,GAAG,CAACC,kBAAS,CAACI,aAAa,EAAE;gBAAEF,OAAO;YAAK,GAAGL;QAC5E;IACF;IANA,IAAMC,QAAQ,IAAIO,uBAAK,CAACL,kBAAS,CAACM,eAAe;IAQjDV,UAAU,SAACO;QACT,IAAIA,KAAK;YACPI,QAAQC,GAAG,CAAC,AAAC,+CAA0D,OAAZL,IAAIM,OAAO;YACtE,OAAOC,IAAAA,aAAI,EAACP,IAAIQ,IAAI,IAAI,CAAC;QAC3B;QACAD,IAAAA,aAAI,EAAC;IACP;AACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export default class NodeVersions {
|
|
2
|
+
static load(options: any, callback: any): Promise<any>;
|
|
3
|
+
static loadSync(options: any): NodeVersions;
|
|
4
|
+
constructor(versions: any, schedule: any);
|
|
5
|
+
schedules: {
|
|
6
|
+
name: any;
|
|
7
|
+
semver: any;
|
|
8
|
+
raw: any;
|
|
9
|
+
}[];
|
|
10
|
+
versions: {
|
|
11
|
+
version: any;
|
|
12
|
+
name: string;
|
|
13
|
+
semver: string;
|
|
14
|
+
major: number;
|
|
15
|
+
minor: number;
|
|
16
|
+
patch: number;
|
|
17
|
+
lts: any;
|
|
18
|
+
date: Date;
|
|
19
|
+
raw: any;
|
|
20
|
+
}[];
|
|
21
|
+
resolve(expression: any, options: any): any;
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
declare function _exports(expression: any, now: any): {
|
|
2
|
+
major: number;
|
|
3
|
+
minor?: undefined;
|
|
4
|
+
patch?: undefined;
|
|
5
|
+
name?: undefined;
|
|
6
|
+
codename?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
major: number;
|
|
9
|
+
minor: number;
|
|
10
|
+
patch?: undefined;
|
|
11
|
+
name?: undefined;
|
|
12
|
+
codename?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
major: number;
|
|
15
|
+
minor: number;
|
|
16
|
+
patch: number;
|
|
17
|
+
name?: undefined;
|
|
18
|
+
codename?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
name: any;
|
|
21
|
+
major?: undefined;
|
|
22
|
+
minor?: undefined;
|
|
23
|
+
patch?: undefined;
|
|
24
|
+
codename?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
codename: any;
|
|
27
|
+
major?: undefined;
|
|
28
|
+
minor?: undefined;
|
|
29
|
+
patch?: undefined;
|
|
30
|
+
name?: undefined;
|
|
31
|
+
};
|
|
32
|
+
export = _exports;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-semvers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Utilities for managing versions of node including looking up codenames",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -17,46 +17,49 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Kevin Malakoff <kmalakoff@gmail.com> (https://github.com/kmalakoff)",
|
|
20
|
-
"main": "
|
|
20
|
+
"main": "dist/cjs/index.js",
|
|
21
|
+
"types": "dist/types/index.d.ts",
|
|
21
22
|
"bin": {
|
|
22
|
-
"nsv": "./bin/
|
|
23
|
+
"nsv": "./bin/cli.js"
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
25
|
-
"
|
|
26
|
-
"bin"
|
|
26
|
+
"dist",
|
|
27
|
+
"bin",
|
|
28
|
+
"scripts"
|
|
27
29
|
],
|
|
28
30
|
"scripts": {
|
|
29
|
-
"build": "",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"test": "
|
|
35
|
-
"
|
|
31
|
+
"build": "tsds build",
|
|
32
|
+
"deploy": "tsds deploy",
|
|
33
|
+
"format": "biome check --write --unsafe src/ test/",
|
|
34
|
+
"postinstall": "node scripts/cache.js",
|
|
35
|
+
"test": "tsds test:node --timeout=10000",
|
|
36
|
+
"test:engines": "nvu engines npm test",
|
|
37
|
+
"version": "tsds version"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
40
|
"exit": "^0.1.2",
|
|
39
|
-
"fetch-json-cache": "^0.
|
|
41
|
+
"fetch-json-cache": "^1.0.0",
|
|
40
42
|
"getopts-compat": "^2.2.5",
|
|
41
43
|
"isarray": "^2.0.5",
|
|
42
44
|
"semver": "^5.7.1"
|
|
43
45
|
},
|
|
44
46
|
"devDependencies": {
|
|
45
|
-
"@
|
|
47
|
+
"@biomejs/biome": "^1.9.4",
|
|
48
|
+
"@types/mocha": "^10.0.10",
|
|
49
|
+
"@types/node": "^22.10.1",
|
|
46
50
|
"cr": "^0.1.0",
|
|
47
|
-
"cross-spawn-cb": "^0.
|
|
48
|
-
"depcheck": "^1.4.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"eslint-config-standard": "^17.0.0",
|
|
52
|
-
"eslint-plugin-import": "^2.26.0",
|
|
53
|
-
"eslint-plugin-n": "^15.2.4",
|
|
54
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
55
|
-
"mocha-compat": "^3.5.5",
|
|
56
|
-
"prettier": "^2.7.1",
|
|
57
|
-
"rimraf": "^2.7.1"
|
|
51
|
+
"cross-spawn-cb": "^1.0.0",
|
|
52
|
+
"depcheck": "^1.4.7",
|
|
53
|
+
"rimraf2": "^2.7.1",
|
|
54
|
+
"ts-dev-stack": "^0.16.2"
|
|
58
55
|
},
|
|
59
56
|
"engines": {
|
|
60
57
|
"node": ">=0.8"
|
|
58
|
+
},
|
|
59
|
+
"tsds": {
|
|
60
|
+
"source": "src/index.mjs",
|
|
61
|
+
"targets": [
|
|
62
|
+
"cjs"
|
|
63
|
+
]
|
|
61
64
|
}
|
|
62
65
|
}
|
package/scripts/cache.js
ADDED
package/bin/cache.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var Cache = require('fetch-json-cache');
|
|
4
|
-
var exit = require('exit');
|
|
5
|
-
var constants = require('../lib/constants');
|
|
6
|
-
|
|
7
|
-
var cache = new Cache(constants.CACHE_DIRECTORY);
|
|
8
|
-
|
|
9
|
-
function cacheJSON(callback) {
|
|
10
|
-
cache.get(constants.DISTS_URL, { force: true }, function (err) {
|
|
11
|
-
err ? callback(err) : cache.get(constants.SCHEDULES_URL, { force: true }, callback);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
cacheJSON(function (err) {
|
|
16
|
-
if (err) {
|
|
17
|
-
console.log('Failed to cache dists and schedules. Error: ' + err.message);
|
|
18
|
-
return exit(err.code || -1);
|
|
19
|
-
}
|
|
20
|
-
exit(0);
|
|
21
|
-
});
|
package/bin/node-semvers.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
var getopts = require('getopts-compat');
|
|
4
|
-
var exit = require('exit');
|
|
5
|
-
var isArray = require('isarray');
|
|
6
|
-
var NodeVersions = require('..');
|
|
7
|
-
var isNaN = require('../lib/isNaN');
|
|
8
|
-
|
|
9
|
-
(function () {
|
|
10
|
-
var options = getopts(process.argv.slice(3), {
|
|
11
|
-
alias: { path: 'p', range: 'r', now: 'n' },
|
|
12
|
-
stopEarly: true,
|
|
13
|
-
});
|
|
14
|
-
if (typeof options.now !== 'undefined') options.now = new Date(isNaN(+options.now) ? Date.parse(options.now) : +options.now);
|
|
15
|
-
|
|
16
|
-
// define.option('-p, --path [path]', 'path within version including raw for unprocessed version', 'version');
|
|
17
|
-
// define.option('-r, --range [range]', 'range type of major, minor, or patch with filters of lts, even, odd for version string expressions', 'patch');
|
|
18
|
-
// define.option('-n, --now [date]', 'use a specific time as a Date.parse');
|
|
19
|
-
|
|
20
|
-
if (options.help) {
|
|
21
|
-
console.log('');
|
|
22
|
-
console.log('Example call:');
|
|
23
|
-
console.log(' $ nv [version string]');
|
|
24
|
-
console.log('');
|
|
25
|
-
console.log('Version Strings:');
|
|
26
|
-
console.log('Any command that calls for a version can be provided any of the');
|
|
27
|
-
console.log('following "version-ish" identifies:');
|
|
28
|
-
console.log('');
|
|
29
|
-
console.log('- x.y.z A specific SemVer tuple');
|
|
30
|
-
console.log('- x.y Major and minor version number');
|
|
31
|
-
console.log('- x Just a major version number');
|
|
32
|
-
console.log('- lts The most recent LTS (long-term support) node version');
|
|
33
|
-
console.log('- lts/<name> The latest in a named LTS set. (argon, boron, etc.)');
|
|
34
|
-
console.log('- lts/* Same as just "lts"');
|
|
35
|
-
console.log('- latest The most recent (non-LTS) version');
|
|
36
|
-
console.log('- stable Backwards-compatible alias for "lts"');
|
|
37
|
-
console.log('- [expression] Engine and semver module expression like "10.1.x || >=12.0.0"');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var args = process.argv.slice(2, 3).concat(options._);
|
|
42
|
-
if (args.length < 1) {
|
|
43
|
-
console.log('Missing version string. Example usage: nv [version string]. Use nv --help for information on version strings');
|
|
44
|
-
return exit(-1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function stringify(value) {
|
|
48
|
-
return typeof value === 'string' ? value : JSON.stringify(value);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
NodeVersions.load(options, function (err, semvers) {
|
|
52
|
-
if (err) {
|
|
53
|
-
console.log(err.message);
|
|
54
|
-
return exit(err.code || -1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var version = semvers.resolve(args[0], options);
|
|
58
|
-
if (!version || (isArray(version) && !version.length)) {
|
|
59
|
-
console.log('Unrecognized: ' + args[0]);
|
|
60
|
-
return exit(-1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
console.log('versions:');
|
|
64
|
-
if (isArray(version)) {
|
|
65
|
-
for (var index = 0; index < version.length; index++) console.log(stringify(version[index]));
|
|
66
|
-
} else console.log(stringify(version));
|
|
67
|
-
exit(0);
|
|
68
|
-
});
|
|
69
|
-
})();
|
package/lib/constants.js
DELETED
package/lib/index.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
var semver = require('semver');
|
|
2
|
-
var Cache = require('fetch-json-cache');
|
|
3
|
-
|
|
4
|
-
var constants = require('./constants');
|
|
5
|
-
var keyFunctions = require('./keyFunctions');
|
|
6
|
-
var lineFunctions = require('./lineFunctions');
|
|
7
|
-
var normalizeSchedule = require('./normalizeSchedule');
|
|
8
|
-
var normalizeVersion = require('./normalizeVersion');
|
|
9
|
-
var match = require('./match');
|
|
10
|
-
var parseExpression = require('./parseExpression');
|
|
11
|
-
|
|
12
|
-
function NodeVersions(versions, schedule) {
|
|
13
|
-
if (!versions) throw new Error('Missing option: versions');
|
|
14
|
-
if (!schedule) throw new Error('Missing option: schedule');
|
|
15
|
-
|
|
16
|
-
this.schedules = [];
|
|
17
|
-
for (var name in schedule) this.schedules.push(normalizeSchedule(name, schedule[name]));
|
|
18
|
-
this.schedules = this.schedules.sort(function (a, b) {
|
|
19
|
-
return semver.gt(semver.coerce(a.semver), semver.coerce(b.semver)) ? 1 : -1;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
this.versions = [];
|
|
23
|
-
for (var index = 0; index < versions.length; index++) this.versions.push(normalizeVersion(versions[index], this.schedules));
|
|
24
|
-
this.versions = this.versions.sort(function (a, b) {
|
|
25
|
-
return semver.gt(a.semver, b.semver) ? -1 : 1;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
NodeVersions.load = function load(options, callback) {
|
|
30
|
-
if (typeof options === 'function') {
|
|
31
|
-
callback = options;
|
|
32
|
-
options = null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof callback === 'function') {
|
|
36
|
-
options = options || {};
|
|
37
|
-
|
|
38
|
-
var cache = new Cache(options.cacheDirectory || constants.CACHE_DIRECTORY);
|
|
39
|
-
cache.get(constants.DISTS_URL, function (err, versions) {
|
|
40
|
-
if (err) return callback(err);
|
|
41
|
-
|
|
42
|
-
cache.get(constants.SCHEDULES_URL, function (err, schedule) {
|
|
43
|
-
err ? callback(err) : callback(null, new NodeVersions(versions, schedule));
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
return new Promise(function (resolve, reject) {
|
|
48
|
-
load(options, function loadCallback(err, NodeVersions) {
|
|
49
|
-
err ? reject(err) : resolve(NodeVersions);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
NodeVersions.loadSync = function loadSync(options) {
|
|
56
|
-
options = options || {};
|
|
57
|
-
var cache = new Cache(options.cacheDirectory || constants.CACHE_DIRECTORY);
|
|
58
|
-
var versions = cache.getSync(constants.DISTS_URL);
|
|
59
|
-
var schedule = cache.getSync(constants.SCHEDULES_URL);
|
|
60
|
-
if (!versions || !schedule) return null;
|
|
61
|
-
return new NodeVersions(versions, schedule);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
NodeVersions.prototype.resolve = function resolve(expression, options) {
|
|
65
|
-
options = options || {};
|
|
66
|
-
var path = options.path || 'version';
|
|
67
|
-
|
|
68
|
-
// normalize
|
|
69
|
-
if (typeof expression === 'number') expression = '' + expression;
|
|
70
|
-
if (typeof expression !== 'string') return null;
|
|
71
|
-
expression = expression.trim();
|
|
72
|
-
|
|
73
|
-
// single result, try a match
|
|
74
|
-
var query = parseExpression.call(this, expression, options.now || new Date());
|
|
75
|
-
if (query) {
|
|
76
|
-
var version = null;
|
|
77
|
-
for (var index = 0; index < this.versions.length; index++) {
|
|
78
|
-
var test = this.versions[index];
|
|
79
|
-
if (options.now && options.now < test.date) continue;
|
|
80
|
-
if (!match(test, query)) continue;
|
|
81
|
-
version = test;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
if (version) return version[path];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// filtered expression
|
|
88
|
-
var range = options.range || '';
|
|
89
|
-
var filters = { lts: !!~range.indexOf('lts') };
|
|
90
|
-
filters.key = ~range.indexOf('major') ? keyFunctions.major : ~range.indexOf('minor') ? keyFunctions.minor : undefined;
|
|
91
|
-
filters.line = ~range.indexOf('even') ? lineFunctions.even : ~range.indexOf('odd') ? lineFunctions.odd : undefined;
|
|
92
|
-
|
|
93
|
-
var results = [];
|
|
94
|
-
var founds = {};
|
|
95
|
-
// eslint-disable-next-line no-redeclare
|
|
96
|
-
for (var index = 0; index < this.versions.length; index++) {
|
|
97
|
-
// eslint-disable-next-line no-redeclare
|
|
98
|
-
var test = this.versions[index];
|
|
99
|
-
if (options.now && options.now < test.date) continue;
|
|
100
|
-
if (filters.lts && !test.lts) continue;
|
|
101
|
-
if (filters.line && !filters.line(test)) continue;
|
|
102
|
-
if (!semver.satisfies(test.semver, expression)) continue;
|
|
103
|
-
if (filters.key) {
|
|
104
|
-
if (founds[filters.key(test)]) continue;
|
|
105
|
-
founds[filters.key(test)] = true;
|
|
106
|
-
}
|
|
107
|
-
results.unshift(test[path]);
|
|
108
|
-
}
|
|
109
|
-
return results;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
module.exports = NodeVersions;
|
package/lib/isNaN.js
DELETED
package/lib/keyFunctions.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
module.exports.major = function major(version) {
|
|
2
|
-
return version.major === 0 ? version.major + '.' + version.minor : version.major;
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
module.exports.minor = function minor(version) {
|
|
6
|
-
return version.major === 0 ? version.major + '.' + version.minor + '.' + version.patch : version.major + '.' + version.minor;
|
|
7
|
-
};
|
package/lib/lineFunctions.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
module.exports.even = function even(version) {
|
|
2
|
-
var major = version.major === 0 ? version.minor : version.major;
|
|
3
|
-
return major % 2 === 0;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
module.exports.odd = function odd(version) {
|
|
7
|
-
var major = version.major === 0 ? version.minor : version.major;
|
|
8
|
-
return major % 2 === 1;
|
|
9
|
-
};
|
package/lib/match.js
DELETED
package/lib/normalizeSchedule.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = function normalizeSchedule(name, raw) {
|
|
2
|
-
var schedule = {
|
|
3
|
-
name: name,
|
|
4
|
-
semver: name.slice(1),
|
|
5
|
-
raw: raw,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
schedule.start = new Date(raw.start);
|
|
9
|
-
schedule.end = new Date(raw.end);
|
|
10
|
-
if (raw.codename) schedule.codename = raw.codename.toLowerCase();
|
|
11
|
-
if (raw.lts) schedule.lts = new Date(raw.lts);
|
|
12
|
-
if (raw.maintenance) schedule.maintenance = new Date(raw.maintenance);
|
|
13
|
-
|
|
14
|
-
return schedule;
|
|
15
|
-
};
|
package/lib/normalizeVersion.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module.exports = function normalizeVersion(raw, schedules) {
|
|
2
|
-
var parts = raw.version.substr(1).split('.');
|
|
3
|
-
|
|
4
|
-
var version = {
|
|
5
|
-
version: raw.version,
|
|
6
|
-
name: parts[0] !== 0 ? 'v' + +parts[0] : 'v' + +parts[0] + '.' + +parts[1],
|
|
7
|
-
semver: parts[0] + '.' + +parts[1] + '.' + +parts[2],
|
|
8
|
-
major: +parts[0],
|
|
9
|
-
minor: +parts[1],
|
|
10
|
-
patch: +parts[2],
|
|
11
|
-
lts: raw.lts,
|
|
12
|
-
date: new Date(raw.date),
|
|
13
|
-
raw: raw,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
var schedule = null;
|
|
17
|
-
for (var index = 0; index < schedules.length; index++) {
|
|
18
|
-
var test = schedules[index];
|
|
19
|
-
if (test.name === version.name) {
|
|
20
|
-
schedule = test;
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (schedule && raw.lts) version.codename = schedule.codename;
|
|
25
|
-
return version;
|
|
26
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
var isNaN = require('../isNaN');
|
|
2
|
-
var isLTSFn = require('./isLTSFn');
|
|
3
|
-
var isLatestFn = require('./isLatestFn');
|
|
4
|
-
var schedulesLatest = require('./schedulesLatest');
|
|
5
|
-
|
|
6
|
-
module.exports = function parseExpression(expression, now) {
|
|
7
|
-
if (expression[0] === 'v' && !isNaN(+expression.substr(1, 1))) expression = expression.substr(1);
|
|
8
|
-
if (expression.substr(0, 4) === 'lts/') expression = expression.substr(4) === '*' ? 'lts' : expression.substr(4);
|
|
9
|
-
if (expression === 'stable') expression = 'lts';
|
|
10
|
-
|
|
11
|
-
if (typeof expression === 'number') return { major: expression };
|
|
12
|
-
if (~expression.indexOf('.')) {
|
|
13
|
-
var parts = expression.split('.');
|
|
14
|
-
if (parts.length === 1) return isNaN(+parts[0]) ? null : { major: +parts[0] };
|
|
15
|
-
else if (parts.length === 2) return isNaN(+parts[0]) && isNaN(+parts[1]) ? null : { major: +parts[0], minor: +parts[1] };
|
|
16
|
-
else return isNaN(+parts[0]) && isNaN(+parts[1]) && isNaN(+parts[2]) ? null : { major: +parts[0], minor: +parts[1], patch: +parts[2] };
|
|
17
|
-
}
|
|
18
|
-
if (!isNaN(+expression)) return { major: +expression };
|
|
19
|
-
if (expression === 'lts') {
|
|
20
|
-
var lts = schedulesLatest(this.schedules, isLTSFn(now));
|
|
21
|
-
return lts ? { name: lts.name } : null;
|
|
22
|
-
}
|
|
23
|
-
if (expression === 'latest') {
|
|
24
|
-
var latest = schedulesLatest(this.schedules, isLatestFn(now));
|
|
25
|
-
return latest ? { name: latest.name } : null;
|
|
26
|
-
}
|
|
27
|
-
return { codename: expression.toLowerCase() };
|
|
28
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var schedulesForEach = require('./schedulesForEach');
|
|
2
|
-
|
|
3
|
-
module.exports = function schedulesLatest(schedules, filter) {
|
|
4
|
-
var latest = null;
|
|
5
|
-
schedulesForEach(schedules, filter, function (schedule) {
|
|
6
|
-
if (!latest || latest.start < schedule.start) latest = schedule;
|
|
7
|
-
});
|
|
8
|
-
return latest;
|
|
9
|
-
};
|