app-bundler 0.2.22 → 0.2.23
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/.circleci/config.yml +37 -37
- package/.editorconfig +8 -8
- package/README.md +33 -33
- package/lib/bundler.js +1884 -1884
- package/lib/cli.js +1884 -1884
- package/package.json +1 -1
- package/todo.txt +2 -2
- package/tools/build.js +58 -58
- package/tools/bundler.js +7075 -7075
- package/tsconfig-build.json +23 -23
- package/tsconfig.json +24 -24
- package/types/color.d.ts +2 -2
- package/typings.json +6 -6
package/lib/bundler.js
CHANGED
|
@@ -2156,282 +2156,282 @@ var _node_modules_tslib_tslib;
|
|
|
2156
2156
|
var exports = _node_modules_tslib_tslib != null ? _node_modules_tslib_tslib : {};
|
|
2157
2157
|
var module = { exports: exports };
|
|
2158
2158
|
|
|
2159
|
-
/*! *****************************************************************************
|
|
2160
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2161
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
2162
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
2163
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
2164
|
-
|
|
2165
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
2166
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
2167
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
2168
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
2169
|
-
|
|
2170
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
2171
|
-
and limitations under the License.
|
|
2172
|
-
***************************************************************************** */
|
|
2173
|
-
/* global global, define, System, Reflect, Promise */
|
|
2174
|
-
var __extends;
|
|
2175
|
-
var __assign;
|
|
2176
|
-
var __rest;
|
|
2177
|
-
var __decorate;
|
|
2178
|
-
var __param;
|
|
2179
|
-
var __metadata;
|
|
2180
|
-
var __awaiter;
|
|
2181
|
-
var __generator;
|
|
2182
|
-
var __exportStar;
|
|
2183
|
-
var __values;
|
|
2184
|
-
var __read;
|
|
2185
|
-
var __spread;
|
|
2186
|
-
var __spreadArrays;
|
|
2187
|
-
var __await;
|
|
2188
|
-
var __asyncGenerator;
|
|
2189
|
-
var __asyncDelegator;
|
|
2190
|
-
var __asyncValues;
|
|
2191
|
-
var __makeTemplateObject;
|
|
2192
|
-
var __importStar;
|
|
2193
|
-
var __importDefault;
|
|
2194
|
-
var __classPrivateFieldGet;
|
|
2195
|
-
var __classPrivateFieldSet;
|
|
2196
|
-
(function (factory) {
|
|
2197
|
-
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
2198
|
-
if (typeof define === "function" && define.amd) {
|
|
2199
|
-
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
|
|
2200
|
-
}
|
|
2201
|
-
else if (typeof module === "object" && typeof module.exports === "object") {
|
|
2202
|
-
factory(createExporter(root, createExporter(module.exports)));
|
|
2203
|
-
}
|
|
2204
|
-
else {
|
|
2205
|
-
factory(createExporter(root));
|
|
2206
|
-
}
|
|
2207
|
-
function createExporter(exports, previous) {
|
|
2208
|
-
if (exports !== root) {
|
|
2209
|
-
if (typeof Object.create === "function") {
|
|
2210
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2211
|
-
}
|
|
2212
|
-
else {
|
|
2213
|
-
exports.__esModule = true;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
|
|
2217
|
-
}
|
|
2218
|
-
})
|
|
2219
|
-
(function (exporter) {
|
|
2220
|
-
var extendStatics = Object.setPrototypeOf ||
|
|
2221
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2222
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2223
|
-
|
|
2224
|
-
__extends = function (d, b) {
|
|
2225
|
-
extendStatics(d, b);
|
|
2226
|
-
function __() { this.constructor = d; }
|
|
2227
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2228
|
-
};
|
|
2229
|
-
|
|
2230
|
-
__assign = Object.assign || function (t) {
|
|
2231
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2232
|
-
s = arguments[i];
|
|
2233
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2234
|
-
}
|
|
2235
|
-
return t;
|
|
2236
|
-
};
|
|
2237
|
-
|
|
2238
|
-
__rest = function (s, e) {
|
|
2239
|
-
var t = {};
|
|
2240
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2241
|
-
t[p] = s[p];
|
|
2242
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2243
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2244
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2245
|
-
t[p[i]] = s[p[i]];
|
|
2246
|
-
}
|
|
2247
|
-
return t;
|
|
2248
|
-
};
|
|
2249
|
-
|
|
2250
|
-
__decorate = function (decorators, target, key, desc) {
|
|
2251
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2252
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2253
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2254
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2255
|
-
};
|
|
2256
|
-
|
|
2257
|
-
__param = function (paramIndex, decorator) {
|
|
2258
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
2259
|
-
};
|
|
2260
|
-
|
|
2261
|
-
__metadata = function (metadataKey, metadataValue) {
|
|
2262
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
2263
|
-
};
|
|
2264
|
-
|
|
2265
|
-
__awaiter = function (thisArg, _arguments, P, generator) {
|
|
2266
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2267
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2268
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2269
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2270
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2271
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2272
|
-
});
|
|
2273
|
-
};
|
|
2274
|
-
|
|
2275
|
-
__generator = function (thisArg, body) {
|
|
2276
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2277
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2278
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2279
|
-
function step(op) {
|
|
2280
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2281
|
-
while (_) try {
|
|
2282
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2283
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2284
|
-
switch (op[0]) {
|
|
2285
|
-
case 0: case 1: t = op; break;
|
|
2286
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
2287
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2288
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2289
|
-
default:
|
|
2290
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2291
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2292
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2293
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2294
|
-
if (t[2]) _.ops.pop();
|
|
2295
|
-
_.trys.pop(); continue;
|
|
2296
|
-
}
|
|
2297
|
-
op = body.call(thisArg, _);
|
|
2298
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2299
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2300
|
-
}
|
|
2301
|
-
};
|
|
2302
|
-
|
|
2303
|
-
__exportStar = function (m, exports) {
|
|
2304
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
2305
|
-
};
|
|
2306
|
-
|
|
2307
|
-
__values = function (o) {
|
|
2308
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
2309
|
-
if (m) return m.call(o);
|
|
2310
|
-
if (o && typeof o.length === "number") return {
|
|
2311
|
-
next: function () {
|
|
2312
|
-
if (o && i >= o.length) o = void 0;
|
|
2313
|
-
return { value: o && o[i++], done: !o };
|
|
2314
|
-
}
|
|
2315
|
-
};
|
|
2316
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
2317
|
-
};
|
|
2318
|
-
|
|
2319
|
-
__read = function (o, n) {
|
|
2320
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
2321
|
-
if (!m) return o;
|
|
2322
|
-
var i = m.call(o), r, ar = [], e;
|
|
2323
|
-
try {
|
|
2324
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2325
|
-
}
|
|
2326
|
-
catch (error) { e = { error: error }; }
|
|
2327
|
-
finally {
|
|
2328
|
-
try {
|
|
2329
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
2330
|
-
}
|
|
2331
|
-
finally { if (e) throw e.error; }
|
|
2332
|
-
}
|
|
2333
|
-
return ar;
|
|
2334
|
-
};
|
|
2335
|
-
|
|
2336
|
-
__spread = function () {
|
|
2337
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
2338
|
-
ar = ar.concat(__read(arguments[i]));
|
|
2339
|
-
return ar;
|
|
2340
|
-
};
|
|
2341
|
-
|
|
2342
|
-
__spreadArrays = function () {
|
|
2343
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2344
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
2345
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
2346
|
-
r[k] = a[j];
|
|
2347
|
-
return r;
|
|
2348
|
-
};
|
|
2349
|
-
|
|
2350
|
-
__await = function (v) {
|
|
2351
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
2352
|
-
};
|
|
2353
|
-
|
|
2354
|
-
__asyncGenerator = function (thisArg, _arguments, generator) {
|
|
2355
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2356
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
2357
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
2358
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
2359
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
2360
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
2361
|
-
function fulfill(value) { resume("next", value); }
|
|
2362
|
-
function reject(value) { resume("throw", value); }
|
|
2363
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
2364
|
-
};
|
|
2365
|
-
|
|
2366
|
-
__asyncDelegator = function (o) {
|
|
2367
|
-
var i, p;
|
|
2368
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
2369
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
2370
|
-
};
|
|
2371
|
-
|
|
2372
|
-
__asyncValues = function (o) {
|
|
2373
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2374
|
-
var m = o[Symbol.asyncIterator], i;
|
|
2375
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
2376
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
2377
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
2378
|
-
};
|
|
2379
|
-
|
|
2380
|
-
__makeTemplateObject = function (cooked, raw) {
|
|
2381
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
2382
|
-
return cooked;
|
|
2383
|
-
};
|
|
2384
|
-
|
|
2385
|
-
__importStar = function (mod) {
|
|
2386
|
-
if (mod && mod.__esModule) return mod;
|
|
2387
|
-
var result = {};
|
|
2388
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
2389
|
-
result["default"] = mod;
|
|
2390
|
-
return result;
|
|
2391
|
-
};
|
|
2392
|
-
|
|
2393
|
-
__importDefault = function (mod) {
|
|
2394
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2395
|
-
};
|
|
2396
|
-
|
|
2397
|
-
__classPrivateFieldGet = function (receiver, privateMap) {
|
|
2398
|
-
if (!privateMap.has(receiver)) {
|
|
2399
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
2400
|
-
}
|
|
2401
|
-
return privateMap.get(receiver);
|
|
2402
|
-
};
|
|
2403
|
-
|
|
2404
|
-
__classPrivateFieldSet = function (receiver, privateMap, value) {
|
|
2405
|
-
if (!privateMap.has(receiver)) {
|
|
2406
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
2407
|
-
}
|
|
2408
|
-
privateMap.set(receiver, value);
|
|
2409
|
-
return value;
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
exporter("__extends", __extends);
|
|
2413
|
-
exporter("__assign", __assign);
|
|
2414
|
-
exporter("__rest", __rest);
|
|
2415
|
-
exporter("__decorate", __decorate);
|
|
2416
|
-
exporter("__param", __param);
|
|
2417
|
-
exporter("__metadata", __metadata);
|
|
2418
|
-
exporter("__awaiter", __awaiter);
|
|
2419
|
-
exporter("__generator", __generator);
|
|
2420
|
-
exporter("__exportStar", __exportStar);
|
|
2421
|
-
exporter("__values", __values);
|
|
2422
|
-
exporter("__read", __read);
|
|
2423
|
-
exporter("__spread", __spread);
|
|
2424
|
-
exporter("__spreadArrays", __spreadArrays);
|
|
2425
|
-
exporter("__await", __await);
|
|
2426
|
-
exporter("__asyncGenerator", __asyncGenerator);
|
|
2427
|
-
exporter("__asyncDelegator", __asyncDelegator);
|
|
2428
|
-
exporter("__asyncValues", __asyncValues);
|
|
2429
|
-
exporter("__makeTemplateObject", __makeTemplateObject);
|
|
2430
|
-
exporter("__importStar", __importStar);
|
|
2431
|
-
exporter("__importDefault", __importDefault);
|
|
2432
|
-
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
|
|
2433
|
-
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
|
|
2434
|
-
});
|
|
2159
|
+
/*! *****************************************************************************
|
|
2160
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2161
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
2162
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
2163
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
2164
|
+
|
|
2165
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
2166
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
2167
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
2168
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
2169
|
+
|
|
2170
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
2171
|
+
and limitations under the License.
|
|
2172
|
+
***************************************************************************** */
|
|
2173
|
+
/* global global, define, System, Reflect, Promise */
|
|
2174
|
+
var __extends;
|
|
2175
|
+
var __assign;
|
|
2176
|
+
var __rest;
|
|
2177
|
+
var __decorate;
|
|
2178
|
+
var __param;
|
|
2179
|
+
var __metadata;
|
|
2180
|
+
var __awaiter;
|
|
2181
|
+
var __generator;
|
|
2182
|
+
var __exportStar;
|
|
2183
|
+
var __values;
|
|
2184
|
+
var __read;
|
|
2185
|
+
var __spread;
|
|
2186
|
+
var __spreadArrays;
|
|
2187
|
+
var __await;
|
|
2188
|
+
var __asyncGenerator;
|
|
2189
|
+
var __asyncDelegator;
|
|
2190
|
+
var __asyncValues;
|
|
2191
|
+
var __makeTemplateObject;
|
|
2192
|
+
var __importStar;
|
|
2193
|
+
var __importDefault;
|
|
2194
|
+
var __classPrivateFieldGet;
|
|
2195
|
+
var __classPrivateFieldSet;
|
|
2196
|
+
(function (factory) {
|
|
2197
|
+
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
2198
|
+
if (typeof define === "function" && define.amd) {
|
|
2199
|
+
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
|
|
2200
|
+
}
|
|
2201
|
+
else if (typeof module === "object" && typeof module.exports === "object") {
|
|
2202
|
+
factory(createExporter(root, createExporter(module.exports)));
|
|
2203
|
+
}
|
|
2204
|
+
else {
|
|
2205
|
+
factory(createExporter(root));
|
|
2206
|
+
}
|
|
2207
|
+
function createExporter(exports, previous) {
|
|
2208
|
+
if (exports !== root) {
|
|
2209
|
+
if (typeof Object.create === "function") {
|
|
2210
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2211
|
+
}
|
|
2212
|
+
else {
|
|
2213
|
+
exports.__esModule = true;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
|
|
2217
|
+
}
|
|
2218
|
+
})
|
|
2219
|
+
(function (exporter) {
|
|
2220
|
+
var extendStatics = Object.setPrototypeOf ||
|
|
2221
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
2222
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
2223
|
+
|
|
2224
|
+
__extends = function (d, b) {
|
|
2225
|
+
extendStatics(d, b);
|
|
2226
|
+
function __() { this.constructor = d; }
|
|
2227
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
2228
|
+
};
|
|
2229
|
+
|
|
2230
|
+
__assign = Object.assign || function (t) {
|
|
2231
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2232
|
+
s = arguments[i];
|
|
2233
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
2234
|
+
}
|
|
2235
|
+
return t;
|
|
2236
|
+
};
|
|
2237
|
+
|
|
2238
|
+
__rest = function (s, e) {
|
|
2239
|
+
var t = {};
|
|
2240
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2241
|
+
t[p] = s[p];
|
|
2242
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2243
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2244
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2245
|
+
t[p[i]] = s[p[i]];
|
|
2246
|
+
}
|
|
2247
|
+
return t;
|
|
2248
|
+
};
|
|
2249
|
+
|
|
2250
|
+
__decorate = function (decorators, target, key, desc) {
|
|
2251
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2252
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2253
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2254
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2255
|
+
};
|
|
2256
|
+
|
|
2257
|
+
__param = function (paramIndex, decorator) {
|
|
2258
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
__metadata = function (metadataKey, metadataValue) {
|
|
2262
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
2263
|
+
};
|
|
2264
|
+
|
|
2265
|
+
__awaiter = function (thisArg, _arguments, P, generator) {
|
|
2266
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2267
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2268
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2269
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2270
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2271
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2272
|
+
});
|
|
2273
|
+
};
|
|
2274
|
+
|
|
2275
|
+
__generator = function (thisArg, body) {
|
|
2276
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2277
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
2278
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
2279
|
+
function step(op) {
|
|
2280
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
2281
|
+
while (_) try {
|
|
2282
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2283
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
2284
|
+
switch (op[0]) {
|
|
2285
|
+
case 0: case 1: t = op; break;
|
|
2286
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
2287
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
2288
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
2289
|
+
default:
|
|
2290
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
2291
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
2292
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
2293
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
2294
|
+
if (t[2]) _.ops.pop();
|
|
2295
|
+
_.trys.pop(); continue;
|
|
2296
|
+
}
|
|
2297
|
+
op = body.call(thisArg, _);
|
|
2298
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
2299
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2300
|
+
}
|
|
2301
|
+
};
|
|
2302
|
+
|
|
2303
|
+
__exportStar = function (m, exports) {
|
|
2304
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
2305
|
+
};
|
|
2306
|
+
|
|
2307
|
+
__values = function (o) {
|
|
2308
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
2309
|
+
if (m) return m.call(o);
|
|
2310
|
+
if (o && typeof o.length === "number") return {
|
|
2311
|
+
next: function () {
|
|
2312
|
+
if (o && i >= o.length) o = void 0;
|
|
2313
|
+
return { value: o && o[i++], done: !o };
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
2317
|
+
};
|
|
2318
|
+
|
|
2319
|
+
__read = function (o, n) {
|
|
2320
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
2321
|
+
if (!m) return o;
|
|
2322
|
+
var i = m.call(o), r, ar = [], e;
|
|
2323
|
+
try {
|
|
2324
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
2325
|
+
}
|
|
2326
|
+
catch (error) { e = { error: error }; }
|
|
2327
|
+
finally {
|
|
2328
|
+
try {
|
|
2329
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
2330
|
+
}
|
|
2331
|
+
finally { if (e) throw e.error; }
|
|
2332
|
+
}
|
|
2333
|
+
return ar;
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
__spread = function () {
|
|
2337
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
2338
|
+
ar = ar.concat(__read(arguments[i]));
|
|
2339
|
+
return ar;
|
|
2340
|
+
};
|
|
2341
|
+
|
|
2342
|
+
__spreadArrays = function () {
|
|
2343
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
2344
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
2345
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
2346
|
+
r[k] = a[j];
|
|
2347
|
+
return r;
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2350
|
+
__await = function (v) {
|
|
2351
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
__asyncGenerator = function (thisArg, _arguments, generator) {
|
|
2355
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2356
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
2357
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
2358
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
2359
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
2360
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
2361
|
+
function fulfill(value) { resume("next", value); }
|
|
2362
|
+
function reject(value) { resume("throw", value); }
|
|
2363
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
__asyncDelegator = function (o) {
|
|
2367
|
+
var i, p;
|
|
2368
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
2369
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
2370
|
+
};
|
|
2371
|
+
|
|
2372
|
+
__asyncValues = function (o) {
|
|
2373
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
2374
|
+
var m = o[Symbol.asyncIterator], i;
|
|
2375
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
2376
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
2377
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
2378
|
+
};
|
|
2379
|
+
|
|
2380
|
+
__makeTemplateObject = function (cooked, raw) {
|
|
2381
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
2382
|
+
return cooked;
|
|
2383
|
+
};
|
|
2384
|
+
|
|
2385
|
+
__importStar = function (mod) {
|
|
2386
|
+
if (mod && mod.__esModule) return mod;
|
|
2387
|
+
var result = {};
|
|
2388
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
2389
|
+
result["default"] = mod;
|
|
2390
|
+
return result;
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2393
|
+
__importDefault = function (mod) {
|
|
2394
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
2395
|
+
};
|
|
2396
|
+
|
|
2397
|
+
__classPrivateFieldGet = function (receiver, privateMap) {
|
|
2398
|
+
if (!privateMap.has(receiver)) {
|
|
2399
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
2400
|
+
}
|
|
2401
|
+
return privateMap.get(receiver);
|
|
2402
|
+
};
|
|
2403
|
+
|
|
2404
|
+
__classPrivateFieldSet = function (receiver, privateMap, value) {
|
|
2405
|
+
if (!privateMap.has(receiver)) {
|
|
2406
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
2407
|
+
}
|
|
2408
|
+
privateMap.set(receiver, value);
|
|
2409
|
+
return value;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
exporter("__extends", __extends);
|
|
2413
|
+
exporter("__assign", __assign);
|
|
2414
|
+
exporter("__rest", __rest);
|
|
2415
|
+
exporter("__decorate", __decorate);
|
|
2416
|
+
exporter("__param", __param);
|
|
2417
|
+
exporter("__metadata", __metadata);
|
|
2418
|
+
exporter("__awaiter", __awaiter);
|
|
2419
|
+
exporter("__generator", __generator);
|
|
2420
|
+
exporter("__exportStar", __exportStar);
|
|
2421
|
+
exporter("__values", __values);
|
|
2422
|
+
exporter("__read", __read);
|
|
2423
|
+
exporter("__spread", __spread);
|
|
2424
|
+
exporter("__spreadArrays", __spreadArrays);
|
|
2425
|
+
exporter("__await", __await);
|
|
2426
|
+
exporter("__asyncGenerator", __asyncGenerator);
|
|
2427
|
+
exporter("__asyncDelegator", __asyncDelegator);
|
|
2428
|
+
exporter("__asyncValues", __asyncValues);
|
|
2429
|
+
exporter("__makeTemplateObject", __makeTemplateObject);
|
|
2430
|
+
exporter("__importStar", __importStar);
|
|
2431
|
+
exporter("__importDefault", __importDefault);
|
|
2432
|
+
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
|
|
2433
|
+
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
|
|
2434
|
+
});
|
|
2435
2435
|
;
|
|
2436
2436
|
|
|
2437
2437
|
function __isObj(x) {
|
|
@@ -10356,18 +10356,18 @@ var _src_util_path;
|
|
|
10356
10356
|
var exports = _src_util_path != null ? _src_util_path : {};
|
|
10357
10357
|
var module = { exports: exports };
|
|
10358
10358
|
|
|
10359
|
-
"use strict";
|
|
10360
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10361
|
-
exports.path_ensure = void 0;
|
|
10362
|
-
var atma_utils_1 = require("atma-utils");
|
|
10363
|
-
function path_ensure(cwd, base) {
|
|
10364
|
-
if (cwd[0] !== '/' && new atma_utils_1.class_Uri(cwd).isRelative()) {
|
|
10365
|
-
var x = require('path').normalize(atma_utils_1.class_Uri.combine(base, cwd));
|
|
10366
|
-
return x;
|
|
10367
|
-
}
|
|
10368
|
-
return cwd;
|
|
10369
|
-
}
|
|
10370
|
-
exports.path_ensure = path_ensure;
|
|
10359
|
+
"use strict";
|
|
10360
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10361
|
+
exports.path_ensure = void 0;
|
|
10362
|
+
var atma_utils_1 = require("atma-utils");
|
|
10363
|
+
function path_ensure(cwd, base) {
|
|
10364
|
+
if (cwd[0] !== '/' && new atma_utils_1.class_Uri(cwd).isRelative()) {
|
|
10365
|
+
var x = require('path').normalize(atma_utils_1.class_Uri.combine(base, cwd));
|
|
10366
|
+
return x;
|
|
10367
|
+
}
|
|
10368
|
+
return cwd;
|
|
10369
|
+
}
|
|
10370
|
+
exports.path_ensure = path_ensure;
|
|
10371
10371
|
;
|
|
10372
10372
|
|
|
10373
10373
|
function __isObj(x) {
|
|
@@ -10395,64 +10395,64 @@ var _src_util_ShellWrapperUtil;
|
|
|
10395
10395
|
var exports = _src_util_ShellWrapperUtil != null ? _src_util_ShellWrapperUtil : {};
|
|
10396
10396
|
var module = { exports: exports };
|
|
10397
10397
|
|
|
10398
|
-
"use strict";
|
|
10399
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
10400
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
10401
|
-
if (ar || !(i in from)) {
|
|
10402
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
10403
|
-
ar[i] = from[i];
|
|
10404
|
-
}
|
|
10405
|
-
}
|
|
10406
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10407
|
-
};
|
|
10408
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10409
|
-
exports.ShellWrapperUtil = void 0;
|
|
10410
|
-
var COMMAND_PLACEHOLDER = '%COMMAND%';
|
|
10411
|
-
var ShellWrapperUtil;
|
|
10412
|
-
(function (ShellWrapperUtil) {
|
|
10413
|
-
function prefix(args, config) {
|
|
10414
|
-
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10415
|
-
return args;
|
|
10416
|
-
}
|
|
10417
|
-
if (Array.isArray(config.shell) === false) {
|
|
10418
|
-
throw new Error("We can prefix only array of strings(argumnets)");
|
|
10419
|
-
return;
|
|
10420
|
-
}
|
|
10421
|
-
var _a = config.shell, exec = _a[0], rest = _a.slice(1);
|
|
10422
|
-
return __spreadArray(__spreadArray([exec], rest, true), args, true);
|
|
10423
|
-
}
|
|
10424
|
-
ShellWrapperUtil.prefix = prefix;
|
|
10425
|
-
function wrap(command, config) {
|
|
10426
|
-
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10427
|
-
return command;
|
|
10428
|
-
}
|
|
10429
|
-
if (typeof config.shell !== 'string') {
|
|
10430
|
-
throw new Error("We can wrap only as command template");
|
|
10431
|
-
return;
|
|
10432
|
-
}
|
|
10433
|
-
if (command.includes('"') === false) {
|
|
10434
|
-
command = "\"".concat(command, "\"");
|
|
10435
|
-
}
|
|
10436
|
-
else if (command.includes("'") === false) {
|
|
10437
|
-
command = "'".concat(command, "'");
|
|
10438
|
-
}
|
|
10439
|
-
else {
|
|
10440
|
-
throw new Error("Command can't be quoted, as both already present");
|
|
10441
|
-
}
|
|
10442
|
-
return config.shell.replace(COMMAND_PLACEHOLDER, command);
|
|
10443
|
-
}
|
|
10444
|
-
ShellWrapperUtil.wrap = wrap;
|
|
10445
|
-
// [cmd, /c, ...command]
|
|
10446
|
-
function isPrefix(shell) {
|
|
10447
|
-
return shell != null && Array.isArray(shell);
|
|
10448
|
-
}
|
|
10449
|
-
ShellWrapperUtil.isPrefix = isPrefix;
|
|
10450
|
-
// bash.exe -c %COMMAND%
|
|
10451
|
-
function isWrapper(shell) {
|
|
10452
|
-
return shell != null && typeof shell === 'string' && shell.includes(COMMAND_PLACEHOLDER);
|
|
10453
|
-
}
|
|
10454
|
-
ShellWrapperUtil.isWrapper = isWrapper;
|
|
10455
|
-
})(ShellWrapperUtil = exports.ShellWrapperUtil || (exports.ShellWrapperUtil = {}));
|
|
10398
|
+
"use strict";
|
|
10399
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
10400
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
10401
|
+
if (ar || !(i in from)) {
|
|
10402
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
10403
|
+
ar[i] = from[i];
|
|
10404
|
+
}
|
|
10405
|
+
}
|
|
10406
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10407
|
+
};
|
|
10408
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10409
|
+
exports.ShellWrapperUtil = void 0;
|
|
10410
|
+
var COMMAND_PLACEHOLDER = '%COMMAND%';
|
|
10411
|
+
var ShellWrapperUtil;
|
|
10412
|
+
(function (ShellWrapperUtil) {
|
|
10413
|
+
function prefix(args, config) {
|
|
10414
|
+
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10415
|
+
return args;
|
|
10416
|
+
}
|
|
10417
|
+
if (Array.isArray(config.shell) === false) {
|
|
10418
|
+
throw new Error("We can prefix only array of strings(argumnets)");
|
|
10419
|
+
return;
|
|
10420
|
+
}
|
|
10421
|
+
var _a = config.shell, exec = _a[0], rest = _a.slice(1);
|
|
10422
|
+
return __spreadArray(__spreadArray([exec], rest, true), args, true);
|
|
10423
|
+
}
|
|
10424
|
+
ShellWrapperUtil.prefix = prefix;
|
|
10425
|
+
function wrap(command, config) {
|
|
10426
|
+
if (!(config === null || config === void 0 ? void 0 : config.shell)) {
|
|
10427
|
+
return command;
|
|
10428
|
+
}
|
|
10429
|
+
if (typeof config.shell !== 'string') {
|
|
10430
|
+
throw new Error("We can wrap only as command template");
|
|
10431
|
+
return;
|
|
10432
|
+
}
|
|
10433
|
+
if (command.includes('"') === false) {
|
|
10434
|
+
command = "\"".concat(command, "\"");
|
|
10435
|
+
}
|
|
10436
|
+
else if (command.includes("'") === false) {
|
|
10437
|
+
command = "'".concat(command, "'");
|
|
10438
|
+
}
|
|
10439
|
+
else {
|
|
10440
|
+
throw new Error("Command can't be quoted, as both already present");
|
|
10441
|
+
}
|
|
10442
|
+
return config.shell.replace(COMMAND_PLACEHOLDER, command);
|
|
10443
|
+
}
|
|
10444
|
+
ShellWrapperUtil.wrap = wrap;
|
|
10445
|
+
// [cmd, /c, ...command]
|
|
10446
|
+
function isPrefix(shell) {
|
|
10447
|
+
return shell != null && Array.isArray(shell);
|
|
10448
|
+
}
|
|
10449
|
+
ShellWrapperUtil.isPrefix = isPrefix;
|
|
10450
|
+
// bash.exe -c %COMMAND%
|
|
10451
|
+
function isWrapper(shell) {
|
|
10452
|
+
return shell != null && typeof shell === 'string' && shell.includes(COMMAND_PLACEHOLDER);
|
|
10453
|
+
}
|
|
10454
|
+
ShellWrapperUtil.isWrapper = isWrapper;
|
|
10455
|
+
})(ShellWrapperUtil = exports.ShellWrapperUtil || (exports.ShellWrapperUtil = {}));
|
|
10456
10456
|
;
|
|
10457
10457
|
|
|
10458
10458
|
function __isObj(x) {
|
|
@@ -10480,84 +10480,84 @@ var _src_util_command;
|
|
|
10480
10480
|
var exports = _src_util_command != null ? _src_util_command : {};
|
|
10481
10481
|
var module = { exports: exports };
|
|
10482
10482
|
|
|
10483
|
-
"use strict";
|
|
10484
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10485
|
-
exports.command_parseAll = void 0;
|
|
10486
|
-
var path_1 = _src_util_path;
|
|
10487
|
-
var ShellWrapperUtil_1 = _src_util_ShellWrapperUtil;
|
|
10488
|
-
function command_parseAll(commands, params) {
|
|
10489
|
-
var _a;
|
|
10490
|
-
var cwdAll = (_a = params.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
10491
|
-
cwdAll = (0, path_1.path_ensure)(cwdAll, process.cwd());
|
|
10492
|
-
return commands.map(function (command) {
|
|
10493
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10494
|
-
var opts = typeof command === 'string' ? {
|
|
10495
|
-
exec: command
|
|
10496
|
-
} : command;
|
|
10497
|
-
if (opts.cwd) {
|
|
10498
|
-
opts.cwd = (0, path_1.path_ensure)(opts.cwd, cwdAll !== null && cwdAll !== void 0 ? cwdAll : process.cwd());
|
|
10499
|
-
}
|
|
10500
|
-
var exec = opts.exec;
|
|
10501
|
-
if (exec == null || exec === '') {
|
|
10502
|
-
console.warn('Command Object is not valid. Should be at least {command: string}');
|
|
10503
|
-
return null;
|
|
10504
|
-
}
|
|
10505
|
-
var args = command_parse(exec, params);
|
|
10506
|
-
return {
|
|
10507
|
-
exec: args.shift(),
|
|
10508
|
-
args: args,
|
|
10509
|
-
cwd: (_b = (_a = opts.cwd) !== null && _a !== void 0 ? _a : cwdAll) !== null && _b !== void 0 ? _b : process.cwd(),
|
|
10510
|
-
//stdio: 'pipe',
|
|
10511
|
-
detached: (_d = (_c = opts.detached) !== null && _c !== void 0 ? _c : params.detached) !== null && _d !== void 0 ? _d : false,
|
|
10512
|
-
command: exec,
|
|
10513
|
-
matchReady: (_e = opts.matchReady) !== null && _e !== void 0 ? _e : params.matchReady,
|
|
10514
|
-
extract: opts.extract,
|
|
10515
|
-
fork: (_g = (_f = opts.fork) !== null && _f !== void 0 ? _f : params.fork) !== null && _g !== void 0 ? _g : false,
|
|
10516
|
-
ipc: (_j = (_h = opts.ipc) !== null && _h !== void 0 ? _h : params.ipc) !== null && _j !== void 0 ? _j : false,
|
|
10517
|
-
};
|
|
10518
|
-
}).filter(function (x) { return x != null; });
|
|
10519
|
-
}
|
|
10520
|
-
exports.command_parseAll = command_parseAll;
|
|
10521
|
-
function command_parse(command, params) {
|
|
10522
|
-
if (ShellWrapperUtil_1.ShellWrapperUtil.isWrapper(params.shell)) {
|
|
10523
|
-
command = ShellWrapperUtil_1.ShellWrapperUtil.wrap(command, params);
|
|
10524
|
-
}
|
|
10525
|
-
var parts = command.trim().split(/\s+/);
|
|
10526
|
-
var imax = parts.length;
|
|
10527
|
-
var i = -1;
|
|
10528
|
-
while (++i < imax) {
|
|
10529
|
-
var arg = parts[i];
|
|
10530
|
-
if (arg.length === 0) {
|
|
10531
|
-
continue;
|
|
10532
|
-
}
|
|
10533
|
-
var c = arg[0];
|
|
10534
|
-
if (c !== '"' && c !== "'") {
|
|
10535
|
-
continue;
|
|
10536
|
-
}
|
|
10537
|
-
var start = i;
|
|
10538
|
-
for (; i < imax; i++) {
|
|
10539
|
-
arg = parts[i];
|
|
10540
|
-
if (arg[arg.length - 1] === c) {
|
|
10541
|
-
var str = parts
|
|
10542
|
-
.splice(start, i - start + 1)
|
|
10543
|
-
.join(' ')
|
|
10544
|
-
.slice(1, -1);
|
|
10545
|
-
parts.splice(start, 0, str);
|
|
10546
|
-
imax = parts.length;
|
|
10547
|
-
i--;
|
|
10548
|
-
break;
|
|
10549
|
-
}
|
|
10550
|
-
}
|
|
10551
|
-
}
|
|
10552
|
-
// On windows normalize executable command path to backward slashes
|
|
10553
|
-
if (global.process.platform === 'win32') {
|
|
10554
|
-
parts[0] = parts[0].replace(/\//g, '\\');
|
|
10555
|
-
}
|
|
10556
|
-
if (ShellWrapperUtil_1.ShellWrapperUtil.isPrefix(params.shell)) {
|
|
10557
|
-
parts = ShellWrapperUtil_1.ShellWrapperUtil.prefix(parts, params);
|
|
10558
|
-
}
|
|
10559
|
-
return parts;
|
|
10560
|
-
}
|
|
10483
|
+
"use strict";
|
|
10484
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10485
|
+
exports.command_parseAll = void 0;
|
|
10486
|
+
var path_1 = _src_util_path;
|
|
10487
|
+
var ShellWrapperUtil_1 = _src_util_ShellWrapperUtil;
|
|
10488
|
+
function command_parseAll(commands, params) {
|
|
10489
|
+
var _a;
|
|
10490
|
+
var cwdAll = (_a = params.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
10491
|
+
cwdAll = (0, path_1.path_ensure)(cwdAll, process.cwd());
|
|
10492
|
+
return commands.map(function (command) {
|
|
10493
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10494
|
+
var opts = typeof command === 'string' ? {
|
|
10495
|
+
exec: command
|
|
10496
|
+
} : command;
|
|
10497
|
+
if (opts.cwd) {
|
|
10498
|
+
opts.cwd = (0, path_1.path_ensure)(opts.cwd, cwdAll !== null && cwdAll !== void 0 ? cwdAll : process.cwd());
|
|
10499
|
+
}
|
|
10500
|
+
var exec = opts.exec;
|
|
10501
|
+
if (exec == null || exec === '') {
|
|
10502
|
+
console.warn('Command Object is not valid. Should be at least {command: string}');
|
|
10503
|
+
return null;
|
|
10504
|
+
}
|
|
10505
|
+
var args = command_parse(exec, params);
|
|
10506
|
+
return {
|
|
10507
|
+
exec: args.shift(),
|
|
10508
|
+
args: args,
|
|
10509
|
+
cwd: (_b = (_a = opts.cwd) !== null && _a !== void 0 ? _a : cwdAll) !== null && _b !== void 0 ? _b : process.cwd(),
|
|
10510
|
+
//stdio: 'pipe',
|
|
10511
|
+
detached: (_d = (_c = opts.detached) !== null && _c !== void 0 ? _c : params.detached) !== null && _d !== void 0 ? _d : false,
|
|
10512
|
+
command: exec,
|
|
10513
|
+
matchReady: (_e = opts.matchReady) !== null && _e !== void 0 ? _e : params.matchReady,
|
|
10514
|
+
extract: opts.extract,
|
|
10515
|
+
fork: (_g = (_f = opts.fork) !== null && _f !== void 0 ? _f : params.fork) !== null && _g !== void 0 ? _g : false,
|
|
10516
|
+
ipc: (_j = (_h = opts.ipc) !== null && _h !== void 0 ? _h : params.ipc) !== null && _j !== void 0 ? _j : false,
|
|
10517
|
+
};
|
|
10518
|
+
}).filter(function (x) { return x != null; });
|
|
10519
|
+
}
|
|
10520
|
+
exports.command_parseAll = command_parseAll;
|
|
10521
|
+
function command_parse(command, params) {
|
|
10522
|
+
if (ShellWrapperUtil_1.ShellWrapperUtil.isWrapper(params.shell)) {
|
|
10523
|
+
command = ShellWrapperUtil_1.ShellWrapperUtil.wrap(command, params);
|
|
10524
|
+
}
|
|
10525
|
+
var parts = command.trim().split(/\s+/);
|
|
10526
|
+
var imax = parts.length;
|
|
10527
|
+
var i = -1;
|
|
10528
|
+
while (++i < imax) {
|
|
10529
|
+
var arg = parts[i];
|
|
10530
|
+
if (arg.length === 0) {
|
|
10531
|
+
continue;
|
|
10532
|
+
}
|
|
10533
|
+
var c = arg[0];
|
|
10534
|
+
if (c !== '"' && c !== "'") {
|
|
10535
|
+
continue;
|
|
10536
|
+
}
|
|
10537
|
+
var start = i;
|
|
10538
|
+
for (; i < imax; i++) {
|
|
10539
|
+
arg = parts[i];
|
|
10540
|
+
if (arg[arg.length - 1] === c) {
|
|
10541
|
+
var str = parts
|
|
10542
|
+
.splice(start, i - start + 1)
|
|
10543
|
+
.join(' ')
|
|
10544
|
+
.slice(1, -1);
|
|
10545
|
+
parts.splice(start, 0, str);
|
|
10546
|
+
imax = parts.length;
|
|
10547
|
+
i--;
|
|
10548
|
+
break;
|
|
10549
|
+
}
|
|
10550
|
+
}
|
|
10551
|
+
}
|
|
10552
|
+
// On windows normalize executable command path to backward slashes
|
|
10553
|
+
if (global.process.platform === 'win32') {
|
|
10554
|
+
parts[0] = parts[0].replace(/\//g, '\\');
|
|
10555
|
+
}
|
|
10556
|
+
if (ShellWrapperUtil_1.ShellWrapperUtil.isPrefix(params.shell)) {
|
|
10557
|
+
parts = ShellWrapperUtil_1.ShellWrapperUtil.prefix(parts, params);
|
|
10558
|
+
}
|
|
10559
|
+
return parts;
|
|
10560
|
+
}
|
|
10561
10561
|
;
|
|
10562
10562
|
|
|
10563
10563
|
function __isObj(x) {
|
|
@@ -10585,60 +10585,60 @@ var _src_ValueExtractor;
|
|
|
10585
10585
|
var exports = _src_ValueExtractor != null ? _src_ValueExtractor : {};
|
|
10586
10586
|
var module = { exports: exports };
|
|
10587
10587
|
|
|
10588
|
-
"use strict";
|
|
10589
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10590
|
-
exports.ValueExtractor = void 0;
|
|
10591
|
-
var atma_utils_1 = require("atma-utils");
|
|
10592
|
-
var ValueExtractor = /** @class */ (function () {
|
|
10593
|
-
function ValueExtractor(target, extractors) {
|
|
10594
|
-
this.target = target;
|
|
10595
|
-
this.extractors = extractors;
|
|
10596
|
-
this.string = '';
|
|
10597
|
-
this.string = '';
|
|
10598
|
-
}
|
|
10599
|
-
ValueExtractor.prototype.write = function (buffer) {
|
|
10600
|
-
this.string += buffer.toString();
|
|
10601
|
-
};
|
|
10602
|
-
ValueExtractor.prototype.complete = function () {
|
|
10603
|
-
for (var key in this.extractors) {
|
|
10604
|
-
this.target[key] = (0, atma_utils_1.is_Function)(this.extractors[key])
|
|
10605
|
-
? this.extractors[key](this.string)
|
|
10606
|
-
: null;
|
|
10607
|
-
}
|
|
10608
|
-
};
|
|
10609
|
-
ValueExtractor.extract = function (str, mix) {
|
|
10610
|
-
if (typeof mix === 'function') {
|
|
10611
|
-
return mix(str);
|
|
10612
|
-
}
|
|
10613
|
-
};
|
|
10614
|
-
ValueExtractor.interpolateAny = function (mix, values, options) {
|
|
10615
|
-
if (mix == null || (options === null || options === void 0 ? void 0 : options.interpolate) === false) {
|
|
10616
|
-
return mix;
|
|
10617
|
-
}
|
|
10618
|
-
if (typeof mix === 'string') {
|
|
10619
|
-
return ValueExtractor.interpolateStr(mix, values);
|
|
10620
|
-
}
|
|
10621
|
-
if (typeof mix.map === 'function') {
|
|
10622
|
-
// isArrayLike
|
|
10623
|
-
return mix.map(function (str) {
|
|
10624
|
-
return ValueExtractor.interpolateAny(str, values, options);
|
|
10625
|
-
});
|
|
10626
|
-
}
|
|
10627
|
-
return mix;
|
|
10628
|
-
};
|
|
10629
|
-
ValueExtractor.interpolateStr = function (str, values) {
|
|
10630
|
-
return str.replace(/\{\{(\w+)\}\}/g, function (full, prop) {
|
|
10631
|
-
var val = values[prop];
|
|
10632
|
-
if (val == null) {
|
|
10633
|
-
console.warn('Extracted property expected: ', prop, values);
|
|
10634
|
-
return '';
|
|
10635
|
-
}
|
|
10636
|
-
return val;
|
|
10637
|
-
});
|
|
10638
|
-
};
|
|
10639
|
-
return ValueExtractor;
|
|
10640
|
-
}());
|
|
10641
|
-
exports.ValueExtractor = ValueExtractor;
|
|
10588
|
+
"use strict";
|
|
10589
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10590
|
+
exports.ValueExtractor = void 0;
|
|
10591
|
+
var atma_utils_1 = require("atma-utils");
|
|
10592
|
+
var ValueExtractor = /** @class */ (function () {
|
|
10593
|
+
function ValueExtractor(target, extractors) {
|
|
10594
|
+
this.target = target;
|
|
10595
|
+
this.extractors = extractors;
|
|
10596
|
+
this.string = '';
|
|
10597
|
+
this.string = '';
|
|
10598
|
+
}
|
|
10599
|
+
ValueExtractor.prototype.write = function (buffer) {
|
|
10600
|
+
this.string += buffer.toString();
|
|
10601
|
+
};
|
|
10602
|
+
ValueExtractor.prototype.complete = function () {
|
|
10603
|
+
for (var key in this.extractors) {
|
|
10604
|
+
this.target[key] = (0, atma_utils_1.is_Function)(this.extractors[key])
|
|
10605
|
+
? this.extractors[key](this.string)
|
|
10606
|
+
: null;
|
|
10607
|
+
}
|
|
10608
|
+
};
|
|
10609
|
+
ValueExtractor.extract = function (str, mix) {
|
|
10610
|
+
if (typeof mix === 'function') {
|
|
10611
|
+
return mix(str);
|
|
10612
|
+
}
|
|
10613
|
+
};
|
|
10614
|
+
ValueExtractor.interpolateAny = function (mix, values, options) {
|
|
10615
|
+
if (mix == null || (options === null || options === void 0 ? void 0 : options.interpolate) === false) {
|
|
10616
|
+
return mix;
|
|
10617
|
+
}
|
|
10618
|
+
if (typeof mix === 'string') {
|
|
10619
|
+
return ValueExtractor.interpolateStr(mix, values);
|
|
10620
|
+
}
|
|
10621
|
+
if (typeof mix.map === 'function') {
|
|
10622
|
+
// isArrayLike
|
|
10623
|
+
return mix.map(function (str) {
|
|
10624
|
+
return ValueExtractor.interpolateAny(str, values, options);
|
|
10625
|
+
});
|
|
10626
|
+
}
|
|
10627
|
+
return mix;
|
|
10628
|
+
};
|
|
10629
|
+
ValueExtractor.interpolateStr = function (str, values) {
|
|
10630
|
+
return str.replace(/\{\{(\w+)\}\}/g, function (full, prop) {
|
|
10631
|
+
var val = values[prop];
|
|
10632
|
+
if (val == null) {
|
|
10633
|
+
console.warn('Extracted property expected: ', prop, values);
|
|
10634
|
+
return '';
|
|
10635
|
+
}
|
|
10636
|
+
return val;
|
|
10637
|
+
});
|
|
10638
|
+
};
|
|
10639
|
+
return ValueExtractor;
|
|
10640
|
+
}());
|
|
10641
|
+
exports.ValueExtractor = ValueExtractor;
|
|
10642
10642
|
;
|
|
10643
10643
|
|
|
10644
10644
|
function __isObj(x) {
|
|
@@ -10666,17 +10666,17 @@ var _src_util_serialize;
|
|
|
10666
10666
|
var exports = _src_util_serialize != null ? _src_util_serialize : {};
|
|
10667
10667
|
var module = { exports: exports };
|
|
10668
10668
|
|
|
10669
|
-
"use strict";
|
|
10670
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10671
|
-
exports.serialize_error = void 0;
|
|
10672
|
-
function serialize_error(err) {
|
|
10673
|
-
var _a;
|
|
10674
|
-
return {
|
|
10675
|
-
message: (_a = err.message) !== null && _a !== void 0 ? _a : String(err),
|
|
10676
|
-
stack: err.stack
|
|
10677
|
-
};
|
|
10678
|
-
}
|
|
10679
|
-
exports.serialize_error = serialize_error;
|
|
10669
|
+
"use strict";
|
|
10670
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10671
|
+
exports.serialize_error = void 0;
|
|
10672
|
+
function serialize_error(err) {
|
|
10673
|
+
var _a;
|
|
10674
|
+
return {
|
|
10675
|
+
message: (_a = err.message) !== null && _a !== void 0 ? _a : String(err),
|
|
10676
|
+
stack: err.stack
|
|
10677
|
+
};
|
|
10678
|
+
}
|
|
10679
|
+
exports.serialize_error = serialize_error;
|
|
10680
10680
|
;
|
|
10681
10681
|
|
|
10682
10682
|
function __isObj(x) {
|
|
@@ -10704,135 +10704,135 @@ var _src_CommunicationChannel;
|
|
|
10704
10704
|
var exports = _src_CommunicationChannel != null ? _src_CommunicationChannel : {};
|
|
10705
10705
|
var module = { exports: exports };
|
|
10706
10706
|
|
|
10707
|
-
"use strict";
|
|
10708
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10709
|
-
exports.CommunicationChannel = void 0;
|
|
10710
|
-
var atma_utils_1 = require("atma-utils");
|
|
10711
|
-
var serialize_1 = _src_util_serialize;
|
|
10712
|
-
var CommunicationChannel = /** @class */ (function () {
|
|
10713
|
-
function CommunicationChannel(child, timeoutMs) {
|
|
10714
|
-
var _this = this;
|
|
10715
|
-
this.child = child;
|
|
10716
|
-
this.timeoutMs = timeoutMs;
|
|
10717
|
-
this.awaiters = Object.create(null);
|
|
10718
|
-
child.on('message', function (resp) {
|
|
10719
|
-
if (resp.id == null || resp.id in _this.awaiters === false) {
|
|
10720
|
-
return;
|
|
10721
|
-
}
|
|
10722
|
-
var awaiter = _this.awaiters[resp.id];
|
|
10723
|
-
delete _this.awaiters[resp.id];
|
|
10724
|
-
if (resp.error) {
|
|
10725
|
-
awaiter.promise.reject(resp.error);
|
|
10726
|
-
return;
|
|
10727
|
-
}
|
|
10728
|
-
awaiter.promise.resolve(resp.data);
|
|
10729
|
-
});
|
|
10730
|
-
}
|
|
10731
|
-
CommunicationChannel.ipc = function (handlers) {
|
|
10732
|
-
process.on('message', function (message) {
|
|
10733
|
-
var id = message.id, method = message.method, args = message.args;
|
|
10734
|
-
var handler = (0, atma_utils_1.obj_getProperty)(handlers, method);
|
|
10735
|
-
if (typeof handler !== 'function') {
|
|
10736
|
-
process.send({
|
|
10737
|
-
id: id,
|
|
10738
|
-
error: (0, serialize_1.serialize_error)(new Error("".concat(method, " not defined")))
|
|
10739
|
-
});
|
|
10740
|
-
return;
|
|
10741
|
-
}
|
|
10742
|
-
try {
|
|
10743
|
-
var result = handler.apply(null, args);
|
|
10744
|
-
if (result == null) {
|
|
10745
|
-
process.send({
|
|
10746
|
-
id: id,
|
|
10747
|
-
data: null
|
|
10748
|
-
});
|
|
10749
|
-
return;
|
|
10750
|
-
}
|
|
10751
|
-
if (typeof result.then === 'function') {
|
|
10752
|
-
result.then(function (data) {
|
|
10753
|
-
process.send({
|
|
10754
|
-
id: id,
|
|
10755
|
-
data: data
|
|
10756
|
-
});
|
|
10757
|
-
}, function (error) {
|
|
10758
|
-
process.send({
|
|
10759
|
-
id: id,
|
|
10760
|
-
error: (0, serialize_1.serialize_error)(error),
|
|
10761
|
-
});
|
|
10762
|
-
});
|
|
10763
|
-
return;
|
|
10764
|
-
}
|
|
10765
|
-
process.send({
|
|
10766
|
-
id: id,
|
|
10767
|
-
data: result
|
|
10768
|
-
});
|
|
10769
|
-
}
|
|
10770
|
-
catch (error) {
|
|
10771
|
-
process.send({
|
|
10772
|
-
id: id,
|
|
10773
|
-
error: (0, serialize_1.serialize_error)(error),
|
|
10774
|
-
});
|
|
10775
|
-
return;
|
|
10776
|
-
}
|
|
10777
|
-
});
|
|
10778
|
-
setTimeout(function () { return console.log('IPC Listening'); }, 10);
|
|
10779
|
-
};
|
|
10780
|
-
CommunicationChannel.prototype.call = function (method) {
|
|
10781
|
-
var _this = this;
|
|
10782
|
-
var args = [];
|
|
10783
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10784
|
-
args[_i - 1] = arguments[_i];
|
|
10785
|
-
}
|
|
10786
|
-
var promise = new atma_utils_1.class_Dfr;
|
|
10787
|
-
var id = (Math.round(Math.random() * Math.pow(10, 10))) + '' + Date.now();
|
|
10788
|
-
this.awaiters[id] = {
|
|
10789
|
-
timestamp: Date.now(),
|
|
10790
|
-
promise: promise
|
|
10791
|
-
};
|
|
10792
|
-
this.child.send({
|
|
10793
|
-
id: id,
|
|
10794
|
-
method: method,
|
|
10795
|
-
args: args
|
|
10796
|
-
});
|
|
10797
|
-
if (this.timeoutMs) {
|
|
10798
|
-
setTimeout(function () { return _this.checkTimeout(); }, this.timeoutMs);
|
|
10799
|
-
}
|
|
10800
|
-
return promise;
|
|
10801
|
-
};
|
|
10802
|
-
CommunicationChannel.prototype.checkTimeout = function () {
|
|
10803
|
-
var _this = this;
|
|
10804
|
-
var now = Date.now();
|
|
10805
|
-
var keys = [];
|
|
10806
|
-
for (var key in this.awaiters) {
|
|
10807
|
-
var bin = this.awaiters[key];
|
|
10808
|
-
var ms = now - bin.timestamp;
|
|
10809
|
-
if (ms >= this.timeoutMs) {
|
|
10810
|
-
try {
|
|
10811
|
-
bin.promise.reject(new Error('Timeouted'));
|
|
10812
|
-
}
|
|
10813
|
-
catch (error) { }
|
|
10814
|
-
keys.push(key);
|
|
10815
|
-
}
|
|
10816
|
-
}
|
|
10817
|
-
keys.forEach(function (key) { return delete _this.awaiters[key]; });
|
|
10818
|
-
};
|
|
10819
|
-
CommunicationChannel.prototype.onError = function (error) {
|
|
10820
|
-
var obj = Object.create(this.awaiters);
|
|
10821
|
-
this.awaiters = {};
|
|
10822
|
-
for (var key in obj) {
|
|
10823
|
-
var bin = obj[key];
|
|
10824
|
-
try {
|
|
10825
|
-
bin.promise.reject(error);
|
|
10826
|
-
}
|
|
10827
|
-
catch (error) { }
|
|
10828
|
-
}
|
|
10829
|
-
};
|
|
10830
|
-
CommunicationChannel.prototype.onStdError = function (str) {
|
|
10831
|
-
this.onError(new Error(str));
|
|
10832
|
-
};
|
|
10833
|
-
return CommunicationChannel;
|
|
10834
|
-
}());
|
|
10835
|
-
exports.CommunicationChannel = CommunicationChannel;
|
|
10707
|
+
"use strict";
|
|
10708
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10709
|
+
exports.CommunicationChannel = void 0;
|
|
10710
|
+
var atma_utils_1 = require("atma-utils");
|
|
10711
|
+
var serialize_1 = _src_util_serialize;
|
|
10712
|
+
var CommunicationChannel = /** @class */ (function () {
|
|
10713
|
+
function CommunicationChannel(child, timeoutMs) {
|
|
10714
|
+
var _this = this;
|
|
10715
|
+
this.child = child;
|
|
10716
|
+
this.timeoutMs = timeoutMs;
|
|
10717
|
+
this.awaiters = Object.create(null);
|
|
10718
|
+
child.on('message', function (resp) {
|
|
10719
|
+
if (resp.id == null || resp.id in _this.awaiters === false) {
|
|
10720
|
+
return;
|
|
10721
|
+
}
|
|
10722
|
+
var awaiter = _this.awaiters[resp.id];
|
|
10723
|
+
delete _this.awaiters[resp.id];
|
|
10724
|
+
if (resp.error) {
|
|
10725
|
+
awaiter.promise.reject(resp.error);
|
|
10726
|
+
return;
|
|
10727
|
+
}
|
|
10728
|
+
awaiter.promise.resolve(resp.data);
|
|
10729
|
+
});
|
|
10730
|
+
}
|
|
10731
|
+
CommunicationChannel.ipc = function (handlers) {
|
|
10732
|
+
process.on('message', function (message) {
|
|
10733
|
+
var id = message.id, method = message.method, args = message.args;
|
|
10734
|
+
var handler = (0, atma_utils_1.obj_getProperty)(handlers, method);
|
|
10735
|
+
if (typeof handler !== 'function') {
|
|
10736
|
+
process.send({
|
|
10737
|
+
id: id,
|
|
10738
|
+
error: (0, serialize_1.serialize_error)(new Error("".concat(method, " not defined")))
|
|
10739
|
+
});
|
|
10740
|
+
return;
|
|
10741
|
+
}
|
|
10742
|
+
try {
|
|
10743
|
+
var result = handler.apply(null, args);
|
|
10744
|
+
if (result == null) {
|
|
10745
|
+
process.send({
|
|
10746
|
+
id: id,
|
|
10747
|
+
data: null
|
|
10748
|
+
});
|
|
10749
|
+
return;
|
|
10750
|
+
}
|
|
10751
|
+
if (typeof result.then === 'function') {
|
|
10752
|
+
result.then(function (data) {
|
|
10753
|
+
process.send({
|
|
10754
|
+
id: id,
|
|
10755
|
+
data: data
|
|
10756
|
+
});
|
|
10757
|
+
}, function (error) {
|
|
10758
|
+
process.send({
|
|
10759
|
+
id: id,
|
|
10760
|
+
error: (0, serialize_1.serialize_error)(error),
|
|
10761
|
+
});
|
|
10762
|
+
});
|
|
10763
|
+
return;
|
|
10764
|
+
}
|
|
10765
|
+
process.send({
|
|
10766
|
+
id: id,
|
|
10767
|
+
data: result
|
|
10768
|
+
});
|
|
10769
|
+
}
|
|
10770
|
+
catch (error) {
|
|
10771
|
+
process.send({
|
|
10772
|
+
id: id,
|
|
10773
|
+
error: (0, serialize_1.serialize_error)(error),
|
|
10774
|
+
});
|
|
10775
|
+
return;
|
|
10776
|
+
}
|
|
10777
|
+
});
|
|
10778
|
+
setTimeout(function () { return console.log('IPC Listening'); }, 10);
|
|
10779
|
+
};
|
|
10780
|
+
CommunicationChannel.prototype.call = function (method) {
|
|
10781
|
+
var _this = this;
|
|
10782
|
+
var args = [];
|
|
10783
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
10784
|
+
args[_i - 1] = arguments[_i];
|
|
10785
|
+
}
|
|
10786
|
+
var promise = new atma_utils_1.class_Dfr;
|
|
10787
|
+
var id = (Math.round(Math.random() * Math.pow(10, 10))) + '' + Date.now();
|
|
10788
|
+
this.awaiters[id] = {
|
|
10789
|
+
timestamp: Date.now(),
|
|
10790
|
+
promise: promise
|
|
10791
|
+
};
|
|
10792
|
+
this.child.send({
|
|
10793
|
+
id: id,
|
|
10794
|
+
method: method,
|
|
10795
|
+
args: args
|
|
10796
|
+
});
|
|
10797
|
+
if (this.timeoutMs) {
|
|
10798
|
+
setTimeout(function () { return _this.checkTimeout(); }, this.timeoutMs);
|
|
10799
|
+
}
|
|
10800
|
+
return promise;
|
|
10801
|
+
};
|
|
10802
|
+
CommunicationChannel.prototype.checkTimeout = function () {
|
|
10803
|
+
var _this = this;
|
|
10804
|
+
var now = Date.now();
|
|
10805
|
+
var keys = [];
|
|
10806
|
+
for (var key in this.awaiters) {
|
|
10807
|
+
var bin = this.awaiters[key];
|
|
10808
|
+
var ms = now - bin.timestamp;
|
|
10809
|
+
if (ms >= this.timeoutMs) {
|
|
10810
|
+
try {
|
|
10811
|
+
bin.promise.reject(new Error('Timeouted'));
|
|
10812
|
+
}
|
|
10813
|
+
catch (error) { }
|
|
10814
|
+
keys.push(key);
|
|
10815
|
+
}
|
|
10816
|
+
}
|
|
10817
|
+
keys.forEach(function (key) { return delete _this.awaiters[key]; });
|
|
10818
|
+
};
|
|
10819
|
+
CommunicationChannel.prototype.onError = function (error) {
|
|
10820
|
+
var obj = Object.create(this.awaiters);
|
|
10821
|
+
this.awaiters = {};
|
|
10822
|
+
for (var key in obj) {
|
|
10823
|
+
var bin = obj[key];
|
|
10824
|
+
try {
|
|
10825
|
+
bin.promise.reject(error);
|
|
10826
|
+
}
|
|
10827
|
+
catch (error) { }
|
|
10828
|
+
}
|
|
10829
|
+
};
|
|
10830
|
+
CommunicationChannel.prototype.onStdError = function (str) {
|
|
10831
|
+
this.onError(new Error(str));
|
|
10832
|
+
};
|
|
10833
|
+
return CommunicationChannel;
|
|
10834
|
+
}());
|
|
10835
|
+
exports.CommunicationChannel = CommunicationChannel;
|
|
10836
10836
|
;
|
|
10837
10837
|
|
|
10838
10838
|
function __isObj(x) {
|
|
@@ -10860,30 +10860,30 @@ var _src_util_events;
|
|
|
10860
10860
|
var exports = _src_util_events != null ? _src_util_events : {};
|
|
10861
10861
|
var module = { exports: exports };
|
|
10862
10862
|
|
|
10863
|
-
"use strict";
|
|
10864
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10865
|
-
exports.events_someOnce = void 0;
|
|
10866
|
-
function events_someOnce(emitter, events) {
|
|
10867
|
-
var listeners = {};
|
|
10868
|
-
for (var event in events) {
|
|
10869
|
-
emitter.on(event, delegate(emitter, listeners, event, events[event]));
|
|
10870
|
-
}
|
|
10871
|
-
}
|
|
10872
|
-
exports.events_someOnce = events_someOnce;
|
|
10873
|
-
function delegate(emitter, listeners, event, cb) {
|
|
10874
|
-
function fn() {
|
|
10875
|
-
var args = [];
|
|
10876
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10877
|
-
args[_i] = arguments[_i];
|
|
10878
|
-
}
|
|
10879
|
-
for (var event_1 in listeners) {
|
|
10880
|
-
emitter.off(event_1, listeners[event_1]);
|
|
10881
|
-
}
|
|
10882
|
-
cb === null || cb === void 0 ? void 0 : cb.apply(void 0, args);
|
|
10883
|
-
}
|
|
10884
|
-
listeners[event] = fn;
|
|
10885
|
-
return fn;
|
|
10886
|
-
}
|
|
10863
|
+
"use strict";
|
|
10864
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10865
|
+
exports.events_someOnce = void 0;
|
|
10866
|
+
function events_someOnce(emitter, events) {
|
|
10867
|
+
var listeners = {};
|
|
10868
|
+
for (var event in events) {
|
|
10869
|
+
emitter.on(event, delegate(emitter, listeners, event, events[event]));
|
|
10870
|
+
}
|
|
10871
|
+
}
|
|
10872
|
+
exports.events_someOnce = events_someOnce;
|
|
10873
|
+
function delegate(emitter, listeners, event, cb) {
|
|
10874
|
+
function fn() {
|
|
10875
|
+
var args = [];
|
|
10876
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10877
|
+
args[_i] = arguments[_i];
|
|
10878
|
+
}
|
|
10879
|
+
for (var event_1 in listeners) {
|
|
10880
|
+
emitter.off(event_1, listeners[event_1]);
|
|
10881
|
+
}
|
|
10882
|
+
cb === null || cb === void 0 ? void 0 : cb.apply(void 0, args);
|
|
10883
|
+
}
|
|
10884
|
+
listeners[event] = fn;
|
|
10885
|
+
return fn;
|
|
10886
|
+
}
|
|
10887
10887
|
;
|
|
10888
10888
|
|
|
10889
10889
|
function __isObj(x) {
|
|
@@ -10911,33 +10911,33 @@ var _src_util_ShellParamsUtil;
|
|
|
10911
10911
|
var exports = _src_util_ShellParamsUtil != null ? _src_util_ShellParamsUtil : {};
|
|
10912
10912
|
var module = { exports: exports };
|
|
10913
10913
|
|
|
10914
|
-
"use strict";
|
|
10915
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10916
|
-
exports.ShellParamsUtil = void 0;
|
|
10917
|
-
var ShellParamsUtil;
|
|
10918
|
-
(function (ShellParamsUtil) {
|
|
10919
|
-
function normalize(params) {
|
|
10920
|
-
var _a, _b;
|
|
10921
|
-
if (params.shell == null && !params.fork) {
|
|
10922
|
-
params.shell = DEFAULT.shell;
|
|
10923
|
-
}
|
|
10924
|
-
if (params.command != null) {
|
|
10925
|
-
params.commands = [params.command];
|
|
10926
|
-
}
|
|
10927
|
-
if (params.commands == null) {
|
|
10928
|
-
throw new Error("shellbee: Command(s) are not defined");
|
|
10929
|
-
}
|
|
10930
|
-
(_a = params.parallel) !== null && _a !== void 0 ? _a : (params.parallel = false);
|
|
10931
|
-
(_b = params.restartOnErrorExit) !== null && _b !== void 0 ? _b : (params.restartOnErrorExit = false);
|
|
10932
|
-
return params;
|
|
10933
|
-
}
|
|
10934
|
-
ShellParamsUtil.normalize = normalize;
|
|
10935
|
-
})(ShellParamsUtil = exports.ShellParamsUtil || (exports.ShellParamsUtil = {}));
|
|
10936
|
-
var DEFAULT = {
|
|
10937
|
-
shell: global.process.platform === 'win32'
|
|
10938
|
-
? ['cmd.exe', '/C']
|
|
10939
|
-
: null
|
|
10940
|
-
};
|
|
10914
|
+
"use strict";
|
|
10915
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10916
|
+
exports.ShellParamsUtil = void 0;
|
|
10917
|
+
var ShellParamsUtil;
|
|
10918
|
+
(function (ShellParamsUtil) {
|
|
10919
|
+
function normalize(params) {
|
|
10920
|
+
var _a, _b;
|
|
10921
|
+
if (params.shell == null && !params.fork) {
|
|
10922
|
+
params.shell = DEFAULT.shell;
|
|
10923
|
+
}
|
|
10924
|
+
if (params.command != null) {
|
|
10925
|
+
params.commands = [params.command];
|
|
10926
|
+
}
|
|
10927
|
+
if (params.commands == null) {
|
|
10928
|
+
throw new Error("shellbee: Command(s) are not defined");
|
|
10929
|
+
}
|
|
10930
|
+
(_a = params.parallel) !== null && _a !== void 0 ? _a : (params.parallel = false);
|
|
10931
|
+
(_b = params.restartOnErrorExit) !== null && _b !== void 0 ? _b : (params.restartOnErrorExit = false);
|
|
10932
|
+
return params;
|
|
10933
|
+
}
|
|
10934
|
+
ShellParamsUtil.normalize = normalize;
|
|
10935
|
+
})(ShellParamsUtil = exports.ShellParamsUtil || (exports.ShellParamsUtil = {}));
|
|
10936
|
+
var DEFAULT = {
|
|
10937
|
+
shell: global.process.platform === 'win32'
|
|
10938
|
+
? ['cmd.exe', '/C']
|
|
10939
|
+
: null
|
|
10940
|
+
};
|
|
10941
10941
|
;
|
|
10942
10942
|
|
|
10943
10943
|
function __isObj(x) {
|
|
@@ -10965,46 +10965,46 @@ var _src_util_ShellErrorExitsHandler;
|
|
|
10965
10965
|
var exports = _src_util_ShellErrorExitsHandler != null ? _src_util_ShellErrorExitsHandler : {};
|
|
10966
10966
|
var module = { exports: exports };
|
|
10967
10967
|
|
|
10968
|
-
"use strict";
|
|
10969
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10970
|
-
exports.ShellErrorExitsHandler = void 0;
|
|
10971
|
-
var ShellErrorExitsHandler = /** @class */ (function () {
|
|
10972
|
-
function ShellErrorExitsHandler(params) {
|
|
10973
|
-
var _a, _b, _c;
|
|
10974
|
-
this._active = false;
|
|
10975
|
-
this.options = {
|
|
10976
|
-
delayMs: 200,
|
|
10977
|
-
maxRestartCount: 10,
|
|
10978
|
-
maxRestartTimespanMs: 30 * 1000,
|
|
10979
|
-
};
|
|
10980
|
-
this._params = params;
|
|
10981
|
-
this._errors = [];
|
|
10982
|
-
this._active = params.restartOnErrorExit != null && params.restartOnErrorExit !== false;
|
|
10983
|
-
if (typeof params.restartOnErrorExit !== 'boolean') {
|
|
10984
|
-
var opts = params.restartOnErrorExit;
|
|
10985
|
-
this.options.delayMs = (_a = opts.delayMs) !== null && _a !== void 0 ? _a : this.options.delayMs;
|
|
10986
|
-
this.options.maxRestartCount = (_b = opts.maxRestartCount) !== null && _b !== void 0 ? _b : this.options.maxRestartCount;
|
|
10987
|
-
this.options.maxRestartTimespanMs = (_c = opts.maxRestartTimespanMs) !== null && _c !== void 0 ? _c : this.options.maxRestartTimespanMs;
|
|
10988
|
-
}
|
|
10989
|
-
}
|
|
10990
|
-
ShellErrorExitsHandler.prototype.delay = function (cb) {
|
|
10991
|
-
this._errors.push({ time: Date.now() });
|
|
10992
|
-
setTimeout(function () { return cb(); }, this.options.delayMs);
|
|
10993
|
-
};
|
|
10994
|
-
ShellErrorExitsHandler.prototype.isActive = function () {
|
|
10995
|
-
if (this._active !== true) {
|
|
10996
|
-
return false;
|
|
10997
|
-
}
|
|
10998
|
-
var fromTimePoint = Date.now() - this.options.maxRestartTimespanMs;
|
|
10999
|
-
var errors = this._errors.filter(function (x) { return x.time > fromTimePoint; });
|
|
11000
|
-
if (errors.length < this.options.maxRestartCount) {
|
|
11001
|
-
return true;
|
|
11002
|
-
}
|
|
11003
|
-
return false;
|
|
11004
|
-
};
|
|
11005
|
-
return ShellErrorExitsHandler;
|
|
11006
|
-
}());
|
|
11007
|
-
exports.ShellErrorExitsHandler = ShellErrorExitsHandler;
|
|
10968
|
+
"use strict";
|
|
10969
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10970
|
+
exports.ShellErrorExitsHandler = void 0;
|
|
10971
|
+
var ShellErrorExitsHandler = /** @class */ (function () {
|
|
10972
|
+
function ShellErrorExitsHandler(params) {
|
|
10973
|
+
var _a, _b, _c;
|
|
10974
|
+
this._active = false;
|
|
10975
|
+
this.options = {
|
|
10976
|
+
delayMs: 200,
|
|
10977
|
+
maxRestartCount: 10,
|
|
10978
|
+
maxRestartTimespanMs: 30 * 1000,
|
|
10979
|
+
};
|
|
10980
|
+
this._params = params;
|
|
10981
|
+
this._errors = [];
|
|
10982
|
+
this._active = params.restartOnErrorExit != null && params.restartOnErrorExit !== false;
|
|
10983
|
+
if (typeof params.restartOnErrorExit !== 'boolean') {
|
|
10984
|
+
var opts = params.restartOnErrorExit;
|
|
10985
|
+
this.options.delayMs = (_a = opts.delayMs) !== null && _a !== void 0 ? _a : this.options.delayMs;
|
|
10986
|
+
this.options.maxRestartCount = (_b = opts.maxRestartCount) !== null && _b !== void 0 ? _b : this.options.maxRestartCount;
|
|
10987
|
+
this.options.maxRestartTimespanMs = (_c = opts.maxRestartTimespanMs) !== null && _c !== void 0 ? _c : this.options.maxRestartTimespanMs;
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
ShellErrorExitsHandler.prototype.delay = function (cb) {
|
|
10991
|
+
this._errors.push({ time: Date.now() });
|
|
10992
|
+
setTimeout(function () { return cb(); }, this.options.delayMs);
|
|
10993
|
+
};
|
|
10994
|
+
ShellErrorExitsHandler.prototype.isActive = function () {
|
|
10995
|
+
if (this._active !== true) {
|
|
10996
|
+
return false;
|
|
10997
|
+
}
|
|
10998
|
+
var fromTimePoint = Date.now() - this.options.maxRestartTimespanMs;
|
|
10999
|
+
var errors = this._errors.filter(function (x) { return x.time > fromTimePoint; });
|
|
11000
|
+
if (errors.length < this.options.maxRestartCount) {
|
|
11001
|
+
return true;
|
|
11002
|
+
}
|
|
11003
|
+
return false;
|
|
11004
|
+
};
|
|
11005
|
+
return ShellErrorExitsHandler;
|
|
11006
|
+
}());
|
|
11007
|
+
exports.ShellErrorExitsHandler = ShellErrorExitsHandler;
|
|
11008
11008
|
;
|
|
11009
11009
|
|
|
11010
11010
|
function __isObj(x) {
|
|
@@ -11032,119 +11032,119 @@ var _src_util_ShellStalledOutputHandler;
|
|
|
11032
11032
|
var exports = _src_util_ShellStalledOutputHandler != null ? _src_util_ShellStalledOutputHandler : {};
|
|
11033
11033
|
var module = { exports: exports };
|
|
11034
11034
|
|
|
11035
|
-
"use strict";
|
|
11036
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11037
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11038
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11039
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11040
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11041
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11042
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11043
|
-
});
|
|
11044
|
-
};
|
|
11045
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11046
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11047
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11048
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11049
|
-
function step(op) {
|
|
11050
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
11051
|
-
while (_) try {
|
|
11052
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11053
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11054
|
-
switch (op[0]) {
|
|
11055
|
-
case 0: case 1: t = op; break;
|
|
11056
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
11057
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11058
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11059
|
-
default:
|
|
11060
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11061
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11062
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11063
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11064
|
-
if (t[2]) _.ops.pop();
|
|
11065
|
-
_.trys.pop(); continue;
|
|
11066
|
-
}
|
|
11067
|
-
op = body.call(thisArg, _);
|
|
11068
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11069
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11070
|
-
}
|
|
11071
|
-
};
|
|
11072
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11073
|
-
exports.ShellStalledOutputHandler = void 0;
|
|
11074
|
-
var ShellStalledOutputHandler = /** @class */ (function () {
|
|
11075
|
-
function ShellStalledOutputHandler(params, shell) {
|
|
11076
|
-
this.params = params;
|
|
11077
|
-
this.shell = shell;
|
|
11078
|
-
}
|
|
11079
|
-
ShellStalledOutputHandler.prototype.init = function () {
|
|
11080
|
-
var _this = this;
|
|
11081
|
-
var _a;
|
|
11082
|
-
var _b = this, shell = _b.shell, params = _b.params;
|
|
11083
|
-
this._ms = (_a = params.restartOnStalledOutput) === null || _a === void 0 ? void 0 : _a.emptyOutputInterval;
|
|
11084
|
-
if (typeof this._ms !== 'number' || this._ms === 0) {
|
|
11085
|
-
return;
|
|
11086
|
-
}
|
|
11087
|
-
shell
|
|
11088
|
-
.on('process_start', function (data) { return _this.onProcessStarted(data); })
|
|
11089
|
-
.on('process_exit', function (data) { return _this.onProcessExit(data); })
|
|
11090
|
-
.on('process_stderr', function (data) { return _this.onProcessStd('stderr', data); })
|
|
11091
|
-
.on('process_stdout', function (data) { return _this.onProcessStd('stdout', data); });
|
|
11092
|
-
};
|
|
11093
|
-
ShellStalledOutputHandler.prototype.onProcessStarted = function (data) {
|
|
11094
|
-
this._lastOutput = Date.now();
|
|
11095
|
-
this.stop();
|
|
11096
|
-
this.defer(this._ms);
|
|
11097
|
-
};
|
|
11098
|
-
ShellStalledOutputHandler.prototype.onProcessExit = function (data) {
|
|
11099
|
-
this.stop();
|
|
11100
|
-
};
|
|
11101
|
-
ShellStalledOutputHandler.prototype.onProcessStd = function (output, data) {
|
|
11102
|
-
this._lastOutput = Date.now();
|
|
11103
|
-
};
|
|
11104
|
-
ShellStalledOutputHandler.prototype.stop = function () {
|
|
11105
|
-
clearTimeout(this._timeout);
|
|
11106
|
-
};
|
|
11107
|
-
ShellStalledOutputHandler.prototype.defer = function (ms) {
|
|
11108
|
-
var _this = this;
|
|
11109
|
-
this._timeout = setTimeout(function () { return _this.onTimer(); }, ms);
|
|
11110
|
-
};
|
|
11111
|
-
ShellStalledOutputHandler.prototype.onTimer = function () {
|
|
11112
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11113
|
-
var ms;
|
|
11114
|
-
return __generator(this, function (_a) {
|
|
11115
|
-
switch (_a.label) {
|
|
11116
|
-
case 0:
|
|
11117
|
-
ms = Date.now() - this._lastOutput;
|
|
11118
|
-
if (!(ms >= this._ms)) return [3 /*break*/, 2];
|
|
11119
|
-
return [4 /*yield*/, this.restart()];
|
|
11120
|
-
case 1:
|
|
11121
|
-
_a.sent();
|
|
11122
|
-
return [2 /*return*/];
|
|
11123
|
-
case 2:
|
|
11124
|
-
// otherwise check again after (TIMEOUT_MS - LAST_OUTPUT_MS)
|
|
11125
|
-
this.defer(this._ms - ms);
|
|
11126
|
-
return [2 /*return*/];
|
|
11127
|
-
}
|
|
11128
|
-
});
|
|
11129
|
-
});
|
|
11130
|
-
};
|
|
11131
|
-
ShellStalledOutputHandler.prototype.restart = function () {
|
|
11132
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11133
|
-
return __generator(this, function (_a) {
|
|
11134
|
-
switch (_a.label) {
|
|
11135
|
-
case 0:
|
|
11136
|
-
console.log("Restarting the process, as there was not output for ".concat(this._ms, "ms"));
|
|
11137
|
-
return [4 /*yield*/, this.shell.restart()];
|
|
11138
|
-
case 1:
|
|
11139
|
-
_a.sent();
|
|
11140
|
-
return [2 /*return*/];
|
|
11141
|
-
}
|
|
11142
|
-
});
|
|
11143
|
-
});
|
|
11144
|
-
};
|
|
11145
|
-
return ShellStalledOutputHandler;
|
|
11146
|
-
}());
|
|
11147
|
-
exports.ShellStalledOutputHandler = ShellStalledOutputHandler;
|
|
11035
|
+
"use strict";
|
|
11036
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11037
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11038
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11039
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11040
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11041
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11042
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11043
|
+
});
|
|
11044
|
+
};
|
|
11045
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11046
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11047
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11048
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11049
|
+
function step(op) {
|
|
11050
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11051
|
+
while (_) try {
|
|
11052
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11053
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11054
|
+
switch (op[0]) {
|
|
11055
|
+
case 0: case 1: t = op; break;
|
|
11056
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11057
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11058
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11059
|
+
default:
|
|
11060
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11061
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11062
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11063
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11064
|
+
if (t[2]) _.ops.pop();
|
|
11065
|
+
_.trys.pop(); continue;
|
|
11066
|
+
}
|
|
11067
|
+
op = body.call(thisArg, _);
|
|
11068
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11069
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11070
|
+
}
|
|
11071
|
+
};
|
|
11072
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11073
|
+
exports.ShellStalledOutputHandler = void 0;
|
|
11074
|
+
var ShellStalledOutputHandler = /** @class */ (function () {
|
|
11075
|
+
function ShellStalledOutputHandler(params, shell) {
|
|
11076
|
+
this.params = params;
|
|
11077
|
+
this.shell = shell;
|
|
11078
|
+
}
|
|
11079
|
+
ShellStalledOutputHandler.prototype.init = function () {
|
|
11080
|
+
var _this = this;
|
|
11081
|
+
var _a;
|
|
11082
|
+
var _b = this, shell = _b.shell, params = _b.params;
|
|
11083
|
+
this._ms = (_a = params.restartOnStalledOutput) === null || _a === void 0 ? void 0 : _a.emptyOutputInterval;
|
|
11084
|
+
if (typeof this._ms !== 'number' || this._ms === 0) {
|
|
11085
|
+
return;
|
|
11086
|
+
}
|
|
11087
|
+
shell
|
|
11088
|
+
.on('process_start', function (data) { return _this.onProcessStarted(data); })
|
|
11089
|
+
.on('process_exit', function (data) { return _this.onProcessExit(data); })
|
|
11090
|
+
.on('process_stderr', function (data) { return _this.onProcessStd('stderr', data); })
|
|
11091
|
+
.on('process_stdout', function (data) { return _this.onProcessStd('stdout', data); });
|
|
11092
|
+
};
|
|
11093
|
+
ShellStalledOutputHandler.prototype.onProcessStarted = function (data) {
|
|
11094
|
+
this._lastOutput = Date.now();
|
|
11095
|
+
this.stop();
|
|
11096
|
+
this.defer(this._ms);
|
|
11097
|
+
};
|
|
11098
|
+
ShellStalledOutputHandler.prototype.onProcessExit = function (data) {
|
|
11099
|
+
this.stop();
|
|
11100
|
+
};
|
|
11101
|
+
ShellStalledOutputHandler.prototype.onProcessStd = function (output, data) {
|
|
11102
|
+
this._lastOutput = Date.now();
|
|
11103
|
+
};
|
|
11104
|
+
ShellStalledOutputHandler.prototype.stop = function () {
|
|
11105
|
+
clearTimeout(this._timeout);
|
|
11106
|
+
};
|
|
11107
|
+
ShellStalledOutputHandler.prototype.defer = function (ms) {
|
|
11108
|
+
var _this = this;
|
|
11109
|
+
this._timeout = setTimeout(function () { return _this.onTimer(); }, ms);
|
|
11110
|
+
};
|
|
11111
|
+
ShellStalledOutputHandler.prototype.onTimer = function () {
|
|
11112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11113
|
+
var ms;
|
|
11114
|
+
return __generator(this, function (_a) {
|
|
11115
|
+
switch (_a.label) {
|
|
11116
|
+
case 0:
|
|
11117
|
+
ms = Date.now() - this._lastOutput;
|
|
11118
|
+
if (!(ms >= this._ms)) return [3 /*break*/, 2];
|
|
11119
|
+
return [4 /*yield*/, this.restart()];
|
|
11120
|
+
case 1:
|
|
11121
|
+
_a.sent();
|
|
11122
|
+
return [2 /*return*/];
|
|
11123
|
+
case 2:
|
|
11124
|
+
// otherwise check again after (TIMEOUT_MS - LAST_OUTPUT_MS)
|
|
11125
|
+
this.defer(this._ms - ms);
|
|
11126
|
+
return [2 /*return*/];
|
|
11127
|
+
}
|
|
11128
|
+
});
|
|
11129
|
+
});
|
|
11130
|
+
};
|
|
11131
|
+
ShellStalledOutputHandler.prototype.restart = function () {
|
|
11132
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11133
|
+
return __generator(this, function (_a) {
|
|
11134
|
+
switch (_a.label) {
|
|
11135
|
+
case 0:
|
|
11136
|
+
console.log("Restarting the process, as there was not output for ".concat(this._ms, "ms"));
|
|
11137
|
+
return [4 /*yield*/, this.shell.restart()];
|
|
11138
|
+
case 1:
|
|
11139
|
+
_a.sent();
|
|
11140
|
+
return [2 /*return*/];
|
|
11141
|
+
}
|
|
11142
|
+
});
|
|
11143
|
+
});
|
|
11144
|
+
};
|
|
11145
|
+
return ShellStalledOutputHandler;
|
|
11146
|
+
}());
|
|
11147
|
+
exports.ShellStalledOutputHandler = ShellStalledOutputHandler;
|
|
11148
11148
|
;
|
|
11149
11149
|
|
|
11150
11150
|
function __isObj(x) {
|
|
@@ -11172,563 +11172,563 @@ var _src_Shell;
|
|
|
11172
11172
|
var exports = _src_Shell != null ? _src_Shell : {};
|
|
11173
11173
|
var module = { exports: exports };
|
|
11174
11174
|
|
|
11175
|
-
"use strict";
|
|
11176
|
-
var __extends = (this && this.__extends) || (function () {
|
|
11177
|
-
var extendStatics = function (d, b) {
|
|
11178
|
-
extendStatics = Object.setPrototypeOf ||
|
|
11179
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11180
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11181
|
-
return extendStatics(d, b);
|
|
11182
|
-
};
|
|
11183
|
-
return function (d, b) {
|
|
11184
|
-
if (typeof b !== "function" && b !== null)
|
|
11185
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11186
|
-
extendStatics(d, b);
|
|
11187
|
-
function __() { this.constructor = d; }
|
|
11188
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
11189
|
-
};
|
|
11190
|
-
})();
|
|
11191
|
-
var __assign = (this && this.__assign) || function () {
|
|
11192
|
-
__assign = Object.assign || function(t) {
|
|
11193
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11194
|
-
s = arguments[i];
|
|
11195
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11196
|
-
t[p] = s[p];
|
|
11197
|
-
}
|
|
11198
|
-
return t;
|
|
11199
|
-
};
|
|
11200
|
-
return __assign.apply(this, arguments);
|
|
11201
|
-
};
|
|
11202
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11203
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11204
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11205
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11206
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11207
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11208
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11209
|
-
});
|
|
11210
|
-
};
|
|
11211
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11212
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11213
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11214
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11215
|
-
function step(op) {
|
|
11216
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
11217
|
-
while (_) try {
|
|
11218
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11219
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11220
|
-
switch (op[0]) {
|
|
11221
|
-
case 0: case 1: t = op; break;
|
|
11222
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
11223
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11224
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11225
|
-
default:
|
|
11226
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11227
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11228
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11229
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11230
|
-
if (t[2]) _.ops.pop();
|
|
11231
|
-
_.trys.pop(); continue;
|
|
11232
|
-
}
|
|
11233
|
-
op = body.call(thisArg, _);
|
|
11234
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11235
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11236
|
-
}
|
|
11237
|
-
};
|
|
11238
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
11239
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11240
|
-
if (ar || !(i in from)) {
|
|
11241
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11242
|
-
ar[i] = from[i];
|
|
11243
|
-
}
|
|
11244
|
-
}
|
|
11245
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11246
|
-
};
|
|
11247
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11248
|
-
exports.ProcessResult = exports.Shell = void 0;
|
|
11249
|
-
var atma_utils_1 = require("atma-utils");
|
|
11250
|
-
var atma_io_1 = require("atma-io");
|
|
11251
|
-
var child_process = require("child_process");
|
|
11252
|
-
var command_1 = _src_util_command;
|
|
11253
|
-
var ValueExtractor_1 = _src_ValueExtractor;
|
|
11254
|
-
var CommunicationChannel_1 = _src_CommunicationChannel;
|
|
11255
|
-
var events_1 = _src_util_events;
|
|
11256
|
-
var treeKill = require("tree-kill");
|
|
11257
|
-
var ShellParamsUtil_1 = _src_util_ShellParamsUtil;
|
|
11258
|
-
var ShellErrorExitsHandler_1 = _src_util_ShellErrorExitsHandler;
|
|
11259
|
-
var ShellStalledOutputHandler_1 = _src_util_ShellStalledOutputHandler;
|
|
11260
|
-
var Shell = /** @class */ (function (_super) {
|
|
11261
|
-
__extends(Shell, _super);
|
|
11262
|
-
function Shell(params) {
|
|
11263
|
-
var _this = _super.call(this) || this;
|
|
11264
|
-
_this.children = [];
|
|
11265
|
-
_this.errors = [];
|
|
11266
|
-
_this.lastCode = 0;
|
|
11267
|
-
_this.results = [];
|
|
11268
|
-
_this.extracted = {};
|
|
11269
|
-
_this.state = ShellState.Initial;
|
|
11270
|
-
_this.promise = new atma_utils_1.class_Dfr();
|
|
11271
|
-
_this.std = [];
|
|
11272
|
-
_this.stderr = [];
|
|
11273
|
-
_this.stdout = [];
|
|
11274
|
-
_this.isBusy = false;
|
|
11275
|
-
_this.isReady = false;
|
|
11276
|
-
_this.params = ShellParamsUtil_1.ShellParamsUtil.normalize(params);
|
|
11277
|
-
_this.errorsHandler = new ShellErrorExitsHandler_1.ShellErrorExitsHandler(_this.params);
|
|
11278
|
-
_this.stalledOutputHandler = new ShellStalledOutputHandler_1.ShellStalledOutputHandler(_this.params, _this);
|
|
11279
|
-
_this.stalledOutputHandler.init();
|
|
11280
|
-
_this.commands = (0, command_1.command_parseAll)(params.commands, params);
|
|
11281
|
-
_this.commandsQueue = _this.commands.slice();
|
|
11282
|
-
_this.on('process_start', function () {
|
|
11283
|
-
_this.state = ShellState.Started;
|
|
11284
|
-
});
|
|
11285
|
-
return _this;
|
|
11286
|
-
}
|
|
11287
|
-
Shell.run = function (mix) {
|
|
11288
|
-
var params;
|
|
11289
|
-
if (typeof mix === 'string') {
|
|
11290
|
-
params = { command: mix };
|
|
11291
|
-
}
|
|
11292
|
-
else if (Array.isArray(mix)) {
|
|
11293
|
-
params = { commands: mix };
|
|
11294
|
-
}
|
|
11295
|
-
else {
|
|
11296
|
-
params = mix;
|
|
11297
|
-
}
|
|
11298
|
-
return new Shell(params).run();
|
|
11299
|
-
};
|
|
11300
|
-
/**
|
|
11301
|
-
* "Run" starts the command
|
|
11302
|
-
* @returns Promise, which is resolved after the executables are completed.
|
|
11303
|
-
*/
|
|
11304
|
-
Shell.prototype.run = function () {
|
|
11305
|
-
if (this.isBusy === false) {
|
|
11306
|
-
this.next();
|
|
11307
|
-
return this.promise;
|
|
11308
|
-
}
|
|
11309
|
-
return this.promise;
|
|
11310
|
-
};
|
|
11311
|
-
Shell.factory = function (config) {
|
|
11312
|
-
return {
|
|
11313
|
-
run: function (mix) {
|
|
11314
|
-
var params;
|
|
11315
|
-
if (typeof mix === 'string') {
|
|
11316
|
-
params = { command: mix };
|
|
11317
|
-
}
|
|
11318
|
-
else if (Array.isArray(mix)) {
|
|
11319
|
-
params = { commands: mix };
|
|
11320
|
-
}
|
|
11321
|
-
else {
|
|
11322
|
-
params = mix;
|
|
11323
|
-
}
|
|
11324
|
-
return Shell.run(__assign(__assign({}, config), params));
|
|
11325
|
-
}
|
|
11326
|
-
};
|
|
11327
|
-
};
|
|
11328
|
-
Shell.prototype.onStart = function (cb) {
|
|
11329
|
-
return this.on('process_start', cb);
|
|
11330
|
-
};
|
|
11331
|
-
Shell.prototype.onStdout = function (cb) {
|
|
11332
|
-
return this.on('process_stdout', cb);
|
|
11333
|
-
};
|
|
11334
|
-
Shell.prototype.onStderr = function (cb) {
|
|
11335
|
-
return this.on('process_stderr', cb);
|
|
11336
|
-
};
|
|
11337
|
-
Shell.prototype.onExit = function (cb) {
|
|
11338
|
-
return this.on('process_exit', cb);
|
|
11339
|
-
};
|
|
11340
|
-
/** When rgxReady is specified the event will be called */
|
|
11341
|
-
Shell.prototype.onReady = function (cb) {
|
|
11342
|
-
var _a, _b, _c, _d, _e, _f;
|
|
11343
|
-
var isAlreadyCompleted = this.isBusy === false && this.lastCode != null;
|
|
11344
|
-
var isReady = this.isReady;
|
|
11345
|
-
if (isReady || isAlreadyCompleted) {
|
|
11346
|
-
cb({ command: (_a = this.currentOptions) === null || _a === void 0 ? void 0 : _a.command });
|
|
11347
|
-
return;
|
|
11348
|
-
}
|
|
11349
|
-
if (!((_b = this.currentOptions) === null || _b === void 0 ? void 0 : _b.matchReady) && this.commandsQueue.some(function (x) { return x.matchReady; }) === false) {
|
|
11350
|
-
console.error('Ready Matcher Regex is not defined', (_d = (_c = this.currentOptions) === null || _c === void 0 ? void 0 : _c.command) !== null && _d !== void 0 ? _d : (_f = (_e = this.commands) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.command);
|
|
11351
|
-
}
|
|
11352
|
-
return this.on('process_ready', cb);
|
|
11353
|
-
};
|
|
11354
|
-
Shell.prototype.onReadyAsync = function () {
|
|
11355
|
-
var _this = this;
|
|
11356
|
-
return new Promise(function (resolve) {
|
|
11357
|
-
_this.onReady(resolve);
|
|
11358
|
-
});
|
|
11359
|
-
};
|
|
11360
|
-
Shell.prototype.onComplete = function (cb) {
|
|
11361
|
-
var _this = this;
|
|
11362
|
-
this.promise.always(function () { return cb(_this); });
|
|
11363
|
-
return this;
|
|
11364
|
-
};
|
|
11365
|
-
Shell.prototype.onCompleteAsync = function () {
|
|
11366
|
-
var _this = this;
|
|
11367
|
-
return new Promise(function (resolve) {
|
|
11368
|
-
_this.onComplete(resolve);
|
|
11369
|
-
});
|
|
11370
|
-
};
|
|
11371
|
-
Shell.prototype.kill = function (mix) {
|
|
11372
|
-
var _this = this;
|
|
11373
|
-
var _a, _b, _c;
|
|
11374
|
-
var signal = 'SIGINT';
|
|
11375
|
-
var commandIdx = 0;
|
|
11376
|
-
var terminateAfterMs = null;
|
|
11377
|
-
if (mix != null) {
|
|
11378
|
-
signal = (_a = (typeof mix === 'object' ? mix.signal : mix)) !== null && _a !== void 0 ? _a : signal;
|
|
11379
|
-
if (typeof mix === 'object') {
|
|
11380
|
-
commandIdx = (_b = mix.commandIdx) !== null && _b !== void 0 ? _b : commandIdx;
|
|
11381
|
-
terminateAfterMs = (_c = mix.terminateAfter) !== null && _c !== void 0 ? _c : terminateAfterMs;
|
|
11382
|
-
}
|
|
11383
|
-
}
|
|
11384
|
-
return new Promise(function (resolve) {
|
|
11385
|
-
var isCompleted = _this.isBusy === false && _this.lastCode != null;
|
|
11386
|
-
if (isCompleted) {
|
|
11387
|
-
return resolve(null);
|
|
11388
|
-
}
|
|
11389
|
-
var options = _this.commands[commandIdx];
|
|
11390
|
-
var child = _this.children.find(function (x) { return x.options === options; });
|
|
11391
|
-
if (child == null) {
|
|
11392
|
-
return resolve(null);
|
|
11393
|
-
}
|
|
11394
|
-
var i = _this.children.indexOf(child);
|
|
11395
|
-
_this.children.splice(i, 1);
|
|
11396
|
-
var timeout;
|
|
11397
|
-
child.process.kill(signal);
|
|
11398
|
-
_this.once('process_exit', function () {
|
|
11399
|
-
if (timeout != null) {
|
|
11400
|
-
clearTimeout(timeout);
|
|
11401
|
-
}
|
|
11402
|
-
resolve(null);
|
|
11403
|
-
});
|
|
11404
|
-
if (terminateAfterMs != null) {
|
|
11405
|
-
timeout = setTimeout(function () {
|
|
11406
|
-
treeKill(child.process.pid);
|
|
11407
|
-
}, terminateAfterMs);
|
|
11408
|
-
}
|
|
11409
|
-
});
|
|
11410
|
-
};
|
|
11411
|
-
/** Uses tree-kill to terminate the tree */
|
|
11412
|
-
Shell.prototype.terminate = function () {
|
|
11413
|
-
var _this = this;
|
|
11414
|
-
return new Promise(function (resolve) {
|
|
11415
|
-
var child = _this.children.pop();
|
|
11416
|
-
if (child == null) {
|
|
11417
|
-
return resolve(null);
|
|
11418
|
-
}
|
|
11419
|
-
_this.once('process_exit', resolve);
|
|
11420
|
-
treeKill(child.process.pid);
|
|
11421
|
-
});
|
|
11422
|
-
};
|
|
11423
|
-
Shell.prototype.send = function (method) {
|
|
11424
|
-
var _this = this;
|
|
11425
|
-
var args = [];
|
|
11426
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
11427
|
-
args[_i - 1] = arguments[_i];
|
|
11428
|
-
}
|
|
11429
|
-
return new Promise(function (resolve, reject) {
|
|
11430
|
-
_this.waitForChannel().then(function (channel) {
|
|
11431
|
-
channel.call.apply(channel, __spreadArray([method], args, false)).then(resolve, reject);
|
|
11432
|
-
}, reject);
|
|
11433
|
-
});
|
|
11434
|
-
};
|
|
11435
|
-
Shell.prototype.restart = function (mix) {
|
|
11436
|
-
if (mix === void 0) { mix = 0; }
|
|
11437
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11438
|
-
var options;
|
|
11439
|
-
return __generator(this, function (_a) {
|
|
11440
|
-
switch (_a.label) {
|
|
11441
|
-
case 0:
|
|
11442
|
-
if (typeof mix === 'number') {
|
|
11443
|
-
options = this.commands[mix];
|
|
11444
|
-
}
|
|
11445
|
-
else {
|
|
11446
|
-
options = this.commands.find(function (x) { return x.command === mix; });
|
|
11447
|
-
}
|
|
11448
|
-
if (options == null) {
|
|
11449
|
-
throw new Error("Options undefined for ".concat(mix));
|
|
11450
|
-
}
|
|
11451
|
-
this.commandsQueue.push(options);
|
|
11452
|
-
if (this.isBusy === false) {
|
|
11453
|
-
this.next();
|
|
11454
|
-
return [2 /*return*/];
|
|
11455
|
-
}
|
|
11456
|
-
// `next` will be called indirect (after the process exits)
|
|
11457
|
-
return [4 /*yield*/, this.kill({ terminateAfter: 10000 })];
|
|
11458
|
-
case 1:
|
|
11459
|
-
// `next` will be called indirect (after the process exits)
|
|
11460
|
-
_a.sent();
|
|
11461
|
-
return [2 /*return*/];
|
|
11462
|
-
}
|
|
11463
|
-
});
|
|
11464
|
-
});
|
|
11465
|
-
};
|
|
11466
|
-
Shell.prototype.waitForChannel = function () {
|
|
11467
|
-
var _this = this;
|
|
11468
|
-
if (this.currentOptions.ipc && this.isReady === false) {
|
|
11469
|
-
return new Promise(function (resolve, reject) {
|
|
11470
|
-
(0, events_1.events_someOnce)(_this, {
|
|
11471
|
-
'process_ready': function () {
|
|
11472
|
-
_this.waitForChannel().then(resolve, reject);
|
|
11473
|
-
},
|
|
11474
|
-
'exit': function () {
|
|
11475
|
-
reject('Process exited');
|
|
11476
|
-
}
|
|
11477
|
-
});
|
|
11478
|
-
});
|
|
11479
|
-
}
|
|
11480
|
-
return new Promise(function (resolve, reject) {
|
|
11481
|
-
if (_this.channel) {
|
|
11482
|
-
resolve(_this.channel);
|
|
11483
|
-
return;
|
|
11484
|
-
}
|
|
11485
|
-
(0, events_1.events_someOnce)(_this, {
|
|
11486
|
-
'channel_created': function () {
|
|
11487
|
-
resolve(_this.channel);
|
|
11488
|
-
},
|
|
11489
|
-
'exit': function () {
|
|
11490
|
-
reject('Process exited');
|
|
11491
|
-
}
|
|
11492
|
-
});
|
|
11493
|
-
});
|
|
11494
|
-
};
|
|
11495
|
-
Shell.prototype.next = function () {
|
|
11496
|
-
var _this = this;
|
|
11497
|
-
var _a;
|
|
11498
|
-
if (this.isBusy === false) {
|
|
11499
|
-
this.start = new Date();
|
|
11500
|
-
this.isBusy = true;
|
|
11501
|
-
this.isReady = false;
|
|
11502
|
-
}
|
|
11503
|
-
if (this.channel) {
|
|
11504
|
-
this.emit('channel_closed', {
|
|
11505
|
-
channel: this.channel
|
|
11506
|
-
});
|
|
11507
|
-
if (this.commandsQueue.length !== 0 || (this.lastCode === 1 && this.errorsHandler.isActive())) {
|
|
11508
|
-
this.channel = null;
|
|
11509
|
-
}
|
|
11510
|
-
}
|
|
11511
|
-
if (this.lastCode === 1 && this.errorsHandler.isActive()) {
|
|
11512
|
-
this.lastCode = 0;
|
|
11513
|
-
this.commandsQueue.push(this.currentOptions);
|
|
11514
|
-
this.errorsHandler.delay(function () {
|
|
11515
|
-
_this.next();
|
|
11516
|
-
});
|
|
11517
|
-
return this.promise;
|
|
11518
|
-
}
|
|
11519
|
-
if (this.commandsQueue.length === 0) {
|
|
11520
|
-
if (this.state !== ShellState.Empty) {
|
|
11521
|
-
this.state = ShellState.Empty;
|
|
11522
|
-
this.end = new Date();
|
|
11523
|
-
this.isBusy = false;
|
|
11524
|
-
var promise = this.promise;
|
|
11525
|
-
// Always resolve the promise, consumer should check for errors
|
|
11526
|
-
promise.resolve(this);
|
|
11527
|
-
}
|
|
11528
|
-
return this.promise;
|
|
11529
|
-
}
|
|
11530
|
-
var child = null;
|
|
11531
|
-
var options = this.commandsQueue.shift();
|
|
11532
|
-
var command = ValueExtractor_1.ValueExtractor.interpolateAny(options.command, this.extracted);
|
|
11533
|
-
var rgxReady = options.matchReady;
|
|
11534
|
-
var detached = options.detached === true;
|
|
11535
|
-
var silent = this.params.silent;
|
|
11536
|
-
var stdio = detached ? (void 0) : 'pipe';
|
|
11537
|
-
var extractor = options.extract ? new ValueExtractor_1.ValueExtractor(this.extracted, options.extract) : null;
|
|
11538
|
-
var result = new ProcessResult(options);
|
|
11539
|
-
this.results.push(result);
|
|
11540
|
-
this.currentOptions = options;
|
|
11541
|
-
if (!options.fork && global.process.platform === 'win32') {
|
|
11542
|
-
if (options.exec !== 'cmd') {
|
|
11543
|
-
options.args.unshift('/C', options.exec);
|
|
11544
|
-
options.exec = 'cmd';
|
|
11545
|
-
}
|
|
11546
|
-
}
|
|
11547
|
-
if (rgxReady == null && options.ipc) {
|
|
11548
|
-
rgxReady = /IPC Listening/i;
|
|
11549
|
-
}
|
|
11550
|
-
this.isReady = rgxReady == null;
|
|
11551
|
-
try {
|
|
11552
|
-
var cwd = options.cwd;
|
|
11553
|
-
if (cwd != null) {
|
|
11554
|
-
var hasFileProtocol = cwd.startsWith('file:');
|
|
11555
|
-
var cwdUri = hasFileProtocol ? cwd : 'file://' + cwd;
|
|
11556
|
-
if (atma_io_1.Directory.exists(cwdUri + '/') === false) {
|
|
11557
|
-
throw Error('CWD Directory not exists: ' + cwd);
|
|
11558
|
-
}
|
|
11559
|
-
if (hasFileProtocol) {
|
|
11560
|
-
cwd = new atma_utils_1.class_Uri(cwd).toLocalDir();
|
|
11561
|
-
}
|
|
11562
|
-
}
|
|
11563
|
-
if (cwd == null) {
|
|
11564
|
-
cwd = process.cwd();
|
|
11565
|
-
}
|
|
11566
|
-
var exec = ValueExtractor_1.ValueExtractor.interpolateAny(options.exec, this.extracted, options);
|
|
11567
|
-
var args = ValueExtractor_1.ValueExtractor.interpolateAny(options.args, this.extracted, options);
|
|
11568
|
-
var method = options.fork ? 'fork' : 'spawn';
|
|
11569
|
-
if (this.params.verbose) {
|
|
11570
|
-
this.print("".concat(method, ": ").concat(exec, " ").concat(args.join('')));
|
|
11571
|
-
}
|
|
11572
|
-
child = options.fork
|
|
11573
|
-
? child_process.fork(exec, args, {
|
|
11574
|
-
cwd: options.cwd || process.cwd(),
|
|
11575
|
-
env: process.env,
|
|
11576
|
-
stdio: stdio,
|
|
11577
|
-
detached: detached
|
|
11578
|
-
})
|
|
11579
|
-
: child_process.spawn(exec, args, {
|
|
11580
|
-
cwd: options.cwd || process.cwd(),
|
|
11581
|
-
env: process.env,
|
|
11582
|
-
stdio: stdio,
|
|
11583
|
-
detached: detached
|
|
11584
|
-
});
|
|
11585
|
-
if (options.fork) {
|
|
11586
|
-
this.channel = new CommunicationChannel_1.CommunicationChannel(child, (_a = this.params.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
|
|
11587
|
-
this.emit('channel_created', {
|
|
11588
|
-
channel: this.channel
|
|
11589
|
-
});
|
|
11590
|
-
}
|
|
11591
|
-
result.pid = child.pid;
|
|
11592
|
-
this.children.push({
|
|
11593
|
-
process: child,
|
|
11594
|
-
options: options,
|
|
11595
|
-
});
|
|
11596
|
-
}
|
|
11597
|
-
catch (error) {
|
|
11598
|
-
if (this.params.verbose) {
|
|
11599
|
-
this.print('on start exception:', error);
|
|
11600
|
-
}
|
|
11601
|
-
result.error = error;
|
|
11602
|
-
this.errors.push({
|
|
11603
|
-
command: command,
|
|
11604
|
-
error: error
|
|
11605
|
-
});
|
|
11606
|
-
this.emit('process_exception', {
|
|
11607
|
-
command: command,
|
|
11608
|
-
error: error
|
|
11609
|
-
});
|
|
11610
|
-
return this.next();
|
|
11611
|
-
}
|
|
11612
|
-
child.on('error', function (error) {
|
|
11613
|
-
var _a;
|
|
11614
|
-
if (_this.params.verbose) {
|
|
11615
|
-
_this.print('on error:', error);
|
|
11616
|
-
}
|
|
11617
|
-
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(error);
|
|
11618
|
-
});
|
|
11619
|
-
child.on('exit', function (code) {
|
|
11620
|
-
var _a;
|
|
11621
|
-
if (_this.params.verbose) {
|
|
11622
|
-
_this.print('on exit:', code);
|
|
11623
|
-
}
|
|
11624
|
-
result.resultCode = code !== null && code !== void 0 ? code : 0;
|
|
11625
|
-
_this.emit('process_exit', {
|
|
11626
|
-
command: command,
|
|
11627
|
-
code: code,
|
|
11628
|
-
result: result
|
|
11629
|
-
});
|
|
11630
|
-
_this.isBusy = false;
|
|
11631
|
-
_this.isReady = false;
|
|
11632
|
-
_this.lastCode = code;
|
|
11633
|
-
if (code > 0) {
|
|
11634
|
-
var msg = result.stderr.slice(-20).join('');
|
|
11635
|
-
var err = new Error("Exit code: ".concat(code, ". ").concat(msg !== null && msg !== void 0 ? msg : ''));
|
|
11636
|
-
_this.errors.push({
|
|
11637
|
-
command: command,
|
|
11638
|
-
error: err
|
|
11639
|
-
});
|
|
11640
|
-
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(err);
|
|
11641
|
-
}
|
|
11642
|
-
extractor === null || extractor === void 0 ? void 0 : extractor.complete();
|
|
11643
|
-
_this.next();
|
|
11644
|
-
});
|
|
11645
|
-
child.stdout.on('data', function (buffer) {
|
|
11646
|
-
if (detached !== true && silent !== true) {
|
|
11647
|
-
process.stdout.write(buffer);
|
|
11648
|
-
}
|
|
11649
|
-
if (rgxReady != null && rgxReady.test(buffer.toString())) {
|
|
11650
|
-
rgxReady = null;
|
|
11651
|
-
_this.isReady = true;
|
|
11652
|
-
_this.emit('process_ready', {
|
|
11653
|
-
command: command
|
|
11654
|
-
});
|
|
11655
|
-
}
|
|
11656
|
-
if (extractor != null) {
|
|
11657
|
-
extractor.write(buffer);
|
|
11658
|
-
}
|
|
11659
|
-
var str = String(buffer);
|
|
11660
|
-
result.stdout.push(str);
|
|
11661
|
-
result.std.push(str);
|
|
11662
|
-
_this.stdout.push(str);
|
|
11663
|
-
_this.std.push(str);
|
|
11664
|
-
_this.emit('process_stdout', {
|
|
11665
|
-
command: command,
|
|
11666
|
-
buffer: buffer
|
|
11667
|
-
});
|
|
11668
|
-
});
|
|
11669
|
-
child.stderr.on('data', function (buffer) {
|
|
11670
|
-
var _a;
|
|
11671
|
-
if (detached !== true && silent !== true) {
|
|
11672
|
-
process.stderr.write(buffer);
|
|
11673
|
-
}
|
|
11674
|
-
var str = String(buffer);
|
|
11675
|
-
result.stderr.push(str);
|
|
11676
|
-
result.std.push(str);
|
|
11677
|
-
_this.stderr.push(str);
|
|
11678
|
-
_this.std.push(str);
|
|
11679
|
-
_this.emit('process_stderr', {
|
|
11680
|
-
command: command,
|
|
11681
|
-
buffer: buffer
|
|
11682
|
-
});
|
|
11683
|
-
if (str.includes('UnhandledPromiseRejectionWarning')) {
|
|
11684
|
-
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onStdError(str);
|
|
11685
|
-
}
|
|
11686
|
-
});
|
|
11687
|
-
this.emit('process_start', {
|
|
11688
|
-
command: command
|
|
11689
|
-
});
|
|
11690
|
-
if (this.params.parallel !== false) {
|
|
11691
|
-
this.next();
|
|
11692
|
-
}
|
|
11693
|
-
if (rgxReady == null) {
|
|
11694
|
-
setTimeout(function () {
|
|
11695
|
-
_this.emit('process_ready', {
|
|
11696
|
-
command: command
|
|
11697
|
-
});
|
|
11698
|
-
}, 200);
|
|
11699
|
-
}
|
|
11700
|
-
return this.promise;
|
|
11701
|
-
};
|
|
11702
|
-
Shell.prototype.print = function () {
|
|
11703
|
-
var args = [];
|
|
11704
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11705
|
-
args[_i] = arguments[_i];
|
|
11706
|
-
}
|
|
11707
|
-
console.log('Shellbee: ' + args.join(' '));
|
|
11708
|
-
};
|
|
11709
|
-
Shell.ipc = CommunicationChannel_1.CommunicationChannel.ipc;
|
|
11710
|
-
return Shell;
|
|
11711
|
-
}(atma_utils_1.class_EventEmitter));
|
|
11712
|
-
exports.Shell = Shell;
|
|
11713
|
-
;
|
|
11714
|
-
var ProcessResult = /** @class */ (function () {
|
|
11715
|
-
function ProcessResult(options) {
|
|
11716
|
-
this.options = options;
|
|
11717
|
-
this.std = [];
|
|
11718
|
-
this.stdout = [];
|
|
11719
|
-
this.stderr = [];
|
|
11720
|
-
this.resultCode = null;
|
|
11721
|
-
this.error = null;
|
|
11722
|
-
}
|
|
11723
|
-
return ProcessResult;
|
|
11724
|
-
}());
|
|
11725
|
-
exports.ProcessResult = ProcessResult;
|
|
11726
|
-
var ShellState;
|
|
11727
|
-
(function (ShellState) {
|
|
11728
|
-
ShellState[ShellState["Empty"] = -1] = "Empty";
|
|
11729
|
-
ShellState[ShellState["Initial"] = 0] = "Initial";
|
|
11730
|
-
ShellState[ShellState["Started"] = 1] = "Started";
|
|
11731
|
-
})(ShellState || (ShellState = {}));
|
|
11175
|
+
"use strict";
|
|
11176
|
+
var __extends = (this && this.__extends) || (function () {
|
|
11177
|
+
var extendStatics = function (d, b) {
|
|
11178
|
+
extendStatics = Object.setPrototypeOf ||
|
|
11179
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
11180
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11181
|
+
return extendStatics(d, b);
|
|
11182
|
+
};
|
|
11183
|
+
return function (d, b) {
|
|
11184
|
+
if (typeof b !== "function" && b !== null)
|
|
11185
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11186
|
+
extendStatics(d, b);
|
|
11187
|
+
function __() { this.constructor = d; }
|
|
11188
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
11189
|
+
};
|
|
11190
|
+
})();
|
|
11191
|
+
var __assign = (this && this.__assign) || function () {
|
|
11192
|
+
__assign = Object.assign || function(t) {
|
|
11193
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
11194
|
+
s = arguments[i];
|
|
11195
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
11196
|
+
t[p] = s[p];
|
|
11197
|
+
}
|
|
11198
|
+
return t;
|
|
11199
|
+
};
|
|
11200
|
+
return __assign.apply(this, arguments);
|
|
11201
|
+
};
|
|
11202
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11203
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11204
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11205
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11206
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11207
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11208
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11209
|
+
});
|
|
11210
|
+
};
|
|
11211
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11212
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11213
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11214
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11215
|
+
function step(op) {
|
|
11216
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11217
|
+
while (_) try {
|
|
11218
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11219
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11220
|
+
switch (op[0]) {
|
|
11221
|
+
case 0: case 1: t = op; break;
|
|
11222
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11223
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11224
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11225
|
+
default:
|
|
11226
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11227
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11228
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11229
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11230
|
+
if (t[2]) _.ops.pop();
|
|
11231
|
+
_.trys.pop(); continue;
|
|
11232
|
+
}
|
|
11233
|
+
op = body.call(thisArg, _);
|
|
11234
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11235
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11236
|
+
}
|
|
11237
|
+
};
|
|
11238
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
11239
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
11240
|
+
if (ar || !(i in from)) {
|
|
11241
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
11242
|
+
ar[i] = from[i];
|
|
11243
|
+
}
|
|
11244
|
+
}
|
|
11245
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
11246
|
+
};
|
|
11247
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11248
|
+
exports.ProcessResult = exports.Shell = void 0;
|
|
11249
|
+
var atma_utils_1 = require("atma-utils");
|
|
11250
|
+
var atma_io_1 = require("atma-io");
|
|
11251
|
+
var child_process = require("child_process");
|
|
11252
|
+
var command_1 = _src_util_command;
|
|
11253
|
+
var ValueExtractor_1 = _src_ValueExtractor;
|
|
11254
|
+
var CommunicationChannel_1 = _src_CommunicationChannel;
|
|
11255
|
+
var events_1 = _src_util_events;
|
|
11256
|
+
var treeKill = require("tree-kill");
|
|
11257
|
+
var ShellParamsUtil_1 = _src_util_ShellParamsUtil;
|
|
11258
|
+
var ShellErrorExitsHandler_1 = _src_util_ShellErrorExitsHandler;
|
|
11259
|
+
var ShellStalledOutputHandler_1 = _src_util_ShellStalledOutputHandler;
|
|
11260
|
+
var Shell = /** @class */ (function (_super) {
|
|
11261
|
+
__extends(Shell, _super);
|
|
11262
|
+
function Shell(params) {
|
|
11263
|
+
var _this = _super.call(this) || this;
|
|
11264
|
+
_this.children = [];
|
|
11265
|
+
_this.errors = [];
|
|
11266
|
+
_this.lastCode = 0;
|
|
11267
|
+
_this.results = [];
|
|
11268
|
+
_this.extracted = {};
|
|
11269
|
+
_this.state = ShellState.Initial;
|
|
11270
|
+
_this.promise = new atma_utils_1.class_Dfr();
|
|
11271
|
+
_this.std = [];
|
|
11272
|
+
_this.stderr = [];
|
|
11273
|
+
_this.stdout = [];
|
|
11274
|
+
_this.isBusy = false;
|
|
11275
|
+
_this.isReady = false;
|
|
11276
|
+
_this.params = ShellParamsUtil_1.ShellParamsUtil.normalize(params);
|
|
11277
|
+
_this.errorsHandler = new ShellErrorExitsHandler_1.ShellErrorExitsHandler(_this.params);
|
|
11278
|
+
_this.stalledOutputHandler = new ShellStalledOutputHandler_1.ShellStalledOutputHandler(_this.params, _this);
|
|
11279
|
+
_this.stalledOutputHandler.init();
|
|
11280
|
+
_this.commands = (0, command_1.command_parseAll)(params.commands, params);
|
|
11281
|
+
_this.commandsQueue = _this.commands.slice();
|
|
11282
|
+
_this.on('process_start', function () {
|
|
11283
|
+
_this.state = ShellState.Started;
|
|
11284
|
+
});
|
|
11285
|
+
return _this;
|
|
11286
|
+
}
|
|
11287
|
+
Shell.run = function (mix) {
|
|
11288
|
+
var params;
|
|
11289
|
+
if (typeof mix === 'string') {
|
|
11290
|
+
params = { command: mix };
|
|
11291
|
+
}
|
|
11292
|
+
else if (Array.isArray(mix)) {
|
|
11293
|
+
params = { commands: mix };
|
|
11294
|
+
}
|
|
11295
|
+
else {
|
|
11296
|
+
params = mix;
|
|
11297
|
+
}
|
|
11298
|
+
return new Shell(params).run();
|
|
11299
|
+
};
|
|
11300
|
+
/**
|
|
11301
|
+
* "Run" starts the command
|
|
11302
|
+
* @returns Promise, which is resolved after the executables are completed.
|
|
11303
|
+
*/
|
|
11304
|
+
Shell.prototype.run = function () {
|
|
11305
|
+
if (this.isBusy === false) {
|
|
11306
|
+
this.next();
|
|
11307
|
+
return this.promise;
|
|
11308
|
+
}
|
|
11309
|
+
return this.promise;
|
|
11310
|
+
};
|
|
11311
|
+
Shell.factory = function (config) {
|
|
11312
|
+
return {
|
|
11313
|
+
run: function (mix) {
|
|
11314
|
+
var params;
|
|
11315
|
+
if (typeof mix === 'string') {
|
|
11316
|
+
params = { command: mix };
|
|
11317
|
+
}
|
|
11318
|
+
else if (Array.isArray(mix)) {
|
|
11319
|
+
params = { commands: mix };
|
|
11320
|
+
}
|
|
11321
|
+
else {
|
|
11322
|
+
params = mix;
|
|
11323
|
+
}
|
|
11324
|
+
return Shell.run(__assign(__assign({}, config), params));
|
|
11325
|
+
}
|
|
11326
|
+
};
|
|
11327
|
+
};
|
|
11328
|
+
Shell.prototype.onStart = function (cb) {
|
|
11329
|
+
return this.on('process_start', cb);
|
|
11330
|
+
};
|
|
11331
|
+
Shell.prototype.onStdout = function (cb) {
|
|
11332
|
+
return this.on('process_stdout', cb);
|
|
11333
|
+
};
|
|
11334
|
+
Shell.prototype.onStderr = function (cb) {
|
|
11335
|
+
return this.on('process_stderr', cb);
|
|
11336
|
+
};
|
|
11337
|
+
Shell.prototype.onExit = function (cb) {
|
|
11338
|
+
return this.on('process_exit', cb);
|
|
11339
|
+
};
|
|
11340
|
+
/** When rgxReady is specified the event will be called */
|
|
11341
|
+
Shell.prototype.onReady = function (cb) {
|
|
11342
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11343
|
+
var isAlreadyCompleted = this.isBusy === false && this.lastCode != null;
|
|
11344
|
+
var isReady = this.isReady;
|
|
11345
|
+
if (isReady || isAlreadyCompleted) {
|
|
11346
|
+
cb({ command: (_a = this.currentOptions) === null || _a === void 0 ? void 0 : _a.command });
|
|
11347
|
+
return;
|
|
11348
|
+
}
|
|
11349
|
+
if (!((_b = this.currentOptions) === null || _b === void 0 ? void 0 : _b.matchReady) && this.commandsQueue.some(function (x) { return x.matchReady; }) === false) {
|
|
11350
|
+
console.error('Ready Matcher Regex is not defined', (_d = (_c = this.currentOptions) === null || _c === void 0 ? void 0 : _c.command) !== null && _d !== void 0 ? _d : (_f = (_e = this.commands) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.command);
|
|
11351
|
+
}
|
|
11352
|
+
return this.on('process_ready', cb);
|
|
11353
|
+
};
|
|
11354
|
+
Shell.prototype.onReadyAsync = function () {
|
|
11355
|
+
var _this = this;
|
|
11356
|
+
return new Promise(function (resolve) {
|
|
11357
|
+
_this.onReady(resolve);
|
|
11358
|
+
});
|
|
11359
|
+
};
|
|
11360
|
+
Shell.prototype.onComplete = function (cb) {
|
|
11361
|
+
var _this = this;
|
|
11362
|
+
this.promise.always(function () { return cb(_this); });
|
|
11363
|
+
return this;
|
|
11364
|
+
};
|
|
11365
|
+
Shell.prototype.onCompleteAsync = function () {
|
|
11366
|
+
var _this = this;
|
|
11367
|
+
return new Promise(function (resolve) {
|
|
11368
|
+
_this.onComplete(resolve);
|
|
11369
|
+
});
|
|
11370
|
+
};
|
|
11371
|
+
Shell.prototype.kill = function (mix) {
|
|
11372
|
+
var _this = this;
|
|
11373
|
+
var _a, _b, _c;
|
|
11374
|
+
var signal = 'SIGINT';
|
|
11375
|
+
var commandIdx = 0;
|
|
11376
|
+
var terminateAfterMs = null;
|
|
11377
|
+
if (mix != null) {
|
|
11378
|
+
signal = (_a = (typeof mix === 'object' ? mix.signal : mix)) !== null && _a !== void 0 ? _a : signal;
|
|
11379
|
+
if (typeof mix === 'object') {
|
|
11380
|
+
commandIdx = (_b = mix.commandIdx) !== null && _b !== void 0 ? _b : commandIdx;
|
|
11381
|
+
terminateAfterMs = (_c = mix.terminateAfter) !== null && _c !== void 0 ? _c : terminateAfterMs;
|
|
11382
|
+
}
|
|
11383
|
+
}
|
|
11384
|
+
return new Promise(function (resolve) {
|
|
11385
|
+
var isCompleted = _this.isBusy === false && _this.lastCode != null;
|
|
11386
|
+
if (isCompleted) {
|
|
11387
|
+
return resolve(null);
|
|
11388
|
+
}
|
|
11389
|
+
var options = _this.commands[commandIdx];
|
|
11390
|
+
var child = _this.children.find(function (x) { return x.options === options; });
|
|
11391
|
+
if (child == null) {
|
|
11392
|
+
return resolve(null);
|
|
11393
|
+
}
|
|
11394
|
+
var i = _this.children.indexOf(child);
|
|
11395
|
+
_this.children.splice(i, 1);
|
|
11396
|
+
var timeout;
|
|
11397
|
+
child.process.kill(signal);
|
|
11398
|
+
_this.once('process_exit', function () {
|
|
11399
|
+
if (timeout != null) {
|
|
11400
|
+
clearTimeout(timeout);
|
|
11401
|
+
}
|
|
11402
|
+
resolve(null);
|
|
11403
|
+
});
|
|
11404
|
+
if (terminateAfterMs != null) {
|
|
11405
|
+
timeout = setTimeout(function () {
|
|
11406
|
+
treeKill(child.process.pid);
|
|
11407
|
+
}, terminateAfterMs);
|
|
11408
|
+
}
|
|
11409
|
+
});
|
|
11410
|
+
};
|
|
11411
|
+
/** Uses tree-kill to terminate the tree */
|
|
11412
|
+
Shell.prototype.terminate = function () {
|
|
11413
|
+
var _this = this;
|
|
11414
|
+
return new Promise(function (resolve) {
|
|
11415
|
+
var child = _this.children.pop();
|
|
11416
|
+
if (child == null) {
|
|
11417
|
+
return resolve(null);
|
|
11418
|
+
}
|
|
11419
|
+
_this.once('process_exit', resolve);
|
|
11420
|
+
treeKill(child.process.pid);
|
|
11421
|
+
});
|
|
11422
|
+
};
|
|
11423
|
+
Shell.prototype.send = function (method) {
|
|
11424
|
+
var _this = this;
|
|
11425
|
+
var args = [];
|
|
11426
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
11427
|
+
args[_i - 1] = arguments[_i];
|
|
11428
|
+
}
|
|
11429
|
+
return new Promise(function (resolve, reject) {
|
|
11430
|
+
_this.waitForChannel().then(function (channel) {
|
|
11431
|
+
channel.call.apply(channel, __spreadArray([method], args, false)).then(resolve, reject);
|
|
11432
|
+
}, reject);
|
|
11433
|
+
});
|
|
11434
|
+
};
|
|
11435
|
+
Shell.prototype.restart = function (mix) {
|
|
11436
|
+
if (mix === void 0) { mix = 0; }
|
|
11437
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11438
|
+
var options;
|
|
11439
|
+
return __generator(this, function (_a) {
|
|
11440
|
+
switch (_a.label) {
|
|
11441
|
+
case 0:
|
|
11442
|
+
if (typeof mix === 'number') {
|
|
11443
|
+
options = this.commands[mix];
|
|
11444
|
+
}
|
|
11445
|
+
else {
|
|
11446
|
+
options = this.commands.find(function (x) { return x.command === mix; });
|
|
11447
|
+
}
|
|
11448
|
+
if (options == null) {
|
|
11449
|
+
throw new Error("Options undefined for ".concat(mix));
|
|
11450
|
+
}
|
|
11451
|
+
this.commandsQueue.push(options);
|
|
11452
|
+
if (this.isBusy === false) {
|
|
11453
|
+
this.next();
|
|
11454
|
+
return [2 /*return*/];
|
|
11455
|
+
}
|
|
11456
|
+
// `next` will be called indirect (after the process exits)
|
|
11457
|
+
return [4 /*yield*/, this.kill({ terminateAfter: 10000 })];
|
|
11458
|
+
case 1:
|
|
11459
|
+
// `next` will be called indirect (after the process exits)
|
|
11460
|
+
_a.sent();
|
|
11461
|
+
return [2 /*return*/];
|
|
11462
|
+
}
|
|
11463
|
+
});
|
|
11464
|
+
});
|
|
11465
|
+
};
|
|
11466
|
+
Shell.prototype.waitForChannel = function () {
|
|
11467
|
+
var _this = this;
|
|
11468
|
+
if (this.currentOptions.ipc && this.isReady === false) {
|
|
11469
|
+
return new Promise(function (resolve, reject) {
|
|
11470
|
+
(0, events_1.events_someOnce)(_this, {
|
|
11471
|
+
'process_ready': function () {
|
|
11472
|
+
_this.waitForChannel().then(resolve, reject);
|
|
11473
|
+
},
|
|
11474
|
+
'exit': function () {
|
|
11475
|
+
reject('Process exited');
|
|
11476
|
+
}
|
|
11477
|
+
});
|
|
11478
|
+
});
|
|
11479
|
+
}
|
|
11480
|
+
return new Promise(function (resolve, reject) {
|
|
11481
|
+
if (_this.channel) {
|
|
11482
|
+
resolve(_this.channel);
|
|
11483
|
+
return;
|
|
11484
|
+
}
|
|
11485
|
+
(0, events_1.events_someOnce)(_this, {
|
|
11486
|
+
'channel_created': function () {
|
|
11487
|
+
resolve(_this.channel);
|
|
11488
|
+
},
|
|
11489
|
+
'exit': function () {
|
|
11490
|
+
reject('Process exited');
|
|
11491
|
+
}
|
|
11492
|
+
});
|
|
11493
|
+
});
|
|
11494
|
+
};
|
|
11495
|
+
Shell.prototype.next = function () {
|
|
11496
|
+
var _this = this;
|
|
11497
|
+
var _a;
|
|
11498
|
+
if (this.isBusy === false) {
|
|
11499
|
+
this.start = new Date();
|
|
11500
|
+
this.isBusy = true;
|
|
11501
|
+
this.isReady = false;
|
|
11502
|
+
}
|
|
11503
|
+
if (this.channel) {
|
|
11504
|
+
this.emit('channel_closed', {
|
|
11505
|
+
channel: this.channel
|
|
11506
|
+
});
|
|
11507
|
+
if (this.commandsQueue.length !== 0 || (this.lastCode === 1 && this.errorsHandler.isActive())) {
|
|
11508
|
+
this.channel = null;
|
|
11509
|
+
}
|
|
11510
|
+
}
|
|
11511
|
+
if (this.lastCode === 1 && this.errorsHandler.isActive()) {
|
|
11512
|
+
this.lastCode = 0;
|
|
11513
|
+
this.commandsQueue.push(this.currentOptions);
|
|
11514
|
+
this.errorsHandler.delay(function () {
|
|
11515
|
+
_this.next();
|
|
11516
|
+
});
|
|
11517
|
+
return this.promise;
|
|
11518
|
+
}
|
|
11519
|
+
if (this.commandsQueue.length === 0) {
|
|
11520
|
+
if (this.state !== ShellState.Empty) {
|
|
11521
|
+
this.state = ShellState.Empty;
|
|
11522
|
+
this.end = new Date();
|
|
11523
|
+
this.isBusy = false;
|
|
11524
|
+
var promise = this.promise;
|
|
11525
|
+
// Always resolve the promise, consumer should check for errors
|
|
11526
|
+
promise.resolve(this);
|
|
11527
|
+
}
|
|
11528
|
+
return this.promise;
|
|
11529
|
+
}
|
|
11530
|
+
var child = null;
|
|
11531
|
+
var options = this.commandsQueue.shift();
|
|
11532
|
+
var command = ValueExtractor_1.ValueExtractor.interpolateAny(options.command, this.extracted);
|
|
11533
|
+
var rgxReady = options.matchReady;
|
|
11534
|
+
var detached = options.detached === true;
|
|
11535
|
+
var silent = this.params.silent;
|
|
11536
|
+
var stdio = detached ? (void 0) : 'pipe';
|
|
11537
|
+
var extractor = options.extract ? new ValueExtractor_1.ValueExtractor(this.extracted, options.extract) : null;
|
|
11538
|
+
var result = new ProcessResult(options);
|
|
11539
|
+
this.results.push(result);
|
|
11540
|
+
this.currentOptions = options;
|
|
11541
|
+
if (!options.fork && global.process.platform === 'win32') {
|
|
11542
|
+
if (options.exec !== 'cmd') {
|
|
11543
|
+
options.args.unshift('/C', options.exec);
|
|
11544
|
+
options.exec = 'cmd';
|
|
11545
|
+
}
|
|
11546
|
+
}
|
|
11547
|
+
if (rgxReady == null && options.ipc) {
|
|
11548
|
+
rgxReady = /IPC Listening/i;
|
|
11549
|
+
}
|
|
11550
|
+
this.isReady = rgxReady == null;
|
|
11551
|
+
try {
|
|
11552
|
+
var cwd = options.cwd;
|
|
11553
|
+
if (cwd != null) {
|
|
11554
|
+
var hasFileProtocol = cwd.startsWith('file:');
|
|
11555
|
+
var cwdUri = hasFileProtocol ? cwd : 'file://' + cwd;
|
|
11556
|
+
if (atma_io_1.Directory.exists(cwdUri + '/') === false) {
|
|
11557
|
+
throw Error('CWD Directory not exists: ' + cwd);
|
|
11558
|
+
}
|
|
11559
|
+
if (hasFileProtocol) {
|
|
11560
|
+
cwd = new atma_utils_1.class_Uri(cwd).toLocalDir();
|
|
11561
|
+
}
|
|
11562
|
+
}
|
|
11563
|
+
if (cwd == null) {
|
|
11564
|
+
cwd = process.cwd();
|
|
11565
|
+
}
|
|
11566
|
+
var exec = ValueExtractor_1.ValueExtractor.interpolateAny(options.exec, this.extracted, options);
|
|
11567
|
+
var args = ValueExtractor_1.ValueExtractor.interpolateAny(options.args, this.extracted, options);
|
|
11568
|
+
var method = options.fork ? 'fork' : 'spawn';
|
|
11569
|
+
if (this.params.verbose) {
|
|
11570
|
+
this.print("".concat(method, ": ").concat(exec, " ").concat(args.join('')));
|
|
11571
|
+
}
|
|
11572
|
+
child = options.fork
|
|
11573
|
+
? child_process.fork(exec, args, {
|
|
11574
|
+
cwd: options.cwd || process.cwd(),
|
|
11575
|
+
env: process.env,
|
|
11576
|
+
stdio: stdio,
|
|
11577
|
+
detached: detached
|
|
11578
|
+
})
|
|
11579
|
+
: child_process.spawn(exec, args, {
|
|
11580
|
+
cwd: options.cwd || process.cwd(),
|
|
11581
|
+
env: process.env,
|
|
11582
|
+
stdio: stdio,
|
|
11583
|
+
detached: detached
|
|
11584
|
+
});
|
|
11585
|
+
if (options.fork) {
|
|
11586
|
+
this.channel = new CommunicationChannel_1.CommunicationChannel(child, (_a = this.params.timeoutMs) !== null && _a !== void 0 ? _a : 10000);
|
|
11587
|
+
this.emit('channel_created', {
|
|
11588
|
+
channel: this.channel
|
|
11589
|
+
});
|
|
11590
|
+
}
|
|
11591
|
+
result.pid = child.pid;
|
|
11592
|
+
this.children.push({
|
|
11593
|
+
process: child,
|
|
11594
|
+
options: options,
|
|
11595
|
+
});
|
|
11596
|
+
}
|
|
11597
|
+
catch (error) {
|
|
11598
|
+
if (this.params.verbose) {
|
|
11599
|
+
this.print('on start exception:', error);
|
|
11600
|
+
}
|
|
11601
|
+
result.error = error;
|
|
11602
|
+
this.errors.push({
|
|
11603
|
+
command: command,
|
|
11604
|
+
error: error
|
|
11605
|
+
});
|
|
11606
|
+
this.emit('process_exception', {
|
|
11607
|
+
command: command,
|
|
11608
|
+
error: error
|
|
11609
|
+
});
|
|
11610
|
+
return this.next();
|
|
11611
|
+
}
|
|
11612
|
+
child.on('error', function (error) {
|
|
11613
|
+
var _a;
|
|
11614
|
+
if (_this.params.verbose) {
|
|
11615
|
+
_this.print('on error:', error);
|
|
11616
|
+
}
|
|
11617
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(error);
|
|
11618
|
+
});
|
|
11619
|
+
child.on('exit', function (code) {
|
|
11620
|
+
var _a;
|
|
11621
|
+
if (_this.params.verbose) {
|
|
11622
|
+
_this.print('on exit:', code);
|
|
11623
|
+
}
|
|
11624
|
+
result.resultCode = code !== null && code !== void 0 ? code : 0;
|
|
11625
|
+
_this.emit('process_exit', {
|
|
11626
|
+
command: command,
|
|
11627
|
+
code: code,
|
|
11628
|
+
result: result
|
|
11629
|
+
});
|
|
11630
|
+
_this.isBusy = false;
|
|
11631
|
+
_this.isReady = false;
|
|
11632
|
+
_this.lastCode = code;
|
|
11633
|
+
if (code > 0) {
|
|
11634
|
+
var msg = result.stderr.slice(-20).join('');
|
|
11635
|
+
var err = new Error("Exit code: ".concat(code, ". ").concat(msg !== null && msg !== void 0 ? msg : ''));
|
|
11636
|
+
_this.errors.push({
|
|
11637
|
+
command: command,
|
|
11638
|
+
error: err
|
|
11639
|
+
});
|
|
11640
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onError(err);
|
|
11641
|
+
}
|
|
11642
|
+
extractor === null || extractor === void 0 ? void 0 : extractor.complete();
|
|
11643
|
+
_this.next();
|
|
11644
|
+
});
|
|
11645
|
+
child.stdout.on('data', function (buffer) {
|
|
11646
|
+
if (detached !== true && silent !== true) {
|
|
11647
|
+
process.stdout.write(buffer);
|
|
11648
|
+
}
|
|
11649
|
+
if (rgxReady != null && rgxReady.test(buffer.toString())) {
|
|
11650
|
+
rgxReady = null;
|
|
11651
|
+
_this.isReady = true;
|
|
11652
|
+
_this.emit('process_ready', {
|
|
11653
|
+
command: command
|
|
11654
|
+
});
|
|
11655
|
+
}
|
|
11656
|
+
if (extractor != null) {
|
|
11657
|
+
extractor.write(buffer);
|
|
11658
|
+
}
|
|
11659
|
+
var str = String(buffer);
|
|
11660
|
+
result.stdout.push(str);
|
|
11661
|
+
result.std.push(str);
|
|
11662
|
+
_this.stdout.push(str);
|
|
11663
|
+
_this.std.push(str);
|
|
11664
|
+
_this.emit('process_stdout', {
|
|
11665
|
+
command: command,
|
|
11666
|
+
buffer: buffer
|
|
11667
|
+
});
|
|
11668
|
+
});
|
|
11669
|
+
child.stderr.on('data', function (buffer) {
|
|
11670
|
+
var _a;
|
|
11671
|
+
if (detached !== true && silent !== true) {
|
|
11672
|
+
process.stderr.write(buffer);
|
|
11673
|
+
}
|
|
11674
|
+
var str = String(buffer);
|
|
11675
|
+
result.stderr.push(str);
|
|
11676
|
+
result.std.push(str);
|
|
11677
|
+
_this.stderr.push(str);
|
|
11678
|
+
_this.std.push(str);
|
|
11679
|
+
_this.emit('process_stderr', {
|
|
11680
|
+
command: command,
|
|
11681
|
+
buffer: buffer
|
|
11682
|
+
});
|
|
11683
|
+
if (str.includes('UnhandledPromiseRejectionWarning')) {
|
|
11684
|
+
(_a = _this.channel) === null || _a === void 0 ? void 0 : _a.onStdError(str);
|
|
11685
|
+
}
|
|
11686
|
+
});
|
|
11687
|
+
this.emit('process_start', {
|
|
11688
|
+
command: command
|
|
11689
|
+
});
|
|
11690
|
+
if (this.params.parallel !== false) {
|
|
11691
|
+
this.next();
|
|
11692
|
+
}
|
|
11693
|
+
if (rgxReady == null) {
|
|
11694
|
+
setTimeout(function () {
|
|
11695
|
+
_this.emit('process_ready', {
|
|
11696
|
+
command: command
|
|
11697
|
+
});
|
|
11698
|
+
}, 200);
|
|
11699
|
+
}
|
|
11700
|
+
return this.promise;
|
|
11701
|
+
};
|
|
11702
|
+
Shell.prototype.print = function () {
|
|
11703
|
+
var args = [];
|
|
11704
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11705
|
+
args[_i] = arguments[_i];
|
|
11706
|
+
}
|
|
11707
|
+
console.log('Shellbee: ' + args.join(' '));
|
|
11708
|
+
};
|
|
11709
|
+
Shell.ipc = CommunicationChannel_1.CommunicationChannel.ipc;
|
|
11710
|
+
return Shell;
|
|
11711
|
+
}(atma_utils_1.class_EventEmitter));
|
|
11712
|
+
exports.Shell = Shell;
|
|
11713
|
+
;
|
|
11714
|
+
var ProcessResult = /** @class */ (function () {
|
|
11715
|
+
function ProcessResult(options) {
|
|
11716
|
+
this.options = options;
|
|
11717
|
+
this.std = [];
|
|
11718
|
+
this.stdout = [];
|
|
11719
|
+
this.stderr = [];
|
|
11720
|
+
this.resultCode = null;
|
|
11721
|
+
this.error = null;
|
|
11722
|
+
}
|
|
11723
|
+
return ProcessResult;
|
|
11724
|
+
}());
|
|
11725
|
+
exports.ProcessResult = ProcessResult;
|
|
11726
|
+
var ShellState;
|
|
11727
|
+
(function (ShellState) {
|
|
11728
|
+
ShellState[ShellState["Empty"] = -1] = "Empty";
|
|
11729
|
+
ShellState[ShellState["Initial"] = 0] = "Initial";
|
|
11730
|
+
ShellState[ShellState["Started"] = 1] = "Started";
|
|
11731
|
+
})(ShellState || (ShellState = {}));
|
|
11732
11732
|
;
|
|
11733
11733
|
|
|
11734
11734
|
function __isObj(x) {
|
|
@@ -11756,292 +11756,292 @@ var _src_ps_PsList;
|
|
|
11756
11756
|
var exports = _src_ps_PsList != null ? _src_ps_PsList : {};
|
|
11757
11757
|
var module = { exports: exports };
|
|
11758
11758
|
|
|
11759
|
-
"use strict";
|
|
11760
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11761
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11762
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11763
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11764
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11765
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11766
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11767
|
-
});
|
|
11768
|
-
};
|
|
11769
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11770
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11771
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11772
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11773
|
-
function step(op) {
|
|
11774
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
11775
|
-
while (_) try {
|
|
11776
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11777
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11778
|
-
switch (op[0]) {
|
|
11779
|
-
case 0: case 1: t = op; break;
|
|
11780
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
11781
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11782
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11783
|
-
default:
|
|
11784
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11785
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11786
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11787
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11788
|
-
if (t[2]) _.ops.pop();
|
|
11789
|
-
_.trys.pop(); continue;
|
|
11790
|
-
}
|
|
11791
|
-
op = body.call(thisArg, _);
|
|
11792
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11793
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11794
|
-
}
|
|
11795
|
-
};
|
|
11796
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11797
|
-
exports.PsList = void 0;
|
|
11798
|
-
var Shell_1 = _src_Shell;
|
|
11799
|
-
var path = require("path");
|
|
11800
|
-
var treeKill = require("tree-kill");
|
|
11801
|
-
var PsList;
|
|
11802
|
-
(function (PsList) {
|
|
11803
|
-
function getAll() {
|
|
11804
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
11805
|
-
return __generator(this, function (_a) {
|
|
11806
|
-
return [2 /*return*/, Platforms[process.platform]()];
|
|
11807
|
-
});
|
|
11808
|
-
});
|
|
11809
|
-
}
|
|
11810
|
-
PsList.getAll = getAll;
|
|
11811
|
-
function kill(pid) {
|
|
11812
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11813
|
-
return __generator(this, function (_a) {
|
|
11814
|
-
return [2 /*return*/, treeKill(pid)];
|
|
11815
|
-
});
|
|
11816
|
-
});
|
|
11817
|
-
}
|
|
11818
|
-
PsList.kill = kill;
|
|
11819
|
-
var ProcessListResolver = {
|
|
11820
|
-
nix: function () {
|
|
11821
|
-
var _a;
|
|
11822
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11823
|
-
var shell, stdout, data, columns, list;
|
|
11824
|
-
return __generator(this, function (_b) {
|
|
11825
|
-
switch (_b.label) {
|
|
11826
|
-
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11827
|
-
silent: true,
|
|
11828
|
-
command: "ps ax -ww -o pid,ppid,uid,gid,args"
|
|
11829
|
-
})];
|
|
11830
|
-
case 1:
|
|
11831
|
-
shell = _b.sent();
|
|
11832
|
-
stdout = (_a = shell.stdout) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11833
|
-
data = utils.stripLine(stdout, 1);
|
|
11834
|
-
columns = utils.extractColumns(data, [0, 1, 2, 3, 4], 5);
|
|
11835
|
-
list = columns.map(function (column) {
|
|
11836
|
-
var cmd = String(column[4]);
|
|
11837
|
-
var bin = fetchBin(cmd);
|
|
11838
|
-
return {
|
|
11839
|
-
pid: parseInt(column[0], 10),
|
|
11840
|
-
ppid: parseInt(column[1], 10),
|
|
11841
|
-
uid: parseInt(column[2], 10),
|
|
11842
|
-
gid: parseInt(column[3], 10),
|
|
11843
|
-
name: fetchName(bin),
|
|
11844
|
-
bin: bin,
|
|
11845
|
-
cmd: column[4]
|
|
11846
|
-
};
|
|
11847
|
-
});
|
|
11848
|
-
return [2 /*return*/, list];
|
|
11849
|
-
}
|
|
11850
|
-
});
|
|
11851
|
-
});
|
|
11852
|
-
},
|
|
11853
|
-
win32: function () {
|
|
11854
|
-
var _a;
|
|
11855
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11856
|
-
var shell, std, list;
|
|
11857
|
-
return __generator(this, function (_b) {
|
|
11858
|
-
switch (_b.label) {
|
|
11859
|
-
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11860
|
-
silent: true,
|
|
11861
|
-
command: "powershell.exe /c \"Get-CimInstance -className win32_process | select Name,ProcessId,ParentProcessId,CommandLine,ExecutablePath\"",
|
|
11862
|
-
})];
|
|
11863
|
-
case 1:
|
|
11864
|
-
shell = _b.sent();
|
|
11865
|
-
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11866
|
-
list = utils
|
|
11867
|
-
.parseTable(std)
|
|
11868
|
-
.map(function (row) { return ({
|
|
11869
|
-
pid: parseInt(row.ProcessId, 10),
|
|
11870
|
-
ppid: parseInt(row.ParentProcessId, 10),
|
|
11871
|
-
bin: row.ExecutablePath,
|
|
11872
|
-
name: row.Name || '',
|
|
11873
|
-
cmd: row.CommandLine
|
|
11874
|
-
}); });
|
|
11875
|
-
return [2 /*return*/, list];
|
|
11876
|
-
}
|
|
11877
|
-
});
|
|
11878
|
-
});
|
|
11879
|
-
}
|
|
11880
|
-
};
|
|
11881
|
-
var Platforms = {
|
|
11882
|
-
darwin: ProcessListResolver.nix,
|
|
11883
|
-
linux: ProcessListResolver.nix,
|
|
11884
|
-
sunos: ProcessListResolver.nix,
|
|
11885
|
-
freebsd: ProcessListResolver.nix,
|
|
11886
|
-
win32: ProcessListResolver.win32,
|
|
11887
|
-
};
|
|
11888
|
-
function fetchBin(cmd) {
|
|
11889
|
-
var pieces = cmd.split(path.sep);
|
|
11890
|
-
var last = pieces[pieces.length - 1];
|
|
11891
|
-
if (last) {
|
|
11892
|
-
pieces[pieces.length - 1] = last.split(' ')[0];
|
|
11893
|
-
}
|
|
11894
|
-
var fixed = [];
|
|
11895
|
-
for (var _i = 0, pieces_1 = pieces; _i < pieces_1.length; _i++) {
|
|
11896
|
-
var part = pieces_1[_i];
|
|
11897
|
-
var optIdx = part.indexOf(' -');
|
|
11898
|
-
if (optIdx >= 0) {
|
|
11899
|
-
// case: /aaa/bbb/ccc -c
|
|
11900
|
-
fixed.push(part.substring(0, optIdx).trim());
|
|
11901
|
-
break;
|
|
11902
|
-
}
|
|
11903
|
-
else if (part.endsWith(' ')) {
|
|
11904
|
-
// case: node /aaa/bbb/ccc.js
|
|
11905
|
-
fixed.push(part.trim());
|
|
11906
|
-
break;
|
|
11907
|
-
}
|
|
11908
|
-
fixed.push(part);
|
|
11909
|
-
}
|
|
11910
|
-
return fixed.join(path.sep);
|
|
11911
|
-
}
|
|
11912
|
-
function fetchName(fullpath) {
|
|
11913
|
-
if (process.platform === 'darwin') {
|
|
11914
|
-
var idx = fullpath.indexOf('.app/');
|
|
11915
|
-
if (idx >= 0) {
|
|
11916
|
-
return path.basename(fullpath.substring(0, idx));
|
|
11917
|
-
}
|
|
11918
|
-
}
|
|
11919
|
-
return path.basename(fullpath);
|
|
11920
|
-
}
|
|
11921
|
-
var utils = {
|
|
11922
|
-
/**
|
|
11923
|
-
* Strip top lines of text
|
|
11924
|
-
*
|
|
11925
|
-
* @param {String} text
|
|
11926
|
-
* @param {Number} num
|
|
11927
|
-
* @return {String}
|
|
11928
|
-
*/
|
|
11929
|
-
stripLine: function (text, num) {
|
|
11930
|
-
var idx = 0;
|
|
11931
|
-
while (num-- > 0) {
|
|
11932
|
-
var nIdx = text.indexOf('\n', idx);
|
|
11933
|
-
if (nIdx >= 0) {
|
|
11934
|
-
idx = nIdx + 1;
|
|
11935
|
-
}
|
|
11936
|
-
}
|
|
11937
|
-
return idx > 0 ? text.substring(idx) : text;
|
|
11938
|
-
},
|
|
11939
|
-
/**
|
|
11940
|
-
* Split string and stop at max parts
|
|
11941
|
-
*
|
|
11942
|
-
* @param {Number} line
|
|
11943
|
-
* @param {Number} max
|
|
11944
|
-
* @return {Array}
|
|
11945
|
-
*/
|
|
11946
|
-
split: function (line, max) {
|
|
11947
|
-
var cols = line.trim().split(/\s+/);
|
|
11948
|
-
if (cols.length > max) {
|
|
11949
|
-
cols[max - 1] = cols.slice(max - 1).join(' ');
|
|
11950
|
-
}
|
|
11951
|
-
return cols;
|
|
11952
|
-
},
|
|
11953
|
-
/**
|
|
11954
|
-
* Extract columns from table text
|
|
11955
|
-
*
|
|
11956
|
-
* Example:
|
|
11957
|
-
*
|
|
11958
|
-
* ```
|
|
11959
|
-
* extractColumns(text, [0, 2], 3)
|
|
11960
|
-
* ```
|
|
11961
|
-
*
|
|
11962
|
-
* From:
|
|
11963
|
-
* ```
|
|
11964
|
-
* foo bar bar2
|
|
11965
|
-
* valx valy valz
|
|
11966
|
-
* ```
|
|
11967
|
-
*
|
|
11968
|
-
* To:
|
|
11969
|
-
* ```
|
|
11970
|
-
* [ ['foo', 'bar2'], ['valx', 'valz'] ]
|
|
11971
|
-
* ```
|
|
11972
|
-
*
|
|
11973
|
-
* @param {String} text raw table text
|
|
11974
|
-
* @param {Array} idxes the column index list to extract
|
|
11975
|
-
* @param {Number} max max column number of table
|
|
11976
|
-
* @return {Array}
|
|
11977
|
-
*/
|
|
11978
|
-
extractColumns: function (text, idxes, max) {
|
|
11979
|
-
var lines = text.split(/(\r\n|\n|\r)/);
|
|
11980
|
-
var columns = [];
|
|
11981
|
-
if (!max) {
|
|
11982
|
-
max = Math.max.apply(null, idxes) + 1;
|
|
11983
|
-
}
|
|
11984
|
-
lines.forEach(function (line) {
|
|
11985
|
-
var cols = utils.split(line, max);
|
|
11986
|
-
var column = [];
|
|
11987
|
-
idxes.forEach(function (idx) {
|
|
11988
|
-
column.push(cols[idx] || '');
|
|
11989
|
-
});
|
|
11990
|
-
columns.push(column);
|
|
11991
|
-
});
|
|
11992
|
-
return columns;
|
|
11993
|
-
},
|
|
11994
|
-
/**
|
|
11995
|
-
* parse table text to array
|
|
11996
|
-
*
|
|
11997
|
-
* From:
|
|
11998
|
-
* ```
|
|
11999
|
-
* Header1 : foo
|
|
12000
|
-
* Header2 : bar
|
|
12001
|
-
* Header3 : val
|
|
12002
|
-
*
|
|
12003
|
-
* Header1 : foo2
|
|
12004
|
-
* Header2 : bar2
|
|
12005
|
-
* Header3 : val2
|
|
12006
|
-
* ```
|
|
12007
|
-
*
|
|
12008
|
-
* To:
|
|
12009
|
-
* ```
|
|
12010
|
-
* [{ Header1: 'foo', Header2: 'bar', Header3: 'val' }, ...]
|
|
12011
|
-
* ```
|
|
12012
|
-
*
|
|
12013
|
-
* @param {String} data raw table data
|
|
12014
|
-
* @return {Array}
|
|
12015
|
-
*/
|
|
12016
|
-
parseTable: function (data) {
|
|
12017
|
-
var lines = data.split(/(\r\n\r\n|\r\n\n|\n\r\n)|\n\n/).filter(function (line) {
|
|
12018
|
-
return line.trim().length > 0;
|
|
12019
|
-
}).map(function (e) { return e.split(/(\r\n|\n|\r)/).filter(function (line) { return line.trim().length > 0; }); });
|
|
12020
|
-
// Join multi-ligne value
|
|
12021
|
-
lines.forEach(function (line) {
|
|
12022
|
-
for (var index = 0; line[index];) {
|
|
12023
|
-
var entry = line[index];
|
|
12024
|
-
if (entry.startsWith(' ')) {
|
|
12025
|
-
line[index - 1] += entry.trimLeft();
|
|
12026
|
-
line.splice(index, 1);
|
|
12027
|
-
}
|
|
12028
|
-
else {
|
|
12029
|
-
index += 1;
|
|
12030
|
-
}
|
|
12031
|
-
}
|
|
12032
|
-
});
|
|
12033
|
-
return lines.map(function (line) {
|
|
12034
|
-
var row = {};
|
|
12035
|
-
line.forEach(function (string) {
|
|
12036
|
-
var splitterIndex = string.indexOf(':');
|
|
12037
|
-
var key = string.slice(0, splitterIndex).trim();
|
|
12038
|
-
row[key] = string.slice(splitterIndex + 1).trim();
|
|
12039
|
-
});
|
|
12040
|
-
return row;
|
|
12041
|
-
});
|
|
12042
|
-
}
|
|
12043
|
-
};
|
|
12044
|
-
})(PsList = exports.PsList || (exports.PsList = {}));
|
|
11759
|
+
"use strict";
|
|
11760
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11761
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11762
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11763
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11764
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11765
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11766
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11767
|
+
});
|
|
11768
|
+
};
|
|
11769
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11770
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
11771
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11772
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
11773
|
+
function step(op) {
|
|
11774
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
11775
|
+
while (_) try {
|
|
11776
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
11777
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11778
|
+
switch (op[0]) {
|
|
11779
|
+
case 0: case 1: t = op; break;
|
|
11780
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
11781
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
11782
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
11783
|
+
default:
|
|
11784
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
11785
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
11786
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
11787
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
11788
|
+
if (t[2]) _.ops.pop();
|
|
11789
|
+
_.trys.pop(); continue;
|
|
11790
|
+
}
|
|
11791
|
+
op = body.call(thisArg, _);
|
|
11792
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
11793
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
11794
|
+
}
|
|
11795
|
+
};
|
|
11796
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11797
|
+
exports.PsList = void 0;
|
|
11798
|
+
var Shell_1 = _src_Shell;
|
|
11799
|
+
var path = require("path");
|
|
11800
|
+
var treeKill = require("tree-kill");
|
|
11801
|
+
var PsList;
|
|
11802
|
+
(function (PsList) {
|
|
11803
|
+
function getAll() {
|
|
11804
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
11805
|
+
return __generator(this, function (_a) {
|
|
11806
|
+
return [2 /*return*/, Platforms[process.platform]()];
|
|
11807
|
+
});
|
|
11808
|
+
});
|
|
11809
|
+
}
|
|
11810
|
+
PsList.getAll = getAll;
|
|
11811
|
+
function kill(pid) {
|
|
11812
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11813
|
+
return __generator(this, function (_a) {
|
|
11814
|
+
return [2 /*return*/, treeKill(pid)];
|
|
11815
|
+
});
|
|
11816
|
+
});
|
|
11817
|
+
}
|
|
11818
|
+
PsList.kill = kill;
|
|
11819
|
+
var ProcessListResolver = {
|
|
11820
|
+
nix: function () {
|
|
11821
|
+
var _a;
|
|
11822
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11823
|
+
var shell, stdout, data, columns, list;
|
|
11824
|
+
return __generator(this, function (_b) {
|
|
11825
|
+
switch (_b.label) {
|
|
11826
|
+
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11827
|
+
silent: true,
|
|
11828
|
+
command: "ps ax -ww -o pid,ppid,uid,gid,args"
|
|
11829
|
+
})];
|
|
11830
|
+
case 1:
|
|
11831
|
+
shell = _b.sent();
|
|
11832
|
+
stdout = (_a = shell.stdout) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11833
|
+
data = utils.stripLine(stdout, 1);
|
|
11834
|
+
columns = utils.extractColumns(data, [0, 1, 2, 3, 4], 5);
|
|
11835
|
+
list = columns.map(function (column) {
|
|
11836
|
+
var cmd = String(column[4]);
|
|
11837
|
+
var bin = fetchBin(cmd);
|
|
11838
|
+
return {
|
|
11839
|
+
pid: parseInt(column[0], 10),
|
|
11840
|
+
ppid: parseInt(column[1], 10),
|
|
11841
|
+
uid: parseInt(column[2], 10),
|
|
11842
|
+
gid: parseInt(column[3], 10),
|
|
11843
|
+
name: fetchName(bin),
|
|
11844
|
+
bin: bin,
|
|
11845
|
+
cmd: column[4]
|
|
11846
|
+
};
|
|
11847
|
+
});
|
|
11848
|
+
return [2 /*return*/, list];
|
|
11849
|
+
}
|
|
11850
|
+
});
|
|
11851
|
+
});
|
|
11852
|
+
},
|
|
11853
|
+
win32: function () {
|
|
11854
|
+
var _a;
|
|
11855
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11856
|
+
var shell, std, list;
|
|
11857
|
+
return __generator(this, function (_b) {
|
|
11858
|
+
switch (_b.label) {
|
|
11859
|
+
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
11860
|
+
silent: true,
|
|
11861
|
+
command: "powershell.exe /c \"Get-CimInstance -className win32_process | select Name,ProcessId,ParentProcessId,CommandLine,ExecutablePath\"",
|
|
11862
|
+
})];
|
|
11863
|
+
case 1:
|
|
11864
|
+
shell = _b.sent();
|
|
11865
|
+
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
11866
|
+
list = utils
|
|
11867
|
+
.parseTable(std)
|
|
11868
|
+
.map(function (row) { return ({
|
|
11869
|
+
pid: parseInt(row.ProcessId, 10),
|
|
11870
|
+
ppid: parseInt(row.ParentProcessId, 10),
|
|
11871
|
+
bin: row.ExecutablePath,
|
|
11872
|
+
name: row.Name || '',
|
|
11873
|
+
cmd: row.CommandLine
|
|
11874
|
+
}); });
|
|
11875
|
+
return [2 /*return*/, list];
|
|
11876
|
+
}
|
|
11877
|
+
});
|
|
11878
|
+
});
|
|
11879
|
+
}
|
|
11880
|
+
};
|
|
11881
|
+
var Platforms = {
|
|
11882
|
+
darwin: ProcessListResolver.nix,
|
|
11883
|
+
linux: ProcessListResolver.nix,
|
|
11884
|
+
sunos: ProcessListResolver.nix,
|
|
11885
|
+
freebsd: ProcessListResolver.nix,
|
|
11886
|
+
win32: ProcessListResolver.win32,
|
|
11887
|
+
};
|
|
11888
|
+
function fetchBin(cmd) {
|
|
11889
|
+
var pieces = cmd.split(path.sep);
|
|
11890
|
+
var last = pieces[pieces.length - 1];
|
|
11891
|
+
if (last) {
|
|
11892
|
+
pieces[pieces.length - 1] = last.split(' ')[0];
|
|
11893
|
+
}
|
|
11894
|
+
var fixed = [];
|
|
11895
|
+
for (var _i = 0, pieces_1 = pieces; _i < pieces_1.length; _i++) {
|
|
11896
|
+
var part = pieces_1[_i];
|
|
11897
|
+
var optIdx = part.indexOf(' -');
|
|
11898
|
+
if (optIdx >= 0) {
|
|
11899
|
+
// case: /aaa/bbb/ccc -c
|
|
11900
|
+
fixed.push(part.substring(0, optIdx).trim());
|
|
11901
|
+
break;
|
|
11902
|
+
}
|
|
11903
|
+
else if (part.endsWith(' ')) {
|
|
11904
|
+
// case: node /aaa/bbb/ccc.js
|
|
11905
|
+
fixed.push(part.trim());
|
|
11906
|
+
break;
|
|
11907
|
+
}
|
|
11908
|
+
fixed.push(part);
|
|
11909
|
+
}
|
|
11910
|
+
return fixed.join(path.sep);
|
|
11911
|
+
}
|
|
11912
|
+
function fetchName(fullpath) {
|
|
11913
|
+
if (process.platform === 'darwin') {
|
|
11914
|
+
var idx = fullpath.indexOf('.app/');
|
|
11915
|
+
if (idx >= 0) {
|
|
11916
|
+
return path.basename(fullpath.substring(0, idx));
|
|
11917
|
+
}
|
|
11918
|
+
}
|
|
11919
|
+
return path.basename(fullpath);
|
|
11920
|
+
}
|
|
11921
|
+
var utils = {
|
|
11922
|
+
/**
|
|
11923
|
+
* Strip top lines of text
|
|
11924
|
+
*
|
|
11925
|
+
* @param {String} text
|
|
11926
|
+
* @param {Number} num
|
|
11927
|
+
* @return {String}
|
|
11928
|
+
*/
|
|
11929
|
+
stripLine: function (text, num) {
|
|
11930
|
+
var idx = 0;
|
|
11931
|
+
while (num-- > 0) {
|
|
11932
|
+
var nIdx = text.indexOf('\n', idx);
|
|
11933
|
+
if (nIdx >= 0) {
|
|
11934
|
+
idx = nIdx + 1;
|
|
11935
|
+
}
|
|
11936
|
+
}
|
|
11937
|
+
return idx > 0 ? text.substring(idx) : text;
|
|
11938
|
+
},
|
|
11939
|
+
/**
|
|
11940
|
+
* Split string and stop at max parts
|
|
11941
|
+
*
|
|
11942
|
+
* @param {Number} line
|
|
11943
|
+
* @param {Number} max
|
|
11944
|
+
* @return {Array}
|
|
11945
|
+
*/
|
|
11946
|
+
split: function (line, max) {
|
|
11947
|
+
var cols = line.trim().split(/\s+/);
|
|
11948
|
+
if (cols.length > max) {
|
|
11949
|
+
cols[max - 1] = cols.slice(max - 1).join(' ');
|
|
11950
|
+
}
|
|
11951
|
+
return cols;
|
|
11952
|
+
},
|
|
11953
|
+
/**
|
|
11954
|
+
* Extract columns from table text
|
|
11955
|
+
*
|
|
11956
|
+
* Example:
|
|
11957
|
+
*
|
|
11958
|
+
* ```
|
|
11959
|
+
* extractColumns(text, [0, 2], 3)
|
|
11960
|
+
* ```
|
|
11961
|
+
*
|
|
11962
|
+
* From:
|
|
11963
|
+
* ```
|
|
11964
|
+
* foo bar bar2
|
|
11965
|
+
* valx valy valz
|
|
11966
|
+
* ```
|
|
11967
|
+
*
|
|
11968
|
+
* To:
|
|
11969
|
+
* ```
|
|
11970
|
+
* [ ['foo', 'bar2'], ['valx', 'valz'] ]
|
|
11971
|
+
* ```
|
|
11972
|
+
*
|
|
11973
|
+
* @param {String} text raw table text
|
|
11974
|
+
* @param {Array} idxes the column index list to extract
|
|
11975
|
+
* @param {Number} max max column number of table
|
|
11976
|
+
* @return {Array}
|
|
11977
|
+
*/
|
|
11978
|
+
extractColumns: function (text, idxes, max) {
|
|
11979
|
+
var lines = text.split(/(\r\n|\n|\r)/);
|
|
11980
|
+
var columns = [];
|
|
11981
|
+
if (!max) {
|
|
11982
|
+
max = Math.max.apply(null, idxes) + 1;
|
|
11983
|
+
}
|
|
11984
|
+
lines.forEach(function (line) {
|
|
11985
|
+
var cols = utils.split(line, max);
|
|
11986
|
+
var column = [];
|
|
11987
|
+
idxes.forEach(function (idx) {
|
|
11988
|
+
column.push(cols[idx] || '');
|
|
11989
|
+
});
|
|
11990
|
+
columns.push(column);
|
|
11991
|
+
});
|
|
11992
|
+
return columns;
|
|
11993
|
+
},
|
|
11994
|
+
/**
|
|
11995
|
+
* parse table text to array
|
|
11996
|
+
*
|
|
11997
|
+
* From:
|
|
11998
|
+
* ```
|
|
11999
|
+
* Header1 : foo
|
|
12000
|
+
* Header2 : bar
|
|
12001
|
+
* Header3 : val
|
|
12002
|
+
*
|
|
12003
|
+
* Header1 : foo2
|
|
12004
|
+
* Header2 : bar2
|
|
12005
|
+
* Header3 : val2
|
|
12006
|
+
* ```
|
|
12007
|
+
*
|
|
12008
|
+
* To:
|
|
12009
|
+
* ```
|
|
12010
|
+
* [{ Header1: 'foo', Header2: 'bar', Header3: 'val' }, ...]
|
|
12011
|
+
* ```
|
|
12012
|
+
*
|
|
12013
|
+
* @param {String} data raw table data
|
|
12014
|
+
* @return {Array}
|
|
12015
|
+
*/
|
|
12016
|
+
parseTable: function (data) {
|
|
12017
|
+
var lines = data.split(/(\r\n\r\n|\r\n\n|\n\r\n)|\n\n/).filter(function (line) {
|
|
12018
|
+
return line.trim().length > 0;
|
|
12019
|
+
}).map(function (e) { return e.split(/(\r\n|\n|\r)/).filter(function (line) { return line.trim().length > 0; }); });
|
|
12020
|
+
// Join multi-ligne value
|
|
12021
|
+
lines.forEach(function (line) {
|
|
12022
|
+
for (var index = 0; line[index];) {
|
|
12023
|
+
var entry = line[index];
|
|
12024
|
+
if (entry.startsWith(' ')) {
|
|
12025
|
+
line[index - 1] += entry.trimLeft();
|
|
12026
|
+
line.splice(index, 1);
|
|
12027
|
+
}
|
|
12028
|
+
else {
|
|
12029
|
+
index += 1;
|
|
12030
|
+
}
|
|
12031
|
+
}
|
|
12032
|
+
});
|
|
12033
|
+
return lines.map(function (line) {
|
|
12034
|
+
var row = {};
|
|
12035
|
+
line.forEach(function (string) {
|
|
12036
|
+
var splitterIndex = string.indexOf(':');
|
|
12037
|
+
var key = string.slice(0, splitterIndex).trim();
|
|
12038
|
+
row[key] = string.slice(splitterIndex + 1).trim();
|
|
12039
|
+
});
|
|
12040
|
+
return row;
|
|
12041
|
+
});
|
|
12042
|
+
}
|
|
12043
|
+
};
|
|
12044
|
+
})(PsList = exports.PsList || (exports.PsList = {}));
|
|
12045
12045
|
;
|
|
12046
12046
|
|
|
12047
12047
|
function __isObj(x) {
|
|
@@ -12069,185 +12069,185 @@ var _src_ps_Net;
|
|
|
12069
12069
|
var exports = _src_ps_Net != null ? _src_ps_Net : {};
|
|
12070
12070
|
var module = { exports: exports };
|
|
12071
12071
|
|
|
12072
|
-
"use strict";
|
|
12073
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12074
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12075
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12076
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12077
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12078
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12079
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12080
|
-
});
|
|
12081
|
-
};
|
|
12082
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12083
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12084
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
12085
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
12086
|
-
function step(op) {
|
|
12087
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
12088
|
-
while (_) try {
|
|
12089
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
12090
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
12091
|
-
switch (op[0]) {
|
|
12092
|
-
case 0: case 1: t = op; break;
|
|
12093
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
12094
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
12095
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
12096
|
-
default:
|
|
12097
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
12098
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
12099
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
12100
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
12101
|
-
if (t[2]) _.ops.pop();
|
|
12102
|
-
_.trys.pop(); continue;
|
|
12103
|
-
}
|
|
12104
|
-
op = body.call(thisArg, _);
|
|
12105
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
12106
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
12107
|
-
}
|
|
12108
|
-
};
|
|
12109
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12110
|
-
exports.Net = void 0;
|
|
12111
|
-
var alot_1 = require("alot");
|
|
12112
|
-
var Shell_1 = _src_Shell;
|
|
12113
|
-
var PsList_1 = _src_ps_PsList;
|
|
12114
|
-
var Net;
|
|
12115
|
-
(function (Net) {
|
|
12116
|
-
var PidResolver = {
|
|
12117
|
-
nix: function (port) {
|
|
12118
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
12119
|
-
var table, iPid, iStatus, iProtocol;
|
|
12120
|
-
return __generator(this, function (_a) {
|
|
12121
|
-
switch (_a.label) {
|
|
12122
|
-
case 0: return [4 /*yield*/, exec("lsof -i :".concat(port))];
|
|
12123
|
-
case 1:
|
|
12124
|
-
table = _a.sent();
|
|
12125
|
-
iPid = 1;
|
|
12126
|
-
iStatus = 9;
|
|
12127
|
-
iProtocol = 7;
|
|
12128
|
-
return [2 /*return*/, table.map(function (row) {
|
|
12129
|
-
var _a, _b, _c;
|
|
12130
|
-
var pid = Number(row[iPid]);
|
|
12131
|
-
var status = (_a = row[iStatus]) !== null && _a !== void 0 ? _a : '';
|
|
12132
|
-
var protocol = (_c = (_b = row[iProtocol]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'tcp';
|
|
12133
|
-
return {
|
|
12134
|
-
pid: pid,
|
|
12135
|
-
status: status,
|
|
12136
|
-
protocol: protocol,
|
|
12137
|
-
};
|
|
12138
|
-
})];
|
|
12139
|
-
}
|
|
12140
|
-
});
|
|
12141
|
-
});
|
|
12142
|
-
},
|
|
12143
|
-
win32: function (port) {
|
|
12144
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
12145
|
-
var table, iPid, iStatus, iProtocol;
|
|
12146
|
-
return __generator(this, function (_a) {
|
|
12147
|
-
switch (_a.label) {
|
|
12148
|
-
case 0: return [4 /*yield*/, exec("netstat -a -n -o | findstr :".concat(port))];
|
|
12149
|
-
case 1:
|
|
12150
|
-
table = _a.sent();
|
|
12151
|
-
iPid = 4;
|
|
12152
|
-
iStatus = 3;
|
|
12153
|
-
iProtocol = 0;
|
|
12154
|
-
return [2 /*return*/, table.map(function (row) {
|
|
12155
|
-
var _a;
|
|
12156
|
-
var pid = Number(row[iPid]);
|
|
12157
|
-
var status = row[iStatus];
|
|
12158
|
-
var protocol = (_a = row[iProtocol]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
12159
|
-
return {
|
|
12160
|
-
pid: pid,
|
|
12161
|
-
status: status,
|
|
12162
|
-
protocol: protocol,
|
|
12163
|
-
};
|
|
12164
|
-
})];
|
|
12165
|
-
}
|
|
12166
|
-
});
|
|
12167
|
-
});
|
|
12168
|
-
}
|
|
12169
|
-
};
|
|
12170
|
-
function exec(command) {
|
|
12171
|
-
var _a;
|
|
12172
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
12173
|
-
var shell, std;
|
|
12174
|
-
return __generator(this, function (_b) {
|
|
12175
|
-
switch (_b.label) {
|
|
12176
|
-
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
12177
|
-
silent: true,
|
|
12178
|
-
command: command,
|
|
12179
|
-
})];
|
|
12180
|
-
case 1:
|
|
12181
|
-
shell = _b.sent();
|
|
12182
|
-
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
12183
|
-
return [2 /*return*/, std
|
|
12184
|
-
.split('\n')
|
|
12185
|
-
.map(function (x) { return x.trim(); })
|
|
12186
|
-
.filter(Boolean)
|
|
12187
|
-
.map(function (line) {
|
|
12188
|
-
return line.split(' ').map(function (x) { return x.trim(); }).filter(Boolean);
|
|
12189
|
-
})
|
|
12190
|
-
.filter(function (x) { return x.length > 0; })];
|
|
12191
|
-
}
|
|
12192
|
-
});
|
|
12193
|
-
});
|
|
12194
|
-
}
|
|
12195
|
-
var Platforms = {
|
|
12196
|
-
darwin: PidResolver.nix,
|
|
12197
|
-
linux: PidResolver.nix,
|
|
12198
|
-
sunos: PidResolver.nix,
|
|
12199
|
-
freebsd: PidResolver.nix,
|
|
12200
|
-
win32: PidResolver.win32,
|
|
12201
|
-
};
|
|
12202
|
-
function findByPort(port) {
|
|
12203
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
12204
|
-
var arr;
|
|
12205
|
-
return __generator(this, function (_a) {
|
|
12206
|
-
switch (_a.label) {
|
|
12207
|
-
case 0: return [4 /*yield*/, Platforms[process.platform](port)];
|
|
12208
|
-
case 1:
|
|
12209
|
-
arr = _a.sent();
|
|
12210
|
-
return [2 /*return*/, (0, alot_1.default)(arr)
|
|
12211
|
-
.filter(function (x) { return Boolean(x.pid); })
|
|
12212
|
-
.distinctBy(function (x) { return x.pid; })
|
|
12213
|
-
.toArray()];
|
|
12214
|
-
}
|
|
12215
|
-
});
|
|
12216
|
-
});
|
|
12217
|
-
}
|
|
12218
|
-
Net.findByPort = findByPort;
|
|
12219
|
-
;
|
|
12220
|
-
function killByPort(port) {
|
|
12221
|
-
return __awaiter(this, void 0, Promise, function () {
|
|
12222
|
-
var processes;
|
|
12223
|
-
var _this = this;
|
|
12224
|
-
return __generator(this, function (_a) {
|
|
12225
|
-
switch (_a.label) {
|
|
12226
|
-
case 0: return [4 /*yield*/, findByPort(port)];
|
|
12227
|
-
case 1:
|
|
12228
|
-
processes = _a.sent();
|
|
12229
|
-
return [4 /*yield*/, (0, alot_1.default)(processes).forEachAsync(function (x) { return __awaiter(_this, void 0, void 0, function () {
|
|
12230
|
-
return __generator(this, function (_a) {
|
|
12231
|
-
switch (_a.label) {
|
|
12232
|
-
case 0:
|
|
12233
|
-
if (!x.pid) return [3 /*break*/, 2];
|
|
12234
|
-
return [4 /*yield*/, PsList_1.PsList.kill(x.pid)];
|
|
12235
|
-
case 1:
|
|
12236
|
-
_a.sent();
|
|
12237
|
-
_a.label = 2;
|
|
12238
|
-
case 2: return [2 /*return*/];
|
|
12239
|
-
}
|
|
12240
|
-
});
|
|
12241
|
-
}); }).toArrayAsync()];
|
|
12242
|
-
case 2:
|
|
12243
|
-
_a.sent();
|
|
12244
|
-
return [2 /*return*/, processes];
|
|
12245
|
-
}
|
|
12246
|
-
});
|
|
12247
|
-
});
|
|
12248
|
-
}
|
|
12249
|
-
Net.killByPort = killByPort;
|
|
12250
|
-
})(Net = exports.Net || (exports.Net = {}));
|
|
12072
|
+
"use strict";
|
|
12073
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12074
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12075
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12076
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12077
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12078
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12079
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12080
|
+
});
|
|
12081
|
+
};
|
|
12082
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12083
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12084
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
12085
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
12086
|
+
function step(op) {
|
|
12087
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
12088
|
+
while (_) try {
|
|
12089
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
12090
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
12091
|
+
switch (op[0]) {
|
|
12092
|
+
case 0: case 1: t = op; break;
|
|
12093
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
12094
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
12095
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
12096
|
+
default:
|
|
12097
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
12098
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
12099
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
12100
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
12101
|
+
if (t[2]) _.ops.pop();
|
|
12102
|
+
_.trys.pop(); continue;
|
|
12103
|
+
}
|
|
12104
|
+
op = body.call(thisArg, _);
|
|
12105
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
12106
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
12107
|
+
}
|
|
12108
|
+
};
|
|
12109
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12110
|
+
exports.Net = void 0;
|
|
12111
|
+
var alot_1 = require("alot");
|
|
12112
|
+
var Shell_1 = _src_Shell;
|
|
12113
|
+
var PsList_1 = _src_ps_PsList;
|
|
12114
|
+
var Net;
|
|
12115
|
+
(function (Net) {
|
|
12116
|
+
var PidResolver = {
|
|
12117
|
+
nix: function (port) {
|
|
12118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12119
|
+
var table, iPid, iStatus, iProtocol;
|
|
12120
|
+
return __generator(this, function (_a) {
|
|
12121
|
+
switch (_a.label) {
|
|
12122
|
+
case 0: return [4 /*yield*/, exec("lsof -i :".concat(port))];
|
|
12123
|
+
case 1:
|
|
12124
|
+
table = _a.sent();
|
|
12125
|
+
iPid = 1;
|
|
12126
|
+
iStatus = 9;
|
|
12127
|
+
iProtocol = 7;
|
|
12128
|
+
return [2 /*return*/, table.map(function (row) {
|
|
12129
|
+
var _a, _b, _c;
|
|
12130
|
+
var pid = Number(row[iPid]);
|
|
12131
|
+
var status = (_a = row[iStatus]) !== null && _a !== void 0 ? _a : '';
|
|
12132
|
+
var protocol = (_c = (_b = row[iProtocol]) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'tcp';
|
|
12133
|
+
return {
|
|
12134
|
+
pid: pid,
|
|
12135
|
+
status: status,
|
|
12136
|
+
protocol: protocol,
|
|
12137
|
+
};
|
|
12138
|
+
})];
|
|
12139
|
+
}
|
|
12140
|
+
});
|
|
12141
|
+
});
|
|
12142
|
+
},
|
|
12143
|
+
win32: function (port) {
|
|
12144
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12145
|
+
var table, iPid, iStatus, iProtocol;
|
|
12146
|
+
return __generator(this, function (_a) {
|
|
12147
|
+
switch (_a.label) {
|
|
12148
|
+
case 0: return [4 /*yield*/, exec("netstat -a -n -o | findstr :".concat(port))];
|
|
12149
|
+
case 1:
|
|
12150
|
+
table = _a.sent();
|
|
12151
|
+
iPid = 4;
|
|
12152
|
+
iStatus = 3;
|
|
12153
|
+
iProtocol = 0;
|
|
12154
|
+
return [2 /*return*/, table.map(function (row) {
|
|
12155
|
+
var _a;
|
|
12156
|
+
var pid = Number(row[iPid]);
|
|
12157
|
+
var status = row[iStatus];
|
|
12158
|
+
var protocol = (_a = row[iProtocol]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
12159
|
+
return {
|
|
12160
|
+
pid: pid,
|
|
12161
|
+
status: status,
|
|
12162
|
+
protocol: protocol,
|
|
12163
|
+
};
|
|
12164
|
+
})];
|
|
12165
|
+
}
|
|
12166
|
+
});
|
|
12167
|
+
});
|
|
12168
|
+
}
|
|
12169
|
+
};
|
|
12170
|
+
function exec(command) {
|
|
12171
|
+
var _a;
|
|
12172
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
12173
|
+
var shell, std;
|
|
12174
|
+
return __generator(this, function (_b) {
|
|
12175
|
+
switch (_b.label) {
|
|
12176
|
+
case 0: return [4 /*yield*/, Shell_1.Shell.run({
|
|
12177
|
+
silent: true,
|
|
12178
|
+
command: command,
|
|
12179
|
+
})];
|
|
12180
|
+
case 1:
|
|
12181
|
+
shell = _b.sent();
|
|
12182
|
+
std = (_a = shell.std) === null || _a === void 0 ? void 0 : _a.join('');
|
|
12183
|
+
return [2 /*return*/, std
|
|
12184
|
+
.split('\n')
|
|
12185
|
+
.map(function (x) { return x.trim(); })
|
|
12186
|
+
.filter(Boolean)
|
|
12187
|
+
.map(function (line) {
|
|
12188
|
+
return line.split(' ').map(function (x) { return x.trim(); }).filter(Boolean);
|
|
12189
|
+
})
|
|
12190
|
+
.filter(function (x) { return x.length > 0; })];
|
|
12191
|
+
}
|
|
12192
|
+
});
|
|
12193
|
+
});
|
|
12194
|
+
}
|
|
12195
|
+
var Platforms = {
|
|
12196
|
+
darwin: PidResolver.nix,
|
|
12197
|
+
linux: PidResolver.nix,
|
|
12198
|
+
sunos: PidResolver.nix,
|
|
12199
|
+
freebsd: PidResolver.nix,
|
|
12200
|
+
win32: PidResolver.win32,
|
|
12201
|
+
};
|
|
12202
|
+
function findByPort(port) {
|
|
12203
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
12204
|
+
var arr;
|
|
12205
|
+
return __generator(this, function (_a) {
|
|
12206
|
+
switch (_a.label) {
|
|
12207
|
+
case 0: return [4 /*yield*/, Platforms[process.platform](port)];
|
|
12208
|
+
case 1:
|
|
12209
|
+
arr = _a.sent();
|
|
12210
|
+
return [2 /*return*/, (0, alot_1.default)(arr)
|
|
12211
|
+
.filter(function (x) { return Boolean(x.pid); })
|
|
12212
|
+
.distinctBy(function (x) { return x.pid; })
|
|
12213
|
+
.toArray()];
|
|
12214
|
+
}
|
|
12215
|
+
});
|
|
12216
|
+
});
|
|
12217
|
+
}
|
|
12218
|
+
Net.findByPort = findByPort;
|
|
12219
|
+
;
|
|
12220
|
+
function killByPort(port) {
|
|
12221
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
12222
|
+
var processes;
|
|
12223
|
+
var _this = this;
|
|
12224
|
+
return __generator(this, function (_a) {
|
|
12225
|
+
switch (_a.label) {
|
|
12226
|
+
case 0: return [4 /*yield*/, findByPort(port)];
|
|
12227
|
+
case 1:
|
|
12228
|
+
processes = _a.sent();
|
|
12229
|
+
return [4 /*yield*/, (0, alot_1.default)(processes).forEachAsync(function (x) { return __awaiter(_this, void 0, void 0, function () {
|
|
12230
|
+
return __generator(this, function (_a) {
|
|
12231
|
+
switch (_a.label) {
|
|
12232
|
+
case 0:
|
|
12233
|
+
if (!x.pid) return [3 /*break*/, 2];
|
|
12234
|
+
return [4 /*yield*/, PsList_1.PsList.kill(x.pid)];
|
|
12235
|
+
case 1:
|
|
12236
|
+
_a.sent();
|
|
12237
|
+
_a.label = 2;
|
|
12238
|
+
case 2: return [2 /*return*/];
|
|
12239
|
+
}
|
|
12240
|
+
});
|
|
12241
|
+
}); }).toArrayAsync()];
|
|
12242
|
+
case 2:
|
|
12243
|
+
_a.sent();
|
|
12244
|
+
return [2 /*return*/, processes];
|
|
12245
|
+
}
|
|
12246
|
+
});
|
|
12247
|
+
});
|
|
12248
|
+
}
|
|
12249
|
+
Net.killByPort = killByPort;
|
|
12250
|
+
})(Net = exports.Net || (exports.Net = {}));
|
|
12251
12251
|
;
|
|
12252
12252
|
|
|
12253
12253
|
function __isObj(x) {
|
|
@@ -12275,28 +12275,28 @@ var _src_util_restartSelf;
|
|
|
12275
12275
|
var exports = _src_util_restartSelf != null ? _src_util_restartSelf : {};
|
|
12276
12276
|
var module = { exports: exports };
|
|
12277
12277
|
|
|
12278
|
-
"use strict";
|
|
12279
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12280
|
-
exports.restartSelf = void 0;
|
|
12281
|
-
var Shell_1 = _src_Shell;
|
|
12282
|
-
function restartSelf() {
|
|
12283
|
-
var command = process
|
|
12284
|
-
.argv
|
|
12285
|
-
.map(function (x) { return x.includes(' ') ? "\"".concat(x, "\"") : x; })
|
|
12286
|
-
.join(' ');
|
|
12287
|
-
var shell = new Shell_1.Shell({
|
|
12288
|
-
command: command,
|
|
12289
|
-
detached: true,
|
|
12290
|
-
});
|
|
12291
|
-
shell.onStart(function () {
|
|
12292
|
-
console.log('Exit self.');
|
|
12293
|
-
process.exit();
|
|
12294
|
-
});
|
|
12295
|
-
console.log('Cloning this process.');
|
|
12296
|
-
shell.run();
|
|
12297
|
-
}
|
|
12298
|
-
exports.restartSelf = restartSelf;
|
|
12299
|
-
;
|
|
12278
|
+
"use strict";
|
|
12279
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12280
|
+
exports.restartSelf = void 0;
|
|
12281
|
+
var Shell_1 = _src_Shell;
|
|
12282
|
+
function restartSelf() {
|
|
12283
|
+
var command = process
|
|
12284
|
+
.argv
|
|
12285
|
+
.map(function (x) { return x.includes(' ') ? "\"".concat(x, "\"") : x; })
|
|
12286
|
+
.join(' ');
|
|
12287
|
+
var shell = new Shell_1.Shell({
|
|
12288
|
+
command: command,
|
|
12289
|
+
detached: true,
|
|
12290
|
+
});
|
|
12291
|
+
shell.onStart(function () {
|
|
12292
|
+
console.log('Exit self.');
|
|
12293
|
+
process.exit();
|
|
12294
|
+
});
|
|
12295
|
+
console.log('Cloning this process.');
|
|
12296
|
+
shell.run();
|
|
12297
|
+
}
|
|
12298
|
+
exports.restartSelf = restartSelf;
|
|
12299
|
+
;
|
|
12300
12300
|
;
|
|
12301
12301
|
|
|
12302
12302
|
function __isObj(x) {
|
|
@@ -12315,24 +12315,24 @@ exports.restartSelf = restartSelf;
|
|
|
12315
12315
|
|
|
12316
12316
|
// end:source ./ModuleSimplified.js
|
|
12317
12317
|
|
|
12318
|
-
"use strict";
|
|
12319
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12320
|
-
exports.ShellUtils = exports.run = exports.Shell = exports.restartSelf = void 0;
|
|
12321
|
-
var Net_1 = _src_ps_Net;
|
|
12322
|
-
var PsList_1 = _src_ps_PsList;
|
|
12323
|
-
var Shell_1 = _src_Shell;
|
|
12324
|
-
Object.defineProperty(exports, "Shell", { enumerable: true, get: function () { return Shell_1.Shell; } });
|
|
12325
|
-
var restartSelf_1 = _src_util_restartSelf;
|
|
12326
|
-
Object.defineProperty(exports, "restartSelf", { enumerable: true, get: function () { return restartSelf_1.restartSelf; } });
|
|
12327
|
-
exports.run = Shell_1.Shell.run;
|
|
12328
|
-
exports.ShellUtils = {
|
|
12329
|
-
process: {
|
|
12330
|
-
getAll: PsList_1.PsList.getAll,
|
|
12331
|
-
getByPort: Net_1.Net.findByPort,
|
|
12332
|
-
kill: PsList_1.PsList.kill,
|
|
12333
|
-
killByPort: Net_1.Net.killByPort,
|
|
12334
|
-
}
|
|
12335
|
-
};
|
|
12318
|
+
"use strict";
|
|
12319
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12320
|
+
exports.ShellUtils = exports.run = exports.Shell = exports.restartSelf = void 0;
|
|
12321
|
+
var Net_1 = _src_ps_Net;
|
|
12322
|
+
var PsList_1 = _src_ps_PsList;
|
|
12323
|
+
var Shell_1 = _src_Shell;
|
|
12324
|
+
Object.defineProperty(exports, "Shell", { enumerable: true, get: function () { return Shell_1.Shell; } });
|
|
12325
|
+
var restartSelf_1 = _src_util_restartSelf;
|
|
12326
|
+
Object.defineProperty(exports, "restartSelf", { enumerable: true, get: function () { return restartSelf_1.restartSelf; } });
|
|
12327
|
+
exports.run = Shell_1.Shell.run;
|
|
12328
|
+
exports.ShellUtils = {
|
|
12329
|
+
process: {
|
|
12330
|
+
getAll: PsList_1.PsList.getAll,
|
|
12331
|
+
getByPort: Net_1.Net.findByPort,
|
|
12332
|
+
kill: PsList_1.PsList.kill,
|
|
12333
|
+
killByPort: Net_1.Net.killByPort,
|
|
12334
|
+
}
|
|
12335
|
+
};
|
|
12336
12336
|
|
|
12337
12337
|
|
|
12338
12338
|
}());
|