aurora-langium 0.3.0 → 0.3.2

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.
@@ -1118,8 +1118,8 @@ var require_semaphore = __commonJS({
1118
1118
  this._waiting = [];
1119
1119
  }
1120
1120
  lock(thunk) {
1121
- return new Promise((resolve3, reject2) => {
1122
- this._waiting.push({ thunk, resolve: resolve3, reject: reject2 });
1121
+ return new Promise((resolve2, reject2) => {
1122
+ this._waiting.push({ thunk, resolve: resolve2, reject: reject2 });
1123
1123
  this.runNext();
1124
1124
  });
1125
1125
  }
@@ -1705,7 +1705,7 @@ var require_connection = __commonJS({
1705
1705
  }
1706
1706
  }
1707
1707
  Trace2.fromString = fromString;
1708
- function toString4(value) {
1708
+ function toString3(value) {
1709
1709
  switch (value) {
1710
1710
  case Trace2.Off:
1711
1711
  return "off";
@@ -1719,7 +1719,7 @@ var require_connection = __commonJS({
1719
1719
  return "off";
1720
1720
  }
1721
1721
  }
1722
- Trace2.toString = toString4;
1722
+ Trace2.toString = toString3;
1723
1723
  })(Trace || (exports2.Trace = Trace = {}));
1724
1724
  var TraceFormat;
1725
1725
  (function(TraceFormat2) {
@@ -2614,9 +2614,9 @@ ${JSON.stringify(message, null, 4)}`);
2614
2614
  if (typeof cancellationStrategy.sender.enableCancellation === "function") {
2615
2615
  cancellationStrategy.sender.enableCancellation(requestMessage);
2616
2616
  }
2617
- return new Promise(async (resolve3, reject2) => {
2617
+ return new Promise(async (resolve2, reject2) => {
2618
2618
  const resolveWithCleanup = (r) => {
2619
- resolve3(r);
2619
+ resolve2(r);
2620
2620
  cancellationStrategy.sender.cleanup(id);
2621
2621
  disposable == null ? void 0 : disposable.dispose();
2622
2622
  };
@@ -3027,10 +3027,10 @@ var require_ril = __commonJS({
3027
3027
  return api_1.Disposable.create(() => this.stream.off("end", listener));
3028
3028
  }
3029
3029
  write(data, encoding) {
3030
- return new Promise((resolve3, reject2) => {
3030
+ return new Promise((resolve2, reject2) => {
3031
3031
  const callback = (error) => {
3032
3032
  if (error === void 0 || error === null) {
3033
- resolve3();
3033
+ resolve2();
3034
3034
  } else {
3035
3035
  reject2(error);
3036
3036
  }
@@ -3137,7 +3137,7 @@ var require_main = __commonJS({
3137
3137
  exports2.createMessageConnection = exports2.createServerSocketTransport = exports2.createClientSocketTransport = exports2.createServerPipeTransport = exports2.createClientPipeTransport = exports2.generateRandomPipeName = exports2.StreamMessageWriter = exports2.StreamMessageReader = exports2.SocketMessageWriter = exports2.SocketMessageReader = exports2.PortMessageWriter = exports2.PortMessageReader = exports2.IPCMessageWriter = exports2.IPCMessageReader = void 0;
3138
3138
  var ril_1 = require_ril();
3139
3139
  ril_1.default.install();
3140
- var path4 = require("path");
3140
+ var path2 = require("path");
3141
3141
  var os2 = require("os");
3142
3142
  var crypto_1 = require("crypto");
3143
3143
  var net_1 = require("net");
@@ -3273,9 +3273,9 @@ var require_main = __commonJS({
3273
3273
  }
3274
3274
  let result;
3275
3275
  if (XDG_RUNTIME_DIR) {
3276
- result = path4.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
3276
+ result = path2.join(XDG_RUNTIME_DIR, `vscode-ipc-${randomSuffix}.sock`);
3277
3277
  } else {
3278
- result = path4.join(os2.tmpdir(), `vscode-${randomSuffix}.sock`);
3278
+ result = path2.join(os2.tmpdir(), `vscode-${randomSuffix}.sock`);
3279
3279
  }
3280
3280
  const limit = safeIpcPathLengths.get(process.platform);
3281
3281
  if (limit !== void 0 && result.length > limit) {
@@ -3286,10 +3286,10 @@ var require_main = __commonJS({
3286
3286
  exports2.generateRandomPipeName = generateRandomPipeName;
3287
3287
  function createClientPipeTransport(pipeName, encoding = "utf-8") {
3288
3288
  let connectResolve;
3289
- const connected = new Promise((resolve3, _reject) => {
3290
- connectResolve = resolve3;
3289
+ const connected = new Promise((resolve2, _reject) => {
3290
+ connectResolve = resolve2;
3291
3291
  });
3292
- return new Promise((resolve3, reject2) => {
3292
+ return new Promise((resolve2, reject2) => {
3293
3293
  let server = (0, net_1.createServer)((socket) => {
3294
3294
  server.close();
3295
3295
  connectResolve([
@@ -3300,7 +3300,7 @@ var require_main = __commonJS({
3300
3300
  server.on("error", reject2);
3301
3301
  server.listen(pipeName, () => {
3302
3302
  server.removeListener("error", reject2);
3303
- resolve3({
3303
+ resolve2({
3304
3304
  onConnected: () => {
3305
3305
  return connected;
3306
3306
  }
@@ -3319,10 +3319,10 @@ var require_main = __commonJS({
3319
3319
  exports2.createServerPipeTransport = createServerPipeTransport;
3320
3320
  function createClientSocketTransport(port, encoding = "utf-8") {
3321
3321
  let connectResolve;
3322
- const connected = new Promise((resolve3, _reject) => {
3323
- connectResolve = resolve3;
3322
+ const connected = new Promise((resolve2, _reject) => {
3323
+ connectResolve = resolve2;
3324
3324
  });
3325
- return new Promise((resolve3, reject2) => {
3325
+ return new Promise((resolve2, reject2) => {
3326
3326
  const server = (0, net_1.createServer)((socket) => {
3327
3327
  server.close();
3328
3328
  connectResolve([
@@ -3333,7 +3333,7 @@ var require_main = __commonJS({
3333
3333
  server.on("error", reject2);
3334
3334
  server.listen(port, "127.0.0.1", () => {
3335
3335
  server.removeListener("error", reject2);
3336
- resolve3({
3336
+ resolve2({
3337
3337
  onConnected: () => {
3338
3338
  return connected;
3339
3339
  }
@@ -3631,8 +3631,8 @@ var require_main2 = __commonJS({
3631
3631
  }
3632
3632
  Diagnostic3.is = is;
3633
3633
  })(Diagnostic2 || (exports3.Diagnostic = Diagnostic2 = {}));
3634
- var Command3;
3635
- (function(Command4) {
3634
+ var Command2;
3635
+ (function(Command3) {
3636
3636
  function create(title, command) {
3637
3637
  var args = [];
3638
3638
  for (var _i = 2; _i < arguments.length; _i++) {
@@ -3644,13 +3644,13 @@ var require_main2 = __commonJS({
3644
3644
  }
3645
3645
  return result;
3646
3646
  }
3647
- Command4.create = create;
3647
+ Command3.create = create;
3648
3648
  function is(value) {
3649
3649
  var candidate = value;
3650
3650
  return Is2.defined(candidate) && Is2.string(candidate.title) && Is2.string(candidate.command);
3651
3651
  }
3652
- Command4.is = is;
3653
- })(Command3 || (exports3.Command = Command3 = {}));
3652
+ Command3.is = is;
3653
+ })(Command2 || (exports3.Command = Command2 = {}));
3654
3654
  var TextEdit2;
3655
3655
  (function(TextEdit3) {
3656
3656
  function replace(range, newText) {
@@ -4427,7 +4427,7 @@ var require_main2 = __commonJS({
4427
4427
  if (typeof kindOrCommandOrEdit === "string") {
4428
4428
  checkKind = false;
4429
4429
  result.kind = kindOrCommandOrEdit;
4430
- } else if (Command3.is(kindOrCommandOrEdit)) {
4430
+ } else if (Command2.is(kindOrCommandOrEdit)) {
4431
4431
  result.command = kindOrCommandOrEdit;
4432
4432
  } else {
4433
4433
  result.edit = kindOrCommandOrEdit;
@@ -4440,7 +4440,7 @@ var require_main2 = __commonJS({
4440
4440
  CodeAction3.create = create;
4441
4441
  function is(value) {
4442
4442
  var candidate = value;
4443
- return candidate && Is2.string(candidate.title) && (candidate.diagnostics === void 0 || Is2.typedArray(candidate.diagnostics, Diagnostic2.is)) && (candidate.kind === void 0 || Is2.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command3.is(candidate.command)) && (candidate.isPreferred === void 0 || Is2.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit2.is(candidate.edit));
4443
+ return candidate && Is2.string(candidate.title) && (candidate.diagnostics === void 0 || Is2.typedArray(candidate.diagnostics, Diagnostic2.is)) && (candidate.kind === void 0 || Is2.string(candidate.kind)) && (candidate.edit !== void 0 || candidate.command !== void 0) && (candidate.command === void 0 || Command2.is(candidate.command)) && (candidate.isPreferred === void 0 || Is2.boolean(candidate.isPreferred)) && (candidate.edit === void 0 || WorkspaceEdit2.is(candidate.edit));
4444
4444
  }
4445
4445
  CodeAction3.is = is;
4446
4446
  })(CodeAction2 || (exports3.CodeAction = CodeAction2 = {}));
@@ -4456,7 +4456,7 @@ var require_main2 = __commonJS({
4456
4456
  CodeLens3.create = create;
4457
4457
  function is(value) {
4458
4458
  var candidate = value;
4459
- return Is2.defined(candidate) && Range2.is(candidate.range) && (Is2.undefined(candidate.command) || Command3.is(candidate.command));
4459
+ return Is2.defined(candidate) && Range2.is(candidate.range) && (Is2.undefined(candidate.command) || Command2.is(candidate.command));
4460
4460
  }
4461
4461
  CodeLens3.is = is;
4462
4462
  })(CodeLens2 || (exports3.CodeLens = CodeLens2 = {}));
@@ -4608,7 +4608,7 @@ var require_main2 = __commonJS({
4608
4608
  InlayHintLabelPart3.create = create;
4609
4609
  function is(value) {
4610
4610
  var candidate = value;
4611
- return Is2.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is2.string(candidate.tooltip) || MarkupContent2.is(candidate.tooltip)) && (candidate.location === void 0 || Location3.is(candidate.location)) && (candidate.command === void 0 || Command3.is(candidate.command));
4611
+ return Is2.objectLiteral(candidate) && (candidate.tooltip === void 0 || Is2.string(candidate.tooltip) || MarkupContent2.is(candidate.tooltip)) && (candidate.location === void 0 || Location3.is(candidate.location)) && (candidate.command === void 0 || Command2.is(candidate.command));
4612
4612
  }
4613
4613
  InlayHintLabelPart3.is = is;
4614
4614
  })(InlayHintLabelPart2 || (exports3.InlayHintLabelPart = InlayHintLabelPart2 = {}));
@@ -4849,7 +4849,7 @@ var require_main2 = __commonJS({
4849
4849
  );
4850
4850
  var Is2;
4851
4851
  (function(Is3) {
4852
- var toString4 = Object.prototype.toString;
4852
+ var toString3 = Object.prototype.toString;
4853
4853
  function defined(value) {
4854
4854
  return typeof value !== "undefined";
4855
4855
  }
@@ -4863,27 +4863,27 @@ var require_main2 = __commonJS({
4863
4863
  }
4864
4864
  Is3.boolean = boolean;
4865
4865
  function string(value) {
4866
- return toString4.call(value) === "[object String]";
4866
+ return toString3.call(value) === "[object String]";
4867
4867
  }
4868
4868
  Is3.string = string;
4869
4869
  function number(value) {
4870
- return toString4.call(value) === "[object Number]";
4870
+ return toString3.call(value) === "[object Number]";
4871
4871
  }
4872
4872
  Is3.number = number;
4873
4873
  function numberRange(value, min2, max) {
4874
- return toString4.call(value) === "[object Number]" && min2 <= value && value <= max;
4874
+ return toString3.call(value) === "[object Number]" && min2 <= value && value <= max;
4875
4875
  }
4876
4876
  Is3.numberRange = numberRange;
4877
4877
  function integer3(value) {
4878
- return toString4.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
4878
+ return toString3.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
4879
4879
  }
4880
4880
  Is3.integer = integer3;
4881
4881
  function uinteger3(value) {
4882
- return toString4.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
4882
+ return toString3.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
4883
4883
  }
4884
4884
  Is3.uinteger = uinteger3;
4885
4885
  function func(value) {
4886
- return toString4.call(value) === "[object Function]";
4886
+ return toString3.call(value) === "[object Function]";
4887
4887
  }
4888
4888
  Is3.func = func;
4889
4889
  function objectLiteral(value) {
@@ -8130,8 +8130,8 @@ var require_server = __commonJS({
8130
8130
  if (value instanceof Promise) {
8131
8131
  return value;
8132
8132
  } else if (Is2.thenable(value)) {
8133
- return new Promise((resolve3, reject2) => {
8134
- value.then((resolved) => resolve3(resolved), (error) => reject2(error));
8133
+ return new Promise((resolve2, reject2) => {
8134
+ value.then((resolved) => resolve2(resolved), (error) => reject2(error));
8135
8135
  });
8136
8136
  } else {
8137
8137
  return Promise.resolve(value);
@@ -8376,8 +8376,8 @@ var require_files = __commonJS({
8376
8376
  Object.defineProperty(exports2, "__esModule", { value: true });
8377
8377
  exports2.resolveModulePath = exports2.FileSystem = exports2.resolveGlobalYarnPath = exports2.resolveGlobalNodePath = exports2.resolve = exports2.uriToFilePath = void 0;
8378
8378
  var url = require("url");
8379
- var path4 = require("path");
8380
- var fs5 = require("fs");
8379
+ var path2 = require("path");
8380
+ var fs3 = require("fs");
8381
8381
  var child_process_1 = require("child_process");
8382
8382
  function uriToFilePath(uri) {
8383
8383
  let parsed = url.parse(uri);
@@ -8395,13 +8395,13 @@ var require_files = __commonJS({
8395
8395
  segments.shift();
8396
8396
  }
8397
8397
  }
8398
- return path4.normalize(segments.join("/"));
8398
+ return path2.normalize(segments.join("/"));
8399
8399
  }
8400
8400
  exports2.uriToFilePath = uriToFilePath;
8401
8401
  function isWindows() {
8402
8402
  return process.platform === "win32";
8403
8403
  }
8404
- function resolve3(moduleName, nodePath, cwd, tracer) {
8404
+ function resolve2(moduleName, nodePath, cwd, tracer) {
8405
8405
  const nodePathKey = "NODE_PATH";
8406
8406
  const app = [
8407
8407
  "var p = process;",
@@ -8420,13 +8420,13 @@ var require_files = __commonJS({
8420
8420
  "}",
8421
8421
  "});"
8422
8422
  ].join("");
8423
- return new Promise((resolve4, reject2) => {
8423
+ return new Promise((resolve3, reject2) => {
8424
8424
  let env2 = process.env;
8425
8425
  let newEnv = /* @__PURE__ */ Object.create(null);
8426
8426
  Object.keys(env2).forEach((key) => newEnv[key] = env2[key]);
8427
- if (nodePath && fs5.existsSync(nodePath)) {
8427
+ if (nodePath && fs3.existsSync(nodePath)) {
8428
8428
  if (newEnv[nodePathKey]) {
8429
- newEnv[nodePathKey] = nodePath + path4.delimiter + newEnv[nodePathKey];
8429
+ newEnv[nodePathKey] = nodePath + path2.delimiter + newEnv[nodePathKey];
8430
8430
  } else {
8431
8431
  newEnv[nodePathKey] = nodePath;
8432
8432
  }
@@ -8452,7 +8452,7 @@ var require_files = __commonJS({
8452
8452
  if (message2.c === "r") {
8453
8453
  cp.send({ c: "e" });
8454
8454
  if (message2.s) {
8455
- resolve4(message2.r);
8455
+ resolve3(message2.r);
8456
8456
  } else {
8457
8457
  reject2(new Error(`Failed to resolve module: ${moduleName}`));
8458
8458
  }
@@ -8468,7 +8468,7 @@ var require_files = __commonJS({
8468
8468
  }
8469
8469
  });
8470
8470
  }
8471
- exports2.resolve = resolve3;
8471
+ exports2.resolve = resolve2;
8472
8472
  function resolveGlobalNodePath(tracer) {
8473
8473
  let npmCommand = "npm";
8474
8474
  const env2 = /* @__PURE__ */ Object.create(null);
@@ -8499,9 +8499,9 @@ var require_files = __commonJS({
8499
8499
  }
8500
8500
  if (prefix.length > 0) {
8501
8501
  if (isWindows()) {
8502
- return path4.join(prefix, "node_modules");
8502
+ return path2.join(prefix, "node_modules");
8503
8503
  } else {
8504
- return path4.join(prefix, "lib", "node_modules");
8504
+ return path2.join(prefix, "lib", "node_modules");
8505
8505
  }
8506
8506
  }
8507
8507
  return void 0;
@@ -8541,7 +8541,7 @@ var require_files = __commonJS({
8541
8541
  try {
8542
8542
  let yarn = JSON.parse(line);
8543
8543
  if (yarn.type === "log") {
8544
- return path4.join(yarn.data, "node_modules");
8544
+ return path2.join(yarn.data, "node_modules");
8545
8545
  }
8546
8546
  } catch (e) {
8547
8547
  }
@@ -8564,36 +8564,36 @@ var require_files = __commonJS({
8564
8564
  if (process.platform === "win32") {
8565
8565
  _isCaseSensitive = false;
8566
8566
  } else {
8567
- _isCaseSensitive = !fs5.existsSync(__filename.toUpperCase()) || !fs5.existsSync(__filename.toLowerCase());
8567
+ _isCaseSensitive = !fs3.existsSync(__filename.toUpperCase()) || !fs3.existsSync(__filename.toLowerCase());
8568
8568
  }
8569
8569
  return _isCaseSensitive;
8570
8570
  }
8571
8571
  FileSystem2.isCaseSensitive = isCaseSensitive;
8572
8572
  function isParent(parent, child) {
8573
8573
  if (isCaseSensitive()) {
8574
- return path4.normalize(child).indexOf(path4.normalize(parent)) === 0;
8574
+ return path2.normalize(child).indexOf(path2.normalize(parent)) === 0;
8575
8575
  } else {
8576
- return path4.normalize(child).toLowerCase().indexOf(path4.normalize(parent).toLowerCase()) === 0;
8576
+ return path2.normalize(child).toLowerCase().indexOf(path2.normalize(parent).toLowerCase()) === 0;
8577
8577
  }
8578
8578
  }
8579
8579
  FileSystem2.isParent = isParent;
8580
8580
  })(FileSystem || (exports2.FileSystem = FileSystem = {}));
8581
8581
  function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
8582
8582
  if (nodePath) {
8583
- if (!path4.isAbsolute(nodePath)) {
8584
- nodePath = path4.join(workspaceRoot, nodePath);
8583
+ if (!path2.isAbsolute(nodePath)) {
8584
+ nodePath = path2.join(workspaceRoot, nodePath);
8585
8585
  }
8586
- return resolve3(moduleName, nodePath, nodePath, tracer).then((value) => {
8586
+ return resolve2(moduleName, nodePath, nodePath, tracer).then((value) => {
8587
8587
  if (FileSystem.isParent(nodePath, value)) {
8588
8588
  return value;
8589
8589
  } else {
8590
8590
  return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
8591
8591
  }
8592
8592
  }).then(void 0, (_error) => {
8593
- return resolve3(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
8593
+ return resolve2(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
8594
8594
  });
8595
8595
  } else {
8596
- return resolve3(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
8596
+ return resolve2(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
8597
8597
  }
8598
8598
  }
8599
8599
  exports2.resolveModulePath = resolveModulePath;
@@ -9502,8 +9502,8 @@ var require_async = __commonJS({
9502
9502
  var Deferred2 = class {
9503
9503
  constructor() {
9504
9504
  this._state = "unresolved";
9505
- this.promise = new Promise((resolve3, reject2) => {
9506
- this.resolve = resolve3;
9505
+ this.promise = new Promise((resolve2, reject2) => {
9506
+ this.resolve = resolve2;
9507
9507
  this.reject = reject2;
9508
9508
  });
9509
9509
  this.promise.then((res) => this._state = "resolved", (rej) => this._state = "rejected");
@@ -12575,7 +12575,7 @@ var require_context = __commonJS({
12575
12575
  Object.defineProperty(exports2, "__esModule", { value: true });
12576
12576
  exports2.Context = void 0;
12577
12577
  var id_1 = require_id();
12578
- var Context2 = class {
12578
+ var Context = class {
12579
12579
  constructor(container) {
12580
12580
  __publicField(this, "id");
12581
12581
  __publicField(this, "container");
@@ -12591,7 +12591,7 @@ var require_context = __commonJS({
12591
12591
  this.currentRequest = currentRequest;
12592
12592
  }
12593
12593
  };
12594
- exports2.Context = Context2;
12594
+ exports2.Context = Context;
12595
12595
  }
12596
12596
  });
12597
12597
 
@@ -13435,7 +13435,7 @@ var require_resolver = __commonJS({
13435
13435
  };
13436
13436
  }();
13437
13437
  Object.defineProperty(exports2, "__esModule", { value: true });
13438
- exports2.resolve = resolve3;
13438
+ exports2.resolve = resolve2;
13439
13439
  var ERROR_MSGS = __importStar(require_error_msgs());
13440
13440
  var literal_types_1 = require_literal_types();
13441
13441
  var planner_1 = require_planner();
@@ -13581,7 +13581,7 @@ var require_resolver = __commonJS({
13581
13581
  };
13582
13582
  return containersIterator;
13583
13583
  };
13584
- function resolve3(context) {
13584
+ function resolve2(context) {
13585
13585
  const resolveRequestFunction = _resolveRequest(context.plan.rootRequest.requestScope);
13586
13586
  return resolveRequestFunction(context.plan.rootRequest);
13587
13587
  }
@@ -16523,13 +16523,13 @@ var require_elk_bundled = __commonJS({
16523
16523
  this.id = id + 1;
16524
16524
  msg.id = id;
16525
16525
  var self2 = this;
16526
- return new Promise(function(resolve3, reject2) {
16526
+ return new Promise(function(resolve2, reject2) {
16527
16527
  self2.resolvers[id] = function(err, res) {
16528
16528
  if (err) {
16529
16529
  self2.convertGwtStyleError(err);
16530
16530
  reject2(err);
16531
16531
  } else {
16532
- resolve3(res);
16532
+ resolve2(res);
16533
16533
  }
16534
16534
  };
16535
16535
  self2.worker.postMessage(msg);
@@ -26764,7 +26764,7 @@ var require_elk_bundled = __commonJS({
26764
26764
  ++b.b;
26765
26765
  Ekb(a10.d, d);
26766
26766
  }
26767
- function fs5(a10, b) {
26767
+ function fs3(a10, b) {
26768
26768
  var c;
26769
26769
  c = (uCb(a10), a10).g;
26770
26770
  lCb(!!c);
@@ -45855,7 +45855,7 @@ var require_elk_bundled = __commonJS({
45855
45855
  function m5c(c, d) {
45856
45856
  var e, f, g10;
45857
45857
  try {
45858
- g10 = fs5(c.a, d);
45858
+ g10 = fs3(c.a, d);
45859
45859
  return g10;
45860
45860
  } catch (b) {
45861
45861
  b = ubb(b);
@@ -83785,7 +83785,7 @@ var require_elk_bundled = __commonJS({
83785
83785
  _2.Kb = function Azb(a10) {
83786
83786
  return CD(a10)[0];
83787
83787
  };
83788
- var NL2 = mdb(vke, "Collectors/lambda$28$Type", 1067);
83788
+ var NL = mdb(vke, "Collectors/lambda$28$Type", 1067);
83789
83789
  bcb(713, 1, {}, Czb);
83790
83790
  _2.Ce = function Dzb(a10, b) {
83791
83791
  return Bzb(a10, b);
@@ -105220,2806 +105220,12 @@ var require_elk_bundled = __commonJS({
105220
105220
  }
105221
105221
  });
105222
105222
 
105223
- // node_modules/commander/lib/error.js
105224
- var require_error = __commonJS({
105225
- "node_modules/commander/lib/error.js"(exports2) {
105226
- var CommanderError2 = class extends Error {
105227
- /**
105228
- * Constructs the CommanderError class
105229
- * @param {number} exitCode suggested exit code which could be used with process.exit
105230
- * @param {string} code an id string representing the error
105231
- * @param {string} message human-readable description of the error
105232
- * @constructor
105233
- */
105234
- constructor(exitCode, code, message) {
105235
- super(message);
105236
- Error.captureStackTrace(this, this.constructor);
105237
- this.name = this.constructor.name;
105238
- this.code = code;
105239
- this.exitCode = exitCode;
105240
- this.nestedError = void 0;
105241
- }
105242
- };
105243
- var InvalidArgumentError2 = class extends CommanderError2 {
105244
- /**
105245
- * Constructs the InvalidArgumentError class
105246
- * @param {string} [message] explanation of why argument is invalid
105247
- * @constructor
105248
- */
105249
- constructor(message) {
105250
- super(1, "commander.invalidArgument", message);
105251
- Error.captureStackTrace(this, this.constructor);
105252
- this.name = this.constructor.name;
105253
- }
105254
- };
105255
- exports2.CommanderError = CommanderError2;
105256
- exports2.InvalidArgumentError = InvalidArgumentError2;
105257
- }
105258
- });
105259
-
105260
- // node_modules/commander/lib/argument.js
105261
- var require_argument = __commonJS({
105262
- "node_modules/commander/lib/argument.js"(exports2) {
105263
- var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
105264
- var Argument2 = class {
105265
- /**
105266
- * Initialize a new command argument with the given name and description.
105267
- * The default is that the argument is required, and you can explicitly
105268
- * indicate this with <> around the name. Put [] around the name for an optional argument.
105269
- *
105270
- * @param {string} name
105271
- * @param {string} [description]
105272
- */
105273
- constructor(name, description) {
105274
- this.description = description || "";
105275
- this.variadic = false;
105276
- this.parseArg = void 0;
105277
- this.defaultValue = void 0;
105278
- this.defaultValueDescription = void 0;
105279
- this.argChoices = void 0;
105280
- switch (name[0]) {
105281
- case "<":
105282
- this.required = true;
105283
- this._name = name.slice(1, -1);
105284
- break;
105285
- case "[":
105286
- this.required = false;
105287
- this._name = name.slice(1, -1);
105288
- break;
105289
- default:
105290
- this.required = true;
105291
- this._name = name;
105292
- break;
105293
- }
105294
- if (this._name.length > 3 && this._name.slice(-3) === "...") {
105295
- this.variadic = true;
105296
- this._name = this._name.slice(0, -3);
105297
- }
105298
- }
105299
- /**
105300
- * Return argument name.
105301
- *
105302
- * @return {string}
105303
- */
105304
- name() {
105305
- return this._name;
105306
- }
105307
- /**
105308
- * @api private
105309
- */
105310
- _concatValue(value, previous) {
105311
- if (previous === this.defaultValue || !Array.isArray(previous)) {
105312
- return [value];
105313
- }
105314
- return previous.concat(value);
105315
- }
105316
- /**
105317
- * Set the default value, and optionally supply the description to be displayed in the help.
105318
- *
105319
- * @param {any} value
105320
- * @param {string} [description]
105321
- * @return {Argument}
105322
- */
105323
- default(value, description) {
105324
- this.defaultValue = value;
105325
- this.defaultValueDescription = description;
105326
- return this;
105327
- }
105328
- /**
105329
- * Set the custom handler for processing CLI command arguments into argument values.
105330
- *
105331
- * @param {Function} [fn]
105332
- * @return {Argument}
105333
- */
105334
- argParser(fn) {
105335
- this.parseArg = fn;
105336
- return this;
105337
- }
105338
- /**
105339
- * Only allow argument value to be one of choices.
105340
- *
105341
- * @param {string[]} values
105342
- * @return {Argument}
105343
- */
105344
- choices(values2) {
105345
- this.argChoices = values2.slice();
105346
- this.parseArg = (arg, previous) => {
105347
- if (!this.argChoices.includes(arg)) {
105348
- throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);
105349
- }
105350
- if (this.variadic) {
105351
- return this._concatValue(arg, previous);
105352
- }
105353
- return arg;
105354
- };
105355
- return this;
105356
- }
105357
- /**
105358
- * Make argument required.
105359
- */
105360
- argRequired() {
105361
- this.required = true;
105362
- return this;
105363
- }
105364
- /**
105365
- * Make argument optional.
105366
- */
105367
- argOptional() {
105368
- this.required = false;
105369
- return this;
105370
- }
105371
- };
105372
- function humanReadableArgName(arg) {
105373
- const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
105374
- return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
105375
- }
105376
- exports2.Argument = Argument2;
105377
- exports2.humanReadableArgName = humanReadableArgName;
105378
- }
105379
- });
105380
-
105381
- // node_modules/commander/lib/help.js
105382
- var require_help = __commonJS({
105383
- "node_modules/commander/lib/help.js"(exports2) {
105384
- var { humanReadableArgName } = require_argument();
105385
- var Help2 = class {
105386
- constructor() {
105387
- this.helpWidth = void 0;
105388
- this.sortSubcommands = false;
105389
- this.sortOptions = false;
105390
- this.showGlobalOptions = false;
105391
- }
105392
- /**
105393
- * Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one.
105394
- *
105395
- * @param {Command} cmd
105396
- * @returns {Command[]}
105397
- */
105398
- visibleCommands(cmd) {
105399
- const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden);
105400
- if (cmd._hasImplicitHelpCommand()) {
105401
- const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);
105402
- const helpCommand = cmd.createCommand(helpName).helpOption(false);
105403
- helpCommand.description(cmd._helpCommandDescription);
105404
- if (helpArgs)
105405
- helpCommand.arguments(helpArgs);
105406
- visibleCommands.push(helpCommand);
105407
- }
105408
- if (this.sortSubcommands) {
105409
- visibleCommands.sort((a2, b) => {
105410
- return a2.name().localeCompare(b.name());
105411
- });
105412
- }
105413
- return visibleCommands;
105414
- }
105415
- /**
105416
- * Compare options for sort.
105417
- *
105418
- * @param {Option} a
105419
- * @param {Option} b
105420
- * @returns number
105421
- */
105422
- compareOptions(a2, b) {
105423
- const getSortKey = (option2) => {
105424
- return option2.short ? option2.short.replace(/^-/, "") : option2.long.replace(/^--/, "");
105425
- };
105426
- return getSortKey(a2).localeCompare(getSortKey(b));
105427
- }
105428
- /**
105429
- * Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one.
105430
- *
105431
- * @param {Command} cmd
105432
- * @returns {Option[]}
105433
- */
105434
- visibleOptions(cmd) {
105435
- const visibleOptions = cmd.options.filter((option2) => !option2.hidden);
105436
- const showShortHelpFlag = cmd._hasHelpOption && cmd._helpShortFlag && !cmd._findOption(cmd._helpShortFlag);
105437
- const showLongHelpFlag = cmd._hasHelpOption && !cmd._findOption(cmd._helpLongFlag);
105438
- if (showShortHelpFlag || showLongHelpFlag) {
105439
- let helpOption;
105440
- if (!showShortHelpFlag) {
105441
- helpOption = cmd.createOption(cmd._helpLongFlag, cmd._helpDescription);
105442
- } else if (!showLongHelpFlag) {
105443
- helpOption = cmd.createOption(cmd._helpShortFlag, cmd._helpDescription);
105444
- } else {
105445
- helpOption = cmd.createOption(cmd._helpFlags, cmd._helpDescription);
105446
- }
105447
- visibleOptions.push(helpOption);
105448
- }
105449
- if (this.sortOptions) {
105450
- visibleOptions.sort(this.compareOptions);
105451
- }
105452
- return visibleOptions;
105453
- }
105454
- /**
105455
- * Get an array of the visible global options. (Not including help.)
105456
- *
105457
- * @param {Command} cmd
105458
- * @returns {Option[]}
105459
- */
105460
- visibleGlobalOptions(cmd) {
105461
- if (!this.showGlobalOptions)
105462
- return [];
105463
- const globalOptions = [];
105464
- for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
105465
- const visibleOptions = parentCmd.options.filter((option2) => !option2.hidden);
105466
- globalOptions.push(...visibleOptions);
105467
- }
105468
- if (this.sortOptions) {
105469
- globalOptions.sort(this.compareOptions);
105470
- }
105471
- return globalOptions;
105472
- }
105473
- /**
105474
- * Get an array of the arguments if any have a description.
105475
- *
105476
- * @param {Command} cmd
105477
- * @returns {Argument[]}
105478
- */
105479
- visibleArguments(cmd) {
105480
- if (cmd._argsDescription) {
105481
- cmd._args.forEach((argument) => {
105482
- argument.description = argument.description || cmd._argsDescription[argument.name()] || "";
105483
- });
105484
- }
105485
- if (cmd._args.find((argument) => argument.description)) {
105486
- return cmd._args;
105487
- }
105488
- return [];
105489
- }
105490
- /**
105491
- * Get the command term to show in the list of subcommands.
105492
- *
105493
- * @param {Command} cmd
105494
- * @returns {string}
105495
- */
105496
- subcommandTerm(cmd) {
105497
- const args = cmd._args.map((arg) => humanReadableArgName(arg)).join(" ");
105498
- return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + // simplistic check for non-help option
105499
- (args ? " " + args : "");
105500
- }
105501
- /**
105502
- * Get the option term to show in the list of options.
105503
- *
105504
- * @param {Option} option
105505
- * @returns {string}
105506
- */
105507
- optionTerm(option2) {
105508
- return option2.flags;
105509
- }
105510
- /**
105511
- * Get the argument term to show in the list of arguments.
105512
- *
105513
- * @param {Argument} argument
105514
- * @returns {string}
105515
- */
105516
- argumentTerm(argument) {
105517
- return argument.name();
105518
- }
105519
- /**
105520
- * Get the longest command term length.
105521
- *
105522
- * @param {Command} cmd
105523
- * @param {Help} helper
105524
- * @returns {number}
105525
- */
105526
- longestSubcommandTermLength(cmd, helper) {
105527
- return helper.visibleCommands(cmd).reduce((max, command) => {
105528
- return Math.max(max, helper.subcommandTerm(command).length);
105529
- }, 0);
105530
- }
105531
- /**
105532
- * Get the longest option term length.
105533
- *
105534
- * @param {Command} cmd
105535
- * @param {Help} helper
105536
- * @returns {number}
105537
- */
105538
- longestOptionTermLength(cmd, helper) {
105539
- return helper.visibleOptions(cmd).reduce((max, option2) => {
105540
- return Math.max(max, helper.optionTerm(option2).length);
105541
- }, 0);
105542
- }
105543
- /**
105544
- * Get the longest global option term length.
105545
- *
105546
- * @param {Command} cmd
105547
- * @param {Help} helper
105548
- * @returns {number}
105549
- */
105550
- longestGlobalOptionTermLength(cmd, helper) {
105551
- return helper.visibleGlobalOptions(cmd).reduce((max, option2) => {
105552
- return Math.max(max, helper.optionTerm(option2).length);
105553
- }, 0);
105554
- }
105555
- /**
105556
- * Get the longest argument term length.
105557
- *
105558
- * @param {Command} cmd
105559
- * @param {Help} helper
105560
- * @returns {number}
105561
- */
105562
- longestArgumentTermLength(cmd, helper) {
105563
- return helper.visibleArguments(cmd).reduce((max, argument) => {
105564
- return Math.max(max, helper.argumentTerm(argument).length);
105565
- }, 0);
105566
- }
105567
- /**
105568
- * Get the command usage to be displayed at the top of the built-in help.
105569
- *
105570
- * @param {Command} cmd
105571
- * @returns {string}
105572
- */
105573
- commandUsage(cmd) {
105574
- let cmdName = cmd._name;
105575
- if (cmd._aliases[0]) {
105576
- cmdName = cmdName + "|" + cmd._aliases[0];
105577
- }
105578
- let parentCmdNames = "";
105579
- for (let parentCmd = cmd.parent; parentCmd; parentCmd = parentCmd.parent) {
105580
- parentCmdNames = parentCmd.name() + " " + parentCmdNames;
105581
- }
105582
- return parentCmdNames + cmdName + " " + cmd.usage();
105583
- }
105584
- /**
105585
- * Get the description for the command.
105586
- *
105587
- * @param {Command} cmd
105588
- * @returns {string}
105589
- */
105590
- commandDescription(cmd) {
105591
- return cmd.description();
105592
- }
105593
- /**
105594
- * Get the subcommand summary to show in the list of subcommands.
105595
- * (Fallback to description for backwards compatibility.)
105596
- *
105597
- * @param {Command} cmd
105598
- * @returns {string}
105599
- */
105600
- subcommandDescription(cmd) {
105601
- return cmd.summary() || cmd.description();
105602
- }
105603
- /**
105604
- * Get the option description to show in the list of options.
105605
- *
105606
- * @param {Option} option
105607
- * @return {string}
105608
- */
105609
- optionDescription(option2) {
105610
- const extraInfo = [];
105611
- if (option2.argChoices) {
105612
- extraInfo.push(
105613
- // use stringify to match the display of the default value
105614
- `choices: ${option2.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
105615
- );
105616
- }
105617
- if (option2.defaultValue !== void 0) {
105618
- const showDefault = option2.required || option2.optional || option2.isBoolean() && typeof option2.defaultValue === "boolean";
105619
- if (showDefault) {
105620
- extraInfo.push(`default: ${option2.defaultValueDescription || JSON.stringify(option2.defaultValue)}`);
105621
- }
105622
- }
105623
- if (option2.presetArg !== void 0 && option2.optional) {
105624
- extraInfo.push(`preset: ${JSON.stringify(option2.presetArg)}`);
105625
- }
105626
- if (option2.envVar !== void 0) {
105627
- extraInfo.push(`env: ${option2.envVar}`);
105628
- }
105629
- if (extraInfo.length > 0) {
105630
- return `${option2.description} (${extraInfo.join(", ")})`;
105631
- }
105632
- return option2.description;
105633
- }
105634
- /**
105635
- * Get the argument description to show in the list of arguments.
105636
- *
105637
- * @param {Argument} argument
105638
- * @return {string}
105639
- */
105640
- argumentDescription(argument) {
105641
- const extraInfo = [];
105642
- if (argument.argChoices) {
105643
- extraInfo.push(
105644
- // use stringify to match the display of the default value
105645
- `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`
105646
- );
105647
- }
105648
- if (argument.defaultValue !== void 0) {
105649
- extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
105650
- }
105651
- if (extraInfo.length > 0) {
105652
- const extraDescripton = `(${extraInfo.join(", ")})`;
105653
- if (argument.description) {
105654
- return `${argument.description} ${extraDescripton}`;
105655
- }
105656
- return extraDescripton;
105657
- }
105658
- return argument.description;
105659
- }
105660
- /**
105661
- * Generate the built-in help text.
105662
- *
105663
- * @param {Command} cmd
105664
- * @param {Help} helper
105665
- * @returns {string}
105666
- */
105667
- formatHelp(cmd, helper) {
105668
- const termWidth = helper.padWidth(cmd, helper);
105669
- const helpWidth = helper.helpWidth || 80;
105670
- const itemIndentWidth = 2;
105671
- const itemSeparatorWidth = 2;
105672
- function formatItem(term, description) {
105673
- if (description) {
105674
- const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
105675
- return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
105676
- }
105677
- return term;
105678
- }
105679
- function formatList(textArray) {
105680
- return textArray.join("\n").replace(/^/gm, " ".repeat(itemIndentWidth));
105681
- }
105682
- let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
105683
- const commandDescription = helper.commandDescription(cmd);
105684
- if (commandDescription.length > 0) {
105685
- output = output.concat([helper.wrap(commandDescription, helpWidth, 0), ""]);
105686
- }
105687
- const argumentList = helper.visibleArguments(cmd).map((argument) => {
105688
- return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
105689
- });
105690
- if (argumentList.length > 0) {
105691
- output = output.concat(["Arguments:", formatList(argumentList), ""]);
105692
- }
105693
- const optionList = helper.visibleOptions(cmd).map((option2) => {
105694
- return formatItem(helper.optionTerm(option2), helper.optionDescription(option2));
105695
- });
105696
- if (optionList.length > 0) {
105697
- output = output.concat(["Options:", formatList(optionList), ""]);
105698
- }
105699
- if (this.showGlobalOptions) {
105700
- const globalOptionList = helper.visibleGlobalOptions(cmd).map((option2) => {
105701
- return formatItem(helper.optionTerm(option2), helper.optionDescription(option2));
105702
- });
105703
- if (globalOptionList.length > 0) {
105704
- output = output.concat(["Global Options:", formatList(globalOptionList), ""]);
105705
- }
105706
- }
105707
- const commandList = helper.visibleCommands(cmd).map((cmd2) => {
105708
- return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2));
105709
- });
105710
- if (commandList.length > 0) {
105711
- output = output.concat(["Commands:", formatList(commandList), ""]);
105712
- }
105713
- return output.join("\n");
105714
- }
105715
- /**
105716
- * Calculate the pad width from the maximum term length.
105717
- *
105718
- * @param {Command} cmd
105719
- * @param {Help} helper
105720
- * @returns {number}
105721
- */
105722
- padWidth(cmd, helper) {
105723
- return Math.max(
105724
- helper.longestOptionTermLength(cmd, helper),
105725
- helper.longestGlobalOptionTermLength(cmd, helper),
105726
- helper.longestSubcommandTermLength(cmd, helper),
105727
- helper.longestArgumentTermLength(cmd, helper)
105728
- );
105729
- }
105730
- /**
105731
- * Wrap the given string to width characters per line, with lines after the first indented.
105732
- * Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
105733
- *
105734
- * @param {string} str
105735
- * @param {number} width
105736
- * @param {number} indent
105737
- * @param {number} [minColumnWidth=40]
105738
- * @return {string}
105739
- *
105740
- */
105741
- wrap(str, width, indent, minColumnWidth = 40) {
105742
- const indents = " \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF";
105743
- const manualIndent = new RegExp(`[\\n][${indents}]+`);
105744
- if (str.match(manualIndent))
105745
- return str;
105746
- const columnWidth = width - indent;
105747
- if (columnWidth < minColumnWidth)
105748
- return str;
105749
- const leadingStr = str.slice(0, indent);
105750
- const columnText = str.slice(indent).replace("\r\n", "\n");
105751
- const indentString = " ".repeat(indent);
105752
- const zeroWidthSpace = "\u200B";
105753
- const breaks = `\\s${zeroWidthSpace}`;
105754
- const regex = new RegExp(`
105755
- |.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
105756
- const lines = columnText.match(regex) || [];
105757
- return leadingStr + lines.map((line, i) => {
105758
- if (line === "\n")
105759
- return "";
105760
- return (i > 0 ? indentString : "") + line.trimEnd();
105761
- }).join("\n");
105762
- }
105763
- };
105764
- exports2.Help = Help2;
105765
- }
105766
- });
105767
-
105768
- // node_modules/commander/lib/option.js
105769
- var require_option = __commonJS({
105770
- "node_modules/commander/lib/option.js"(exports2) {
105771
- var { InvalidArgumentError: InvalidArgumentError2 } = require_error();
105772
- var Option3 = class {
105773
- /**
105774
- * Initialize a new `Option` with the given `flags` and `description`.
105775
- *
105776
- * @param {string} flags
105777
- * @param {string} [description]
105778
- */
105779
- constructor(flags, description) {
105780
- this.flags = flags;
105781
- this.description = description || "";
105782
- this.required = flags.includes("<");
105783
- this.optional = flags.includes("[");
105784
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
105785
- this.mandatory = false;
105786
- const optionFlags = splitOptionFlags(flags);
105787
- this.short = optionFlags.shortFlag;
105788
- this.long = optionFlags.longFlag;
105789
- this.negate = false;
105790
- if (this.long) {
105791
- this.negate = this.long.startsWith("--no-");
105792
- }
105793
- this.defaultValue = void 0;
105794
- this.defaultValueDescription = void 0;
105795
- this.presetArg = void 0;
105796
- this.envVar = void 0;
105797
- this.parseArg = void 0;
105798
- this.hidden = false;
105799
- this.argChoices = void 0;
105800
- this.conflictsWith = [];
105801
- this.implied = void 0;
105802
- }
105803
- /**
105804
- * Set the default value, and optionally supply the description to be displayed in the help.
105805
- *
105806
- * @param {any} value
105807
- * @param {string} [description]
105808
- * @return {Option}
105809
- */
105810
- default(value, description) {
105811
- this.defaultValue = value;
105812
- this.defaultValueDescription = description;
105813
- return this;
105814
- }
105815
- /**
105816
- * Preset to use when option used without option-argument, especially optional but also boolean and negated.
105817
- * The custom processing (parseArg) is called.
105818
- *
105819
- * @example
105820
- * new Option('--color').default('GREYSCALE').preset('RGB');
105821
- * new Option('--donate [amount]').preset('20').argParser(parseFloat);
105822
- *
105823
- * @param {any} arg
105824
- * @return {Option}
105825
- */
105826
- preset(arg) {
105827
- this.presetArg = arg;
105828
- return this;
105829
- }
105830
- /**
105831
- * Add option name(s) that conflict with this option.
105832
- * An error will be displayed if conflicting options are found during parsing.
105833
- *
105834
- * @example
105835
- * new Option('--rgb').conflicts('cmyk');
105836
- * new Option('--js').conflicts(['ts', 'jsx']);
105837
- *
105838
- * @param {string | string[]} names
105839
- * @return {Option}
105840
- */
105841
- conflicts(names) {
105842
- this.conflictsWith = this.conflictsWith.concat(names);
105843
- return this;
105844
- }
105845
- /**
105846
- * Specify implied option values for when this option is set and the implied options are not.
105847
- *
105848
- * The custom processing (parseArg) is not called on the implied values.
105849
- *
105850
- * @example
105851
- * program
105852
- * .addOption(new Option('--log', 'write logging information to file'))
105853
- * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
105854
- *
105855
- * @param {Object} impliedOptionValues
105856
- * @return {Option}
105857
- */
105858
- implies(impliedOptionValues) {
105859
- let newImplied = impliedOptionValues;
105860
- if (typeof impliedOptionValues === "string") {
105861
- newImplied = { [impliedOptionValues]: true };
105862
- }
105863
- this.implied = Object.assign(this.implied || {}, newImplied);
105864
- return this;
105865
- }
105866
- /**
105867
- * Set environment variable to check for option value.
105868
- *
105869
- * An environment variable is only used if when processed the current option value is
105870
- * undefined, or the source of the current value is 'default' or 'config' or 'env'.
105871
- *
105872
- * @param {string} name
105873
- * @return {Option}
105874
- */
105875
- env(name) {
105876
- this.envVar = name;
105877
- return this;
105878
- }
105879
- /**
105880
- * Set the custom handler for processing CLI option arguments into option values.
105881
- *
105882
- * @param {Function} [fn]
105883
- * @return {Option}
105884
- */
105885
- argParser(fn) {
105886
- this.parseArg = fn;
105887
- return this;
105888
- }
105889
- /**
105890
- * Whether the option is mandatory and must have a value after parsing.
105891
- *
105892
- * @param {boolean} [mandatory=true]
105893
- * @return {Option}
105894
- */
105895
- makeOptionMandatory(mandatory = true) {
105896
- this.mandatory = !!mandatory;
105897
- return this;
105898
- }
105899
- /**
105900
- * Hide option in help.
105901
- *
105902
- * @param {boolean} [hide=true]
105903
- * @return {Option}
105904
- */
105905
- hideHelp(hide = true) {
105906
- this.hidden = !!hide;
105907
- return this;
105908
- }
105909
- /**
105910
- * @api private
105911
- */
105912
- _concatValue(value, previous) {
105913
- if (previous === this.defaultValue || !Array.isArray(previous)) {
105914
- return [value];
105915
- }
105916
- return previous.concat(value);
105917
- }
105918
- /**
105919
- * Only allow option value to be one of choices.
105920
- *
105921
- * @param {string[]} values
105922
- * @return {Option}
105923
- */
105924
- choices(values2) {
105925
- this.argChoices = values2.slice();
105926
- this.parseArg = (arg, previous) => {
105927
- if (!this.argChoices.includes(arg)) {
105928
- throw new InvalidArgumentError2(`Allowed choices are ${this.argChoices.join(", ")}.`);
105929
- }
105930
- if (this.variadic) {
105931
- return this._concatValue(arg, previous);
105932
- }
105933
- return arg;
105934
- };
105935
- return this;
105936
- }
105937
- /**
105938
- * Return option name.
105939
- *
105940
- * @return {string}
105941
- */
105942
- name() {
105943
- if (this.long) {
105944
- return this.long.replace(/^--/, "");
105945
- }
105946
- return this.short.replace(/^-/, "");
105947
- }
105948
- /**
105949
- * Return option name, in a camelcase format that can be used
105950
- * as a object attribute key.
105951
- *
105952
- * @return {string}
105953
- * @api private
105954
- */
105955
- attributeName() {
105956
- return camelcase(this.name().replace(/^no-/, ""));
105957
- }
105958
- /**
105959
- * Check if `arg` matches the short or long flag.
105960
- *
105961
- * @param {string} arg
105962
- * @return {boolean}
105963
- * @api private
105964
- */
105965
- is(arg) {
105966
- return this.short === arg || this.long === arg;
105967
- }
105968
- /**
105969
- * Return whether a boolean option.
105970
- *
105971
- * Options are one of boolean, negated, required argument, or optional argument.
105972
- *
105973
- * @return {boolean}
105974
- * @api private
105975
- */
105976
- isBoolean() {
105977
- return !this.required && !this.optional && !this.negate;
105978
- }
105979
- };
105980
- var DualOptions = class {
105981
- /**
105982
- * @param {Option[]} options
105983
- */
105984
- constructor(options) {
105985
- this.positiveOptions = /* @__PURE__ */ new Map();
105986
- this.negativeOptions = /* @__PURE__ */ new Map();
105987
- this.dualOptions = /* @__PURE__ */ new Set();
105988
- options.forEach((option2) => {
105989
- if (option2.negate) {
105990
- this.negativeOptions.set(option2.attributeName(), option2);
105991
- } else {
105992
- this.positiveOptions.set(option2.attributeName(), option2);
105993
- }
105994
- });
105995
- this.negativeOptions.forEach((value, key) => {
105996
- if (this.positiveOptions.has(key)) {
105997
- this.dualOptions.add(key);
105998
- }
105999
- });
106000
- }
106001
- /**
106002
- * Did the value come from the option, and not from possible matching dual option?
106003
- *
106004
- * @param {any} value
106005
- * @param {Option} option
106006
- * @returns {boolean}
106007
- */
106008
- valueFromOption(value, option2) {
106009
- const optionKey = option2.attributeName();
106010
- if (!this.dualOptions.has(optionKey))
106011
- return true;
106012
- const preset = this.negativeOptions.get(optionKey).presetArg;
106013
- const negativeValue = preset !== void 0 ? preset : false;
106014
- return option2.negate === (negativeValue === value);
106015
- }
106016
- };
106017
- function camelcase(str) {
106018
- return str.split("-").reduce((str2, word) => {
106019
- return str2 + word[0].toUpperCase() + word.slice(1);
106020
- });
106021
- }
106022
- function splitOptionFlags(flags) {
106023
- let shortFlag;
106024
- let longFlag;
106025
- const flagParts = flags.split(/[ |,]+/);
106026
- if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
106027
- shortFlag = flagParts.shift();
106028
- longFlag = flagParts.shift();
106029
- if (!shortFlag && /^-[^-]$/.test(longFlag)) {
106030
- shortFlag = longFlag;
106031
- longFlag = void 0;
106032
- }
106033
- return { shortFlag, longFlag };
106034
- }
106035
- exports2.Option = Option3;
106036
- exports2.splitOptionFlags = splitOptionFlags;
106037
- exports2.DualOptions = DualOptions;
106038
- }
106039
- });
106040
-
106041
- // node_modules/commander/lib/suggestSimilar.js
106042
- var require_suggestSimilar = __commonJS({
106043
- "node_modules/commander/lib/suggestSimilar.js"(exports2) {
106044
- var maxDistance = 3;
106045
- function editDistance(a2, b) {
106046
- if (Math.abs(a2.length - b.length) > maxDistance)
106047
- return Math.max(a2.length, b.length);
106048
- const d = [];
106049
- for (let i = 0; i <= a2.length; i++) {
106050
- d[i] = [i];
106051
- }
106052
- for (let j = 0; j <= b.length; j++) {
106053
- d[0][j] = j;
106054
- }
106055
- for (let j = 1; j <= b.length; j++) {
106056
- for (let i = 1; i <= a2.length; i++) {
106057
- let cost = 1;
106058
- if (a2[i - 1] === b[j - 1]) {
106059
- cost = 0;
106060
- } else {
106061
- cost = 1;
106062
- }
106063
- d[i][j] = Math.min(
106064
- d[i - 1][j] + 1,
106065
- // deletion
106066
- d[i][j - 1] + 1,
106067
- // insertion
106068
- d[i - 1][j - 1] + cost
106069
- // substitution
106070
- );
106071
- if (i > 1 && j > 1 && a2[i - 1] === b[j - 2] && a2[i - 2] === b[j - 1]) {
106072
- d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1);
106073
- }
106074
- }
106075
- }
106076
- return d[a2.length][b.length];
106077
- }
106078
- function suggestSimilar(word, candidates) {
106079
- if (!candidates || candidates.length === 0)
106080
- return "";
106081
- candidates = Array.from(new Set(candidates));
106082
- const searchingOptions = word.startsWith("--");
106083
- if (searchingOptions) {
106084
- word = word.slice(2);
106085
- candidates = candidates.map((candidate) => candidate.slice(2));
106086
- }
106087
- let similar = [];
106088
- let bestDistance = maxDistance;
106089
- const minSimilarity = 0.4;
106090
- candidates.forEach((candidate) => {
106091
- if (candidate.length <= 1)
106092
- return;
106093
- const distance = editDistance(word, candidate);
106094
- const length = Math.max(word.length, candidate.length);
106095
- const similarity = (length - distance) / length;
106096
- if (similarity > minSimilarity) {
106097
- if (distance < bestDistance) {
106098
- bestDistance = distance;
106099
- similar = [candidate];
106100
- } else if (distance === bestDistance) {
106101
- similar.push(candidate);
106102
- }
106103
- }
106104
- });
106105
- similar.sort((a2, b) => a2.localeCompare(b));
106106
- if (searchingOptions) {
106107
- similar = similar.map((candidate) => `--${candidate}`);
106108
- }
106109
- if (similar.length > 1) {
106110
- return `
106111
- (Did you mean one of ${similar.join(", ")}?)`;
106112
- }
106113
- if (similar.length === 1) {
106114
- return `
106115
- (Did you mean ${similar[0]}?)`;
106116
- }
106117
- return "";
106118
- }
106119
- exports2.suggestSimilar = suggestSimilar;
106120
- }
106121
- });
106122
-
106123
- // node_modules/commander/lib/command.js
106124
- var require_command = __commonJS({
106125
- "node_modules/commander/lib/command.js"(exports2) {
106126
- var EventEmitter = require("events").EventEmitter;
106127
- var childProcess = require("child_process");
106128
- var path4 = require("path");
106129
- var fs5 = require("fs");
106130
- var process3 = require("process");
106131
- var { Argument: Argument2, humanReadableArgName } = require_argument();
106132
- var { CommanderError: CommanderError2 } = require_error();
106133
- var { Help: Help2 } = require_help();
106134
- var { Option: Option3, splitOptionFlags, DualOptions } = require_option();
106135
- var { suggestSimilar } = require_suggestSimilar();
106136
- var Command3 = class _Command extends EventEmitter {
106137
- /**
106138
- * Initialize a new `Command`.
106139
- *
106140
- * @param {string} [name]
106141
- */
106142
- constructor(name) {
106143
- super();
106144
- this.commands = [];
106145
- this.options = [];
106146
- this.parent = null;
106147
- this._allowUnknownOption = false;
106148
- this._allowExcessArguments = true;
106149
- this._args = [];
106150
- this.args = [];
106151
- this.rawArgs = [];
106152
- this.processedArgs = [];
106153
- this._scriptPath = null;
106154
- this._name = name || "";
106155
- this._optionValues = {};
106156
- this._optionValueSources = {};
106157
- this._storeOptionsAsProperties = false;
106158
- this._actionHandler = null;
106159
- this._executableHandler = false;
106160
- this._executableFile = null;
106161
- this._executableDir = null;
106162
- this._defaultCommandName = null;
106163
- this._exitCallback = null;
106164
- this._aliases = [];
106165
- this._combineFlagAndOptionalValue = true;
106166
- this._description = "";
106167
- this._summary = "";
106168
- this._argsDescription = void 0;
106169
- this._enablePositionalOptions = false;
106170
- this._passThroughOptions = false;
106171
- this._lifeCycleHooks = {};
106172
- this._showHelpAfterError = false;
106173
- this._showSuggestionAfterError = true;
106174
- this._outputConfiguration = {
106175
- writeOut: (str) => process3.stdout.write(str),
106176
- writeErr: (str) => process3.stderr.write(str),
106177
- getOutHelpWidth: () => process3.stdout.isTTY ? process3.stdout.columns : void 0,
106178
- getErrHelpWidth: () => process3.stderr.isTTY ? process3.stderr.columns : void 0,
106179
- outputError: (str, write) => write(str)
106180
- };
106181
- this._hidden = false;
106182
- this._hasHelpOption = true;
106183
- this._helpFlags = "-h, --help";
106184
- this._helpDescription = "display help for command";
106185
- this._helpShortFlag = "-h";
106186
- this._helpLongFlag = "--help";
106187
- this._addImplicitHelpCommand = void 0;
106188
- this._helpCommandName = "help";
106189
- this._helpCommandnameAndArgs = "help [command]";
106190
- this._helpCommandDescription = "display help for command";
106191
- this._helpConfiguration = {};
106192
- }
106193
- /**
106194
- * Copy settings that are useful to have in common across root command and subcommands.
106195
- *
106196
- * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
106197
- *
106198
- * @param {Command} sourceCommand
106199
- * @return {Command} `this` command for chaining
106200
- */
106201
- copyInheritedSettings(sourceCommand) {
106202
- this._outputConfiguration = sourceCommand._outputConfiguration;
106203
- this._hasHelpOption = sourceCommand._hasHelpOption;
106204
- this._helpFlags = sourceCommand._helpFlags;
106205
- this._helpDescription = sourceCommand._helpDescription;
106206
- this._helpShortFlag = sourceCommand._helpShortFlag;
106207
- this._helpLongFlag = sourceCommand._helpLongFlag;
106208
- this._helpCommandName = sourceCommand._helpCommandName;
106209
- this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;
106210
- this._helpCommandDescription = sourceCommand._helpCommandDescription;
106211
- this._helpConfiguration = sourceCommand._helpConfiguration;
106212
- this._exitCallback = sourceCommand._exitCallback;
106213
- this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;
106214
- this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;
106215
- this._allowExcessArguments = sourceCommand._allowExcessArguments;
106216
- this._enablePositionalOptions = sourceCommand._enablePositionalOptions;
106217
- this._showHelpAfterError = sourceCommand._showHelpAfterError;
106218
- this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError;
106219
- return this;
106220
- }
106221
- /**
106222
- * Define a command.
106223
- *
106224
- * There are two styles of command: pay attention to where to put the description.
106225
- *
106226
- * @example
106227
- * // Command implemented using action handler (description is supplied separately to `.command`)
106228
- * program
106229
- * .command('clone <source> [destination]')
106230
- * .description('clone a repository into a newly created directory')
106231
- * .action((source, destination) => {
106232
- * console.log('clone command called');
106233
- * });
106234
- *
106235
- * // Command implemented using separate executable file (description is second parameter to `.command`)
106236
- * program
106237
- * .command('start <service>', 'start named service')
106238
- * .command('stop [service]', 'stop named service, or all if no name supplied');
106239
- *
106240
- * @param {string} nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
106241
- * @param {Object|string} [actionOptsOrExecDesc] - configuration options (for action), or description (for executable)
106242
- * @param {Object} [execOpts] - configuration options (for executable)
106243
- * @return {Command} returns new command for action handler, or `this` for executable command
106244
- */
106245
- command(nameAndArgs, actionOptsOrExecDesc, execOpts) {
106246
- let desc = actionOptsOrExecDesc;
106247
- let opts = execOpts;
106248
- if (typeof desc === "object" && desc !== null) {
106249
- opts = desc;
106250
- desc = null;
106251
- }
106252
- opts = opts || {};
106253
- const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/);
106254
- const cmd = this.createCommand(name);
106255
- if (desc) {
106256
- cmd.description(desc);
106257
- cmd._executableHandler = true;
106258
- }
106259
- if (opts.isDefault)
106260
- this._defaultCommandName = cmd._name;
106261
- cmd._hidden = !!(opts.noHelp || opts.hidden);
106262
- cmd._executableFile = opts.executableFile || null;
106263
- if (args)
106264
- cmd.arguments(args);
106265
- this.commands.push(cmd);
106266
- cmd.parent = this;
106267
- cmd.copyInheritedSettings(this);
106268
- if (desc)
106269
- return this;
106270
- return cmd;
106271
- }
106272
- /**
106273
- * Factory routine to create a new unattached command.
106274
- *
106275
- * See .command() for creating an attached subcommand, which uses this routine to
106276
- * create the command. You can override createCommand to customise subcommands.
106277
- *
106278
- * @param {string} [name]
106279
- * @return {Command} new command
106280
- */
106281
- createCommand(name) {
106282
- return new _Command(name);
106283
- }
106284
- /**
106285
- * You can customise the help with a subclass of Help by overriding createHelp,
106286
- * or by overriding Help properties using configureHelp().
106287
- *
106288
- * @return {Help}
106289
- */
106290
- createHelp() {
106291
- return Object.assign(new Help2(), this.configureHelp());
106292
- }
106293
- /**
106294
- * You can customise the help by overriding Help properties using configureHelp(),
106295
- * or with a subclass of Help by overriding createHelp().
106296
- *
106297
- * @param {Object} [configuration] - configuration options
106298
- * @return {Command|Object} `this` command for chaining, or stored configuration
106299
- */
106300
- configureHelp(configuration) {
106301
- if (configuration === void 0)
106302
- return this._helpConfiguration;
106303
- this._helpConfiguration = configuration;
106304
- return this;
106305
- }
106306
- /**
106307
- * The default output goes to stdout and stderr. You can customise this for special
106308
- * applications. You can also customise the display of errors by overriding outputError.
106309
- *
106310
- * The configuration properties are all functions:
106311
- *
106312
- * // functions to change where being written, stdout and stderr
106313
- * writeOut(str)
106314
- * writeErr(str)
106315
- * // matching functions to specify width for wrapping help
106316
- * getOutHelpWidth()
106317
- * getErrHelpWidth()
106318
- * // functions based on what is being written out
106319
- * outputError(str, write) // used for displaying errors, and not used for displaying help
106320
- *
106321
- * @param {Object} [configuration] - configuration options
106322
- * @return {Command|Object} `this` command for chaining, or stored configuration
106323
- */
106324
- configureOutput(configuration) {
106325
- if (configuration === void 0)
106326
- return this._outputConfiguration;
106327
- Object.assign(this._outputConfiguration, configuration);
106328
- return this;
106329
- }
106330
- /**
106331
- * Display the help or a custom message after an error occurs.
106332
- *
106333
- * @param {boolean|string} [displayHelp]
106334
- * @return {Command} `this` command for chaining
106335
- */
106336
- showHelpAfterError(displayHelp = true) {
106337
- if (typeof displayHelp !== "string")
106338
- displayHelp = !!displayHelp;
106339
- this._showHelpAfterError = displayHelp;
106340
- return this;
106341
- }
106342
- /**
106343
- * Display suggestion of similar commands for unknown commands, or options for unknown options.
106344
- *
106345
- * @param {boolean} [displaySuggestion]
106346
- * @return {Command} `this` command for chaining
106347
- */
106348
- showSuggestionAfterError(displaySuggestion = true) {
106349
- this._showSuggestionAfterError = !!displaySuggestion;
106350
- return this;
106351
- }
106352
- /**
106353
- * Add a prepared subcommand.
106354
- *
106355
- * See .command() for creating an attached subcommand which inherits settings from its parent.
106356
- *
106357
- * @param {Command} cmd - new subcommand
106358
- * @param {Object} [opts] - configuration options
106359
- * @return {Command} `this` command for chaining
106360
- */
106361
- addCommand(cmd, opts) {
106362
- if (!cmd._name) {
106363
- throw new Error(`Command passed to .addCommand() must have a name
106364
- - specify the name in Command constructor or using .name()`);
106365
- }
106366
- opts = opts || {};
106367
- if (opts.isDefault)
106368
- this._defaultCommandName = cmd._name;
106369
- if (opts.noHelp || opts.hidden)
106370
- cmd._hidden = true;
106371
- this.commands.push(cmd);
106372
- cmd.parent = this;
106373
- return this;
106374
- }
106375
- /**
106376
- * Factory routine to create a new unattached argument.
106377
- *
106378
- * See .argument() for creating an attached argument, which uses this routine to
106379
- * create the argument. You can override createArgument to return a custom argument.
106380
- *
106381
- * @param {string} name
106382
- * @param {string} [description]
106383
- * @return {Argument} new argument
106384
- */
106385
- createArgument(name, description) {
106386
- return new Argument2(name, description);
106387
- }
106388
- /**
106389
- * Define argument syntax for command.
106390
- *
106391
- * The default is that the argument is required, and you can explicitly
106392
- * indicate this with <> around the name. Put [] around the name for an optional argument.
106393
- *
106394
- * @example
106395
- * program.argument('<input-file>');
106396
- * program.argument('[output-file]');
106397
- *
106398
- * @param {string} name
106399
- * @param {string} [description]
106400
- * @param {Function|*} [fn] - custom argument processing function
106401
- * @param {*} [defaultValue]
106402
- * @return {Command} `this` command for chaining
106403
- */
106404
- argument(name, description, fn, defaultValue) {
106405
- const argument = this.createArgument(name, description);
106406
- if (typeof fn === "function") {
106407
- argument.default(defaultValue).argParser(fn);
106408
- } else {
106409
- argument.default(fn);
106410
- }
106411
- this.addArgument(argument);
106412
- return this;
106413
- }
106414
- /**
106415
- * Define argument syntax for command, adding multiple at once (without descriptions).
106416
- *
106417
- * See also .argument().
106418
- *
106419
- * @example
106420
- * program.arguments('<cmd> [env]');
106421
- *
106422
- * @param {string} names
106423
- * @return {Command} `this` command for chaining
106424
- */
106425
- arguments(names) {
106426
- names.trim().split(/ +/).forEach((detail) => {
106427
- this.argument(detail);
106428
- });
106429
- return this;
106430
- }
106431
- /**
106432
- * Define argument syntax for command, adding a prepared argument.
106433
- *
106434
- * @param {Argument} argument
106435
- * @return {Command} `this` command for chaining
106436
- */
106437
- addArgument(argument) {
106438
- const previousArgument = this._args.slice(-1)[0];
106439
- if (previousArgument && previousArgument.variadic) {
106440
- throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`);
106441
- }
106442
- if (argument.required && argument.defaultValue !== void 0 && argument.parseArg === void 0) {
106443
- throw new Error(`a default value for a required argument is never used: '${argument.name()}'`);
106444
- }
106445
- this._args.push(argument);
106446
- return this;
106447
- }
106448
- /**
106449
- * Override default decision whether to add implicit help command.
106450
- *
106451
- * addHelpCommand() // force on
106452
- * addHelpCommand(false); // force off
106453
- * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
106454
- *
106455
- * @return {Command} `this` command for chaining
106456
- */
106457
- addHelpCommand(enableOrNameAndArgs, description) {
106458
- if (enableOrNameAndArgs === false) {
106459
- this._addImplicitHelpCommand = false;
106460
- } else {
106461
- this._addImplicitHelpCommand = true;
106462
- if (typeof enableOrNameAndArgs === "string") {
106463
- this._helpCommandName = enableOrNameAndArgs.split(" ")[0];
106464
- this._helpCommandnameAndArgs = enableOrNameAndArgs;
106465
- }
106466
- this._helpCommandDescription = description || this._helpCommandDescription;
106467
- }
106468
- return this;
106469
- }
106470
- /**
106471
- * @return {boolean}
106472
- * @api private
106473
- */
106474
- _hasImplicitHelpCommand() {
106475
- if (this._addImplicitHelpCommand === void 0) {
106476
- return this.commands.length && !this._actionHandler && !this._findCommand("help");
106477
- }
106478
- return this._addImplicitHelpCommand;
106479
- }
106480
- /**
106481
- * Add hook for life cycle event.
106482
- *
106483
- * @param {string} event
106484
- * @param {Function} listener
106485
- * @return {Command} `this` command for chaining
106486
- */
106487
- hook(event, listener) {
106488
- const allowedValues = ["preSubcommand", "preAction", "postAction"];
106489
- if (!allowedValues.includes(event)) {
106490
- throw new Error(`Unexpected value for event passed to hook : '${event}'.
106491
- Expecting one of '${allowedValues.join("', '")}'`);
106492
- }
106493
- if (this._lifeCycleHooks[event]) {
106494
- this._lifeCycleHooks[event].push(listener);
106495
- } else {
106496
- this._lifeCycleHooks[event] = [listener];
106497
- }
106498
- return this;
106499
- }
106500
- /**
106501
- * Register callback to use as replacement for calling process.exit.
106502
- *
106503
- * @param {Function} [fn] optional callback which will be passed a CommanderError, defaults to throwing
106504
- * @return {Command} `this` command for chaining
106505
- */
106506
- exitOverride(fn) {
106507
- if (fn) {
106508
- this._exitCallback = fn;
106509
- } else {
106510
- this._exitCallback = (err) => {
106511
- if (err.code !== "commander.executeSubCommandAsync") {
106512
- throw err;
106513
- } else {
106514
- }
106515
- };
106516
- }
106517
- return this;
106518
- }
106519
- /**
106520
- * Call process.exit, and _exitCallback if defined.
106521
- *
106522
- * @param {number} exitCode exit code for using with process.exit
106523
- * @param {string} code an id string representing the error
106524
- * @param {string} message human-readable description of the error
106525
- * @return never
106526
- * @api private
106527
- */
106528
- _exit(exitCode, code, message) {
106529
- if (this._exitCallback) {
106530
- this._exitCallback(new CommanderError2(exitCode, code, message));
106531
- }
106532
- process3.exit(exitCode);
106533
- }
106534
- /**
106535
- * Register callback `fn` for the command.
106536
- *
106537
- * @example
106538
- * program
106539
- * .command('serve')
106540
- * .description('start service')
106541
- * .action(function() {
106542
- * // do work here
106543
- * });
106544
- *
106545
- * @param {Function} fn
106546
- * @return {Command} `this` command for chaining
106547
- */
106548
- action(fn) {
106549
- const listener = (args) => {
106550
- const expectedArgsCount = this._args.length;
106551
- const actionArgs = args.slice(0, expectedArgsCount);
106552
- if (this._storeOptionsAsProperties) {
106553
- actionArgs[expectedArgsCount] = this;
106554
- } else {
106555
- actionArgs[expectedArgsCount] = this.opts();
106556
- }
106557
- actionArgs.push(this);
106558
- return fn.apply(this, actionArgs);
106559
- };
106560
- this._actionHandler = listener;
106561
- return this;
106562
- }
106563
- /**
106564
- * Factory routine to create a new unattached option.
106565
- *
106566
- * See .option() for creating an attached option, which uses this routine to
106567
- * create the option. You can override createOption to return a custom option.
106568
- *
106569
- * @param {string} flags
106570
- * @param {string} [description]
106571
- * @return {Option} new option
106572
- */
106573
- createOption(flags, description) {
106574
- return new Option3(flags, description);
106575
- }
106576
- /**
106577
- * Add an option.
106578
- *
106579
- * @param {Option} option
106580
- * @return {Command} `this` command for chaining
106581
- */
106582
- addOption(option2) {
106583
- const oname = option2.name();
106584
- const name = option2.attributeName();
106585
- if (option2.negate) {
106586
- const positiveLongFlag = option2.long.replace(/^--no-/, "--");
106587
- if (!this._findOption(positiveLongFlag)) {
106588
- this.setOptionValueWithSource(name, option2.defaultValue === void 0 ? true : option2.defaultValue, "default");
106589
- }
106590
- } else if (option2.defaultValue !== void 0) {
106591
- this.setOptionValueWithSource(name, option2.defaultValue, "default");
106592
- }
106593
- this.options.push(option2);
106594
- const handleOptionValue = (val, invalidValueMessage, valueSource) => {
106595
- if (val == null && option2.presetArg !== void 0) {
106596
- val = option2.presetArg;
106597
- }
106598
- const oldValue = this.getOptionValue(name);
106599
- if (val !== null && option2.parseArg) {
106600
- try {
106601
- val = option2.parseArg(val, oldValue);
106602
- } catch (err) {
106603
- if (err.code === "commander.invalidArgument") {
106604
- const message = `${invalidValueMessage} ${err.message}`;
106605
- this.error(message, { exitCode: err.exitCode, code: err.code });
106606
- }
106607
- throw err;
106608
- }
106609
- } else if (val !== null && option2.variadic) {
106610
- val = option2._concatValue(val, oldValue);
106611
- }
106612
- if (val == null) {
106613
- if (option2.negate) {
106614
- val = false;
106615
- } else if (option2.isBoolean() || option2.optional) {
106616
- val = true;
106617
- } else {
106618
- val = "";
106619
- }
106620
- }
106621
- this.setOptionValueWithSource(name, val, valueSource);
106622
- };
106623
- this.on("option:" + oname, (val) => {
106624
- const invalidValueMessage = `error: option '${option2.flags}' argument '${val}' is invalid.`;
106625
- handleOptionValue(val, invalidValueMessage, "cli");
106626
- });
106627
- if (option2.envVar) {
106628
- this.on("optionEnv:" + oname, (val) => {
106629
- const invalidValueMessage = `error: option '${option2.flags}' value '${val}' from env '${option2.envVar}' is invalid.`;
106630
- handleOptionValue(val, invalidValueMessage, "env");
106631
- });
106632
- }
106633
- return this;
106634
- }
106635
- /**
106636
- * Internal implementation shared by .option() and .requiredOption()
106637
- *
106638
- * @api private
106639
- */
106640
- _optionEx(config, flags, description, fn, defaultValue) {
106641
- if (typeof flags === "object" && flags instanceof Option3) {
106642
- throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");
106643
- }
106644
- const option2 = this.createOption(flags, description);
106645
- option2.makeOptionMandatory(!!config.mandatory);
106646
- if (typeof fn === "function") {
106647
- option2.default(defaultValue).argParser(fn);
106648
- } else if (fn instanceof RegExp) {
106649
- const regex = fn;
106650
- fn = (val, def) => {
106651
- const m = regex.exec(val);
106652
- return m ? m[0] : def;
106653
- };
106654
- option2.default(defaultValue).argParser(fn);
106655
- } else {
106656
- option2.default(fn);
106657
- }
106658
- return this.addOption(option2);
106659
- }
106660
- /**
106661
- * Define option with `flags`, `description` and optional
106662
- * coercion `fn`.
106663
- *
106664
- * The `flags` string contains the short and/or long flags,
106665
- * separated by comma, a pipe or space. The following are all valid
106666
- * all will output this way when `--help` is used.
106667
- *
106668
- * "-p, --pepper"
106669
- * "-p|--pepper"
106670
- * "-p --pepper"
106671
- *
106672
- * @example
106673
- * // simple boolean defaulting to undefined
106674
- * program.option('-p, --pepper', 'add pepper');
106675
- *
106676
- * program.pepper
106677
- * // => undefined
106678
- *
106679
- * --pepper
106680
- * program.pepper
106681
- * // => true
106682
- *
106683
- * // simple boolean defaulting to true (unless non-negated option is also defined)
106684
- * program.option('-C, --no-cheese', 'remove cheese');
106685
- *
106686
- * program.cheese
106687
- * // => true
106688
- *
106689
- * --no-cheese
106690
- * program.cheese
106691
- * // => false
106692
- *
106693
- * // required argument
106694
- * program.option('-C, --chdir <path>', 'change the working directory');
106695
- *
106696
- * --chdir /tmp
106697
- * program.chdir
106698
- * // => "/tmp"
106699
- *
106700
- * // optional argument
106701
- * program.option('-c, --cheese [type]', 'add cheese [marble]');
106702
- *
106703
- * @param {string} flags
106704
- * @param {string} [description]
106705
- * @param {Function|*} [fn] - custom option processing function or default value
106706
- * @param {*} [defaultValue]
106707
- * @return {Command} `this` command for chaining
106708
- */
106709
- option(flags, description, fn, defaultValue) {
106710
- return this._optionEx({}, flags, description, fn, defaultValue);
106711
- }
106712
- /**
106713
- * Add a required option which must have a value after parsing. This usually means
106714
- * the option must be specified on the command line. (Otherwise the same as .option().)
106715
- *
106716
- * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
106717
- *
106718
- * @param {string} flags
106719
- * @param {string} [description]
106720
- * @param {Function|*} [fn] - custom option processing function or default value
106721
- * @param {*} [defaultValue]
106722
- * @return {Command} `this` command for chaining
106723
- */
106724
- requiredOption(flags, description, fn, defaultValue) {
106725
- return this._optionEx({ mandatory: true }, flags, description, fn, defaultValue);
106726
- }
106727
- /**
106728
- * Alter parsing of short flags with optional values.
106729
- *
106730
- * @example
106731
- * // for `.option('-f,--flag [value]'):
106732
- * program.combineFlagAndOptionalValue(true); // `-f80` is treated like `--flag=80`, this is the default behaviour
106733
- * program.combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
106734
- *
106735
- * @param {Boolean} [combine=true] - if `true` or omitted, an optional value can be specified directly after the flag.
106736
- */
106737
- combineFlagAndOptionalValue(combine = true) {
106738
- this._combineFlagAndOptionalValue = !!combine;
106739
- return this;
106740
- }
106741
- /**
106742
- * Allow unknown options on the command line.
106743
- *
106744
- * @param {Boolean} [allowUnknown=true] - if `true` or omitted, no error will be thrown
106745
- * for unknown options.
106746
- */
106747
- allowUnknownOption(allowUnknown = true) {
106748
- this._allowUnknownOption = !!allowUnknown;
106749
- return this;
106750
- }
106751
- /**
106752
- * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
106753
- *
106754
- * @param {Boolean} [allowExcess=true] - if `true` or omitted, no error will be thrown
106755
- * for excess arguments.
106756
- */
106757
- allowExcessArguments(allowExcess = true) {
106758
- this._allowExcessArguments = !!allowExcess;
106759
- return this;
106760
- }
106761
- /**
106762
- * Enable positional options. Positional means global options are specified before subcommands which lets
106763
- * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
106764
- * The default behaviour is non-positional and global options may appear anywhere on the command line.
106765
- *
106766
- * @param {Boolean} [positional=true]
106767
- */
106768
- enablePositionalOptions(positional = true) {
106769
- this._enablePositionalOptions = !!positional;
106770
- return this;
106771
- }
106772
- /**
106773
- * Pass through options that come after command-arguments rather than treat them as command-options,
106774
- * so actual command-options come before command-arguments. Turning this on for a subcommand requires
106775
- * positional options to have been enabled on the program (parent commands).
106776
- * The default behaviour is non-positional and options may appear before or after command-arguments.
106777
- *
106778
- * @param {Boolean} [passThrough=true]
106779
- * for unknown options.
106780
- */
106781
- passThroughOptions(passThrough = true) {
106782
- this._passThroughOptions = !!passThrough;
106783
- if (!!this.parent && passThrough && !this.parent._enablePositionalOptions) {
106784
- throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");
106785
- }
106786
- return this;
106787
- }
106788
- /**
106789
- * Whether to store option values as properties on command object,
106790
- * or store separately (specify false). In both cases the option values can be accessed using .opts().
106791
- *
106792
- * @param {boolean} [storeAsProperties=true]
106793
- * @return {Command} `this` command for chaining
106794
- */
106795
- storeOptionsAsProperties(storeAsProperties = true) {
106796
- this._storeOptionsAsProperties = !!storeAsProperties;
106797
- if (this.options.length) {
106798
- throw new Error("call .storeOptionsAsProperties() before adding options");
106799
- }
106800
- return this;
106801
- }
106802
- /**
106803
- * Retrieve option value.
106804
- *
106805
- * @param {string} key
106806
- * @return {Object} value
106807
- */
106808
- getOptionValue(key) {
106809
- if (this._storeOptionsAsProperties) {
106810
- return this[key];
106811
- }
106812
- return this._optionValues[key];
106813
- }
106814
- /**
106815
- * Store option value.
106816
- *
106817
- * @param {string} key
106818
- * @param {Object} value
106819
- * @return {Command} `this` command for chaining
106820
- */
106821
- setOptionValue(key, value) {
106822
- return this.setOptionValueWithSource(key, value, void 0);
106823
- }
106824
- /**
106825
- * Store option value and where the value came from.
106826
- *
106827
- * @param {string} key
106828
- * @param {Object} value
106829
- * @param {string} source - expected values are default/config/env/cli/implied
106830
- * @return {Command} `this` command for chaining
106831
- */
106832
- setOptionValueWithSource(key, value, source) {
106833
- if (this._storeOptionsAsProperties) {
106834
- this[key] = value;
106835
- } else {
106836
- this._optionValues[key] = value;
106837
- }
106838
- this._optionValueSources[key] = source;
106839
- return this;
106840
- }
106841
- /**
106842
- * Get source of option value.
106843
- * Expected values are default | config | env | cli | implied
106844
- *
106845
- * @param {string} key
106846
- * @return {string}
106847
- */
106848
- getOptionValueSource(key) {
106849
- return this._optionValueSources[key];
106850
- }
106851
- /**
106852
- * Get source of option value. See also .optsWithGlobals().
106853
- * Expected values are default | config | env | cli | implied
106854
- *
106855
- * @param {string} key
106856
- * @return {string}
106857
- */
106858
- getOptionValueSourceWithGlobals(key) {
106859
- let source;
106860
- getCommandAndParents(this).forEach((cmd) => {
106861
- if (cmd.getOptionValueSource(key) !== void 0) {
106862
- source = cmd.getOptionValueSource(key);
106863
- }
106864
- });
106865
- return source;
106866
- }
106867
- /**
106868
- * Get user arguments from implied or explicit arguments.
106869
- * Side-effects: set _scriptPath if args included script. Used for default program name, and subcommand searches.
106870
- *
106871
- * @api private
106872
- */
106873
- _prepareUserArgs(argv, parseOptions) {
106874
- if (argv !== void 0 && !Array.isArray(argv)) {
106875
- throw new Error("first parameter to parse must be array or undefined");
106876
- }
106877
- parseOptions = parseOptions || {};
106878
- if (argv === void 0) {
106879
- argv = process3.argv;
106880
- if (process3.versions && process3.versions.electron) {
106881
- parseOptions.from = "electron";
106882
- }
106883
- }
106884
- this.rawArgs = argv.slice();
106885
- let userArgs;
106886
- switch (parseOptions.from) {
106887
- case void 0:
106888
- case "node":
106889
- this._scriptPath = argv[1];
106890
- userArgs = argv.slice(2);
106891
- break;
106892
- case "electron":
106893
- if (process3.defaultApp) {
106894
- this._scriptPath = argv[1];
106895
- userArgs = argv.slice(2);
106896
- } else {
106897
- userArgs = argv.slice(1);
106898
- }
106899
- break;
106900
- case "user":
106901
- userArgs = argv.slice(0);
106902
- break;
106903
- default:
106904
- throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`);
106905
- }
106906
- if (!this._name && this._scriptPath)
106907
- this.nameFromFilename(this._scriptPath);
106908
- this._name = this._name || "program";
106909
- return userArgs;
106910
- }
106911
- /**
106912
- * Parse `argv`, setting options and invoking commands when defined.
106913
- *
106914
- * The default expectation is that the arguments are from node and have the application as argv[0]
106915
- * and the script being run in argv[1], with user parameters after that.
106916
- *
106917
- * @example
106918
- * program.parse(process.argv);
106919
- * program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
106920
- * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
106921
- *
106922
- * @param {string[]} [argv] - optional, defaults to process.argv
106923
- * @param {Object} [parseOptions] - optionally specify style of options with from: node/user/electron
106924
- * @param {string} [parseOptions.from] - where the args are from: 'node', 'user', 'electron'
106925
- * @return {Command} `this` command for chaining
106926
- */
106927
- parse(argv, parseOptions) {
106928
- const userArgs = this._prepareUserArgs(argv, parseOptions);
106929
- this._parseCommand([], userArgs);
106930
- return this;
106931
- }
106932
- /**
106933
- * Parse `argv`, setting options and invoking commands when defined.
106934
- *
106935
- * Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
106936
- *
106937
- * The default expectation is that the arguments are from node and have the application as argv[0]
106938
- * and the script being run in argv[1], with user parameters after that.
106939
- *
106940
- * @example
106941
- * await program.parseAsync(process.argv);
106942
- * await program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
106943
- * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
106944
- *
106945
- * @param {string[]} [argv]
106946
- * @param {Object} [parseOptions]
106947
- * @param {string} parseOptions.from - where the args are from: 'node', 'user', 'electron'
106948
- * @return {Promise}
106949
- */
106950
- async parseAsync(argv, parseOptions) {
106951
- const userArgs = this._prepareUserArgs(argv, parseOptions);
106952
- await this._parseCommand([], userArgs);
106953
- return this;
106954
- }
106955
- /**
106956
- * Execute a sub-command executable.
106957
- *
106958
- * @api private
106959
- */
106960
- _executeSubCommand(subcommand, args) {
106961
- args = args.slice();
106962
- let launchWithNode = false;
106963
- const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
106964
- function findFile(baseDir, baseName) {
106965
- const localBin = path4.resolve(baseDir, baseName);
106966
- if (fs5.existsSync(localBin))
106967
- return localBin;
106968
- if (sourceExt.includes(path4.extname(baseName)))
106969
- return void 0;
106970
- const foundExt = sourceExt.find((ext) => fs5.existsSync(`${localBin}${ext}`));
106971
- if (foundExt)
106972
- return `${localBin}${foundExt}`;
106973
- return void 0;
106974
- }
106975
- this._checkForMissingMandatoryOptions();
106976
- this._checkForConflictingOptions();
106977
- let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`;
106978
- let executableDir = this._executableDir || "";
106979
- if (this._scriptPath) {
106980
- let resolvedScriptPath;
106981
- try {
106982
- resolvedScriptPath = fs5.realpathSync(this._scriptPath);
106983
- } catch (err) {
106984
- resolvedScriptPath = this._scriptPath;
106985
- }
106986
- executableDir = path4.resolve(path4.dirname(resolvedScriptPath), executableDir);
106987
- }
106988
- if (executableDir) {
106989
- let localFile = findFile(executableDir, executableFile);
106990
- if (!localFile && !subcommand._executableFile && this._scriptPath) {
106991
- const legacyName = path4.basename(this._scriptPath, path4.extname(this._scriptPath));
106992
- if (legacyName !== this._name) {
106993
- localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
106994
- }
106995
- }
106996
- executableFile = localFile || executableFile;
106997
- }
106998
- launchWithNode = sourceExt.includes(path4.extname(executableFile));
106999
- let proc;
107000
- if (process3.platform !== "win32") {
107001
- if (launchWithNode) {
107002
- args.unshift(executableFile);
107003
- args = incrementNodeInspectorPort(process3.execArgv).concat(args);
107004
- proc = childProcess.spawn(process3.argv[0], args, { stdio: "inherit" });
107005
- } else {
107006
- proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
107007
- }
107008
- } else {
107009
- args.unshift(executableFile);
107010
- args = incrementNodeInspectorPort(process3.execArgv).concat(args);
107011
- proc = childProcess.spawn(process3.execPath, args, { stdio: "inherit" });
107012
- }
107013
- if (!proc.killed) {
107014
- const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
107015
- signals.forEach((signal) => {
107016
- process3.on(signal, () => {
107017
- if (proc.killed === false && proc.exitCode === null) {
107018
- proc.kill(signal);
107019
- }
107020
- });
107021
- });
107022
- }
107023
- const exitCallback = this._exitCallback;
107024
- if (!exitCallback) {
107025
- proc.on("close", process3.exit.bind(process3));
107026
- } else {
107027
- proc.on("close", () => {
107028
- exitCallback(new CommanderError2(process3.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
107029
- });
107030
- }
107031
- proc.on("error", (err) => {
107032
- if (err.code === "ENOENT") {
107033
- const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
107034
- const executableMissing = `'${executableFile}' does not exist
107035
- - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
107036
- - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
107037
- - ${executableDirMessage}`;
107038
- throw new Error(executableMissing);
107039
- } else if (err.code === "EACCES") {
107040
- throw new Error(`'${executableFile}' not executable`);
107041
- }
107042
- if (!exitCallback) {
107043
- process3.exit(1);
107044
- } else {
107045
- const wrappedError = new CommanderError2(1, "commander.executeSubCommandAsync", "(error)");
107046
- wrappedError.nestedError = err;
107047
- exitCallback(wrappedError);
107048
- }
107049
- });
107050
- this.runningCommand = proc;
107051
- }
107052
- /**
107053
- * @api private
107054
- */
107055
- _dispatchSubcommand(commandName, operands, unknown) {
107056
- const subCommand = this._findCommand(commandName);
107057
- if (!subCommand)
107058
- this.help({ error: true });
107059
- let hookResult;
107060
- hookResult = this._chainOrCallSubCommandHook(hookResult, subCommand, "preSubcommand");
107061
- hookResult = this._chainOrCall(hookResult, () => {
107062
- if (subCommand._executableHandler) {
107063
- this._executeSubCommand(subCommand, operands.concat(unknown));
107064
- } else {
107065
- return subCommand._parseCommand(operands, unknown);
107066
- }
107067
- });
107068
- return hookResult;
107069
- }
107070
- /**
107071
- * Invoke help directly if possible, or dispatch if necessary.
107072
- * e.g. help foo
107073
- *
107074
- * @api private
107075
- */
107076
- _dispatchHelpCommand(subcommandName) {
107077
- if (!subcommandName) {
107078
- this.help();
107079
- }
107080
- const subCommand = this._findCommand(subcommandName);
107081
- if (subCommand && !subCommand._executableHandler) {
107082
- subCommand.help();
107083
- }
107084
- return this._dispatchSubcommand(subcommandName, [], [this._helpLongFlag]);
107085
- }
107086
- /**
107087
- * Check this.args against expected this._args.
107088
- *
107089
- * @api private
107090
- */
107091
- _checkNumberOfArguments() {
107092
- this._args.forEach((arg, i) => {
107093
- if (arg.required && this.args[i] == null) {
107094
- this.missingArgument(arg.name());
107095
- }
107096
- });
107097
- if (this._args.length > 0 && this._args[this._args.length - 1].variadic) {
107098
- return;
107099
- }
107100
- if (this.args.length > this._args.length) {
107101
- this._excessArguments(this.args);
107102
- }
107103
- }
107104
- /**
107105
- * Process this.args using this._args and save as this.processedArgs!
107106
- *
107107
- * @api private
107108
- */
107109
- _processArguments() {
107110
- const myParseArg = (argument, value, previous) => {
107111
- let parsedValue = value;
107112
- if (value !== null && argument.parseArg) {
107113
- try {
107114
- parsedValue = argument.parseArg(value, previous);
107115
- } catch (err) {
107116
- if (err.code === "commander.invalidArgument") {
107117
- const message = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'. ${err.message}`;
107118
- this.error(message, { exitCode: err.exitCode, code: err.code });
107119
- }
107120
- throw err;
107121
- }
107122
- }
107123
- return parsedValue;
107124
- };
107125
- this._checkNumberOfArguments();
107126
- const processedArgs = [];
107127
- this._args.forEach((declaredArg, index) => {
107128
- let value = declaredArg.defaultValue;
107129
- if (declaredArg.variadic) {
107130
- if (index < this.args.length) {
107131
- value = this.args.slice(index);
107132
- if (declaredArg.parseArg) {
107133
- value = value.reduce((processed, v) => {
107134
- return myParseArg(declaredArg, v, processed);
107135
- }, declaredArg.defaultValue);
107136
- }
107137
- } else if (value === void 0) {
107138
- value = [];
107139
- }
107140
- } else if (index < this.args.length) {
107141
- value = this.args[index];
107142
- if (declaredArg.parseArg) {
107143
- value = myParseArg(declaredArg, value, declaredArg.defaultValue);
107144
- }
107145
- }
107146
- processedArgs[index] = value;
107147
- });
107148
- this.processedArgs = processedArgs;
107149
- }
107150
- /**
107151
- * Once we have a promise we chain, but call synchronously until then.
107152
- *
107153
- * @param {Promise|undefined} promise
107154
- * @param {Function} fn
107155
- * @return {Promise|undefined}
107156
- * @api private
107157
- */
107158
- _chainOrCall(promise, fn) {
107159
- if (promise && promise.then && typeof promise.then === "function") {
107160
- return promise.then(() => fn());
107161
- }
107162
- return fn();
107163
- }
107164
- /**
107165
- *
107166
- * @param {Promise|undefined} promise
107167
- * @param {string} event
107168
- * @return {Promise|undefined}
107169
- * @api private
107170
- */
107171
- _chainOrCallHooks(promise, event) {
107172
- let result = promise;
107173
- const hooks = [];
107174
- getCommandAndParents(this).reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== void 0).forEach((hookedCommand) => {
107175
- hookedCommand._lifeCycleHooks[event].forEach((callback) => {
107176
- hooks.push({ hookedCommand, callback });
107177
- });
107178
- });
107179
- if (event === "postAction") {
107180
- hooks.reverse();
107181
- }
107182
- hooks.forEach((hookDetail) => {
107183
- result = this._chainOrCall(result, () => {
107184
- return hookDetail.callback(hookDetail.hookedCommand, this);
107185
- });
107186
- });
107187
- return result;
107188
- }
107189
- /**
107190
- *
107191
- * @param {Promise|undefined} promise
107192
- * @param {Command} subCommand
107193
- * @param {string} event
107194
- * @return {Promise|undefined}
107195
- * @api private
107196
- */
107197
- _chainOrCallSubCommandHook(promise, subCommand, event) {
107198
- let result = promise;
107199
- if (this._lifeCycleHooks[event] !== void 0) {
107200
- this._lifeCycleHooks[event].forEach((hook) => {
107201
- result = this._chainOrCall(result, () => {
107202
- return hook(this, subCommand);
107203
- });
107204
- });
107205
- }
107206
- return result;
107207
- }
107208
- /**
107209
- * Process arguments in context of this command.
107210
- * Returns action result, in case it is a promise.
107211
- *
107212
- * @api private
107213
- */
107214
- _parseCommand(operands, unknown) {
107215
- const parsed = this.parseOptions(unknown);
107216
- this._parseOptionsEnv();
107217
- this._parseOptionsImplied();
107218
- operands = operands.concat(parsed.operands);
107219
- unknown = parsed.unknown;
107220
- this.args = operands.concat(unknown);
107221
- if (operands && this._findCommand(operands[0])) {
107222
- return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);
107223
- }
107224
- if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {
107225
- return this._dispatchHelpCommand(operands[1]);
107226
- }
107227
- if (this._defaultCommandName) {
107228
- outputHelpIfRequested(this, unknown);
107229
- return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
107230
- }
107231
- if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) {
107232
- this.help({ error: true });
107233
- }
107234
- outputHelpIfRequested(this, parsed.unknown);
107235
- this._checkForMissingMandatoryOptions();
107236
- this._checkForConflictingOptions();
107237
- const checkForUnknownOptions = () => {
107238
- if (parsed.unknown.length > 0) {
107239
- this.unknownOption(parsed.unknown[0]);
107240
- }
107241
- };
107242
- const commandEvent = `command:${this.name()}`;
107243
- if (this._actionHandler) {
107244
- checkForUnknownOptions();
107245
- this._processArguments();
107246
- let actionResult;
107247
- actionResult = this._chainOrCallHooks(actionResult, "preAction");
107248
- actionResult = this._chainOrCall(actionResult, () => this._actionHandler(this.processedArgs));
107249
- if (this.parent) {
107250
- actionResult = this._chainOrCall(actionResult, () => {
107251
- this.parent.emit(commandEvent, operands, unknown);
107252
- });
107253
- }
107254
- actionResult = this._chainOrCallHooks(actionResult, "postAction");
107255
- return actionResult;
107256
- }
107257
- if (this.parent && this.parent.listenerCount(commandEvent)) {
107258
- checkForUnknownOptions();
107259
- this._processArguments();
107260
- this.parent.emit(commandEvent, operands, unknown);
107261
- } else if (operands.length) {
107262
- if (this._findCommand("*")) {
107263
- return this._dispatchSubcommand("*", operands, unknown);
107264
- }
107265
- if (this.listenerCount("command:*")) {
107266
- this.emit("command:*", operands, unknown);
107267
- } else if (this.commands.length) {
107268
- this.unknownCommand();
107269
- } else {
107270
- checkForUnknownOptions();
107271
- this._processArguments();
107272
- }
107273
- } else if (this.commands.length) {
107274
- checkForUnknownOptions();
107275
- this.help({ error: true });
107276
- } else {
107277
- checkForUnknownOptions();
107278
- this._processArguments();
107279
- }
107280
- }
107281
- /**
107282
- * Find matching command.
107283
- *
107284
- * @api private
107285
- */
107286
- _findCommand(name) {
107287
- if (!name)
107288
- return void 0;
107289
- return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name));
107290
- }
107291
- /**
107292
- * Return an option matching `arg` if any.
107293
- *
107294
- * @param {string} arg
107295
- * @return {Option}
107296
- * @api private
107297
- */
107298
- _findOption(arg) {
107299
- return this.options.find((option2) => option2.is(arg));
107300
- }
107301
- /**
107302
- * Display an error message if a mandatory option does not have a value.
107303
- * Called after checking for help flags in leaf subcommand.
107304
- *
107305
- * @api private
107306
- */
107307
- _checkForMissingMandatoryOptions() {
107308
- for (let cmd = this; cmd; cmd = cmd.parent) {
107309
- cmd.options.forEach((anOption) => {
107310
- if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === void 0) {
107311
- cmd.missingMandatoryOptionValue(anOption);
107312
- }
107313
- });
107314
- }
107315
- }
107316
- /**
107317
- * Display an error message if conflicting options are used together in this.
107318
- *
107319
- * @api private
107320
- */
107321
- _checkForConflictingLocalOptions() {
107322
- const definedNonDefaultOptions = this.options.filter(
107323
- (option2) => {
107324
- const optionKey = option2.attributeName();
107325
- if (this.getOptionValue(optionKey) === void 0) {
107326
- return false;
107327
- }
107328
- return this.getOptionValueSource(optionKey) !== "default";
107329
- }
107330
- );
107331
- const optionsWithConflicting = definedNonDefaultOptions.filter(
107332
- (option2) => option2.conflictsWith.length > 0
107333
- );
107334
- optionsWithConflicting.forEach((option2) => {
107335
- const conflictingAndDefined = definedNonDefaultOptions.find(
107336
- (defined) => option2.conflictsWith.includes(defined.attributeName())
107337
- );
107338
- if (conflictingAndDefined) {
107339
- this._conflictingOption(option2, conflictingAndDefined);
107340
- }
107341
- });
107342
- }
107343
- /**
107344
- * Display an error message if conflicting options are used together.
107345
- * Called after checking for help flags in leaf subcommand.
107346
- *
107347
- * @api private
107348
- */
107349
- _checkForConflictingOptions() {
107350
- for (let cmd = this; cmd; cmd = cmd.parent) {
107351
- cmd._checkForConflictingLocalOptions();
107352
- }
107353
- }
107354
- /**
107355
- * Parse options from `argv` removing known options,
107356
- * and return argv split into operands and unknown arguments.
107357
- *
107358
- * Examples:
107359
- *
107360
- * argv => operands, unknown
107361
- * --known kkk op => [op], []
107362
- * op --known kkk => [op], []
107363
- * sub --unknown uuu op => [sub], [--unknown uuu op]
107364
- * sub -- --unknown uuu op => [sub --unknown uuu op], []
107365
- *
107366
- * @param {String[]} argv
107367
- * @return {{operands: String[], unknown: String[]}}
107368
- */
107369
- parseOptions(argv) {
107370
- const operands = [];
107371
- const unknown = [];
107372
- let dest = operands;
107373
- const args = argv.slice();
107374
- function maybeOption(arg) {
107375
- return arg.length > 1 && arg[0] === "-";
107376
- }
107377
- let activeVariadicOption = null;
107378
- while (args.length) {
107379
- const arg = args.shift();
107380
- if (arg === "--") {
107381
- if (dest === unknown)
107382
- dest.push(arg);
107383
- dest.push(...args);
107384
- break;
107385
- }
107386
- if (activeVariadicOption && !maybeOption(arg)) {
107387
- this.emit(`option:${activeVariadicOption.name()}`, arg);
107388
- continue;
107389
- }
107390
- activeVariadicOption = null;
107391
- if (maybeOption(arg)) {
107392
- const option2 = this._findOption(arg);
107393
- if (option2) {
107394
- if (option2.required) {
107395
- const value = args.shift();
107396
- if (value === void 0)
107397
- this.optionMissingArgument(option2);
107398
- this.emit(`option:${option2.name()}`, value);
107399
- } else if (option2.optional) {
107400
- let value = null;
107401
- if (args.length > 0 && !maybeOption(args[0])) {
107402
- value = args.shift();
107403
- }
107404
- this.emit(`option:${option2.name()}`, value);
107405
- } else {
107406
- this.emit(`option:${option2.name()}`);
107407
- }
107408
- activeVariadicOption = option2.variadic ? option2 : null;
107409
- continue;
107410
- }
107411
- }
107412
- if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") {
107413
- const option2 = this._findOption(`-${arg[1]}`);
107414
- if (option2) {
107415
- if (option2.required || option2.optional && this._combineFlagAndOptionalValue) {
107416
- this.emit(`option:${option2.name()}`, arg.slice(2));
107417
- } else {
107418
- this.emit(`option:${option2.name()}`);
107419
- args.unshift(`-${arg.slice(2)}`);
107420
- }
107421
- continue;
107422
- }
107423
- }
107424
- if (/^--[^=]+=/.test(arg)) {
107425
- const index = arg.indexOf("=");
107426
- const option2 = this._findOption(arg.slice(0, index));
107427
- if (option2 && (option2.required || option2.optional)) {
107428
- this.emit(`option:${option2.name()}`, arg.slice(index + 1));
107429
- continue;
107430
- }
107431
- }
107432
- if (maybeOption(arg)) {
107433
- dest = unknown;
107434
- }
107435
- if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) {
107436
- if (this._findCommand(arg)) {
107437
- operands.push(arg);
107438
- if (args.length > 0)
107439
- unknown.push(...args);
107440
- break;
107441
- } else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {
107442
- operands.push(arg);
107443
- if (args.length > 0)
107444
- operands.push(...args);
107445
- break;
107446
- } else if (this._defaultCommandName) {
107447
- unknown.push(arg);
107448
- if (args.length > 0)
107449
- unknown.push(...args);
107450
- break;
107451
- }
107452
- }
107453
- if (this._passThroughOptions) {
107454
- dest.push(arg);
107455
- if (args.length > 0)
107456
- dest.push(...args);
107457
- break;
107458
- }
107459
- dest.push(arg);
107460
- }
107461
- return { operands, unknown };
107462
- }
107463
- /**
107464
- * Return an object containing local option values as key-value pairs.
107465
- *
107466
- * @return {Object}
107467
- */
107468
- opts() {
107469
- if (this._storeOptionsAsProperties) {
107470
- const result = {};
107471
- const len = this.options.length;
107472
- for (let i = 0; i < len; i++) {
107473
- const key = this.options[i].attributeName();
107474
- result[key] = key === this._versionOptionName ? this._version : this[key];
107475
- }
107476
- return result;
107477
- }
107478
- return this._optionValues;
107479
- }
107480
- /**
107481
- * Return an object containing merged local and global option values as key-value pairs.
107482
- *
107483
- * @return {Object}
107484
- */
107485
- optsWithGlobals() {
107486
- return getCommandAndParents(this).reduce(
107487
- (combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()),
107488
- {}
107489
- );
107490
- }
107491
- /**
107492
- * Display error message and exit (or call exitOverride).
107493
- *
107494
- * @param {string} message
107495
- * @param {Object} [errorOptions]
107496
- * @param {string} [errorOptions.code] - an id string representing the error
107497
- * @param {number} [errorOptions.exitCode] - used with process.exit
107498
- */
107499
- error(message, errorOptions) {
107500
- this._outputConfiguration.outputError(`${message}
107501
- `, this._outputConfiguration.writeErr);
107502
- if (typeof this._showHelpAfterError === "string") {
107503
- this._outputConfiguration.writeErr(`${this._showHelpAfterError}
107504
- `);
107505
- } else if (this._showHelpAfterError) {
107506
- this._outputConfiguration.writeErr("\n");
107507
- this.outputHelp({ error: true });
107508
- }
107509
- const config = errorOptions || {};
107510
- const exitCode = config.exitCode || 1;
107511
- const code = config.code || "commander.error";
107512
- this._exit(exitCode, code, message);
107513
- }
107514
- /**
107515
- * Apply any option related environment variables, if option does
107516
- * not have a value from cli or client code.
107517
- *
107518
- * @api private
107519
- */
107520
- _parseOptionsEnv() {
107521
- this.options.forEach((option2) => {
107522
- if (option2.envVar && option2.envVar in process3.env) {
107523
- const optionKey = option2.attributeName();
107524
- if (this.getOptionValue(optionKey) === void 0 || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
107525
- if (option2.required || option2.optional) {
107526
- this.emit(`optionEnv:${option2.name()}`, process3.env[option2.envVar]);
107527
- } else {
107528
- this.emit(`optionEnv:${option2.name()}`);
107529
- }
107530
- }
107531
- }
107532
- });
107533
- }
107534
- /**
107535
- * Apply any implied option values, if option is undefined or default value.
107536
- *
107537
- * @api private
107538
- */
107539
- _parseOptionsImplied() {
107540
- const dualHelper = new DualOptions(this.options);
107541
- const hasCustomOptionValue = (optionKey) => {
107542
- return this.getOptionValue(optionKey) !== void 0 && !["default", "implied"].includes(this.getOptionValueSource(optionKey));
107543
- };
107544
- this.options.filter((option2) => option2.implied !== void 0 && hasCustomOptionValue(option2.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option2.attributeName()), option2)).forEach((option2) => {
107545
- Object.keys(option2.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => {
107546
- this.setOptionValueWithSource(impliedKey, option2.implied[impliedKey], "implied");
107547
- });
107548
- });
107549
- }
107550
- /**
107551
- * Argument `name` is missing.
107552
- *
107553
- * @param {string} name
107554
- * @api private
107555
- */
107556
- missingArgument(name) {
107557
- const message = `error: missing required argument '${name}'`;
107558
- this.error(message, { code: "commander.missingArgument" });
107559
- }
107560
- /**
107561
- * `Option` is missing an argument.
107562
- *
107563
- * @param {Option} option
107564
- * @api private
107565
- */
107566
- optionMissingArgument(option2) {
107567
- const message = `error: option '${option2.flags}' argument missing`;
107568
- this.error(message, { code: "commander.optionMissingArgument" });
107569
- }
107570
- /**
107571
- * `Option` does not have a value, and is a mandatory option.
107572
- *
107573
- * @param {Option} option
107574
- * @api private
107575
- */
107576
- missingMandatoryOptionValue(option2) {
107577
- const message = `error: required option '${option2.flags}' not specified`;
107578
- this.error(message, { code: "commander.missingMandatoryOptionValue" });
107579
- }
107580
- /**
107581
- * `Option` conflicts with another option.
107582
- *
107583
- * @param {Option} option
107584
- * @param {Option} conflictingOption
107585
- * @api private
107586
- */
107587
- _conflictingOption(option2, conflictingOption) {
107588
- const findBestOptionFromValue = (option3) => {
107589
- const optionKey = option3.attributeName();
107590
- const optionValue = this.getOptionValue(optionKey);
107591
- const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName());
107592
- const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName());
107593
- if (negativeOption && (negativeOption.presetArg === void 0 && optionValue === false || negativeOption.presetArg !== void 0 && optionValue === negativeOption.presetArg)) {
107594
- return negativeOption;
107595
- }
107596
- return positiveOption || option3;
107597
- };
107598
- const getErrorMessage = (option3) => {
107599
- const bestOption = findBestOptionFromValue(option3);
107600
- const optionKey = bestOption.attributeName();
107601
- const source = this.getOptionValueSource(optionKey);
107602
- if (source === "env") {
107603
- return `environment variable '${bestOption.envVar}'`;
107604
- }
107605
- return `option '${bestOption.flags}'`;
107606
- };
107607
- const message = `error: ${getErrorMessage(option2)} cannot be used with ${getErrorMessage(conflictingOption)}`;
107608
- this.error(message, { code: "commander.conflictingOption" });
107609
- }
107610
- /**
107611
- * Unknown option `flag`.
107612
- *
107613
- * @param {string} flag
107614
- * @api private
107615
- */
107616
- unknownOption(flag) {
107617
- if (this._allowUnknownOption)
107618
- return;
107619
- let suggestion = "";
107620
- if (flag.startsWith("--") && this._showSuggestionAfterError) {
107621
- let candidateFlags = [];
107622
- let command = this;
107623
- do {
107624
- const moreFlags = command.createHelp().visibleOptions(command).filter((option2) => option2.long).map((option2) => option2.long);
107625
- candidateFlags = candidateFlags.concat(moreFlags);
107626
- command = command.parent;
107627
- } while (command && !command._enablePositionalOptions);
107628
- suggestion = suggestSimilar(flag, candidateFlags);
107629
- }
107630
- const message = `error: unknown option '${flag}'${suggestion}`;
107631
- this.error(message, { code: "commander.unknownOption" });
107632
- }
107633
- /**
107634
- * Excess arguments, more than expected.
107635
- *
107636
- * @param {string[]} receivedArgs
107637
- * @api private
107638
- */
107639
- _excessArguments(receivedArgs) {
107640
- if (this._allowExcessArguments)
107641
- return;
107642
- const expected = this._args.length;
107643
- const s = expected === 1 ? "" : "s";
107644
- const forSubcommand = this.parent ? ` for '${this.name()}'` : "";
107645
- const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`;
107646
- this.error(message, { code: "commander.excessArguments" });
107647
- }
107648
- /**
107649
- * Unknown command.
107650
- *
107651
- * @api private
107652
- */
107653
- unknownCommand() {
107654
- const unknownName = this.args[0];
107655
- let suggestion = "";
107656
- if (this._showSuggestionAfterError) {
107657
- const candidateNames = [];
107658
- this.createHelp().visibleCommands(this).forEach((command) => {
107659
- candidateNames.push(command.name());
107660
- if (command.alias())
107661
- candidateNames.push(command.alias());
107662
- });
107663
- suggestion = suggestSimilar(unknownName, candidateNames);
107664
- }
107665
- const message = `error: unknown command '${unknownName}'${suggestion}`;
107666
- this.error(message, { code: "commander.unknownCommand" });
107667
- }
107668
- /**
107669
- * Set the program version to `str`.
107670
- *
107671
- * This method auto-registers the "-V, --version" flag
107672
- * which will print the version number when passed.
107673
- *
107674
- * You can optionally supply the flags and description to override the defaults.
107675
- *
107676
- * @param {string} str
107677
- * @param {string} [flags]
107678
- * @param {string} [description]
107679
- * @return {this | string} `this` command for chaining, or version string if no arguments
107680
- */
107681
- version(str, flags, description) {
107682
- if (str === void 0)
107683
- return this._version;
107684
- this._version = str;
107685
- flags = flags || "-V, --version";
107686
- description = description || "output the version number";
107687
- const versionOption = this.createOption(flags, description);
107688
- this._versionOptionName = versionOption.attributeName();
107689
- this.options.push(versionOption);
107690
- this.on("option:" + versionOption.name(), () => {
107691
- this._outputConfiguration.writeOut(`${str}
107692
- `);
107693
- this._exit(0, "commander.version", str);
107694
- });
107695
- return this;
107696
- }
107697
- /**
107698
- * Set the description.
107699
- *
107700
- * @param {string} [str]
107701
- * @param {Object} [argsDescription]
107702
- * @return {string|Command}
107703
- */
107704
- description(str, argsDescription) {
107705
- if (str === void 0 && argsDescription === void 0)
107706
- return this._description;
107707
- this._description = str;
107708
- if (argsDescription) {
107709
- this._argsDescription = argsDescription;
107710
- }
107711
- return this;
107712
- }
107713
- /**
107714
- * Set the summary. Used when listed as subcommand of parent.
107715
- *
107716
- * @param {string} [str]
107717
- * @return {string|Command}
107718
- */
107719
- summary(str) {
107720
- if (str === void 0)
107721
- return this._summary;
107722
- this._summary = str;
107723
- return this;
107724
- }
107725
- /**
107726
- * Set an alias for the command.
107727
- *
107728
- * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
107729
- *
107730
- * @param {string} [alias]
107731
- * @return {string|Command}
107732
- */
107733
- alias(alias) {
107734
- if (alias === void 0)
107735
- return this._aliases[0];
107736
- let command = this;
107737
- if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) {
107738
- command = this.commands[this.commands.length - 1];
107739
- }
107740
- if (alias === command._name)
107741
- throw new Error("Command alias can't be the same as its name");
107742
- command._aliases.push(alias);
107743
- return this;
107744
- }
107745
- /**
107746
- * Set aliases for the command.
107747
- *
107748
- * Only the first alias is shown in the auto-generated help.
107749
- *
107750
- * @param {string[]} [aliases]
107751
- * @return {string[]|Command}
107752
- */
107753
- aliases(aliases) {
107754
- if (aliases === void 0)
107755
- return this._aliases;
107756
- aliases.forEach((alias) => this.alias(alias));
107757
- return this;
107758
- }
107759
- /**
107760
- * Set / get the command usage `str`.
107761
- *
107762
- * @param {string} [str]
107763
- * @return {String|Command}
107764
- */
107765
- usage(str) {
107766
- if (str === void 0) {
107767
- if (this._usage)
107768
- return this._usage;
107769
- const args = this._args.map((arg) => {
107770
- return humanReadableArgName(arg);
107771
- });
107772
- return [].concat(
107773
- this.options.length || this._hasHelpOption ? "[options]" : [],
107774
- this.commands.length ? "[command]" : [],
107775
- this._args.length ? args : []
107776
- ).join(" ");
107777
- }
107778
- this._usage = str;
107779
- return this;
107780
- }
107781
- /**
107782
- * Get or set the name of the command.
107783
- *
107784
- * @param {string} [str]
107785
- * @return {string|Command}
107786
- */
107787
- name(str) {
107788
- if (str === void 0)
107789
- return this._name;
107790
- this._name = str;
107791
- return this;
107792
- }
107793
- /**
107794
- * Set the name of the command from script filename, such as process.argv[1],
107795
- * or require.main.filename, or __filename.
107796
- *
107797
- * (Used internally and public although not documented in README.)
107798
- *
107799
- * @example
107800
- * program.nameFromFilename(require.main.filename);
107801
- *
107802
- * @param {string} filename
107803
- * @return {Command}
107804
- */
107805
- nameFromFilename(filename) {
107806
- this._name = path4.basename(filename, path4.extname(filename));
107807
- return this;
107808
- }
107809
- /**
107810
- * Get or set the directory for searching for executable subcommands of this command.
107811
- *
107812
- * @example
107813
- * program.executableDir(__dirname);
107814
- * // or
107815
- * program.executableDir('subcommands');
107816
- *
107817
- * @param {string} [path]
107818
- * @return {string|Command}
107819
- */
107820
- executableDir(path5) {
107821
- if (path5 === void 0)
107822
- return this._executableDir;
107823
- this._executableDir = path5;
107824
- return this;
107825
- }
107826
- /**
107827
- * Return program help documentation.
107828
- *
107829
- * @param {{ error: boolean }} [contextOptions] - pass {error:true} to wrap for stderr instead of stdout
107830
- * @return {string}
107831
- */
107832
- helpInformation(contextOptions) {
107833
- const helper = this.createHelp();
107834
- if (helper.helpWidth === void 0) {
107835
- helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth();
107836
- }
107837
- return helper.formatHelp(this, helper);
107838
- }
107839
- /**
107840
- * @api private
107841
- */
107842
- _getHelpContext(contextOptions) {
107843
- contextOptions = contextOptions || {};
107844
- const context = { error: !!contextOptions.error };
107845
- let write;
107846
- if (context.error) {
107847
- write = (arg) => this._outputConfiguration.writeErr(arg);
107848
- } else {
107849
- write = (arg) => this._outputConfiguration.writeOut(arg);
107850
- }
107851
- context.write = contextOptions.write || write;
107852
- context.command = this;
107853
- return context;
107854
- }
107855
- /**
107856
- * Output help information for this command.
107857
- *
107858
- * Outputs built-in help, and custom text added using `.addHelpText()`.
107859
- *
107860
- * @param {{ error: boolean } | Function} [contextOptions] - pass {error:true} to write to stderr instead of stdout
107861
- */
107862
- outputHelp(contextOptions) {
107863
- let deprecatedCallback;
107864
- if (typeof contextOptions === "function") {
107865
- deprecatedCallback = contextOptions;
107866
- contextOptions = void 0;
107867
- }
107868
- const context = this._getHelpContext(contextOptions);
107869
- getCommandAndParents(this).reverse().forEach((command) => command.emit("beforeAllHelp", context));
107870
- this.emit("beforeHelp", context);
107871
- let helpInformation = this.helpInformation(context);
107872
- if (deprecatedCallback) {
107873
- helpInformation = deprecatedCallback(helpInformation);
107874
- if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
107875
- throw new Error("outputHelp callback must return a string or a Buffer");
107876
- }
107877
- }
107878
- context.write(helpInformation);
107879
- this.emit(this._helpLongFlag);
107880
- this.emit("afterHelp", context);
107881
- getCommandAndParents(this).forEach((command) => command.emit("afterAllHelp", context));
107882
- }
107883
- /**
107884
- * You can pass in flags and a description to override the help
107885
- * flags and help description for your command. Pass in false to
107886
- * disable the built-in help option.
107887
- *
107888
- * @param {string | boolean} [flags]
107889
- * @param {string} [description]
107890
- * @return {Command} `this` command for chaining
107891
- */
107892
- helpOption(flags, description) {
107893
- if (typeof flags === "boolean") {
107894
- this._hasHelpOption = flags;
107895
- return this;
107896
- }
107897
- this._helpFlags = flags || this._helpFlags;
107898
- this._helpDescription = description || this._helpDescription;
107899
- const helpFlags = splitOptionFlags(this._helpFlags);
107900
- this._helpShortFlag = helpFlags.shortFlag;
107901
- this._helpLongFlag = helpFlags.longFlag;
107902
- return this;
107903
- }
107904
- /**
107905
- * Output help information and exit.
107906
- *
107907
- * Outputs built-in help, and custom text added using `.addHelpText()`.
107908
- *
107909
- * @param {{ error: boolean }} [contextOptions] - pass {error:true} to write to stderr instead of stdout
107910
- */
107911
- help(contextOptions) {
107912
- this.outputHelp(contextOptions);
107913
- let exitCode = process3.exitCode || 0;
107914
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
107915
- exitCode = 1;
107916
- }
107917
- this._exit(exitCode, "commander.help", "(outputHelp)");
107918
- }
107919
- /**
107920
- * Add additional text to be displayed with the built-in help.
107921
- *
107922
- * Position is 'before' or 'after' to affect just this command,
107923
- * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
107924
- *
107925
- * @param {string} position - before or after built-in help
107926
- * @param {string | Function} text - string to add, or a function returning a string
107927
- * @return {Command} `this` command for chaining
107928
- */
107929
- addHelpText(position, text) {
107930
- const allowedValues = ["beforeAll", "before", "after", "afterAll"];
107931
- if (!allowedValues.includes(position)) {
107932
- throw new Error(`Unexpected value for position to addHelpText.
107933
- Expecting one of '${allowedValues.join("', '")}'`);
107934
- }
107935
- const helpEvent = `${position}Help`;
107936
- this.on(helpEvent, (context) => {
107937
- let helpStr;
107938
- if (typeof text === "function") {
107939
- helpStr = text({ error: context.error, command: context.command });
107940
- } else {
107941
- helpStr = text;
107942
- }
107943
- if (helpStr) {
107944
- context.write(`${helpStr}
107945
- `);
107946
- }
107947
- });
107948
- return this;
107949
- }
107950
- };
107951
- function outputHelpIfRequested(cmd, args) {
107952
- const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
107953
- if (helpOption) {
107954
- cmd.outputHelp();
107955
- cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
107956
- }
107957
- }
107958
- function incrementNodeInspectorPort(args) {
107959
- return args.map((arg) => {
107960
- if (!arg.startsWith("--inspect")) {
107961
- return arg;
107962
- }
107963
- let debugOption;
107964
- let debugHost = "127.0.0.1";
107965
- let debugPort = "9229";
107966
- let match;
107967
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
107968
- debugOption = match[1];
107969
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
107970
- debugOption = match[1];
107971
- if (/^\d+$/.test(match[3])) {
107972
- debugPort = match[3];
107973
- } else {
107974
- debugHost = match[3];
107975
- }
107976
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
107977
- debugOption = match[1];
107978
- debugHost = match[3];
107979
- debugPort = match[4];
107980
- }
107981
- if (debugOption && debugPort !== "0") {
107982
- return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
107983
- }
107984
- return arg;
107985
- });
107986
- }
107987
- function getCommandAndParents(startCommand) {
107988
- const result = [];
107989
- for (let command = startCommand; command; command = command.parent) {
107990
- result.push(command);
107991
- }
107992
- return result;
107993
- }
107994
- exports2.Command = Command3;
107995
- }
107996
- });
107997
-
107998
- // node_modules/commander/index.js
107999
- var require_commander = __commonJS({
108000
- "node_modules/commander/index.js"(exports2, module2) {
108001
- var { Argument: Argument2 } = require_argument();
108002
- var { Command: Command3 } = require_command();
108003
- var { CommanderError: CommanderError2, InvalidArgumentError: InvalidArgumentError2 } = require_error();
108004
- var { Help: Help2 } = require_help();
108005
- var { Option: Option3 } = require_option();
108006
- exports2 = module2.exports = new Command3();
108007
- exports2.program = exports2;
108008
- exports2.Argument = Argument2;
108009
- exports2.Command = Command3;
108010
- exports2.CommanderError = CommanderError2;
108011
- exports2.Help = Help2;
108012
- exports2.InvalidArgumentError = InvalidArgumentError2;
108013
- exports2.InvalidOptionArgumentError = InvalidArgumentError2;
108014
- exports2.Option = Option3;
108015
- }
108016
- });
108017
-
108018
105223
  // src/cli/index.ts
108019
105224
  var cli_exports = {};
108020
105225
  __export(cli_exports, {
108021
105226
  AstUtils: () => ast_utils_exports,
108022
105227
  GenAst: () => ast_exports2,
105228
+ extractAstNode: () => extractAstNode,
108023
105229
  getAuroraServices: () => getAuroraServices,
108024
105230
  getEmptyAuroraServices: () => getEmptyAuroraServices,
108025
105231
  parse: () => parse
@@ -112724,19 +109930,19 @@ function toKey(value) {
112724
109930
  var toKey_default = toKey;
112725
109931
 
112726
109932
  // node_modules/lodash-es/_baseGet.js
112727
- function baseGet(object, path4) {
112728
- path4 = castPath_default(path4, object);
112729
- var index = 0, length = path4.length;
109933
+ function baseGet(object, path2) {
109934
+ path2 = castPath_default(path2, object);
109935
+ var index = 0, length = path2.length;
112730
109936
  while (object != null && index < length) {
112731
- object = object[toKey_default(path4[index++])];
109937
+ object = object[toKey_default(path2[index++])];
112732
109938
  }
112733
109939
  return index && index == length ? object : void 0;
112734
109940
  }
112735
109941
  var baseGet_default = baseGet;
112736
109942
 
112737
109943
  // node_modules/lodash-es/get.js
112738
- function get(object, path4, defaultValue) {
112739
- var result = object == null ? void 0 : baseGet_default(object, path4);
109944
+ function get(object, path2, defaultValue) {
109945
+ var result = object == null ? void 0 : baseGet_default(object, path2);
112740
109946
  return result === void 0 ? defaultValue : result;
112741
109947
  }
112742
109948
  var get_default = get;
@@ -113648,11 +110854,11 @@ function baseHasIn(object, key) {
113648
110854
  var baseHasIn_default = baseHasIn;
113649
110855
 
113650
110856
  // node_modules/lodash-es/_hasPath.js
113651
- function hasPath(object, path4, hasFunc) {
113652
- path4 = castPath_default(path4, object);
113653
- var index = -1, length = path4.length, result = false;
110857
+ function hasPath(object, path2, hasFunc) {
110858
+ path2 = castPath_default(path2, object);
110859
+ var index = -1, length = path2.length, result = false;
113654
110860
  while (++index < length) {
113655
- var key = toKey_default(path4[index]);
110861
+ var key = toKey_default(path2[index]);
113656
110862
  if (!(result = object != null && hasFunc(object, key))) {
113657
110863
  break;
113658
110864
  }
@@ -113667,21 +110873,21 @@ function hasPath(object, path4, hasFunc) {
113667
110873
  var hasPath_default = hasPath;
113668
110874
 
113669
110875
  // node_modules/lodash-es/hasIn.js
113670
- function hasIn(object, path4) {
113671
- return object != null && hasPath_default(object, path4, baseHasIn_default);
110876
+ function hasIn(object, path2) {
110877
+ return object != null && hasPath_default(object, path2, baseHasIn_default);
113672
110878
  }
113673
110879
  var hasIn_default = hasIn;
113674
110880
 
113675
110881
  // node_modules/lodash-es/_baseMatchesProperty.js
113676
110882
  var COMPARE_PARTIAL_FLAG6 = 1;
113677
110883
  var COMPARE_UNORDERED_FLAG4 = 2;
113678
- function baseMatchesProperty(path4, srcValue) {
113679
- if (isKey_default(path4) && isStrictComparable_default(srcValue)) {
113680
- return matchesStrictComparable_default(toKey_default(path4), srcValue);
110884
+ function baseMatchesProperty(path2, srcValue) {
110885
+ if (isKey_default(path2) && isStrictComparable_default(srcValue)) {
110886
+ return matchesStrictComparable_default(toKey_default(path2), srcValue);
113681
110887
  }
113682
110888
  return function(object) {
113683
- var objValue = get_default(object, path4);
113684
- return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path4) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
110889
+ var objValue = get_default(object, path2);
110890
+ return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path2) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
113685
110891
  };
113686
110892
  }
113687
110893
  var baseMatchesProperty_default = baseMatchesProperty;
@@ -113695,16 +110901,16 @@ function baseProperty(key) {
113695
110901
  var baseProperty_default = baseProperty;
113696
110902
 
113697
110903
  // node_modules/lodash-es/_basePropertyDeep.js
113698
- function basePropertyDeep(path4) {
110904
+ function basePropertyDeep(path2) {
113699
110905
  return function(object) {
113700
- return baseGet_default(object, path4);
110906
+ return baseGet_default(object, path2);
113701
110907
  };
113702
110908
  }
113703
110909
  var basePropertyDeep_default = basePropertyDeep;
113704
110910
 
113705
110911
  // node_modules/lodash-es/property.js
113706
- function property(path4) {
113707
- return isKey_default(path4) ? baseProperty_default(toKey_default(path4)) : basePropertyDeep_default(path4);
110912
+ function property(path2) {
110913
+ return isKey_default(path2) ? baseProperty_default(toKey_default(path2)) : basePropertyDeep_default(path2);
113708
110914
  }
113709
110915
  var property_default = property;
113710
110916
 
@@ -114072,8 +111278,8 @@ function baseHas(object, key) {
114072
111278
  var baseHas_default = baseHas;
114073
111279
 
114074
111280
  // node_modules/lodash-es/has.js
114075
- function has(object, path4) {
114076
- return object != null && hasPath_default(object, path4, baseHas_default);
111281
+ function has(object, path2) {
111282
+ return object != null && hasPath_default(object, path2, baseHas_default);
114077
111283
  }
114078
111284
  var has_default = has;
114079
111285
 
@@ -114221,14 +111427,14 @@ function negate(predicate) {
114221
111427
  var negate_default = negate;
114222
111428
 
114223
111429
  // node_modules/lodash-es/_baseSet.js
114224
- function baseSet(object, path4, value, customizer) {
111430
+ function baseSet(object, path2, value, customizer) {
114225
111431
  if (!isObject_default(object)) {
114226
111432
  return object;
114227
111433
  }
114228
- path4 = castPath_default(path4, object);
114229
- var index = -1, length = path4.length, lastIndex = length - 1, nested = object;
111434
+ path2 = castPath_default(path2, object);
111435
+ var index = -1, length = path2.length, lastIndex = length - 1, nested = object;
114230
111436
  while (nested != null && ++index < length) {
114231
- var key = toKey_default(path4[index]), newValue = value;
111437
+ var key = toKey_default(path2[index]), newValue = value;
114232
111438
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
114233
111439
  return object;
114234
111440
  }
@@ -114236,7 +111442,7 @@ function baseSet(object, path4, value, customizer) {
114236
111442
  var objValue = nested[key];
114237
111443
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
114238
111444
  if (newValue === void 0) {
114239
- newValue = isObject_default(objValue) ? objValue : isIndex_default(path4[index + 1]) ? [] : {};
111445
+ newValue = isObject_default(objValue) ? objValue : isIndex_default(path2[index + 1]) ? [] : {};
114240
111446
  }
114241
111447
  }
114242
111448
  assignValue_default(nested, key, newValue);
@@ -114250,9 +111456,9 @@ var baseSet_default = baseSet;
114250
111456
  function basePickBy(object, paths, predicate) {
114251
111457
  var index = -1, length = paths.length, result = {};
114252
111458
  while (++index < length) {
114253
- var path4 = paths[index], value = baseGet_default(object, path4);
114254
- if (predicate(value, path4)) {
114255
- baseSet_default(result, castPath_default(path4, object), value);
111459
+ var path2 = paths[index], value = baseGet_default(object, path2);
111460
+ if (predicate(value, path2)) {
111461
+ baseSet_default(result, castPath_default(path2, object), value);
114256
111462
  }
114257
111463
  }
114258
111464
  return result;
@@ -114268,8 +111474,8 @@ function pickBy(object, predicate) {
114268
111474
  return [prop];
114269
111475
  });
114270
111476
  predicate = baseIteratee_default(predicate);
114271
- return basePickBy_default(object, props, function(value, path4) {
114272
- return predicate(value, path4[0]);
111477
+ return basePickBy_default(object, props, function(value, path2) {
111478
+ return predicate(value, path2[0]);
114273
111479
  });
114274
111480
  }
114275
111481
  var pickBy_default = pickBy;
@@ -115866,12 +113072,12 @@ function assignCategoriesMapProp(tokenTypes) {
115866
113072
  singleAssignCategoriesToksMap([], currTokType);
115867
113073
  });
115868
113074
  }
115869
- function singleAssignCategoriesToksMap(path4, nextNode) {
115870
- forEach_default(path4, (pathNode) => {
113075
+ function singleAssignCategoriesToksMap(path2, nextNode) {
113076
+ forEach_default(path2, (pathNode) => {
115871
113077
  nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
115872
113078
  });
115873
113079
  forEach_default(nextNode.CATEGORIES, (nextCategory) => {
115874
- const newPath = path4.concat(nextNode);
113080
+ const newPath = path2.concat(nextNode);
115875
113081
  if (!includes_default(newPath, nextCategory)) {
115876
113082
  singleAssignCategoriesToksMap(newPath, nextCategory);
115877
113083
  }
@@ -116715,10 +113921,10 @@ var GastRefResolverVisitor = class extends GAstVisitor {
116715
113921
 
116716
113922
  // node_modules/chevrotain/lib/src/parse/grammar/interpreter.js
116717
113923
  var AbstractNextPossibleTokensWalker = class extends RestWalker {
116718
- constructor(topProd, path4) {
113924
+ constructor(topProd, path2) {
116719
113925
  super();
116720
113926
  this.topProd = topProd;
116721
- this.path = path4;
113927
+ this.path = path2;
116722
113928
  this.possibleTokTypes = [];
116723
113929
  this.nextProductionName = "";
116724
113930
  this.nextProductionOccurrence = 0;
@@ -116762,9 +113968,9 @@ var AbstractNextPossibleTokensWalker = class extends RestWalker {
116762
113968
  }
116763
113969
  };
116764
113970
  var NextAfterTokenWalker = class extends AbstractNextPossibleTokensWalker {
116765
- constructor(topProd, path4) {
116766
- super(topProd, path4);
116767
- this.path = path4;
113971
+ constructor(topProd, path2) {
113972
+ super(topProd, path2);
113973
+ this.path = path2;
116768
113974
  this.nextTerminalName = "";
116769
113975
  this.nextTerminalOccurrence = 0;
116770
113976
  this.nextTerminalName = this.path.lastTok.name;
@@ -117372,10 +114578,10 @@ function initializeArrayOfArrays(size) {
117372
114578
  }
117373
114579
  return result;
117374
114580
  }
117375
- function pathToHashKeys(path4) {
114581
+ function pathToHashKeys(path2) {
117376
114582
  let keys2 = [""];
117377
- for (let i = 0; i < path4.length; i++) {
117378
- const tokType = path4[i];
114583
+ for (let i = 0; i < path2.length; i++) {
114584
+ const tokType = path2[i];
117379
114585
  const longerKeys = [];
117380
114586
  for (let j = 0; j < keys2.length; j++) {
117381
114587
  const currShorterKey = keys2[j];
@@ -117615,7 +114821,7 @@ function validateRuleIsOverridden(ruleName, definedRulesNames, className) {
117615
114821
  }
117616
114822
  return errors;
117617
114823
  }
117618
- function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path4 = []) {
114824
+ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path2 = []) {
117619
114825
  const errors = [];
117620
114826
  const nextNonTerminals = getFirstNoneTerminal(currRule.definition);
117621
114827
  if (isEmpty_default(nextNonTerminals)) {
@@ -117627,15 +114833,15 @@ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path4 = [])
117627
114833
  errors.push({
117628
114834
  message: errMsgProvider.buildLeftRecursionError({
117629
114835
  topLevelRule: topRule,
117630
- leftRecursionPath: path4
114836
+ leftRecursionPath: path2
117631
114837
  }),
117632
114838
  type: ParserDefinitionErrorType.LEFT_RECURSION,
117633
114839
  ruleName
117634
114840
  });
117635
114841
  }
117636
- const validNextSteps = difference_default(nextNonTerminals, path4.concat([topRule]));
114842
+ const validNextSteps = difference_default(nextNonTerminals, path2.concat([topRule]));
117637
114843
  const errorsFromNextSteps = flatMap_default(validNextSteps, (currRefRule) => {
117638
- const newPath = clone_default(path4);
114844
+ const newPath = clone_default(path2);
117639
114845
  newPath.push(currRefRule);
117640
114846
  return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
117641
114847
  });
@@ -120495,7 +117701,7 @@ var LLStarLookaheadStrategy = class extends LLkLookaheadStrategy {
120495
117701
  occurrence: prodOccurrence,
120496
117702
  prodType: "Alternation",
120497
117703
  rule
120498
- }), (currAlt) => map_default(currAlt, (path4) => path4[0]));
117704
+ }), (currAlt) => map_default(currAlt, (path2) => path2[0]));
120499
117705
  if (isLL1Sequence(partialAlts, false) && !dynamicTokensEnabled) {
120500
117706
  const choiceToAlt = reduce_default(partialAlts, (result, currAlt, idx) => {
120501
117707
  forEach_default(currAlt, (currTokType) => {
@@ -120640,7 +117846,7 @@ function adaptivePredict(dfaCaches, decision, predicateSet, logging) {
120640
117846
  function performLookahead(dfa, s0, predicateSet, logging) {
120641
117847
  let previousD = s0;
120642
117848
  let i = 1;
120643
- const path4 = [];
117849
+ const path2 = [];
120644
117850
  let t = this.LA(i++);
120645
117851
  while (true) {
120646
117852
  let d = getExistingTargetState(previousD, t);
@@ -120648,13 +117854,13 @@ function performLookahead(dfa, s0, predicateSet, logging) {
120648
117854
  d = computeLookaheadTarget.apply(this, [dfa, previousD, t, i, predicateSet, logging]);
120649
117855
  }
120650
117856
  if (d === DFA_ERROR) {
120651
- return buildAdaptivePredictError(path4, previousD, t);
117857
+ return buildAdaptivePredictError(path2, previousD, t);
120652
117858
  }
120653
117859
  if (d.isAcceptState === true) {
120654
117860
  return d.prediction;
120655
117861
  }
120656
117862
  previousD = d;
120657
- path4.push(t);
117863
+ path2.push(t);
120658
117864
  t = this.LA(i++);
120659
117865
  }
120660
117866
  }
@@ -120727,13 +117933,13 @@ function getProductionDslName2(prod) {
120727
117933
  throw Error("non exhaustive match");
120728
117934
  }
120729
117935
  }
120730
- function buildAdaptivePredictError(path4, previous, current) {
117936
+ function buildAdaptivePredictError(path2, previous, current) {
120731
117937
  const nextTransitions = flatMap_default(previous.configs.elements, (e) => e.state.transitions);
120732
117938
  const nextTokenTypes = uniqBy_default(nextTransitions.filter((e) => e instanceof AtomTransition).map((e) => e.tokenType), (e) => e.tokenTypeIdx);
120733
117939
  return {
120734
117940
  actualToken: current,
120735
117941
  possibleTokenTypes: nextTokenTypes,
120736
- tokenPath: path4
117942
+ tokenPath: path2
120737
117943
  };
120738
117944
  }
120739
117945
  function getExistingTargetState(state, token) {
@@ -121176,7 +118382,7 @@ var Diagnostic;
121176
118382
  Diagnostic2.is = is;
121177
118383
  })(Diagnostic || (Diagnostic = {}));
121178
118384
  var Command;
121179
- (function(Command3) {
118385
+ (function(Command2) {
121180
118386
  function create(title, command, ...args) {
121181
118387
  let result = { title, command };
121182
118388
  if (Is.defined(args) && args.length > 0) {
@@ -121184,12 +118390,12 @@ var Command;
121184
118390
  }
121185
118391
  return result;
121186
118392
  }
121187
- Command3.create = create;
118393
+ Command2.create = create;
121188
118394
  function is(value) {
121189
118395
  let candidate = value;
121190
118396
  return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
121191
118397
  }
121192
- Command3.is = is;
118398
+ Command2.is = is;
121193
118399
  })(Command || (Command = {}));
121194
118400
  var TextEdit;
121195
118401
  (function(TextEdit2) {
@@ -122075,7 +119281,7 @@ var FullTextDocument = class {
122075
119281
  };
122076
119282
  var Is;
122077
119283
  (function(Is2) {
122078
- const toString4 = Object.prototype.toString;
119284
+ const toString3 = Object.prototype.toString;
122079
119285
  function defined(value) {
122080
119286
  return typeof value !== "undefined";
122081
119287
  }
@@ -122089,27 +119295,27 @@ var Is;
122089
119295
  }
122090
119296
  Is2.boolean = boolean;
122091
119297
  function string(value) {
122092
- return toString4.call(value) === "[object String]";
119298
+ return toString3.call(value) === "[object String]";
122093
119299
  }
122094
119300
  Is2.string = string;
122095
119301
  function number(value) {
122096
- return toString4.call(value) === "[object Number]";
119302
+ return toString3.call(value) === "[object Number]";
122097
119303
  }
122098
119304
  Is2.number = number;
122099
119305
  function numberRange(value, min2, max) {
122100
- return toString4.call(value) === "[object Number]" && min2 <= value && value <= max;
119306
+ return toString3.call(value) === "[object Number]" && min2 <= value && value <= max;
122101
119307
  }
122102
119308
  Is2.numberRange = numberRange;
122103
119309
  function integer2(value) {
122104
- return toString4.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
119310
+ return toString3.call(value) === "[object Number]" && -2147483648 <= value && value <= 2147483647;
122105
119311
  }
122106
119312
  Is2.integer = integer2;
122107
119313
  function uinteger2(value) {
122108
- return toString4.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
119314
+ return toString3.call(value) === "[object Number]" && 0 <= value && value <= 2147483647;
122109
119315
  }
122110
119316
  Is2.uinteger = uinteger2;
122111
119317
  function func(value) {
122112
- return toString4.call(value) === "[object Function]";
119318
+ return toString3.call(value) === "[object Function]";
122113
119319
  }
122114
119320
  Is2.func = func;
122115
119321
  function objectLiteral(value) {
@@ -123301,11 +120507,11 @@ __reExport(cancellation_exports, __toESM(require_cancellation(), 1));
123301
120507
 
123302
120508
  // node_modules/langium/lib/utils/promise-utils.js
123303
120509
  function delayNextTick() {
123304
- return new Promise((resolve3) => {
120510
+ return new Promise((resolve2) => {
123305
120511
  if (typeof setImmediate === "undefined") {
123306
- setTimeout(resolve3, 0);
120512
+ setTimeout(resolve2, 0);
123307
120513
  } else {
123308
- setImmediate(resolve3);
120514
+ setImmediate(resolve2);
123309
120515
  }
123310
120516
  });
123311
120517
  }
@@ -123337,9 +120543,9 @@ async function interruptAndCheck(token) {
123337
120543
  }
123338
120544
  var Deferred = class {
123339
120545
  constructor() {
123340
- this.promise = new Promise((resolve3, reject2) => {
120546
+ this.promise = new Promise((resolve2, reject2) => {
123341
120547
  this.resolve = (arg) => {
123342
- resolve3(arg);
120548
+ resolve2(arg);
123343
120549
  return this;
123344
120550
  };
123345
120551
  this.reject = (err) => {
@@ -124398,12 +121604,12 @@ var DefaultReferences = class {
124398
121604
  const nameNode = this.nameProvider.getNameNode(targetNode);
124399
121605
  if (nameNode) {
124400
121606
  const doc = getDocument(targetNode);
124401
- const path4 = this.nodeLocator.getAstNodePath(targetNode);
121607
+ const path2 = this.nodeLocator.getAstNodePath(targetNode);
124402
121608
  return {
124403
121609
  sourceUri: doc.uri,
124404
- sourcePath: path4,
121610
+ sourcePath: path2,
124405
121611
  targetUri: doc.uri,
124406
- targetPath: path4,
121612
+ targetPath: path2,
124407
121613
  segment: toDocumentSegment(nameNode),
124408
121614
  local: true
124409
121615
  };
@@ -125453,9 +122659,9 @@ var DefaultAstNodeDescriptionProvider = class {
125453
122659
  createDescription(node, name, document2) {
125454
122660
  const doc = document2 !== null && document2 !== void 0 ? document2 : getDocument(node);
125455
122661
  name !== null && name !== void 0 ? name : name = this.nameProvider.getName(node);
125456
- const path4 = this.astNodeLocator.getAstNodePath(node);
122662
+ const path2 = this.astNodeLocator.getAstNodePath(node);
125457
122663
  if (!name) {
125458
- throw new Error(`Node at path ${path4} has no name.`);
122664
+ throw new Error(`Node at path ${path2} has no name.`);
125459
122665
  }
125460
122666
  let nameNodeSegment;
125461
122667
  const nameSegmentGetter = () => {
@@ -125471,7 +122677,7 @@ var DefaultAstNodeDescriptionProvider = class {
125471
122677
  selectionSegment: toDocumentSegment(node.$cstNode),
125472
122678
  type: node.$type,
125473
122679
  documentUri: doc.uri,
125474
- path: path4
122680
+ path: path2
125475
122681
  };
125476
122682
  }
125477
122683
  };
@@ -125535,8 +122741,8 @@ var DefaultAstNodeLocator = class {
125535
122741
  }
125536
122742
  return $containerProperty;
125537
122743
  }
125538
- getAstNode(node, path4) {
125539
- const segments = path4.split(this.segmentSeparator);
122744
+ getAstNode(node, path2) {
122745
+ const segments = path2.split(this.segmentSeparator);
125540
122746
  return segments.reduce((previousValue, currentValue) => {
125541
122747
  if (!previousValue || currentValue.length === 0) {
125542
122748
  return previousValue;
@@ -125884,15 +123090,15 @@ var DefaultDocumentBuilder = class {
125884
123090
  } else if (cancelToken.isCancellationRequested) {
125885
123091
  return Promise.reject(OperationCancelled);
125886
123092
  }
125887
- return new Promise((resolve3, reject2) => {
123093
+ return new Promise((resolve2, reject2) => {
125888
123094
  const buildDisposable = this.onBuildPhase(state, () => {
125889
123095
  buildDisposable.dispose();
125890
123096
  cancelDisposable.dispose();
125891
123097
  if (uri) {
125892
123098
  const document2 = this.langiumDocuments.getDocument(uri);
125893
- resolve3(document2 === null || document2 === void 0 ? void 0 : document2.uri);
123099
+ resolve2(document2 === null || document2 === void 0 ? void 0 : document2.uri);
125894
123100
  } else {
125895
- resolve3(void 0);
123101
+ resolve2(void 0);
125896
123102
  }
125897
123103
  });
125898
123104
  const cancelDisposable = cancelToken.onCancellationRequested(() => {
@@ -133245,828 +130451,6 @@ var IdCacheImpl = class {
133245
130451
  }
133246
130452
  };
133247
130453
 
133248
- // node_modules/langium/lib/generate/generator-tracing.js
133249
- function getSourceRegion(sourceSpec) {
133250
- var _a, _b;
133251
- if (!sourceSpec) {
133252
- return void 0;
133253
- } else if ("astNode" in sourceSpec) {
133254
- return getSourceRegionOfAstNode(sourceSpec);
133255
- } else if (Array.isArray(sourceSpec)) {
133256
- return sourceSpec.reduce(mergeDocumentSegment, void 0);
133257
- } else {
133258
- const sourceRegion = sourceSpec;
133259
- const sourceFileURIviaCstNode = isCstNode(sourceRegion) ? getDocumentURIOrUndefined((_b = (_a = sourceRegion === null || sourceRegion === void 0 ? void 0 : sourceRegion.root) === null || _a === void 0 ? void 0 : _a.astNode) !== null && _b !== void 0 ? _b : sourceRegion === null || sourceRegion === void 0 ? void 0 : sourceRegion.astNode) : void 0;
133260
- return copyDocumentSegment(sourceRegion, sourceFileURIviaCstNode);
133261
- }
133262
- }
133263
- function isCstNode(segment) {
133264
- return typeof segment !== "undefined" && "element" in segment && "text" in segment;
133265
- }
133266
- function getDocumentURIOrUndefined(astNode) {
133267
- try {
133268
- return getDocument(astNode).uri.toString();
133269
- } catch (e) {
133270
- return void 0;
133271
- }
133272
- }
133273
- function getSourceRegionOfAstNode(sourceSpec) {
133274
- var _a, _b;
133275
- const { astNode, property: property2, index } = sourceSpec !== null && sourceSpec !== void 0 ? sourceSpec : {};
133276
- const textRegion = (_a = astNode === null || astNode === void 0 ? void 0 : astNode.$cstNode) !== null && _a !== void 0 ? _a : astNode === null || astNode === void 0 ? void 0 : astNode.$textRegion;
133277
- if (astNode === void 0 || textRegion === void 0) {
133278
- return void 0;
133279
- } else if (property2 === void 0) {
133280
- return copyDocumentSegment(textRegion, getDocumentURI(astNode));
133281
- } else {
133282
- const getSingleOrCompoundRegion = (regions) => {
133283
- if (index !== void 0 && index > -1 && Array.isArray(astNode[property2])) {
133284
- return index < regions.length ? regions[index] : void 0;
133285
- } else {
133286
- return regions.reduce(mergeDocumentSegment, void 0);
133287
- }
133288
- };
133289
- if ((_b = textRegion.assignments) === null || _b === void 0 ? void 0 : _b[property2]) {
133290
- const region = getSingleOrCompoundRegion(textRegion.assignments[property2]);
133291
- return region && copyDocumentSegment(region, getDocumentURI(astNode));
133292
- } else if (astNode.$cstNode) {
133293
- const region = getSingleOrCompoundRegion(findNodesForProperty(astNode.$cstNode, property2));
133294
- return region && copyDocumentSegment(region, getDocumentURI(astNode));
133295
- } else {
133296
- return void 0;
133297
- }
133298
- }
133299
- }
133300
- function getDocumentURI(astNode) {
133301
- var _a, _b, _c, _d;
133302
- if (astNode.$cstNode) {
133303
- return (_b = (_a = getDocument(astNode)) === null || _a === void 0 ? void 0 : _a.uri) === null || _b === void 0 ? void 0 : _b.toString();
133304
- } else if (astNode.$textRegion) {
133305
- return astNode.$textRegion.documentURI || ((_d = (_c = new TreeStreamImpl(astNode, (n) => n.$container ? [n.$container] : []).find((n) => {
133306
- var _a2;
133307
- return (_a2 = n.$textRegion) === null || _a2 === void 0 ? void 0 : _a2.documentURI;
133308
- })) === null || _c === void 0 ? void 0 : _c.$textRegion) === null || _d === void 0 ? void 0 : _d.documentURI);
133309
- } else {
133310
- return void 0;
133311
- }
133312
- }
133313
- function copyDocumentSegment(region, fileURI) {
133314
- var _a, _b;
133315
- const result = {
133316
- offset: region.offset,
133317
- end: (_a = region.end) !== null && _a !== void 0 ? _a : region.offset + region.length,
133318
- length: (_b = region.length) !== null && _b !== void 0 ? _b : region.end - region.offset
133319
- };
133320
- if (region.range) {
133321
- result.range = region.range;
133322
- }
133323
- fileURI !== null && fileURI !== void 0 ? fileURI : fileURI = region.fileURI;
133324
- if (fileURI) {
133325
- result.fileURI = fileURI;
133326
- }
133327
- return result;
133328
- }
133329
- function mergeDocumentSegment(prev, curr) {
133330
- var _a, _b;
133331
- if (!prev) {
133332
- return curr && copyDocumentSegment(curr);
133333
- } else if (!curr) {
133334
- return prev && copyDocumentSegment(prev);
133335
- }
133336
- const prevEnd = (_a = prev.end) !== null && _a !== void 0 ? _a : prev.offset + prev.length;
133337
- const currEnd = (_b = curr.end) !== null && _b !== void 0 ? _b : curr.offset + curr.length;
133338
- const offset = Math.min(prev.offset, curr.offset);
133339
- const end = Math.max(prevEnd, currEnd);
133340
- const length = end - offset;
133341
- const result = {
133342
- offset,
133343
- end,
133344
- length
133345
- };
133346
- if (prev.range && curr.range) {
133347
- result.range = {
133348
- start: curr.range.start.line < prev.range.start.line || curr.range.start.line === prev.range.start.line && curr.range.start.character < prev.range.start.character ? curr.range.start : prev.range.start,
133349
- end: curr.range.end.line > prev.range.end.line || curr.range.end.line === prev.range.end.line && curr.range.end.character > prev.range.end.character ? curr.range.end : prev.range.end
133350
- };
133351
- }
133352
- if (prev.fileURI || curr.fileURI) {
133353
- const prevURI = prev.fileURI;
133354
- const currURI = curr.fileURI;
133355
- const fileURI = prevURI && currURI && prevURI !== currURI ? `<unmergable text regions of ${prevURI}, ${currURI}>` : prevURI !== null && prevURI !== void 0 ? prevURI : currURI;
133356
- result.fileURI = fileURI;
133357
- }
133358
- return result;
133359
- }
133360
-
133361
- // node_modules/langium/lib/generate/node-processor.js
133362
- var Context = class {
133363
- constructor(defaultIndent) {
133364
- this.defaultIndentation = " ";
133365
- this.pendingIndent = true;
133366
- this.currentIndents = [];
133367
- this.recentNonImmediateIndents = [];
133368
- this.traceData = [];
133369
- this.lines = [[]];
133370
- this.length = 0;
133371
- if (typeof defaultIndent === "string") {
133372
- this.defaultIndentation = defaultIndent;
133373
- } else if (typeof defaultIndent === "number") {
133374
- this.defaultIndentation = "".padStart(defaultIndent);
133375
- }
133376
- }
133377
- get content() {
133378
- return this.lines.map((e) => e.join("")).join("");
133379
- }
133380
- get contentLength() {
133381
- return this.length;
133382
- }
133383
- get currentLineNumber() {
133384
- return this.lines.length - 1;
133385
- }
133386
- get currentLineContent() {
133387
- return this.lines[this.currentLineNumber].join("");
133388
- }
133389
- get currentPosition() {
133390
- return {
133391
- offset: this.contentLength,
133392
- line: this.currentLineNumber,
133393
- character: this.currentLineContent.length
133394
- };
133395
- }
133396
- append(value, isIndent) {
133397
- if (value.length > 0) {
133398
- const beforePos = isIndent && this.currentPosition;
133399
- this.lines[this.currentLineNumber].push(value);
133400
- this.length += value.length;
133401
- if (beforePos) {
133402
- this.indentPendingTraceRegions(beforePos);
133403
- }
133404
- }
133405
- }
133406
- indentPendingTraceRegions(before) {
133407
- for (let i = this.traceData.length - 1; i >= 0; i--) {
133408
- const tr = this.traceData[i];
133409
- if (tr.targetStart && tr.targetStart.offset === before.offset)
133410
- tr.targetStart = this.currentPosition;
133411
- }
133412
- }
133413
- increaseIndent(node) {
133414
- this.currentIndents.push(node);
133415
- if (!node.indentImmediately) {
133416
- this.recentNonImmediateIndents.push(node);
133417
- }
133418
- }
133419
- decreaseIndent() {
133420
- this.currentIndents.pop();
133421
- }
133422
- get relevantIndents() {
133423
- return this.currentIndents.filter((i) => !this.recentNonImmediateIndents.includes(i));
133424
- }
133425
- resetCurrentLine() {
133426
- this.length -= this.lines[this.currentLineNumber].join("").length;
133427
- this.lines[this.currentLineNumber] = [];
133428
- this.pendingIndent = true;
133429
- }
133430
- addNewLine() {
133431
- this.pendingIndent = true;
133432
- this.lines.push([]);
133433
- this.recentNonImmediateIndents.length = 0;
133434
- }
133435
- pushTraceRegion(sourceRegion) {
133436
- const region = createTraceRegion(sourceRegion, this.currentPosition, (it) => {
133437
- var _a, _b;
133438
- return (_b = (_a = this.traceData[this.traceData.length - 1]) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.push(it);
133439
- });
133440
- this.traceData.push(region);
133441
- return region;
133442
- }
133443
- popTraceRegion(expected) {
133444
- const traceRegion = this.traceData.pop();
133445
- this.assertTrue(traceRegion === expected, "Trace region mismatch!");
133446
- return traceRegion;
133447
- }
133448
- getParentTraceSourceFileURI() {
133449
- var _a;
133450
- for (let i = this.traceData.length - 1; i > -1; i--) {
133451
- const fileUri = (_a = this.traceData[i].sourceRegion) === null || _a === void 0 ? void 0 : _a.fileURI;
133452
- if (fileUri)
133453
- return fileUri;
133454
- }
133455
- return void 0;
133456
- }
133457
- assertTrue(condition, msg) {
133458
- if (!condition) {
133459
- throw new Error(msg);
133460
- }
133461
- }
133462
- };
133463
- function createTraceRegion(sourceRegion, targetStart, accept) {
133464
- const result = {
133465
- sourceRegion,
133466
- targetRegion: void 0,
133467
- children: [],
133468
- targetStart,
133469
- complete: (targetEnd) => {
133470
- var _a, _b;
133471
- result.targetRegion = {
133472
- offset: result.targetStart.offset,
133473
- end: targetEnd.offset,
133474
- length: targetEnd.offset - result.targetStart.offset,
133475
- range: {
133476
- start: {
133477
- line: result.targetStart.line,
133478
- character: result.targetStart.character
133479
- },
133480
- end: {
133481
- line: targetEnd.line,
133482
- character: targetEnd.character
133483
- }
133484
- }
133485
- };
133486
- delete result.targetStart;
133487
- if (((_a = result.children) === null || _a === void 0 ? void 0 : _a.length) === 0) {
133488
- delete result.children;
133489
- }
133490
- if ((_b = result.targetRegion) === null || _b === void 0 ? void 0 : _b.length) {
133491
- accept(result);
133492
- }
133493
- delete result.complete;
133494
- return result;
133495
- }
133496
- };
133497
- return result;
133498
- }
133499
- function processGeneratorNode(node, defaultIndentation) {
133500
- const context = new Context(defaultIndentation);
133501
- const trace = context.pushTraceRegion(void 0);
133502
- processNodeInternal(node, context);
133503
- context.popTraceRegion(trace);
133504
- trace.complete && trace.complete(context.currentPosition);
133505
- const singleChild = trace.children && trace.children.length === 1 ? trace.children[0] : void 0;
133506
- const singleChildTargetRegion = singleChild === null || singleChild === void 0 ? void 0 : singleChild.targetRegion;
133507
- const rootTargetRegion = trace.targetRegion;
133508
- if (singleChildTargetRegion && singleChild.sourceRegion && singleChildTargetRegion.offset === rootTargetRegion.offset && singleChildTargetRegion.length === rootTargetRegion.length) {
133509
- return { text: context.content, trace: singleChild };
133510
- } else {
133511
- return { text: context.content, trace };
133512
- }
133513
- }
133514
- function processNodeInternal(node, context) {
133515
- if (typeof node === "string") {
133516
- processStringNode(node, context);
133517
- } else if (node instanceof IndentNode) {
133518
- processIndentNode(node, context);
133519
- } else if (node instanceof CompositeGeneratorNode) {
133520
- processCompositeNode(node, context);
133521
- } else if (node instanceof NewLineNode) {
133522
- processNewLineNode(node, context);
133523
- }
133524
- }
133525
- function hasContent(node, ctx) {
133526
- if (typeof node === "string") {
133527
- return node.length !== 0;
133528
- } else if (node instanceof CompositeGeneratorNode) {
133529
- return node.contents.some((e) => hasContent(e, ctx));
133530
- } else if (node instanceof NewLineNode) {
133531
- return !(node.ifNotEmpty && ctx.currentLineContent.length === 0);
133532
- } else {
133533
- return false;
133534
- }
133535
- }
133536
- function processStringNode(node, context) {
133537
- if (node) {
133538
- if (context.pendingIndent) {
133539
- handlePendingIndent(context, false);
133540
- }
133541
- context.append(node);
133542
- }
133543
- }
133544
- function handlePendingIndent(ctx, endOfLine) {
133545
- var _a;
133546
- let indent = "";
133547
- for (const indentNode of ctx.relevantIndents.filter((e) => e.indentEmptyLines || !endOfLine)) {
133548
- indent += (_a = indentNode.indentation) !== null && _a !== void 0 ? _a : ctx.defaultIndentation;
133549
- }
133550
- ctx.append(indent, true);
133551
- ctx.pendingIndent = false;
133552
- }
133553
- function processCompositeNode(node, context) {
133554
- let traceRegion = void 0;
133555
- const sourceRegion = getSourceRegion(node.tracedSource);
133556
- if (sourceRegion) {
133557
- traceRegion = context.pushTraceRegion(sourceRegion);
133558
- }
133559
- for (const child of node.contents) {
133560
- processNodeInternal(child, context);
133561
- }
133562
- if (traceRegion) {
133563
- context.popTraceRegion(traceRegion);
133564
- const parentsFileURI = context.getParentTraceSourceFileURI();
133565
- if (parentsFileURI && (sourceRegion === null || sourceRegion === void 0 ? void 0 : sourceRegion.fileURI) === parentsFileURI) {
133566
- delete sourceRegion.fileURI;
133567
- }
133568
- traceRegion.complete && traceRegion.complete(context.currentPosition);
133569
- }
133570
- }
133571
- function processIndentNode(node, context) {
133572
- var _a;
133573
- if (hasContent(node, context)) {
133574
- if (node.indentImmediately && !context.pendingIndent) {
133575
- context.append((_a = node.indentation) !== null && _a !== void 0 ? _a : context.defaultIndentation, true);
133576
- }
133577
- try {
133578
- context.increaseIndent(node);
133579
- processCompositeNode(node, context);
133580
- } finally {
133581
- context.decreaseIndent();
133582
- }
133583
- }
133584
- }
133585
- function processNewLineNode(node, context) {
133586
- if (node.ifNotEmpty && !hasNonWhitespace(context.currentLineContent)) {
133587
- context.resetCurrentLine();
133588
- } else {
133589
- if (context.pendingIndent) {
133590
- handlePendingIndent(context, true);
133591
- }
133592
- context.append(node.lineDelimiter);
133593
- context.addNewLine();
133594
- }
133595
- }
133596
- function hasNonWhitespace(text) {
133597
- return text.trimStart() !== "";
133598
- }
133599
-
133600
- // node_modules/langium/lib/generate/template-string.js
133601
- var SNLE = Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");
133602
- var nonWhitespace = /\S|$/;
133603
- function findIndentation(lines) {
133604
- const indents = lines.filter((line) => line.length > 0).map((line) => line.search(nonWhitespace));
133605
- const min2 = indents.length === 0 ? 0 : Math.min(...indents);
133606
- return Math.max(0, min2);
133607
- }
133608
-
133609
- // node_modules/langium/lib/generate/template-node.js
133610
- function expandToNode(staticParts, ...substitutions) {
133611
- const templateProps = findIndentationAndTemplateStructure(staticParts);
133612
- const splitAndMerged = splitTemplateLinesAndMergeWithSubstitutions(staticParts, substitutions, templateProps);
133613
- return composeFinalGeneratorNode(splitAndMerged);
133614
- }
133615
- function expandTracedToNode(source, property2, index) {
133616
- return (staticParts, ...substitutions) => {
133617
- return traceToNode(source, property2, index)(expandToNode(staticParts, ...substitutions));
133618
- };
133619
- }
133620
- function findIndentationAndTemplateStructure(staticParts) {
133621
- const lines = staticParts.join("_").split(NEWLINE_REGEXP);
133622
- const omitFirstLine = lines.length > 1 && lines[0].trim().length === 0;
133623
- const omitLastLine = omitFirstLine && lines.length > 1 && lines[lines.length - 1].trim().length === 0;
133624
- if (lines.length === 1 || lines.length !== 0 && lines[0].trim().length !== 0 || lines.length === 2 && lines[1].trim().length === 0) {
133625
- return {
133626
- indentation: 0,
133627
- //''
133628
- omitFirstLine,
133629
- omitLastLine,
133630
- trimLastLine: lines.length !== 1 && lines[lines.length - 1].trim().length === 0
133631
- };
133632
- } else {
133633
- let sliced = omitFirstLine ? lines.slice(1) : lines;
133634
- sliced = omitLastLine ? sliced.slice(0, sliced.length - 1) : sliced;
133635
- sliced = sliced.filter((e) => e.length !== 0);
133636
- const indentation = findIndentation(sliced);
133637
- return {
133638
- indentation,
133639
- omitFirstLine,
133640
- // in the subsequent steps omit the last line only if it is empty or if it only contains whitespace of which the common indentation is not a valid prefix;
133641
- // in other words: keep the last line if it matches the common indentation (and maybe contains non-whitespace), a non-match may be due to mistaken usage of tabs and spaces
133642
- omitLastLine: omitLastLine && (lines[lines.length - 1].length < indentation || !lines[lines.length - 1].startsWith(sliced[0].substring(0, indentation)))
133643
- };
133644
- }
133645
- }
133646
- function splitTemplateLinesAndMergeWithSubstitutions(staticParts, substitutions, { indentation, omitFirstLine, omitLastLine, trimLastLine }) {
133647
- const splitAndMerged = [];
133648
- staticParts.forEach((part, i) => {
133649
- splitAndMerged.push(...part.split(NEWLINE_REGEXP).map((e, j) => j === 0 || e.length < indentation ? e : e.substring(indentation)).reduce(
133650
- // treat the particular (potentially multiple) lines of the <i>th template segment (part),
133651
- // s.t. all the effective lines are collected and separated by the NEWLINE node
133652
- // note: different reduce functions are provided for the initial template segment vs. the remaining segments
133653
- i === 0 ? (result, line, j) => (
133654
- // special handling of the initial template segment, which may contain line-breaks;
133655
- // suppresses the injection of unintended NEWLINE indicators for templates like
133656
- // expandToNode`
133657
- // someText
133658
- // ${something}
133659
- // `
133660
- j === 0 ? omitFirstLine ? [] : [line] : j === 1 && result.length === 0 ? [line] : result.concat(NEWLINE, line)
133661
- ) : (result, line, j) => (
133662
- // handling of the remaining template segments
133663
- j === 0 ? [line] : result.concat(NEWLINE, line)
133664
- ),
133665
- []
133666
- // start with an empty array
133667
- ).filter(
133668
- (e) => !(typeof e === "string" && e.length === 0)
133669
- // drop empty strings, they don't contribute anything but might confuse subsequent processing
133670
- ).concat(
133671
- // append the corresponding substitution after each segment (part),
133672
- // note that 'substitutions[i]' will be undefined for the last segment
133673
- isGeneratorNode(substitutions[i]) ? substitutions[i] : substitutions[i] !== void 0 ? { content: String(substitutions[i]) } : i < substitutions.length ? UNDEFINED_SEGMENT : []
133674
- /* don't concat anything as we passed behind the last substitution, since 'i' enumerates the indices of 'staticParts',
133675
- but 'substitutions' has one entry less and 'substitutions[staticParts.length -1 ]' will always be undefined */
133676
- ));
133677
- });
133678
- const splitAndMergedLength = splitAndMerged.length;
133679
- const lastItem = splitAndMergedLength !== 0 ? splitAndMerged[splitAndMergedLength - 1] : void 0;
133680
- if ((omitLastLine || trimLastLine) && typeof lastItem === "string" && lastItem.trim().length === 0) {
133681
- if (omitFirstLine && splitAndMergedLength !== 1 && splitAndMerged[splitAndMergedLength - 2] === NEWLINE) {
133682
- return splitAndMerged.slice(0, splitAndMergedLength - 2);
133683
- } else {
133684
- return splitAndMerged.slice(0, splitAndMergedLength - 1);
133685
- }
133686
- } else {
133687
- return splitAndMerged;
133688
- }
133689
- }
133690
- var NEWLINE = { isNewLine: true };
133691
- var UNDEFINED_SEGMENT = { isUndefinedSegment: true };
133692
- var isNewLineMarker = (nl) => nl === NEWLINE;
133693
- var isUndefinedSegmentMarker = (us) => us === UNDEFINED_SEGMENT;
133694
- var isSubstitutionWrapper = (s) => s.content !== void 0;
133695
- function composeFinalGeneratorNode(splitAndMerged) {
133696
- const result = splitAndMerged.reduce((res, segment, i) => isUndefinedSegmentMarker(segment) ? res : isNewLineMarker(segment) ? {
133697
- // in case of a newLine marker append an 'ifNotEmpty' newLine by default, but
133698
- // append an unconditional newLine if and only if:
133699
- // * the template starts with the current line break, i.e. the first line is empty
133700
- // * the current newLine marker directly follows another one, i.e. the current line is empty
133701
- // * the current newline marker directly follows a substitution contributing a string (or some non-GeneratorNode being converted to a string)
133702
- // * the current newline marker directly follows a (template static) string that
133703
- // * is the initial token of the template
133704
- // * is the initial token of the line, maybe just indentation
133705
- // * follows a a substitution contributing a string (or some non-GeneratorNode being converted to a string), maybe is just irrelevant trailing whitespace
133706
- // in particular do _not_ append an unconditional newLine if the last substitution of a line contributes 'undefined' or an instance of 'GeneratorNode'
133707
- // which may be a newline itself or be empty or (transitively) contain a trailing newline itself
133708
- // node: i === 0
133709
- // || isNewLineMarker(splitAndMerged[i - 1]) || isSubstitutionWrapper(splitAndMerged[i - 1]) /* implies: typeof content === 'string', esp. !undefined */
133710
- // || typeof splitAndMerged[i - 1] === 'string' && (
133711
- // i === 1 || isNewLineMarker(splitAndMerged[i - 2]) || isSubstitutionWrapper(splitAndMerged[i - 2]) /* implies: typeof content === 'string', esp. !undefined */
133712
- // )
133713
- // ? res.node.appendNewLine() : res.node.appendNewLineIfNotEmpty()
133714
- //
133715
- // UPDATE cs: inverting the logic leads to the following, I hope I didn't miss anything:
133716
- // in case of a newLine marker append an unconditional newLine by default, but
133717
- // append an 'ifNotEmpty' newLine if and only if:
133718
- // * the template doesn't start with a newLine marker and
133719
- // * the current newline marker directly follows a substitution contributing an `undefined` or an instance of 'GeneratorNode', or
133720
- // * the current newline marker directly follows a (template static) string (containing potentially unintended trailing whitespace)
133721
- // that in turn directly follows a substitution contributing an `undefined` or an instance of 'GeneratorNode'
133722
- node: i !== 0 && (isUndefinedSegmentMarker(splitAndMerged[i - 1]) || isGeneratorNode(splitAndMerged[i - 1])) || i > 1 && typeof splitAndMerged[i - 1] === "string" && (isUndefinedSegmentMarker(splitAndMerged[i - 2]) || isGeneratorNode(splitAndMerged[i - 2])) ? res.node.appendNewLineIfNotEmpty() : res.node.appendNewLine()
133723
- } : (() => {
133724
- var _a;
133725
- const indent = (i === 0 || isNewLineMarker(splitAndMerged[i - 1])) && typeof segment === "string" && segment.length !== 0 ? "".padStart(segment.length - segment.trimStart().length) : "";
133726
- const content = isSubstitutionWrapper(segment) ? segment.content : segment;
133727
- let indented;
133728
- return {
133729
- node: res.indented ? res.node : indent.length !== 0 ? res.node.indent({ indentation: indent, indentImmediately: false, indentedChildren: (ind) => indented = ind.append(content) }) : res.node.append(content),
133730
- indented: (
133731
- // if an indentNode has been created in this cycle, just register it,
133732
- // otherwise check for a earlier registered indentNode and add the current segment to that one
133733
- indented !== null && indented !== void 0 ? indented : (_a = res.indented) === null || _a === void 0 ? void 0 : _a.append(content)
133734
- )
133735
- };
133736
- })(), { node: new CompositeGeneratorNode() });
133737
- return result.node;
133738
- }
133739
-
133740
- // node_modules/langium/lib/generate/generator-node.js
133741
- var EOL = typeof process === "undefined" ? "\n" : process.platform === "win32" ? "\r\n" : "\n";
133742
- function isGeneratorNode(node) {
133743
- return node instanceof CompositeGeneratorNode || node instanceof IndentNode || node instanceof NewLineNode;
133744
- }
133745
- function toString3(input, defaultIndentation) {
133746
- if (isGeneratorNode(input))
133747
- return processGeneratorNode(input, defaultIndentation).text;
133748
- else
133749
- return String(input);
133750
- }
133751
- var CompositeGeneratorNode = class _CompositeGeneratorNode {
133752
- /**
133753
- * Constructor.
133754
- *
133755
- * @param content a var arg mixture of `strings` and {@link GeneratorNode GeneratorNodes}
133756
- * describing the initial content of this {@link CompositeGeneratorNode}
133757
- *
133758
- * @example
133759
- * new CompositeGeneratorNode(
133760
- * 'Hello World!', NL
133761
- * );
133762
- */
133763
- constructor(...content) {
133764
- this.contents = [];
133765
- this.append(...content);
133766
- }
133767
- isEmpty() {
133768
- return this.contents.length === 0;
133769
- }
133770
- trace(source, property2, index) {
133771
- if (isAstNode(source)) {
133772
- this.tracedSource = { astNode: source, property: property2, index };
133773
- if (this.tracedSource.property === void 0 && this.tracedSource.index !== void 0 && this.tracedSource.index > -1) {
133774
- throw new Error("Generation support: 'property' argument must not be 'undefined' if a non-negative value is assigned to 'index' in 'CompositeGeneratorNode.trace(...)'.");
133775
- }
133776
- } else {
133777
- this.tracedSource = source;
133778
- }
133779
- return this;
133780
- }
133781
- /**
133782
- * Appends `strings` and instances of {@link GeneratorNode} to `this` generator node.
133783
- *
133784
- * @param content a var arg mixture of `strings`, {@link GeneratorNode GeneratorNodes}, or single param
133785
- * functions that are immediately called with `this` node as argument, and which may append elements themselves.
133786
- *
133787
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133788
- *
133789
- * @example
133790
- * new CompositeGeneratorNode().append(
133791
- * 'Hello', ' ', `${name}!`, NL, someOtherNode, 'NL', node => generateContent(node)
133792
- * ).append(
133793
- * 'The end!'
133794
- * );
133795
- */
133796
- append(...content) {
133797
- for (const arg of content) {
133798
- if (typeof arg === "function") {
133799
- arg(this);
133800
- } else if (arg) {
133801
- this.contents.push(arg);
133802
- }
133803
- }
133804
- return this;
133805
- }
133806
- /**
133807
- * Appends `strings` and instances of {@link GeneratorNode} to `this` generator node, if `condition` is equal to `true`.
133808
- *
133809
- * If `condition` is satisfied this method delegates to {@link append}, otherwise it returns just `this`.
133810
- *
133811
- * @param condition a boolean value indicating whether to append the elements of `args` to `this`.
133812
- *
133813
- * @param content a var arg mixture of `strings`, {@link GeneratorNode GeneratorNodes}, or single param
133814
- * functions that are immediately called with `this` node as argument, and which may append elements themselves.
133815
- *
133816
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133817
- *
133818
- * @example
133819
- * new CompositeGeneratorNode().append(
133820
- * 'Hello World!'
133821
- * ).appendNewLine().appendIf(
133822
- * entity !== undefined, `Hello ${entity?.name}!`
133823
- * ).appendNewLineIfNotEmpty();
133824
- */
133825
- appendIf(condition, ...content) {
133826
- return condition ? this.append(...content) : this;
133827
- }
133828
- /**
133829
- * Appends a strict {@link NewLineNode} to `this` node.
133830
- * Strict {@link NewLineNode}s yield mandatory linebreaks in the derived generated text.
133831
- *
133832
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133833
- *
133834
- * @example
133835
- * new CompositeGeneratorNode().append(
133836
- * 'Hello World!'
133837
- * ).appendNewLine();
133838
- */
133839
- appendNewLine() {
133840
- return this.append(NL);
133841
- }
133842
- /**
133843
- * Appends a strict {@link NewLineNode} to `this` node, if `condition` is equal to `true`.
133844
- * Strict {@link NewLineNode}s yield mandatory linebreaks in the derived generated text.
133845
- *
133846
- * @param condition a boolean value indicating whether to append a {@link NewLineNode} to `this`.
133847
- *
133848
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133849
- *
133850
- * @example
133851
- * new CompositeGeneratorNode().append(
133852
- * 'Hello World!'
133853
- * ).appendNewLineIf(entity !== undefined).appendIf(
133854
- * entity !== undefined, `Hello ${entity?.name}!`
133855
- * )
133856
- */
133857
- appendNewLineIf(condition) {
133858
- return condition ? this.append(NL) : this;
133859
- }
133860
- /**
133861
- * Appends a soft {@link NewLineNode} to `this` node.
133862
- * Soft {@link NewLineNode}s yield linebreaks in the derived generated text only if the preceding line is non-empty,
133863
- * i.e. there are non-whitespace characters added to the generated text since the last linebreak.
133864
- *
133865
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133866
- *
133867
- * @example
133868
- * new CompositeGeneratorNode().appendIf(
133869
- * entity !== undefined, `Hello ${entity?.name}!`
133870
- * ).appendNewLineIfNotEmpty();
133871
- */
133872
- appendNewLineIfNotEmpty() {
133873
- return this.append(NLEmpty);
133874
- }
133875
- /**
133876
- * Appends a soft {@link NewLineNode} to `this` node, if `condition` is equal to `true`.
133877
- * Soft {@link NewLineNode}s yield linebreaks in the derived generated text only if the preceding line is non-empty,
133878
- * i.e. there are non-whitespace characters added to the generated text since the last linebreak.
133879
- *
133880
- * @param condition a boolean value indicating whether to append a {@link NewLineNode} to `this`.
133881
- *
133882
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133883
- *
133884
- * @example
133885
- * new CompositeGeneratorNode().append(
133886
- * entity.label ?? ''
133887
- * ).appendNewLineIfNotEmptyIf(entity.description !== undefined).append(
133888
- * entity.description
133889
- * )
133890
- */
133891
- appendNewLineIfNotEmptyIf(condition) {
133892
- return condition ? this.appendNewLineIfNotEmpty() : this;
133893
- }
133894
- /**
133895
- * Convenience method for appending content in form of a template to `this` generation node.
133896
- *
133897
- * See {@link expandToNode} for details.
133898
- *
133899
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133900
- *
133901
- * @example
133902
- * new CompositeGeneratorNode().appendTemplate
133903
- * `Hello World!`
133904
- * .appendNewLine()
133905
- */
133906
- appendTemplate(staticParts, ...substitutions) {
133907
- return this.append(expandToNode(staticParts, ...substitutions));
133908
- }
133909
- /**
133910
- * Convenience method for appending content in form of a template to `this` generator node, if `condition` is equal to `true`.
133911
- *
133912
- * This method returns a tag function that takes the desired template and does the processing.
133913
- *
133914
- * If `condition` is satisfied the tagged template delegates to {@link appendTemplate}, otherwise it returns just `this`.
133915
- *
133916
- * See {@link expandToNode} for details.
133917
- *
133918
- * @param condition a boolean value indicating whether to append the template content to `this`.
133919
- *
133920
- * @returns a tag function behaving as described above, which in turn returns `this` {@link CompositeGeneratorNode} for convenience.
133921
- *
133922
- * @example
133923
- * new CompositeGeneratorNode().appendTemplate
133924
- * `Hello World!`
133925
- * .appendNewLine().appendTemplateIf(entity !== undefined)
133926
- * `Hello ${entity?.name}!`
133927
- * .appendNewLineIfNotEmpty()
133928
- */
133929
- appendTemplateIf(condition) {
133930
- return condition ? (staticParts, ...substitutions) => this.appendTemplate(staticParts, ...substitutions) : () => this;
133931
- }
133932
- /**
133933
- * Adds an area of indented text output.
133934
- * The content to be indented can be provided as an array consisting of strings and/or generation nodes
133935
- * (undefined is permitted), or via a callback offering the `indentingNode` to which the content shall be appended.
133936
- * Alternatively, an object satisfying {@link IndentConfig} can be provided taking the children as Array or via
133937
- * a callback as described previously via the `indentedChildren` property.
133938
- *
133939
- * The remaining properties of {@link IndentConfig} have the following effects:
133940
- * - `indentation`: a specific indentation length or string, defaults to the global indentation setting if omitted, see {@link toString},
133941
- * - `indentEmptyLines`: apply indentation to empty lines, defaults to `false`
133942
- * - `indentImmediately`: apply the indentation immediately starting at the first line, defaults to `true`, might be set to `false`
133943
- * if preceding content is not terminated by any `newline`. If `false` the indentation is inserted only after child `newline` nodes
133944
- * followed by further content.
133945
- *
133946
- * @param childrenOrConfig an {@link Array} or callback contributing the children, or a config object satisfying {@link IndentConfig} alternatively.
133947
- *
133948
- * @returns `this` {@link CompositeGeneratorNode} for convenience.
133949
- *
133950
- * @example
133951
- * new CompositeGeneratorNode().append(
133952
- * '{'
133953
- * ).indent(indentingNode =>
133954
- * indentingNode.append(
133955
- * 'name:', name, ','
133956
- * ).appendNewLine().appendIf(description !== undefined,
133957
- * 'description:', description
133958
- * ).appendNewLineIfNotEmpty()
133959
- * ).append(
133960
- * '}'
133961
- * );
133962
- */
133963
- indent(childrenOrConfig) {
133964
- const { indentedChildren, indentation, indentEmptyLines, indentImmediately } = Array.isArray(childrenOrConfig) || typeof childrenOrConfig === "function" ? { indentedChildren: childrenOrConfig } : typeof childrenOrConfig === "object" ? childrenOrConfig : {};
133965
- const node = new IndentNode(indentation, indentImmediately, indentEmptyLines);
133966
- this.contents.push(node);
133967
- if (Array.isArray(indentedChildren)) {
133968
- node.append(...indentedChildren);
133969
- } else if (indentedChildren) {
133970
- node.append(indentedChildren);
133971
- }
133972
- return this;
133973
- }
133974
- // implementation:
133975
- appendTraced(source, property2, index) {
133976
- return (content) => {
133977
- return this.append(new _CompositeGeneratorNode().trace(source, property2, index).append(content));
133978
- };
133979
- }
133980
- // implementation:
133981
- appendTracedIf(condition, source, property2, index) {
133982
- return condition ? this.appendTraced(typeof source === "function" ? source() : source, property2, index) : () => this;
133983
- }
133984
- // implementation:
133985
- appendTracedTemplate(source, property2, index) {
133986
- return (staticParts, ...substitutions) => {
133987
- return this.append(expandTracedToNode(source, property2, index)(staticParts, ...substitutions));
133988
- };
133989
- }
133990
- // implementation:
133991
- appendTracedTemplateIf(condition, source, property2, index) {
133992
- return condition ? this.appendTracedTemplate(typeof source === "function" ? source() : source, property2, index) : () => this;
133993
- }
133994
- };
133995
- function traceToNode(astNode, property2, index) {
133996
- return (content) => {
133997
- if (content instanceof CompositeGeneratorNode && content.tracedSource === void 0) {
133998
- return content.trace(astNode, property2, index);
133999
- } else {
134000
- return new CompositeGeneratorNode().trace(astNode, property2, index).append(content);
134001
- }
134002
- };
134003
- }
134004
- var IndentNode = class extends CompositeGeneratorNode {
134005
- constructor(indentation, indentImmediately = true, indentEmptyLines = false) {
134006
- super();
134007
- this.indentImmediately = true;
134008
- this.indentEmptyLines = false;
134009
- if (typeof indentation === "string") {
134010
- this.indentation = indentation;
134011
- } else if (typeof indentation === "number") {
134012
- this.indentation = "".padStart(indentation);
134013
- }
134014
- this.indentImmediately = indentImmediately;
134015
- this.indentEmptyLines = indentEmptyLines;
134016
- }
134017
- };
134018
- var NewLineNode = class {
134019
- constructor(lineDelimiter, ifNotEmpty = false) {
134020
- this.ifNotEmpty = false;
134021
- this.lineDelimiter = lineDelimiter !== null && lineDelimiter !== void 0 ? lineDelimiter : EOL;
134022
- this.ifNotEmpty = ifNotEmpty;
134023
- }
134024
- };
134025
- var NL = new NewLineNode();
134026
- var NLEmpty = new NewLineNode(void 0, true);
134027
-
134028
- // node_modules/langium/lib/generate/node-joiner.js
134029
- var defaultToGenerated = (e) => e === void 0 || typeof e === "string" || isGeneratorNode(e) ? e : String(e);
134030
- function joinToNode(iterable, toGeneratedOrOptions = defaultToGenerated, options = {}) {
134031
- const toGenerated = typeof toGeneratedOrOptions === "function" ? toGeneratedOrOptions : defaultToGenerated;
134032
- const { filter: filter2, prefix, suffix, separator, appendNewLineIfNotEmpty, skipNewLineAfterLastItem } = typeof toGeneratedOrOptions === "object" ? toGeneratedOrOptions : options;
134033
- const prefixFunc = typeof prefix === "function" ? prefix : () => prefix;
134034
- const suffixFunc = typeof suffix === "function" ? suffix : () => suffix;
134035
- return reduceWithIsLast(iterable, (node, it, i, isLast) => {
134036
- if (filter2 && !filter2(it, i, isLast)) {
134037
- return node;
134038
- }
134039
- const content = toGenerated(it, i, isLast);
134040
- return content === void 0 ? (
134041
- /* in this case don't append anything to */
134042
- node
134043
- ) : (
134044
- /* otherwise: */
134045
- (node !== null && node !== void 0 ? node : node = new CompositeGeneratorNode()).append(prefixFunc(it, i, isLast)).append(content).append(suffixFunc(it, i, isLast)).appendIf(!isLast, separator).appendNewLineIfNotEmptyIf(
134046
- // append 'newLineIfNotEmpty' elements only if 'node' has some content already,
134047
- // as if the parent is an IndentNode with 'indentImmediately' set to 'false'
134048
- // the indentation is not properly applied to the first non-empty line of the (this) child node
134049
- // besides, append the newLine only if more lines are following, if appending a newline
134050
- // is not suppressed for the final item
134051
- !node.isEmpty() && !!appendNewLineIfNotEmpty && (!isLast || !skipNewLineAfterLastItem)
134052
- )
134053
- );
134054
- });
134055
- }
134056
- function reduceWithIsLast(iterable, callbackfn, initial) {
134057
- const iterator = iterable[Symbol.iterator]();
134058
- let next = iterator.next();
134059
- let index = 0;
134060
- let result = initial;
134061
- while (!next.done) {
134062
- const nextNext = iterator.next();
134063
- result = callbackfn(result, next.value, index, Boolean(nextNext.done));
134064
- next = nextNext;
134065
- index++;
134066
- }
134067
- return result;
134068
- }
134069
-
134070
130454
  // src/language/aurora-diagram-generator.ts
