@kelceyp/caw 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/caw.js +2431 -191
- package/package.json +5 -2
- package/scripts/postinstall.js +1 -1
package/dist/caw.js
CHANGED
|
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
8
13
|
var __toESM = (mod, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod != null && typeof mod === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
9
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
10
22
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
11
23
|
for (let key of __getOwnPropNames(mod))
|
|
12
24
|
if (!__hasOwnProp.call(to, key))
|
|
13
25
|
__defProp(to, key, {
|
|
14
|
-
get: (
|
|
26
|
+
get: __accessProp.bind(mod, key),
|
|
15
27
|
enumerable: true
|
|
16
28
|
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod, to);
|
|
17
31
|
return to;
|
|
18
32
|
};
|
|
19
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
|
+
var __returnValue = (v) => v;
|
|
35
|
+
function __exportSetter(name, newValue) {
|
|
36
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
37
|
+
}
|
|
20
38
|
var __export = (target, all) => {
|
|
21
39
|
for (var name in all)
|
|
22
40
|
__defProp(target, name, {
|
|
23
41
|
get: all[name],
|
|
24
42
|
enumerable: true,
|
|
25
43
|
configurable: true,
|
|
26
|
-
set: (
|
|
44
|
+
set: __exportSetter.bind(all, name)
|
|
27
45
|
});
|
|
28
46
|
};
|
|
29
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -1154,7 +1172,7 @@ var init_hook_engine = __esm(() => {
|
|
|
1154
1172
|
import { AsyncResource as AsyncResource2 } from "node:async_hooks";
|
|
1155
1173
|
function useState(defaultValue) {
|
|
1156
1174
|
return withPointer((pointer) => {
|
|
1157
|
-
const setState = AsyncResource2.bind(function
|
|
1175
|
+
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
1158
1176
|
if (pointer.get() !== newValue) {
|
|
1159
1177
|
pointer.set(newValue);
|
|
1160
1178
|
handleChange();
|
|
@@ -7699,189 +7717,2032 @@ var init_executor = __esm(() => {
|
|
|
7699
7717
|
init_CLIError();
|
|
7700
7718
|
});
|
|
7701
7719
|
|
|
7702
|
-
// node_modules
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7720
|
+
// node_modules/semver/internal/constants.js
|
|
7721
|
+
var require_constants = __commonJS((exports, module) => {
|
|
7722
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
7723
|
+
var MAX_LENGTH = 256;
|
|
7724
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
7725
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
7726
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
7727
|
+
var RELEASE_TYPES = [
|
|
7728
|
+
"major",
|
|
7729
|
+
"premajor",
|
|
7730
|
+
"minor",
|
|
7731
|
+
"preminor",
|
|
7732
|
+
"patch",
|
|
7733
|
+
"prepatch",
|
|
7734
|
+
"prerelease"
|
|
7735
|
+
];
|
|
7736
|
+
module.exports = {
|
|
7737
|
+
MAX_LENGTH,
|
|
7738
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
7739
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
7740
|
+
MAX_SAFE_INTEGER,
|
|
7741
|
+
RELEASE_TYPES,
|
|
7742
|
+
SEMVER_SPEC_VERSION,
|
|
7743
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
7744
|
+
FLAG_LOOSE: 2
|
|
7745
|
+
};
|
|
7746
|
+
});
|
|
7706
7747
|
|
|
7707
|
-
// node_modules
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7748
|
+
// node_modules/semver/internal/debug.js
|
|
7749
|
+
var require_debug = __commonJS((exports, module) => {
|
|
7750
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
7751
|
+
module.exports = debug;
|
|
7752
|
+
});
|
|
7753
|
+
|
|
7754
|
+
// node_modules/semver/internal/re.js
|
|
7755
|
+
var require_re = __commonJS((exports, module) => {
|
|
7756
|
+
var {
|
|
7757
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
7758
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
7759
|
+
MAX_LENGTH
|
|
7760
|
+
} = require_constants();
|
|
7761
|
+
var debug = require_debug();
|
|
7762
|
+
exports = module.exports = {};
|
|
7763
|
+
var re = exports.re = [];
|
|
7764
|
+
var safeRe = exports.safeRe = [];
|
|
7765
|
+
var src = exports.src = [];
|
|
7766
|
+
var safeSrc = exports.safeSrc = [];
|
|
7767
|
+
var t = exports.t = {};
|
|
7768
|
+
var R = 0;
|
|
7769
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
7770
|
+
var safeRegexReplacements = [
|
|
7771
|
+
["\\s", 1],
|
|
7772
|
+
["\\d", MAX_LENGTH],
|
|
7773
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
7774
|
+
];
|
|
7775
|
+
var makeSafeRegex = (value) => {
|
|
7776
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
7777
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
7778
|
+
}
|
|
7779
|
+
return value;
|
|
7780
|
+
};
|
|
7781
|
+
var createToken = (name, value, isGlobal) => {
|
|
7782
|
+
const safe = makeSafeRegex(value);
|
|
7783
|
+
const index = R++;
|
|
7784
|
+
debug(name, index, value);
|
|
7785
|
+
t[name] = index;
|
|
7786
|
+
src[index] = value;
|
|
7787
|
+
safeSrc[index] = safe;
|
|
7788
|
+
re[index] = new RegExp(value, isGlobal ? "g" : undefined);
|
|
7789
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : undefined);
|
|
7790
|
+
};
|
|
7791
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
7792
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
7793
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
7794
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
|
|
7795
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
7796
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
7797
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
7798
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
7799
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
7800
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
7801
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
7802
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
7803
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
7804
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
7805
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
7806
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
7807
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
7808
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
7809
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
7810
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
|
|
7811
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
7812
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
7813
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])" + "(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
7814
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
7815
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?` + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`);
|
|
7816
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
7817
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
7818
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
7819
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
7820
|
+
exports.tildeTrimReplace = "$1~";
|
|
7821
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
7822
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
7823
|
+
createToken("LONECARET", "(?:\\^)");
|
|
7824
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
7825
|
+
exports.caretTrimReplace = "$1^";
|
|
7826
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
7827
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
7828
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
7829
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
7830
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
7831
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
7832
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
|
|
7833
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`);
|
|
7834
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
7835
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
7836
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
7837
|
+
});
|
|
7838
|
+
|
|
7839
|
+
// node_modules/semver/internal/parse-options.js
|
|
7840
|
+
var require_parse_options = __commonJS((exports, module) => {
|
|
7841
|
+
var looseOption = Object.freeze({ loose: true });
|
|
7842
|
+
var emptyOpts = Object.freeze({});
|
|
7843
|
+
var parseOptions = (options) => {
|
|
7844
|
+
if (!options) {
|
|
7845
|
+
return emptyOpts;
|
|
7846
|
+
}
|
|
7847
|
+
if (typeof options !== "object") {
|
|
7848
|
+
return looseOption;
|
|
7849
|
+
}
|
|
7850
|
+
return options;
|
|
7851
|
+
};
|
|
7852
|
+
module.exports = parseOptions;
|
|
7853
|
+
});
|
|
7854
|
+
|
|
7855
|
+
// node_modules/semver/internal/identifiers.js
|
|
7856
|
+
var require_identifiers = __commonJS((exports, module) => {
|
|
7857
|
+
var numeric = /^[0-9]+$/;
|
|
7858
|
+
var compareIdentifiers = (a, b) => {
|
|
7859
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
7860
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
7861
|
+
}
|
|
7862
|
+
const anum = numeric.test(a);
|
|
7863
|
+
const bnum = numeric.test(b);
|
|
7864
|
+
if (anum && bnum) {
|
|
7865
|
+
a = +a;
|
|
7866
|
+
b = +b;
|
|
7867
|
+
}
|
|
7868
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
7869
|
+
};
|
|
7870
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
7871
|
+
module.exports = {
|
|
7872
|
+
compareIdentifiers,
|
|
7873
|
+
rcompareIdentifiers
|
|
7874
|
+
};
|
|
7875
|
+
});
|
|
7876
|
+
|
|
7877
|
+
// node_modules/semver/classes/semver.js
|
|
7878
|
+
var require_semver = __commonJS((exports, module) => {
|
|
7879
|
+
var debug = require_debug();
|
|
7880
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
7881
|
+
var { safeRe: re, t } = require_re();
|
|
7882
|
+
var parseOptions = require_parse_options();
|
|
7883
|
+
var { compareIdentifiers } = require_identifiers();
|
|
7884
|
+
var isPrereleaseIdentifier = (prerelease, identifier) => {
|
|
7885
|
+
const identifiers = identifier.split(".");
|
|
7886
|
+
if (identifiers.length > prerelease.length) {
|
|
7887
|
+
return false;
|
|
7888
|
+
}
|
|
7889
|
+
for (let i = 0;i < identifiers.length; i++) {
|
|
7890
|
+
if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
|
|
7891
|
+
return false;
|
|
7892
|
+
}
|
|
7893
|
+
}
|
|
7894
|
+
return true;
|
|
7895
|
+
};
|
|
7896
|
+
|
|
7897
|
+
class SemVer {
|
|
7898
|
+
constructor(version, options) {
|
|
7899
|
+
options = parseOptions(options);
|
|
7900
|
+
if (version instanceof SemVer) {
|
|
7901
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
7902
|
+
return version;
|
|
7903
|
+
} else {
|
|
7904
|
+
version = version.version;
|
|
7721
7905
|
}
|
|
7906
|
+
} else if (typeof version !== "string") {
|
|
7907
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
7908
|
+
}
|
|
7909
|
+
if (version.length > MAX_LENGTH) {
|
|
7910
|
+
throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
|
|
7911
|
+
}
|
|
7912
|
+
debug("SemVer", version, options);
|
|
7913
|
+
this.options = options;
|
|
7914
|
+
this.loose = !!options.loose;
|
|
7915
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
7916
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
7917
|
+
if (!m) {
|
|
7918
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
7919
|
+
}
|
|
7920
|
+
this.raw = version;
|
|
7921
|
+
this.major = +m[1];
|
|
7922
|
+
this.minor = +m[2];
|
|
7923
|
+
this.patch = +m[3];
|
|
7924
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
7925
|
+
throw new TypeError("Invalid major version");
|
|
7926
|
+
}
|
|
7927
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
7928
|
+
throw new TypeError("Invalid minor version");
|
|
7929
|
+
}
|
|
7930
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
7931
|
+
throw new TypeError("Invalid patch version");
|
|
7932
|
+
}
|
|
7933
|
+
if (!m[4]) {
|
|
7934
|
+
this.prerelease = [];
|
|
7935
|
+
} else {
|
|
7936
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
7937
|
+
if (/^[0-9]+$/.test(id)) {
|
|
7938
|
+
const num = +id;
|
|
7939
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
7940
|
+
return num;
|
|
7941
|
+
}
|
|
7942
|
+
}
|
|
7943
|
+
return id;
|
|
7944
|
+
});
|
|
7722
7945
|
}
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7946
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
7947
|
+
this.format();
|
|
7948
|
+
}
|
|
7949
|
+
format() {
|
|
7950
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
7951
|
+
if (this.prerelease.length) {
|
|
7952
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
7728
7953
|
}
|
|
7954
|
+
return this.version;
|
|
7729
7955
|
}
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
if (pathSegments.length === 0) {
|
|
7733
|
-
return {
|
|
7734
|
-
type: "unknown",
|
|
7735
|
-
matchedPath: [],
|
|
7736
|
-
remainingPath: []
|
|
7737
|
-
};
|
|
7956
|
+
toString() {
|
|
7957
|
+
return this.version;
|
|
7738
7958
|
}
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
if (command) {
|
|
7745
|
-
return {
|
|
7746
|
-
type: "command",
|
|
7747
|
-
command,
|
|
7748
|
-
matchedPath: testPath
|
|
7749
|
-
};
|
|
7750
|
-
}
|
|
7751
|
-
const group = this.groups.get(canonicalPath);
|
|
7752
|
-
if (group) {
|
|
7753
|
-
const remaining = pathSegments.slice(i);
|
|
7754
|
-
if (remaining.length === 0) {
|
|
7755
|
-
return {
|
|
7756
|
-
type: "group",
|
|
7757
|
-
group,
|
|
7758
|
-
matchedPath: testPath
|
|
7759
|
-
};
|
|
7959
|
+
compare(other) {
|
|
7960
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
7961
|
+
if (!(other instanceof SemVer)) {
|
|
7962
|
+
if (typeof other === "string" && other === this.version) {
|
|
7963
|
+
return 0;
|
|
7760
7964
|
}
|
|
7965
|
+
other = new SemVer(other, this.options);
|
|
7966
|
+
}
|
|
7967
|
+
if (other.version === this.version) {
|
|
7968
|
+
return 0;
|
|
7761
7969
|
}
|
|
7970
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
7762
7971
|
}
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7972
|
+
compareMain(other) {
|
|
7973
|
+
if (!(other instanceof SemVer)) {
|
|
7974
|
+
other = new SemVer(other, this.options);
|
|
7975
|
+
}
|
|
7976
|
+
if (this.major < other.major) {
|
|
7977
|
+
return -1;
|
|
7978
|
+
}
|
|
7979
|
+
if (this.major > other.major) {
|
|
7980
|
+
return 1;
|
|
7981
|
+
}
|
|
7982
|
+
if (this.minor < other.minor) {
|
|
7983
|
+
return -1;
|
|
7984
|
+
}
|
|
7985
|
+
if (this.minor > other.minor) {
|
|
7986
|
+
return 1;
|
|
7987
|
+
}
|
|
7988
|
+
if (this.patch < other.patch) {
|
|
7989
|
+
return -1;
|
|
7770
7990
|
}
|
|
7991
|
+
if (this.patch > other.patch) {
|
|
7992
|
+
return 1;
|
|
7993
|
+
}
|
|
7994
|
+
return 0;
|
|
7771
7995
|
}
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
items.push(command);
|
|
7996
|
+
comparePre(other) {
|
|
7997
|
+
if (!(other instanceof SemVer)) {
|
|
7998
|
+
other = new SemVer(other, this.options);
|
|
7999
|
+
}
|
|
8000
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
8001
|
+
return -1;
|
|
8002
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
8003
|
+
return 1;
|
|
8004
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
8005
|
+
return 0;
|
|
7783
8006
|
}
|
|
8007
|
+
let i = 0;
|
|
8008
|
+
do {
|
|
8009
|
+
const a = this.prerelease[i];
|
|
8010
|
+
const b = other.prerelease[i];
|
|
8011
|
+
debug("prerelease compare", i, a, b);
|
|
8012
|
+
if (a === undefined && b === undefined) {
|
|
8013
|
+
return 0;
|
|
8014
|
+
} else if (b === undefined) {
|
|
8015
|
+
return 1;
|
|
8016
|
+
} else if (a === undefined) {
|
|
8017
|
+
return -1;
|
|
8018
|
+
} else if (a === b) {
|
|
8019
|
+
continue;
|
|
8020
|
+
} else {
|
|
8021
|
+
return compareIdentifiers(a, b);
|
|
8022
|
+
}
|
|
8023
|
+
} while (++i);
|
|
8024
|
+
}
|
|
8025
|
+
compareBuild(other) {
|
|
8026
|
+
if (!(other instanceof SemVer)) {
|
|
8027
|
+
other = new SemVer(other, this.options);
|
|
8028
|
+
}
|
|
8029
|
+
let i = 0;
|
|
8030
|
+
do {
|
|
8031
|
+
const a = this.build[i];
|
|
8032
|
+
const b = other.build[i];
|
|
8033
|
+
debug("build compare", i, a, b);
|
|
8034
|
+
if (a === undefined && b === undefined) {
|
|
8035
|
+
return 0;
|
|
8036
|
+
} else if (b === undefined) {
|
|
8037
|
+
return 1;
|
|
8038
|
+
} else if (a === undefined) {
|
|
8039
|
+
return -1;
|
|
8040
|
+
} else if (a === b) {
|
|
8041
|
+
continue;
|
|
8042
|
+
} else {
|
|
8043
|
+
return compareIdentifiers(a, b);
|
|
8044
|
+
}
|
|
8045
|
+
} while (++i);
|
|
7784
8046
|
}
|
|
7785
|
-
|
|
7786
|
-
if (
|
|
7787
|
-
|
|
8047
|
+
inc(release, identifier, identifierBase) {
|
|
8048
|
+
if (release.startsWith("pre")) {
|
|
8049
|
+
if (!identifier && identifierBase === false) {
|
|
8050
|
+
throw new Error("invalid increment argument: identifier is empty");
|
|
8051
|
+
}
|
|
8052
|
+
if (identifier) {
|
|
8053
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
8054
|
+
if (!match || match[1] !== identifier) {
|
|
8055
|
+
throw new Error(`invalid identifier: ${identifier}`);
|
|
8056
|
+
}
|
|
8057
|
+
}
|
|
8058
|
+
}
|
|
8059
|
+
switch (release) {
|
|
8060
|
+
case "premajor":
|
|
8061
|
+
this.prerelease.length = 0;
|
|
8062
|
+
this.patch = 0;
|
|
8063
|
+
this.minor = 0;
|
|
8064
|
+
this.major++;
|
|
8065
|
+
this.inc("pre", identifier, identifierBase);
|
|
8066
|
+
break;
|
|
8067
|
+
case "preminor":
|
|
8068
|
+
this.prerelease.length = 0;
|
|
8069
|
+
this.patch = 0;
|
|
8070
|
+
this.minor++;
|
|
8071
|
+
this.inc("pre", identifier, identifierBase);
|
|
8072
|
+
break;
|
|
8073
|
+
case "prepatch":
|
|
8074
|
+
this.prerelease.length = 0;
|
|
8075
|
+
this.inc("patch", identifier, identifierBase);
|
|
8076
|
+
this.inc("pre", identifier, identifierBase);
|
|
8077
|
+
break;
|
|
8078
|
+
case "prerelease":
|
|
8079
|
+
if (this.prerelease.length === 0) {
|
|
8080
|
+
this.inc("patch", identifier, identifierBase);
|
|
8081
|
+
}
|
|
8082
|
+
this.inc("pre", identifier, identifierBase);
|
|
8083
|
+
break;
|
|
8084
|
+
case "release":
|
|
8085
|
+
if (this.prerelease.length === 0) {
|
|
8086
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
8087
|
+
}
|
|
8088
|
+
this.prerelease.length = 0;
|
|
8089
|
+
break;
|
|
8090
|
+
case "major":
|
|
8091
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
8092
|
+
this.major++;
|
|
8093
|
+
}
|
|
8094
|
+
this.minor = 0;
|
|
8095
|
+
this.patch = 0;
|
|
8096
|
+
this.prerelease = [];
|
|
8097
|
+
break;
|
|
8098
|
+
case "minor":
|
|
8099
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
8100
|
+
this.minor++;
|
|
8101
|
+
}
|
|
8102
|
+
this.patch = 0;
|
|
8103
|
+
this.prerelease = [];
|
|
8104
|
+
break;
|
|
8105
|
+
case "patch":
|
|
8106
|
+
if (this.prerelease.length === 0) {
|
|
8107
|
+
this.patch++;
|
|
8108
|
+
}
|
|
8109
|
+
this.prerelease = [];
|
|
8110
|
+
break;
|
|
8111
|
+
case "pre": {
|
|
8112
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
8113
|
+
if (this.prerelease.length === 0) {
|
|
8114
|
+
this.prerelease = [base];
|
|
8115
|
+
} else {
|
|
8116
|
+
let i = this.prerelease.length;
|
|
8117
|
+
while (--i >= 0) {
|
|
8118
|
+
if (typeof this.prerelease[i] === "number") {
|
|
8119
|
+
this.prerelease[i]++;
|
|
8120
|
+
i = -2;
|
|
8121
|
+
}
|
|
8122
|
+
}
|
|
8123
|
+
if (i === -1) {
|
|
8124
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
8125
|
+
throw new Error("invalid increment argument: identifier already exists");
|
|
8126
|
+
}
|
|
8127
|
+
this.prerelease.push(base);
|
|
8128
|
+
}
|
|
8129
|
+
}
|
|
8130
|
+
if (identifier) {
|
|
8131
|
+
let prerelease = [identifier, base];
|
|
8132
|
+
if (identifierBase === false) {
|
|
8133
|
+
prerelease = [identifier];
|
|
8134
|
+
}
|
|
8135
|
+
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
8136
|
+
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
8137
|
+
if (isNaN(prereleaseBase)) {
|
|
8138
|
+
this.prerelease = prerelease;
|
|
8139
|
+
}
|
|
8140
|
+
} else {
|
|
8141
|
+
this.prerelease = prerelease;
|
|
8142
|
+
}
|
|
8143
|
+
}
|
|
8144
|
+
break;
|
|
8145
|
+
}
|
|
8146
|
+
default:
|
|
8147
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
7788
8148
|
}
|
|
8149
|
+
this.raw = this.format();
|
|
8150
|
+
if (this.build.length) {
|
|
8151
|
+
this.raw += `+${this.build.join(".")}`;
|
|
8152
|
+
}
|
|
8153
|
+
return this;
|
|
7789
8154
|
}
|
|
7790
|
-
return items;
|
|
7791
8155
|
}
|
|
7792
|
-
|
|
8156
|
+
module.exports = SemVer;
|
|
8157
|
+
});
|
|
7793
8158
|
|
|
7794
|
-
// node_modules
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
if (!arg) {
|
|
7801
|
-
break;
|
|
8159
|
+
// node_modules/semver/functions/parse.js
|
|
8160
|
+
var require_parse = __commonJS((exports, module) => {
|
|
8161
|
+
var SemVer = require_semver();
|
|
8162
|
+
var parse = (version, options, throwErrors = false) => {
|
|
8163
|
+
if (version instanceof SemVer) {
|
|
8164
|
+
return version;
|
|
7802
8165
|
}
|
|
7803
|
-
|
|
7804
|
-
|
|
8166
|
+
try {
|
|
8167
|
+
return new SemVer(version, options);
|
|
8168
|
+
} catch (er) {
|
|
8169
|
+
if (!throwErrors) {
|
|
8170
|
+
return null;
|
|
8171
|
+
}
|
|
8172
|
+
throw er;
|
|
7805
8173
|
}
|
|
7806
|
-
commandPath.push(arg);
|
|
7807
|
-
}
|
|
7808
|
-
const paramArgv = argv.slice(i);
|
|
7809
|
-
return {
|
|
7810
|
-
commandPath,
|
|
7811
|
-
paramArgv
|
|
7812
8174
|
};
|
|
7813
|
-
|
|
8175
|
+
module.exports = parse;
|
|
8176
|
+
});
|
|
7814
8177
|
|
|
7815
|
-
// node_modules
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
8178
|
+
// node_modules/semver/functions/valid.js
|
|
8179
|
+
var require_valid = __commonJS((exports, module) => {
|
|
8180
|
+
var parse = require_parse();
|
|
8181
|
+
var valid = (version, options) => {
|
|
8182
|
+
const v = parse(version, options);
|
|
8183
|
+
return v ? v.version : null;
|
|
8184
|
+
};
|
|
8185
|
+
module.exports = valid;
|
|
8186
|
+
});
|
|
8187
|
+
|
|
8188
|
+
// node_modules/semver/functions/clean.js
|
|
8189
|
+
var require_clean = __commonJS((exports, module) => {
|
|
8190
|
+
var parse = require_parse();
|
|
8191
|
+
var clean = (version, options) => {
|
|
8192
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
8193
|
+
return s ? s.version : null;
|
|
8194
|
+
};
|
|
8195
|
+
module.exports = clean;
|
|
8196
|
+
});
|
|
8197
|
+
|
|
8198
|
+
// node_modules/semver/functions/inc.js
|
|
8199
|
+
var require_inc = __commonJS((exports, module) => {
|
|
8200
|
+
var SemVer = require_semver();
|
|
8201
|
+
var inc = (version, release, options, identifier, identifierBase) => {
|
|
8202
|
+
if (typeof options === "string") {
|
|
8203
|
+
identifierBase = identifier;
|
|
8204
|
+
identifier = options;
|
|
8205
|
+
options = undefined;
|
|
7832
8206
|
}
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
8207
|
+
try {
|
|
8208
|
+
return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
|
|
8209
|
+
} catch (er) {
|
|
8210
|
+
return null;
|
|
7836
8211
|
}
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
8212
|
+
};
|
|
8213
|
+
module.exports = inc;
|
|
8214
|
+
});
|
|
8215
|
+
|
|
8216
|
+
// node_modules/semver/functions/diff.js
|
|
8217
|
+
var require_diff = __commonJS((exports, module) => {
|
|
8218
|
+
var parse = require_parse();
|
|
8219
|
+
var diff = (version1, version2) => {
|
|
8220
|
+
const v1 = parse(version1, null, true);
|
|
8221
|
+
const v2 = parse(version2, null, true);
|
|
8222
|
+
const comparison = v1.compare(v2);
|
|
8223
|
+
if (comparison === 0) {
|
|
8224
|
+
return null;
|
|
7847
8225
|
}
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
if (recursiveResult.type === "group") {
|
|
7861
|
-
return {
|
|
7862
|
-
type: "group_without_subcommand",
|
|
7863
|
-
group: recursiveResult.group,
|
|
7864
|
-
matchedPath: recursiveResult.matchedPath
|
|
7865
|
-
};
|
|
8226
|
+
const v1Higher = comparison > 0;
|
|
8227
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
8228
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
8229
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
8230
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
8231
|
+
if (lowHasPre && !highHasPre) {
|
|
8232
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
8233
|
+
return "major";
|
|
8234
|
+
}
|
|
8235
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
8236
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
8237
|
+
return "minor";
|
|
7866
8238
|
}
|
|
8239
|
+
return "patch";
|
|
7867
8240
|
}
|
|
7868
|
-
return {
|
|
7869
|
-
type: "group_without_subcommand",
|
|
7870
|
-
group: result.group,
|
|
7871
|
-
matchedPath: result.matchedPath
|
|
7872
|
-
};
|
|
7873
8241
|
}
|
|
7874
|
-
const
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
}
|
|
7884
|
-
|
|
8242
|
+
const prefix = highHasPre ? "pre" : "";
|
|
8243
|
+
if (v1.major !== v2.major) {
|
|
8244
|
+
return prefix + "major";
|
|
8245
|
+
}
|
|
8246
|
+
if (v1.minor !== v2.minor) {
|
|
8247
|
+
return prefix + "minor";
|
|
8248
|
+
}
|
|
8249
|
+
if (v1.patch !== v2.patch) {
|
|
8250
|
+
return prefix + "patch";
|
|
8251
|
+
}
|
|
8252
|
+
return "prerelease";
|
|
8253
|
+
};
|
|
8254
|
+
module.exports = diff;
|
|
8255
|
+
});
|
|
8256
|
+
|
|
8257
|
+
// node_modules/semver/functions/major.js
|
|
8258
|
+
var require_major = __commonJS((exports, module) => {
|
|
8259
|
+
var SemVer = require_semver();
|
|
8260
|
+
var major = (a, loose) => new SemVer(a, loose).major;
|
|
8261
|
+
module.exports = major;
|
|
8262
|
+
});
|
|
8263
|
+
|
|
8264
|
+
// node_modules/semver/functions/minor.js
|
|
8265
|
+
var require_minor = __commonJS((exports, module) => {
|
|
8266
|
+
var SemVer = require_semver();
|
|
8267
|
+
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
8268
|
+
module.exports = minor;
|
|
8269
|
+
});
|
|
8270
|
+
|
|
8271
|
+
// node_modules/semver/functions/patch.js
|
|
8272
|
+
var require_patch = __commonJS((exports, module) => {
|
|
8273
|
+
var SemVer = require_semver();
|
|
8274
|
+
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
8275
|
+
module.exports = patch;
|
|
8276
|
+
});
|
|
8277
|
+
|
|
8278
|
+
// node_modules/semver/functions/prerelease.js
|
|
8279
|
+
var require_prerelease = __commonJS((exports, module) => {
|
|
8280
|
+
var parse = require_parse();
|
|
8281
|
+
var prerelease = (version, options) => {
|
|
8282
|
+
const parsed = parse(version, options);
|
|
8283
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
8284
|
+
};
|
|
8285
|
+
module.exports = prerelease;
|
|
8286
|
+
});
|
|
8287
|
+
|
|
8288
|
+
// node_modules/semver/functions/compare.js
|
|
8289
|
+
var require_compare = __commonJS((exports, module) => {
|
|
8290
|
+
var SemVer = require_semver();
|
|
8291
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
8292
|
+
module.exports = compare;
|
|
8293
|
+
});
|
|
8294
|
+
|
|
8295
|
+
// node_modules/semver/functions/rcompare.js
|
|
8296
|
+
var require_rcompare = __commonJS((exports, module) => {
|
|
8297
|
+
var compare = require_compare();
|
|
8298
|
+
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
8299
|
+
module.exports = rcompare;
|
|
8300
|
+
});
|
|
8301
|
+
|
|
8302
|
+
// node_modules/semver/functions/compare-loose.js
|
|
8303
|
+
var require_compare_loose = __commonJS((exports, module) => {
|
|
8304
|
+
var compare = require_compare();
|
|
8305
|
+
var compareLoose = (a, b) => compare(a, b, true);
|
|
8306
|
+
module.exports = compareLoose;
|
|
8307
|
+
});
|
|
8308
|
+
|
|
8309
|
+
// node_modules/semver/functions/compare-build.js
|
|
8310
|
+
var require_compare_build = __commonJS((exports, module) => {
|
|
8311
|
+
var SemVer = require_semver();
|
|
8312
|
+
var compareBuild = (a, b, loose) => {
|
|
8313
|
+
const versionA = new SemVer(a, loose);
|
|
8314
|
+
const versionB = new SemVer(b, loose);
|
|
8315
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
8316
|
+
};
|
|
8317
|
+
module.exports = compareBuild;
|
|
8318
|
+
});
|
|
8319
|
+
|
|
8320
|
+
// node_modules/semver/functions/sort.js
|
|
8321
|
+
var require_sort = __commonJS((exports, module) => {
|
|
8322
|
+
var compareBuild = require_compare_build();
|
|
8323
|
+
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
8324
|
+
module.exports = sort;
|
|
8325
|
+
});
|
|
8326
|
+
|
|
8327
|
+
// node_modules/semver/functions/rsort.js
|
|
8328
|
+
var require_rsort = __commonJS((exports, module) => {
|
|
8329
|
+
var compareBuild = require_compare_build();
|
|
8330
|
+
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
8331
|
+
module.exports = rsort;
|
|
8332
|
+
});
|
|
8333
|
+
|
|
8334
|
+
// node_modules/semver/functions/gt.js
|
|
8335
|
+
var require_gt = __commonJS((exports, module) => {
|
|
8336
|
+
var compare = require_compare();
|
|
8337
|
+
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
8338
|
+
module.exports = gt;
|
|
8339
|
+
});
|
|
8340
|
+
|
|
8341
|
+
// node_modules/semver/functions/lt.js
|
|
8342
|
+
var require_lt = __commonJS((exports, module) => {
|
|
8343
|
+
var compare = require_compare();
|
|
8344
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
8345
|
+
module.exports = lt;
|
|
8346
|
+
});
|
|
8347
|
+
|
|
8348
|
+
// node_modules/semver/functions/eq.js
|
|
8349
|
+
var require_eq = __commonJS((exports, module) => {
|
|
8350
|
+
var compare = require_compare();
|
|
8351
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
8352
|
+
module.exports = eq;
|
|
8353
|
+
});
|
|
8354
|
+
|
|
8355
|
+
// node_modules/semver/functions/neq.js
|
|
8356
|
+
var require_neq = __commonJS((exports, module) => {
|
|
8357
|
+
var compare = require_compare();
|
|
8358
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
8359
|
+
module.exports = neq;
|
|
8360
|
+
});
|
|
8361
|
+
|
|
8362
|
+
// node_modules/semver/functions/gte.js
|
|
8363
|
+
var require_gte = __commonJS((exports, module) => {
|
|
8364
|
+
var compare = require_compare();
|
|
8365
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
8366
|
+
module.exports = gte;
|
|
8367
|
+
});
|
|
8368
|
+
|
|
8369
|
+
// node_modules/semver/functions/lte.js
|
|
8370
|
+
var require_lte = __commonJS((exports, module) => {
|
|
8371
|
+
var compare = require_compare();
|
|
8372
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
8373
|
+
module.exports = lte;
|
|
8374
|
+
});
|
|
8375
|
+
|
|
8376
|
+
// node_modules/semver/functions/cmp.js
|
|
8377
|
+
var require_cmp = __commonJS((exports, module) => {
|
|
8378
|
+
var eq = require_eq();
|
|
8379
|
+
var neq = require_neq();
|
|
8380
|
+
var gt = require_gt();
|
|
8381
|
+
var gte = require_gte();
|
|
8382
|
+
var lt = require_lt();
|
|
8383
|
+
var lte = require_lte();
|
|
8384
|
+
var cmp = (a, op, b, loose) => {
|
|
8385
|
+
switch (op) {
|
|
8386
|
+
case "===":
|
|
8387
|
+
if (typeof a === "object") {
|
|
8388
|
+
a = a.version;
|
|
8389
|
+
}
|
|
8390
|
+
if (typeof b === "object") {
|
|
8391
|
+
b = b.version;
|
|
8392
|
+
}
|
|
8393
|
+
return a === b;
|
|
8394
|
+
case "!==":
|
|
8395
|
+
if (typeof a === "object") {
|
|
8396
|
+
a = a.version;
|
|
8397
|
+
}
|
|
8398
|
+
if (typeof b === "object") {
|
|
8399
|
+
b = b.version;
|
|
8400
|
+
}
|
|
8401
|
+
return a !== b;
|
|
8402
|
+
case "":
|
|
8403
|
+
case "=":
|
|
8404
|
+
case "==":
|
|
8405
|
+
return eq(a, b, loose);
|
|
8406
|
+
case "!=":
|
|
8407
|
+
return neq(a, b, loose);
|
|
8408
|
+
case ">":
|
|
8409
|
+
return gt(a, b, loose);
|
|
8410
|
+
case ">=":
|
|
8411
|
+
return gte(a, b, loose);
|
|
8412
|
+
case "<":
|
|
8413
|
+
return lt(a, b, loose);
|
|
8414
|
+
case "<=":
|
|
8415
|
+
return lte(a, b, loose);
|
|
8416
|
+
default:
|
|
8417
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
8418
|
+
}
|
|
8419
|
+
};
|
|
8420
|
+
module.exports = cmp;
|
|
8421
|
+
});
|
|
8422
|
+
|
|
8423
|
+
// node_modules/semver/functions/coerce.js
|
|
8424
|
+
var require_coerce = __commonJS((exports, module) => {
|
|
8425
|
+
var SemVer = require_semver();
|
|
8426
|
+
var parse = require_parse();
|
|
8427
|
+
var { safeRe: re, t } = require_re();
|
|
8428
|
+
var coerce = (version, options) => {
|
|
8429
|
+
if (version instanceof SemVer) {
|
|
8430
|
+
return version;
|
|
8431
|
+
}
|
|
8432
|
+
if (typeof version === "number") {
|
|
8433
|
+
version = String(version);
|
|
8434
|
+
}
|
|
8435
|
+
if (typeof version !== "string") {
|
|
8436
|
+
return null;
|
|
8437
|
+
}
|
|
8438
|
+
options = options || {};
|
|
8439
|
+
let match = null;
|
|
8440
|
+
if (!options.rtl) {
|
|
8441
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
8442
|
+
} else {
|
|
8443
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
8444
|
+
let next;
|
|
8445
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
8446
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
8447
|
+
match = next;
|
|
8448
|
+
}
|
|
8449
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
8450
|
+
}
|
|
8451
|
+
coerceRtlRegex.lastIndex = -1;
|
|
8452
|
+
}
|
|
8453
|
+
if (match === null) {
|
|
8454
|
+
return null;
|
|
8455
|
+
}
|
|
8456
|
+
const major = match[2];
|
|
8457
|
+
const minor = match[3] || "0";
|
|
8458
|
+
const patch = match[4] || "0";
|
|
8459
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
|
|
8460
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
8461
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
8462
|
+
};
|
|
8463
|
+
module.exports = coerce;
|
|
8464
|
+
});
|
|
8465
|
+
|
|
8466
|
+
// node_modules/semver/functions/truncate.js
|
|
8467
|
+
var require_truncate = __commonJS((exports, module) => {
|
|
8468
|
+
var parse = require_parse();
|
|
8469
|
+
var constants = require_constants();
|
|
8470
|
+
var SemVer = require_semver();
|
|
8471
|
+
var truncate2 = (version, truncation, options) => {
|
|
8472
|
+
if (!constants.RELEASE_TYPES.includes(truncation)) {
|
|
8473
|
+
return null;
|
|
8474
|
+
}
|
|
8475
|
+
const clonedVersion = cloneInputVersion(version, options);
|
|
8476
|
+
return clonedVersion && doTruncation(clonedVersion, truncation);
|
|
8477
|
+
};
|
|
8478
|
+
var cloneInputVersion = (version, options) => {
|
|
8479
|
+
const versionStringToParse = version instanceof SemVer ? version.version : version;
|
|
8480
|
+
return parse(versionStringToParse, options);
|
|
8481
|
+
};
|
|
8482
|
+
var doTruncation = (version, truncation) => {
|
|
8483
|
+
if (isPrerelease(truncation)) {
|
|
8484
|
+
return version.version;
|
|
8485
|
+
}
|
|
8486
|
+
version.prerelease = [];
|
|
8487
|
+
switch (truncation) {
|
|
8488
|
+
case "major":
|
|
8489
|
+
version.minor = 0;
|
|
8490
|
+
version.patch = 0;
|
|
8491
|
+
break;
|
|
8492
|
+
case "minor":
|
|
8493
|
+
version.patch = 0;
|
|
8494
|
+
break;
|
|
8495
|
+
}
|
|
8496
|
+
return version.format();
|
|
8497
|
+
};
|
|
8498
|
+
var isPrerelease = (type) => {
|
|
8499
|
+
return type.startsWith("pre");
|
|
8500
|
+
};
|
|
8501
|
+
module.exports = truncate2;
|
|
8502
|
+
});
|
|
8503
|
+
|
|
8504
|
+
// node_modules/semver/internal/lrucache.js
|
|
8505
|
+
var require_lrucache = __commonJS((exports, module) => {
|
|
8506
|
+
class LRUCache {
|
|
8507
|
+
constructor() {
|
|
8508
|
+
this.max = 1000;
|
|
8509
|
+
this.map = new Map;
|
|
8510
|
+
}
|
|
8511
|
+
get(key) {
|
|
8512
|
+
const value = this.map.get(key);
|
|
8513
|
+
if (value === undefined) {
|
|
8514
|
+
return;
|
|
8515
|
+
} else {
|
|
8516
|
+
this.map.delete(key);
|
|
8517
|
+
this.map.set(key, value);
|
|
8518
|
+
return value;
|
|
8519
|
+
}
|
|
8520
|
+
}
|
|
8521
|
+
delete(key) {
|
|
8522
|
+
return this.map.delete(key);
|
|
8523
|
+
}
|
|
8524
|
+
set(key, value) {
|
|
8525
|
+
const deleted = this.delete(key);
|
|
8526
|
+
if (!deleted && value !== undefined) {
|
|
8527
|
+
if (this.map.size >= this.max) {
|
|
8528
|
+
const firstKey = this.map.keys().next().value;
|
|
8529
|
+
this.delete(firstKey);
|
|
8530
|
+
}
|
|
8531
|
+
this.map.set(key, value);
|
|
8532
|
+
}
|
|
8533
|
+
return this;
|
|
8534
|
+
}
|
|
8535
|
+
}
|
|
8536
|
+
module.exports = LRUCache;
|
|
8537
|
+
});
|
|
8538
|
+
|
|
8539
|
+
// node_modules/semver/classes/range.js
|
|
8540
|
+
var require_range = __commonJS((exports, module) => {
|
|
8541
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
8542
|
+
|
|
8543
|
+
class Range {
|
|
8544
|
+
constructor(range, options) {
|
|
8545
|
+
options = parseOptions(options);
|
|
8546
|
+
if (range instanceof Range) {
|
|
8547
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
8548
|
+
return range;
|
|
8549
|
+
} else {
|
|
8550
|
+
return new Range(range.raw, options);
|
|
8551
|
+
}
|
|
8552
|
+
}
|
|
8553
|
+
if (range instanceof Comparator) {
|
|
8554
|
+
this.raw = range.value;
|
|
8555
|
+
this.set = [[range]];
|
|
8556
|
+
this.formatted = undefined;
|
|
8557
|
+
return this;
|
|
8558
|
+
}
|
|
8559
|
+
this.options = options;
|
|
8560
|
+
this.loose = !!options.loose;
|
|
8561
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
8562
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
8563
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
8564
|
+
if (!this.set.length) {
|
|
8565
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
8566
|
+
}
|
|
8567
|
+
if (this.set.length > 1) {
|
|
8568
|
+
const first = this.set[0];
|
|
8569
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
8570
|
+
if (this.set.length === 0) {
|
|
8571
|
+
this.set = [first];
|
|
8572
|
+
} else if (this.set.length > 1) {
|
|
8573
|
+
for (const c of this.set) {
|
|
8574
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
8575
|
+
this.set = [c];
|
|
8576
|
+
break;
|
|
8577
|
+
}
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
}
|
|
8581
|
+
this.formatted = undefined;
|
|
8582
|
+
}
|
|
8583
|
+
get range() {
|
|
8584
|
+
if (this.formatted === undefined) {
|
|
8585
|
+
this.formatted = "";
|
|
8586
|
+
for (let i = 0;i < this.set.length; i++) {
|
|
8587
|
+
if (i > 0) {
|
|
8588
|
+
this.formatted += "||";
|
|
8589
|
+
}
|
|
8590
|
+
const comps = this.set[i];
|
|
8591
|
+
for (let k = 0;k < comps.length; k++) {
|
|
8592
|
+
if (k > 0) {
|
|
8593
|
+
this.formatted += " ";
|
|
8594
|
+
}
|
|
8595
|
+
this.formatted += comps[k].toString().trim();
|
|
8596
|
+
}
|
|
8597
|
+
}
|
|
8598
|
+
}
|
|
8599
|
+
return this.formatted;
|
|
8600
|
+
}
|
|
8601
|
+
format() {
|
|
8602
|
+
return this.range;
|
|
8603
|
+
}
|
|
8604
|
+
toString() {
|
|
8605
|
+
return this.range;
|
|
8606
|
+
}
|
|
8607
|
+
parseRange(range) {
|
|
8608
|
+
range = range.replace(BUILDSTRIPRE, "");
|
|
8609
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
8610
|
+
const memoKey = memoOpts + ":" + range;
|
|
8611
|
+
const cached = cache.get(memoKey);
|
|
8612
|
+
if (cached) {
|
|
8613
|
+
return cached;
|
|
8614
|
+
}
|
|
8615
|
+
const loose = this.options.loose;
|
|
8616
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
8617
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
8618
|
+
debug("hyphen replace", range);
|
|
8619
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
8620
|
+
debug("comparator trim", range);
|
|
8621
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
8622
|
+
debug("tilde trim", range);
|
|
8623
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
8624
|
+
debug("caret trim", range);
|
|
8625
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
8626
|
+
if (loose) {
|
|
8627
|
+
rangeList = rangeList.filter((comp) => {
|
|
8628
|
+
debug("loose invalid filter", comp, this.options);
|
|
8629
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
8630
|
+
});
|
|
8631
|
+
}
|
|
8632
|
+
debug("range list", rangeList);
|
|
8633
|
+
const rangeMap = new Map;
|
|
8634
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
8635
|
+
for (const comp of comparators) {
|
|
8636
|
+
if (isNullSet(comp)) {
|
|
8637
|
+
return [comp];
|
|
8638
|
+
}
|
|
8639
|
+
rangeMap.set(comp.value, comp);
|
|
8640
|
+
}
|
|
8641
|
+
if (rangeMap.size > 1 && rangeMap.has("")) {
|
|
8642
|
+
rangeMap.delete("");
|
|
8643
|
+
}
|
|
8644
|
+
const result = [...rangeMap.values()];
|
|
8645
|
+
cache.set(memoKey, result);
|
|
8646
|
+
return result;
|
|
8647
|
+
}
|
|
8648
|
+
intersects(range, options) {
|
|
8649
|
+
if (!(range instanceof Range)) {
|
|
8650
|
+
throw new TypeError("a Range is required");
|
|
8651
|
+
}
|
|
8652
|
+
return this.set.some((thisComparators) => {
|
|
8653
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
8654
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
8655
|
+
return rangeComparators.every((rangeComparator) => {
|
|
8656
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
8657
|
+
});
|
|
8658
|
+
});
|
|
8659
|
+
});
|
|
8660
|
+
});
|
|
8661
|
+
}
|
|
8662
|
+
test(version) {
|
|
8663
|
+
if (!version) {
|
|
8664
|
+
return false;
|
|
8665
|
+
}
|
|
8666
|
+
if (typeof version === "string") {
|
|
8667
|
+
try {
|
|
8668
|
+
version = new SemVer(version, this.options);
|
|
8669
|
+
} catch (er) {
|
|
8670
|
+
return false;
|
|
8671
|
+
}
|
|
8672
|
+
}
|
|
8673
|
+
for (let i = 0;i < this.set.length; i++) {
|
|
8674
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
8675
|
+
return true;
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8678
|
+
return false;
|
|
8679
|
+
}
|
|
8680
|
+
}
|
|
8681
|
+
module.exports = Range;
|
|
8682
|
+
var LRU = require_lrucache();
|
|
8683
|
+
var cache = new LRU;
|
|
8684
|
+
var parseOptions = require_parse_options();
|
|
8685
|
+
var Comparator = require_comparator();
|
|
8686
|
+
var debug = require_debug();
|
|
8687
|
+
var SemVer = require_semver();
|
|
8688
|
+
var {
|
|
8689
|
+
safeRe: re,
|
|
8690
|
+
src,
|
|
8691
|
+
t,
|
|
8692
|
+
comparatorTrimReplace,
|
|
8693
|
+
tildeTrimReplace,
|
|
8694
|
+
caretTrimReplace
|
|
8695
|
+
} = require_re();
|
|
8696
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
8697
|
+
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
8698
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
8699
|
+
var isAny = (c) => c.value === "";
|
|
8700
|
+
var isSatisfiable = (comparators, options) => {
|
|
8701
|
+
let result = true;
|
|
8702
|
+
const remainingComparators = comparators.slice();
|
|
8703
|
+
let testComparator = remainingComparators.pop();
|
|
8704
|
+
while (result && remainingComparators.length) {
|
|
8705
|
+
result = remainingComparators.every((otherComparator) => {
|
|
8706
|
+
return testComparator.intersects(otherComparator, options);
|
|
8707
|
+
});
|
|
8708
|
+
testComparator = remainingComparators.pop();
|
|
8709
|
+
}
|
|
8710
|
+
return result;
|
|
8711
|
+
};
|
|
8712
|
+
var parseComparator = (comp, options) => {
|
|
8713
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
8714
|
+
debug("comp", comp, options);
|
|
8715
|
+
comp = replaceCarets(comp, options);
|
|
8716
|
+
debug("caret", comp);
|
|
8717
|
+
comp = replaceTildes(comp, options);
|
|
8718
|
+
debug("tildes", comp);
|
|
8719
|
+
comp = replaceXRanges(comp, options);
|
|
8720
|
+
debug("xrange", comp);
|
|
8721
|
+
comp = replaceStars(comp, options);
|
|
8722
|
+
debug("stars", comp);
|
|
8723
|
+
return comp;
|
|
8724
|
+
};
|
|
8725
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
8726
|
+
var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
8727
|
+
var replaceTildes = (comp, options) => {
|
|
8728
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
8729
|
+
};
|
|
8730
|
+
var replaceTilde = (comp, options) => {
|
|
8731
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
8732
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
8733
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
8734
|
+
let ret;
|
|
8735
|
+
if (isX(M)) {
|
|
8736
|
+
ret = "";
|
|
8737
|
+
} else if (isX(m)) {
|
|
8738
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
8739
|
+
} else if (isX(p)) {
|
|
8740
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
8741
|
+
} else if (pr) {
|
|
8742
|
+
debug("replaceTilde pr", pr);
|
|
8743
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
8744
|
+
} else {
|
|
8745
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
8746
|
+
}
|
|
8747
|
+
debug("tilde return", ret);
|
|
8748
|
+
return ret;
|
|
8749
|
+
});
|
|
8750
|
+
};
|
|
8751
|
+
var replaceCarets = (comp, options) => {
|
|
8752
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
8753
|
+
};
|
|
8754
|
+
var replaceCaret = (comp, options) => {
|
|
8755
|
+
debug("caret", comp, options);
|
|
8756
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
8757
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
8758
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
8759
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
8760
|
+
let ret;
|
|
8761
|
+
if (isX(M)) {
|
|
8762
|
+
ret = "";
|
|
8763
|
+
} else if (isX(m)) {
|
|
8764
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
8765
|
+
} else if (isX(p)) {
|
|
8766
|
+
if (M === "0") {
|
|
8767
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
8768
|
+
} else {
|
|
8769
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
8770
|
+
}
|
|
8771
|
+
} else if (pr) {
|
|
8772
|
+
debug("replaceCaret pr", pr);
|
|
8773
|
+
if (M === "0") {
|
|
8774
|
+
if (m === "0") {
|
|
8775
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
8776
|
+
} else {
|
|
8777
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
8778
|
+
}
|
|
8779
|
+
} else {
|
|
8780
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
8781
|
+
}
|
|
8782
|
+
} else {
|
|
8783
|
+
debug("no pr");
|
|
8784
|
+
if (M === "0") {
|
|
8785
|
+
if (m === "0") {
|
|
8786
|
+
ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
8787
|
+
} else {
|
|
8788
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
8789
|
+
}
|
|
8790
|
+
} else {
|
|
8791
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
8792
|
+
}
|
|
8793
|
+
}
|
|
8794
|
+
debug("caret return", ret);
|
|
8795
|
+
return ret;
|
|
8796
|
+
});
|
|
8797
|
+
};
|
|
8798
|
+
var replaceXRanges = (comp, options) => {
|
|
8799
|
+
debug("replaceXRanges", comp, options);
|
|
8800
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
8801
|
+
};
|
|
8802
|
+
var replaceXRange = (comp, options) => {
|
|
8803
|
+
comp = comp.trim();
|
|
8804
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
8805
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
8806
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
8807
|
+
if (invalidXRangeOrder(M, m, p)) {
|
|
8808
|
+
return comp;
|
|
8809
|
+
}
|
|
8810
|
+
const xM = isX(M);
|
|
8811
|
+
const xm = xM || isX(m);
|
|
8812
|
+
const xp = xm || isX(p);
|
|
8813
|
+
const anyX = xp;
|
|
8814
|
+
if (gtlt === "=" && anyX) {
|
|
8815
|
+
gtlt = "";
|
|
8816
|
+
}
|
|
8817
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
8818
|
+
if (xM) {
|
|
8819
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
8820
|
+
ret = "<0.0.0-0";
|
|
8821
|
+
} else {
|
|
8822
|
+
ret = "*";
|
|
8823
|
+
}
|
|
8824
|
+
} else if (gtlt && anyX) {
|
|
8825
|
+
if (xm) {
|
|
8826
|
+
m = 0;
|
|
8827
|
+
}
|
|
8828
|
+
p = 0;
|
|
8829
|
+
if (gtlt === ">") {
|
|
8830
|
+
gtlt = ">=";
|
|
8831
|
+
if (xm) {
|
|
8832
|
+
M = +M + 1;
|
|
8833
|
+
m = 0;
|
|
8834
|
+
p = 0;
|
|
8835
|
+
} else {
|
|
8836
|
+
m = +m + 1;
|
|
8837
|
+
p = 0;
|
|
8838
|
+
}
|
|
8839
|
+
} else if (gtlt === "<=") {
|
|
8840
|
+
gtlt = "<";
|
|
8841
|
+
if (xm) {
|
|
8842
|
+
M = +M + 1;
|
|
8843
|
+
} else {
|
|
8844
|
+
m = +m + 1;
|
|
8845
|
+
}
|
|
8846
|
+
}
|
|
8847
|
+
if (gtlt === "<") {
|
|
8848
|
+
pr = "-0";
|
|
8849
|
+
}
|
|
8850
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
8851
|
+
} else if (xm) {
|
|
8852
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
8853
|
+
} else if (xp) {
|
|
8854
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
8855
|
+
}
|
|
8856
|
+
debug("xRange return", ret);
|
|
8857
|
+
return ret;
|
|
8858
|
+
});
|
|
8859
|
+
};
|
|
8860
|
+
var replaceStars = (comp, options) => {
|
|
8861
|
+
debug("replaceStars", comp, options);
|
|
8862
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
8863
|
+
};
|
|
8864
|
+
var replaceGTE0 = (comp, options) => {
|
|
8865
|
+
debug("replaceGTE0", comp, options);
|
|
8866
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
8867
|
+
};
|
|
8868
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
8869
|
+
if (isX(fM)) {
|
|
8870
|
+
from = "";
|
|
8871
|
+
} else if (isX(fm)) {
|
|
8872
|
+
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
8873
|
+
} else if (isX(fp)) {
|
|
8874
|
+
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
8875
|
+
} else if (fpr) {
|
|
8876
|
+
from = `>=${from}`;
|
|
8877
|
+
} else {
|
|
8878
|
+
from = `>=${from}${incPr ? "-0" : ""}`;
|
|
8879
|
+
}
|
|
8880
|
+
if (isX(tM)) {
|
|
8881
|
+
to = "";
|
|
8882
|
+
} else if (isX(tm)) {
|
|
8883
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
8884
|
+
} else if (isX(tp)) {
|
|
8885
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
8886
|
+
} else if (tpr) {
|
|
8887
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
8888
|
+
} else if (incPr) {
|
|
8889
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
8890
|
+
} else {
|
|
8891
|
+
to = `<=${to}`;
|
|
8892
|
+
}
|
|
8893
|
+
return `${from} ${to}`.trim();
|
|
8894
|
+
};
|
|
8895
|
+
var testSet = (set, version, options) => {
|
|
8896
|
+
for (let i = 0;i < set.length; i++) {
|
|
8897
|
+
if (!set[i].test(version)) {
|
|
8898
|
+
return false;
|
|
8899
|
+
}
|
|
8900
|
+
}
|
|
8901
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
8902
|
+
for (let i = 0;i < set.length; i++) {
|
|
8903
|
+
debug(set[i].semver);
|
|
8904
|
+
if (set[i].semver === Comparator.ANY) {
|
|
8905
|
+
continue;
|
|
8906
|
+
}
|
|
8907
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
8908
|
+
const allowed = set[i].semver;
|
|
8909
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
8910
|
+
return true;
|
|
8911
|
+
}
|
|
8912
|
+
}
|
|
8913
|
+
}
|
|
8914
|
+
return false;
|
|
8915
|
+
}
|
|
8916
|
+
return true;
|
|
8917
|
+
};
|
|
8918
|
+
});
|
|
8919
|
+
|
|
8920
|
+
// node_modules/semver/classes/comparator.js
|
|
8921
|
+
var require_comparator = __commonJS((exports, module) => {
|
|
8922
|
+
var ANY = Symbol("SemVer ANY");
|
|
8923
|
+
|
|
8924
|
+
class Comparator {
|
|
8925
|
+
static get ANY() {
|
|
8926
|
+
return ANY;
|
|
8927
|
+
}
|
|
8928
|
+
constructor(comp, options) {
|
|
8929
|
+
options = parseOptions(options);
|
|
8930
|
+
if (comp instanceof Comparator) {
|
|
8931
|
+
if (comp.loose === !!options.loose) {
|
|
8932
|
+
return comp;
|
|
8933
|
+
} else {
|
|
8934
|
+
comp = comp.value;
|
|
8935
|
+
}
|
|
8936
|
+
}
|
|
8937
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
8938
|
+
debug("comparator", comp, options);
|
|
8939
|
+
this.options = options;
|
|
8940
|
+
this.loose = !!options.loose;
|
|
8941
|
+
this.parse(comp);
|
|
8942
|
+
if (this.semver === ANY) {
|
|
8943
|
+
this.value = "";
|
|
8944
|
+
} else {
|
|
8945
|
+
this.value = this.operator + this.semver.version;
|
|
8946
|
+
}
|
|
8947
|
+
debug("comp", this);
|
|
8948
|
+
}
|
|
8949
|
+
parse(comp) {
|
|
8950
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
8951
|
+
const m = comp.match(r);
|
|
8952
|
+
if (!m) {
|
|
8953
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
8954
|
+
}
|
|
8955
|
+
this.operator = m[1] !== undefined ? m[1] : "";
|
|
8956
|
+
if (this.operator === "=") {
|
|
8957
|
+
this.operator = "";
|
|
8958
|
+
}
|
|
8959
|
+
if (!m[2]) {
|
|
8960
|
+
this.semver = ANY;
|
|
8961
|
+
} else {
|
|
8962
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
8963
|
+
}
|
|
8964
|
+
}
|
|
8965
|
+
toString() {
|
|
8966
|
+
return this.value;
|
|
8967
|
+
}
|
|
8968
|
+
test(version) {
|
|
8969
|
+
debug("Comparator.test", version, this.options.loose);
|
|
8970
|
+
if (this.semver === ANY || version === ANY) {
|
|
8971
|
+
return true;
|
|
8972
|
+
}
|
|
8973
|
+
if (typeof version === "string") {
|
|
8974
|
+
try {
|
|
8975
|
+
version = new SemVer(version, this.options);
|
|
8976
|
+
} catch (er) {
|
|
8977
|
+
return false;
|
|
8978
|
+
}
|
|
8979
|
+
}
|
|
8980
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
8981
|
+
}
|
|
8982
|
+
intersects(comp, options) {
|
|
8983
|
+
if (!(comp instanceof Comparator)) {
|
|
8984
|
+
throw new TypeError("a Comparator is required");
|
|
8985
|
+
}
|
|
8986
|
+
if (this.operator === "") {
|
|
8987
|
+
if (this.value === "") {
|
|
8988
|
+
return true;
|
|
8989
|
+
}
|
|
8990
|
+
return new Range(comp.value, options).test(this.value);
|
|
8991
|
+
} else if (comp.operator === "") {
|
|
8992
|
+
if (comp.value === "") {
|
|
8993
|
+
return true;
|
|
8994
|
+
}
|
|
8995
|
+
return new Range(this.value, options).test(comp.semver);
|
|
8996
|
+
}
|
|
8997
|
+
options = parseOptions(options);
|
|
8998
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
|
|
8999
|
+
return false;
|
|
9000
|
+
}
|
|
9001
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
|
|
9002
|
+
return false;
|
|
9003
|
+
}
|
|
9004
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
|
|
9005
|
+
return true;
|
|
9006
|
+
}
|
|
9007
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
|
|
9008
|
+
return true;
|
|
9009
|
+
}
|
|
9010
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
9011
|
+
return true;
|
|
9012
|
+
}
|
|
9013
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
9014
|
+
return true;
|
|
9015
|
+
}
|
|
9016
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
9017
|
+
return true;
|
|
9018
|
+
}
|
|
9019
|
+
return false;
|
|
9020
|
+
}
|
|
9021
|
+
}
|
|
9022
|
+
module.exports = Comparator;
|
|
9023
|
+
var parseOptions = require_parse_options();
|
|
9024
|
+
var { safeRe: re, t } = require_re();
|
|
9025
|
+
var cmp = require_cmp();
|
|
9026
|
+
var debug = require_debug();
|
|
9027
|
+
var SemVer = require_semver();
|
|
9028
|
+
var Range = require_range();
|
|
9029
|
+
});
|
|
9030
|
+
|
|
9031
|
+
// node_modules/semver/functions/satisfies.js
|
|
9032
|
+
var require_satisfies = __commonJS((exports, module) => {
|
|
9033
|
+
var Range = require_range();
|
|
9034
|
+
var satisfies = (version, range, options) => {
|
|
9035
|
+
try {
|
|
9036
|
+
range = new Range(range, options);
|
|
9037
|
+
} catch (er) {
|
|
9038
|
+
return false;
|
|
9039
|
+
}
|
|
9040
|
+
return range.test(version);
|
|
9041
|
+
};
|
|
9042
|
+
module.exports = satisfies;
|
|
9043
|
+
});
|
|
9044
|
+
|
|
9045
|
+
// node_modules/semver/ranges/to-comparators.js
|
|
9046
|
+
var require_to_comparators = __commonJS((exports, module) => {
|
|
9047
|
+
var Range = require_range();
|
|
9048
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
9049
|
+
module.exports = toComparators;
|
|
9050
|
+
});
|
|
9051
|
+
|
|
9052
|
+
// node_modules/semver/ranges/max-satisfying.js
|
|
9053
|
+
var require_max_satisfying = __commonJS((exports, module) => {
|
|
9054
|
+
var SemVer = require_semver();
|
|
9055
|
+
var Range = require_range();
|
|
9056
|
+
var maxSatisfying = (versions, range, options) => {
|
|
9057
|
+
let max = null;
|
|
9058
|
+
let maxSV = null;
|
|
9059
|
+
let rangeObj = null;
|
|
9060
|
+
try {
|
|
9061
|
+
rangeObj = new Range(range, options);
|
|
9062
|
+
} catch (er) {
|
|
9063
|
+
return null;
|
|
9064
|
+
}
|
|
9065
|
+
versions.forEach((v) => {
|
|
9066
|
+
if (rangeObj.test(v)) {
|
|
9067
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
9068
|
+
max = v;
|
|
9069
|
+
maxSV = new SemVer(max, options);
|
|
9070
|
+
}
|
|
9071
|
+
}
|
|
9072
|
+
});
|
|
9073
|
+
return max;
|
|
9074
|
+
};
|
|
9075
|
+
module.exports = maxSatisfying;
|
|
9076
|
+
});
|
|
9077
|
+
|
|
9078
|
+
// node_modules/semver/ranges/min-satisfying.js
|
|
9079
|
+
var require_min_satisfying = __commonJS((exports, module) => {
|
|
9080
|
+
var SemVer = require_semver();
|
|
9081
|
+
var Range = require_range();
|
|
9082
|
+
var minSatisfying = (versions, range, options) => {
|
|
9083
|
+
let min = null;
|
|
9084
|
+
let minSV = null;
|
|
9085
|
+
let rangeObj = null;
|
|
9086
|
+
try {
|
|
9087
|
+
rangeObj = new Range(range, options);
|
|
9088
|
+
} catch (er) {
|
|
9089
|
+
return null;
|
|
9090
|
+
}
|
|
9091
|
+
versions.forEach((v) => {
|
|
9092
|
+
if (rangeObj.test(v)) {
|
|
9093
|
+
if (!min || minSV.compare(v) === 1) {
|
|
9094
|
+
min = v;
|
|
9095
|
+
minSV = new SemVer(min, options);
|
|
9096
|
+
}
|
|
9097
|
+
}
|
|
9098
|
+
});
|
|
9099
|
+
return min;
|
|
9100
|
+
};
|
|
9101
|
+
module.exports = minSatisfying;
|
|
9102
|
+
});
|
|
9103
|
+
|
|
9104
|
+
// node_modules/semver/ranges/min-version.js
|
|
9105
|
+
var require_min_version = __commonJS((exports, module) => {
|
|
9106
|
+
var SemVer = require_semver();
|
|
9107
|
+
var Range = require_range();
|
|
9108
|
+
var gt = require_gt();
|
|
9109
|
+
var minVersion = (range, loose) => {
|
|
9110
|
+
range = new Range(range, loose);
|
|
9111
|
+
let minver = new SemVer("0.0.0");
|
|
9112
|
+
if (range.test(minver)) {
|
|
9113
|
+
return minver;
|
|
9114
|
+
}
|
|
9115
|
+
minver = new SemVer("0.0.0-0");
|
|
9116
|
+
if (range.test(minver)) {
|
|
9117
|
+
return minver;
|
|
9118
|
+
}
|
|
9119
|
+
minver = null;
|
|
9120
|
+
for (let i = 0;i < range.set.length; ++i) {
|
|
9121
|
+
const comparators = range.set[i];
|
|
9122
|
+
let setMin = null;
|
|
9123
|
+
comparators.forEach((comparator) => {
|
|
9124
|
+
const compver = new SemVer(comparator.semver.version);
|
|
9125
|
+
switch (comparator.operator) {
|
|
9126
|
+
case ">":
|
|
9127
|
+
if (compver.prerelease.length === 0) {
|
|
9128
|
+
compver.patch++;
|
|
9129
|
+
} else {
|
|
9130
|
+
compver.prerelease.push(0);
|
|
9131
|
+
}
|
|
9132
|
+
compver.raw = compver.format();
|
|
9133
|
+
case "":
|
|
9134
|
+
case ">=":
|
|
9135
|
+
if (!setMin || gt(compver, setMin)) {
|
|
9136
|
+
setMin = compver;
|
|
9137
|
+
}
|
|
9138
|
+
break;
|
|
9139
|
+
case "<":
|
|
9140
|
+
case "<=":
|
|
9141
|
+
break;
|
|
9142
|
+
default:
|
|
9143
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
9144
|
+
}
|
|
9145
|
+
});
|
|
9146
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
9147
|
+
minver = setMin;
|
|
9148
|
+
}
|
|
9149
|
+
}
|
|
9150
|
+
if (minver && range.test(minver)) {
|
|
9151
|
+
return minver;
|
|
9152
|
+
}
|
|
9153
|
+
return null;
|
|
9154
|
+
};
|
|
9155
|
+
module.exports = minVersion;
|
|
9156
|
+
});
|
|
9157
|
+
|
|
9158
|
+
// node_modules/semver/ranges/valid.js
|
|
9159
|
+
var require_valid2 = __commonJS((exports, module) => {
|
|
9160
|
+
var Range = require_range();
|
|
9161
|
+
var validRange = (range, options) => {
|
|
9162
|
+
try {
|
|
9163
|
+
return new Range(range, options).range || "*";
|
|
9164
|
+
} catch (er) {
|
|
9165
|
+
return null;
|
|
9166
|
+
}
|
|
9167
|
+
};
|
|
9168
|
+
module.exports = validRange;
|
|
9169
|
+
});
|
|
9170
|
+
|
|
9171
|
+
// node_modules/semver/ranges/outside.js
|
|
9172
|
+
var require_outside = __commonJS((exports, module) => {
|
|
9173
|
+
var SemVer = require_semver();
|
|
9174
|
+
var Comparator = require_comparator();
|
|
9175
|
+
var { ANY } = Comparator;
|
|
9176
|
+
var Range = require_range();
|
|
9177
|
+
var satisfies = require_satisfies();
|
|
9178
|
+
var gt = require_gt();
|
|
9179
|
+
var lt = require_lt();
|
|
9180
|
+
var lte = require_lte();
|
|
9181
|
+
var gte = require_gte();
|
|
9182
|
+
var outside = (version, range, hilo, options) => {
|
|
9183
|
+
version = new SemVer(version, options);
|
|
9184
|
+
range = new Range(range, options);
|
|
9185
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
9186
|
+
switch (hilo) {
|
|
9187
|
+
case ">":
|
|
9188
|
+
gtfn = gt;
|
|
9189
|
+
ltefn = lte;
|
|
9190
|
+
ltfn = lt;
|
|
9191
|
+
comp = ">";
|
|
9192
|
+
ecomp = ">=";
|
|
9193
|
+
break;
|
|
9194
|
+
case "<":
|
|
9195
|
+
gtfn = lt;
|
|
9196
|
+
ltefn = gte;
|
|
9197
|
+
ltfn = gt;
|
|
9198
|
+
comp = "<";
|
|
9199
|
+
ecomp = "<=";
|
|
9200
|
+
break;
|
|
9201
|
+
default:
|
|
9202
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
9203
|
+
}
|
|
9204
|
+
if (satisfies(version, range, options)) {
|
|
9205
|
+
return false;
|
|
9206
|
+
}
|
|
9207
|
+
for (let i = 0;i < range.set.length; ++i) {
|
|
9208
|
+
const comparators = range.set[i];
|
|
9209
|
+
let high = null;
|
|
9210
|
+
let low = null;
|
|
9211
|
+
comparators.forEach((comparator) => {
|
|
9212
|
+
if (comparator.semver === ANY) {
|
|
9213
|
+
comparator = new Comparator(">=0.0.0");
|
|
9214
|
+
}
|
|
9215
|
+
high = high || comparator;
|
|
9216
|
+
low = low || comparator;
|
|
9217
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
9218
|
+
high = comparator;
|
|
9219
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
9220
|
+
low = comparator;
|
|
9221
|
+
}
|
|
9222
|
+
});
|
|
9223
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
9224
|
+
return false;
|
|
9225
|
+
}
|
|
9226
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
9227
|
+
return false;
|
|
9228
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
9229
|
+
return false;
|
|
9230
|
+
}
|
|
9231
|
+
}
|
|
9232
|
+
return true;
|
|
9233
|
+
};
|
|
9234
|
+
module.exports = outside;
|
|
9235
|
+
});
|
|
9236
|
+
|
|
9237
|
+
// node_modules/semver/ranges/gtr.js
|
|
9238
|
+
var require_gtr = __commonJS((exports, module) => {
|
|
9239
|
+
var outside = require_outside();
|
|
9240
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
9241
|
+
module.exports = gtr;
|
|
9242
|
+
});
|
|
9243
|
+
|
|
9244
|
+
// node_modules/semver/ranges/ltr.js
|
|
9245
|
+
var require_ltr = __commonJS((exports, module) => {
|
|
9246
|
+
var outside = require_outside();
|
|
9247
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
9248
|
+
module.exports = ltr;
|
|
9249
|
+
});
|
|
9250
|
+
|
|
9251
|
+
// node_modules/semver/ranges/intersects.js
|
|
9252
|
+
var require_intersects = __commonJS((exports, module) => {
|
|
9253
|
+
var Range = require_range();
|
|
9254
|
+
var intersects = (r1, r2, options) => {
|
|
9255
|
+
r1 = new Range(r1, options);
|
|
9256
|
+
r2 = new Range(r2, options);
|
|
9257
|
+
return r1.intersects(r2, options);
|
|
9258
|
+
};
|
|
9259
|
+
module.exports = intersects;
|
|
9260
|
+
});
|
|
9261
|
+
|
|
9262
|
+
// node_modules/semver/ranges/simplify.js
|
|
9263
|
+
var require_simplify = __commonJS((exports, module) => {
|
|
9264
|
+
var satisfies = require_satisfies();
|
|
9265
|
+
var compare = require_compare();
|
|
9266
|
+
module.exports = (versions, range, options) => {
|
|
9267
|
+
const set = [];
|
|
9268
|
+
let first = null;
|
|
9269
|
+
let prev = null;
|
|
9270
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
9271
|
+
for (const version of v) {
|
|
9272
|
+
const included = satisfies(version, range, options);
|
|
9273
|
+
if (included) {
|
|
9274
|
+
prev = version;
|
|
9275
|
+
if (!first) {
|
|
9276
|
+
first = version;
|
|
9277
|
+
}
|
|
9278
|
+
} else {
|
|
9279
|
+
if (prev) {
|
|
9280
|
+
set.push([first, prev]);
|
|
9281
|
+
}
|
|
9282
|
+
prev = null;
|
|
9283
|
+
first = null;
|
|
9284
|
+
}
|
|
9285
|
+
}
|
|
9286
|
+
if (first) {
|
|
9287
|
+
set.push([first, null]);
|
|
9288
|
+
}
|
|
9289
|
+
const ranges = [];
|
|
9290
|
+
for (const [min, max] of set) {
|
|
9291
|
+
if (min === max) {
|
|
9292
|
+
ranges.push(min);
|
|
9293
|
+
} else if (!max && min === v[0]) {
|
|
9294
|
+
ranges.push("*");
|
|
9295
|
+
} else if (!max) {
|
|
9296
|
+
ranges.push(`>=${min}`);
|
|
9297
|
+
} else if (min === v[0]) {
|
|
9298
|
+
ranges.push(`<=${max}`);
|
|
9299
|
+
} else {
|
|
9300
|
+
ranges.push(`${min} - ${max}`);
|
|
9301
|
+
}
|
|
9302
|
+
}
|
|
9303
|
+
const simplified = ranges.join(" || ");
|
|
9304
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
9305
|
+
return simplified.length < original.length ? simplified : range;
|
|
9306
|
+
};
|
|
9307
|
+
});
|
|
9308
|
+
|
|
9309
|
+
// node_modules/semver/ranges/subset.js
|
|
9310
|
+
var require_subset = __commonJS((exports, module) => {
|
|
9311
|
+
var Range = require_range();
|
|
9312
|
+
var Comparator = require_comparator();
|
|
9313
|
+
var { ANY } = Comparator;
|
|
9314
|
+
var satisfies = require_satisfies();
|
|
9315
|
+
var compare = require_compare();
|
|
9316
|
+
var subset = (sub, dom, options = {}) => {
|
|
9317
|
+
if (sub === dom) {
|
|
9318
|
+
return true;
|
|
9319
|
+
}
|
|
9320
|
+
sub = new Range(sub, options);
|
|
9321
|
+
dom = new Range(dom, options);
|
|
9322
|
+
let sawNonNull = false;
|
|
9323
|
+
OUTER:
|
|
9324
|
+
for (const simpleSub of sub.set) {
|
|
9325
|
+
for (const simpleDom of dom.set) {
|
|
9326
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
9327
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
9328
|
+
if (isSub) {
|
|
9329
|
+
continue OUTER;
|
|
9330
|
+
}
|
|
9331
|
+
}
|
|
9332
|
+
if (sawNonNull) {
|
|
9333
|
+
return false;
|
|
9334
|
+
}
|
|
9335
|
+
}
|
|
9336
|
+
return true;
|
|
9337
|
+
};
|
|
9338
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
9339
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
9340
|
+
var simpleSubset = (sub, dom, options) => {
|
|
9341
|
+
if (sub === dom) {
|
|
9342
|
+
return true;
|
|
9343
|
+
}
|
|
9344
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
9345
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
9346
|
+
return true;
|
|
9347
|
+
} else if (options.includePrerelease) {
|
|
9348
|
+
sub = minimumVersionWithPreRelease;
|
|
9349
|
+
} else {
|
|
9350
|
+
sub = minimumVersion;
|
|
9351
|
+
}
|
|
9352
|
+
}
|
|
9353
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
9354
|
+
if (options.includePrerelease) {
|
|
9355
|
+
return true;
|
|
9356
|
+
} else {
|
|
9357
|
+
dom = minimumVersion;
|
|
9358
|
+
}
|
|
9359
|
+
}
|
|
9360
|
+
const eqSet = new Set;
|
|
9361
|
+
let gt, lt;
|
|
9362
|
+
for (const c of sub) {
|
|
9363
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
9364
|
+
gt = higherGT(gt, c, options);
|
|
9365
|
+
} else if (c.operator === "<" || c.operator === "<=") {
|
|
9366
|
+
lt = lowerLT(lt, c, options);
|
|
9367
|
+
} else {
|
|
9368
|
+
eqSet.add(c.semver);
|
|
9369
|
+
}
|
|
9370
|
+
}
|
|
9371
|
+
if (eqSet.size > 1) {
|
|
9372
|
+
return null;
|
|
9373
|
+
}
|
|
9374
|
+
let gtltComp;
|
|
9375
|
+
if (gt && lt) {
|
|
9376
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
9377
|
+
if (gtltComp > 0) {
|
|
9378
|
+
return null;
|
|
9379
|
+
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
9380
|
+
return null;
|
|
9381
|
+
}
|
|
9382
|
+
}
|
|
9383
|
+
for (const eq of eqSet) {
|
|
9384
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
9385
|
+
return null;
|
|
9386
|
+
}
|
|
9387
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
9388
|
+
return null;
|
|
9389
|
+
}
|
|
9390
|
+
for (const c of dom) {
|
|
9391
|
+
if (!satisfies(eq, String(c), options)) {
|
|
9392
|
+
return false;
|
|
9393
|
+
}
|
|
9394
|
+
}
|
|
9395
|
+
return true;
|
|
9396
|
+
}
|
|
9397
|
+
let higher, lower;
|
|
9398
|
+
let hasDomLT, hasDomGT;
|
|
9399
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
9400
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
9401
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
9402
|
+
needDomLTPre = false;
|
|
9403
|
+
}
|
|
9404
|
+
for (const c of dom) {
|
|
9405
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
9406
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
9407
|
+
if (gt) {
|
|
9408
|
+
if (needDomGTPre) {
|
|
9409
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
9410
|
+
needDomGTPre = false;
|
|
9411
|
+
}
|
|
9412
|
+
}
|
|
9413
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
9414
|
+
higher = higherGT(gt, c, options);
|
|
9415
|
+
if (higher === c && higher !== gt) {
|
|
9416
|
+
return false;
|
|
9417
|
+
}
|
|
9418
|
+
} else if (gt.operator === ">=" && !c.test(gt.semver)) {
|
|
9419
|
+
return false;
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9422
|
+
if (lt) {
|
|
9423
|
+
if (needDomLTPre) {
|
|
9424
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
9425
|
+
needDomLTPre = false;
|
|
9426
|
+
}
|
|
9427
|
+
}
|
|
9428
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
9429
|
+
lower = lowerLT(lt, c, options);
|
|
9430
|
+
if (lower === c && lower !== lt) {
|
|
9431
|
+
return false;
|
|
9432
|
+
}
|
|
9433
|
+
} else if (lt.operator === "<=" && !c.test(lt.semver)) {
|
|
9434
|
+
return false;
|
|
9435
|
+
}
|
|
9436
|
+
}
|
|
9437
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
9438
|
+
return false;
|
|
9439
|
+
}
|
|
9440
|
+
}
|
|
9441
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
9442
|
+
return false;
|
|
9443
|
+
}
|
|
9444
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
9445
|
+
return false;
|
|
9446
|
+
}
|
|
9447
|
+
if (needDomGTPre || needDomLTPre) {
|
|
9448
|
+
return false;
|
|
9449
|
+
}
|
|
9450
|
+
return true;
|
|
9451
|
+
};
|
|
9452
|
+
var higherGT = (a, b, options) => {
|
|
9453
|
+
if (!a) {
|
|
9454
|
+
return b;
|
|
9455
|
+
}
|
|
9456
|
+
const comp = compare(a.semver, b.semver, options);
|
|
9457
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
9458
|
+
};
|
|
9459
|
+
var lowerLT = (a, b, options) => {
|
|
9460
|
+
if (!a) {
|
|
9461
|
+
return b;
|
|
9462
|
+
}
|
|
9463
|
+
const comp = compare(a.semver, b.semver, options);
|
|
9464
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
9465
|
+
};
|
|
9466
|
+
module.exports = subset;
|
|
9467
|
+
});
|
|
9468
|
+
|
|
9469
|
+
// node_modules/semver/index.js
|
|
9470
|
+
var require_semver2 = __commonJS((exports, module) => {
|
|
9471
|
+
var internalRe = require_re();
|
|
9472
|
+
var constants = require_constants();
|
|
9473
|
+
var SemVer = require_semver();
|
|
9474
|
+
var identifiers = require_identifiers();
|
|
9475
|
+
var parse = require_parse();
|
|
9476
|
+
var valid = require_valid();
|
|
9477
|
+
var clean = require_clean();
|
|
9478
|
+
var inc = require_inc();
|
|
9479
|
+
var diff = require_diff();
|
|
9480
|
+
var major = require_major();
|
|
9481
|
+
var minor = require_minor();
|
|
9482
|
+
var patch = require_patch();
|
|
9483
|
+
var prerelease = require_prerelease();
|
|
9484
|
+
var compare = require_compare();
|
|
9485
|
+
var rcompare = require_rcompare();
|
|
9486
|
+
var compareLoose = require_compare_loose();
|
|
9487
|
+
var compareBuild = require_compare_build();
|
|
9488
|
+
var sort = require_sort();
|
|
9489
|
+
var rsort = require_rsort();
|
|
9490
|
+
var gt = require_gt();
|
|
9491
|
+
var lt = require_lt();
|
|
9492
|
+
var eq = require_eq();
|
|
9493
|
+
var neq = require_neq();
|
|
9494
|
+
var gte = require_gte();
|
|
9495
|
+
var lte = require_lte();
|
|
9496
|
+
var cmp = require_cmp();
|
|
9497
|
+
var coerce = require_coerce();
|
|
9498
|
+
var truncate2 = require_truncate();
|
|
9499
|
+
var Comparator = require_comparator();
|
|
9500
|
+
var Range = require_range();
|
|
9501
|
+
var satisfies = require_satisfies();
|
|
9502
|
+
var toComparators = require_to_comparators();
|
|
9503
|
+
var maxSatisfying = require_max_satisfying();
|
|
9504
|
+
var minSatisfying = require_min_satisfying();
|
|
9505
|
+
var minVersion = require_min_version();
|
|
9506
|
+
var validRange = require_valid2();
|
|
9507
|
+
var outside = require_outside();
|
|
9508
|
+
var gtr = require_gtr();
|
|
9509
|
+
var ltr = require_ltr();
|
|
9510
|
+
var intersects = require_intersects();
|
|
9511
|
+
var simplifyRange = require_simplify();
|
|
9512
|
+
var subset = require_subset();
|
|
9513
|
+
module.exports = {
|
|
9514
|
+
parse,
|
|
9515
|
+
valid,
|
|
9516
|
+
clean,
|
|
9517
|
+
inc,
|
|
9518
|
+
diff,
|
|
9519
|
+
major,
|
|
9520
|
+
minor,
|
|
9521
|
+
patch,
|
|
9522
|
+
prerelease,
|
|
9523
|
+
compare,
|
|
9524
|
+
rcompare,
|
|
9525
|
+
compareLoose,
|
|
9526
|
+
compareBuild,
|
|
9527
|
+
sort,
|
|
9528
|
+
rsort,
|
|
9529
|
+
gt,
|
|
9530
|
+
lt,
|
|
9531
|
+
eq,
|
|
9532
|
+
neq,
|
|
9533
|
+
gte,
|
|
9534
|
+
lte,
|
|
9535
|
+
cmp,
|
|
9536
|
+
coerce,
|
|
9537
|
+
truncate: truncate2,
|
|
9538
|
+
Comparator,
|
|
9539
|
+
Range,
|
|
9540
|
+
satisfies,
|
|
9541
|
+
toComparators,
|
|
9542
|
+
maxSatisfying,
|
|
9543
|
+
minSatisfying,
|
|
9544
|
+
minVersion,
|
|
9545
|
+
validRange,
|
|
9546
|
+
outside,
|
|
9547
|
+
gtr,
|
|
9548
|
+
ltr,
|
|
9549
|
+
intersects,
|
|
9550
|
+
simplifyRange,
|
|
9551
|
+
subset,
|
|
9552
|
+
SemVer,
|
|
9553
|
+
re: internalRe.re,
|
|
9554
|
+
src: internalRe.src,
|
|
9555
|
+
tokens: internalRe.t,
|
|
9556
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
9557
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
9558
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
9559
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
9560
|
+
};
|
|
9561
|
+
});
|
|
9562
|
+
|
|
9563
|
+
// node_modules/@kelceyp/clibuilder/dist/errors/index.js
|
|
9564
|
+
init_CLIError();
|
|
9565
|
+
// node_modules/@kelceyp/clibuilder/dist/builders/App.js
|
|
9566
|
+
init_CLIError();
|
|
9567
|
+
|
|
9568
|
+
// node_modules/@kelceyp/clibuilder/dist/dispatch/registry.js
|
|
9569
|
+
class CommandRegistry {
|
|
9570
|
+
commands = new Map;
|
|
9571
|
+
groups = new Map;
|
|
9572
|
+
aliases = new Map;
|
|
9573
|
+
register(item, parentPath = []) {
|
|
9574
|
+
const fullPath = [...parentPath, item.name].join("/");
|
|
9575
|
+
if (item.type === "command") {
|
|
9576
|
+
const command = item;
|
|
9577
|
+
this.commands.set(fullPath, command);
|
|
9578
|
+
if (command.aliases) {
|
|
9579
|
+
for (const alias of command.aliases) {
|
|
9580
|
+
const aliasPath = [...parentPath, alias].join("/");
|
|
9581
|
+
this.aliases.set(aliasPath, fullPath);
|
|
9582
|
+
}
|
|
9583
|
+
}
|
|
9584
|
+
} else {
|
|
9585
|
+
const group = item;
|
|
9586
|
+
this.groups.set(fullPath, group);
|
|
9587
|
+
for (const child of group.children) {
|
|
9588
|
+
this.register(child, [...parentPath, item.name]);
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
}
|
|
9592
|
+
lookup(pathSegments) {
|
|
9593
|
+
if (pathSegments.length === 0) {
|
|
9594
|
+
return {
|
|
9595
|
+
type: "unknown",
|
|
9596
|
+
matchedPath: [],
|
|
9597
|
+
remainingPath: []
|
|
9598
|
+
};
|
|
9599
|
+
}
|
|
9600
|
+
for (let i = pathSegments.length;i > 0; i--) {
|
|
9601
|
+
const testPath = pathSegments.slice(0, i);
|
|
9602
|
+
const testPathStr = testPath.join("/");
|
|
9603
|
+
const canonicalPath = this.aliases.get(testPathStr) || testPathStr;
|
|
9604
|
+
const command = this.commands.get(canonicalPath);
|
|
9605
|
+
if (command) {
|
|
9606
|
+
return {
|
|
9607
|
+
type: "command",
|
|
9608
|
+
command,
|
|
9609
|
+
matchedPath: testPath
|
|
9610
|
+
};
|
|
9611
|
+
}
|
|
9612
|
+
const group = this.groups.get(canonicalPath);
|
|
9613
|
+
if (group) {
|
|
9614
|
+
const remaining = pathSegments.slice(i);
|
|
9615
|
+
if (remaining.length === 0) {
|
|
9616
|
+
return {
|
|
9617
|
+
type: "group",
|
|
9618
|
+
group,
|
|
9619
|
+
matchedPath: testPath
|
|
9620
|
+
};
|
|
9621
|
+
}
|
|
9622
|
+
}
|
|
9623
|
+
}
|
|
9624
|
+
let matchedCount = 0;
|
|
9625
|
+
for (let i = 1;i <= pathSegments.length; i++) {
|
|
9626
|
+
const testPath = pathSegments.slice(0, i);
|
|
9627
|
+
const testPathStr = testPath.join("/");
|
|
9628
|
+
const canonicalPath = this.aliases.get(testPathStr) || testPathStr;
|
|
9629
|
+
if (this.groups.has(canonicalPath) || this.commands.has(canonicalPath)) {
|
|
9630
|
+
matchedCount = i;
|
|
9631
|
+
}
|
|
9632
|
+
}
|
|
9633
|
+
return {
|
|
9634
|
+
type: "unknown",
|
|
9635
|
+
matchedPath: pathSegments.slice(0, matchedCount),
|
|
9636
|
+
remainingPath: pathSegments.slice(matchedCount)
|
|
9637
|
+
};
|
|
9638
|
+
}
|
|
9639
|
+
getTopLevel() {
|
|
9640
|
+
const items = [];
|
|
9641
|
+
for (const [path, command] of this.commands.entries()) {
|
|
9642
|
+
if (!path.includes("/")) {
|
|
9643
|
+
items.push(command);
|
|
9644
|
+
}
|
|
9645
|
+
}
|
|
9646
|
+
for (const [path, group] of this.groups.entries()) {
|
|
9647
|
+
if (!path.includes("/")) {
|
|
9648
|
+
items.push(group);
|
|
9649
|
+
}
|
|
9650
|
+
}
|
|
9651
|
+
return items;
|
|
9652
|
+
}
|
|
9653
|
+
}
|
|
9654
|
+
|
|
9655
|
+
// node_modules/@kelceyp/clibuilder/dist/dispatch/parser.js
|
|
9656
|
+
function parseCommandPath(argv) {
|
|
9657
|
+
const commandPath = [];
|
|
9658
|
+
let i = 0;
|
|
9659
|
+
for (;i < argv.length; i++) {
|
|
9660
|
+
const arg = argv[i];
|
|
9661
|
+
if (!arg) {
|
|
9662
|
+
break;
|
|
9663
|
+
}
|
|
9664
|
+
if (arg.startsWith("-")) {
|
|
9665
|
+
break;
|
|
9666
|
+
}
|
|
9667
|
+
commandPath.push(arg);
|
|
9668
|
+
}
|
|
9669
|
+
const paramArgv = argv.slice(i);
|
|
9670
|
+
return {
|
|
9671
|
+
commandPath,
|
|
9672
|
+
paramArgv
|
|
9673
|
+
};
|
|
9674
|
+
}
|
|
9675
|
+
|
|
9676
|
+
// node_modules/@kelceyp/clibuilder/dist/dispatch/dispatcher.js
|
|
9677
|
+
class Dispatcher {
|
|
9678
|
+
registry;
|
|
9679
|
+
strict;
|
|
9680
|
+
constructor(app) {
|
|
9681
|
+
this.registry = new CommandRegistry;
|
|
9682
|
+
this.strict = app.strict ?? false;
|
|
9683
|
+
for (const item of app.commands) {
|
|
9684
|
+
this.registry.register(item);
|
|
9685
|
+
}
|
|
9686
|
+
}
|
|
9687
|
+
dispatch(argv) {
|
|
9688
|
+
if (argv.length === 0) {
|
|
9689
|
+
return { type: "show_help" };
|
|
9690
|
+
}
|
|
9691
|
+
if (argv[0] === "--help" || argv[0] === "-h") {
|
|
9692
|
+
return { type: "show_help" };
|
|
9693
|
+
}
|
|
9694
|
+
const { commandPath, paramArgv } = parseCommandPath(argv);
|
|
9695
|
+
if (commandPath.length === 0) {
|
|
9696
|
+
return { type: "show_help" };
|
|
9697
|
+
}
|
|
9698
|
+
const result = this.registry.lookup(commandPath);
|
|
9699
|
+
if (result.type === "command") {
|
|
9700
|
+
const unmatchedSegments = commandPath.slice(result.matchedPath.length);
|
|
9701
|
+
const actualParamArgv = [...unmatchedSegments, ...paramArgv];
|
|
9702
|
+
return {
|
|
9703
|
+
type: "command",
|
|
9704
|
+
command: result.command,
|
|
9705
|
+
paramArgv: actualParamArgv,
|
|
9706
|
+
matchedPath: result.matchedPath
|
|
9707
|
+
};
|
|
9708
|
+
}
|
|
9709
|
+
if (result.type === "group" && result.group) {
|
|
9710
|
+
if (result.group.defaultChild) {
|
|
9711
|
+
const defaultChildPath = [...commandPath, result.group.defaultChild];
|
|
9712
|
+
const recursiveResult = this.registry.lookup(defaultChildPath);
|
|
9713
|
+
if (recursiveResult.type === "command") {
|
|
9714
|
+
return {
|
|
9715
|
+
type: "command",
|
|
9716
|
+
command: recursiveResult.command,
|
|
9717
|
+
paramArgv,
|
|
9718
|
+
matchedPath: recursiveResult.matchedPath
|
|
9719
|
+
};
|
|
9720
|
+
}
|
|
9721
|
+
if (recursiveResult.type === "group") {
|
|
9722
|
+
return {
|
|
9723
|
+
type: "group_without_subcommand",
|
|
9724
|
+
group: recursiveResult.group,
|
|
9725
|
+
matchedPath: recursiveResult.matchedPath
|
|
9726
|
+
};
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
return {
|
|
9730
|
+
type: "group_without_subcommand",
|
|
9731
|
+
group: result.group,
|
|
9732
|
+
matchedPath: result.matchedPath
|
|
9733
|
+
};
|
|
9734
|
+
}
|
|
9735
|
+
const unknownSegment = result.remainingPath?.[0] || commandPath[commandPath.length - 1];
|
|
9736
|
+
const parentPath = result.matchedPath.join(" ");
|
|
9737
|
+
let error;
|
|
9738
|
+
if (this.strict) {
|
|
9739
|
+
if (parentPath) {
|
|
9740
|
+
error = `Unknown command: "${unknownSegment}" in "${parentPath}"`;
|
|
9741
|
+
} else {
|
|
9742
|
+
error = `Unknown command: "${unknownSegment}"`;
|
|
9743
|
+
}
|
|
9744
|
+
} else {
|
|
9745
|
+
if (parentPath) {
|
|
7885
9746
|
error = `Unknown command: "${unknownSegment}" in "${parentPath}". Use --help to see available commands.`;
|
|
7886
9747
|
} else {
|
|
7887
9748
|
error = `Unknown command: "${unknownSegment}". Use --help to see available commands.`;
|
|
@@ -8783,7 +10644,7 @@ function isProcessAlive(pid) {
|
|
|
8783
10644
|
}
|
|
8784
10645
|
}
|
|
8785
10646
|
function getPm2Name(envDir) {
|
|
8786
|
-
return `caw-${path3.basename(envDir)}`;
|
|
10647
|
+
return `caw-${path3.basename(envDir).replace(/^\./, "")}`;
|
|
8787
10648
|
}
|
|
8788
10649
|
function isPm2Installed() {
|
|
8789
10650
|
try {
|
|
@@ -8795,10 +10656,10 @@ function isPm2Installed() {
|
|
|
8795
10656
|
}
|
|
8796
10657
|
function createPidManager(envDir) {
|
|
8797
10658
|
return {
|
|
8798
|
-
start(mainJsPath, envVars) {
|
|
10659
|
+
start(mainJsPath, envVars, nodeArgs = []) {
|
|
8799
10660
|
const logPath = logFilePath(envDir);
|
|
8800
10661
|
const logFd = fs4.openSync(logPath, "a");
|
|
8801
|
-
const child = spawn(process.execPath, [mainJsPath], {
|
|
10662
|
+
const child = spawn(process.execPath, [...nodeArgs, mainJsPath], {
|
|
8802
10663
|
detached: true,
|
|
8803
10664
|
stdio: ["ignore", logFd, logFd],
|
|
8804
10665
|
env: { ...process.env, ...envVars }
|
|
@@ -8857,6 +10718,8 @@ function createPm2Manager(envDir, checkPm2 = isPm2Installed) {
|
|
|
8857
10718
|
return false;
|
|
8858
10719
|
try {
|
|
8859
10720
|
pm2Exec(`stop ${name}`);
|
|
10721
|
+
} catch {}
|
|
10722
|
+
try {
|
|
8860
10723
|
pm2Exec(`delete ${name}`);
|
|
8861
10724
|
return true;
|
|
8862
10725
|
} catch {
|
|
@@ -8864,15 +10727,19 @@ function createPm2Manager(envDir, checkPm2 = isPm2Installed) {
|
|
|
8864
10727
|
}
|
|
8865
10728
|
}
|
|
8866
10729
|
return {
|
|
8867
|
-
start(mainJsPath, envVars) {
|
|
10730
|
+
start(mainJsPath, envVars, nodeArgs = []) {
|
|
8868
10731
|
if (!checkPm2()) {
|
|
8869
10732
|
throw new Error(`PM2 is configured as the process manager but is not installed.
|
|
8870
10733
|
` + `Install PM2 with: npm install -g pm2
|
|
8871
10734
|
` + 'Or switch to PID mode by setting "process_manager": "pid" in config.json');
|
|
8872
10735
|
}
|
|
10736
|
+
try {
|
|
10737
|
+
pm2Exec(`delete ${name}`);
|
|
10738
|
+
} catch {}
|
|
8873
10739
|
const logPath = logFilePath(envDir);
|
|
8874
10740
|
const envArgs = Object.entries(envVars).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
8875
|
-
|
|
10741
|
+
const nodeArgsStr = nodeArgs.length > 0 ? ` --node-args="${nodeArgs.map((a) => `\\"${a}\\"`).join(" ")}"` : "";
|
|
10742
|
+
execSync2(`${envArgs} pm2 start ${mainJsPath} --name ${name}${nodeArgsStr} --output ${logPath} --error ${logPath} --merge-logs`, { stdio: "inherit", env: { ...process.env, ...envVars } });
|
|
8876
10743
|
return name;
|
|
8877
10744
|
},
|
|
8878
10745
|
isRunning() {
|
|
@@ -8914,6 +10781,16 @@ function createProcessManager(config, envDir) {
|
|
|
8914
10781
|
}
|
|
8915
10782
|
return createPidManager(envDir);
|
|
8916
10783
|
}
|
|
10784
|
+
async function waitForExit(pm, intervalMs, maxWaitMs) {
|
|
10785
|
+
const iterations = Math.ceil(maxWaitMs / intervalMs);
|
|
10786
|
+
for (let i = 0;i < iterations; i++) {
|
|
10787
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
10788
|
+
const state = pm.isRunning();
|
|
10789
|
+
if (!state.running)
|
|
10790
|
+
return true;
|
|
10791
|
+
}
|
|
10792
|
+
return false;
|
|
10793
|
+
}
|
|
8917
10794
|
|
|
8918
10795
|
// src/server-info.js
|
|
8919
10796
|
import fs5 from "node:fs";
|
|
@@ -8982,10 +10859,89 @@ function resolveEnvDir(rawEnvDir) {
|
|
|
8982
10859
|
function configExists(envDir) {
|
|
8983
10860
|
return fs6.existsSync(path5.join(envDir, "config.json"));
|
|
8984
10861
|
}
|
|
10862
|
+
function validateEnvFile(envDir) {
|
|
10863
|
+
const envFilePath = path5.join(envDir, ".env");
|
|
10864
|
+
if (!fs6.existsSync(envFilePath)) {
|
|
10865
|
+
return {
|
|
10866
|
+
ok: false,
|
|
10867
|
+
message: `Error: Environment file not found: ${envFilePath}
|
|
10868
|
+
Create it with your configuration variables (e.g., OPENAI_API_KEY, CLAUDE_CODE_OAUTH_TOKEN).`
|
|
10869
|
+
};
|
|
10870
|
+
}
|
|
10871
|
+
const content = fs6.readFileSync(envFilePath, "utf8");
|
|
10872
|
+
const lines = content.split(`
|
|
10873
|
+
`);
|
|
10874
|
+
for (let i = 0;i < lines.length; i++) {
|
|
10875
|
+
const line = lines[i].trim();
|
|
10876
|
+
if (line === "" || line.startsWith("#"))
|
|
10877
|
+
continue;
|
|
10878
|
+
const stripped = line.startsWith("export ") ? line.slice(7) : line;
|
|
10879
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*=/.test(stripped)) {
|
|
10880
|
+
return {
|
|
10881
|
+
ok: false,
|
|
10882
|
+
message: `Error: Malformed line ${i + 1} in ${envFilePath}: ${line}
|
|
10883
|
+
Each non-comment line must match KEY=VALUE or export KEY=VALUE.`
|
|
10884
|
+
};
|
|
10885
|
+
}
|
|
10886
|
+
}
|
|
10887
|
+
return { ok: true, message: null, path: envFilePath };
|
|
10888
|
+
}
|
|
10889
|
+
var MAX_LOG_SIZE = 10 * 1024 * 1024;
|
|
10890
|
+
var LOG_RETAIN = 5;
|
|
10891
|
+
function rotateLogIfNeeded(envDir) {
|
|
10892
|
+
try {
|
|
10893
|
+
const logPath = path5.join(envDir, "server.log");
|
|
10894
|
+
if (!fs6.existsSync(logPath))
|
|
10895
|
+
return;
|
|
10896
|
+
const stats = fs6.statSync(logPath);
|
|
10897
|
+
if (stats.size <= MAX_LOG_SIZE)
|
|
10898
|
+
return;
|
|
10899
|
+
const now = new Date;
|
|
10900
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
10901
|
+
const timestamp = [
|
|
10902
|
+
now.getFullYear(),
|
|
10903
|
+
pad2(now.getMonth() + 1),
|
|
10904
|
+
pad2(now.getDate())
|
|
10905
|
+
].join("-") + "_" + [
|
|
10906
|
+
pad2(now.getHours()),
|
|
10907
|
+
pad2(now.getMinutes()),
|
|
10908
|
+
pad2(now.getSeconds())
|
|
10909
|
+
].join("-");
|
|
10910
|
+
fs6.renameSync(logPath, `${logPath}.${timestamp}`);
|
|
10911
|
+
console.log(`Rotated server.log (was ${(stats.size / 1024 / 1024).toFixed(1)} MB)`);
|
|
10912
|
+
const rotated = fs6.readdirSync(envDir).filter((f) => f.startsWith("server.log.")).map((f) => ({ name: f, mtime: fs6.statSync(path5.join(envDir, f)).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
10913
|
+
for (const file of rotated.slice(LOG_RETAIN)) {
|
|
10914
|
+
fs6.unlinkSync(path5.join(envDir, file.name));
|
|
10915
|
+
}
|
|
10916
|
+
} catch (err) {
|
|
10917
|
+
console.warn(`Warning: log rotation failed: ${err.message}`);
|
|
10918
|
+
}
|
|
10919
|
+
}
|
|
10920
|
+
function buildEnvNodeArgs(envDir) {
|
|
10921
|
+
const envFilePath = path5.join(envDir, ".env");
|
|
10922
|
+
return [`--env-file=${envFilePath}`];
|
|
10923
|
+
}
|
|
8985
10924
|
function bootstrap(envDir) {
|
|
8986
10925
|
fs6.mkdirSync(envDir, { recursive: true });
|
|
8987
10926
|
fs6.mkdirSync(path5.join(envDir, "assets"), { recursive: true });
|
|
8988
10927
|
writeConfig(envDir, { ...DEFAULTS });
|
|
10928
|
+
const envFilePath = path5.join(envDir, ".env");
|
|
10929
|
+
if (!fs6.existsSync(envFilePath)) {
|
|
10930
|
+
fs6.writeFileSync(envFilePath, [
|
|
10931
|
+
"# CAW environment configuration",
|
|
10932
|
+
"# Uncomment and set values as needed",
|
|
10933
|
+
"",
|
|
10934
|
+
"# Agent credentials",
|
|
10935
|
+
"#OPENAI_API_KEY=",
|
|
10936
|
+
"#CLAUDE_CODE_OAUTH_TOKEN=",
|
|
10937
|
+
"",
|
|
10938
|
+
"# Logging",
|
|
10939
|
+
"#DEBUG=caw:*",
|
|
10940
|
+
"#LOG_LEVEL=warn",
|
|
10941
|
+
""
|
|
10942
|
+
].join(`
|
|
10943
|
+
`));
|
|
10944
|
+
}
|
|
8989
10945
|
}
|
|
8990
10946
|
function buildChangeSummary(active, pending) {
|
|
8991
10947
|
const changes = [];
|
|
@@ -9020,7 +10976,7 @@ async function pollHealth(port, maxRetries = 10, intervalMs = 1000) {
|
|
|
9020
10976
|
}
|
|
9021
10977
|
function attemptInstallServer() {
|
|
9022
10978
|
try {
|
|
9023
|
-
execSync4("npm install -g @kelceyp/caw-server@^1", { stdio: "inherit" });
|
|
10979
|
+
execSync4("npm install -g @kelceyp/caw-server@^1 --loglevel=error", { stdio: "inherit" });
|
|
9024
10980
|
return true;
|
|
9025
10981
|
} catch {
|
|
9026
10982
|
return false;
|
|
@@ -9105,12 +11061,20 @@ To install nvm and get a user-owned prefix:`);
|
|
|
9105
11061
|
}
|
|
9106
11062
|
console.log(`Installed caw-server v${serverInfo.version}`);
|
|
9107
11063
|
}
|
|
11064
|
+
const envCheck = validateEnvFile(envDir);
|
|
11065
|
+
if (!envCheck.ok) {
|
|
11066
|
+
console.error(envCheck.message);
|
|
11067
|
+
process.exit(1);
|
|
11068
|
+
}
|
|
11069
|
+
console.log(`Found environment file: ${envCheck.path}`);
|
|
11070
|
+
rotateLogIfNeeded(envDir);
|
|
9108
11071
|
const envVars = {
|
|
9109
11072
|
CAW_PORT: String(activeConfig.port),
|
|
9110
11073
|
CAW_ENV_DIR: envDir
|
|
9111
11074
|
};
|
|
11075
|
+
const nodeArgs = buildEnvNodeArgs(envDir);
|
|
9112
11076
|
const pm2 = createProcessManager(activeConfig, envDir);
|
|
9113
|
-
const id = pm2.start(serverInfo.mainJsPath, envVars);
|
|
11077
|
+
const id = pm2.start(serverInfo.mainJsPath, envVars, nodeArgs);
|
|
9114
11078
|
const modeLabel = pm2.mode === "pm2" ? `pm2: ${id}` : `PID: ${id}`;
|
|
9115
11079
|
console.log(`Starting server (${modeLabel})...`);
|
|
9116
11080
|
const started = await pollHealth(activeConfig.port);
|
|
@@ -9149,16 +11113,6 @@ async function checkHealth2(port) {
|
|
|
9149
11113
|
return { reachable: false, healthy: false, data: null };
|
|
9150
11114
|
}
|
|
9151
11115
|
}
|
|
9152
|
-
async function waitForExit(pm, intervalMs, maxWaitMs) {
|
|
9153
|
-
const iterations = Math.ceil(maxWaitMs / intervalMs);
|
|
9154
|
-
for (let i = 0;i < iterations; i++) {
|
|
9155
|
-
await new Promise((r) => setTimeout(r, intervalMs));
|
|
9156
|
-
const state = pm.isRunning();
|
|
9157
|
-
if (!state.running)
|
|
9158
|
-
return true;
|
|
9159
|
-
}
|
|
9160
|
-
return false;
|
|
9161
|
-
}
|
|
9162
11116
|
var create3 = () => {
|
|
9163
11117
|
return createCommand("stop").summary("Stop the caw server").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).param((p) => p.name("force").type("boolean").flag("force").default(false)).run(async (ctx) => {
|
|
9164
11118
|
const envDir = resolveEnvDir2(ctx.params["env-dir"]);
|
|
@@ -9222,17 +11176,63 @@ var create3 = () => {
|
|
|
9222
11176
|
var stop_default = Object.freeze({ create: create3 });
|
|
9223
11177
|
|
|
9224
11178
|
// src/commands/status.js
|
|
11179
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
11180
|
+
import fs9 from "node:fs";
|
|
11181
|
+
import path8 from "node:path";
|
|
11182
|
+
import os4 from "node:os";
|
|
11183
|
+
|
|
11184
|
+
// src/registry.js
|
|
9225
11185
|
import fs8 from "node:fs";
|
|
9226
11186
|
import path7 from "node:path";
|
|
9227
|
-
|
|
11187
|
+
var CACHE_FILENAME = "caw-cache.json";
|
|
11188
|
+
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
11189
|
+
var DEFAULT_TTL_MS = 60 * 60 * 1000;
|
|
11190
|
+
async function fetchLatestVersion(packageName, { timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
|
|
11191
|
+
const url = `https://registry.npmjs.org/${encodeURIComponent(packageName)}`;
|
|
11192
|
+
const response = await fetch(url, {
|
|
11193
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" },
|
|
11194
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
11195
|
+
});
|
|
11196
|
+
if (!response.ok)
|
|
11197
|
+
throw new Error(`npm registry returned ${response.status}`);
|
|
11198
|
+
const data = await response.json();
|
|
11199
|
+
return data["dist-tags"].latest;
|
|
11200
|
+
}
|
|
11201
|
+
function readCache(envDir) {
|
|
11202
|
+
const cachePath = path7.join(envDir, CACHE_FILENAME);
|
|
11203
|
+
try {
|
|
11204
|
+
return JSON.parse(fs8.readFileSync(cachePath, "utf8"));
|
|
11205
|
+
} catch {
|
|
11206
|
+
return null;
|
|
11207
|
+
}
|
|
11208
|
+
}
|
|
11209
|
+
function writeCache(envDir, cache) {
|
|
11210
|
+
const cachePath = path7.join(envDir, CACHE_FILENAME);
|
|
11211
|
+
const tmp = cachePath + ".tmp";
|
|
11212
|
+
fs8.writeFileSync(tmp, JSON.stringify(cache, null, 2));
|
|
11213
|
+
fs8.renameSync(tmp, cachePath);
|
|
11214
|
+
}
|
|
11215
|
+
function isCacheStale(cache, ttlMs = DEFAULT_TTL_MS) {
|
|
11216
|
+
if (!cache)
|
|
11217
|
+
return true;
|
|
11218
|
+
const checkedAt = cache.server?.checkedAt ?? cache.launcher?.checkedAt;
|
|
11219
|
+
if (!checkedAt)
|
|
11220
|
+
return true;
|
|
11221
|
+
const checkedTime = new Date(checkedAt).getTime();
|
|
11222
|
+
if (Number.isNaN(checkedTime))
|
|
11223
|
+
return true;
|
|
11224
|
+
return Date.now() - checkedTime > ttlMs;
|
|
11225
|
+
}
|
|
11226
|
+
|
|
11227
|
+
// src/commands/status.js
|
|
9228
11228
|
function resolveEnvDir3(rawEnvDir) {
|
|
9229
11229
|
if (rawEnvDir.startsWith("~")) {
|
|
9230
|
-
rawEnvDir =
|
|
11230
|
+
rawEnvDir = path8.join(os4.homedir(), rawEnvDir.slice(1));
|
|
9231
11231
|
}
|
|
9232
|
-
return
|
|
11232
|
+
return path8.resolve(rawEnvDir);
|
|
9233
11233
|
}
|
|
9234
11234
|
function configExists3(envDir) {
|
|
9235
|
-
return
|
|
11235
|
+
return fs9.existsSync(path8.join(envDir, "config.json"));
|
|
9236
11236
|
}
|
|
9237
11237
|
async function fetchHealth(port) {
|
|
9238
11238
|
try {
|
|
@@ -9275,7 +11275,7 @@ function formatUptime(ms) {
|
|
|
9275
11275
|
function getUptimeFromPidFile(envDir) {
|
|
9276
11276
|
const filePath = pidFilePath(envDir);
|
|
9277
11277
|
try {
|
|
9278
|
-
const stat =
|
|
11278
|
+
const stat = fs9.statSync(filePath);
|
|
9279
11279
|
return Date.now() - stat.mtimeMs;
|
|
9280
11280
|
} catch {
|
|
9281
11281
|
return null;
|
|
@@ -9290,7 +11290,7 @@ function getUptimeFromPm2(runState) {
|
|
|
9290
11290
|
var create4 = () => {
|
|
9291
11291
|
return createCommand("status").summary("Show caw server status").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).run(async (ctx) => {
|
|
9292
11292
|
const envDir = resolveEnvDir3(ctx.params["env-dir"]);
|
|
9293
|
-
if (!
|
|
11293
|
+
if (!fs9.existsSync(envDir) || !configExists3(envDir)) {
|
|
9294
11294
|
console.log("Server: not configured");
|
|
9295
11295
|
console.log(` No environment found at ${envDir}`);
|
|
9296
11296
|
process.exit(0);
|
|
@@ -9307,6 +11307,16 @@ var create4 = () => {
|
|
|
9307
11307
|
}
|
|
9308
11308
|
process.exit(0);
|
|
9309
11309
|
}
|
|
11310
|
+
const cache = readCache(envDir);
|
|
11311
|
+
let registryPromise = null;
|
|
11312
|
+
if (!cache || isCacheStale(cache)) {
|
|
11313
|
+
registryPromise = fetchLatestVersion("@kelceyp/caw-server", { timeoutMs: 3000 }).then((latest) => {
|
|
11314
|
+
const now = new Date().toISOString();
|
|
11315
|
+
const updatedCache = { ...cache, server: { latest, checkedAt: now } };
|
|
11316
|
+
writeCache(envDir, updatedCache);
|
|
11317
|
+
return latest;
|
|
11318
|
+
}).catch(() => null);
|
|
11319
|
+
}
|
|
9310
11320
|
const processLabel = pm.mode === "pm2" ? `running (pm2: ${runState.pm2Name})` : `running (PID ${runState.pid})`;
|
|
9311
11321
|
const health = await fetchHealth(config.port);
|
|
9312
11322
|
const info = await fetchInfo(config.port);
|
|
@@ -9314,10 +11324,23 @@ var create4 = () => {
|
|
|
9314
11324
|
const uptimeMs = pm.mode === "pm2" ? getUptimeFromPm2(runState) : getUptimeFromPidFile(envDir);
|
|
9315
11325
|
const uptimeLabel = uptimeMs !== null ? formatUptime(uptimeMs) : "unknown";
|
|
9316
11326
|
const version = info?.version || "unknown";
|
|
11327
|
+
let latestVersion = cache?.server?.latest ?? null;
|
|
11328
|
+
if (registryPromise) {
|
|
11329
|
+
const fetched = await registryPromise;
|
|
11330
|
+
if (fetched)
|
|
11331
|
+
latestVersion = fetched;
|
|
11332
|
+
}
|
|
9317
11333
|
console.log(`Server: ${processLabel}`);
|
|
9318
11334
|
console.log(`Health: ${healthStatus}`);
|
|
9319
11335
|
console.log(`Uptime: ${uptimeLabel}`);
|
|
9320
11336
|
console.log(`Version: ${version}`);
|
|
11337
|
+
if (latestVersion && version !== "unknown") {
|
|
11338
|
+
try {
|
|
11339
|
+
if (import_semver.default.gt(latestVersion, version)) {
|
|
11340
|
+
console.log(`Update: ${latestVersion} available`);
|
|
11341
|
+
}
|
|
11342
|
+
} catch {}
|
|
11343
|
+
}
|
|
9321
11344
|
console.log("");
|
|
9322
11345
|
console.log(`HTTP/1.1 Server: http://localhost:${config.port}`);
|
|
9323
11346
|
if (config.caddy?.enabled && config.caddy?.domain) {
|
|
@@ -9332,25 +11355,25 @@ var create4 = () => {
|
|
|
9332
11355
|
var status_default = Object.freeze({ create: create4 });
|
|
9333
11356
|
|
|
9334
11357
|
// src/commands/logs.js
|
|
9335
|
-
import
|
|
9336
|
-
import
|
|
11358
|
+
import fs10 from "node:fs";
|
|
11359
|
+
import path9 from "node:path";
|
|
9337
11360
|
import os5 from "node:os";
|
|
9338
11361
|
import { spawn as spawn2 } from "node:child_process";
|
|
9339
11362
|
function resolveEnvDir4(rawEnvDir) {
|
|
9340
11363
|
if (rawEnvDir.startsWith("~")) {
|
|
9341
|
-
rawEnvDir =
|
|
11364
|
+
rawEnvDir = path9.join(os5.homedir(), rawEnvDir.slice(1));
|
|
9342
11365
|
}
|
|
9343
|
-
return
|
|
11366
|
+
return path9.resolve(rawEnvDir);
|
|
9344
11367
|
}
|
|
9345
11368
|
var create5 = () => {
|
|
9346
11369
|
return createCommand("logs").summary("Tail the caw server logs").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).run(async (ctx) => {
|
|
9347
11370
|
const envDir = resolveEnvDir4(ctx.params["env-dir"]);
|
|
9348
|
-
const logPath =
|
|
9349
|
-
if (!
|
|
11371
|
+
const logPath = path9.join(envDir, "server.log");
|
|
11372
|
+
if (!fs10.existsSync(logPath)) {
|
|
9350
11373
|
console.log(`No log file found at ${logPath}`);
|
|
9351
11374
|
process.exit(0);
|
|
9352
11375
|
}
|
|
9353
|
-
const tail = spawn2("tail", ["-
|
|
11376
|
+
const tail = spawn2("tail", ["-F", logPath], {
|
|
9354
11377
|
stdio: ["ignore", "inherit", "inherit"]
|
|
9355
11378
|
});
|
|
9356
11379
|
const cleanup = () => {
|
|
@@ -9366,6 +11389,223 @@ var create5 = () => {
|
|
|
9366
11389
|
};
|
|
9367
11390
|
var logs_default = Object.freeze({ create: create5 });
|
|
9368
11391
|
|
|
11392
|
+
// src/commands/upgrade.js
|
|
11393
|
+
var import_semver2 = __toESM(require_semver2(), 1);
|
|
11394
|
+
import fs11 from "node:fs";
|
|
11395
|
+
import path10 from "node:path";
|
|
11396
|
+
import os6 from "node:os";
|
|
11397
|
+
import { execSync as execSync5 } from "node:child_process";
|
|
11398
|
+
var COMPATIBLE_SERVER_RANGE = "^1";
|
|
11399
|
+
function resolveEnvDir5(rawEnvDir) {
|
|
11400
|
+
if (rawEnvDir.startsWith("~")) {
|
|
11401
|
+
rawEnvDir = path10.join(os6.homedir(), rawEnvDir.slice(1));
|
|
11402
|
+
}
|
|
11403
|
+
return path10.resolve(rawEnvDir);
|
|
11404
|
+
}
|
|
11405
|
+
function configExists4(envDir) {
|
|
11406
|
+
return fs11.existsSync(path10.join(envDir, "config.json"));
|
|
11407
|
+
}
|
|
11408
|
+
async function checkHealth3(port) {
|
|
11409
|
+
try {
|
|
11410
|
+
const response = await fetch(`http://localhost:${port}/health`);
|
|
11411
|
+
if (response.ok) {
|
|
11412
|
+
const data = await response.json();
|
|
11413
|
+
return { reachable: true, healthy: true, data };
|
|
11414
|
+
}
|
|
11415
|
+
return { reachable: true, healthy: false, data: null };
|
|
11416
|
+
} catch {
|
|
11417
|
+
return { reachable: false, healthy: false, data: null };
|
|
11418
|
+
}
|
|
11419
|
+
}
|
|
11420
|
+
async function fetchRunningVersion(port) {
|
|
11421
|
+
try {
|
|
11422
|
+
const response = await fetch(`http://localhost:${port}/api/info`);
|
|
11423
|
+
if (response.ok) {
|
|
11424
|
+
const data = await response.json();
|
|
11425
|
+
return data.version || null;
|
|
11426
|
+
}
|
|
11427
|
+
return null;
|
|
11428
|
+
} catch {
|
|
11429
|
+
return null;
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11432
|
+
async function pollHealth2(port, maxRetries = 10, intervalMs = 1000) {
|
|
11433
|
+
for (let i = 0;i < maxRetries; i++) {
|
|
11434
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
11435
|
+
const result = await checkHealth3(port);
|
|
11436
|
+
if (result.healthy)
|
|
11437
|
+
return true;
|
|
11438
|
+
}
|
|
11439
|
+
return false;
|
|
11440
|
+
}
|
|
11441
|
+
function resolveInstalledLauncherVersion() {
|
|
11442
|
+
try {
|
|
11443
|
+
const pkgPath = path10.join(import.meta.dirname, "..", "package.json");
|
|
11444
|
+
const pkg = JSON.parse(fs11.readFileSync(pkgPath, "utf8"));
|
|
11445
|
+
return pkg.version;
|
|
11446
|
+
} catch {
|
|
11447
|
+
return null;
|
|
11448
|
+
}
|
|
11449
|
+
}
|
|
11450
|
+
var create6 = () => {
|
|
11451
|
+
return createCommand("upgrade").summary("Upgrade caw-server to the latest version").param((p) => p.name("env-dir").type("string").flag("env-dir").default("~/.caw/")).param((p) => p.name("force").type("boolean").flag("force").default(false)).run(async (ctx) => {
|
|
11452
|
+
const envDir = resolveEnvDir5(ctx.params["env-dir"]);
|
|
11453
|
+
const force = ctx.params.force;
|
|
11454
|
+
const prefixCheck = checkPrefixWritable();
|
|
11455
|
+
if (!prefixCheck.ok) {
|
|
11456
|
+
console.error("Error: npm global prefix is not writable.");
|
|
11457
|
+
console.error("Run manually: sudo npm install -g @kelceyp/caw-server@latest");
|
|
11458
|
+
process.exit(1);
|
|
11459
|
+
}
|
|
11460
|
+
const serverInfo = resolve();
|
|
11461
|
+
if (!serverInfo) {
|
|
11462
|
+
console.error("Server is not installed. Run `caw start` to install and set up the server.");
|
|
11463
|
+
process.exit(1);
|
|
11464
|
+
}
|
|
11465
|
+
const installedVersion = serverInfo.version;
|
|
11466
|
+
console.log("Checking for updates...");
|
|
11467
|
+
let latestServerVersion, latestLauncherVersion;
|
|
11468
|
+
try {
|
|
11469
|
+
[latestServerVersion, latestLauncherVersion] = await Promise.all([
|
|
11470
|
+
fetchLatestVersion("@kelceyp/caw-server"),
|
|
11471
|
+
fetchLatestVersion("@kelceyp/caw")
|
|
11472
|
+
]);
|
|
11473
|
+
} catch {
|
|
11474
|
+
console.error("Error: Cannot reach npm registry. Check your network connection and try again.");
|
|
11475
|
+
process.exit(1);
|
|
11476
|
+
}
|
|
11477
|
+
const now = new Date().toISOString();
|
|
11478
|
+
const cache = {
|
|
11479
|
+
server: { latest: latestServerVersion, checkedAt: now },
|
|
11480
|
+
launcher: { latest: latestLauncherVersion, checkedAt: now }
|
|
11481
|
+
};
|
|
11482
|
+
try {
|
|
11483
|
+
writeCache(envDir, cache);
|
|
11484
|
+
} catch (e) {
|
|
11485
|
+
console.warn(`Warning: Could not write cache file: ${e.message}`);
|
|
11486
|
+
}
|
|
11487
|
+
let skipInstall = false;
|
|
11488
|
+
if (import_semver2.default.gte(installedVersion, latestServerVersion)) {
|
|
11489
|
+
let needsRestart = false;
|
|
11490
|
+
if (fs11.existsSync(envDir) && configExists4(envDir)) {
|
|
11491
|
+
const config = readConfigWithDefaults(envDir);
|
|
11492
|
+
const pm = createProcessManager(config, envDir);
|
|
11493
|
+
if (pm.isRunning().running) {
|
|
11494
|
+
const runningVersion = await fetchRunningVersion(config.port);
|
|
11495
|
+
if (runningVersion && import_semver2.default.lt(runningVersion, installedVersion)) {
|
|
11496
|
+
needsRestart = true;
|
|
11497
|
+
console.log(`Installed: ${installedVersion} Running: ${runningVersion} — restarting server.`);
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
}
|
|
11501
|
+
if (!needsRestart) {
|
|
11502
|
+
console.log(`Server is already up to date (version ${installedVersion}).`);
|
|
11503
|
+
process.exit(0);
|
|
11504
|
+
}
|
|
11505
|
+
skipInstall = true;
|
|
11506
|
+
}
|
|
11507
|
+
if (!skipInstall) {
|
|
11508
|
+
console.log(`Server update available: ${installedVersion} → ${latestServerVersion}`);
|
|
11509
|
+
}
|
|
11510
|
+
if (!skipInstall && !import_semver2.default.satisfies(latestServerVersion, COMPATIBLE_SERVER_RANGE)) {
|
|
11511
|
+
const installedLauncherVersion = resolveInstalledLauncherVersion();
|
|
11512
|
+
if (installedLauncherVersion && installedLauncherVersion === latestLauncherVersion) {
|
|
11513
|
+
console.error(`Error: Launcher is already at the latest version (${installedLauncherVersion}) but does not support server version ${latestServerVersion}. A new launcher version is needed before upgrading.`);
|
|
11514
|
+
process.exit(1);
|
|
11515
|
+
}
|
|
11516
|
+
console.log(`Upgrading launcher to ${latestLauncherVersion}...`);
|
|
11517
|
+
try {
|
|
11518
|
+
execSync5(`npm install -g @kelceyp/caw@${latestLauncherVersion} --loglevel=error`, { stdio: "inherit" });
|
|
11519
|
+
} catch {
|
|
11520
|
+
console.error("Error: Could not upgrade launcher. Run manually: npm install -g @kelceyp/caw@latest");
|
|
11521
|
+
process.exit(1);
|
|
11522
|
+
}
|
|
11523
|
+
const fromLabel = installedLauncherVersion || "unknown";
|
|
11524
|
+
console.log(`Launcher upgraded from ${fromLabel} to ${latestLauncherVersion}.`);
|
|
11525
|
+
console.log("Rerun `caw upgrade` to complete the server upgrade.");
|
|
11526
|
+
process.exit(0);
|
|
11527
|
+
}
|
|
11528
|
+
let serverWasStopped = false;
|
|
11529
|
+
if (fs11.existsSync(envDir) && configExists4(envDir)) {
|
|
11530
|
+
const config = readConfigWithDefaults(envDir);
|
|
11531
|
+
const pm = createProcessManager(config, envDir);
|
|
11532
|
+
const runState = pm.isRunning();
|
|
11533
|
+
if (runState.running) {
|
|
11534
|
+
const health = await checkHealth3(config.port);
|
|
11535
|
+
if (health.reachable && health.healthy) {
|
|
11536
|
+
const safeToStop = health.data?.safeToStop;
|
|
11537
|
+
if (safeToStop === false && !force) {
|
|
11538
|
+
const message = health.data?.safeToStopMessage || "There are active jobs running.";
|
|
11539
|
+
console.log(message);
|
|
11540
|
+
const confirm = await ctx.prompt({
|
|
11541
|
+
type: "confirm",
|
|
11542
|
+
message: "Stop server and proceed with upgrade?",
|
|
11543
|
+
default: false
|
|
11544
|
+
});
|
|
11545
|
+
if (!confirm) {
|
|
11546
|
+
process.exit(0);
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
} else if (!health.reachable) {
|
|
11550
|
+
if (!force) {
|
|
11551
|
+
console.error("Error: Server is running but not responding to health checks. Use --force to proceed without safety verification.");
|
|
11552
|
+
process.exit(1);
|
|
11553
|
+
}
|
|
11554
|
+
}
|
|
11555
|
+
console.log("Stopping server...");
|
|
11556
|
+
pm.stop();
|
|
11557
|
+
serverWasStopped = true;
|
|
11558
|
+
console.log("Waiting for server to exit...");
|
|
11559
|
+
const exited = await waitForExit(pm, 200, 30000);
|
|
11560
|
+
if (!exited) {
|
|
11561
|
+
console.error(`Error: Server process (PID ${runState.pid}) did not exit within 30 seconds.`);
|
|
11562
|
+
process.exit(1);
|
|
11563
|
+
}
|
|
11564
|
+
pm.cleanup();
|
|
11565
|
+
}
|
|
11566
|
+
}
|
|
11567
|
+
if (!skipInstall) {
|
|
11568
|
+
console.log(`Installing @kelceyp/caw-server@${latestServerVersion}...`);
|
|
11569
|
+
try {
|
|
11570
|
+
execSync5(`npm install -g @kelceyp/caw-server@${latestServerVersion} --loglevel=error`, { stdio: "inherit" });
|
|
11571
|
+
} catch {
|
|
11572
|
+
if (serverWasStopped) {
|
|
11573
|
+
console.error("Error: npm install failed. Server is stopped. Fix the issue and run 'caw upgrade' again, or start the server with 'caw start'.");
|
|
11574
|
+
} else {
|
|
11575
|
+
console.error("Error: npm install failed. Fix the issue and run 'caw upgrade' again.");
|
|
11576
|
+
}
|
|
11577
|
+
process.exit(1);
|
|
11578
|
+
}
|
|
11579
|
+
}
|
|
11580
|
+
if (serverWasStopped || fs11.existsSync(envDir) && configExists4(envDir)) {
|
|
11581
|
+
const config = readConfigWithDefaults(envDir);
|
|
11582
|
+
const pm = createProcessManager(config, envDir);
|
|
11583
|
+
const newServerInfo = resolve();
|
|
11584
|
+
if (!newServerInfo) {
|
|
11585
|
+
console.error(`Error: Server upgraded to ${latestServerVersion} but failed to start. Check logs with 'caw logs'. Start manually with 'caw start'.`);
|
|
11586
|
+
process.exit(1);
|
|
11587
|
+
}
|
|
11588
|
+
const envVars = {
|
|
11589
|
+
CAW_PORT: String(config.port),
|
|
11590
|
+
CAW_ENV_DIR: envDir
|
|
11591
|
+
};
|
|
11592
|
+
console.log("Starting server...");
|
|
11593
|
+
pm.start(newServerInfo.mainJsPath, envVars);
|
|
11594
|
+
const started = await pollHealth2(config.port);
|
|
11595
|
+
if (!started) {
|
|
11596
|
+
console.error(`Error: Server upgraded to ${latestServerVersion} but failed to start. Check logs with 'caw logs'. Start manually with 'caw start'.`);
|
|
11597
|
+
process.exit(1);
|
|
11598
|
+
}
|
|
11599
|
+
}
|
|
11600
|
+
if (skipInstall) {
|
|
11601
|
+
console.log(`Server restarted with version ${installedVersion}.`);
|
|
11602
|
+
} else {
|
|
11603
|
+
console.log(`Server upgraded from ${installedVersion} to ${latestServerVersion}.`);
|
|
11604
|
+
}
|
|
11605
|
+
}).onError({ exitCode: 1 }).build();
|
|
11606
|
+
};
|
|
11607
|
+
var upgrade_default = Object.freeze({ create: create6 });
|
|
11608
|
+
|
|
9369
11609
|
// src/main.js
|
|
9370
11610
|
var [major] = process.versions.node.split(".").map(Number);
|
|
9371
11611
|
if (major < 24) {
|
|
@@ -9378,6 +11618,6 @@ if (!globalCheck.ok) {
|
|
|
9378
11618
|
console.error(globalCheck.message);
|
|
9379
11619
|
process.exit(1);
|
|
9380
11620
|
}
|
|
9381
|
-
var LAUNCHER_VERSION = "1.0.
|
|
9382
|
-
var app = create().name("caw").version(LAUNCHER_VERSION).command(start_default.create()).command(stop_default.create()).command(status_default.create()).command(logs_default.create());
|
|
11621
|
+
var LAUNCHER_VERSION = "1.0.7";
|
|
11622
|
+
var app = create().name("caw").version(LAUNCHER_VERSION).command(start_default.create()).command(stop_default.create()).command(status_default.create()).command(logs_default.create()).command(upgrade_default.create());
|
|
9383
11623
|
await app.run(process.argv.slice(2));
|