app-bundler 0.1.10 → 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 +1506 -225
- package/lib/cli.js +1506 -225
- 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 = {};
|
|
@@ -4610,202 +4611,218 @@ var __register, __require, require;
|
|
|
4610
4611
|
|
|
4611
4612
|
(function(){
|
|
4612
4613
|
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4614
|
+
// source ./path.js
|
|
4615
|
+
var path_getDir,
|
|
4616
|
+
path_resolveCurrent,
|
|
4617
|
+
path_normalize,
|
|
4618
|
+
path_resolveUrl,
|
|
4619
|
+
path_combine
|
|
4620
|
+
;
|
|
4621
|
+
(function(){
|
|
4622
|
+
var isNodeJS = typeof process !== 'undefined'
|
|
4623
|
+
&& typeof window === 'undefined'
|
|
4624
|
+
&& typeof navigator === 'undefined';
|
|
4625
|
+
|
|
4626
|
+
path_getDir = function(path) {
|
|
4627
|
+
return path.substring(0, path.lastIndexOf('/') + 1);
|
|
4628
|
+
};
|
|
4629
|
+
|
|
4630
|
+
(function(){
|
|
4631
|
+
var current_;
|
|
4632
|
+
if (isNodeJS === false) {
|
|
4633
|
+
path_resolveCurrent = function(){
|
|
4634
|
+
if (current_ != null) return current_;
|
|
4635
|
+
|
|
4636
|
+
var fn = 'baseURI' in window.document
|
|
4637
|
+
? fromBase
|
|
4638
|
+
: fromLocation;
|
|
4639
|
+
return (current_ = path_sliceFilename(fn()));
|
|
4640
|
+
};
|
|
4641
|
+
function fromBase() {
|
|
4642
|
+
var path = window.document.baseURI;
|
|
4643
|
+
var i = path.indexOf('?');
|
|
4644
|
+
return i === -1 ? path : path.substring(0, i);
|
|
4645
|
+
}
|
|
4646
|
+
function fromLocation() {
|
|
4647
|
+
return window.location.origin + window.location.pathname;
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4650
|
+
else {
|
|
4651
|
+
|
|
4652
|
+
path_resolveCurrent = function(){
|
|
4653
|
+
if (current_ != null) return current_;
|
|
4654
|
+
return (current_ = path_win32Normalize(__dirname));
|
|
4655
|
+
};
|
|
4656
|
+
}
|
|
4657
|
+
}());
|
|
4658
|
+
|
|
4659
|
+
|
|
4660
|
+
path_normalize = function(path) {
|
|
4661
|
+
var path_ = path
|
|
4662
|
+
.replace(new RegExp("\\\\\\\\", "g"), '/')
|
|
4663
|
+
// remove double slashes, but not near protocol
|
|
4664
|
+
.replace(new RegExp("([^:\\\\/])\\\\/{2,}", "g"), '$1/')
|
|
4665
|
+
// './xx' to relative string
|
|
4666
|
+
.replace(new RegExp("^\\\\.\\\\/"), '')
|
|
4667
|
+
// join 'xx/./xx'
|
|
4668
|
+
.replace(new RegExp("\\\\/\\\\.\\\\//", "g"), '/')
|
|
4669
|
+
;
|
|
4670
|
+
path_ = path_collapse(path_);
|
|
4671
|
+
return path_;
|
|
4672
|
+
};
|
|
4673
|
+
path_resolveUrl = function(path, location) {
|
|
4674
|
+
if (/\\.\\w+$/.test(path) === false) {
|
|
4675
|
+
path += '.js';
|
|
4676
|
+
}
|
|
4677
|
+
var url = path_normalize(path);
|
|
4678
|
+
if (url[0] === '/') {
|
|
4679
|
+
url = path_combine(path_resolveCurrent(), url);
|
|
4680
|
+
} else if (rgx_PROTOCOL.test(url) === false) {
|
|
4681
|
+
url = path_normalize(path_combine(location || path_resolveCurrent(), url));
|
|
4682
|
+
}
|
|
4683
|
+
if (rgx_PROTOCOL.test(url) === false) {
|
|
4684
|
+
url = 'file://' + url;
|
|
4685
|
+
}
|
|
4686
|
+
return url;
|
|
4687
|
+
};
|
|
4688
|
+
|
|
4689
|
+
path_combine = function() {
|
|
4690
|
+
var out = '',
|
|
4691
|
+
imax = arguments.length,
|
|
4692
|
+
i = -1, x;
|
|
4693
|
+
while ( ++i < imax ){
|
|
4694
|
+
x = arguments[i];
|
|
4695
|
+
if (!x) continue;
|
|
4696
|
+
|
|
4697
|
+
x = path_normalize(x);
|
|
4698
|
+
if (out === '') {
|
|
4699
|
+
out = x;
|
|
4700
|
+
continue;
|
|
4701
|
+
}
|
|
4702
|
+
if (out[out.length - 1] !== '/') {
|
|
4703
|
+
out += '/'
|
|
4704
|
+
}
|
|
4705
|
+
if (x[0] === '/') {
|
|
4706
|
+
x = x.substring(1);
|
|
4707
|
+
}
|
|
4708
|
+
out += x;
|
|
4709
|
+
}
|
|
4710
|
+
return path_collapse(out);
|
|
4711
|
+
};
|
|
4712
|
+
|
|
4713
|
+
var rgx_PROTOCOL = /^(file|https?):/i,
|
|
4714
|
+
rgx_SUB_DIR = new RegExp("[^\\\\/\\\\.]+\/\\\\.\\\\.\\\\/"),
|
|
4715
|
+
rgx_FILENAME = new RegExp("\\\\/[^\\\\/]+\\\\.\\\\w+(\\\\?.*)?(#.*)?$"),
|
|
4716
|
+
rgx_EXT = new RegExp("\\\\.(\\\\w+)$"),
|
|
4717
|
+
rgx_win32Drive = new RegExp("(^\\\\/?\\\\w{1}:)(\\\\/|$)")
|
|
4718
|
+
;
|
|
4719
|
+
|
|
4720
|
+
function path_win32Normalize (path){
|
|
4721
|
+
path = path_normalize(path);
|
|
4722
|
+
if (path.substring(0, 5) === 'file:')
|
|
4723
|
+
return path;
|
|
4724
|
+
|
|
4725
|
+
return 'file://' + path;
|
|
4726
|
+
}
|
|
4727
|
+
|
|
4728
|
+
function path_collapse(url_) {
|
|
4729
|
+
var url = url_;
|
|
4730
|
+
while (rgx_SUB_DIR.test(url)) {
|
|
4731
|
+
url = url.replace(rgx_SUB_DIR, '');
|
|
4732
|
+
}
|
|
4733
|
+
return url;
|
|
4734
|
+
}
|
|
4735
|
+
function path_ensureTrailingSlash(path) {
|
|
4736
|
+
if (path.charCodeAt(path.length - 1) === 47 /* / */)
|
|
4737
|
+
return path;
|
|
4738
|
+
|
|
4739
|
+
return path + '/';
|
|
4740
|
+
}
|
|
4741
|
+
function path_sliceFilename(path) {
|
|
4742
|
+
return path_ensureTrailingSlash(path.replace(rgx_FILENAME, ''));
|
|
4743
|
+
}
|
|
4744
|
+
|
|
4745
|
+
}());
|
|
4746
|
+
|
|
4747
|
+
// end:source ./path.js
|
|
4748
|
+
|
|
4749
|
+
var __global = typeof global !== 'undefined' && global ? global : window;
|
|
4750
|
+
var __nativeRequire = __global.require || require;
|
|
4751
|
+
var __originalRequire = function (path_) {
|
|
4752
|
+
var location = this.location;
|
|
4753
|
+
var path = path_resolveUrl(path_, location);
|
|
4747
4754
|
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4755
|
+
if (modules[path]) {
|
|
4756
|
+
return modules[path].runOnce();
|
|
4757
|
+
}
|
|
4758
|
+
var pathWithoutExt = path.replace(/\\.\\w+$/, '').toLowerCase();
|
|
4759
|
+
for (var key in modules) {
|
|
4760
|
+
var $pathWithoutExt = key.replace(/\\.\\w+$/, '').toLowerCase();
|
|
4761
|
+
if ($pathWithoutExt === pathWithoutExt) {
|
|
4762
|
+
let module = modules[path] = modules[key];
|
|
4763
|
+
return module.runOnce();
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4753
4766
|
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
}
|
|
4767
|
+
return __nativeRequire(path_);
|
|
4768
|
+
};
|
|
4757
4769
|
|
|
4758
|
-
|
|
4759
|
-
|
|
4770
|
+
__register = function (path, factory) {
|
|
4771
|
+
var filename = path_resolveUrl(path);
|
|
4772
|
+
modules[filename] = new Module(filename, factory);
|
|
4773
|
+
};
|
|
4760
4774
|
|
|
4761
|
-
|
|
4762
|
-
var filename = path_resolveUrl(path);
|
|
4763
|
-
modules[filename] = new Module(filename, factory);
|
|
4764
|
-
};
|
|
4775
|
+
__require =__originalRequire.bind({ location: path_getDir(path_resolveUrl('%ROOT_DIR%')) });
|
|
4765
4776
|
|
|
4766
|
-
|
|
4777
|
+
var modules = {};
|
|
4778
|
+
var Module = function(filename, factory){
|
|
4779
|
+
this.filename = filename;
|
|
4780
|
+
this.dirname = path_getDir(filename);
|
|
4781
|
+
this.factory = factory;
|
|
4782
|
+
this.exports = null;
|
|
4783
|
+
};
|
|
4784
|
+
Module.prototype.runOnce = function(){
|
|
4785
|
+
if (this.exports != null) {
|
|
4786
|
+
return this.exports;
|
|
4787
|
+
}
|
|
4788
|
+
var require = __originalRequire.bind({
|
|
4789
|
+
location: this.dirname
|
|
4790
|
+
});
|
|
4791
|
+
this.exports = {};
|
|
4792
|
+
this.factory(
|
|
4793
|
+
require,
|
|
4794
|
+
this,
|
|
4795
|
+
this.exports,
|
|
4796
|
+
this.filename,
|
|
4797
|
+
this.dirname
|
|
4798
|
+
);
|
|
4799
|
+
return this.exports;
|
|
4800
|
+
};
|
|
4767
4801
|
|
|
4768
|
-
|
|
4769
|
-
var Module = function(filename, factory){
|
|
4770
|
-
this.filename = filename;
|
|
4771
|
-
this.dirname = path_getDir(filename);
|
|
4772
|
-
this.factory = factory;
|
|
4773
|
-
this.exports = null;
|
|
4774
|
-
};
|
|
4775
|
-
Module.prototype.runOnce = function(){
|
|
4776
|
-
if (this.exports != null) {
|
|
4777
|
-
return this.exports;
|
|
4778
|
-
}
|
|
4779
|
-
var require = __originalRequire.bind({
|
|
4780
|
-
location: this.dirname
|
|
4781
|
-
});
|
|
4782
|
-
this.exports = {};
|
|
4783
|
-
this.factory(
|
|
4784
|
-
require,
|
|
4785
|
-
this,
|
|
4786
|
-
this.exports,
|
|
4787
|
-
this.filename,
|
|
4788
|
-
this.dirname
|
|
4789
|
-
);
|
|
4790
|
-
return this.exports;
|
|
4791
|
-
};
|
|
4792
|
-
|
|
4793
|
-
require = __require;
|
|
4802
|
+
require = __require;
|
|
4794
4803
|
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4804
|
+
if (__nativeRequire == null) {
|
|
4805
|
+
__global.require = __require;
|
|
4806
|
+
}
|
|
4798
4807
|
}());
|
|
4808
|
+
|
|
4799
4809
|
// end:source ./Header.js
|
|
4800
4810
|
`,
|
|
4801
4811
|
RootModule: `
|
|
4802
4812
|
// source ./RootModule.js
|
|
4813
|
+
%BUNDLE%
|
|
4814
|
+
|
|
4815
|
+
// end:source ./RootModule.js
|
|
4816
|
+
`,
|
|
4817
|
+
RootModuleWrapped: `
|
|
4818
|
+
// source ./RootModuleWrapped.js
|
|
4803
4819
|
(function(){
|
|
4804
|
-
|
|
4805
|
-
|
|
4820
|
+
|
|
4821
|
+
%BUNDLE%
|
|
4806
4822
|
|
|
4807
4823
|
}());
|
|
4808
|
-
|
|
4824
|
+
|
|
4825
|
+
// end:source ./RootModuleWrapped.js
|
|
4809
4826
|
`,
|
|
4810
4827
|
UMD: `
|
|
4811
4828
|
// source ./UMD.js
|
|
@@ -5098,6 +5115,9 @@ class ModuleWrapper {
|
|
|
5098
5115
|
wrap(body) {
|
|
5099
5116
|
var wrapper = this.solution.opts.package.moduleWrapper;
|
|
5100
5117
|
switch (wrapper) {
|
|
5118
|
+
case 'script':
|
|
5119
|
+
body = this.wrapSimple(body);
|
|
5120
|
+
break;
|
|
5101
5121
|
case 'iif':
|
|
5102
5122
|
body = this.wrapWithIIF(body);
|
|
5103
5123
|
break;
|
|
@@ -5107,18 +5127,21 @@ class ModuleWrapper {
|
|
|
5107
5127
|
case 'custom':
|
|
5108
5128
|
body = this.wrapWithCustom(body);
|
|
5109
5129
|
break;
|
|
5110
|
-
case 'script':
|
|
5111
|
-
break;
|
|
5112
5130
|
default:
|
|
5113
5131
|
throw new Error('Uknown module wrapper: ' + wrapper);
|
|
5114
5132
|
}
|
|
5115
5133
|
return body;
|
|
5116
5134
|
}
|
|
5117
|
-
|
|
5135
|
+
wrapSimple(body) {
|
|
5118
5136
|
return Templates_1.Templates
|
|
5119
5137
|
.RootModule
|
|
5120
5138
|
.replace('%BUNDLE%', () => body);
|
|
5121
5139
|
}
|
|
5140
|
+
wrapWithIIF(body) {
|
|
5141
|
+
return Templates_1.Templates
|
|
5142
|
+
.RootModuleWrapped
|
|
5143
|
+
.replace('%BUNDLE%', () => body);
|
|
5144
|
+
}
|
|
5122
5145
|
wrapWithUMD(body) {
|
|
5123
5146
|
var opts = this.solution.opts.package;
|
|
5124
5147
|
var name = opts.moduleName || '';
|
|
@@ -6108,7 +6131,7 @@ class IncludeJsHandler extends BaseHandler_1.BaseHandler {
|
|
|
6108
6131
|
constructor(solution) {
|
|
6109
6132
|
super(solution);
|
|
6110
6133
|
// if (this.solution.opts.package.module === 'includejs') {
|
|
6111
|
-
//
|
|
6134
|
+
// this.registerMappings_();
|
|
6112
6135
|
// }
|
|
6113
6136
|
}
|
|
6114
6137
|
accepts(resource) {
|
|
@@ -9531,58 +9554,1316 @@ exports.Handlers = [
|
|
|
9531
9554
|
|
|
9532
9555
|
|
|
9533
9556
|
// source ./ModuleSimplified.js
|
|
9534
|
-
var
|
|
9557
|
+
var _node_modules_shellbee_lib_shellbee;
|
|
9535
9558
|
(function () {
|
|
9536
9559
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
9537
9560
|
var define = null;
|
|
9538
|
-
var exports =
|
|
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 : {};
|
|
9539
9586
|
var module = { exports: exports };
|
|
9540
9587
|
|
|
9541
9588
|
"use strict";
|
|
9542
9589
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9543
|
-
exports.
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
const HandlersUtils_1 = _src_class_HandlersUtils;
|
|
9550
|
-
const OutputResources_1 = _src_class_OutputResources;
|
|
9551
|
-
const exports_1 = _src_handlers_exports;
|
|
9552
|
-
const global_1 = _src_global;
|
|
9553
|
-
class Solution extends atma_utils_1.class_EventEmitter {
|
|
9554
|
-
constructor(path, opts = {}) {
|
|
9555
|
-
super();
|
|
9556
|
-
this.iteration = {};
|
|
9557
|
-
this.path = path;
|
|
9558
|
-
this.opts = new SolutionOpts_1.SolutionOpts(this, opts);
|
|
9559
|
-
this.assetsManager = new AssetsManager_1.AssetsManager(this);
|
|
9560
|
-
this.outputResources = new OutputResources_1.OutputResources(this);
|
|
9561
|
-
this.reporter = Reporter_1.IReporter.create(this.opts);
|
|
9562
|
-
this.handlers = exports_1.Handlers.map(Ctor => new Ctor(this));
|
|
9563
|
-
Object.assign(this.handlers, HandlersUtils_1.HandlersUtils);
|
|
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;
|
|
9564
9596
|
}
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
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
|
+
}
|
|
9571
9634
|
}
|
|
9572
|
-
|
|
9573
|
-
|
|
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);
|
|
9574
9652
|
}
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
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) {
|
|
9580
9949
|
return;
|
|
9581
9950
|
}
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
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
|
+
|
|
10808
|
+
// source ./ModuleSimplified.js
|
|
10809
|
+
var _src_class_Solution;
|
|
10810
|
+
(function () {
|
|
10811
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
10812
|
+
var define = null;
|
|
10813
|
+
var exports = _src_class_Solution != null ? _src_class_Solution : {};
|
|
10814
|
+
var module = { exports: exports };
|
|
10815
|
+
|
|
10816
|
+
"use strict";
|
|
10817
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10818
|
+
exports.Solution = void 0;
|
|
10819
|
+
const AssetsManager_1 = _src_assets_AssetsManager;
|
|
10820
|
+
const async_1 = _src_utils_async;
|
|
10821
|
+
const atma_utils_1 = require("atma-utils");
|
|
10822
|
+
const SolutionOpts_1 = _src_class_SolutionOpts;
|
|
10823
|
+
const Reporter_1 = _src_class_Reporter;
|
|
10824
|
+
const HandlersUtils_1 = _src_class_HandlersUtils;
|
|
10825
|
+
const OutputResources_1 = _src_class_OutputResources;
|
|
10826
|
+
const exports_1 = _src_handlers_exports;
|
|
10827
|
+
const global_1 = _src_global;
|
|
10828
|
+
const shellbee_1 = _node_modules_shellbee_lib_shellbee;
|
|
10829
|
+
class Solution extends atma_utils_1.class_EventEmitter {
|
|
10830
|
+
constructor(path, opts = {}) {
|
|
10831
|
+
super();
|
|
10832
|
+
this.iteration = {};
|
|
10833
|
+
this.path = path;
|
|
10834
|
+
this.opts = new SolutionOpts_1.SolutionOpts(this, opts);
|
|
10835
|
+
this.assetsManager = new AssetsManager_1.AssetsManager(this);
|
|
10836
|
+
this.outputResources = new OutputResources_1.OutputResources(this);
|
|
10837
|
+
this.reporter = Reporter_1.IReporter.create(this.opts);
|
|
10838
|
+
this.handlers = exports_1.Handlers.map(Ctor => new Ctor(this));
|
|
10839
|
+
Object.assign(this.handlers, HandlersUtils_1.HandlersUtils);
|
|
10840
|
+
}
|
|
10841
|
+
getOptionsForResource(resource) {
|
|
10842
|
+
// var files = this.opts.files;
|
|
10843
|
+
// if (files == null) {
|
|
10844
|
+
// return null;
|
|
10845
|
+
// }
|
|
10846
|
+
// @TODO support settings for a resource
|
|
10847
|
+
}
|
|
10848
|
+
isMainResource(resource) {
|
|
10849
|
+
return this.outputResources.rootInput === resource;
|
|
10850
|
+
}
|
|
10851
|
+
runScripts(name, ...args) {
|
|
10852
|
+
return (0, async_1.async_run)((resolve, reject) => {
|
|
10853
|
+
let arr = this.opts[name];
|
|
10854
|
+
if (arr == null || arr.length === 0) {
|
|
10855
|
+
resolve(...args);
|
|
10856
|
+
return;
|
|
10857
|
+
}
|
|
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);
|
|
9586
10867
|
}
|
|
9587
10868
|
}).then(() => resolve(...args), reject);
|
|
9588
10869
|
});
|