134071
130455
  var ngoFilter = [];
134072
130456
  function clearNGOFilter() {
@@ -134963,13 +131347,6 @@ async function extractAstNode(fileName, services) {
134963
131347
  var _a;
134964
131348
  return (_a = (await extractDocument(fileName, services)).parseResult) == null ? void 0 : _a.value;
134965
131349
  }
134966
- function extractDestinationAndName(filePath, destination) {
134967
- filePath = path.basename(filePath, path.extname(filePath)).replace(/[.-]/g, "");
134968
- return {
134969
- destination: destination != null ? destination : path.join(path.dirname(filePath), "generated"),
134970
- name: path.basename(filePath)
134971
- };
134972
- }
134973
131350
 
134974
131351
  // node_modules/langium/lib/node/node-file-system-provider.js
134975
131352
  var fs2 = __toESM(require("fs"), 1);
@@ -134995,50 +131372,12 @@ var NodeFileSystem = {
134995
131372
  fileSystemProvider: () => new NodeFileSystemProvider()
134996
131373
  };
134997
131374
 
134998
- // node_modules/commander/esm.mjs
134999
- var import_index = __toESM(require_commander(), 1);
135000
- var {
135001
- program,
135002
- createCommand,
135003
- createArgument,
135004
- createOption,
135005
- CommanderError,
135006
- InvalidArgumentError,
135007
- InvalidOptionArgumentError,
135008
- // deprecated old name
135009
- Command: Command2,
135010
- Argument,
135011
- Option: Option2,
135012
- Help
135013
- } = import_index.default;
135014
-
135015
- // src/cli/generator.ts
135016
- var fs3 = __toESM(require("fs"), 1);
135017
- var path2 = __toESM(require("path"), 1);
135018
- function generateJavaScript(model, filePath, destination) {
135019
- const data = extractDestinationAndName(filePath, destination);
135020
- const generatedFilePath = `${path2.join(data.destination, data.name)}.js`;
135021
- const fileNode = expandToNode`
135022
- "use strict";
135023
-
135024
- ${joinToNode(model.imports, (greeting) => `console.log('Hello, ${greeting.importedNamespace}!');`, { appendNewLineIfNotEmpty: true })}
135025
- `.appendNewLineIfNotEmpty();
135026
- if (!fs3.existsSync(data.destination)) {
135027
- fs3.mkdirSync(data.destination, { recursive: true });
135028
- }
135029
- fs3.writeFileSync(generatedFilePath, toString3(fileNode));
135030
- return generatedFilePath;
135031
- }
135032
-
135033
- // src/cli/main.ts
135034
- var fs4 = __toESM(require("fs/promises"), 1);
135035
- var path3 = __toESM(require("path"), 1);
135036
- var __dirname = path3.resolve();
135037
- var packagePath = path3.resolve(__dirname, "..", "..", "package.json");
135038
- async function loadPackageContent() {
135039
- const packageContent = await fs4.readFile(packagePath, "utf-8");
135040
- return JSON.parse(packageContent);
135041
- }
131375
+ // src/cli/index.ts
131376
+ var parse = async (fileName) => {
131377
+ const services = createAuroraServices(NodeFileSystem).Aurora;
131378
+ const module2 = await extractAstNode(fileName, services);
131379
+ return module2;
131380
+ };
135042
131381
  var getAuroraServices = async () => {
135043
131382
  const services = await Promise.resolve(createAuroraServices(NodeFileSystem));
135044
131383
  return services;
@@ -135047,35 +131386,11 @@ var getEmptyAuroraServices = async () => {
135047
131386
  const services = await Promise.resolve(createAuroraServices(EmptyFileSystem));
135048
131387
  return services;
135049
131388
  };
135050
- var generateAction = async (fileName, opts) => {
135051
- const services = createAuroraServices(NodeFileSystem).Aurora;
135052
- const PCM4 = await extractAstNode(fileName, services);
135053
- const generatedFilePath = generateJavaScript(PCM4, fileName, opts.destination);
135054
- console.log(source_default.green(`JavaScript code generated successfully: ${generatedFilePath}`));
135055
- };
135056
- async function main() {
135057
- const program2 = new Command2();
135058
- const packageContent = await loadPackageContent();
135059
- program2.version(packageContent.version);
135060
- const fileExtensions = AuroraLanguageMetaData.fileExtensions.join(", ");
135061
- program2.command("generate").argument("<file>", `source file (possible file extensions: ${fileExtensions})`).option("-d, --destination <dir>", "destination directory of generating").description('generates JavaScript code that prints "Hello, {name}!" for each greeting in a source file').action(generateAction);
135062
- program2.parse(process.argv);
135063
- }
135064
- main().catch((err) => {
135065
- console.error(err);
135066
- process.exit(1);
135067
- });
135068
-
135069
- // src/cli/index.ts
135070
- var parse = async (fileName) => {
135071
- const services = createAuroraServices(NodeFileSystem).Aurora;
135072
- const module2 = await extractAstNode(fileName, services);
135073
- return module2;
135074
- };
135075
131389
  // Annotate the CommonJS export names for ESM import in node:
135076
131390
  0 && (module.exports = {
135077
131391
  AstUtils,
135078
131392
  GenAst,
131393
+ extractAstNode,
135079
131394
  getAuroraServices,
135080
131395
  getEmptyAuroraServices,
135081
131396
  parse