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