app-bundler 0.1.12 → 0.1.13
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/lib/bundler.js +1263 -4
- package/lib/cli.js +1263 -4
- package/package.json +2 -1
package/lib/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _node_modules_shellbee_lib_shellbee = {};
|
|
1
2
|
var _node_modules_tslib_tslib = {};
|
|
2
3
|
var _src_Bundler = {};
|
|
3
4
|
var _src_Runner = {};
|
|
@@ -9554,6 +9555,1258 @@ exports.Handlers = [
|
|
|
9554
9555
|
// end:source ./ModuleSimplified.js
|
|
9555
9556
|
|
|
9556
9557
|
|
|
9558
|
+
// source ./ModuleSimplified.js
|
|
9559
|
+
var _node_modules_shellbee_lib_shellbee;
|
|
9560
|
+
(function () {
|
|
9561
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9562
|
+
var define = null;
|
|
9563
|
+
var exports = _node_modules_shellbee_lib_shellbee != null ? _node_modules_shellbee_lib_shellbee : {};
|
|
9564
|
+
var module = { exports: exports };
|
|
9565
|
+
|
|
9566
|
+
|
|
9567
|
+
// source ./RootModule.js
|
|
9568
|
+
(function(){
|
|
9569
|
+
|
|
9570
|
+
var _src_CommunicationChannel = {};
|
|
9571
|
+
var _src_Shell = {};
|
|
9572
|
+
var _src_ValueExtractor = {};
|
|
9573
|
+
var _src_util_ShellErrorExitsHandler = {};
|
|
9574
|
+
var _src_util_ShellParamsUtil = {};
|
|
9575
|
+
var _src_util_ShellWrapperUtil = {};
|
|
9576
|
+
var _src_util_command = {};
|
|
9577
|
+
var _src_util_events = {};
|
|
9578
|
+
var _src_util_path = {};
|
|
9579
|
+
var _src_util_restartSelf = {};
|
|
9580
|
+
var _src_util_serialize = {};
|
|
9581
|
+
|
|
9582
|
+
// source ./ModuleSimplified.js
|
|
9583
|
+
var _src_util_path;
|
|
9584
|
+
(function () {
|
|
9585
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9586
|
+
var define = null;
|
|
9587
|
+
var exports = _src_util_path != null ? _src_util_path : {};
|
|
9588
|
+
var module = { exports: exports };
|
|
9589
|
+
|
|
9590
|
+
"use strict";
|
|
9591
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9592
|
+
exports.path_ensure = void 0;
|
|
9593
|
+
var atma_utils_1 = require("atma-utils");
|
|
9594
|
+
function path_ensure(cwd, base) {
|
|
9595
|
+
if (new atma_utils_1.class_Uri(cwd).isRelative()) {
|
|
9596
|
+
var x = require('path').normalize(atma_utils_1.class_Uri.combine(base, cwd));
|
|
9597
|
+
return x;
|
|
9598
|
+
}
|
|
9599
|
+
return cwd;
|
|
9600
|
+
}
|
|
9601
|
+
exports.path_ensure = path_ensure;
|
|
9602
|
+
;
|
|
9603
|
+
|
|
9604
|
+
function __isObj(x) {
|
|
9605
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
9606
|
+
}
|
|
9607
|
+
if (_src_util_path === module.exports) {
|
|
9608
|
+
// do nothing if
|
|
9609
|
+
} else if (__isObj(_src_util_path) && __isObj(module.exports)) {
|
|
9610
|
+
Object.assign(_src_util_path, module.exports);
|
|
9611
|
+
} else {
|
|
9612
|
+
_src_util_path = module.exports;
|
|
9613
|
+
}
|
|
9614
|
+
|
|
9615
|
+
;
|
|
9616
|
+
}());
|
|
9617
|
+
|
|
9618
|
+
// end:source ./ModuleSimplified.js
|
|
9619
|
+
|
|
9620
|
+
|
|
9621
|
+
// source ./ModuleSimplified.js
|
|
9622
|
+
var _src_util_ShellWrapperUtil;
|
|
9623
|
+
(function () {
|
|
9624
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9625
|
+
var define = null;
|
|
9626
|
+
var exports = _src_util_ShellWrapperUtil != null ? _src_util_ShellWrapperUtil : {};
|
|
9627
|
+
var module = { exports: exports };
|
|
9628
|
+
|
|
9629
|
+
"use strict";
|
|
9630
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
9631
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
9632
|
+
if (ar || !(i in from)) {
|
|
9633
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
9634
|
+
ar[i] = from[i];
|
|
9635
|
+
}
|
|
9636
|
+
}
|
|
9637
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9638
|
+
};
|
|
9639
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9640
|
+
exports.ShellWrapperUtil = void 0;
|
|
9641
|
+
var COMMAND_PLACEHOLDER = '%COMMAND%';
|
|
9642
|
+
var ShellWrapperUtil;
|
|
9643
|
+
(function (ShellWrapperUtil) {
|
|
9644
|
+
function prefix(args, config) {
|
|
9645
|
+
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
9646
|
+
return args;
|
|
9647
|
+
}
|
|
9648
|
+
if (Array.isArray(config.shell) === false) {
|
|
9649
|
+
throw new Error("We can prefix only array of strings(argumnets)");
|
|
9650
|
+
return;
|
|
9651
|
+
}
|
|
9652
|
+
var _a = config.shell, exec = _a[0], rest = _a.slice(1);
|
|
9653
|
+
return __spreadArray(__spreadArray([exec], rest, true), args, true);
|
|
9654
|
+
}
|
|
9655
|
+
ShellWrapperUtil.prefix = prefix;
|
|
9656
|
+
function wrap(command, config) {
|
|
9657
|
+
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
9658
|
+
return command;
|
|
9659
|
+
}
|
|
9660
|
+
if (typeof config.shell !== 'string') {
|
|
9661
|
+
throw new Error("We can wrap only as command template");
|
|
9662
|
+
return;
|
|
9663
|
+
}
|
|
9664
|
+
if (command.includes('"') === false) {
|
|
9665
|
+
command = "\"".concat(command, "\"");
|
|
9666
|
+
}
|
|
9667
|
+
else if (command.includes("'") === false) {
|
|
9668
|
+
command = "'".concat(command, "'");
|
|
9669
|
+
}
|
|
9670
|
+
else {
|
|
9671
|
+
throw new Error("Command can't be quoted, as both already present");
|
|
9672
|
+
}
|
|
9673
|
+
return config.shell.replace(COMMAND_PLACEHOLDER, command);
|
|
9674
|
+
}
|
|
9675
|
+
ShellWrapperUtil.wrap = wrap;
|
|
9676
|
+
// [cmd, /c, ...command]
|
|
9677
|
+
function isPrefix(shell) {
|
|
9678
|
+
return shell != null && Array.isArray(shell);
|
|
9679
|
+
}
|
|
9680
|
+
ShellWrapperUtil.isPrefix = isPrefix;
|
|
9681
|
+
// bash.exe -c %COMMAND%
|
|
9682
|
+
function isWrapper(shell) {
|
|
9683
|
+
return shell != null && typeof shell === 'string' && shell.includes(COMMAND_PLACEHOLDER);
|
|
9684
|
+
}
|
|
9685
|
+
ShellWrapperUtil.isWrapper = isWrapper;
|
|
9686
|
+
})(ShellWrapperUtil = exports.ShellWrapperUtil || (exports.ShellWrapperUtil = {}));
|
|
9687
|
+
;
|
|
9688
|
+
|
|
9689
|
+
function __isObj(x) {
|
|
9690
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
9691
|
+
}
|
|
9692
|
+
if (_src_util_ShellWrapperUtil === module.exports) {
|
|
9693
|
+
// do nothing if
|
|
9694
|
+
} else if (__isObj(_src_util_ShellWrapperUtil) && __isObj(module.exports)) {
|
|
9695
|
+
Object.assign(_src_util_ShellWrapperUtil, module.exports);
|
|
9696
|
+
} else {
|
|
9697
|
+
_src_util_ShellWrapperUtil = module.exports;
|
|
9698
|
+
}
|
|
9699
|
+
|
|
9700
|
+
;
|
|
9701
|
+
}());
|
|
9702
|
+
|
|
9703
|
+
// end:source ./ModuleSimplified.js
|
|
9704
|
+
|
|
9705
|
+
|
|
9706
|
+
// source ./ModuleSimplified.js
|
|
9707
|
+
var _src_util_command;
|
|
9708
|
+
(function () {
|
|
9709
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9710
|
+
var define = null;
|
|
9711
|
+
var exports = _src_util_command != null ? _src_util_command : {};
|
|
9712
|
+
var module = { exports: exports };
|
|
9713
|
+
|
|
9714
|
+
"use strict";
|
|
9715
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9716
|
+
exports.command_parseAll = void 0;
|
|
9717
|
+
var path_1 = _src_util_path;
|
|
9718
|
+
var ShellWrapperUtil_1 = _src_util_ShellWrapperUtil;
|
|
9719
|
+
function command_parseAll(commands, params) {
|
|
9720
|
+
var _a;
|
|
9721
|
+
var cwdAll = (_a = params.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
9722
|
+
cwdAll = (0, path_1.path_ensure)(cwdAll, process.cwd());
|
|
9723
|
+
return commands.map(function (command) {
|
|
9724
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
9725
|
+
var opts = typeof command === 'string' ? {
|
|
9726
|
+
exec: command
|
|
9727
|
+
} : command;
|
|
9728
|
+
if (opts.cwd) {
|
|
9729
|
+
opts.cwd = (0, path_1.path_ensure)(opts.cwd, cwdAll !== null && cwdAll !== void 0 ? cwdAll : process.cwd());
|
|
9730
|
+
}
|
|
9731
|
+
var exec = opts.exec;
|
|
9732
|
+
if (exec == null || exec === '') {
|
|
9733
|
+
console.warn('Command Object is not valid. Should be at least {command: string}');
|
|
9734
|
+
return null;
|
|
9735
|
+
}
|
|
9736
|
+
var args = command_parse(exec, params);
|
|
9737
|
+
return {
|
|
9738
|
+
exec: args.shift(),
|
|
9739
|
+
args: args,
|
|
9740
|
+
cwd: (_b = (_a = opts.cwd) !== null && _a !== void 0 ? _a : cwdAll) !== null && _b !== void 0 ? _b : process.cwd(),
|
|
9741
|
+
//stdio: 'pipe',
|
|
9742
|
+
detached: (_d = (_c = opts.detached) !== null && _c !== void 0 ? _c : params.detached) !== null && _d !== void 0 ? _d : false,
|
|
9743
|
+
command: exec,
|
|
9744
|
+
matchReady: (_e = opts.matchReady) !== null && _e !== void 0 ? _e : params.matchReady,
|
|
9745
|
+
extract: opts.extract,
|
|
9746
|
+
fork: (_g = (_f = opts.fork) !== null && _f !== void 0 ? _f : params.fork) !== null && _g !== void 0 ? _g : false,
|
|
9747
|
+
ipc: (_j = (_h = opts.ipc) !== null && _h !== void 0 ? _h : params.ipc) !== null && _j !== void 0 ? _j : false,
|
|
9748
|
+
};
|
|
9749
|
+
}).filter(function (x) { return x != null; });
|
|
9750
|
+
}
|
|
9751
|
+
exports.command_parseAll = command_parseAll;
|
|
9752
|
+
function command_parse(command, params) {
|
|
9753
|
+
if (ShellWrapperUtil_1.ShellWrapperUtil.isWrapper(params.shell)) {
|
|
9754
|
+
command = ShellWrapperUtil_1.ShellWrapperUtil.wrap(command, params);
|
|
9755
|
+
}
|
|
9756
|
+
var parts = command.trim().split(/\s+/);
|
|
9757
|
+
var imax = parts.length;
|
|
9758
|
+
var i = -1;
|
|
9759
|
+
while (++i < imax) {
|
|
9760
|
+
var arg = parts[i];
|
|
9761
|
+
if (arg.length === 0) {
|
|
9762
|
+
continue;
|
|
9763
|
+
}
|
|
9764
|
+
var c = arg[0];
|
|
9765
|
+
if (c !== '"' && c !== "'") {
|
|
9766
|
+
continue;
|
|
9767
|
+
}
|
|
9768
|
+
var start = i;
|
|
9769
|
+
for (; i < imax; i++) {
|
|
9770
|
+
arg = parts[i];
|
|
9771
|
+
if (arg[arg.length - 1] === c) {
|
|
9772
|
+
var str = parts
|
|
9773
|
+
.splice(start, i - start + 1)
|
|
9774
|
+
.join(' ')
|
|
9775
|
+
.slice(1, -1);
|
|
9776
|
+
parts.splice(start, 0, str);
|
|
9777
|
+
imax = parts.length;
|
|
9778
|
+
i--;
|
|
9779
|
+
break;
|
|
9780
|
+
}
|
|
9781
|
+
}
|
|
9782
|
+
}
|
|
9783
|
+
// On windows normalize executable command path to backward slashes
|
|
9784
|
+
if (global.process.platform === 'win32') {
|
|
9785
|
+
parts[0] = parts[0].replace(/\//g, '\\');
|
|
9786
|
+
}
|
|
9787
|
+
if (ShellWrapperUtil_1.ShellWrapperUtil.isPrefix(params.shell)) {
|
|
9788
|
+
parts = ShellWrapperUtil_1.ShellWrapperUtil.prefix(parts, params);
|
|
9789
|
+
}
|
|
9790
|
+
return parts;
|
|
9791
|
+
}
|
|
9792
|
+
;
|
|
9793
|
+
|
|
9794
|
+
function __isObj(x) {
|
|
9795
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
9796
|
+
}
|
|
9797
|
+
if (_src_util_command === module.exports) {
|
|
9798
|
+
// do nothing if
|
|
9799
|
+
} else if (__isObj(_src_util_command) && __isObj(module.exports)) {
|
|
9800
|
+
Object.assign(_src_util_command, module.exports);
|
|
9801
|
+
} else {
|
|
9802
|
+
_src_util_command = module.exports;
|
|
9803
|
+
}
|
|
9804
|
+
|
|
9805
|
+
;
|
|
9806
|
+
}());
|
|
9807
|
+
|
|
9808
|
+
// end:source ./ModuleSimplified.js
|
|
9809
|
+
|
|
9810
|
+
|
|
9811
|
+
// source ./ModuleSimplified.js
|
|
9812
|
+
var _src_ValueExtractor;
|
|
9813
|
+
(function () {
|
|
9814
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9815
|
+
var define = null;
|
|
9816
|
+
var exports = _src_ValueExtractor != null ? _src_ValueExtractor : {};
|
|
9817
|
+
var module = { exports: exports };
|
|
9818
|
+
|
|
9819
|
+
"use strict";
|
|
9820
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9821
|
+
exports.ValueExtractor = void 0;
|
|
9822
|
+
var atma_utils_1 = require("atma-utils");
|
|
9823
|
+
var ValueExtractor = /** @class */ (function () {
|
|
9824
|
+
function ValueExtractor(target, extractors) {
|
|
9825
|
+
this.target = target;
|
|
9826
|
+
this.extractors = extractors;
|
|
9827
|
+
this.string = '';
|
|
9828
|
+
this.string = '';
|
|
9829
|
+
}
|
|
9830
|
+
ValueExtractor.prototype.write = function (buffer) {
|
|
9831
|
+
this.string += buffer.toString();
|
|
9832
|
+
};
|
|
9833
|
+
ValueExtractor.prototype.complete = function () {
|
|
9834
|
+
for (var key in this.extractors) {
|
|
9835
|
+
this.target[key] = (0, atma_utils_1.is_Function)(this.extractors[key])
|
|
9836
|
+
? this.extractors[key](this.string)
|
|
9837
|
+
: null;
|
|
9838
|
+
}
|
|
9839
|
+
};
|
|
9840
|
+
ValueExtractor.extract = function (str, mix) {
|
|
9841
|
+
if (typeof mix === 'function') {
|
|
9842
|
+
return mix(str);
|
|
9843
|
+
}
|
|
9844
|
+
};
|
|
9845
|
+
ValueExtractor.interpolateAny = function (mix, values, options) {
|
|
9846
|
+
if (mix == null || (options === null || options === void 0 ? void 0 : options.interpolate) === false) {
|
|
9847
|
+
return mix;
|
|
9848
|
+
}
|
|
9849
|
+
if (typeof mix === 'string') {
|
|
9850
|
+
return ValueExtractor.interpolateStr(mix, values);
|
|
9851
|
+
}
|
|
9852
|
+
if (typeof mix.map === 'function') {
|
|
9853
|
+
// isArrayLike
|
|
9854
|
+
return mix.map(function (str) {
|
|
9855
|
+
return ValueExtractor.interpolateAny(str, values, options);
|
|
9856
|
+
});
|
|
9857
|
+
}
|
|
9858
|
+
return mix;
|
|
9859
|
+
};
|
|
9860
|
+
ValueExtractor.interpolateStr = function (str, values) {
|
|
9861
|
+
return str.replace(/\{\{(\w+)\}\}/g, function (full, prop) {
|
|
9862
|
+
var val = values[prop];
|
|
9863
|
+
if (val == null) {
|
|
9864
|
+
console.warn('Extracted property expected: ', prop, values);
|
|
9865
|
+
return '';
|
|
9866
|
+
}
|
|
9867
|
+
return val;
|
|
9868
|
+
});
|
|
9869
|
+
};
|
|
9870
|
+
return ValueExtractor;
|
|
9871
|
+
}());
|
|
9872
|
+
exports.ValueExtractor = ValueExtractor;
|
|
9873
|
+
;
|
|
9874
|
+
|
|
9875
|
+
function __isObj(x) {
|
|
9876
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
9877
|
+
}
|
|
9878
|
+
if (_src_ValueExtractor === module.exports) {
|
|
9879
|
+
// do nothing if
|
|
9880
|
+
} else if (__isObj(_src_ValueExtractor) && __isObj(module.exports)) {
|
|
9881
|
+
Object.assign(_src_ValueExtractor, module.exports);
|
|
9882
|
+
} else {
|
|
9883
|
+
_src_ValueExtractor = module.exports;
|
|
9884
|
+
}
|
|
9885
|
+
|
|
9886
|
+
;
|
|
9887
|
+
}());
|
|
9888
|
+
|
|
9889
|
+
// end:source ./ModuleSimplified.js
|
|
9890
|
+
|
|
9891
|
+
|
|
9892
|
+
// source ./ModuleSimplified.js
|
|
9893
|
+
var _src_util_serialize;
|
|
9894
|
+
(function () {
|
|
9895
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9896
|
+
var define = null;
|
|
9897
|
+
var exports = _src_util_serialize != null ? _src_util_serialize : {};
|
|
9898
|
+
var module = { exports: exports };
|
|
9899
|
+
|
|
9900
|
+
"use strict";
|
|
9901
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9902
|
+
exports.serialize_error = void 0;
|
|
9903
|
+
function serialize_error(err) {
|
|
9904
|
+
var _a;
|
|
9905
|
+
return {
|
|
9906
|
+
message: (_a = err.message) !== null && _a !== void 0 ? _a : String(err),
|
|
9907
|
+
stack: err.stack
|
|
9908
|
+
};
|
|
9909
|
+
}
|
|
9910
|
+
exports.serialize_error = serialize_error;
|
|
9911
|
+
;
|
|
9912
|
+
|
|
9913
|
+
function __isObj(x) {
|
|
9914
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
9915
|
+
}
|
|
9916
|
+
if (_src_util_serialize === module.exports) {
|
|
9917
|
+
// do nothing if
|
|
9918
|
+
} else if (__isObj(_src_util_serialize) && __isObj(module.exports)) {
|
|
9919
|
+
Object.assign(_src_util_serialize, module.exports);
|
|
9920
|
+
} else {
|
|
9921
|
+
_src_util_serialize = module.exports;
|
|
9922
|
+
}
|
|
9923
|
+
|
|
9924
|
+
;
|
|
9925
|
+
}());
|
|
9926
|
+
|
|
9927
|
+
// end:source ./ModuleSimplified.js
|
|
9928
|
+
|
|
9929
|
+
|
|
9930
|
+
// source ./ModuleSimplified.js
|
|
9931
|
+
var _src_CommunicationChannel;
|
|
9932
|
+
(function () {
|
|
9933
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9934
|
+
var define = null;
|
|
9935
|
+
var exports = _src_CommunicationChannel != null ? _src_CommunicationChannel : {};
|
|
9936
|
+
var module = { exports: exports };
|
|
9937
|
+
|
|
9938
|
+
"use strict";
|
|
9939
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9940
|
+
exports.CommunicationChannel = void 0;
|
|
9941
|
+
var atma_utils_1 = require("atma-utils");
|
|
9942
|
+
var serialize_1 = _src_util_serialize;
|
|
9943
|
+
var CommunicationChannel = /** @class */ (function () {
|
|
9944
|
+
function CommunicationChannel(child, timeoutMs) {
|
|
9945
|
+
var _this = this;
|
|
9946
|
+
this.child = child;
|
|
9947
|
+
this.timeoutMs = timeoutMs;
|
|
9948
|
+
this.awaiters = Object.create(null);
|
|
9949
|
+
child.on('message', function (resp) {
|
|
9950
|
+
if (resp.id == null || resp.id in _this.awaiters === false) {
|
|
9951
|
+
return;
|
|
9952
|
+
}
|
|
9953
|
+
var awaiter = _this.awaiters[resp.id];
|
|
9954
|
+
delete _this.awaiters[resp.id];
|
|
9955
|
+
if (resp.error) {
|
|
9956
|
+
awaiter.promise.reject(resp.error);
|
|
9957
|
+
return;
|
|
9958
|
+
}
|
|
9959
|
+
awaiter.promise.resolve(resp.data);
|
|
9960
|
+
});
|
|
9961
|
+
}
|
|
9962
|
+
CommunicationChannel.ipc = function (handlers) {
|
|
9963
|
+
process.on('message', function (message) {
|
|
9964
|
+
var id = message.id, method = message.method, args = message.args;
|
|
9965
|
+
var handler = (0, atma_utils_1.obj_getProperty)(handlers, method);
|
|
9966
|
+
if (typeof handler !== 'function') {
|
|
9967
|
+
process.send({
|
|
9968
|
+
id: id,
|
|
9969
|
+
error: (0, serialize_1.serialize_error)(new Error("".concat(method, " not defined")))
|
|
9970
|
+
});
|
|
9971
|
+
return;
|
|
9972
|
+
}
|
|
9973
|
+
try {
|
|
9974
|
+
var result = handler.apply(null, args);
|
|
9975
|
+
if (result == null) {
|
|
9976
|
+
process.send({
|
|
9977
|
+
id: id,
|
|
9978
|
+
data: null
|
|
9979
|
+
});
|
|
9980
|
+
return;
|
|
9981
|
+
}
|
|
9982
|
+
if (typeof result.then === 'function') {
|
|
9983
|
+
result.then(function (data) {
|
|
9984
|
+
process.send({
|
|
9985
|
+
id: id,
|
|
9986
|
+
data: data
|
|
9987
|
+
});
|
|
9988
|
+
}, function (error) {
|
|
9989
|
+
process.send({
|
|
9990
|
+
id: id,
|
|
9991
|
+
error: (0, serialize_1.serialize_error)(error),
|
|
9992
|
+
});
|
|
9993
|
+
});
|
|
9994
|
+
return;
|
|
9995
|
+
}
|
|
9996
|
+
process.send({
|
|
9997
|
+
id: id,
|
|
9998
|
+
data: result
|
|
9999
|
+
});
|
|
10000
|
+
}
|
|
10001
|
+
catch (error) {
|
|
10002
|
+
process.send({
|
|
10003
|
+
id: id,
|
|
10004
|
+
error: (0, serialize_1.serialize_error)(error),
|
|
10005
|
+
});
|
|
10006
|
+
return;
|
|
10007
|
+
}
|
|
10008
|
+
});
|
|
10009
|
+
setTimeout(function () { return console.log('IPC Listening'); }, 10);
|
|
10010
|
+
};
|
|
10011
|
+
CommunicationChannel.prototype.call = function (method) {
|
|
10012
|
+
var _this = this;
|
|
10013
|
+
var args = [];
|
|
10014
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10015
|
+
args[_i - 1] = arguments[_i];
|
|
10016
|
+
}
|
|
10017
|
+
var promise = new atma_utils_1.class_Dfr;
|
|
10018
|
+
var id = (Math.round(Math.random() * Math.pow(10, 10))) + '' + Date.now();
|
|
10019
|
+
this.awaiters[id] = {
|
|
10020
|
+
timestamp: Date.now(),
|
|
10021
|
+
promise: promise
|
|
10022
|
+
};
|
|
10023
|
+
this.child.send({
|
|
10024
|
+
id: id,
|
|
10025
|
+
method: method,
|
|
10026
|
+
args: args
|
|
10027
|
+
});
|
|
10028
|
+
if (this.timeoutMs) {
|
|
10029
|
+
setTimeout(function () { return _this.checkTimeout(); }, this.timeoutMs);
|
|
10030
|
+
}
|
|
10031
|
+
return promise;
|
|
10032
|
+
};
|
|
10033
|
+
CommunicationChannel.prototype.checkTimeout = function () {
|
|
10034
|
+
var _this = this;
|
|
10035
|
+
var now = Date.now();
|
|
10036
|
+
var keys = [];
|
|
10037
|
+
for (var key in this.awaiters) {
|
|
10038
|
+
var bin = this.awaiters[key];
|
|
10039
|
+
var ms = now - bin.timestamp;
|
|
10040
|
+
if (ms >= this.timeoutMs) {
|
|
10041
|
+
try {
|
|
10042
|
+
bin.promise.reject(new Error('Timeouted'));
|
|
10043
|
+
}
|
|
10044
|
+
catch (error) { }
|
|
10045
|
+
keys.push(key);
|
|
10046
|
+
}
|
|
10047
|
+
}
|
|
10048
|
+
keys.forEach(function (key) { return delete _this.awaiters[key]; });
|
|
10049
|
+
};
|
|
10050
|
+
CommunicationChannel.prototype.onError = function (error) {
|
|
10051
|
+
var obj = Object.create(this.awaiters);
|
|
10052
|
+
this.awaiters = {};
|
|
10053
|
+
for (var key in obj) {
|
|
10054
|
+
var bin = obj[key];
|
|
10055
|
+
try {
|
|
10056
|
+
bin.promise.reject(error);
|
|
10057
|
+
}
|
|
10058
|
+
catch (error) { }
|
|
10059
|
+
}
|
|
10060
|
+
};
|
|
10061
|
+
CommunicationChannel.prototype.onStdError = function (str) {
|
|
10062
|
+
this.onError(new Error(str));
|
|
10063
|
+
};
|
|
10064
|
+
return CommunicationChannel;
|
|
10065
|
+
}());
|
|
10066
|
+
exports.CommunicationChannel = CommunicationChannel;
|
|
10067
|
+
;
|
|
10068
|
+
|
|
10069
|
+
function __isObj(x) {
|
|
10070
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10071
|
+
}
|
|
10072
|
+
if (_src_CommunicationChannel === module.exports) {
|
|
10073
|
+
// do nothing if
|
|
10074
|
+
} else if (__isObj(_src_CommunicationChannel) && __isObj(module.exports)) {
|
|
10075
|
+
Object.assign(_src_CommunicationChannel, module.exports);
|
|
10076
|
+
} else {
|
|
10077
|
+
_src_CommunicationChannel = module.exports;
|
|
10078
|
+
}
|
|
10079
|
+
|
|
10080
|
+
;
|
|
10081
|
+
}());
|
|
10082
|
+
|
|
10083
|
+
// end:source ./ModuleSimplified.js
|
|
10084
|
+
|
|
10085
|
+
|
|
10086
|
+
// source ./ModuleSimplified.js
|
|
10087
|
+
var _src_util_events;
|
|
10088
|
+
(function () {
|
|
10089
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
10090
|
+
var define = null;
|
|
10091
|
+
var exports = _src_util_events != null ? _src_util_events : {};
|
|
10092
|
+
var module = { exports: exports };
|
|
10093
|
+
|
|
10094
|
+
"use strict";
|
|
10095
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10096
|
+
exports.events_someOnce = void 0;
|
|
10097
|
+
function events_someOnce(emitter, events) {
|
|
10098
|
+
var listeners = {};
|
|
10099
|
+
for (var event in events) {
|
|
10100
|
+
emitter.on(event, delegate(emitter, listeners, event, events[event]));
|
|
10101
|
+
}
|
|
10102
|
+
}
|
|
10103
|
+
exports.events_someOnce = events_someOnce;
|
|
10104
|
+
function delegate(emitter, listeners, event, cb) {
|
|
10105
|
+
function fn() {
|
|
10106
|
+
var args = [];
|
|
10107
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10108
|
+
args[_i] = arguments[_i];
|
|
10109
|
+
}
|
|
10110
|
+
for (var event_1 in listeners) {
|
|
10111
|
+
emitter.off(event_1, listeners[event_1]);
|
|
10112
|
+
}
|
|
10113
|
+
cb === null || cb === void 0 ? void 0 : cb.apply(void 0, args);
|
|
10114
|
+
}
|
|
10115
|
+
listeners[event] = fn;
|
|
10116
|
+
return fn;
|
|
10117
|
+
}
|
|
10118
|
+
;
|
|
10119
|
+
|
|
10120
|
+
function __isObj(x) {
|
|
10121
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10122
|
+
}
|
|
10123
|
+
if (_src_util_events === module.exports) {
|
|
10124
|
+
// do nothing if
|
|
10125
|
+
} else if (__isObj(_src_util_events) && __isObj(module.exports)) {
|
|
10126
|
+
Object.assign(_src_util_events, module.exports);
|
|
10127
|
+
} else {
|
|
10128
|
+
_src_util_events = module.exports;
|
|
10129
|
+
}
|
|
10130
|
+
|
|
10131
|
+
;
|
|
10132
|
+
}());
|
|
10133
|
+
|
|
10134
|
+
// end:source ./ModuleSimplified.js
|
|
10135
|
+
|
|
10136
|
+
|
|
10137
|
+
// source ./ModuleSimplified.js
|
|
10138
|
+
var _src_util_ShellParamsUtil;
|
|
10139
|
+
(function () {
|
|
10140
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
10141
|
+
var define = null;
|
|
10142
|
+
var exports = _src_util_ShellParamsUtil != null ? _src_util_ShellParamsUtil : {};
|
|
10143
|
+
var module = { exports: exports };
|
|
10144
|
+
|
|
10145
|
+
"use strict";
|
|
10146
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10147
|
+
exports.ShellParamsUtil = void 0;
|
|
10148
|
+
var ShellParamsUtil;
|
|
10149
|
+
(function (ShellParamsUtil) {
|
|
10150
|
+
function normalize(params) {
|
|
10151
|
+
var _a, _b;
|
|
10152
|
+
if (params.shell == null && !params.fork) {
|
|
10153
|
+
params.shell = DEFAULT.shell;
|
|
10154
|
+
}
|
|
10155
|
+
if (params.command != null) {
|
|
10156
|
+
params.commands = [params.command];
|
|
10157
|
+
}
|
|
10158
|
+
if (params.commands == null) {
|
|
10159
|
+
throw new Error("shellbee: Command(s) are not defined");
|
|
10160
|
+
}
|
|
10161
|
+
(_a = params.parallel) !== null && _a !== void 0 ? _a : (params.parallel = false);
|
|
10162
|
+
(_b = params.restartOnErrorExit) !== null && _b !== void 0 ? _b : (params.restartOnErrorExit = false);
|
|
10163
|
+
return params;
|
|
10164
|
+
}
|
|
10165
|
+
ShellParamsUtil.normalize = normalize;
|
|
10166
|
+
})(ShellParamsUtil = exports.ShellParamsUtil || (exports.ShellParamsUtil = {}));
|
|
10167
|
+
var DEFAULT = {
|
|
10168
|
+
shell: global.process.platform === 'win32'
|
|
10169
|
+
? ['cmd.exe', '/C']
|
|
10170
|
+
: null
|
|
10171
|
+
};
|
|
10172
|
+
;
|
|
10173
|
+
|
|
10174
|
+
function __isObj(x) {
|
|
10175
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10176
|
+
}
|
|
10177
|
+
if (_src_util_ShellParamsUtil === module.exports) {
|
|
10178
|
+
// do nothing if
|
|
10179
|
+
} else if (__isObj(_src_util_ShellParamsUtil) && __isObj(module.exports)) {
|
|
10180
|
+
Object.assign(_src_util_ShellParamsUtil, module.exports);
|
|
10181
|
+
} else {
|
|
10182
|
+
_src_util_ShellParamsUtil = module.exports;
|
|
10183
|
+
}
|
|
10184
|
+
|
|
10185
|
+
;
|
|
10186
|
+
}());
|
|
10187
|
+
|
|
10188
|
+
// end:source ./ModuleSimplified.js
|
|
10189
|
+
|
|
10190
|
+
|
|
10191
|
+
// source ./ModuleSimplified.js
|
|
10192
|
+
var _src_util_ShellErrorExitsHandler;
|
|
10193
|
+
(function () {
|
|
10194
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
10195
|
+
var define = null;
|
|
10196
|
+
var exports = _src_util_ShellErrorExitsHandler != null ? _src_util_ShellErrorExitsHandler : {};
|
|
10197
|
+
var module = { exports: exports };
|
|
10198
|
+
|
|
10199
|
+
"use strict";
|
|
10200
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10201
|
+
exports.ShellErrorExitsHandler = void 0;
|
|
10202
|
+
var ShellErrorExitsHandler = /** @class */ (function () {
|
|
10203
|
+
function ShellErrorExitsHandler(params) {
|
|
10204
|
+
var _a, _b, _c;
|
|
10205
|
+
this._active = false;
|
|
10206
|
+
this.options = {
|
|
10207
|
+
delayMs: 200,
|
|
10208
|
+
maxRestartCount: 10,
|
|
10209
|
+
maxRestartTimespanMs: 30 * 1000,
|
|
10210
|
+
};
|
|
10211
|
+
this._params = params;
|
|
10212
|
+
this._errors = [];
|
|
10213
|
+
this._active = params.restartOnErrorExit != null && params.restartOnErrorExit !== false;
|
|
10214
|
+
if (typeof params.restartOnErrorExit !== 'boolean') {
|
|
10215
|
+
var opts = params.restartOnErrorExit;
|
|
10216
|
+
this.options.delayMs = (_a = opts.delayMs) !== null && _a !== void 0 ? _a : this.options.delayMs;
|
|
10217
|
+
this.options.maxRestartCount = (_b = opts.maxRestartCount) !== null && _b !== void 0 ? _b : this.options.maxRestartCount;
|
|
10218
|
+
this.options.maxRestartTimespanMs = (_c = opts.maxRestartTimespanMs) !== null && _c !== void 0 ? _c : this.options.maxRestartTimespanMs;
|
|
10219
|
+
}
|
|
10220
|
+
}
|
|
10221
|
+
ShellErrorExitsHandler.prototype.delay = function (cb) {
|
|
10222
|
+
this._errors.push({ time: Date.now() });
|
|
10223
|
+
setTimeout(function () { return cb(); }, this.options.delayMs);
|
|
10224
|
+
};
|
|
10225
|
+
ShellErrorExitsHandler.prototype.isActive = function () {
|
|
10226
|
+
if (this._active !== true) {
|
|
10227
|
+
return false;
|
|
10228
|
+
}
|
|
10229
|
+
var fromTimePoint = Date.now() - this.options.maxRestartTimespanMs;
|
|
10230
|
+
var errors = this._errors.filter(function (x) { return x.time > fromTimePoint; });
|
|
10231
|
+
if (errors.length < this.options.maxRestartCount) {
|
|
10232
|
+
return true;
|
|
10233
|
+
}
|
|
10234
|
+
return false;
|
|
10235
|
+
};
|
|
10236
|
+
return ShellErrorExitsHandler;
|
|
10237
|
+
}());
|
|
10238
|
+
exports.ShellErrorExitsHandler = ShellErrorExitsHandler;
|
|
10239
|
+
;
|
|
10240
|
+
|
|
10241
|
+
function __isObj(x) {
|
|
10242
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10243
|
+
}
|
|
10244
|
+
if (_src_util_ShellErrorExitsHandler === module.exports) {
|
|
10245
|
+
// do nothing if
|
|
10246
|
+
} else if (__isObj(_src_util_ShellErrorExitsHandler) && __isObj(module.exports)) {
|
|
10247
|
+
Object.assign(_src_util_ShellErrorExitsHandler, module.exports);
|
|
10248
|
+
} else {
|
|
10249
|
+
_src_util_ShellErrorExitsHandler = module.exports;
|
|
10250
|
+
}
|
|
10251
|
+
|
|
10252
|
+
;
|
|
10253
|
+
}());
|
|
10254
|
+
|
|
10255
|
+
// end:source ./ModuleSimplified.js
|
|
10256
|
+
|
|
10257
|
+
|
|
10258
|
+
// source ./ModuleSimplified.js
|
|
10259
|
+
var _src_Shell;
|
|
10260
|
+
(function () {
|
|
10261
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
10262
|
+
var define = null;
|
|
10263
|
+
var exports = _src_Shell != null ? _src_Shell : {};
|
|
10264
|
+
var module = { exports: exports };
|
|
10265
|
+
|
|
10266
|
+
"use strict";
|
|
10267
|
+
var __extends = (this && this.__extends) || (function () {
|
|
10268
|
+
var extendStatics = function (d, b) {
|
|
10269
|
+
extendStatics = Object.setPrototypeOf ||
|
|
10270
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10271
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
10272
|
+
return extendStatics(d, b);
|
|
10273
|
+
};
|
|
10274
|
+
return function (d, b) {
|
|
10275
|
+
if (typeof b !== "function" && b !== null)
|
|
10276
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10277
|
+
extendStatics(d, b);
|
|
10278
|
+
function __() { this.constructor = d; }
|
|
10279
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
10280
|
+
};
|
|
10281
|
+
})();
|
|
10282
|
+
var __assign = (this && this.__assign) || function () {
|
|
10283
|
+
__assign = Object.assign || function(t) {
|
|
10284
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
10285
|
+
s = arguments[i];
|
|
10286
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10287
|
+
t[p] = s[p];
|
|
10288
|
+
}
|
|
10289
|
+
return t;
|
|
10290
|
+
};
|
|
10291
|
+
return __assign.apply(this, arguments);
|
|
10292
|
+
};
|
|
10293
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
10294
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
10295
|
+
if (ar || !(i in from)) {
|
|
10296
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
10297
|
+
ar[i] = from[i];
|
|
10298
|
+
}
|
|
10299
|
+
}
|
|
10300
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10301
|
+
};
|
|
10302
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10303
|
+
exports.ProcessResult = exports.Shell = void 0;
|
|
10304
|
+
var atma_utils_1 = require("atma-utils");
|
|
10305
|
+
var atma_io_1 = require("atma-io");
|
|
10306
|
+
var child_process = require("child_process");
|
|
10307
|
+
var command_1 = _src_util_command;
|
|
10308
|
+
var ValueExtractor_1 = _src_ValueExtractor;
|
|
10309
|
+
var CommunicationChannel_1 = _src_CommunicationChannel;
|
|
10310
|
+
var events_1 = _src_util_events;
|
|
10311
|
+
var treeKill = require("tree-kill");
|
|
10312
|
+
var ShellParamsUtil_1 = _src_util_ShellParamsUtil;
|
|
10313
|
+
var ShellErrorExitsHandler_1 = _src_util_ShellErrorExitsHandler;
|
|
10314
|
+
var Shell = /** @class */ (function (_super) {
|
|
10315
|
+
__extends(Shell, _super);
|
|
10316
|
+
function Shell(params) {
|
|
10317
|
+
var _this = _super.call(this) || this;
|
|
10318
|
+
_this.children = [];
|
|
10319
|
+
_this.errors = [];
|
|
10320
|
+
_this.lastCode = 0;
|
|
10321
|
+
_this.results = [];
|
|
10322
|
+
_this.extracted = {};
|
|
10323
|
+
_this.state = ShellState.Initial;
|
|
10324
|
+
_this.promise = new atma_utils_1.class_Dfr();
|
|
10325
|
+
_this.std = [];
|
|
10326
|
+
_this.stderr = [];
|
|
10327
|
+
_this.stdout = [];
|
|
10328
|
+
_this.isBusy = false;
|
|
10329
|
+
_this.isReady = false;
|
|
10330
|
+
_this.params = ShellParamsUtil_1.ShellParamsUtil.normalize(params);
|
|
10331
|
+
_this.errorsHandler = new ShellErrorExitsHandler_1.ShellErrorExitsHandler(_this.params);
|
|
10332
|
+
_this.commands = (0, command_1.command_parseAll)(params.commands, params);
|
|
10333
|
+
_this.on('process_start', function () {
|
|
10334
|
+
_this.state = ShellState.Started;
|
|
10335
|
+
});
|
|
10336
|
+
return _this;
|
|
10337
|
+
}
|
|
10338
|
+
Shell.run = function (mix) {
|
|
10339
|
+
var params;
|
|
10340
|
+
if (typeof mix === 'string') {
|
|
10341
|
+
params = { command: mix };
|
|
10342
|
+
}
|
|
10343
|
+
else if (Array.isArray(mix)) {
|
|
10344
|
+
params = { commands: mix };
|
|
10345
|
+
}
|
|
10346
|
+
else {
|
|
10347
|
+
params = mix;
|
|
10348
|
+
}
|
|
10349
|
+
return new Shell(params).run();
|
|
10350
|
+
};
|
|
10351
|
+
/**
|
|
10352
|
+
* "Run" starts the command
|
|
10353
|
+
* @returns Promise, which is resolved after the executables are completed.
|
|
10354
|
+
*/
|
|
10355
|
+
Shell.prototype.run = function () {
|
|
10356
|
+
if (this.isBusy === false) {
|
|
10357
|
+
this.next();
|
|
10358
|
+
return this.promise;
|
|
10359
|
+
}
|
|
10360
|
+
return this.promise;
|
|
10361
|
+
};
|
|
10362
|
+
Shell.factory = function (config) {
|
|
10363
|
+
return {
|
|
10364
|
+
run: function (mix) {
|
|
10365
|
+
var params;
|
|
10366
|
+
if (typeof mix === 'string') {
|
|
10367
|
+
params = { command: mix };
|
|
10368
|
+
}
|
|
10369
|
+
else if (Array.isArray(mix)) {
|
|
10370
|
+
params = { commands: mix };
|
|
10371
|
+
}
|
|
10372
|
+
else {
|
|
10373
|
+
params = mix;
|
|
10374
|
+
}
|
|
10375
|
+
return Shell.run(__assign(__assign({}, config), params));
|
|
10376
|
+
}
|
|
10377
|
+
};
|
|
10378
|
+
};
|
|
10379
|
+
Shell.prototype.onStart = function (cb) {
|
|
10380
|
+
return this.on('process_start', cb);
|
|
10381
|
+
};
|
|
10382
|
+
Shell.prototype.onStdout = function (cb) {
|
|
10383
|
+
return this.on('process_stdout', cb);
|
|
10384
|
+
};
|
|
10385
|
+
Shell.prototype.onStderr = function (cb) {
|
|
10386
|
+
return this.on('process_stderr', cb);
|
|
10387
|
+
};
|
|
10388
|
+
Shell.prototype.onExit = function (cb) {
|
|
10389
|
+
return this.on('process_exit', cb);
|
|
10390
|
+
};
|
|
10391
|
+
/** When rgxReady is specified the event will be called */
|
|
10392
|
+
Shell.prototype.onReady = function (cb) {
|
|
10393
|
+
var _a, _b, _c, _d, _e;
|
|
10394
|
+
if (!((_a = this.currentOptions) === null || _a === void 0 ? void 0 : _a.matchReady) && this.commands.some(function (x) { return x.matchReady; }) === false) {
|
|
10395
|
+
console.error('Ready Matcher Regex is not defined', (_c = (_b = this.currentOptions) === null || _b === void 0 ? void 0 : _b.command) !== null && _c !== void 0 ? _c : (_e = (_d = this.commands) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.command);
|
|
10396
|
+
}
|
|
10397
|
+
return this.on('process_ready', cb);
|
|
10398
|
+
};
|
|
10399
|
+
Shell.prototype.onReadyAsync = function () {
|
|
10400
|
+
var _this = this;
|
|
10401
|
+
return new Promise(function (resolve) {
|
|
10402
|
+
_this.onReady(resolve);
|
|
10403
|
+
});
|
|
10404
|
+
};
|
|
10405
|
+
Shell.prototype.onComplete = function (cb) {
|
|
10406
|
+
var _this = this;
|
|
10407
|
+
this.promise.always(function () { return cb(_this); });
|
|
10408
|
+
return this;
|
|
10409
|
+
};
|
|
10410
|
+
Shell.prototype.onCompleteAsync = function () {
|
|
10411
|
+
var _this = this;
|
|
10412
|
+
return new Promise(function (resolve) {
|
|
10413
|
+
_this.onComplete(resolve);
|
|
10414
|
+
});
|
|
10415
|
+
};
|
|
10416
|
+
Shell.prototype.kill = function (signal) {
|
|
10417
|
+
var _this = this;
|
|
10418
|
+
if (signal === void 0) { signal = 'SIGINT'; }
|
|
10419
|
+
return new Promise(function (resolve) {
|
|
10420
|
+
var child = _this.children.pop();
|
|
10421
|
+
if (child == null) {
|
|
10422
|
+
return resolve(null);
|
|
10423
|
+
}
|
|
10424
|
+
_this.once('process_exit', resolve);
|
|
10425
|
+
child.kill(signal);
|
|
10426
|
+
});
|
|
10427
|
+
};
|
|
10428
|
+
/** Uses tree-kill to terminate the tree */
|
|
10429
|
+
Shell.prototype.terminate = function () {
|
|
10430
|
+
var _this = this;
|
|
10431
|
+
return new Promise(function (resolve) {
|
|
10432
|
+
var child = _this.children.pop();
|
|
10433
|
+
if (child == null) {
|
|
10434
|
+
return resolve(null);
|
|
10435
|
+
}
|
|
10436
|
+
_this.once('process_exit', resolve);
|
|
10437
|
+
treeKill(child.pid);
|
|
10438
|
+
});
|
|
10439
|
+
};
|
|
10440
|
+
Shell.prototype.send = function (method) {
|
|
10441
|
+
var _this = this;
|
|
10442
|
+
var args = [];
|
|
10443
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10444
|
+
args[_i - 1] = arguments[_i];
|
|
10445
|
+
}
|
|
10446
|
+
return new Promise(function (resolve, reject) {
|
|
10447
|
+
_this.waitForChannel().then(function (channel) {
|
|
10448
|
+
channel.call.apply(channel, __spreadArray([method], args, false)).then(resolve, reject);
|
|
10449
|
+
}, reject);
|
|
10450
|
+
});
|
|
10451
|
+
};
|
|
10452
|
+
Shell.prototype.waitForChannel = function () {
|
|
10453
|
+
var _this = this;
|
|
10454
|
+
if (this.currentOptions.ipc && this.isReady === false) {
|
|
10455
|
+
return new Promise(function (resolve, reject) {
|
|
10456
|
+
(0, events_1.events_someOnce)(_this, {
|
|
10457
|
+
'process_ready': function () {
|
|
10458
|
+
_this.waitForChannel().then(resolve, reject);
|
|
10459
|
+
},
|
|
10460
|
+
'exit': function () {
|
|
10461
|
+
reject('Process exited');
|
|
10462
|
+
}
|
|
10463
|
+
});
|
|
10464
|
+
});
|
|
10465
|
+
}
|
|
10466
|
+
return new Promise(function (resolve, reject) {
|
|
10467
|
+
if (_this.channel) {
|
|
10468
|
+
resolve(_this.channel);
|
|
10469
|
+
return;
|
|
10470
|
+
}
|
|
10471
|
+
(0, events_1.events_someOnce)(_this, {
|
|
10472
|
+
'channel_created': function () {
|
|
10473
|
+
resolve(_this.channel);
|
|
10474
|
+
},
|
|
10475
|
+
'exit': function () {
|
|
10476
|
+
reject('Process exited');
|
|
10477
|
+
}
|
|
10478
|
+
});
|
|
10479
|
+
});
|
|
10480
|
+
};
|
|
10481
|
+
Shell.prototype.next = function () {
|
|
10482
|
+
var _this = this;
|
|
10483
|
+
var _a;
|
|
10484
|
+
if (this.isBusy === false) {
|
|
10485
|
+
this.start = new Date();
|
|
10486
|
+
this.isBusy = true;
|
|
10487
|
+
this.isReady = false;
|
|
10488
|
+
}
|
|
10489
|
+
if (this.channel) {
|
|
10490
|
+
this.emit('channel_closed', {
|
|
10491
|
+
channel: this.channel
|
|
10492
|
+
});
|
|
10493
|
+
if (this.commands.length !== 0 || (this.lastCode === 1 && this.errorsHandler.isActive())) {
|
|
10494
|
+
this.channel = null;
|
|
10495
|
+
}
|
|
10496
|
+
}
|
|
10497
|
+
if (this.lastCode === 1 && this.errorsHandler.isActive()) {
|
|
10498
|
+
this.lastCode = 0;
|
|
10499
|
+
this.commands.push(this.currentOptions);
|
|
10500
|
+
this.errorsHandler.delay(function () {
|
|
10501
|
+
_this.next();
|
|
10502
|
+
});
|
|
10503
|
+
return this.promise;
|
|
10504
|
+
}
|
|
10505
|
+
if (this.commands.length === 0) {
|
|
10506
|
+
if (this.state !== ShellState.Empty) {
|
|
10507
|
+
this.state = ShellState.Empty;
|
|
10508
|
+
this.end = new Date();
|
|
10509
|
+
this.isBusy = false;
|
|
10510
|
+
var promise = this.promise;
|
|
10511
|
+
// Always resolve the promise, consumer should check for errors
|
|
10512
|
+
promise.resolve(this);
|
|
10513
|
+
}
|
|
10514
|
+
return this.promise;
|
|
10515
|
+
}
|
|
10516
|
+
var child = null;
|
|
10517
|
+
var options = this.commands.shift();
|
|
10518
|
+
var command = ValueExtractor_1.ValueExtractor.interpolateAny(options.command, this.extracted);
|
|
10519
|
+
var rgxReady = options.matchReady;
|
|
10520
|
+
var detached = options.detached === true;
|
|
10521
|
+
var silent = this.params.silent;
|
|
10522
|
+
var stdio = detached ? (void 0) : 'pipe';
|
|
10523
|
+
var extractor = options.extract ? new ValueExtractor_1.ValueExtractor(this.extracted, options.extract) : null;
|
|
10524
|
+
var result = new ProcessResult(options);
|
|
10525
|
+
this.results.push(result);
|
|
10526
|
+
this.currentOptions = options;
|
|
10527
|
+
if (!options.fork && global.process.platform === 'win32') {
|
|
10528
|
+
if (options.exec !== 'cmd') {
|
|
10529
|
+
options.args.unshift('/C', options.exec);
|
|
10530
|
+
options.exec = 'cmd';
|
|
10531
|
+
}
|
|
10532
|
+
}
|
|
10533
|
+
if (rgxReady == null && options.ipc) {
|
|
10534
|
+
rgxReady = /IPC Listening/i;
|
|
10535
|
+
}
|
|
10536
|
+
this.isReady = rgxReady == null;
|
|
10537
|
+
try {
|
|
10538
|
+
var cwd = options.cwd;
|
|
10539
|
+
if (cwd != null) {
|
|
10540
|
+
var hasFileProtocol = cwd.startsWith('file:');
|
|
10541
|
+
var cwdUri = hasFileProtocol ? cwd : 'file://' + cwd;
|
|
10542
|
+
if (atma_io_1.Directory.exists(cwdUri + '/') === false) {
|
|
10543
|
+
throw Error('CWD Directory not exists: ' + cwd);
|
|
10544
|
+
}
|
|
10545
|
+
if (hasFileProtocol) {
|
|
10546
|
+
cwd = new atma_utils_1.class_Uri(cwd).toLocalDir();
|
|
10547
|
+
}
|
|
10548
|
+
}
|
|
10549
|
+
if (cwd == null) {
|
|
10550
|
+
cwd = process.cwd();
|
|
10551
|
+
}
|
|
10552
|
+
var exec = ValueExtractor_1.ValueExtractor.interpolateAny(options.exec, this.extracted, options);
|
|
10553
|
+
var args = ValueExtractor_1.ValueExtractor.interpolateAny(options.args, this.extracted, options);
|
|
10554
|
+
var method = options.fork ? 'fork' : 'spawn';
|
|
10555
|
+
if (this.params.verbose) {
|
|
10556
|
+
this.print("".concat(method, ": ").concat(exec, " ").concat(args.join('')));
|
|
10557
|
+
}
|
|
10558
|
+
child = options.fork
|
|
10559
|
+
? child_process.fork(exec, args, {
|
|
10560
|
+
cwd: options.cwd || process.cwd(),
|
|
10561
|
+
env: process.env,
|
|
10562
|
+
stdio: stdio,
|
|
10563
|
+
detached: detached
|
|
10564
|
+
})
|
|
10565
|
+
: child_process.spawn(exec, args, {
|
|
10566
|
+
cwd: options.cwd || process.cwd(),
|
|
10567
|
+
env: process.env,
|
|
10568
|
+
stdio: stdio,
|
|
10569
|
+
detached: detached
|
|
10570
|
+
});
|
|
10571
|
+
if (options.fork) {
|
|
10572
|
+
this.channel = new CommunicationChannel_1.CommunicationChannel(child, (_a = this.params.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
|
|
10573
|
+
this.emit('channel_created', {
|
|
10574
|
+
channel: this.channel
|
|
10575
|
+
});
|
|
10576
|
+
}
|
|
10577
|
+
this.children.push(child);
|
|
10578
|
+
}
|
|
10579
|
+
catch (error) {
|
|
10580
|
+
if (this.params.verbose) {
|
|
10581
|
+
this.print('on start exception:', error);
|
|
10582
|
+
}
|
|
10583
|
+
result.error = error;
|
|
10584
|
+
this.errors.push({
|
|
10585
|
+
command: command,
|
|
10586
|
+
error: error
|
|
10587
|
+
});
|
|
10588
|
+
this.emit('process_exception', {
|
|
10589
|
+
command: command,
|
|
10590
|
+
error: error
|
|
10591
|
+
});
|
|
10592
|
+
return this.next();
|
|
10593
|
+
}
|
|
10594
|
+
child.on('error', function (error) {
|
|
10595
|
+
var _a;
|
|
10596
|
+
if (_this.params.verbose) {
|
|
10597
|
+
_this.print('on error:', error);
|
|
10598
|
+
}
|
|
10599
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(error);
|
|
10600
|
+
});
|
|
10601
|
+
child.on('exit', function (code) {
|
|
10602
|
+
var _a;
|
|
10603
|
+
if (_this.params.verbose) {
|
|
10604
|
+
_this.print('on exit:', code);
|
|
10605
|
+
}
|
|
10606
|
+
result.resultCode = code;
|
|
10607
|
+
_this.emit('process_exit', {
|
|
10608
|
+
command: command,
|
|
10609
|
+
code: code,
|
|
10610
|
+
result: result
|
|
10611
|
+
});
|
|
10612
|
+
_this.lastCode = code;
|
|
10613
|
+
if (code > 0) {
|
|
10614
|
+
var msg = result.stderr.slice(-20).join('');
|
|
10615
|
+
var err = new Error("Exit code: ".concat(code, ". ").concat(msg !== null && msg !== void 0 ? msg : ''));
|
|
10616
|
+
_this.errors.push({
|
|
10617
|
+
command: command,
|
|
10618
|
+
error: err
|
|
10619
|
+
});
|
|
10620
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(err);
|
|
10621
|
+
}
|
|
10622
|
+
extractor === null || extractor === void 0 ? void 0 : extractor.complete();
|
|
10623
|
+
_this.next();
|
|
10624
|
+
});
|
|
10625
|
+
child.stdout.on('data', function (buffer) {
|
|
10626
|
+
if (detached !== true && silent !== true) {
|
|
10627
|
+
process.stdout.write(buffer);
|
|
10628
|
+
}
|
|
10629
|
+
if (rgxReady != null && rgxReady.test(buffer.toString())) {
|
|
10630
|
+
rgxReady = null;
|
|
10631
|
+
_this.isReady = true;
|
|
10632
|
+
_this.emit('process_ready', {
|
|
10633
|
+
command: command
|
|
10634
|
+
});
|
|
10635
|
+
}
|
|
10636
|
+
if (extractor != null) {
|
|
10637
|
+
extractor.write(buffer);
|
|
10638
|
+
}
|
|
10639
|
+
var str = String(buffer);
|
|
10640
|
+
result.stdout.push(str);
|
|
10641
|
+
result.std.push(str);
|
|
10642
|
+
_this.stdout.push(str);
|
|
10643
|
+
_this.std.push(str);
|
|
10644
|
+
_this.emit('process_stdout', {
|
|
10645
|
+
command: command,
|
|
10646
|
+
buffer: buffer
|
|
10647
|
+
});
|
|
10648
|
+
});
|
|
10649
|
+
child.stderr.on('data', function (buffer) {
|
|
10650
|
+
var _a;
|
|
10651
|
+
if (detached !== true && silent !== true) {
|
|
10652
|
+
process.stderr.write(buffer);
|
|
10653
|
+
}
|
|
10654
|
+
var str = String(buffer);
|
|
10655
|
+
result.stderr.push(str);
|
|
10656
|
+
result.std.push(str);
|
|
10657
|
+
_this.stderr.push(str);
|
|
10658
|
+
_this.std.push(str);
|
|
10659
|
+
_this.emit('process_stderr', {
|
|
10660
|
+
command: command,
|
|
10661
|
+
buffer: buffer
|
|
10662
|
+
});
|
|
10663
|
+
if (str.includes('UnhandledPromiseRejectionWarning')) {
|
|
10664
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onStdError(str);
|
|
10665
|
+
}
|
|
10666
|
+
});
|
|
10667
|
+
this.emit('process_start', {
|
|
10668
|
+
command: command
|
|
10669
|
+
});
|
|
10670
|
+
if (this.params.parallel !== false) {
|
|
10671
|
+
this.next();
|
|
10672
|
+
}
|
|
10673
|
+
if (rgxReady == null) {
|
|
10674
|
+
setTimeout(function () {
|
|
10675
|
+
_this.emit('process_ready', {
|
|
10676
|
+
command: command
|
|
10677
|
+
});
|
|
10678
|
+
}, 200);
|
|
10679
|
+
}
|
|
10680
|
+
return this.promise;
|
|
10681
|
+
};
|
|
10682
|
+
Shell.prototype.print = function () {
|
|
10683
|
+
var args = [];
|
|
10684
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10685
|
+
args[_i] = arguments[_i];
|
|
10686
|
+
}
|
|
10687
|
+
console.log('Shellbee: ' + args.join(' '));
|
|
10688
|
+
};
|
|
10689
|
+
Shell.ipc = CommunicationChannel_1.CommunicationChannel.ipc;
|
|
10690
|
+
return Shell;
|
|
10691
|
+
}(atma_utils_1.class_EventEmitter));
|
|
10692
|
+
exports.Shell = Shell;
|
|
10693
|
+
;
|
|
10694
|
+
var ProcessResult = /** @class */ (function () {
|
|
10695
|
+
function ProcessResult(options) {
|
|
10696
|
+
this.options = options;
|
|
10697
|
+
this.std = [];
|
|
10698
|
+
this.stdout = [];
|
|
10699
|
+
this.stderr = [];
|
|
10700
|
+
this.resultCode = null;
|
|
10701
|
+
this.error = null;
|
|
10702
|
+
}
|
|
10703
|
+
return ProcessResult;
|
|
10704
|
+
}());
|
|
10705
|
+
exports.ProcessResult = ProcessResult;
|
|
10706
|
+
var ShellState;
|
|
10707
|
+
(function (ShellState) {
|
|
10708
|
+
ShellState[ShellState["Empty"] = -1] = "Empty";
|
|
10709
|
+
ShellState[ShellState["Initial"] = 0] = "Initial";
|
|
10710
|
+
ShellState[ShellState["Started"] = 1] = "Started";
|
|
10711
|
+
})(ShellState || (ShellState = {}));
|
|
10712
|
+
;
|
|
10713
|
+
|
|
10714
|
+
function __isObj(x) {
|
|
10715
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10716
|
+
}
|
|
10717
|
+
if (_src_Shell === module.exports) {
|
|
10718
|
+
// do nothing if
|
|
10719
|
+
} else if (__isObj(_src_Shell) && __isObj(module.exports)) {
|
|
10720
|
+
Object.assign(_src_Shell, module.exports);
|
|
10721
|
+
} else {
|
|
10722
|
+
_src_Shell = module.exports;
|
|
10723
|
+
}
|
|
10724
|
+
|
|
10725
|
+
;
|
|
10726
|
+
}());
|
|
10727
|
+
|
|
10728
|
+
// end:source ./ModuleSimplified.js
|
|
10729
|
+
|
|
10730
|
+
|
|
10731
|
+
// source ./ModuleSimplified.js
|
|
10732
|
+
var _src_util_restartSelf;
|
|
10733
|
+
(function () {
|
|
10734
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
10735
|
+
var define = null;
|
|
10736
|
+
var exports = _src_util_restartSelf != null ? _src_util_restartSelf : {};
|
|
10737
|
+
var module = { exports: exports };
|
|
10738
|
+
|
|
10739
|
+
"use strict";
|
|
10740
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10741
|
+
exports.restartSelf = void 0;
|
|
10742
|
+
var Shell_1 = _src_Shell;
|
|
10743
|
+
function restartSelf() {
|
|
10744
|
+
var command = process
|
|
10745
|
+
.argv
|
|
10746
|
+
.map(function (x) { return x.includes(' ') ? "\"".concat(x, "\"") : x; })
|
|
10747
|
+
.join(' ');
|
|
10748
|
+
var shell = new Shell_1.Shell({
|
|
10749
|
+
command: command,
|
|
10750
|
+
detached: true,
|
|
10751
|
+
});
|
|
10752
|
+
shell.onStart(function () {
|
|
10753
|
+
console.log('Exit self.');
|
|
10754
|
+
process.exit();
|
|
10755
|
+
});
|
|
10756
|
+
console.log('Cloning this process.');
|
|
10757
|
+
shell.run();
|
|
10758
|
+
}
|
|
10759
|
+
exports.restartSelf = restartSelf;
|
|
10760
|
+
;
|
|
10761
|
+
;
|
|
10762
|
+
|
|
10763
|
+
function __isObj(x) {
|
|
10764
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10765
|
+
}
|
|
10766
|
+
if (_src_util_restartSelf === module.exports) {
|
|
10767
|
+
// do nothing if
|
|
10768
|
+
} else if (__isObj(_src_util_restartSelf) && __isObj(module.exports)) {
|
|
10769
|
+
Object.assign(_src_util_restartSelf, module.exports);
|
|
10770
|
+
} else {
|
|
10771
|
+
_src_util_restartSelf = module.exports;
|
|
10772
|
+
}
|
|
10773
|
+
|
|
10774
|
+
;
|
|
10775
|
+
}());
|
|
10776
|
+
|
|
10777
|
+
// end:source ./ModuleSimplified.js
|
|
10778
|
+
|
|
10779
|
+
"use strict";
|
|
10780
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10781
|
+
exports.run = exports.Shell = exports.restartSelf = void 0;
|
|
10782
|
+
var Shell_1 = _src_Shell;
|
|
10783
|
+
Object.defineProperty(exports, "Shell", { enumerable: true, get: function () { return Shell_1.Shell; } });
|
|
10784
|
+
var restartSelf_1 = _src_util_restartSelf;
|
|
10785
|
+
Object.defineProperty(exports, "restartSelf", { enumerable: true, get: function () { return restartSelf_1.restartSelf; } });
|
|
10786
|
+
exports.run = Shell_1.Shell.run;
|
|
10787
|
+
|
|
10788
|
+
|
|
10789
|
+
}());
|
|
10790
|
+
// end:source ./RootModule.js
|
|
10791
|
+
;
|
|
10792
|
+
|
|
10793
|
+
function __isObj(x) {
|
|
10794
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
10795
|
+
}
|
|
10796
|
+
if (_node_modules_shellbee_lib_shellbee === module.exports) {
|
|
10797
|
+
// do nothing if
|
|
10798
|
+
} else if (__isObj(_node_modules_shellbee_lib_shellbee) && __isObj(module.exports)) {
|
|
10799
|
+
Object.assign(_node_modules_shellbee_lib_shellbee, module.exports);
|
|
10800
|
+
} else {
|
|
10801
|
+
_node_modules_shellbee_lib_shellbee = module.exports;
|
|
10802
|
+
}
|
|
10803
|
+
|
|
10804
|
+
;
|
|
10805
|
+
}());
|
|
10806
|
+
|
|
10807
|
+
// end:source ./ModuleSimplified.js
|
|
10808
|
+
|
|
10809
|
+
|
|
9557
10810
|
// source ./ModuleSimplified.js
|
|
9558
10811
|
var _src_class_Solution;
|
|
9559
10812
|
(function () {
|
|
@@ -9574,6 +10827,7 @@ const HandlersUtils_1 = _src_class_HandlersUtils;
|
|
|
9574
10827
|
const OutputResources_1 = _src_class_OutputResources;
|
|
9575
10828
|
const exports_1 = _src_handlers_exports;
|
|
9576
10829
|
const global_1 = _src_global;
|
|
10830
|
+
const shellbee_1 = _node_modules_shellbee_lib_shellbee;
|
|
9577
10831
|
class Solution extends atma_utils_1.class_EventEmitter {
|
|
9578
10832
|
constructor(path, opts = {}) {
|
|
9579
10833
|
super();
|
|
@@ -9603,10 +10857,15 @@ class Solution extends atma_utils_1.class_EventEmitter {
|
|
|
9603
10857
|
resolve(...args);
|
|
9604
10858
|
return;
|
|
9605
10859
|
}
|
|
9606
|
-
(0, async_1.async_waterfall)(arr, function (
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
10860
|
+
(0, async_1.async_waterfall)(arr, async function (pathOrCommand) {
|
|
10861
|
+
if (/^[.\/]/.test(pathOrCommand)) {
|
|
10862
|
+
let mix = require(atma_utils_1.class_Uri.combine(process.cwd(), pathOrCommand));
|
|
10863
|
+
if (mix && mix.process) {
|
|
10864
|
+
return mix.process();
|
|
10865
|
+
}
|
|
10866
|
+
}
|
|
10867
|
+
else {
|
|
10868
|
+
let result = await (0, shellbee_1.run)(pathOrCommand);
|
|
9610
10869
|
}
|
|
9611
10870
|
}).then(() => resolve(...args), reject);
|
|
9612
10871
|
});
|