genlayer 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.js +1051 -3
- package/package.json +2 -1
- package/src/commands/general/init.ts +2 -0
- package/src/commands/general/start.ts +1 -0
- package/src/lib/interfaces/ISimulatorService.ts +1 -0
- package/src/lib/services/simulator.ts +9 -0
- package/tests/actions/start.test.ts +1 -0
- package/tests/services/simulator.test.ts +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## 0.5.0 (2024-12-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* chack cli version ([#143](https://github.com/yeagerai/genlayer-cli/issues/143)) ([00ada3b](https://github.com/yeagerai/genlayer-cli/commit/00ada3b01ab8f727dbeadc2da0b810dc4211b6c9))
|
|
9
|
+
|
|
3
10
|
## 0.4.0 (2024-11-22)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.js
CHANGED
|
@@ -15689,6 +15689,944 @@ var require_semver2 = __commonJS({
|
|
|
15689
15689
|
}
|
|
15690
15690
|
});
|
|
15691
15691
|
|
|
15692
|
+
// node_modules/rc/node_modules/ini/ini.js
|
|
15693
|
+
var require_ini = __commonJS({
|
|
15694
|
+
"node_modules/rc/node_modules/ini/ini.js"(exports2) {
|
|
15695
|
+
"use strict";
|
|
15696
|
+
exports2.parse = exports2.decode = decode;
|
|
15697
|
+
exports2.stringify = exports2.encode = encode;
|
|
15698
|
+
exports2.safe = safe;
|
|
15699
|
+
exports2.unsafe = unsafe;
|
|
15700
|
+
var eol = typeof process !== "undefined" && process.platform === "win32" ? "\r\n" : "\n";
|
|
15701
|
+
function encode(obj, opt) {
|
|
15702
|
+
var children = [];
|
|
15703
|
+
var out = "";
|
|
15704
|
+
if (typeof opt === "string") {
|
|
15705
|
+
opt = {
|
|
15706
|
+
section: opt,
|
|
15707
|
+
whitespace: false
|
|
15708
|
+
};
|
|
15709
|
+
} else {
|
|
15710
|
+
opt = opt || {};
|
|
15711
|
+
opt.whitespace = opt.whitespace === true;
|
|
15712
|
+
}
|
|
15713
|
+
var separator = opt.whitespace ? " = " : "=";
|
|
15714
|
+
Object.keys(obj).forEach(function(k, _3, __) {
|
|
15715
|
+
var val = obj[k];
|
|
15716
|
+
if (val && Array.isArray(val)) {
|
|
15717
|
+
val.forEach(function(item) {
|
|
15718
|
+
out += safe(k + "[]") + separator + safe(item) + "\n";
|
|
15719
|
+
});
|
|
15720
|
+
} else if (val && typeof val === "object")
|
|
15721
|
+
children.push(k);
|
|
15722
|
+
else
|
|
15723
|
+
out += safe(k) + separator + safe(val) + eol;
|
|
15724
|
+
});
|
|
15725
|
+
if (opt.section && out.length)
|
|
15726
|
+
out = "[" + safe(opt.section) + "]" + eol + out;
|
|
15727
|
+
children.forEach(function(k, _3, __) {
|
|
15728
|
+
var nk = dotSplit(k).join("\\.");
|
|
15729
|
+
var section = (opt.section ? opt.section + "." : "") + nk;
|
|
15730
|
+
var child = encode(obj[k], {
|
|
15731
|
+
section,
|
|
15732
|
+
whitespace: opt.whitespace
|
|
15733
|
+
});
|
|
15734
|
+
if (out.length && child.length)
|
|
15735
|
+
out += eol;
|
|
15736
|
+
out += child;
|
|
15737
|
+
});
|
|
15738
|
+
return out;
|
|
15739
|
+
}
|
|
15740
|
+
function dotSplit(str) {
|
|
15741
|
+
return str.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map(function(part) {
|
|
15742
|
+
return part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, "");
|
|
15743
|
+
});
|
|
15744
|
+
}
|
|
15745
|
+
function decode(str) {
|
|
15746
|
+
var out = {};
|
|
15747
|
+
var p = out;
|
|
15748
|
+
var section = null;
|
|
15749
|
+
var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
|
|
15750
|
+
var lines = str.split(/[\r\n]+/g);
|
|
15751
|
+
lines.forEach(function(line, _3, __) {
|
|
15752
|
+
if (!line || line.match(/^\s*[;#]/))
|
|
15753
|
+
return;
|
|
15754
|
+
var match = line.match(re);
|
|
15755
|
+
if (!match)
|
|
15756
|
+
return;
|
|
15757
|
+
if (match[1] !== void 0) {
|
|
15758
|
+
section = unsafe(match[1]);
|
|
15759
|
+
if (section === "__proto__") {
|
|
15760
|
+
p = {};
|
|
15761
|
+
return;
|
|
15762
|
+
}
|
|
15763
|
+
p = out[section] = out[section] || {};
|
|
15764
|
+
return;
|
|
15765
|
+
}
|
|
15766
|
+
var key = unsafe(match[2]);
|
|
15767
|
+
if (key === "__proto__")
|
|
15768
|
+
return;
|
|
15769
|
+
var value = match[3] ? unsafe(match[4]) : true;
|
|
15770
|
+
switch (value) {
|
|
15771
|
+
case "true":
|
|
15772
|
+
case "false":
|
|
15773
|
+
case "null":
|
|
15774
|
+
value = JSON.parse(value);
|
|
15775
|
+
}
|
|
15776
|
+
if (key.length > 2 && key.slice(-2) === "[]") {
|
|
15777
|
+
key = key.substring(0, key.length - 2);
|
|
15778
|
+
if (key === "__proto__")
|
|
15779
|
+
return;
|
|
15780
|
+
if (!p[key])
|
|
15781
|
+
p[key] = [];
|
|
15782
|
+
else if (!Array.isArray(p[key]))
|
|
15783
|
+
p[key] = [p[key]];
|
|
15784
|
+
}
|
|
15785
|
+
if (Array.isArray(p[key]))
|
|
15786
|
+
p[key].push(value);
|
|
15787
|
+
else
|
|
15788
|
+
p[key] = value;
|
|
15789
|
+
});
|
|
15790
|
+
Object.keys(out).filter(function(k, _3, __) {
|
|
15791
|
+
if (!out[k] || typeof out[k] !== "object" || Array.isArray(out[k]))
|
|
15792
|
+
return false;
|
|
15793
|
+
var parts = dotSplit(k);
|
|
15794
|
+
var p2 = out;
|
|
15795
|
+
var l = parts.pop();
|
|
15796
|
+
var nl = l.replace(/\\\./g, ".");
|
|
15797
|
+
parts.forEach(function(part, _4, __2) {
|
|
15798
|
+
if (part === "__proto__")
|
|
15799
|
+
return;
|
|
15800
|
+
if (!p2[part] || typeof p2[part] !== "object")
|
|
15801
|
+
p2[part] = {};
|
|
15802
|
+
p2 = p2[part];
|
|
15803
|
+
});
|
|
15804
|
+
if (p2 === out && nl === l)
|
|
15805
|
+
return false;
|
|
15806
|
+
p2[nl] = out[k];
|
|
15807
|
+
return true;
|
|
15808
|
+
}).forEach(function(del, _3, __) {
|
|
15809
|
+
delete out[del];
|
|
15810
|
+
});
|
|
15811
|
+
return out;
|
|
15812
|
+
}
|
|
15813
|
+
function isQuoted(val) {
|
|
15814
|
+
return val.charAt(0) === '"' && val.slice(-1) === '"' || val.charAt(0) === "'" && val.slice(-1) === "'";
|
|
15815
|
+
}
|
|
15816
|
+
function safe(val) {
|
|
15817
|
+
return typeof val !== "string" || val.match(/[=\r\n]/) || val.match(/^\[/) || val.length > 1 && isQuoted(val) || val !== val.trim() ? JSON.stringify(val) : val.replace(/;/g, "\\;").replace(/#/g, "\\#");
|
|
15818
|
+
}
|
|
15819
|
+
function unsafe(val, doUnesc) {
|
|
15820
|
+
val = (val || "").trim();
|
|
15821
|
+
if (isQuoted(val)) {
|
|
15822
|
+
if (val.charAt(0) === "'")
|
|
15823
|
+
val = val.substr(1, val.length - 2);
|
|
15824
|
+
try {
|
|
15825
|
+
val = JSON.parse(val);
|
|
15826
|
+
} catch (_3) {
|
|
15827
|
+
}
|
|
15828
|
+
} else {
|
|
15829
|
+
var esc = false;
|
|
15830
|
+
var unesc = "";
|
|
15831
|
+
for (var i = 0, l = val.length; i < l; i++) {
|
|
15832
|
+
var c = val.charAt(i);
|
|
15833
|
+
if (esc) {
|
|
15834
|
+
if ("\\;#".indexOf(c) !== -1)
|
|
15835
|
+
unesc += c;
|
|
15836
|
+
else
|
|
15837
|
+
unesc += "\\" + c;
|
|
15838
|
+
esc = false;
|
|
15839
|
+
} else if (";#".indexOf(c) !== -1)
|
|
15840
|
+
break;
|
|
15841
|
+
else if (c === "\\")
|
|
15842
|
+
esc = true;
|
|
15843
|
+
else
|
|
15844
|
+
unesc += c;
|
|
15845
|
+
}
|
|
15846
|
+
if (esc)
|
|
15847
|
+
unesc += "\\";
|
|
15848
|
+
return unesc.trim();
|
|
15849
|
+
}
|
|
15850
|
+
return val;
|
|
15851
|
+
}
|
|
15852
|
+
}
|
|
15853
|
+
});
|
|
15854
|
+
|
|
15855
|
+
// node_modules/rc/node_modules/strip-json-comments/index.js
|
|
15856
|
+
var require_strip_json_comments = __commonJS({
|
|
15857
|
+
"node_modules/rc/node_modules/strip-json-comments/index.js"(exports2, module2) {
|
|
15858
|
+
"use strict";
|
|
15859
|
+
var singleComment = 1;
|
|
15860
|
+
var multiComment = 2;
|
|
15861
|
+
function stripWithoutWhitespace() {
|
|
15862
|
+
return "";
|
|
15863
|
+
}
|
|
15864
|
+
function stripWithWhitespace(str, start, end) {
|
|
15865
|
+
return str.slice(start, end).replace(/\S/g, " ");
|
|
15866
|
+
}
|
|
15867
|
+
module2.exports = function(str, opts) {
|
|
15868
|
+
opts = opts || {};
|
|
15869
|
+
var currentChar;
|
|
15870
|
+
var nextChar;
|
|
15871
|
+
var insideString = false;
|
|
15872
|
+
var insideComment = false;
|
|
15873
|
+
var offset = 0;
|
|
15874
|
+
var ret = "";
|
|
15875
|
+
var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
|
|
15876
|
+
for (var i = 0; i < str.length; i++) {
|
|
15877
|
+
currentChar = str[i];
|
|
15878
|
+
nextChar = str[i + 1];
|
|
15879
|
+
if (!insideComment && currentChar === '"') {
|
|
15880
|
+
var escaped = str[i - 1] === "\\" && str[i - 2] !== "\\";
|
|
15881
|
+
if (!escaped) {
|
|
15882
|
+
insideString = !insideString;
|
|
15883
|
+
}
|
|
15884
|
+
}
|
|
15885
|
+
if (insideString) {
|
|
15886
|
+
continue;
|
|
15887
|
+
}
|
|
15888
|
+
if (!insideComment && currentChar + nextChar === "//") {
|
|
15889
|
+
ret += str.slice(offset, i);
|
|
15890
|
+
offset = i;
|
|
15891
|
+
insideComment = singleComment;
|
|
15892
|
+
i++;
|
|
15893
|
+
} else if (insideComment === singleComment && currentChar + nextChar === "\r\n") {
|
|
15894
|
+
i++;
|
|
15895
|
+
insideComment = false;
|
|
15896
|
+
ret += strip(str, offset, i);
|
|
15897
|
+
offset = i;
|
|
15898
|
+
continue;
|
|
15899
|
+
} else if (insideComment === singleComment && currentChar === "\n") {
|
|
15900
|
+
insideComment = false;
|
|
15901
|
+
ret += strip(str, offset, i);
|
|
15902
|
+
offset = i;
|
|
15903
|
+
} else if (!insideComment && currentChar + nextChar === "/*") {
|
|
15904
|
+
ret += str.slice(offset, i);
|
|
15905
|
+
offset = i;
|
|
15906
|
+
insideComment = multiComment;
|
|
15907
|
+
i++;
|
|
15908
|
+
continue;
|
|
15909
|
+
} else if (insideComment === multiComment && currentChar + nextChar === "*/") {
|
|
15910
|
+
i++;
|
|
15911
|
+
insideComment = false;
|
|
15912
|
+
ret += strip(str, offset, i + 1);
|
|
15913
|
+
offset = i + 1;
|
|
15914
|
+
continue;
|
|
15915
|
+
}
|
|
15916
|
+
}
|
|
15917
|
+
return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
|
|
15918
|
+
};
|
|
15919
|
+
}
|
|
15920
|
+
});
|
|
15921
|
+
|
|
15922
|
+
// node_modules/rc/lib/utils.js
|
|
15923
|
+
var require_utils2 = __commonJS({
|
|
15924
|
+
"node_modules/rc/lib/utils.js"(exports2) {
|
|
15925
|
+
"use strict";
|
|
15926
|
+
var fs6 = require("fs");
|
|
15927
|
+
var ini = require_ini();
|
|
15928
|
+
var path3 = require("path");
|
|
15929
|
+
var stripJsonComments = require_strip_json_comments();
|
|
15930
|
+
var parse2 = exports2.parse = function(content) {
|
|
15931
|
+
if (/^\s*{/.test(content))
|
|
15932
|
+
return JSON.parse(stripJsonComments(content));
|
|
15933
|
+
return ini.parse(content);
|
|
15934
|
+
};
|
|
15935
|
+
var file = exports2.file = function() {
|
|
15936
|
+
var args = [].slice.call(arguments).filter(function(arg) {
|
|
15937
|
+
return arg != null;
|
|
15938
|
+
});
|
|
15939
|
+
for (var i in args)
|
|
15940
|
+
if ("string" !== typeof args[i])
|
|
15941
|
+
return;
|
|
15942
|
+
var file2 = path3.join.apply(null, args);
|
|
15943
|
+
var content;
|
|
15944
|
+
try {
|
|
15945
|
+
return fs6.readFileSync(file2, "utf-8");
|
|
15946
|
+
} catch (err) {
|
|
15947
|
+
return;
|
|
15948
|
+
}
|
|
15949
|
+
};
|
|
15950
|
+
var json = exports2.json = function() {
|
|
15951
|
+
var content = file.apply(null, arguments);
|
|
15952
|
+
return content ? parse2(content) : null;
|
|
15953
|
+
};
|
|
15954
|
+
var env2 = exports2.env = function(prefix, env3) {
|
|
15955
|
+
env3 = env3 || process.env;
|
|
15956
|
+
var obj = {};
|
|
15957
|
+
var l = prefix.length;
|
|
15958
|
+
for (var k in env3) {
|
|
15959
|
+
if (k.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
|
|
15960
|
+
var keypath = k.substring(l).split("__");
|
|
15961
|
+
var _emptyStringIndex;
|
|
15962
|
+
while ((_emptyStringIndex = keypath.indexOf("")) > -1) {
|
|
15963
|
+
keypath.splice(_emptyStringIndex, 1);
|
|
15964
|
+
}
|
|
15965
|
+
var cursor = obj;
|
|
15966
|
+
keypath.forEach(function _buildSubObj(_subkey, i) {
|
|
15967
|
+
if (!_subkey || typeof cursor !== "object")
|
|
15968
|
+
return;
|
|
15969
|
+
if (i === keypath.length - 1)
|
|
15970
|
+
cursor[_subkey] = env3[k];
|
|
15971
|
+
if (cursor[_subkey] === void 0)
|
|
15972
|
+
cursor[_subkey] = {};
|
|
15973
|
+
cursor = cursor[_subkey];
|
|
15974
|
+
});
|
|
15975
|
+
}
|
|
15976
|
+
}
|
|
15977
|
+
return obj;
|
|
15978
|
+
};
|
|
15979
|
+
var find = exports2.find = function() {
|
|
15980
|
+
var rel = path3.join.apply(null, [].slice.call(arguments));
|
|
15981
|
+
function find2(start, rel2) {
|
|
15982
|
+
var file2 = path3.join(start, rel2);
|
|
15983
|
+
try {
|
|
15984
|
+
fs6.statSync(file2);
|
|
15985
|
+
return file2;
|
|
15986
|
+
} catch (err) {
|
|
15987
|
+
if (path3.dirname(start) !== start)
|
|
15988
|
+
return find2(path3.dirname(start), rel2);
|
|
15989
|
+
}
|
|
15990
|
+
}
|
|
15991
|
+
return find2(process.cwd(), rel);
|
|
15992
|
+
};
|
|
15993
|
+
}
|
|
15994
|
+
});
|
|
15995
|
+
|
|
15996
|
+
// node_modules/deep-extend/lib/deep-extend.js
|
|
15997
|
+
var require_deep_extend = __commonJS({
|
|
15998
|
+
"node_modules/deep-extend/lib/deep-extend.js"(exports2, module2) {
|
|
15999
|
+
"use strict";
|
|
16000
|
+
function isSpecificValue(val) {
|
|
16001
|
+
return val instanceof Buffer || val instanceof Date || val instanceof RegExp ? true : false;
|
|
16002
|
+
}
|
|
16003
|
+
function cloneSpecificValue(val) {
|
|
16004
|
+
if (val instanceof Buffer) {
|
|
16005
|
+
var x = Buffer.alloc ? Buffer.alloc(val.length) : new Buffer(val.length);
|
|
16006
|
+
val.copy(x);
|
|
16007
|
+
return x;
|
|
16008
|
+
} else if (val instanceof Date) {
|
|
16009
|
+
return new Date(val.getTime());
|
|
16010
|
+
} else if (val instanceof RegExp) {
|
|
16011
|
+
return new RegExp(val);
|
|
16012
|
+
} else {
|
|
16013
|
+
throw new Error("Unexpected situation");
|
|
16014
|
+
}
|
|
16015
|
+
}
|
|
16016
|
+
function deepCloneArray(arr) {
|
|
16017
|
+
var clone2 = [];
|
|
16018
|
+
arr.forEach(function(item, index) {
|
|
16019
|
+
if (typeof item === "object" && item !== null) {
|
|
16020
|
+
if (Array.isArray(item)) {
|
|
16021
|
+
clone2[index] = deepCloneArray(item);
|
|
16022
|
+
} else if (isSpecificValue(item)) {
|
|
16023
|
+
clone2[index] = cloneSpecificValue(item);
|
|
16024
|
+
} else {
|
|
16025
|
+
clone2[index] = deepExtend({}, item);
|
|
16026
|
+
}
|
|
16027
|
+
} else {
|
|
16028
|
+
clone2[index] = item;
|
|
16029
|
+
}
|
|
16030
|
+
});
|
|
16031
|
+
return clone2;
|
|
16032
|
+
}
|
|
16033
|
+
function safeGetProperty(object, property) {
|
|
16034
|
+
return property === "__proto__" ? void 0 : object[property];
|
|
16035
|
+
}
|
|
16036
|
+
var deepExtend = module2.exports = function() {
|
|
16037
|
+
if (arguments.length < 1 || typeof arguments[0] !== "object") {
|
|
16038
|
+
return false;
|
|
16039
|
+
}
|
|
16040
|
+
if (arguments.length < 2) {
|
|
16041
|
+
return arguments[0];
|
|
16042
|
+
}
|
|
16043
|
+
var target = arguments[0];
|
|
16044
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
16045
|
+
var val, src, clone2;
|
|
16046
|
+
args.forEach(function(obj) {
|
|
16047
|
+
if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
|
|
16048
|
+
return;
|
|
16049
|
+
}
|
|
16050
|
+
Object.keys(obj).forEach(function(key) {
|
|
16051
|
+
src = safeGetProperty(target, key);
|
|
16052
|
+
val = safeGetProperty(obj, key);
|
|
16053
|
+
if (val === target) {
|
|
16054
|
+
return;
|
|
16055
|
+
} else if (typeof val !== "object" || val === null) {
|
|
16056
|
+
target[key] = val;
|
|
16057
|
+
return;
|
|
16058
|
+
} else if (Array.isArray(val)) {
|
|
16059
|
+
target[key] = deepCloneArray(val);
|
|
16060
|
+
return;
|
|
16061
|
+
} else if (isSpecificValue(val)) {
|
|
16062
|
+
target[key] = cloneSpecificValue(val);
|
|
16063
|
+
return;
|
|
16064
|
+
} else if (typeof src !== "object" || src === null || Array.isArray(src)) {
|
|
16065
|
+
target[key] = deepExtend({}, val);
|
|
16066
|
+
return;
|
|
16067
|
+
} else {
|
|
16068
|
+
target[key] = deepExtend(src, val);
|
|
16069
|
+
return;
|
|
16070
|
+
}
|
|
16071
|
+
});
|
|
16072
|
+
});
|
|
16073
|
+
return target;
|
|
16074
|
+
};
|
|
16075
|
+
}
|
|
16076
|
+
});
|
|
16077
|
+
|
|
16078
|
+
// node_modules/minimist/index.js
|
|
16079
|
+
var require_minimist = __commonJS({
|
|
16080
|
+
"node_modules/minimist/index.js"(exports2, module2) {
|
|
16081
|
+
"use strict";
|
|
16082
|
+
function hasKey(obj, keys) {
|
|
16083
|
+
var o = obj;
|
|
16084
|
+
keys.slice(0, -1).forEach(function(key2) {
|
|
16085
|
+
o = o[key2] || {};
|
|
16086
|
+
});
|
|
16087
|
+
var key = keys[keys.length - 1];
|
|
16088
|
+
return key in o;
|
|
16089
|
+
}
|
|
16090
|
+
function isNumber(x) {
|
|
16091
|
+
if (typeof x === "number") {
|
|
16092
|
+
return true;
|
|
16093
|
+
}
|
|
16094
|
+
if (/^0x[0-9a-f]+$/i.test(x)) {
|
|
16095
|
+
return true;
|
|
16096
|
+
}
|
|
16097
|
+
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
16098
|
+
}
|
|
16099
|
+
function isConstructorOrProto(obj, key) {
|
|
16100
|
+
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
|
|
16101
|
+
}
|
|
16102
|
+
module2.exports = function(args, opts) {
|
|
16103
|
+
if (!opts) {
|
|
16104
|
+
opts = {};
|
|
16105
|
+
}
|
|
16106
|
+
var flags = {
|
|
16107
|
+
bools: {},
|
|
16108
|
+
strings: {},
|
|
16109
|
+
unknownFn: null
|
|
16110
|
+
};
|
|
16111
|
+
if (typeof opts.unknown === "function") {
|
|
16112
|
+
flags.unknownFn = opts.unknown;
|
|
16113
|
+
}
|
|
16114
|
+
if (typeof opts.boolean === "boolean" && opts.boolean) {
|
|
16115
|
+
flags.allBools = true;
|
|
16116
|
+
} else {
|
|
16117
|
+
[].concat(opts.boolean).filter(Boolean).forEach(function(key2) {
|
|
16118
|
+
flags.bools[key2] = true;
|
|
16119
|
+
});
|
|
16120
|
+
}
|
|
16121
|
+
var aliases = {};
|
|
16122
|
+
function aliasIsBoolean(key2) {
|
|
16123
|
+
return aliases[key2].some(function(x) {
|
|
16124
|
+
return flags.bools[x];
|
|
16125
|
+
});
|
|
16126
|
+
}
|
|
16127
|
+
Object.keys(opts.alias || {}).forEach(function(key2) {
|
|
16128
|
+
aliases[key2] = [].concat(opts.alias[key2]);
|
|
16129
|
+
aliases[key2].forEach(function(x) {
|
|
16130
|
+
aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
|
|
16131
|
+
return x !== y;
|
|
16132
|
+
}));
|
|
16133
|
+
});
|
|
16134
|
+
});
|
|
16135
|
+
[].concat(opts.string).filter(Boolean).forEach(function(key2) {
|
|
16136
|
+
flags.strings[key2] = true;
|
|
16137
|
+
if (aliases[key2]) {
|
|
16138
|
+
[].concat(aliases[key2]).forEach(function(k) {
|
|
16139
|
+
flags.strings[k] = true;
|
|
16140
|
+
});
|
|
16141
|
+
}
|
|
16142
|
+
});
|
|
16143
|
+
var defaults2 = opts.default || {};
|
|
16144
|
+
var argv = { _: [] };
|
|
16145
|
+
function argDefined(key2, arg2) {
|
|
16146
|
+
return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
|
|
16147
|
+
}
|
|
16148
|
+
function setKey(obj, keys, value2) {
|
|
16149
|
+
var o = obj;
|
|
16150
|
+
for (var i2 = 0; i2 < keys.length - 1; i2++) {
|
|
16151
|
+
var key2 = keys[i2];
|
|
16152
|
+
if (isConstructorOrProto(o, key2)) {
|
|
16153
|
+
return;
|
|
16154
|
+
}
|
|
16155
|
+
if (o[key2] === void 0) {
|
|
16156
|
+
o[key2] = {};
|
|
16157
|
+
}
|
|
16158
|
+
if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype) {
|
|
16159
|
+
o[key2] = {};
|
|
16160
|
+
}
|
|
16161
|
+
if (o[key2] === Array.prototype) {
|
|
16162
|
+
o[key2] = [];
|
|
16163
|
+
}
|
|
16164
|
+
o = o[key2];
|
|
16165
|
+
}
|
|
16166
|
+
var lastKey = keys[keys.length - 1];
|
|
16167
|
+
if (isConstructorOrProto(o, lastKey)) {
|
|
16168
|
+
return;
|
|
16169
|
+
}
|
|
16170
|
+
if (o === Object.prototype || o === Number.prototype || o === String.prototype) {
|
|
16171
|
+
o = {};
|
|
16172
|
+
}
|
|
16173
|
+
if (o === Array.prototype) {
|
|
16174
|
+
o = [];
|
|
16175
|
+
}
|
|
16176
|
+
if (o[lastKey] === void 0 || flags.bools[lastKey] || typeof o[lastKey] === "boolean") {
|
|
16177
|
+
o[lastKey] = value2;
|
|
16178
|
+
} else if (Array.isArray(o[lastKey])) {
|
|
16179
|
+
o[lastKey].push(value2);
|
|
16180
|
+
} else {
|
|
16181
|
+
o[lastKey] = [o[lastKey], value2];
|
|
16182
|
+
}
|
|
16183
|
+
}
|
|
16184
|
+
function setArg(key2, val, arg2) {
|
|
16185
|
+
if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
|
|
16186
|
+
if (flags.unknownFn(arg2) === false) {
|
|
16187
|
+
return;
|
|
16188
|
+
}
|
|
16189
|
+
}
|
|
16190
|
+
var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
|
|
16191
|
+
setKey(argv, key2.split("."), value2);
|
|
16192
|
+
(aliases[key2] || []).forEach(function(x) {
|
|
16193
|
+
setKey(argv, x.split("."), value2);
|
|
16194
|
+
});
|
|
16195
|
+
}
|
|
16196
|
+
Object.keys(flags.bools).forEach(function(key2) {
|
|
16197
|
+
setArg(key2, defaults2[key2] === void 0 ? false : defaults2[key2]);
|
|
16198
|
+
});
|
|
16199
|
+
var notFlags = [];
|
|
16200
|
+
if (args.indexOf("--") !== -1) {
|
|
16201
|
+
notFlags = args.slice(args.indexOf("--") + 1);
|
|
16202
|
+
args = args.slice(0, args.indexOf("--"));
|
|
16203
|
+
}
|
|
16204
|
+
for (var i = 0; i < args.length; i++) {
|
|
16205
|
+
var arg = args[i];
|
|
16206
|
+
var key;
|
|
16207
|
+
var next;
|
|
16208
|
+
if (/^--.+=/.test(arg)) {
|
|
16209
|
+
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
|
16210
|
+
key = m[1];
|
|
16211
|
+
var value = m[2];
|
|
16212
|
+
if (flags.bools[key]) {
|
|
16213
|
+
value = value !== "false";
|
|
16214
|
+
}
|
|
16215
|
+
setArg(key, value, arg);
|
|
16216
|
+
} else if (/^--no-.+/.test(arg)) {
|
|
16217
|
+
key = arg.match(/^--no-(.+)/)[1];
|
|
16218
|
+
setArg(key, false, arg);
|
|
16219
|
+
} else if (/^--.+/.test(arg)) {
|
|
16220
|
+
key = arg.match(/^--(.+)/)[1];
|
|
16221
|
+
next = args[i + 1];
|
|
16222
|
+
if (next !== void 0 && !/^(-|--)[^-]/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
|
16223
|
+
setArg(key, next, arg);
|
|
16224
|
+
i += 1;
|
|
16225
|
+
} else if (/^(true|false)$/.test(next)) {
|
|
16226
|
+
setArg(key, next === "true", arg);
|
|
16227
|
+
i += 1;
|
|
16228
|
+
} else {
|
|
16229
|
+
setArg(key, flags.strings[key] ? "" : true, arg);
|
|
16230
|
+
}
|
|
16231
|
+
} else if (/^-[^-]+/.test(arg)) {
|
|
16232
|
+
var letters = arg.slice(1, -1).split("");
|
|
16233
|
+
var broken = false;
|
|
16234
|
+
for (var j = 0; j < letters.length; j++) {
|
|
16235
|
+
next = arg.slice(j + 2);
|
|
16236
|
+
if (next === "-") {
|
|
16237
|
+
setArg(letters[j], next, arg);
|
|
16238
|
+
continue;
|
|
16239
|
+
}
|
|
16240
|
+
if (/[A-Za-z]/.test(letters[j]) && next[0] === "=") {
|
|
16241
|
+
setArg(letters[j], next.slice(1), arg);
|
|
16242
|
+
broken = true;
|
|
16243
|
+
break;
|
|
16244
|
+
}
|
|
16245
|
+
if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
|
16246
|
+
setArg(letters[j], next, arg);
|
|
16247
|
+
broken = true;
|
|
16248
|
+
break;
|
|
16249
|
+
}
|
|
16250
|
+
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
|
16251
|
+
setArg(letters[j], arg.slice(j + 2), arg);
|
|
16252
|
+
broken = true;
|
|
16253
|
+
break;
|
|
16254
|
+
} else {
|
|
16255
|
+
setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
|
|
16256
|
+
}
|
|
16257
|
+
}
|
|
16258
|
+
key = arg.slice(-1)[0];
|
|
16259
|
+
if (!broken && key !== "-") {
|
|
16260
|
+
if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
|
|
16261
|
+
setArg(key, args[i + 1], arg);
|
|
16262
|
+
i += 1;
|
|
16263
|
+
} else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
|
16264
|
+
setArg(key, args[i + 1] === "true", arg);
|
|
16265
|
+
i += 1;
|
|
16266
|
+
} else {
|
|
16267
|
+
setArg(key, flags.strings[key] ? "" : true, arg);
|
|
16268
|
+
}
|
|
16269
|
+
}
|
|
16270
|
+
} else {
|
|
16271
|
+
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
|
16272
|
+
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
|
|
16273
|
+
}
|
|
16274
|
+
if (opts.stopEarly) {
|
|
16275
|
+
argv._.push.apply(argv._, args.slice(i + 1));
|
|
16276
|
+
break;
|
|
16277
|
+
}
|
|
16278
|
+
}
|
|
16279
|
+
}
|
|
16280
|
+
Object.keys(defaults2).forEach(function(k) {
|
|
16281
|
+
if (!hasKey(argv, k.split("."))) {
|
|
16282
|
+
setKey(argv, k.split("."), defaults2[k]);
|
|
16283
|
+
(aliases[k] || []).forEach(function(x) {
|
|
16284
|
+
setKey(argv, x.split("."), defaults2[k]);
|
|
16285
|
+
});
|
|
16286
|
+
}
|
|
16287
|
+
});
|
|
16288
|
+
if (opts["--"]) {
|
|
16289
|
+
argv["--"] = notFlags.slice();
|
|
16290
|
+
} else {
|
|
16291
|
+
notFlags.forEach(function(k) {
|
|
16292
|
+
argv._.push(k);
|
|
16293
|
+
});
|
|
16294
|
+
}
|
|
16295
|
+
return argv;
|
|
16296
|
+
};
|
|
16297
|
+
}
|
|
16298
|
+
});
|
|
16299
|
+
|
|
16300
|
+
// node_modules/rc/index.js
|
|
16301
|
+
var require_rc = __commonJS({
|
|
16302
|
+
"node_modules/rc/index.js"(exports2, module2) {
|
|
16303
|
+
"use strict";
|
|
16304
|
+
var cc = require_utils2();
|
|
16305
|
+
var join2 = require("path").join;
|
|
16306
|
+
var deepExtend = require_deep_extend();
|
|
16307
|
+
var etc = "/etc";
|
|
16308
|
+
var win = process.platform === "win32";
|
|
16309
|
+
var home = win ? process.env.USERPROFILE : process.env.HOME;
|
|
16310
|
+
module2.exports = function(name, defaults2, argv, parse2) {
|
|
16311
|
+
if ("string" !== typeof name)
|
|
16312
|
+
throw new Error("rc(name): name *must* be string");
|
|
16313
|
+
if (!argv)
|
|
16314
|
+
argv = require_minimist()(process.argv.slice(2));
|
|
16315
|
+
defaults2 = ("string" === typeof defaults2 ? cc.json(defaults2) : defaults2) || {};
|
|
16316
|
+
parse2 = parse2 || cc.parse;
|
|
16317
|
+
var env2 = cc.env(name + "_");
|
|
16318
|
+
var configs = [defaults2];
|
|
16319
|
+
var configFiles = [];
|
|
16320
|
+
function addConfigFile(file) {
|
|
16321
|
+
if (configFiles.indexOf(file) >= 0) return;
|
|
16322
|
+
var fileConfig = cc.file(file);
|
|
16323
|
+
if (fileConfig) {
|
|
16324
|
+
configs.push(parse2(fileConfig));
|
|
16325
|
+
configFiles.push(file);
|
|
16326
|
+
}
|
|
16327
|
+
}
|
|
16328
|
+
if (!win)
|
|
16329
|
+
[
|
|
16330
|
+
join2(etc, name, "config"),
|
|
16331
|
+
join2(etc, name + "rc")
|
|
16332
|
+
].forEach(addConfigFile);
|
|
16333
|
+
if (home)
|
|
16334
|
+
[
|
|
16335
|
+
join2(home, ".config", name, "config"),
|
|
16336
|
+
join2(home, ".config", name),
|
|
16337
|
+
join2(home, "." + name, "config"),
|
|
16338
|
+
join2(home, "." + name + "rc")
|
|
16339
|
+
].forEach(addConfigFile);
|
|
16340
|
+
addConfigFile(cc.find("." + name + "rc"));
|
|
16341
|
+
if (env2.config) addConfigFile(env2.config);
|
|
16342
|
+
if (argv.config) addConfigFile(argv.config);
|
|
16343
|
+
return deepExtend.apply(null, configs.concat([
|
|
16344
|
+
env2,
|
|
16345
|
+
argv,
|
|
16346
|
+
configFiles.length ? { configs: configFiles, config: configFiles[configFiles.length - 1] } : void 0
|
|
16347
|
+
]));
|
|
16348
|
+
};
|
|
16349
|
+
}
|
|
16350
|
+
});
|
|
16351
|
+
|
|
16352
|
+
// node_modules/update-check/node_modules/registry-url/index.js
|
|
16353
|
+
var require_registry_url = __commonJS({
|
|
16354
|
+
"node_modules/update-check/node_modules/registry-url/index.js"(exports2, module2) {
|
|
16355
|
+
"use strict";
|
|
16356
|
+
module2.exports = function(scope) {
|
|
16357
|
+
var rc = require_rc()("npm", { registry: "https://registry.npmjs.org/" });
|
|
16358
|
+
var url = rc[scope + ":registry"] || rc.registry;
|
|
16359
|
+
return url.slice(-1) === "/" ? url : url + "/";
|
|
16360
|
+
};
|
|
16361
|
+
}
|
|
16362
|
+
});
|
|
16363
|
+
|
|
16364
|
+
// node_modules/update-check/node_modules/registry-auth-token/base64.js
|
|
16365
|
+
var require_base64 = __commonJS({
|
|
16366
|
+
"node_modules/update-check/node_modules/registry-auth-token/base64.js"(exports2, module2) {
|
|
16367
|
+
"use strict";
|
|
16368
|
+
var safeBuffer = require_safe_buffer().Buffer;
|
|
16369
|
+
function decodeBase64(base64) {
|
|
16370
|
+
return safeBuffer.from(base64, "base64").toString("utf8");
|
|
16371
|
+
}
|
|
16372
|
+
function encodeBase64(string) {
|
|
16373
|
+
return safeBuffer.from(string, "utf8").toString("base64");
|
|
16374
|
+
}
|
|
16375
|
+
module2.exports = {
|
|
16376
|
+
decodeBase64,
|
|
16377
|
+
encodeBase64
|
|
16378
|
+
};
|
|
16379
|
+
}
|
|
16380
|
+
});
|
|
16381
|
+
|
|
16382
|
+
// node_modules/update-check/node_modules/registry-auth-token/index.js
|
|
16383
|
+
var require_registry_auth_token = __commonJS({
|
|
16384
|
+
"node_modules/update-check/node_modules/registry-auth-token/index.js"(exports2, module2) {
|
|
16385
|
+
"use strict";
|
|
16386
|
+
var url = require("url");
|
|
16387
|
+
var base64 = require_base64();
|
|
16388
|
+
var decodeBase64 = base64.decodeBase64;
|
|
16389
|
+
var encodeBase64 = base64.encodeBase64;
|
|
16390
|
+
var tokenKey = ":_authToken";
|
|
16391
|
+
var userKey = ":username";
|
|
16392
|
+
var passwordKey = ":_password";
|
|
16393
|
+
module2.exports = function() {
|
|
16394
|
+
var checkUrl;
|
|
16395
|
+
var options;
|
|
16396
|
+
if (arguments.length >= 2) {
|
|
16397
|
+
checkUrl = arguments[0];
|
|
16398
|
+
options = arguments[1];
|
|
16399
|
+
} else if (typeof arguments[0] === "string") {
|
|
16400
|
+
checkUrl = arguments[0];
|
|
16401
|
+
} else {
|
|
16402
|
+
options = arguments[0];
|
|
16403
|
+
}
|
|
16404
|
+
options = options || {};
|
|
16405
|
+
options.npmrc = options.npmrc || require_rc()("npm", { registry: "https://registry.npmjs.org/" });
|
|
16406
|
+
checkUrl = checkUrl || options.npmrc.registry;
|
|
16407
|
+
return getRegistryAuthInfo(checkUrl, options) || getLegacyAuthInfo(options.npmrc);
|
|
16408
|
+
};
|
|
16409
|
+
function getRegistryAuthInfo(checkUrl, options) {
|
|
16410
|
+
var parsed = url.parse(checkUrl, false, true);
|
|
16411
|
+
var pathname;
|
|
16412
|
+
while (pathname !== "/" && parsed.pathname !== pathname) {
|
|
16413
|
+
pathname = parsed.pathname || "/";
|
|
16414
|
+
var regUrl = "//" + parsed.host + pathname.replace(/\/$/, "");
|
|
16415
|
+
var authInfo = getAuthInfoForUrl(regUrl, options.npmrc);
|
|
16416
|
+
if (authInfo) {
|
|
16417
|
+
return authInfo;
|
|
16418
|
+
}
|
|
16419
|
+
if (!options.recursive) {
|
|
16420
|
+
return /\/$/.test(checkUrl) ? void 0 : getRegistryAuthInfo(url.resolve(checkUrl, "."), options);
|
|
16421
|
+
}
|
|
16422
|
+
parsed.pathname = url.resolve(normalizePath(pathname), "..") || "/";
|
|
16423
|
+
}
|
|
16424
|
+
return void 0;
|
|
16425
|
+
}
|
|
16426
|
+
function getLegacyAuthInfo(npmrc) {
|
|
16427
|
+
if (npmrc._auth) {
|
|
16428
|
+
return { token: npmrc._auth, type: "Basic" };
|
|
16429
|
+
}
|
|
16430
|
+
return void 0;
|
|
16431
|
+
}
|
|
16432
|
+
function normalizePath(path3) {
|
|
16433
|
+
return path3[path3.length - 1] === "/" ? path3 : path3 + "/";
|
|
16434
|
+
}
|
|
16435
|
+
function getAuthInfoForUrl(regUrl, npmrc) {
|
|
16436
|
+
var bearerAuth = getBearerToken(npmrc[regUrl + tokenKey] || npmrc[regUrl + "/" + tokenKey]);
|
|
16437
|
+
if (bearerAuth) {
|
|
16438
|
+
return bearerAuth;
|
|
16439
|
+
}
|
|
16440
|
+
var username = npmrc[regUrl + userKey] || npmrc[regUrl + "/" + userKey];
|
|
16441
|
+
var password = npmrc[regUrl + passwordKey] || npmrc[regUrl + "/" + passwordKey];
|
|
16442
|
+
var basicAuth = getTokenForUsernameAndPassword(username, password);
|
|
16443
|
+
if (basicAuth) {
|
|
16444
|
+
return basicAuth;
|
|
16445
|
+
}
|
|
16446
|
+
return void 0;
|
|
16447
|
+
}
|
|
16448
|
+
function getBearerToken(tok) {
|
|
16449
|
+
if (!tok) {
|
|
16450
|
+
return void 0;
|
|
16451
|
+
}
|
|
16452
|
+
var token = tok.replace(/^\$\{?([^}]*)\}?$/, function(fullMatch, envVar) {
|
|
16453
|
+
return process.env[envVar];
|
|
16454
|
+
});
|
|
16455
|
+
return { token, type: "Bearer" };
|
|
16456
|
+
}
|
|
16457
|
+
function getTokenForUsernameAndPassword(username, password) {
|
|
16458
|
+
if (!username || !password) {
|
|
16459
|
+
return void 0;
|
|
16460
|
+
}
|
|
16461
|
+
var pass = decodeBase64(password.replace(/^\$\{?([^}]*)\}?$/, function(fullMatch, envVar) {
|
|
16462
|
+
return process.env[envVar];
|
|
16463
|
+
}));
|
|
16464
|
+
var token = encodeBase64(username + ":" + pass);
|
|
16465
|
+
return {
|
|
16466
|
+
token,
|
|
16467
|
+
type: "Basic",
|
|
16468
|
+
password: pass,
|
|
16469
|
+
username
|
|
16470
|
+
};
|
|
16471
|
+
}
|
|
16472
|
+
}
|
|
16473
|
+
});
|
|
16474
|
+
|
|
16475
|
+
// node_modules/update-check/index.js
|
|
16476
|
+
var require_update_check = __commonJS({
|
|
16477
|
+
"node_modules/update-check/index.js"(exports2, module2) {
|
|
16478
|
+
"use strict";
|
|
16479
|
+
var { URL: URL2 } = require("url");
|
|
16480
|
+
var { join: join2 } = require("path");
|
|
16481
|
+
var fs6 = require("fs");
|
|
16482
|
+
var { promisify: promisify5 } = require("util");
|
|
16483
|
+
var { tmpdir } = require("os");
|
|
16484
|
+
var registryUrl = require_registry_url();
|
|
16485
|
+
var writeFile = promisify5(fs6.writeFile);
|
|
16486
|
+
var mkdir = promisify5(fs6.mkdir);
|
|
16487
|
+
var readFile = promisify5(fs6.readFile);
|
|
16488
|
+
var compareVersions = (a, b) => a.localeCompare(b, "en-US", { numeric: true });
|
|
16489
|
+
var encode = (value) => encodeURIComponent(value).replace(/^%40/, "@");
|
|
16490
|
+
var getFile = (details, distTag) => __async(exports2, null, function* () {
|
|
16491
|
+
const rootDir = tmpdir();
|
|
16492
|
+
const subDir = join2(rootDir, "update-check");
|
|
16493
|
+
if (!fs6.existsSync(subDir)) {
|
|
16494
|
+
yield mkdir(subDir);
|
|
16495
|
+
}
|
|
16496
|
+
let name = `${details.name}-${distTag}.json`;
|
|
16497
|
+
if (details.scope) {
|
|
16498
|
+
name = `${details.scope}-${name}`;
|
|
16499
|
+
}
|
|
16500
|
+
return join2(subDir, name);
|
|
16501
|
+
});
|
|
16502
|
+
var evaluateCache = (file, time, interval) => __async(exports2, null, function* () {
|
|
16503
|
+
if (fs6.existsSync(file)) {
|
|
16504
|
+
const content = yield readFile(file, "utf8");
|
|
16505
|
+
const { lastUpdate, latest } = JSON.parse(content);
|
|
16506
|
+
const nextCheck = lastUpdate + interval;
|
|
16507
|
+
if (nextCheck > time) {
|
|
16508
|
+
return {
|
|
16509
|
+
shouldCheck: false,
|
|
16510
|
+
latest
|
|
16511
|
+
};
|
|
16512
|
+
}
|
|
16513
|
+
}
|
|
16514
|
+
return {
|
|
16515
|
+
shouldCheck: true,
|
|
16516
|
+
latest: null
|
|
16517
|
+
};
|
|
16518
|
+
});
|
|
16519
|
+
var updateCache = (file, latest, lastUpdate) => __async(exports2, null, function* () {
|
|
16520
|
+
const content = JSON.stringify({
|
|
16521
|
+
latest,
|
|
16522
|
+
lastUpdate
|
|
16523
|
+
});
|
|
16524
|
+
yield writeFile(file, content, "utf8");
|
|
16525
|
+
});
|
|
16526
|
+
var loadPackage = (url, authInfo) => new Promise((resolve, reject) => {
|
|
16527
|
+
const options = {
|
|
16528
|
+
host: url.hostname,
|
|
16529
|
+
path: url.pathname,
|
|
16530
|
+
port: url.port,
|
|
16531
|
+
headers: {
|
|
16532
|
+
accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
|
|
16533
|
+
},
|
|
16534
|
+
timeout: 2e3
|
|
16535
|
+
};
|
|
16536
|
+
if (authInfo) {
|
|
16537
|
+
options.headers.authorization = `${authInfo.type} ${authInfo.token}`;
|
|
16538
|
+
}
|
|
16539
|
+
const { get: get2 } = url.protocol === "https:" ? require("https") : require("http");
|
|
16540
|
+
get2(options, (response) => {
|
|
16541
|
+
const { statusCode } = response;
|
|
16542
|
+
if (statusCode !== 200) {
|
|
16543
|
+
const error = new Error(`Request failed with code ${statusCode}`);
|
|
16544
|
+
error.code = statusCode;
|
|
16545
|
+
reject(error);
|
|
16546
|
+
response.resume();
|
|
16547
|
+
return;
|
|
16548
|
+
}
|
|
16549
|
+
let rawData = "";
|
|
16550
|
+
response.setEncoding("utf8");
|
|
16551
|
+
response.on("data", (chunk) => {
|
|
16552
|
+
rawData += chunk;
|
|
16553
|
+
});
|
|
16554
|
+
response.on("end", () => {
|
|
16555
|
+
try {
|
|
16556
|
+
const parsedData = JSON.parse(rawData);
|
|
16557
|
+
resolve(parsedData);
|
|
16558
|
+
} catch (e) {
|
|
16559
|
+
reject(e);
|
|
16560
|
+
}
|
|
16561
|
+
});
|
|
16562
|
+
}).on("error", reject).on("timeout", reject);
|
|
16563
|
+
});
|
|
16564
|
+
var getMostRecent = (_0, _1) => __async(exports2, [_0, _1], function* ({ full, scope }, distTag) {
|
|
16565
|
+
const regURL = registryUrl(scope);
|
|
16566
|
+
const url = new URL2(full, regURL);
|
|
16567
|
+
let spec = null;
|
|
16568
|
+
try {
|
|
16569
|
+
spec = yield loadPackage(url);
|
|
16570
|
+
} catch (err) {
|
|
16571
|
+
if (err.code && String(err.code).startsWith(4)) {
|
|
16572
|
+
const registryAuthToken = require_registry_auth_token();
|
|
16573
|
+
const authInfo = registryAuthToken(regURL, { recursive: true });
|
|
16574
|
+
spec = yield loadPackage(url, authInfo);
|
|
16575
|
+
} else {
|
|
16576
|
+
throw err;
|
|
16577
|
+
}
|
|
16578
|
+
}
|
|
16579
|
+
const version2 = spec["dist-tags"][distTag];
|
|
16580
|
+
if (!version2) {
|
|
16581
|
+
throw new Error(`Distribution tag ${distTag} is not available`);
|
|
16582
|
+
}
|
|
16583
|
+
return version2;
|
|
16584
|
+
});
|
|
16585
|
+
var defaultConfig = {
|
|
16586
|
+
interval: 36e5,
|
|
16587
|
+
distTag: "latest"
|
|
16588
|
+
};
|
|
16589
|
+
var getDetails = (name) => {
|
|
16590
|
+
const spec = {
|
|
16591
|
+
full: encode(name)
|
|
16592
|
+
};
|
|
16593
|
+
if (name.includes("/")) {
|
|
16594
|
+
const parts = name.split("/");
|
|
16595
|
+
spec.scope = parts[0];
|
|
16596
|
+
spec.name = parts[1];
|
|
16597
|
+
} else {
|
|
16598
|
+
spec.scope = null;
|
|
16599
|
+
spec.name = name;
|
|
16600
|
+
}
|
|
16601
|
+
return spec;
|
|
16602
|
+
};
|
|
16603
|
+
module2.exports = (pkg, config) => __async(exports2, null, function* () {
|
|
16604
|
+
if (typeof pkg !== "object") {
|
|
16605
|
+
throw new Error("The first parameter should be your package.json file content");
|
|
16606
|
+
}
|
|
16607
|
+
const details = getDetails(pkg.name);
|
|
16608
|
+
const time = Date.now();
|
|
16609
|
+
const { distTag, interval } = Object.assign({}, defaultConfig, config);
|
|
16610
|
+
const file = yield getFile(details, distTag);
|
|
16611
|
+
let latest = null;
|
|
16612
|
+
let shouldCheck = true;
|
|
16613
|
+
({ shouldCheck, latest } = yield evaluateCache(file, time, interval));
|
|
16614
|
+
if (shouldCheck) {
|
|
16615
|
+
latest = yield getMostRecent(details, distTag);
|
|
16616
|
+
yield updateCache(file, latest, time);
|
|
16617
|
+
}
|
|
16618
|
+
const comparision = compareVersions(pkg.version, latest);
|
|
16619
|
+
if (comparision === -1) {
|
|
16620
|
+
return {
|
|
16621
|
+
latest,
|
|
16622
|
+
fromCache: !shouldCheck
|
|
16623
|
+
};
|
|
16624
|
+
}
|
|
16625
|
+
return null;
|
|
16626
|
+
});
|
|
16627
|
+
}
|
|
16628
|
+
});
|
|
16629
|
+
|
|
15692
16630
|
// node_modules/webidl-conversions/lib/index.js
|
|
15693
16631
|
var require_lib = __commonJS({
|
|
15694
16632
|
"node_modules/webidl-conversions/lib/index.js"(exports2, module2) {
|
|
@@ -15843,7 +16781,7 @@ var require_lib = __commonJS({
|
|
|
15843
16781
|
});
|
|
15844
16782
|
|
|
15845
16783
|
// node_modules/whatwg-url/lib/utils.js
|
|
15846
|
-
var
|
|
16784
|
+
var require_utils3 = __commonJS({
|
|
15847
16785
|
"node_modules/whatwg-url/lib/utils.js"(exports2, module2) {
|
|
15848
16786
|
"use strict";
|
|
15849
16787
|
module2.exports.mixin = function mixin(target, source) {
|
|
@@ -17265,7 +18203,7 @@ var require_URL = __commonJS({
|
|
|
17265
18203
|
"node_modules/whatwg-url/lib/URL.js"(exports2, module2) {
|
|
17266
18204
|
"use strict";
|
|
17267
18205
|
var conversions = require_lib();
|
|
17268
|
-
var utils =
|
|
18206
|
+
var utils = require_utils3();
|
|
17269
18207
|
var Impl = require_URL_impl();
|
|
17270
18208
|
var impl = utils.implSymbol;
|
|
17271
18209
|
function URL2(url) {
|
|
@@ -46421,7 +47359,75 @@ var {
|
|
|
46421
47359
|
} = import_index.default;
|
|
46422
47360
|
|
|
46423
47361
|
// package.json
|
|
46424
|
-
var version = "0.
|
|
47362
|
+
var version = "0.5.0";
|
|
47363
|
+
var package_default = {
|
|
47364
|
+
name: "genlayer",
|
|
47365
|
+
version,
|
|
47366
|
+
description: "GenLayer Command Line Tool",
|
|
47367
|
+
main: "src/index.ts",
|
|
47368
|
+
bin: {
|
|
47369
|
+
genlayer: "./dist/index.js"
|
|
47370
|
+
},
|
|
47371
|
+
scripts: {
|
|
47372
|
+
test: "vitest",
|
|
47373
|
+
"test:watch": "vitest --watch",
|
|
47374
|
+
"test:coverage": "vitest run --coverage",
|
|
47375
|
+
dev: "cross-env NODE_ENV=development node esbuild.config.js",
|
|
47376
|
+
build: "cross-env NODE_ENV=production node esbuild.config.js",
|
|
47377
|
+
release: "release-it --ci",
|
|
47378
|
+
"release-beta": "release-it --ci --preRelease=beta"
|
|
47379
|
+
},
|
|
47380
|
+
repository: {
|
|
47381
|
+
type: "git",
|
|
47382
|
+
url: "git+https://github.com/yeagerai/genlayer-cli.git"
|
|
47383
|
+
},
|
|
47384
|
+
keywords: [
|
|
47385
|
+
"genlayer",
|
|
47386
|
+
"intelligent",
|
|
47387
|
+
"contract",
|
|
47388
|
+
"simulator",
|
|
47389
|
+
"cli"
|
|
47390
|
+
],
|
|
47391
|
+
author: "GenLayer",
|
|
47392
|
+
license: "MIT",
|
|
47393
|
+
bugs: {
|
|
47394
|
+
url: "https://github.com/yeagerai/genlayer-cli/issues"
|
|
47395
|
+
},
|
|
47396
|
+
homepage: "https://github.com/yeagerai/genlayer-cli#readme",
|
|
47397
|
+
devDependencies: {
|
|
47398
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
47399
|
+
"@types/dockerode": "^3.3.31",
|
|
47400
|
+
"@types/inquirer": "^9.0.7",
|
|
47401
|
+
"@types/node": "^20.12.7",
|
|
47402
|
+
"@types/sinon": "^17.0.3",
|
|
47403
|
+
"@types/uuid": "^9.0.8",
|
|
47404
|
+
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
47405
|
+
"@typescript-eslint/parser": "^7.7.0",
|
|
47406
|
+
"@vitest/coverage-v8": "^2.1.4",
|
|
47407
|
+
"cross-env": "^7.0.3",
|
|
47408
|
+
esbuild: "^0.24.0",
|
|
47409
|
+
eslint: "^8.57.0",
|
|
47410
|
+
"eslint-config-prettier": "^9.1.0",
|
|
47411
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
47412
|
+
"eslint-plugin-import": "^2.29.1",
|
|
47413
|
+
jsdom: "^25.0.1",
|
|
47414
|
+
prettier: "^3.2.5",
|
|
47415
|
+
"release-it": "^17.2.0",
|
|
47416
|
+
"ts-node": "^10.9.2",
|
|
47417
|
+
typescript: "^5.4.5"
|
|
47418
|
+
},
|
|
47419
|
+
dependencies: {
|
|
47420
|
+
commander: "^12.0.0",
|
|
47421
|
+
dockerode: "^4.0.2",
|
|
47422
|
+
dotenv: "^16.4.5",
|
|
47423
|
+
inquirer: "^9.2.19",
|
|
47424
|
+
"node-fetch": "^2.7.0",
|
|
47425
|
+
open: "^10.1.0",
|
|
47426
|
+
"update-check": "^1.5.4",
|
|
47427
|
+
uuid: "^9.0.1",
|
|
47428
|
+
vitest: "^2.1.4"
|
|
47429
|
+
}
|
|
47430
|
+
};
|
|
46425
47431
|
|
|
46426
47432
|
// src/lib/config/text.ts
|
|
46427
47433
|
var CLI_DESCRIPTION = "GenLayer CLI is a development environment for the GenLayer ecosystem. It allows developers to interact with the protocol by creating accounts, sending transactions, and working with Intelligent Contracts by testing, debugging, and deploying them.";
|
|
@@ -46432,6 +47438,7 @@ var fs5 = __toESM(require("fs"));
|
|
|
46432
47438
|
var dotenv = __toESM(require_main());
|
|
46433
47439
|
var path2 = __toESM(require("path"));
|
|
46434
47440
|
var semver = __toESM(require_semver2());
|
|
47441
|
+
var import_update_check = __toESM(require_update_check());
|
|
46435
47442
|
|
|
46436
47443
|
// src/lib/clients/jsonRpcClient.ts
|
|
46437
47444
|
var import_node_fetch = __toESM(require_lib2());
|
|
@@ -47126,6 +48133,17 @@ var SimulatorService = class {
|
|
|
47126
48133
|
}).join("\n");
|
|
47127
48134
|
fs5.writeFileSync(envFilePath, updatedConfig);
|
|
47128
48135
|
}
|
|
48136
|
+
checkCliVersion() {
|
|
48137
|
+
return __async(this, null, function* () {
|
|
48138
|
+
const update = yield (0, import_update_check.default)(package_default);
|
|
48139
|
+
if (update && update.latest !== package_default.version) {
|
|
48140
|
+
console.warn(`
|
|
48141
|
+
A new version (${update.latest}) is available! You're using version ${package_default.version}.
|
|
48142
|
+
Run npm install -g genlayer to update
|
|
48143
|
+
`);
|
|
48144
|
+
}
|
|
48145
|
+
});
|
|
48146
|
+
}
|
|
47129
48147
|
checkInstallRequirements() {
|
|
47130
48148
|
return __async(this, null, function* () {
|
|
47131
48149
|
const requirementsInstalled = {
|
|
@@ -49961,6 +50979,7 @@ function initAction(options, simulatorService) {
|
|
|
49961
50979
|
return __async(this, null, function* () {
|
|
49962
50980
|
simulatorService.setSimulatorLocation(options.location);
|
|
49963
50981
|
simulatorService.setComposeOptions(options.headless);
|
|
50982
|
+
yield simulatorService.checkCliVersion();
|
|
49964
50983
|
try {
|
|
49965
50984
|
const requirementsInstalled = yield simulatorService.checkInstallRequirements();
|
|
49966
50985
|
const requirementErrorMessage = getRequirementsErrorMessage(requirementsInstalled);
|
|
@@ -50132,6 +51151,7 @@ function startAction(options, simulatorService) {
|
|
|
50132
51151
|
const { resetValidators, numValidators, branch, location, headless, resetDb } = options;
|
|
50133
51152
|
simulatorService.setComposeOptions(headless);
|
|
50134
51153
|
simulatorService.setSimulatorLocation(location);
|
|
51154
|
+
yield simulatorService.checkCliVersion();
|
|
50135
51155
|
const restartValidatorsHintText = resetValidators ? `creating new ${numValidators} random validators` : "keeping the existing validators";
|
|
50136
51156
|
console.log(`Starting GenLayer simulator ${restartValidatorsHintText}`);
|
|
50137
51157
|
console.log(`Updating GenLayer Simulator...`);
|
|
@@ -50260,6 +51280,34 @@ safe-buffer/index.js:
|
|
|
50260
51280
|
* ------------------------------------------------------------------------
|
|
50261
51281
|
*)
|
|
50262
51282
|
|
|
51283
|
+
deep-extend/lib/deep-extend.js:
|
|
51284
|
+
(*!
|
|
51285
|
+
* @description Recursive object extending
|
|
51286
|
+
* @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
|
|
51287
|
+
* @license MIT
|
|
51288
|
+
*
|
|
51289
|
+
* The MIT License (MIT)
|
|
51290
|
+
*
|
|
51291
|
+
* Copyright (c) 2013-2018 Viacheslav Lotsmanov
|
|
51292
|
+
*
|
|
51293
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
51294
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
51295
|
+
* the Software without restriction, including without limitation the rights to
|
|
51296
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
51297
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
51298
|
+
* subject to the following conditions:
|
|
51299
|
+
*
|
|
51300
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
51301
|
+
* copies or substantial portions of the Software.
|
|
51302
|
+
*
|
|
51303
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
51304
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
51305
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
51306
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
51307
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
51308
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
51309
|
+
*)
|
|
51310
|
+
|
|
50263
51311
|
tmp/lib/tmp.js:
|
|
50264
51312
|
(*!
|
|
50265
51313
|
* Tmp
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genlayer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "GenLayer Command Line Tool",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"bin": {
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"inquirer": "^9.2.19",
|
|
62
62
|
"node-fetch": "^2.7.0",
|
|
63
63
|
"open": "^10.1.0",
|
|
64
|
+
"update-check": "^1.5.4",
|
|
64
65
|
"uuid": "^9.0.1",
|
|
65
66
|
"vitest": "^2.1.4"
|
|
66
67
|
}
|
|
@@ -42,6 +42,8 @@ export async function initAction(options: InitActionOptions, simulatorService: I
|
|
|
42
42
|
simulatorService.setSimulatorLocation(options.location);
|
|
43
43
|
simulatorService.setComposeOptions(options.headless);
|
|
44
44
|
|
|
45
|
+
await simulatorService.checkCliVersion();
|
|
46
|
+
|
|
45
47
|
// Check if requirements are installed
|
|
46
48
|
try {
|
|
47
49
|
const requirementsInstalled = await simulatorService.checkInstallRequirements();
|
|
@@ -17,6 +17,7 @@ export async function startAction(options: StartActionOptions, simulatorService:
|
|
|
17
17
|
simulatorService.setComposeOptions(headless);
|
|
18
18
|
simulatorService.setSimulatorLocation(location);
|
|
19
19
|
|
|
20
|
+
await simulatorService.checkCliVersion();
|
|
20
21
|
|
|
21
22
|
const restartValidatorsHintText = resetValidators
|
|
22
23
|
? `creating new ${numValidators} random validators`
|
|
@@ -3,6 +3,8 @@ import * as fs from "fs";
|
|
|
3
3
|
import * as dotenv from "dotenv";
|
|
4
4
|
import * as path from "path";
|
|
5
5
|
import * as semver from "semver";
|
|
6
|
+
import updateCheck from "update-check";
|
|
7
|
+
import pkg from '../../../package.json'
|
|
6
8
|
|
|
7
9
|
import {rpcClient} from "../clients/jsonRpcClient";
|
|
8
10
|
import {
|
|
@@ -93,6 +95,13 @@ export class SimulatorService implements ISimulatorService {
|
|
|
93
95
|
fs.writeFileSync(envFilePath, updatedConfig);
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
public async checkCliVersion(): Promise<void> {
|
|
99
|
+
const update = await updateCheck(pkg);
|
|
100
|
+
if (update && update.latest !== pkg.version) {
|
|
101
|
+
console.warn(`\nA new version (${update.latest}) is available! You're using version ${pkg.version}.\nRun npm install -g genlayer to update\n`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
public async checkInstallRequirements(): Promise<Record<string, boolean>> {
|
|
97
106
|
const requirementsInstalled = {
|
|
98
107
|
git: false,
|
|
@@ -32,6 +32,7 @@ describe("startAction - Additional Tests", () => {
|
|
|
32
32
|
openFrontend: vi.fn().mockResolvedValue(undefined),
|
|
33
33
|
setSimulatorLocation: vi.fn().mockResolvedValue(undefined),
|
|
34
34
|
setComposeOptions: vi.fn(),
|
|
35
|
+
checkCliVersion: vi.fn(),
|
|
35
36
|
getAiProvidersOptions: vi.fn(() => [
|
|
36
37
|
{ name: "Provider A", value: "providerA" },
|
|
37
38
|
{ name: "Provider B", value: "providerB" },
|
|
@@ -21,7 +21,15 @@ import { rpcClient } from "../../src/lib/clients/jsonRpcClient";
|
|
|
21
21
|
import * as semver from "semver";
|
|
22
22
|
import Docker from "dockerode";
|
|
23
23
|
import {VersionRequiredError} from "../../src/lib/errors/versionRequired";
|
|
24
|
+
import updateCheck from "update-check";
|
|
24
25
|
|
|
26
|
+
vi.mock("../../package.json", () => ({
|
|
27
|
+
default: { version: "1.0.0", name: "genlayer" },
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
vi.mock("update-check", () => ({
|
|
31
|
+
default: vi.fn(),
|
|
32
|
+
}));
|
|
25
33
|
vi.mock("dockerode");
|
|
26
34
|
vi.mock("fs");
|
|
27
35
|
vi.mock("path");
|
|
@@ -410,4 +418,44 @@ describe("SimulatorService - Docker Tests", () => {
|
|
|
410
418
|
mockPing.mockRejectedValueOnce("Unexpected docker error");
|
|
411
419
|
await expect(simulatorService.checkInstallRequirements()).rejects.toThrow("Unexpected docker error");
|
|
412
420
|
});
|
|
421
|
+
|
|
422
|
+
test("should warn the user when an update is available", async () => {
|
|
423
|
+
const update = { latest: "1.1.0" };
|
|
424
|
+
(updateCheck as any).mockResolvedValue(update);
|
|
425
|
+
|
|
426
|
+
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
427
|
+
|
|
428
|
+
await simulatorService.checkCliVersion();
|
|
429
|
+
|
|
430
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
431
|
+
`\nA new version (${update.latest}) is available! You're using version 1.0.0.\nRun npm install -g genlayer to update\n`
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
consoleWarnSpy.mockRestore();
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
test("should not warn the user when the CLI is up-to-date", async () => {
|
|
438
|
+
const update = { latest: "1.0.0" };
|
|
439
|
+
(updateCheck as any).mockResolvedValue(update);
|
|
440
|
+
|
|
441
|
+
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
442
|
+
|
|
443
|
+
await simulatorService.checkCliVersion();
|
|
444
|
+
|
|
445
|
+
expect(consoleWarnSpy).not.toHaveBeenCalled();
|
|
446
|
+
|
|
447
|
+
consoleWarnSpy.mockRestore();
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
test("should handle update-check returning undefined", async () => {
|
|
451
|
+
(updateCheck as any).mockResolvedValue(undefined);
|
|
452
|
+
|
|
453
|
+
const consoleWarnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
454
|
+
|
|
455
|
+
await simulatorService.checkCliVersion();
|
|
456
|
+
|
|
457
|
+
expect(consoleWarnSpy).not.toHaveBeenCalled();
|
|
458
|
+
|
|
459
|
+
consoleWarnSpy.mockRestore();
|
|
460
|
+
});
|
|
413
461
|
});
|