fbi-proxy 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,152 +1,24 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  import { createRequire } from "node:module";
4
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
-
6
- // node_modules/get-port/index.js
7
- import net from "node:net";
8
- import os from "node:os";
9
-
10
- class Locked extends Error {
11
- constructor(port) {
12
- super(`${port} is locked`);
13
- }
4
+ var __defProp = Object.defineProperty;
5
+ var __returnValue = (v) => v;
6
+ function __exportSetter(name, newValue) {
7
+ this[name] = __returnValue.bind(null, newValue);
14
8
  }
15
- var lockedPorts = {
16
- old: new Set,
17
- young: new Set
18
- };
19
- var releaseOldLockedPortsIntervalMs = 1000 * 15;
20
- var timeout;
21
- var getLocalHosts = () => {
22
- const interfaces = os.networkInterfaces();
23
- const results = new Set([undefined, "0.0.0.0"]);
24
- for (const _interface of Object.values(interfaces)) {
25
- for (const config of _interface) {
26
- results.add(config.address);
27
- }
28
- }
29
- return results;
30
- };
31
- var checkAvailablePort = (options) => new Promise((resolve, reject) => {
32
- const server = net.createServer();
33
- server.unref();
34
- server.on("error", reject);
35
- server.listen(options, () => {
36
- const { port } = server.address();
37
- server.close(() => {
38
- resolve(port);
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true,
14
+ configurable: true,
15
+ set: __exportSetter.bind(all, name)
39
16
  });
40
- });
41
- });
42
- var getAvailablePort = async (options, hosts) => {
43
- if (options.host || options.port === 0) {
44
- return checkAvailablePort(options);
45
- }
46
- for (const host of hosts) {
47
- try {
48
- await checkAvailablePort({ port: options.port, host });
49
- } catch (error) {
50
- if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
51
- throw error;
52
- }
53
- }
54
- }
55
- return options.port;
56
- };
57
- var portCheckSequence = function* (ports) {
58
- if (ports) {
59
- yield* ports;
60
- }
61
- yield 0;
62
17
  };
63
- async function getPorts(options) {
64
- let ports;
65
- let exclude = new Set;
66
- if (options) {
67
- if (options.port) {
68
- ports = typeof options.port === "number" ? [options.port] : options.port;
69
- }
70
- if (options.exclude) {
71
- const excludeIterable = options.exclude;
72
- if (typeof excludeIterable[Symbol.iterator] !== "function") {
73
- throw new TypeError("The `exclude` option must be an iterable.");
74
- }
75
- for (const element of excludeIterable) {
76
- if (typeof element !== "number") {
77
- throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
78
- }
79
- if (!Number.isSafeInteger(element)) {
80
- throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
81
- }
82
- }
83
- exclude = new Set(excludeIterable);
84
- }
85
- }
86
- if (timeout === undefined) {
87
- timeout = setTimeout(() => {
88
- timeout = undefined;
89
- lockedPorts.old = lockedPorts.young;
90
- lockedPorts.young = new Set;
91
- }, releaseOldLockedPortsIntervalMs);
92
- if (timeout.unref) {
93
- timeout.unref();
94
- }
95
- }
96
- const hosts = getLocalHosts();
97
- for (const port of portCheckSequence(ports)) {
98
- try {
99
- if (exclude.has(port)) {
100
- continue;
101
- }
102
- let availablePort = await getAvailablePort({ ...options, port }, hosts);
103
- while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
104
- if (port !== 0) {
105
- throw new Locked(port);
106
- }
107
- availablePort = await getAvailablePort({ ...options, port }, hosts);
108
- }
109
- lockedPorts.young.add(availablePort);
110
- return availablePort;
111
- } catch (error) {
112
- if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
113
- throw error;
114
- }
115
- }
116
- }
117
- throw new Error("No available ports found");
118
- }
119
-
120
- // node_modules/hot-memo/dist/index.js
121
- var g = globalThis;
122
- g["_HOTMEMO_SALT_"] ??= new Date().getTime().toString(36) + Math.random().toString(36).slice(2);
123
- var cache = g["_HOTMEMO_CACHE_"] ??= new Map;
124
- async function hotMemo(fn, args = [], key = `_HOTMEMO_${g["_HOTMEMO_SALT_"]}_${String(fn) + "(" + JSON.stringify(args) + ")"}`) {
125
- if (cache.has(key)) {
126
- return cache.get(key);
127
- }
128
- const result = await fn(...args);
129
- cache.set(key, result);
130
- return result;
131
- }
132
- hotMemo.cache = cache;
133
-
134
- // ts/cli.ts
135
- import path3 from "path";
136
-
137
- // node_modules/yargs/lib/platform-shims/esm.mjs
138
- import { notStrictEqual, strictEqual } from "assert";
18
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
19
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
139
20
 
140
21
  // node_modules/cliui/build/lib/index.js
141
- var align = {
142
- right: alignRight,
143
- center: alignCenter
144
- };
145
- var top = 0;
146
- var right = 1;
147
- var bottom = 2;
148
- var left = 3;
149
-
150
22
  class UI {
151
23
  constructor(opts) {
152
24
  var _a;
@@ -387,7 +259,6 @@ function alignCenter(str, width) {
387
259
  }
388
260
  return " ".repeat(width - strWidth >> 1) + str;
389
261
  }
390
- var mixin;
391
262
  function cliui(opts, _mixin) {
392
263
  mixin = _mixin;
393
264
  return new UI({
@@ -395,9 +266,15 @@ function cliui(opts, _mixin) {
395
266
  wrap: opts === null || opts === undefined ? undefined : opts.wrap
396
267
  });
397
268
  }
269
+ var align, top = 0, right = 1, bottom = 2, left = 3, mixin;
270
+ var init_lib = __esm(() => {
271
+ align = {
272
+ right: alignRight,
273
+ center: alignCenter
274
+ };
275
+ });
398
276
 
399
277
  // node_modules/cliui/build/lib/string-utils.js
400
- var ansi = new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|" + "\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
401
278
  function stripAnsi(str) {
402
279
  return str.replace(ansi, "");
403
280
  }
@@ -417,6 +294,10 @@ function wrap(str, width) {
417
294
  }
418
295
  return wrapped;
419
296
  }
297
+ var ansi;
298
+ var init_string_utils = __esm(() => {
299
+ ansi = new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|" + "\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
300
+ });
420
301
 
421
302
  // node_modules/cliui/index.mjs
422
303
  function ui(opts) {
@@ -428,6 +309,10 @@ function ui(opts) {
428
309
  wrap
429
310
  });
430
311
  }
312
+ var init_cliui = __esm(() => {
313
+ init_lib();
314
+ init_string_utils();
315
+ });
431
316
 
432
317
  // node_modules/escalade/sync/index.mjs
433
318
  import { dirname, resolve } from "path";
@@ -447,15 +332,7 @@ function sync_default(start, callback) {
447
332
  break;
448
333
  }
449
334
  }
450
-
451
- // node_modules/yargs/lib/platform-shims/esm.mjs
452
- import { inspect } from "util";
453
- import { readFileSync as readFileSync2 } from "fs";
454
- import { fileURLToPath } from "url";
455
-
456
- // node_modules/yargs-parser/build/lib/index.js
457
- import { format } from "util";
458
- import { normalize, resolve as resolve2 } from "path";
335
+ var init_sync = () => {};
459
336
 
460
337
  // node_modules/yargs-parser/build/lib/string-utils.js
461
338
  function camelCase(str) {
@@ -545,16 +422,16 @@ function tokenizeArgString(argString) {
545
422
 
546
423
  // node_modules/yargs-parser/build/lib/yargs-parser-types.js
547
424
  var DefaultValuesForTypeKey;
548
- (function(DefaultValuesForTypeKey2) {
549
- DefaultValuesForTypeKey2["BOOLEAN"] = "boolean";
550
- DefaultValuesForTypeKey2["STRING"] = "string";
551
- DefaultValuesForTypeKey2["NUMBER"] = "number";
552
- DefaultValuesForTypeKey2["ARRAY"] = "array";
553
- })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
425
+ var init_yargs_parser_types = __esm(() => {
426
+ (function(DefaultValuesForTypeKey2) {
427
+ DefaultValuesForTypeKey2["BOOLEAN"] = "boolean";
428
+ DefaultValuesForTypeKey2["STRING"] = "string";
429
+ DefaultValuesForTypeKey2["NUMBER"] = "number";
430
+ DefaultValuesForTypeKey2["ARRAY"] = "array";
431
+ })(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
432
+ });
554
433
 
555
434
  // node_modules/yargs-parser/build/lib/yargs-parser.js
556
- var mixin2;
557
-
558
435
  class YargsParser {
559
436
  constructor(_mixin) {
560
437
  mixin2 = _mixin;
@@ -1389,48 +1266,51 @@ function sanitizeKey(key) {
1389
1266
  function stripQuotes(val) {
1390
1267
  return typeof val === "string" && (val[0] === "'" || val[0] === '"') && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
1391
1268
  }
1269
+ var mixin2;
1270
+ var init_yargs_parser = __esm(() => {
1271
+ init_yargs_parser_types();
1272
+ });
1392
1273
 
1393
1274
  // node_modules/yargs-parser/build/lib/index.js
1394
- var _a;
1395
- var _b;
1396
- var _c;
1397
- var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
1398
- var nodeVersion = (_b = (_a = process === null || process === undefined ? undefined : process.versions) === null || _a === undefined ? undefined : _a.node) !== null && _b !== undefined ? _b : (_c = process === null || process === undefined ? undefined : process.version) === null || _c === undefined ? undefined : _c.slice(1);
1399
- if (nodeVersion) {
1400
- const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
1401
- if (major < minNodeVersion) {
1402
- throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
1403
- }
1404
- }
1405
- var env = process ? process.env : {};
1406
- var parser = new YargsParser({
1407
- cwd: process.cwd,
1408
- env: () => {
1409
- return env;
1410
- },
1411
- format,
1412
- normalize,
1413
- resolve: resolve2,
1414
- require: (path) => {
1415
- if (true) {
1416
- return __require(path);
1417
- }
1418
- }
1419
- });
1420
- var yargsParser = function Parser(args, opts) {
1275
+ import { format } from "util";
1276
+ import { normalize, resolve as resolve2 } from "path";
1277
+ var _a, _b, _c, minNodeVersion, nodeVersion, env, parser, yargsParser = function Parser(args, opts) {
1421
1278
  const result = parser.parse(args.slice(), opts);
1422
1279
  return result.argv;
1423
- };
1424
- yargsParser.detailed = function(args, opts) {
1425
- return parser.parse(args.slice(), opts);
1426
- };
1427
- yargsParser.camelCase = camelCase;
1428
- yargsParser.decamelize = decamelize;
1429
- yargsParser.looksLikeNumber = looksLikeNumber;
1430
- var lib_default = yargsParser;
1431
-
1432
- // node_modules/yargs/lib/platform-shims/esm.mjs
1433
- import { basename, dirname as dirname2, extname, relative, resolve as resolve4 } from "path";
1280
+ }, lib_default;
1281
+ var init_lib2 = __esm(() => {
1282
+ init_yargs_parser();
1283
+ minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
1284
+ nodeVersion = (_b = (_a = process === null || process === undefined ? undefined : process.versions) === null || _a === undefined ? undefined : _a.node) !== null && _b !== undefined ? _b : (_c = process === null || process === undefined ? undefined : process.version) === null || _c === undefined ? undefined : _c.slice(1);
1285
+ if (nodeVersion) {
1286
+ const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
1287
+ if (major < minNodeVersion) {
1288
+ throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
1289
+ }
1290
+ }
1291
+ env = process ? process.env : {};
1292
+ parser = new YargsParser({
1293
+ cwd: process.cwd,
1294
+ env: () => {
1295
+ return env;
1296
+ },
1297
+ format,
1298
+ normalize,
1299
+ resolve: resolve2,
1300
+ require: (path) => {
1301
+ if (true) {
1302
+ return __require(path);
1303
+ }
1304
+ }
1305
+ });
1306
+ yargsParser.detailed = function(args, opts) {
1307
+ return parser.parse(args.slice(), opts);
1308
+ };
1309
+ yargsParser.camelCase = camelCase;
1310
+ yargsParser.decamelize = decamelize;
1311
+ yargsParser.looksLikeNumber = looksLikeNumber;
1312
+ lib_default = yargsParser;
1313
+ });
1434
1314
 
1435
1315
  // node_modules/yargs/build/lib/utils/process-argv.js
1436
1316
  function getProcessArgvBinIndex() {
@@ -1452,39 +1332,43 @@ function getProcessArgvBin() {
1452
1332
  }
1453
1333
 
1454
1334
  // node_modules/yargs/build/lib/yerror.js
1455
- class YError extends Error {
1456
- constructor(msg) {
1457
- super(msg || "yargs error");
1458
- this.name = "YError";
1459
- if (Error.captureStackTrace) {
1460
- Error.captureStackTrace(this, YError);
1335
+ var YError;
1336
+ var init_yerror = __esm(() => {
1337
+ YError = class YError extends Error {
1338
+ constructor(msg) {
1339
+ super(msg || "yargs error");
1340
+ this.name = "YError";
1341
+ if (Error.captureStackTrace) {
1342
+ Error.captureStackTrace(this, YError);
1343
+ }
1461
1344
  }
1462
- }
1463
- }
1345
+ };
1346
+ });
1464
1347
 
1465
1348
  // node_modules/y18n/build/lib/platform-shims/node.js
1466
1349
  import { readFileSync, statSync as statSync2, writeFile } from "fs";
1467
1350
  import { format as format2 } from "util";
1468
1351
  import { resolve as resolve3 } from "path";
1469
- var node_default = {
1470
- fs: {
1471
- readFileSync,
1472
- writeFile
1473
- },
1474
- format: format2,
1475
- resolve: resolve3,
1476
- exists: (file) => {
1477
- try {
1478
- return statSync2(file).isFile();
1479
- } catch (err) {
1480
- return false;
1352
+ var node_default;
1353
+ var init_node = __esm(() => {
1354
+ node_default = {
1355
+ fs: {
1356
+ readFileSync,
1357
+ writeFile
1358
+ },
1359
+ format: format2,
1360
+ resolve: resolve3,
1361
+ exists: (file) => {
1362
+ try {
1363
+ return statSync2(file).isFile();
1364
+ } catch (err) {
1365
+ return false;
1366
+ }
1481
1367
  }
1482
- }
1483
- };
1368
+ };
1369
+ });
1484
1370
 
1485
1371
  // node_modules/y18n/build/lib/index.js
1486
- var shim;
1487
-
1488
1372
  class Y18N {
1489
1373
  constructor(opts) {
1490
1374
  opts = opts || {};
@@ -1640,71 +1524,85 @@ function y18n(opts, _shim) {
1640
1524
  locale: y18n2.locale
1641
1525
  };
1642
1526
  }
1527
+ var shim;
1643
1528
 
1644
1529
  // node_modules/y18n/index.mjs
1645
1530
  var y18n2 = (opts) => {
1646
1531
  return y18n(opts, node_default);
1647
- };
1648
- var y18n_default = y18n2;
1532
+ }, y18n_default;
1533
+ var init_y18n = __esm(() => {
1534
+ init_node();
1535
+ y18n_default = y18n2;
1536
+ });
1649
1537
 
1650
1538
  // node_modules/yargs/lib/platform-shims/esm.mjs
1651
- var REQUIRE_ERROR = "require is not supported by ESM";
1652
- var REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM";
1653
- var __dirname2;
1654
- try {
1655
- __dirname2 = fileURLToPath(import.meta.url);
1656
- } catch (e) {
1657
- __dirname2 = process.cwd();
1658
- }
1659
- var mainFilename = __dirname2.substring(0, __dirname2.lastIndexOf("node_modules"));
1660
- var esm_default = {
1661
- assert: {
1662
- notStrictEqual,
1663
- strictEqual
1664
- },
1665
- cliui: ui,
1666
- findUp: sync_default,
1667
- getEnv: (key) => {
1668
- return process.env[key];
1669
- },
1670
- inspect,
1671
- getCallerFile: () => {
1672
- throw new YError(REQUIRE_DIRECTORY_ERROR);
1673
- },
1674
- getProcessArgvBin,
1675
- mainFilename: mainFilename || process.cwd(),
1676
- Parser: lib_default,
1677
- path: {
1678
- basename,
1679
- dirname: dirname2,
1680
- extname,
1681
- relative,
1682
- resolve: resolve4
1683
- },
1684
- process: {
1685
- argv: () => process.argv,
1686
- cwd: process.cwd,
1687
- emitWarning: (warning, type) => process.emitWarning(warning, type),
1688
- execPath: () => process.execPath,
1689
- exit: process.exit,
1690
- nextTick: process.nextTick,
1691
- stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null
1692
- },
1693
- readFileSync: readFileSync2,
1694
- require: () => {
1695
- throw new YError(REQUIRE_ERROR);
1696
- },
1697
- requireDirectory: () => {
1698
- throw new YError(REQUIRE_DIRECTORY_ERROR);
1699
- },
1700
- stringWidth: (str) => {
1701
- return [...str].length;
1702
- },
1703
- y18n: y18n_default({
1704
- directory: resolve4(__dirname2, "../../../locales"),
1705
- updateFiles: false
1706
- })
1707
- };
1539
+ import { notStrictEqual, strictEqual } from "assert";
1540
+ import { inspect } from "util";
1541
+ import { readFileSync as readFileSync2 } from "fs";
1542
+ import { fileURLToPath } from "url";
1543
+ import { basename, dirname as dirname2, extname, relative, resolve as resolve4 } from "path";
1544
+ var REQUIRE_ERROR = "require is not supported by ESM", REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM", __dirname2, mainFilename, esm_default;
1545
+ var init_esm = __esm(() => {
1546
+ init_cliui();
1547
+ init_sync();
1548
+ init_lib2();
1549
+ init_yerror();
1550
+ init_y18n();
1551
+ try {
1552
+ __dirname2 = fileURLToPath(import.meta.url);
1553
+ } catch (e) {
1554
+ __dirname2 = process.cwd();
1555
+ }
1556
+ mainFilename = __dirname2.substring(0, __dirname2.lastIndexOf("node_modules"));
1557
+ esm_default = {
1558
+ assert: {
1559
+ notStrictEqual,
1560
+ strictEqual
1561
+ },
1562
+ cliui: ui,
1563
+ findUp: sync_default,
1564
+ getEnv: (key) => {
1565
+ return process.env[key];
1566
+ },
1567
+ inspect,
1568
+ getCallerFile: () => {
1569
+ throw new YError(REQUIRE_DIRECTORY_ERROR);
1570
+ },
1571
+ getProcessArgvBin,
1572
+ mainFilename: mainFilename || process.cwd(),
1573
+ Parser: lib_default,
1574
+ path: {
1575
+ basename,
1576
+ dirname: dirname2,
1577
+ extname,
1578
+ relative,
1579
+ resolve: resolve4
1580
+ },
1581
+ process: {
1582
+ argv: () => process.argv,
1583
+ cwd: process.cwd,
1584
+ emitWarning: (warning, type) => process.emitWarning(warning, type),
1585
+ execPath: () => process.execPath,
1586
+ exit: process.exit,
1587
+ nextTick: process.nextTick,
1588
+ stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null
1589
+ },
1590
+ readFileSync: readFileSync2,
1591
+ require: () => {
1592
+ throw new YError(REQUIRE_ERROR);
1593
+ },
1594
+ requireDirectory: () => {
1595
+ throw new YError(REQUIRE_DIRECTORY_ERROR);
1596
+ },
1597
+ stringWidth: (str) => {
1598
+ return [...str].length;
1599
+ },
1600
+ y18n: y18n_default({
1601
+ directory: resolve4(__dirname2, "../../../locales"),
1602
+ updateFiles: false
1603
+ })
1604
+ };
1605
+ });
1708
1606
 
1709
1607
  // node_modules/yargs/build/lib/typings/common-types.js
1710
1608
  function assertNotStrictEqual(actual, expected, shim2, message) {
@@ -1756,7 +1654,6 @@ function parseCommand(cmd) {
1756
1654
  }
1757
1655
 
1758
1656
  // node_modules/yargs/build/lib/argsert.js
1759
- var positionName = ["first", "second", "third", "fourth", "fifth", "sixth"];
1760
1657
  function argsert(arg1, arg2, arg3) {
1761
1658
  function parseArgs() {
1762
1659
  return typeof arg1 === "object" ? [{ demanded: [], optional: [] }, arg1, arg2] : [
@@ -1812,6 +1709,11 @@ function guessType(arg) {
1812
1709
  function argumentTypeError(observedType, allowedTypes, position) {
1813
1710
  throw new YError(`Invalid ${positionName[position] || "manyith"} argument. Expected ${allowedTypes.join(" or ")} but received ${observedType}.`);
1814
1711
  }
1712
+ var positionName;
1713
+ var init_argsert = __esm(() => {
1714
+ init_yerror();
1715
+ positionName = ["first", "second", "third", "fourth", "fifth", "sixth"];
1716
+ });
1815
1717
 
1816
1718
  // node_modules/yargs/build/lib/middleware.js
1817
1719
  class GlobalMiddleware {
@@ -1894,6 +1796,9 @@ function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
1894
1796
  }
1895
1797
  }, argv);
1896
1798
  }
1799
+ var init_middleware = __esm(() => {
1800
+ init_argsert();
1801
+ });
1897
1802
 
1898
1803
  // node_modules/yargs/build/lib/utils/maybe-async-result.js
1899
1804
  function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
@@ -1909,6 +1814,7 @@ function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
1909
1814
  function isFunction(arg) {
1910
1815
  return typeof arg === "function";
1911
1816
  }
1817
+ var init_maybe_async_result = () => {};
1912
1818
 
1913
1819
  // node_modules/yargs/build/lib/utils/which-module.js
1914
1820
  function whichModule(exported) {
@@ -1921,10 +1827,9 @@ function whichModule(exported) {
1921
1827
  }
1922
1828
  return null;
1923
1829
  }
1830
+ var init_which_module = () => {};
1924
1831
 
1925
1832
  // node_modules/yargs/build/lib/command.js
1926
- var DEFAULT_MARKER = /(^\*)|(^\$0)/;
1927
-
1928
1833
  class CommandInstance {
1929
1834
  constructor(usage, validation, globalMiddleware, shim2) {
1930
1835
  this.requireCache = new Set;
@@ -2312,6 +2217,14 @@ function isCommandBuilderOptionDefinitions(builder) {
2312
2217
  function isCommandHandlerDefinition(cmd) {
2313
2218
  return typeof cmd === "object" && !Array.isArray(cmd);
2314
2219
  }
2220
+ var DEFAULT_MARKER;
2221
+ var init_command = __esm(() => {
2222
+ init_middleware();
2223
+ init_yargs_factory();
2224
+ init_maybe_async_result();
2225
+ init_which_module();
2226
+ DEFAULT_MARKER = /(^\*)|(^\$0)/;
2227
+ });
2315
2228
 
2316
2229
  // node_modules/yargs/build/lib/utils/obj-filter.js
2317
2230
  function objFilter(original = {}, filter = () => true) {
@@ -2323,6 +2236,7 @@ function objFilter(original = {}, filter = () => true) {
2323
2236
  });
2324
2237
  return obj;
2325
2238
  }
2239
+ var init_obj_filter = () => {};
2326
2240
 
2327
2241
  // node_modules/yargs/build/lib/utils/set-blocking.js
2328
2242
  function setBlocking(blocking) {
@@ -2862,6 +2776,10 @@ function getIndentation(text) {
2862
2776
  function getText(text) {
2863
2777
  return isIndentedText(text) ? text.text : text;
2864
2778
  }
2779
+ var init_usage = __esm(() => {
2780
+ init_obj_filter();
2781
+ init_yerror();
2782
+ });
2865
2783
 
2866
2784
  // node_modules/yargs/build/lib/completion-templates.js
2867
2785
  var completionShTemplate = `###-begin-{{app_name}}-completions-###
@@ -2892,8 +2810,7 @@ _{{app_name}}_yargs_completions()
2892
2810
  }
2893
2811
  complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
2894
2812
  ###-end-{{app_name}}-completions-###
2895
- `;
2896
- var completionZshTemplate = `#compdef {{app_name}}
2813
+ `, completionZshTemplate = `#compdef {{app_name}}
2897
2814
  ###-begin-{{app_name}}-completions-###
2898
2815
  #
2899
2816
  # yargs command completion script
@@ -3126,6 +3043,9 @@ function isSyncCompletionFunction(completionFunction) {
3126
3043
  function isFallbackCompletionFunction(completionFunction) {
3127
3044
  return completionFunction.length > 3;
3128
3045
  }
3046
+ var init_completion = __esm(() => {
3047
+ init_command();
3048
+ });
3129
3049
 
3130
3050
  // node_modules/yargs/build/lib/utils/levenshtein.js
3131
3051
  function levenshtein(a, b) {
@@ -3159,7 +3079,6 @@ function levenshtein(a, b) {
3159
3079
  }
3160
3080
 
3161
3081
  // node_modules/yargs/build/lib/validation.js
3162
- var specialKeys = ["$0", "--", "_"];
3163
3082
  function validation(yargs, usage2, shim2) {
3164
3083
  const __ = shim2.y18n.__;
3165
3084
  const __n = shim2.y18n.__n;
@@ -3427,10 +3346,14 @@ ${customMsgs.join(`
3427
3346
  };
3428
3347
  return self;
3429
3348
  }
3349
+ var specialKeys;
3350
+ var init_validation = __esm(() => {
3351
+ init_argsert();
3352
+ init_obj_filter();
3353
+ specialKeys = ["$0", "--", "_"];
3354
+ });
3430
3355
 
3431
3356
  // node_modules/yargs/build/lib/utils/apply-extends.js
3432
- var previouslyVisitedConfigs = [];
3433
- var shim2;
3434
3357
  function applyExtends(config, cwd, mergeExtends, _shim) {
3435
3358
  shim2 = _shim;
3436
3359
  let defaultConfig = {};
@@ -3480,59 +3403,13 @@ function mergeDeep(config1, config2) {
3480
3403
  }
3481
3404
  return target;
3482
3405
  }
3406
+ var previouslyVisitedConfigs, shim2;
3407
+ var init_apply_extends = __esm(() => {
3408
+ init_yerror();
3409
+ previouslyVisitedConfigs = [];
3410
+ });
3483
3411
 
3484
3412
  // node_modules/yargs/build/lib/yargs-factory.js
3485
- var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
3486
- if (kind === "m")
3487
- throw new TypeError("Private method is not writable");
3488
- if (kind === "a" && !f)
3489
- throw new TypeError("Private accessor was defined without a setter");
3490
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3491
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
3492
- return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3493
- };
3494
- var __classPrivateFieldGet = function(receiver, state, kind, f) {
3495
- if (kind === "a" && !f)
3496
- throw new TypeError("Private accessor was defined without a getter");
3497
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3498
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
3499
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3500
- };
3501
- var _YargsInstance_command;
3502
- var _YargsInstance_cwd;
3503
- var _YargsInstance_context;
3504
- var _YargsInstance_completion;
3505
- var _YargsInstance_completionCommand;
3506
- var _YargsInstance_defaultShowHiddenOpt;
3507
- var _YargsInstance_exitError;
3508
- var _YargsInstance_detectLocale;
3509
- var _YargsInstance_emittedWarnings;
3510
- var _YargsInstance_exitProcess;
3511
- var _YargsInstance_frozens;
3512
- var _YargsInstance_globalMiddleware;
3513
- var _YargsInstance_groups;
3514
- var _YargsInstance_hasOutput;
3515
- var _YargsInstance_helpOpt;
3516
- var _YargsInstance_isGlobalContext;
3517
- var _YargsInstance_logger;
3518
- var _YargsInstance_output;
3519
- var _YargsInstance_options;
3520
- var _YargsInstance_parentRequire;
3521
- var _YargsInstance_parserConfig;
3522
- var _YargsInstance_parseFn;
3523
- var _YargsInstance_parseContext;
3524
- var _YargsInstance_pkgs;
3525
- var _YargsInstance_preservedGroups;
3526
- var _YargsInstance_processArgs;
3527
- var _YargsInstance_recommendCommands;
3528
- var _YargsInstance_shim;
3529
- var _YargsInstance_strict;
3530
- var _YargsInstance_strictCommands;
3531
- var _YargsInstance_strictOptions;
3532
- var _YargsInstance_usage;
3533
- var _YargsInstance_usageConfig;
3534
- var _YargsInstance_versionOpt;
3535
- var _YargsInstance_validation;
3536
3413
  function YargsFactory(_shim) {
3537
3414
  return (processArgs = [], cwd = _shim.process.cwd(), parentRequire) => {
3538
3415
  const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim);
@@ -3547,1449 +3424,1466 @@ function YargsFactory(_shim) {
3547
3424
  return yargs;
3548
3425
  };
3549
3426
  }
3550
- var kCopyDoubleDash = Symbol("copyDoubleDash");
3551
- var kCreateLogger = Symbol("copyDoubleDash");
3552
- var kDeleteFromParserHintObject = Symbol("deleteFromParserHintObject");
3553
- var kEmitWarning = Symbol("emitWarning");
3554
- var kFreeze = Symbol("freeze");
3555
- var kGetDollarZero = Symbol("getDollarZero");
3556
- var kGetParserConfiguration = Symbol("getParserConfiguration");
3557
- var kGetUsageConfiguration = Symbol("getUsageConfiguration");
3558
- var kGuessLocale = Symbol("guessLocale");
3559
- var kGuessVersion = Symbol("guessVersion");
3560
- var kParsePositionalNumbers = Symbol("parsePositionalNumbers");
3561
- var kPkgUp = Symbol("pkgUp");
3562
- var kPopulateParserHintArray = Symbol("populateParserHintArray");
3563
- var kPopulateParserHintSingleValueDictionary = Symbol("populateParserHintSingleValueDictionary");
3564
- var kPopulateParserHintArrayDictionary = Symbol("populateParserHintArrayDictionary");
3565
- var kPopulateParserHintDictionary = Symbol("populateParserHintDictionary");
3566
- var kSanitizeKey = Symbol("sanitizeKey");
3567
- var kSetKey = Symbol("setKey");
3568
- var kUnfreeze = Symbol("unfreeze");
3569
- var kValidateAsync = Symbol("validateAsync");
3570
- var kGetCommandInstance = Symbol("getCommandInstance");
3571
- var kGetContext = Symbol("getContext");
3572
- var kGetHasOutput = Symbol("getHasOutput");
3573
- var kGetLoggerInstance = Symbol("getLoggerInstance");
3574
- var kGetParseContext = Symbol("getParseContext");
3575
- var kGetUsageInstance = Symbol("getUsageInstance");
3576
- var kGetValidationInstance = Symbol("getValidationInstance");
3577
- var kHasParseCallback = Symbol("hasParseCallback");
3578
- var kIsGlobalContext = Symbol("isGlobalContext");
3579
- var kPostProcess = Symbol("postProcess");
3580
- var kRebase = Symbol("rebase");
3581
- var kReset = Symbol("reset");
3582
- var kRunYargsParserAndExecuteCommands = Symbol("runYargsParserAndExecuteCommands");
3583
- var kRunValidation = Symbol("runValidation");
3584
- var kSetHasOutput = Symbol("setHasOutput");
3585
- var kTrackManuallySetKeys = Symbol("kTrackManuallySetKeys");
3586
-
3587
- class YargsInstance {
3588
- constructor(processArgs = [], cwd, parentRequire, shim3) {
3589
- this.customScriptName = false;
3590
- this.parsed = false;
3591
- _YargsInstance_command.set(this, undefined);
3592
- _YargsInstance_cwd.set(this, undefined);
3593
- _YargsInstance_context.set(this, { commands: [], fullCommands: [] });
3594
- _YargsInstance_completion.set(this, null);
3595
- _YargsInstance_completionCommand.set(this, null);
3596
- _YargsInstance_defaultShowHiddenOpt.set(this, "show-hidden");
3597
- _YargsInstance_exitError.set(this, null);
3598
- _YargsInstance_detectLocale.set(this, true);
3599
- _YargsInstance_emittedWarnings.set(this, {});
3600
- _YargsInstance_exitProcess.set(this, true);
3601
- _YargsInstance_frozens.set(this, []);
3602
- _YargsInstance_globalMiddleware.set(this, undefined);
3603
- _YargsInstance_groups.set(this, {});
3604
- _YargsInstance_hasOutput.set(this, false);
3605
- _YargsInstance_helpOpt.set(this, null);
3606
- _YargsInstance_isGlobalContext.set(this, true);
3607
- _YargsInstance_logger.set(this, undefined);
3608
- _YargsInstance_output.set(this, "");
3609
- _YargsInstance_options.set(this, undefined);
3610
- _YargsInstance_parentRequire.set(this, undefined);
3611
- _YargsInstance_parserConfig.set(this, {});
3612
- _YargsInstance_parseFn.set(this, null);
3613
- _YargsInstance_parseContext.set(this, null);
3614
- _YargsInstance_pkgs.set(this, {});
3615
- _YargsInstance_preservedGroups.set(this, {});
3616
- _YargsInstance_processArgs.set(this, undefined);
3617
- _YargsInstance_recommendCommands.set(this, false);
3618
- _YargsInstance_shim.set(this, undefined);
3619
- _YargsInstance_strict.set(this, false);
3620
- _YargsInstance_strictCommands.set(this, false);
3621
- _YargsInstance_strictOptions.set(this, false);
3622
- _YargsInstance_usage.set(this, undefined);
3623
- _YargsInstance_usageConfig.set(this, {});
3624
- _YargsInstance_versionOpt.set(this, null);
3625
- _YargsInstance_validation.set(this, undefined);
3626
- __classPrivateFieldSet(this, _YargsInstance_shim, shim3, "f");
3627
- __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
3628
- __classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
3629
- __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
3630
- __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
3631
- this.$0 = this[kGetDollarZero]();
3632
- this[kReset]();
3633
- __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
3634
- __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
3635
- __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
3636
- __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
3637
- __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3638
- __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
3639
- }
3640
- addHelpOpt(opt, msg) {
3641
- const defaultHelpOpt = "help";
3642
- argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3643
- if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
3644
- this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3645
- __classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
3646
- }
3647
- if (opt === false && msg === undefined)
3427
+ function isYargsInstance(y) {
3428
+ return !!y && typeof y.getInternalMethods === "function";
3429
+ }
3430
+ var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
3431
+ if (kind === "m")
3432
+ throw new TypeError("Private method is not writable");
3433
+ if (kind === "a" && !f)
3434
+ throw new TypeError("Private accessor was defined without a setter");
3435
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3436
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
3437
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
3438
+ }, __classPrivateFieldGet = function(receiver, state, kind, f) {
3439
+ if (kind === "a" && !f)
3440
+ throw new TypeError("Private accessor was defined without a getter");
3441
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
3442
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
3443
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
3444
+ }, _YargsInstance_command, _YargsInstance_cwd, _YargsInstance_context, _YargsInstance_completion, _YargsInstance_completionCommand, _YargsInstance_defaultShowHiddenOpt, _YargsInstance_exitError, _YargsInstance_detectLocale, _YargsInstance_emittedWarnings, _YargsInstance_exitProcess, _YargsInstance_frozens, _YargsInstance_globalMiddleware, _YargsInstance_groups, _YargsInstance_hasOutput, _YargsInstance_helpOpt, _YargsInstance_isGlobalContext, _YargsInstance_logger, _YargsInstance_output, _YargsInstance_options, _YargsInstance_parentRequire, _YargsInstance_parserConfig, _YargsInstance_parseFn, _YargsInstance_parseContext, _YargsInstance_pkgs, _YargsInstance_preservedGroups, _YargsInstance_processArgs, _YargsInstance_recommendCommands, _YargsInstance_shim, _YargsInstance_strict, _YargsInstance_strictCommands, _YargsInstance_strictOptions, _YargsInstance_usage, _YargsInstance_usageConfig, _YargsInstance_versionOpt, _YargsInstance_validation, kCopyDoubleDash, kCreateLogger, kDeleteFromParserHintObject, kEmitWarning, kFreeze, kGetDollarZero, kGetParserConfiguration, kGetUsageConfiguration, kGuessLocale, kGuessVersion, kParsePositionalNumbers, kPkgUp, kPopulateParserHintArray, kPopulateParserHintSingleValueDictionary, kPopulateParserHintArrayDictionary, kPopulateParserHintDictionary, kSanitizeKey, kSetKey, kUnfreeze, kValidateAsync, kGetCommandInstance, kGetContext, kGetHasOutput, kGetLoggerInstance, kGetParseContext, kGetUsageInstance, kGetValidationInstance, kHasParseCallback, kIsGlobalContext, kPostProcess, kRebase, kReset, kRunYargsParserAndExecuteCommands, kRunValidation, kSetHasOutput, kTrackManuallySetKeys, YargsInstance;
3445
+ var init_yargs_factory = __esm(() => {
3446
+ init_command();
3447
+ init_yerror();
3448
+ init_usage();
3449
+ init_argsert();
3450
+ init_completion();
3451
+ init_validation();
3452
+ init_obj_filter();
3453
+ init_apply_extends();
3454
+ init_middleware();
3455
+ init_maybe_async_result();
3456
+ kCopyDoubleDash = Symbol("copyDoubleDash");
3457
+ kCreateLogger = Symbol("copyDoubleDash");
3458
+ kDeleteFromParserHintObject = Symbol("deleteFromParserHintObject");
3459
+ kEmitWarning = Symbol("emitWarning");
3460
+ kFreeze = Symbol("freeze");
3461
+ kGetDollarZero = Symbol("getDollarZero");
3462
+ kGetParserConfiguration = Symbol("getParserConfiguration");
3463
+ kGetUsageConfiguration = Symbol("getUsageConfiguration");
3464
+ kGuessLocale = Symbol("guessLocale");
3465
+ kGuessVersion = Symbol("guessVersion");
3466
+ kParsePositionalNumbers = Symbol("parsePositionalNumbers");
3467
+ kPkgUp = Symbol("pkgUp");
3468
+ kPopulateParserHintArray = Symbol("populateParserHintArray");
3469
+ kPopulateParserHintSingleValueDictionary = Symbol("populateParserHintSingleValueDictionary");
3470
+ kPopulateParserHintArrayDictionary = Symbol("populateParserHintArrayDictionary");
3471
+ kPopulateParserHintDictionary = Symbol("populateParserHintDictionary");
3472
+ kSanitizeKey = Symbol("sanitizeKey");
3473
+ kSetKey = Symbol("setKey");
3474
+ kUnfreeze = Symbol("unfreeze");
3475
+ kValidateAsync = Symbol("validateAsync");
3476
+ kGetCommandInstance = Symbol("getCommandInstance");
3477
+ kGetContext = Symbol("getContext");
3478
+ kGetHasOutput = Symbol("getHasOutput");
3479
+ kGetLoggerInstance = Symbol("getLoggerInstance");
3480
+ kGetParseContext = Symbol("getParseContext");
3481
+ kGetUsageInstance = Symbol("getUsageInstance");
3482
+ kGetValidationInstance = Symbol("getValidationInstance");
3483
+ kHasParseCallback = Symbol("hasParseCallback");
3484
+ kIsGlobalContext = Symbol("isGlobalContext");
3485
+ kPostProcess = Symbol("postProcess");
3486
+ kRebase = Symbol("rebase");
3487
+ kReset = Symbol("reset");
3488
+ kRunYargsParserAndExecuteCommands = Symbol("runYargsParserAndExecuteCommands");
3489
+ kRunValidation = Symbol("runValidation");
3490
+ kSetHasOutput = Symbol("setHasOutput");
3491
+ kTrackManuallySetKeys = Symbol("kTrackManuallySetKeys");
3492
+ YargsInstance = class YargsInstance {
3493
+ constructor(processArgs = [], cwd, parentRequire, shim3) {
3494
+ this.customScriptName = false;
3495
+ this.parsed = false;
3496
+ _YargsInstance_command.set(this, undefined);
3497
+ _YargsInstance_cwd.set(this, undefined);
3498
+ _YargsInstance_context.set(this, { commands: [], fullCommands: [] });
3499
+ _YargsInstance_completion.set(this, null);
3500
+ _YargsInstance_completionCommand.set(this, null);
3501
+ _YargsInstance_defaultShowHiddenOpt.set(this, "show-hidden");
3502
+ _YargsInstance_exitError.set(this, null);
3503
+ _YargsInstance_detectLocale.set(this, true);
3504
+ _YargsInstance_emittedWarnings.set(this, {});
3505
+ _YargsInstance_exitProcess.set(this, true);
3506
+ _YargsInstance_frozens.set(this, []);
3507
+ _YargsInstance_globalMiddleware.set(this, undefined);
3508
+ _YargsInstance_groups.set(this, {});
3509
+ _YargsInstance_hasOutput.set(this, false);
3510
+ _YargsInstance_helpOpt.set(this, null);
3511
+ _YargsInstance_isGlobalContext.set(this, true);
3512
+ _YargsInstance_logger.set(this, undefined);
3513
+ _YargsInstance_output.set(this, "");
3514
+ _YargsInstance_options.set(this, undefined);
3515
+ _YargsInstance_parentRequire.set(this, undefined);
3516
+ _YargsInstance_parserConfig.set(this, {});
3517
+ _YargsInstance_parseFn.set(this, null);
3518
+ _YargsInstance_parseContext.set(this, null);
3519
+ _YargsInstance_pkgs.set(this, {});
3520
+ _YargsInstance_preservedGroups.set(this, {});
3521
+ _YargsInstance_processArgs.set(this, undefined);
3522
+ _YargsInstance_recommendCommands.set(this, false);
3523
+ _YargsInstance_shim.set(this, undefined);
3524
+ _YargsInstance_strict.set(this, false);
3525
+ _YargsInstance_strictCommands.set(this, false);
3526
+ _YargsInstance_strictOptions.set(this, false);
3527
+ _YargsInstance_usage.set(this, undefined);
3528
+ _YargsInstance_usageConfig.set(this, {});
3529
+ _YargsInstance_versionOpt.set(this, null);
3530
+ _YargsInstance_validation.set(this, undefined);
3531
+ __classPrivateFieldSet(this, _YargsInstance_shim, shim3, "f");
3532
+ __classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
3533
+ __classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
3534
+ __classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
3535
+ __classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
3536
+ this.$0 = this[kGetDollarZero]();
3537
+ this[kReset]();
3538
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
3539
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
3540
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
3541
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
3542
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3543
+ __classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
3544
+ }
3545
+ addHelpOpt(opt, msg) {
3546
+ const defaultHelpOpt = "help";
3547
+ argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3548
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
3549
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3550
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
3551
+ }
3552
+ if (opt === false && msg === undefined)
3553
+ return this;
3554
+ __classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === "string" ? opt : defaultHelpOpt, "f");
3555
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3556
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show help"));
3648
3557
  return this;
3649
- __classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === "string" ? opt : defaultHelpOpt, "f");
3650
- this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
3651
- this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show help"));
3652
- return this;
3653
- }
3654
- help(opt, msg) {
3655
- return this.addHelpOpt(opt, msg);
3656
- }
3657
- addShowHiddenOpt(opt, msg) {
3658
- argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3659
- if (opt === false && msg === undefined)
3558
+ }
3559
+ help(opt, msg) {
3560
+ return this.addHelpOpt(opt, msg);
3561
+ }
3562
+ addShowHiddenOpt(opt, msg) {
3563
+ argsert("[string|boolean] [string]", [opt, msg], arguments.length);
3564
+ if (opt === false && msg === undefined)
3565
+ return this;
3566
+ const showHiddenOpt = typeof opt === "string" ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3567
+ this.boolean(showHiddenOpt);
3568
+ this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show hidden options"));
3569
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
3660
3570
  return this;
3661
- const showHiddenOpt = typeof opt === "string" ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
3662
- this.boolean(showHiddenOpt);
3663
- this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show hidden options"));
3664
- __classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
3665
- return this;
3666
- }
3667
- showHidden(opt, msg) {
3668
- return this.addShowHiddenOpt(opt, msg);
3669
- }
3670
- alias(key, value) {
3671
- argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3672
- this[kPopulateParserHintArrayDictionary](this.alias.bind(this), "alias", key, value);
3673
- return this;
3674
- }
3675
- array(keys) {
3676
- argsert("<array|string>", [keys], arguments.length);
3677
- this[kPopulateParserHintArray]("array", keys);
3678
- this[kTrackManuallySetKeys](keys);
3679
- return this;
3680
- }
3681
- boolean(keys) {
3682
- argsert("<array|string>", [keys], arguments.length);
3683
- this[kPopulateParserHintArray]("boolean", keys);
3684
- this[kTrackManuallySetKeys](keys);
3685
- return this;
3686
- }
3687
- check(f, global) {
3688
- argsert("<function> [boolean]", [f, global], arguments.length);
3689
- this.middleware((argv, _yargs) => {
3690
- return maybeAsyncResult(() => {
3691
- return f(argv, _yargs.getOptions());
3692
- }, (result) => {
3693
- if (!result) {
3694
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__("Argument check failed: %s", f.toString()));
3695
- } else if (typeof result === "string" || result instanceof Error) {
3696
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
3571
+ }
3572
+ showHidden(opt, msg) {
3573
+ return this.addShowHiddenOpt(opt, msg);
3574
+ }
3575
+ alias(key, value) {
3576
+ argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3577
+ this[kPopulateParserHintArrayDictionary](this.alias.bind(this), "alias", key, value);
3578
+ return this;
3579
+ }
3580
+ array(keys) {
3581
+ argsert("<array|string>", [keys], arguments.length);
3582
+ this[kPopulateParserHintArray]("array", keys);
3583
+ this[kTrackManuallySetKeys](keys);
3584
+ return this;
3585
+ }
3586
+ boolean(keys) {
3587
+ argsert("<array|string>", [keys], arguments.length);
3588
+ this[kPopulateParserHintArray]("boolean", keys);
3589
+ this[kTrackManuallySetKeys](keys);
3590
+ return this;
3591
+ }
3592
+ check(f, global) {
3593
+ argsert("<function> [boolean]", [f, global], arguments.length);
3594
+ this.middleware((argv, _yargs) => {
3595
+ return maybeAsyncResult(() => {
3596
+ return f(argv, _yargs.getOptions());
3597
+ }, (result) => {
3598
+ if (!result) {
3599
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__("Argument check failed: %s", f.toString()));
3600
+ } else if (typeof result === "string" || result instanceof Error) {
3601
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
3602
+ }
3603
+ return argv;
3604
+ }, (err) => {
3605
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
3606
+ return argv;
3607
+ });
3608
+ }, false, global);
3609
+ return this;
3610
+ }
3611
+ choices(key, value) {
3612
+ argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3613
+ this[kPopulateParserHintArrayDictionary](this.choices.bind(this), "choices", key, value);
3614
+ return this;
3615
+ }
3616
+ coerce(keys, value) {
3617
+ argsert("<object|string|array> [function]", [keys, value], arguments.length);
3618
+ if (Array.isArray(keys)) {
3619
+ if (!value) {
3620
+ throw new YError("coerce callback must be provided");
3697
3621
  }
3698
- return argv;
3699
- }, (err) => {
3700
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
3701
- return argv;
3702
- });
3703
- }, false, global);
3704
- return this;
3705
- }
3706
- choices(key, value) {
3707
- argsert("<object|string|array> [string|array]", [key, value], arguments.length);
3708
- this[kPopulateParserHintArrayDictionary](this.choices.bind(this), "choices", key, value);
3709
- return this;
3710
- }
3711
- coerce(keys, value) {
3712
- argsert("<object|string|array> [function]", [keys, value], arguments.length);
3713
- if (Array.isArray(keys)) {
3622
+ for (const key of keys) {
3623
+ this.coerce(key, value);
3624
+ }
3625
+ return this;
3626
+ } else if (typeof keys === "object") {
3627
+ for (const key of Object.keys(keys)) {
3628
+ this.coerce(key, keys[key]);
3629
+ }
3630
+ return this;
3631
+ }
3714
3632
  if (!value) {
3715
3633
  throw new YError("coerce callback must be provided");
3716
3634
  }
3717
- for (const key of keys) {
3718
- this.coerce(key, value);
3635
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
3636
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
3637
+ let aliases;
3638
+ const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
3639
+ if (!shouldCoerce) {
3640
+ return argv;
3641
+ }
3642
+ return maybeAsyncResult(() => {
3643
+ aliases = yargs.getAliases();
3644
+ return value(argv[keys]);
3645
+ }, (result) => {
3646
+ argv[keys] = result;
3647
+ const stripAliased = yargs.getInternalMethods().getParserConfiguration()["strip-aliased"];
3648
+ if (aliases[keys] && stripAliased !== true) {
3649
+ for (const alias of aliases[keys]) {
3650
+ argv[alias] = result;
3651
+ }
3652
+ }
3653
+ return argv;
3654
+ }, (err) => {
3655
+ throw new YError(err.message);
3656
+ });
3657
+ }, keys);
3658
+ return this;
3659
+ }
3660
+ conflicts(key1, key2) {
3661
+ argsert("<string|object> [string|array]", [key1, key2], arguments.length);
3662
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
3663
+ return this;
3664
+ }
3665
+ config(key = "config", msg, parseFn) {
3666
+ argsert("[object|string] [string|function] [function]", [key, msg, parseFn], arguments.length);
3667
+ if (typeof key === "object" && !Array.isArray(key)) {
3668
+ key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3669
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
3670
+ return this;
3671
+ }
3672
+ if (typeof msg === "function") {
3673
+ parseFn = msg;
3674
+ msg = undefined;
3719
3675
  }
3676
+ this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Path to JSON config file"));
3677
+ (Array.isArray(key) ? key : [key]).forEach((k) => {
3678
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
3679
+ });
3720
3680
  return this;
3721
- } else if (typeof keys === "object") {
3722
- for (const key of Object.keys(keys)) {
3723
- this.coerce(key, keys[key]);
3681
+ }
3682
+ completion(cmd, desc, fn) {
3683
+ argsert("[string] [string|boolean|function] [function]", [cmd, desc, fn], arguments.length);
3684
+ if (typeof desc === "function") {
3685
+ fn = desc;
3686
+ desc = undefined;
3687
+ }
3688
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion", "f");
3689
+ if (!desc && desc !== false) {
3690
+ desc = "generate completion script";
3724
3691
  }
3692
+ this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
3693
+ if (fn)
3694
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
3725
3695
  return this;
3726
3696
  }
3727
- if (!value) {
3728
- throw new YError("coerce callback must be provided");
3697
+ command(cmd, description, builder, handler, middlewares, deprecated) {
3698
+ argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [cmd, description, builder, handler, middlewares, deprecated], arguments.length);
3699
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
3700
+ return this;
3729
3701
  }
3730
- __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
3731
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
3732
- let aliases;
3733
- const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
3734
- if (!shouldCoerce) {
3735
- return argv;
3702
+ commands(cmd, description, builder, handler, middlewares, deprecated) {
3703
+ return this.command(cmd, description, builder, handler, middlewares, deprecated);
3704
+ }
3705
+ commandDir(dir, opts) {
3706
+ argsert("<string> [object]", [dir, opts], arguments.length);
3707
+ const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
3708
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
3709
+ return this;
3710
+ }
3711
+ count(keys) {
3712
+ argsert("<array|string>", [keys], arguments.length);
3713
+ this[kPopulateParserHintArray]("count", keys);
3714
+ this[kTrackManuallySetKeys](keys);
3715
+ return this;
3716
+ }
3717
+ default(key, value, defaultDescription) {
3718
+ argsert("<object|string|array> [*] [string]", [key, value, defaultDescription], arguments.length);
3719
+ if (defaultDescription) {
3720
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3721
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
3736
3722
  }
3737
- return maybeAsyncResult(() => {
3738
- aliases = yargs.getAliases();
3739
- return value(argv[keys]);
3740
- }, (result) => {
3741
- argv[keys] = result;
3742
- const stripAliased = yargs.getInternalMethods().getParserConfiguration()["strip-aliased"];
3743
- if (aliases[keys] && stripAliased !== true) {
3744
- for (const alias of aliases[keys]) {
3745
- argv[alias] = result;
3746
- }
3723
+ if (typeof value === "function") {
3724
+ assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3725
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key])
3726
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
3727
+ value = value.call();
3728
+ }
3729
+ this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), "default", key, value);
3730
+ return this;
3731
+ }
3732
+ defaults(key, value, defaultDescription) {
3733
+ return this.default(key, value, defaultDescription);
3734
+ }
3735
+ demandCommand(min = 1, max, minMsg, maxMsg) {
3736
+ argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]", [min, max, minMsg, maxMsg], arguments.length);
3737
+ if (typeof max !== "number") {
3738
+ minMsg = max;
3739
+ max = Infinity;
3740
+ }
3741
+ this.global("_", false);
3742
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
3743
+ min,
3744
+ max,
3745
+ minMsg,
3746
+ maxMsg
3747
+ };
3748
+ return this;
3749
+ }
3750
+ demand(keys, max, msg) {
3751
+ if (Array.isArray(max)) {
3752
+ max.forEach((key) => {
3753
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3754
+ this.demandOption(key, msg);
3755
+ });
3756
+ max = Infinity;
3757
+ } else if (typeof max !== "number") {
3758
+ msg = max;
3759
+ max = Infinity;
3760
+ }
3761
+ if (typeof keys === "number") {
3762
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3763
+ this.demandCommand(keys, max, msg, msg);
3764
+ } else if (Array.isArray(keys)) {
3765
+ keys.forEach((key) => {
3766
+ assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3767
+ this.demandOption(key, msg);
3768
+ });
3769
+ } else {
3770
+ if (typeof msg === "string") {
3771
+ this.demandOption(keys, msg);
3772
+ } else if (msg === true || typeof msg === "undefined") {
3773
+ this.demandOption(keys);
3747
3774
  }
3748
- return argv;
3749
- }, (err) => {
3750
- throw new YError(err.message);
3751
- });
3752
- }, keys);
3753
- return this;
3754
- }
3755
- conflicts(key1, key2) {
3756
- argsert("<string|object> [string|array]", [key1, key2], arguments.length);
3757
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
3758
- return this;
3759
- }
3760
- config(key = "config", msg, parseFn) {
3761
- argsert("[object|string] [string|function] [function]", [key, msg, parseFn], arguments.length);
3762
- if (typeof key === "object" && !Array.isArray(key)) {
3763
- key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3764
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
3775
+ }
3765
3776
  return this;
3766
3777
  }
3767
- if (typeof msg === "function") {
3768
- parseFn = msg;
3769
- msg = undefined;
3778
+ demandOption(keys, msg) {
3779
+ argsert("<object|string|array> [string]", [keys, msg], arguments.length);
3780
+ this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), "demandedOptions", keys, msg);
3781
+ return this;
3770
3782
  }
3771
- this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Path to JSON config file"));
3772
- (Array.isArray(key) ? key : [key]).forEach((k) => {
3773
- __classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
3774
- });
3775
- return this;
3776
- }
3777
- completion(cmd, desc, fn) {
3778
- argsert("[string] [string|boolean|function] [function]", [cmd, desc, fn], arguments.length);
3779
- if (typeof desc === "function") {
3780
- fn = desc;
3781
- desc = undefined;
3783
+ deprecateOption(option, message) {
3784
+ argsert("<string> [string|boolean]", [option, message], arguments.length);
3785
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
3786
+ return this;
3782
3787
  }
3783
- __classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion", "f");
3784
- if (!desc && desc !== false) {
3785
- desc = "generate completion script";
3788
+ describe(keys, description) {
3789
+ argsert("<object|string|array> [string]", [keys, description], arguments.length);
3790
+ this[kSetKey](keys, true);
3791
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
3792
+ return this;
3786
3793
  }
3787
- this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
3788
- if (fn)
3789
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
3790
- return this;
3791
- }
3792
- command(cmd, description, builder, handler, middlewares, deprecated) {
3793
- argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [cmd, description, builder, handler, middlewares, deprecated], arguments.length);
3794
- __classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
3795
- return this;
3796
- }
3797
- commands(cmd, description, builder, handler, middlewares, deprecated) {
3798
- return this.command(cmd, description, builder, handler, middlewares, deprecated);
3799
- }
3800
- commandDir(dir, opts) {
3801
- argsert("<string> [object]", [dir, opts], arguments.length);
3802
- const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
3803
- __classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
3804
- return this;
3805
- }
3806
- count(keys) {
3807
- argsert("<array|string>", [keys], arguments.length);
3808
- this[kPopulateParserHintArray]("count", keys);
3809
- this[kTrackManuallySetKeys](keys);
3810
- return this;
3811
- }
3812
- default(key, value, defaultDescription) {
3813
- argsert("<object|string|array> [*] [string]", [key, value, defaultDescription], arguments.length);
3814
- if (defaultDescription) {
3815
- assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3816
- __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
3794
+ detectLocale(detect) {
3795
+ argsert("<boolean>", [detect], arguments.length);
3796
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
3797
+ return this;
3817
3798
  }
3818
- if (typeof value === "function") {
3819
- assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3820
- if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key])
3821
- __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
3822
- value = value.call();
3799
+ env(prefix) {
3800
+ argsert("[string|boolean]", [prefix], arguments.length);
3801
+ if (prefix === false)
3802
+ delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
3803
+ else
3804
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || "";
3805
+ return this;
3823
3806
  }
3824
- this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), "default", key, value);
3825
- return this;
3826
- }
3827
- defaults(key, value, defaultDescription) {
3828
- return this.default(key, value, defaultDescription);
3829
- }
3830
- demandCommand(min = 1, max, minMsg, maxMsg) {
3831
- argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]", [min, max, minMsg, maxMsg], arguments.length);
3832
- if (typeof max !== "number") {
3833
- minMsg = max;
3834
- max = Infinity;
3835
- }
3836
- this.global("_", false);
3837
- __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
3838
- min,
3839
- max,
3840
- minMsg,
3841
- maxMsg
3842
- };
3843
- return this;
3844
- }
3845
- demand(keys, max, msg) {
3846
- if (Array.isArray(max)) {
3847
- max.forEach((key) => {
3848
- assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3849
- this.demandOption(key, msg);
3850
- });
3851
- max = Infinity;
3852
- } else if (typeof max !== "number") {
3853
- msg = max;
3854
- max = Infinity;
3855
- }
3856
- if (typeof keys === "number") {
3857
- assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3858
- this.demandCommand(keys, max, msg, msg);
3859
- } else if (Array.isArray(keys)) {
3860
- keys.forEach((key) => {
3861
- assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
3862
- this.demandOption(key, msg);
3863
- });
3864
- } else {
3865
- if (typeof msg === "string") {
3866
- this.demandOption(keys, msg);
3867
- } else if (msg === true || typeof msg === "undefined") {
3868
- this.demandOption(keys);
3807
+ epilogue(msg) {
3808
+ argsert("<string>", [msg], arguments.length);
3809
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
3810
+ return this;
3811
+ }
3812
+ epilog(msg) {
3813
+ return this.epilogue(msg);
3814
+ }
3815
+ example(cmd, description) {
3816
+ argsert("<string|array> [string]", [cmd, description], arguments.length);
3817
+ if (Array.isArray(cmd)) {
3818
+ cmd.forEach((exampleParams) => this.example(...exampleParams));
3819
+ } else {
3820
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
3869
3821
  }
3822
+ return this;
3870
3823
  }
3871
- return this;
3872
- }
3873
- demandOption(keys, msg) {
3874
- argsert("<object|string|array> [string]", [keys, msg], arguments.length);
3875
- this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), "demandedOptions", keys, msg);
3876
- return this;
3877
- }
3878
- deprecateOption(option, message) {
3879
- argsert("<string> [string|boolean]", [option, message], arguments.length);
3880
- __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
3881
- return this;
3882
- }
3883
- describe(keys, description) {
3884
- argsert("<object|string|array> [string]", [keys, description], arguments.length);
3885
- this[kSetKey](keys, true);
3886
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
3887
- return this;
3888
- }
3889
- detectLocale(detect) {
3890
- argsert("<boolean>", [detect], arguments.length);
3891
- __classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
3892
- return this;
3893
- }
3894
- env(prefix) {
3895
- argsert("[string|boolean]", [prefix], arguments.length);
3896
- if (prefix === false)
3897
- delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
3898
- else
3899
- __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || "";
3900
- return this;
3901
- }
3902
- epilogue(msg) {
3903
- argsert("<string>", [msg], arguments.length);
3904
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
3905
- return this;
3906
- }
3907
- epilog(msg) {
3908
- return this.epilogue(msg);
3909
- }
3910
- example(cmd, description) {
3911
- argsert("<string|array> [string]", [cmd, description], arguments.length);
3912
- if (Array.isArray(cmd)) {
3913
- cmd.forEach((exampleParams) => this.example(...exampleParams));
3914
- } else {
3915
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
3824
+ exit(code, err) {
3825
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3826
+ __classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
3827
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
3828
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
3916
3829
  }
3917
- return this;
3918
- }
3919
- exit(code, err) {
3920
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3921
- __classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
3922
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
3923
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
3924
- }
3925
- exitProcess(enabled = true) {
3926
- argsert("[boolean]", [enabled], arguments.length);
3927
- __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
3928
- return this;
3929
- }
3930
- fail(f) {
3931
- argsert("<function|boolean>", [f], arguments.length);
3932
- if (typeof f === "boolean" && f !== false) {
3933
- throw new YError("Invalid first argument. Expected function or boolean 'false'");
3830
+ exitProcess(enabled = true) {
3831
+ argsert("[boolean]", [enabled], arguments.length);
3832
+ __classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
3833
+ return this;
3934
3834
  }
3935
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
3936
- return this;
3937
- }
3938
- getAliases() {
3939
- return this.parsed ? this.parsed.aliases : {};
3940
- }
3941
- async getCompletion(args, done) {
3942
- argsert("<array> [function]", [args, done], arguments.length);
3943
- if (!done) {
3944
- return new Promise((resolve5, reject) => {
3945
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
3946
- if (err)
3947
- reject(err);
3948
- else
3949
- resolve5(completions);
3835
+ fail(f) {
3836
+ argsert("<function|boolean>", [f], arguments.length);
3837
+ if (typeof f === "boolean" && f !== false) {
3838
+ throw new YError("Invalid first argument. Expected function or boolean 'false'");
3839
+ }
3840
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
3841
+ return this;
3842
+ }
3843
+ getAliases() {
3844
+ return this.parsed ? this.parsed.aliases : {};
3845
+ }
3846
+ async getCompletion(args, done) {
3847
+ argsert("<array> [function]", [args, done], arguments.length);
3848
+ if (!done) {
3849
+ return new Promise((resolve5, reject) => {
3850
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
3851
+ if (err)
3852
+ reject(err);
3853
+ else
3854
+ resolve5(completions);
3855
+ });
3950
3856
  });
3951
- });
3952
- } else {
3953
- return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
3857
+ } else {
3858
+ return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
3859
+ }
3954
3860
  }
3955
- }
3956
- getDemandedOptions() {
3957
- argsert([], 0);
3958
- return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
3959
- }
3960
- getDemandedCommands() {
3961
- argsert([], 0);
3962
- return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
3963
- }
3964
- getDeprecatedOptions() {
3965
- argsert([], 0);
3966
- return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
3967
- }
3968
- getDetectLocale() {
3969
- return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
3970
- }
3971
- getExitProcess() {
3972
- return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
3973
- }
3974
- getGroups() {
3975
- return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
3976
- }
3977
- getHelp() {
3978
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3979
- if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
3980
- if (!this.parsed) {
3981
- const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
3982
- if (isPromise(parse)) {
3983
- return parse.then(() => {
3861
+ getDemandedOptions() {
3862
+ argsert([], 0);
3863
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
3864
+ }
3865
+ getDemandedCommands() {
3866
+ argsert([], 0);
3867
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
3868
+ }
3869
+ getDeprecatedOptions() {
3870
+ argsert([], 0);
3871
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
3872
+ }
3873
+ getDetectLocale() {
3874
+ return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
3875
+ }
3876
+ getExitProcess() {
3877
+ return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
3878
+ }
3879
+ getGroups() {
3880
+ return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
3881
+ }
3882
+ getHelp() {
3883
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
3884
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
3885
+ if (!this.parsed) {
3886
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
3887
+ if (isPromise(parse)) {
3888
+ return parse.then(() => {
3889
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3890
+ });
3891
+ }
3892
+ }
3893
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
3894
+ if (isPromise(builderResponse)) {
3895
+ return builderResponse.then(() => {
3984
3896
  return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3985
3897
  });
3986
3898
  }
3987
3899
  }
3988
- const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
3989
- if (isPromise(builderResponse)) {
3990
- return builderResponse.then(() => {
3991
- return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
3900
+ return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
3901
+ }
3902
+ getOptions() {
3903
+ return __classPrivateFieldGet(this, _YargsInstance_options, "f");
3904
+ }
3905
+ getStrict() {
3906
+ return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
3907
+ }
3908
+ getStrictCommands() {
3909
+ return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
3910
+ }
3911
+ getStrictOptions() {
3912
+ return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
3913
+ }
3914
+ global(globals, global) {
3915
+ argsert("<string|array> [boolean]", [globals, global], arguments.length);
3916
+ globals = [].concat(globals);
3917
+ if (global !== false) {
3918
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l) => globals.indexOf(l) === -1);
3919
+ } else {
3920
+ globals.forEach((g2) => {
3921
+ if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g2))
3922
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g2);
3992
3923
  });
3993
3924
  }
3925
+ return this;
3994
3926
  }
3995
- return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
3996
- }
3997
- getOptions() {
3998
- return __classPrivateFieldGet(this, _YargsInstance_options, "f");
3999
- }
4000
- getStrict() {
4001
- return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
4002
- }
4003
- getStrictCommands() {
4004
- return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
4005
- }
4006
- getStrictOptions() {
4007
- return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
4008
- }
4009
- global(globals, global) {
4010
- argsert("<string|array> [boolean]", [globals, global], arguments.length);
4011
- globals = [].concat(globals);
4012
- if (global !== false) {
4013
- __classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l) => globals.indexOf(l) === -1);
4014
- } else {
4015
- globals.forEach((g2) => {
4016
- if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g2))
4017
- __classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g2);
3927
+ group(opts, groupName) {
3928
+ argsert("<string|array> <string>", [opts, groupName], arguments.length);
3929
+ const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
3930
+ if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) {
3931
+ delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
3932
+ }
3933
+ const seen = {};
3934
+ __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key) => {
3935
+ if (seen[key])
3936
+ return false;
3937
+ return seen[key] = true;
4018
3938
  });
3939
+ return this;
4019
3940
  }
4020
- return this;
4021
- }
4022
- group(opts, groupName) {
4023
- argsert("<string|array> <string>", [opts, groupName], arguments.length);
4024
- const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
4025
- if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) {
4026
- delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
3941
+ hide(key) {
3942
+ argsert("<string>", [key], arguments.length);
3943
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
3944
+ return this;
4027
3945
  }
4028
- const seen = {};
4029
- __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key) => {
4030
- if (seen[key])
4031
- return false;
4032
- return seen[key] = true;
4033
- });
4034
- return this;
4035
- }
4036
- hide(key) {
4037
- argsert("<string>", [key], arguments.length);
4038
- __classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
4039
- return this;
4040
- }
4041
- implies(key, value) {
4042
- argsert("<string|object> [number|string|array]", [key, value], arguments.length);
4043
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
4044
- return this;
4045
- }
4046
- locale(locale) {
4047
- argsert("[string]", [locale], arguments.length);
4048
- if (locale === undefined) {
4049
- this[kGuessLocale]();
4050
- return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
3946
+ implies(key, value) {
3947
+ argsert("<string|object> [number|string|array]", [key, value], arguments.length);
3948
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
3949
+ return this;
4051
3950
  }
4052
- __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
4053
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
4054
- return this;
4055
- }
4056
- middleware(callback, applyBeforeValidation, global) {
4057
- return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
4058
- }
4059
- nargs(key, value) {
4060
- argsert("<string|object|array> [number]", [key, value], arguments.length);
4061
- this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), "narg", key, value);
4062
- return this;
4063
- }
4064
- normalize(keys) {
4065
- argsert("<array|string>", [keys], arguments.length);
4066
- this[kPopulateParserHintArray]("normalize", keys);
4067
- return this;
4068
- }
4069
- number(keys) {
4070
- argsert("<array|string>", [keys], arguments.length);
4071
- this[kPopulateParserHintArray]("number", keys);
4072
- this[kTrackManuallySetKeys](keys);
4073
- return this;
4074
- }
4075
- option(key, opt) {
4076
- argsert("<string|object> [object]", [key, opt], arguments.length);
4077
- if (typeof key === "object") {
4078
- Object.keys(key).forEach((k) => {
4079
- this.options(k, key[k]);
4080
- });
4081
- } else {
4082
- if (typeof opt !== "object") {
4083
- opt = {};
4084
- }
4085
- this[kTrackManuallySetKeys](key);
4086
- if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === "version" || (opt === null || opt === undefined ? undefined : opt.alias) === "version")) {
4087
- this[kEmitWarning]([
4088
- '"version" is a reserved word.',
4089
- "Please do one of the following:",
4090
- '- Disable version with `yargs.version(false)` if using "version" as an option',
4091
- "- Use the built-in `yargs.version` method instead (if applicable)",
4092
- "- Use a different option key",
4093
- "https://yargs.js.org/docs/#api-reference-version"
4094
- ].join(`
4095
- `), undefined, "versionWarning");
4096
- }
4097
- __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
4098
- if (opt.alias)
4099
- this.alias(key, opt.alias);
4100
- const deprecate = opt.deprecate || opt.deprecated;
4101
- if (deprecate) {
4102
- this.deprecateOption(key, deprecate);
4103
- }
4104
- const demand = opt.demand || opt.required || opt.require;
4105
- if (demand) {
4106
- this.demand(key, demand);
4107
- }
4108
- if (opt.demandOption) {
4109
- this.demandOption(key, typeof opt.demandOption === "string" ? opt.demandOption : undefined);
4110
- }
4111
- if (opt.conflicts) {
4112
- this.conflicts(key, opt.conflicts);
4113
- }
4114
- if ("default" in opt) {
4115
- this.default(key, opt.default);
4116
- }
4117
- if (opt.implies !== undefined) {
4118
- this.implies(key, opt.implies);
4119
- }
4120
- if (opt.nargs !== undefined) {
4121
- this.nargs(key, opt.nargs);
3951
+ locale(locale) {
3952
+ argsert("[string]", [locale], arguments.length);
3953
+ if (locale === undefined) {
3954
+ this[kGuessLocale]();
3955
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
4122
3956
  }
4123
- if (opt.config) {
4124
- this.config(key, opt.configParser);
4125
- }
4126
- if (opt.normalize) {
4127
- this.normalize(key);
4128
- }
4129
- if (opt.choices) {
4130
- this.choices(key, opt.choices);
4131
- }
4132
- if (opt.coerce) {
4133
- this.coerce(key, opt.coerce);
4134
- }
4135
- if (opt.group) {
4136
- this.group(key, opt.group);
4137
- }
4138
- if (opt.boolean || opt.type === "boolean") {
4139
- this.boolean(key);
4140
- if (opt.alias)
4141
- this.boolean(opt.alias);
4142
- }
4143
- if (opt.array || opt.type === "array") {
4144
- this.array(key);
4145
- if (opt.alias)
4146
- this.array(opt.alias);
4147
- }
4148
- if (opt.number || opt.type === "number") {
4149
- this.number(key);
4150
- if (opt.alias)
4151
- this.number(opt.alias);
4152
- }
4153
- if (opt.string || opt.type === "string") {
4154
- this.string(key);
3957
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
3958
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
3959
+ return this;
3960
+ }
3961
+ middleware(callback, applyBeforeValidation, global) {
3962
+ return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global);
3963
+ }
3964
+ nargs(key, value) {
3965
+ argsert("<string|object|array> [number]", [key, value], arguments.length);
3966
+ this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), "narg", key, value);
3967
+ return this;
3968
+ }
3969
+ normalize(keys) {
3970
+ argsert("<array|string>", [keys], arguments.length);
3971
+ this[kPopulateParserHintArray]("normalize", keys);
3972
+ return this;
3973
+ }
3974
+ number(keys) {
3975
+ argsert("<array|string>", [keys], arguments.length);
3976
+ this[kPopulateParserHintArray]("number", keys);
3977
+ this[kTrackManuallySetKeys](keys);
3978
+ return this;
3979
+ }
3980
+ option(key, opt) {
3981
+ argsert("<string|object> [object]", [key, opt], arguments.length);
3982
+ if (typeof key === "object") {
3983
+ Object.keys(key).forEach((k) => {
3984
+ this.options(k, key[k]);
3985
+ });
3986
+ } else {
3987
+ if (typeof opt !== "object") {
3988
+ opt = {};
3989
+ }
3990
+ this[kTrackManuallySetKeys](key);
3991
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === "version" || (opt === null || opt === undefined ? undefined : opt.alias) === "version")) {
3992
+ this[kEmitWarning]([
3993
+ '"version" is a reserved word.',
3994
+ "Please do one of the following:",
3995
+ '- Disable version with `yargs.version(false)` if using "version" as an option',
3996
+ "- Use the built-in `yargs.version` method instead (if applicable)",
3997
+ "- Use a different option key",
3998
+ "https://yargs.js.org/docs/#api-reference-version"
3999
+ ].join(`
4000
+ `), undefined, "versionWarning");
4001
+ }
4002
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
4155
4003
  if (opt.alias)
4156
- this.string(opt.alias);
4157
- }
4158
- if (opt.count || opt.type === "count") {
4159
- this.count(key);
4004
+ this.alias(key, opt.alias);
4005
+ const deprecate = opt.deprecate || opt.deprecated;
4006
+ if (deprecate) {
4007
+ this.deprecateOption(key, deprecate);
4008
+ }
4009
+ const demand = opt.demand || opt.required || opt.require;
4010
+ if (demand) {
4011
+ this.demand(key, demand);
4012
+ }
4013
+ if (opt.demandOption) {
4014
+ this.demandOption(key, typeof opt.demandOption === "string" ? opt.demandOption : undefined);
4015
+ }
4016
+ if (opt.conflicts) {
4017
+ this.conflicts(key, opt.conflicts);
4018
+ }
4019
+ if ("default" in opt) {
4020
+ this.default(key, opt.default);
4021
+ }
4022
+ if (opt.implies !== undefined) {
4023
+ this.implies(key, opt.implies);
4024
+ }
4025
+ if (opt.nargs !== undefined) {
4026
+ this.nargs(key, opt.nargs);
4027
+ }
4028
+ if (opt.config) {
4029
+ this.config(key, opt.configParser);
4030
+ }
4031
+ if (opt.normalize) {
4032
+ this.normalize(key);
4033
+ }
4034
+ if (opt.choices) {
4035
+ this.choices(key, opt.choices);
4036
+ }
4037
+ if (opt.coerce) {
4038
+ this.coerce(key, opt.coerce);
4039
+ }
4040
+ if (opt.group) {
4041
+ this.group(key, opt.group);
4042
+ }
4043
+ if (opt.boolean || opt.type === "boolean") {
4044
+ this.boolean(key);
4045
+ if (opt.alias)
4046
+ this.boolean(opt.alias);
4047
+ }
4048
+ if (opt.array || opt.type === "array") {
4049
+ this.array(key);
4050
+ if (opt.alias)
4051
+ this.array(opt.alias);
4052
+ }
4053
+ if (opt.number || opt.type === "number") {
4054
+ this.number(key);
4055
+ if (opt.alias)
4056
+ this.number(opt.alias);
4057
+ }
4058
+ if (opt.string || opt.type === "string") {
4059
+ this.string(key);
4060
+ if (opt.alias)
4061
+ this.string(opt.alias);
4062
+ }
4063
+ if (opt.count || opt.type === "count") {
4064
+ this.count(key);
4065
+ }
4066
+ if (typeof opt.global === "boolean") {
4067
+ this.global(key, opt.global);
4068
+ }
4069
+ if (opt.defaultDescription) {
4070
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
4071
+ }
4072
+ if (opt.skipValidation) {
4073
+ this.skipValidation(key);
4074
+ }
4075
+ const desc = opt.describe || opt.description || opt.desc;
4076
+ const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
4077
+ if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") {
4078
+ this.describe(key, desc);
4079
+ }
4080
+ if (opt.hidden) {
4081
+ this.hide(key);
4082
+ }
4083
+ if (opt.requiresArg) {
4084
+ this.requiresArg(key);
4085
+ }
4160
4086
  }
4161
- if (typeof opt.global === "boolean") {
4162
- this.global(key, opt.global);
4087
+ return this;
4088
+ }
4089
+ options(key, opt) {
4090
+ return this.option(key, opt);
4091
+ }
4092
+ parse(args, shortCircuit, _parseFn) {
4093
+ argsert("[string|array] [function|boolean|object] [function]", [args, shortCircuit, _parseFn], arguments.length);
4094
+ this[kFreeze]();
4095
+ if (typeof args === "undefined") {
4096
+ args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
4163
4097
  }
4164
- if (opt.defaultDescription) {
4165
- __classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
4098
+ if (typeof shortCircuit === "object") {
4099
+ __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
4100
+ shortCircuit = _parseFn;
4166
4101
  }
4167
- if (opt.skipValidation) {
4168
- this.skipValidation(key);
4102
+ if (typeof shortCircuit === "function") {
4103
+ __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
4104
+ shortCircuit = false;
4169
4105
  }
4170
- const desc = opt.describe || opt.description || opt.desc;
4171
- const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
4172
- if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") {
4173
- this.describe(key, desc);
4106
+ if (!shortCircuit)
4107
+ __classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
4108
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
4109
+ __classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
4110
+ const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
4111
+ const tmpParsed = this.parsed;
4112
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
4113
+ if (isPromise(parsed)) {
4114
+ return parsed.then((argv) => {
4115
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
4116
+ __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
4117
+ return argv;
4118
+ }).catch((err) => {
4119
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) {
4120
+ __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
4121
+ }
4122
+ throw err;
4123
+ }).finally(() => {
4124
+ this[kUnfreeze]();
4125
+ this.parsed = tmpParsed;
4126
+ });
4127
+ } else {
4128
+ if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
4129
+ __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
4130
+ this[kUnfreeze]();
4131
+ this.parsed = tmpParsed;
4174
4132
  }
4175
- if (opt.hidden) {
4176
- this.hide(key);
4133
+ return parsed;
4134
+ }
4135
+ parseAsync(args, shortCircuit, _parseFn) {
4136
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
4137
+ return !isPromise(maybePromise) ? Promise.resolve(maybePromise) : maybePromise;
4138
+ }
4139
+ parseSync(args, shortCircuit, _parseFn) {
4140
+ const maybePromise = this.parse(args, shortCircuit, _parseFn);
4141
+ if (isPromise(maybePromise)) {
4142
+ throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware");
4177
4143
  }
4178
- if (opt.requiresArg) {
4179
- this.requiresArg(key);
4144
+ return maybePromise;
4145
+ }
4146
+ parserConfiguration(config) {
4147
+ argsert("<object>", [config], arguments.length);
4148
+ __classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
4149
+ return this;
4150
+ }
4151
+ pkgConf(key, rootPath) {
4152
+ argsert("<string> [string]", [key, rootPath], arguments.length);
4153
+ let conf = null;
4154
+ const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
4155
+ if (obj[key] && typeof obj[key] === "object") {
4156
+ conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4157
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
4180
4158
  }
4159
+ return this;
4181
4160
  }
4182
- return this;
4183
- }
4184
- options(key, opt) {
4185
- return this.option(key, opt);
4186
- }
4187
- parse(args, shortCircuit, _parseFn) {
4188
- argsert("[string|array] [function|boolean|object] [function]", [args, shortCircuit, _parseFn], arguments.length);
4189
- this[kFreeze]();
4190
- if (typeof args === "undefined") {
4191
- args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
4192
- }
4193
- if (typeof shortCircuit === "object") {
4194
- __classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
4195
- shortCircuit = _parseFn;
4196
- }
4197
- if (typeof shortCircuit === "function") {
4198
- __classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
4199
- shortCircuit = false;
4200
- }
4201
- if (!shortCircuit)
4202
- __classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
4203
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
4204
- __classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
4205
- const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
4206
- const tmpParsed = this.parsed;
4207
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
4208
- if (isPromise(parsed)) {
4209
- return parsed.then((argv) => {
4210
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
4211
- __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
4212
- return argv;
4213
- }).catch((err) => {
4214
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) {
4215
- __classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
4161
+ positional(key, opts) {
4162
+ argsert("<string> <object>", [key, opts], arguments.length);
4163
+ const supportedOpts = [
4164
+ "default",
4165
+ "defaultDescription",
4166
+ "implies",
4167
+ "normalize",
4168
+ "choices",
4169
+ "conflicts",
4170
+ "coerce",
4171
+ "type",
4172
+ "describe",
4173
+ "desc",
4174
+ "description",
4175
+ "alias"
4176
+ ];
4177
+ opts = objFilter(opts, (k, v) => {
4178
+ if (k === "type" && !["string", "number", "boolean"].includes(v))
4179
+ return false;
4180
+ return supportedOpts.includes(k);
4181
+ });
4182
+ const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
4183
+ const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : {
4184
+ array: [],
4185
+ alias: {},
4186
+ default: {},
4187
+ demand: {}
4188
+ };
4189
+ objectKeys(parseOptions).forEach((pk) => {
4190
+ const parseOption = parseOptions[pk];
4191
+ if (Array.isArray(parseOption)) {
4192
+ if (parseOption.indexOf(key) !== -1)
4193
+ opts[pk] = true;
4194
+ } else {
4195
+ if (parseOption[key] && !(pk in opts))
4196
+ opts[pk] = parseOption[key];
4216
4197
  }
4217
- throw err;
4218
- }).finally(() => {
4219
- this[kUnfreeze]();
4220
- this.parsed = tmpParsed;
4221
4198
  });
4222
- } else {
4223
- if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
4224
- __classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
4225
- this[kUnfreeze]();
4226
- this.parsed = tmpParsed;
4227
- }
4228
- return parsed;
4229
- }
4230
- parseAsync(args, shortCircuit, _parseFn) {
4231
- const maybePromise = this.parse(args, shortCircuit, _parseFn);
4232
- return !isPromise(maybePromise) ? Promise.resolve(maybePromise) : maybePromise;
4233
- }
4234
- parseSync(args, shortCircuit, _parseFn) {
4235
- const maybePromise = this.parse(args, shortCircuit, _parseFn);
4236
- if (isPromise(maybePromise)) {
4237
- throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware");
4238
- }
4239
- return maybePromise;
4240
- }
4241
- parserConfiguration(config) {
4242
- argsert("<object>", [config], arguments.length);
4243
- __classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
4244
- return this;
4245
- }
4246
- pkgConf(key, rootPath) {
4247
- argsert("<string> [string]", [key, rootPath], arguments.length);
4248
- let conf = null;
4249
- const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
4250
- if (obj[key] && typeof obj[key] === "object") {
4251
- conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4252
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
4199
+ this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
4200
+ return this.option(key, opts);
4253
4201
  }
4254
- return this;
4255
- }
4256
- positional(key, opts) {
4257
- argsert("<string> <object>", [key, opts], arguments.length);
4258
- const supportedOpts = [
4259
- "default",
4260
- "defaultDescription",
4261
- "implies",
4262
- "normalize",
4263
- "choices",
4264
- "conflicts",
4265
- "coerce",
4266
- "type",
4267
- "describe",
4268
- "desc",
4269
- "description",
4270
- "alias"
4271
- ];
4272
- opts = objFilter(opts, (k, v) => {
4273
- if (k === "type" && !["string", "number", "boolean"].includes(v))
4274
- return false;
4275
- return supportedOpts.includes(k);
4276
- });
4277
- const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
4278
- const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : {
4279
- array: [],
4280
- alias: {},
4281
- default: {},
4282
- demand: {}
4283
- };
4284
- objectKeys(parseOptions).forEach((pk) => {
4285
- const parseOption = parseOptions[pk];
4286
- if (Array.isArray(parseOption)) {
4287
- if (parseOption.indexOf(key) !== -1)
4288
- opts[pk] = true;
4202
+ recommendCommands(recommend = true) {
4203
+ argsert("[boolean]", [recommend], arguments.length);
4204
+ __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
4205
+ return this;
4206
+ }
4207
+ required(keys, max, msg) {
4208
+ return this.demand(keys, max, msg);
4209
+ }
4210
+ require(keys, max, msg) {
4211
+ return this.demand(keys, max, msg);
4212
+ }
4213
+ requiresArg(keys) {
4214
+ argsert("<array|string|object> [number]", [keys], arguments.length);
4215
+ if (typeof keys === "string" && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) {
4216
+ return this;
4289
4217
  } else {
4290
- if (parseOption[key] && !(pk in opts))
4291
- opts[pk] = parseOption[key];
4218
+ this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), "narg", keys, NaN);
4292
4219
  }
4293
- });
4294
- this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
4295
- return this.option(key, opts);
4296
- }
4297
- recommendCommands(recommend = true) {
4298
- argsert("[boolean]", [recommend], arguments.length);
4299
- __classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
4300
- return this;
4301
- }
4302
- required(keys, max, msg) {
4303
- return this.demand(keys, max, msg);
4304
- }
4305
- require(keys, max, msg) {
4306
- return this.demand(keys, max, msg);
4307
- }
4308
- requiresArg(keys) {
4309
- argsert("<array|string|object> [number]", [keys], arguments.length);
4310
- if (typeof keys === "string" && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) {
4311
4220
  return this;
4312
- } else {
4313
- this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), "narg", keys, NaN);
4314
4221
  }
4315
- return this;
4316
- }
4317
- showCompletionScript($0, cmd) {
4318
- argsert("[string] [string]", [$0, cmd], arguments.length);
4319
- $0 = $0 || this.$0;
4320
- __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion"));
4321
- return this;
4322
- }
4323
- showHelp(level) {
4324
- argsert("[string|function]", [level], arguments.length);
4325
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4326
- if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
4327
- if (!this.parsed) {
4328
- const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
4329
- if (isPromise(parse)) {
4330
- parse.then(() => {
4222
+ showCompletionScript($0, cmd) {
4223
+ argsert("[string] [string]", [$0, cmd], arguments.length);
4224
+ $0 = $0 || this.$0;
4225
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion"));
4226
+ return this;
4227
+ }
4228
+ showHelp(level) {
4229
+ argsert("[string|function]", [level], arguments.length);
4230
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4231
+ if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
4232
+ if (!this.parsed) {
4233
+ const parse = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), undefined, undefined, 0, true);
4234
+ if (isPromise(parse)) {
4235
+ parse.then(() => {
4236
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
4237
+ });
4238
+ return this;
4239
+ }
4240
+ }
4241
+ const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
4242
+ if (isPromise(builderResponse)) {
4243
+ builderResponse.then(() => {
4331
4244
  __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
4332
4245
  });
4333
4246
  return this;
4334
4247
  }
4335
4248
  }
4336
- const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
4337
- if (isPromise(builderResponse)) {
4338
- builderResponse.then(() => {
4339
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
4340
- });
4341
- return this;
4342
- }
4249
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
4250
+ return this;
4343
4251
  }
4344
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
4345
- return this;
4346
- }
4347
- scriptName(scriptName) {
4348
- this.customScriptName = true;
4349
- this.$0 = scriptName;
4350
- return this;
4351
- }
4352
- showHelpOnFail(enabled, message) {
4353
- argsert("[boolean|string] [string]", [enabled, message], arguments.length);
4354
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
4355
- return this;
4356
- }
4357
- showVersion(level) {
4358
- argsert("[string|function]", [level], arguments.length);
4359
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
4360
- return this;
4361
- }
4362
- skipValidation(keys) {
4363
- argsert("<array|string>", [keys], arguments.length);
4364
- this[kPopulateParserHintArray]("skipValidation", keys);
4365
- return this;
4366
- }
4367
- strict(enabled) {
4368
- argsert("[boolean]", [enabled], arguments.length);
4369
- __classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
4370
- return this;
4371
- }
4372
- strictCommands(enabled) {
4373
- argsert("[boolean]", [enabled], arguments.length);
4374
- __classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
4375
- return this;
4376
- }
4377
- strictOptions(enabled) {
4378
- argsert("[boolean]", [enabled], arguments.length);
4379
- __classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
4380
- return this;
4381
- }
4382
- string(keys) {
4383
- argsert("<array|string>", [keys], arguments.length);
4384
- this[kPopulateParserHintArray]("string", keys);
4385
- this[kTrackManuallySetKeys](keys);
4386
- return this;
4387
- }
4388
- terminalWidth() {
4389
- argsert([], 0);
4390
- return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
4391
- }
4392
- updateLocale(obj) {
4393
- return this.updateStrings(obj);
4394
- }
4395
- updateStrings(obj) {
4396
- argsert("<object>", [obj], arguments.length);
4397
- __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
4398
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
4399
- return this;
4400
- }
4401
- usage(msg, description, builder, handler) {
4402
- argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [msg, description, builder, handler], arguments.length);
4403
- if (description !== undefined) {
4404
- assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4405
- if ((msg || "").match(/^\$0( |$)/)) {
4406
- return this.command(msg, description, builder, handler);
4407
- } else {
4408
- throw new YError(".usage() description must start with $0 if being used as alias for .command()");
4409
- }
4410
- } else {
4411
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
4252
+ scriptName(scriptName) {
4253
+ this.customScriptName = true;
4254
+ this.$0 = scriptName;
4412
4255
  return this;
4413
4256
  }
4414
- }
4415
- usageConfiguration(config) {
4416
- argsert("<object>", [config], arguments.length);
4417
- __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
4418
- return this;
4419
- }
4420
- version(opt, msg, ver) {
4421
- const defaultVersionOpt = "version";
4422
- argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length);
4423
- if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
4424
- this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
4425
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(undefined);
4426
- __classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
4427
- }
4428
- if (arguments.length === 0) {
4429
- ver = this[kGuessVersion]();
4430
- opt = defaultVersionOpt;
4431
- } else if (arguments.length === 1) {
4432
- if (opt === false) {
4257
+ showHelpOnFail(enabled, message) {
4258
+ argsert("[boolean|string] [string]", [enabled, message], arguments.length);
4259
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
4260
+ return this;
4261
+ }
4262
+ showVersion(level) {
4263
+ argsert("[string|function]", [level], arguments.length);
4264
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
4265
+ return this;
4266
+ }
4267
+ skipValidation(keys) {
4268
+ argsert("<array|string>", [keys], arguments.length);
4269
+ this[kPopulateParserHintArray]("skipValidation", keys);
4270
+ return this;
4271
+ }
4272
+ strict(enabled) {
4273
+ argsert("[boolean]", [enabled], arguments.length);
4274
+ __classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
4275
+ return this;
4276
+ }
4277
+ strictCommands(enabled) {
4278
+ argsert("[boolean]", [enabled], arguments.length);
4279
+ __classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
4280
+ return this;
4281
+ }
4282
+ strictOptions(enabled) {
4283
+ argsert("[boolean]", [enabled], arguments.length);
4284
+ __classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
4285
+ return this;
4286
+ }
4287
+ string(keys) {
4288
+ argsert("<array|string>", [keys], arguments.length);
4289
+ this[kPopulateParserHintArray]("string", keys);
4290
+ this[kTrackManuallySetKeys](keys);
4291
+ return this;
4292
+ }
4293
+ terminalWidth() {
4294
+ argsert([], 0);
4295
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
4296
+ }
4297
+ updateLocale(obj) {
4298
+ return this.updateStrings(obj);
4299
+ }
4300
+ updateStrings(obj) {
4301
+ argsert("<object>", [obj], arguments.length);
4302
+ __classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
4303
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
4304
+ return this;
4305
+ }
4306
+ usage(msg, description, builder, handler) {
4307
+ argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [msg, description, builder, handler], arguments.length);
4308
+ if (description !== undefined) {
4309
+ assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4310
+ if ((msg || "").match(/^\$0( |$)/)) {
4311
+ return this.command(msg, description, builder, handler);
4312
+ } else {
4313
+ throw new YError(".usage() description must start with $0 if being used as alias for .command()");
4314
+ }
4315
+ } else {
4316
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
4433
4317
  return this;
4434
4318
  }
4435
- ver = opt;
4436
- opt = defaultVersionOpt;
4437
- } else if (arguments.length === 2) {
4438
- ver = msg;
4439
- msg = undefined;
4440
- }
4441
- __classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === "string" ? opt : defaultVersionOpt, "f");
4442
- msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show version number");
4443
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || undefined);
4444
- this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
4445
- this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
4446
- return this;
4447
- }
4448
- wrap(cols) {
4449
- argsert("<number|null|undefined>", [cols], arguments.length);
4450
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
4451
- return this;
4452
- }
4453
- [(_YargsInstance_command = new WeakMap, _YargsInstance_cwd = new WeakMap, _YargsInstance_context = new WeakMap, _YargsInstance_completion = new WeakMap, _YargsInstance_completionCommand = new WeakMap, _YargsInstance_defaultShowHiddenOpt = new WeakMap, _YargsInstance_exitError = new WeakMap, _YargsInstance_detectLocale = new WeakMap, _YargsInstance_emittedWarnings = new WeakMap, _YargsInstance_exitProcess = new WeakMap, _YargsInstance_frozens = new WeakMap, _YargsInstance_globalMiddleware = new WeakMap, _YargsInstance_groups = new WeakMap, _YargsInstance_hasOutput = new WeakMap, _YargsInstance_helpOpt = new WeakMap, _YargsInstance_isGlobalContext = new WeakMap, _YargsInstance_logger = new WeakMap, _YargsInstance_output = new WeakMap, _YargsInstance_options = new WeakMap, _YargsInstance_parentRequire = new WeakMap, _YargsInstance_parserConfig = new WeakMap, _YargsInstance_parseFn = new WeakMap, _YargsInstance_parseContext = new WeakMap, _YargsInstance_pkgs = new WeakMap, _YargsInstance_preservedGroups = new WeakMap, _YargsInstance_processArgs = new WeakMap, _YargsInstance_recommendCommands = new WeakMap, _YargsInstance_shim = new WeakMap, _YargsInstance_strict = new WeakMap, _YargsInstance_strictCommands = new WeakMap, _YargsInstance_strictOptions = new WeakMap, _YargsInstance_usage = new WeakMap, _YargsInstance_usageConfig = new WeakMap, _YargsInstance_versionOpt = new WeakMap, _YargsInstance_validation = new WeakMap, kCopyDoubleDash)](argv) {
4454
- if (!argv._ || !argv["--"])
4319
+ }
4320
+ usageConfiguration(config) {
4321
+ argsert("<object>", [config], arguments.length);
4322
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
4323
+ return this;
4324
+ }
4325
+ version(opt, msg, ver) {
4326
+ const defaultVersionOpt = "version";
4327
+ argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length);
4328
+ if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
4329
+ this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
4330
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(undefined);
4331
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
4332
+ }
4333
+ if (arguments.length === 0) {
4334
+ ver = this[kGuessVersion]();
4335
+ opt = defaultVersionOpt;
4336
+ } else if (arguments.length === 1) {
4337
+ if (opt === false) {
4338
+ return this;
4339
+ }
4340
+ ver = opt;
4341
+ opt = defaultVersionOpt;
4342
+ } else if (arguments.length === 2) {
4343
+ ver = msg;
4344
+ msg = undefined;
4345
+ }
4346
+ __classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === "string" ? opt : defaultVersionOpt, "f");
4347
+ msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show version number");
4348
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || undefined);
4349
+ this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
4350
+ this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
4351
+ return this;
4352
+ }
4353
+ wrap(cols) {
4354
+ argsert("<number|null|undefined>", [cols], arguments.length);
4355
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
4356
+ return this;
4357
+ }
4358
+ [(_YargsInstance_command = new WeakMap, _YargsInstance_cwd = new WeakMap, _YargsInstance_context = new WeakMap, _YargsInstance_completion = new WeakMap, _YargsInstance_completionCommand = new WeakMap, _YargsInstance_defaultShowHiddenOpt = new WeakMap, _YargsInstance_exitError = new WeakMap, _YargsInstance_detectLocale = new WeakMap, _YargsInstance_emittedWarnings = new WeakMap, _YargsInstance_exitProcess = new WeakMap, _YargsInstance_frozens = new WeakMap, _YargsInstance_globalMiddleware = new WeakMap, _YargsInstance_groups = new WeakMap, _YargsInstance_hasOutput = new WeakMap, _YargsInstance_helpOpt = new WeakMap, _YargsInstance_isGlobalContext = new WeakMap, _YargsInstance_logger = new WeakMap, _YargsInstance_output = new WeakMap, _YargsInstance_options = new WeakMap, _YargsInstance_parentRequire = new WeakMap, _YargsInstance_parserConfig = new WeakMap, _YargsInstance_parseFn = new WeakMap, _YargsInstance_parseContext = new WeakMap, _YargsInstance_pkgs = new WeakMap, _YargsInstance_preservedGroups = new WeakMap, _YargsInstance_processArgs = new WeakMap, _YargsInstance_recommendCommands = new WeakMap, _YargsInstance_shim = new WeakMap, _YargsInstance_strict = new WeakMap, _YargsInstance_strictCommands = new WeakMap, _YargsInstance_strictOptions = new WeakMap, _YargsInstance_usage = new WeakMap, _YargsInstance_usageConfig = new WeakMap, _YargsInstance_versionOpt = new WeakMap, _YargsInstance_validation = new WeakMap, kCopyDoubleDash)](argv) {
4359
+ if (!argv._ || !argv["--"])
4360
+ return argv;
4361
+ argv._.push.apply(argv._, argv["--"]);
4362
+ try {
4363
+ delete argv["--"];
4364
+ } catch (_err) {}
4455
4365
  return argv;
4456
- argv._.push.apply(argv._, argv["--"]);
4457
- try {
4458
- delete argv["--"];
4459
- } catch (_err) {}
4460
- return argv;
4461
- }
4462
- [kCreateLogger]() {
4463
- return {
4464
- log: (...args) => {
4465
- if (!this[kHasParseCallback]())
4466
- console.log(...args);
4467
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4468
- if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
4469
- __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + `
4366
+ }
4367
+ [kCreateLogger]() {
4368
+ return {
4369
+ log: (...args) => {
4370
+ if (!this[kHasParseCallback]())
4371
+ console.log(...args);
4372
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4373
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
4374
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + `
4470
4375
  `, "f");
4471
- __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
4472
- },
4473
- error: (...args) => {
4474
- if (!this[kHasParseCallback]())
4475
- console.error(...args);
4476
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4477
- if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
4478
- __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + `
4376
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
4377
+ },
4378
+ error: (...args) => {
4379
+ if (!this[kHasParseCallback]())
4380
+ console.error(...args);
4381
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4382
+ if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
4383
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + `
4479
4384
  `, "f");
4480
- __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
4385
+ __classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
4386
+ }
4387
+ };
4388
+ }
4389
+ [kDeleteFromParserHintObject](optionKey) {
4390
+ objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
4391
+ if (((key) => key === "configObjects")(hintKey))
4392
+ return;
4393
+ const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
4394
+ if (Array.isArray(hint)) {
4395
+ if (hint.includes(optionKey))
4396
+ hint.splice(hint.indexOf(optionKey), 1);
4397
+ } else if (typeof hint === "object") {
4398
+ delete hint[optionKey];
4399
+ }
4400
+ });
4401
+ delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
4402
+ }
4403
+ [kEmitWarning](warning, type, deduplicationId) {
4404
+ if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
4405
+ __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
4406
+ __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
4407
+ }
4408
+ }
4409
+ [kFreeze]() {
4410
+ __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
4411
+ options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
4412
+ configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
4413
+ exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
4414
+ groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
4415
+ strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
4416
+ strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
4417
+ strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
4418
+ completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
4419
+ output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
4420
+ exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
4421
+ hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
4422
+ parsed: this.parsed,
4423
+ parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
4424
+ parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")
4425
+ });
4426
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
4427
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
4428
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
4429
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
4430
+ }
4431
+ [kGetDollarZero]() {
4432
+ let $0 = "";
4433
+ let default$0;
4434
+ if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) {
4435
+ default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2);
4436
+ } else {
4437
+ default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
4481
4438
  }
4482
- };
4483
- }
4484
- [kDeleteFromParserHintObject](optionKey) {
4485
- objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
4486
- if (((key) => key === "configObjects")(hintKey))
4487
- return;
4488
- const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
4489
- if (Array.isArray(hint)) {
4490
- if (hint.includes(optionKey))
4491
- hint.splice(hint.indexOf(optionKey), 1);
4492
- } else if (typeof hint === "object") {
4493
- delete hint[optionKey];
4439
+ $0 = default$0.map((x) => {
4440
+ const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
4441
+ return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
4442
+ }).join(" ").trim();
4443
+ if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_") && __classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_")) {
4444
+ $0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_").replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, "");
4494
4445
  }
4495
- });
4496
- delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
4497
- }
4498
- [kEmitWarning](warning, type, deduplicationId) {
4499
- if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
4500
- __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
4501
- __classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
4502
- }
4503
- }
4504
- [kFreeze]() {
4505
- __classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
4506
- options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
4507
- configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
4508
- exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
4509
- groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
4510
- strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
4511
- strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
4512
- strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
4513
- completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
4514
- output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
4515
- exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
4516
- hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
4517
- parsed: this.parsed,
4518
- parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
4519
- parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")
4520
- });
4521
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
4522
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
4523
- __classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
4524
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
4525
- }
4526
- [kGetDollarZero]() {
4527
- let $0 = "";
4528
- let default$0;
4529
- if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) {
4530
- default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2);
4531
- } else {
4532
- default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
4446
+ return $0;
4533
4447
  }
4534
- $0 = default$0.map((x) => {
4535
- const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
4536
- return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
4537
- }).join(" ").trim();
4538
- if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_") && __classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_")) {
4539
- $0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_").replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, "");
4448
+ [kGetParserConfiguration]() {
4449
+ return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
4540
4450
  }
4541
- return $0;
4542
- }
4543
- [kGetParserConfiguration]() {
4544
- return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
4545
- }
4546
- [kGetUsageConfiguration]() {
4547
- return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
4548
- }
4549
- [kGuessLocale]() {
4550
- if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
4551
- return;
4552
- const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_ALL") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_MESSAGES") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANG") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANGUAGE") || "en_US";
4553
- this.locale(locale.replace(/[.:].*/, ""));
4554
- }
4555
- [kGuessVersion]() {
4556
- const obj = this[kPkgUp]();
4557
- return obj.version || "unknown";
4558
- }
4559
- [kParsePositionalNumbers](argv) {
4560
- const args = argv["--"] ? argv["--"] : argv._;
4561
- for (let i = 0, arg;(arg = args[i]) !== undefined; i++) {
4562
- if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) && Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) {
4563
- args[i] = Number(arg);
4564
- }
4451
+ [kGetUsageConfiguration]() {
4452
+ return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
4565
4453
  }
4566
- return argv;
4567
- }
4568
- [kPkgUp](rootPath) {
4569
- const npath = rootPath || "*";
4570
- if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath])
4571
- return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
4572
- let obj = {};
4573
- try {
4574
- let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
4575
- if (!rootPath && __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) {
4576
- startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
4454
+ [kGuessLocale]() {
4455
+ if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
4456
+ return;
4457
+ const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_ALL") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_MESSAGES") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANG") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANGUAGE") || "en_US";
4458
+ this.locale(locale.replace(/[.:].*/, ""));
4459
+ }
4460
+ [kGuessVersion]() {
4461
+ const obj = this[kPkgUp]();
4462
+ return obj.version || "unknown";
4463
+ }
4464
+ [kParsePositionalNumbers](argv) {
4465
+ const args = argv["--"] ? argv["--"] : argv._;
4466
+ for (let i = 0, arg;(arg = args[i]) !== undefined; i++) {
4467
+ if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) && Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) {
4468
+ args[i] = Number(arg);
4469
+ }
4577
4470
  }
4578
- const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
4579
- if (names.includes("package.json")) {
4580
- return "package.json";
4581
- } else {
4582
- return;
4471
+ return argv;
4472
+ }
4473
+ [kPkgUp](rootPath) {
4474
+ const npath = rootPath || "*";
4475
+ if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath])
4476
+ return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
4477
+ let obj = {};
4478
+ try {
4479
+ let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
4480
+ if (!rootPath && __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) {
4481
+ startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
4583
4482
  }
4483
+ const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
4484
+ if (names.includes("package.json")) {
4485
+ return "package.json";
4486
+ } else {
4487
+ return;
4488
+ }
4489
+ });
4490
+ assertNotStrictEqual(pkgJsonPath, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4491
+ obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, "utf8"));
4492
+ } catch (_noop) {}
4493
+ __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
4494
+ return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
4495
+ }
4496
+ [kPopulateParserHintArray](type, keys) {
4497
+ keys = [].concat(keys);
4498
+ keys.forEach((key) => {
4499
+ key = this[kSanitizeKey](key);
4500
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
4584
4501
  });
4585
- assertNotStrictEqual(pkgJsonPath, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4586
- obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, "utf8"));
4587
- } catch (_noop) {}
4588
- __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
4589
- return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
4590
- }
4591
- [kPopulateParserHintArray](type, keys) {
4592
- keys = [].concat(keys);
4593
- keys.forEach((key) => {
4594
- key = this[kSanitizeKey](key);
4595
- __classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
4596
- });
4597
- }
4598
- [kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
4599
- this[kPopulateParserHintDictionary](builder, type, key, value, (type2, key2, value2) => {
4600
- __classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] = value2;
4601
- });
4602
- }
4603
- [kPopulateParserHintArrayDictionary](builder, type, key, value) {
4604
- this[kPopulateParserHintDictionary](builder, type, key, value, (type2, key2, value2) => {
4605
- __classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] || []).concat(value2);
4606
- });
4607
- }
4608
- [kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
4609
- if (Array.isArray(key)) {
4610
- key.forEach((k) => {
4611
- builder(k, value);
4502
+ }
4503
+ [kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
4504
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type2, key2, value2) => {
4505
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] = value2;
4612
4506
  });
4613
- } else if (((key2) => typeof key2 === "object")(key)) {
4614
- for (const k of objectKeys(key)) {
4615
- builder(k, key[k]);
4507
+ }
4508
+ [kPopulateParserHintArrayDictionary](builder, type, key, value) {
4509
+ this[kPopulateParserHintDictionary](builder, type, key, value, (type2, key2, value2) => {
4510
+ __classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] || []).concat(value2);
4511
+ });
4512
+ }
4513
+ [kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
4514
+ if (Array.isArray(key)) {
4515
+ key.forEach((k) => {
4516
+ builder(k, value);
4517
+ });
4518
+ } else if (((key2) => typeof key2 === "object")(key)) {
4519
+ for (const k of objectKeys(key)) {
4520
+ builder(k, key[k]);
4521
+ }
4522
+ } else {
4523
+ singleKeyHandler(type, this[kSanitizeKey](key), value);
4616
4524
  }
4617
- } else {
4618
- singleKeyHandler(type, this[kSanitizeKey](key), value);
4619
4525
  }
4620
- }
4621
- [kSanitizeKey](key) {
4622
- if (key === "__proto__")
4623
- return "___proto___";
4624
- return key;
4625
- }
4626
- [kSetKey](key, set) {
4627
- this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set);
4628
- return this;
4629
- }
4630
- [kUnfreeze]() {
4631
- var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4632
- const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
4633
- assertNotStrictEqual(frozen, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4634
- let configObjects;
4635
- _a2 = this, _b2 = this, _c2 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
4636
- options: { set value(_o) {
4637
- __classPrivateFieldSet(_a2, _YargsInstance_options, _o, "f");
4638
- } }.value,
4639
- configObjects,
4640
- exitProcess: { set value(_o) {
4641
- __classPrivateFieldSet(_b2, _YargsInstance_exitProcess, _o, "f");
4642
- } }.value,
4643
- groups: { set value(_o) {
4644
- __classPrivateFieldSet(_c2, _YargsInstance_groups, _o, "f");
4645
- } }.value,
4646
- output: { set value(_o) {
4647
- __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
4648
- } }.value,
4649
- exitError: { set value(_o) {
4650
- __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f");
4651
- } }.value,
4652
- hasOutput: { set value(_o) {
4653
- __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f");
4654
- } }.value,
4655
- parsed: this.parsed,
4656
- strict: { set value(_o) {
4657
- __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f");
4658
- } }.value,
4659
- strictCommands: { set value(_o) {
4660
- __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f");
4661
- } }.value,
4662
- strictOptions: { set value(_o) {
4663
- __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f");
4664
- } }.value,
4665
- completionCommand: { set value(_o) {
4666
- __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f");
4667
- } }.value,
4668
- parseFn: { set value(_o) {
4669
- __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f");
4670
- } }.value,
4671
- parseContext: { set value(_o) {
4672
- __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f");
4673
- } }.value
4674
- } = frozen;
4675
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
4676
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
4677
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
4678
- __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
4679
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
4680
- }
4681
- [kValidateAsync](validation2, argv) {
4682
- return maybeAsyncResult(argv, (result) => {
4683
- validation2(result);
4684
- return result;
4685
- });
4686
- }
4687
- getInternalMethods() {
4688
- return {
4689
- getCommandInstance: this[kGetCommandInstance].bind(this),
4690
- getContext: this[kGetContext].bind(this),
4691
- getHasOutput: this[kGetHasOutput].bind(this),
4692
- getLoggerInstance: this[kGetLoggerInstance].bind(this),
4693
- getParseContext: this[kGetParseContext].bind(this),
4694
- getParserConfiguration: this[kGetParserConfiguration].bind(this),
4695
- getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
4696
- getUsageInstance: this[kGetUsageInstance].bind(this),
4697
- getValidationInstance: this[kGetValidationInstance].bind(this),
4698
- hasParseCallback: this[kHasParseCallback].bind(this),
4699
- isGlobalContext: this[kIsGlobalContext].bind(this),
4700
- postProcess: this[kPostProcess].bind(this),
4701
- reset: this[kReset].bind(this),
4702
- runValidation: this[kRunValidation].bind(this),
4703
- runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
4704
- setHasOutput: this[kSetHasOutput].bind(this)
4705
- };
4706
- }
4707
- [kGetCommandInstance]() {
4708
- return __classPrivateFieldGet(this, _YargsInstance_command, "f");
4709
- }
4710
- [kGetContext]() {
4711
- return __classPrivateFieldGet(this, _YargsInstance_context, "f");
4712
- }
4713
- [kGetHasOutput]() {
4714
- return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
4715
- }
4716
- [kGetLoggerInstance]() {
4717
- return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
4718
- }
4719
- [kGetParseContext]() {
4720
- return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
4721
- }
4722
- [kGetUsageInstance]() {
4723
- return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
4724
- }
4725
- [kGetValidationInstance]() {
4726
- return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
4727
- }
4728
- [kHasParseCallback]() {
4729
- return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
4730
- }
4731
- [kIsGlobalContext]() {
4732
- return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
4733
- }
4734
- [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
4735
- if (calledFromCommand)
4736
- return argv;
4737
- if (isPromise(argv))
4738
- return argv;
4739
- if (!populateDoubleDash) {
4740
- argv = this[kCopyDoubleDash](argv);
4741
- }
4742
- const parsePositionalNumbers = this[kGetParserConfiguration]()["parse-positional-numbers"] || this[kGetParserConfiguration]()["parse-positional-numbers"] === undefined;
4743
- if (parsePositionalNumbers) {
4744
- argv = this[kParsePositionalNumbers](argv);
4745
- }
4746
- if (runGlobalMiddleware) {
4747
- argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4748
- }
4749
- return argv;
4750
- }
4751
- [kReset](aliases = {}) {
4752
- __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
4753
- const tmpOptions = {};
4754
- tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
4755
- tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
4756
- const localLookup = {};
4757
- tmpOptions.local.forEach((l) => {
4758
- localLookup[l] = true;
4759
- (aliases[l] || []).forEach((a) => {
4760
- localLookup[a] = true;
4526
+ [kSanitizeKey](key) {
4527
+ if (key === "__proto__")
4528
+ return "___proto___";
4529
+ return key;
4530
+ }
4531
+ [kSetKey](key, set) {
4532
+ this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set);
4533
+ return this;
4534
+ }
4535
+ [kUnfreeze]() {
4536
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4537
+ const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
4538
+ assertNotStrictEqual(frozen, undefined, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
4539
+ let configObjects;
4540
+ _a2 = this, _b2 = this, _c2 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
4541
+ options: { set value(_o) {
4542
+ __classPrivateFieldSet(_a2, _YargsInstance_options, _o, "f");
4543
+ } }.value,
4544
+ configObjects,
4545
+ exitProcess: { set value(_o) {
4546
+ __classPrivateFieldSet(_b2, _YargsInstance_exitProcess, _o, "f");
4547
+ } }.value,
4548
+ groups: { set value(_o) {
4549
+ __classPrivateFieldSet(_c2, _YargsInstance_groups, _o, "f");
4550
+ } }.value,
4551
+ output: { set value(_o) {
4552
+ __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
4553
+ } }.value,
4554
+ exitError: { set value(_o) {
4555
+ __classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f");
4556
+ } }.value,
4557
+ hasOutput: { set value(_o) {
4558
+ __classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f");
4559
+ } }.value,
4560
+ parsed: this.parsed,
4561
+ strict: { set value(_o) {
4562
+ __classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f");
4563
+ } }.value,
4564
+ strictCommands: { set value(_o) {
4565
+ __classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f");
4566
+ } }.value,
4567
+ strictOptions: { set value(_o) {
4568
+ __classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f");
4569
+ } }.value,
4570
+ completionCommand: { set value(_o) {
4571
+ __classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f");
4572
+ } }.value,
4573
+ parseFn: { set value(_o) {
4574
+ __classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f");
4575
+ } }.value,
4576
+ parseContext: { set value(_o) {
4577
+ __classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f");
4578
+ } }.value
4579
+ } = frozen;
4580
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
4581
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
4582
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
4583
+ __classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
4584
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
4585
+ }
4586
+ [kValidateAsync](validation2, argv) {
4587
+ return maybeAsyncResult(argv, (result) => {
4588
+ validation2(result);
4589
+ return result;
4761
4590
  });
4762
- });
4763
- Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
4764
- const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key) => !(key in localLookup));
4765
- if (keys.length > 0) {
4766
- acc[groupName] = keys;
4591
+ }
4592
+ getInternalMethods() {
4593
+ return {
4594
+ getCommandInstance: this[kGetCommandInstance].bind(this),
4595
+ getContext: this[kGetContext].bind(this),
4596
+ getHasOutput: this[kGetHasOutput].bind(this),
4597
+ getLoggerInstance: this[kGetLoggerInstance].bind(this),
4598
+ getParseContext: this[kGetParseContext].bind(this),
4599
+ getParserConfiguration: this[kGetParserConfiguration].bind(this),
4600
+ getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
4601
+ getUsageInstance: this[kGetUsageInstance].bind(this),
4602
+ getValidationInstance: this[kGetValidationInstance].bind(this),
4603
+ hasParseCallback: this[kHasParseCallback].bind(this),
4604
+ isGlobalContext: this[kIsGlobalContext].bind(this),
4605
+ postProcess: this[kPostProcess].bind(this),
4606
+ reset: this[kReset].bind(this),
4607
+ runValidation: this[kRunValidation].bind(this),
4608
+ runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
4609
+ setHasOutput: this[kSetHasOutput].bind(this)
4610
+ };
4611
+ }
4612
+ [kGetCommandInstance]() {
4613
+ return __classPrivateFieldGet(this, _YargsInstance_command, "f");
4614
+ }
4615
+ [kGetContext]() {
4616
+ return __classPrivateFieldGet(this, _YargsInstance_context, "f");
4617
+ }
4618
+ [kGetHasOutput]() {
4619
+ return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
4620
+ }
4621
+ [kGetLoggerInstance]() {
4622
+ return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
4623
+ }
4624
+ [kGetParseContext]() {
4625
+ return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
4626
+ }
4627
+ [kGetUsageInstance]() {
4628
+ return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
4629
+ }
4630
+ [kGetValidationInstance]() {
4631
+ return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
4632
+ }
4633
+ [kHasParseCallback]() {
4634
+ return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
4635
+ }
4636
+ [kIsGlobalContext]() {
4637
+ return __classPrivateFieldGet(this, _YargsInstance_isGlobalContext, "f");
4638
+ }
4639
+ [kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
4640
+ if (calledFromCommand)
4641
+ return argv;
4642
+ if (isPromise(argv))
4643
+ return argv;
4644
+ if (!populateDoubleDash) {
4645
+ argv = this[kCopyDoubleDash](argv);
4767
4646
  }
4768
- return acc;
4769
- }, {}));
4770
- __classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
4771
- const arrayOptions = [
4772
- "array",
4773
- "boolean",
4774
- "string",
4775
- "skipValidation",
4776
- "count",
4777
- "normalize",
4778
- "number",
4779
- "hiddenOptions"
4780
- ];
4781
- const objectOptions = [
4782
- "narg",
4783
- "key",
4784
- "alias",
4785
- "default",
4786
- "defaultDescription",
4787
- "config",
4788
- "choices",
4789
- "demandedOptions",
4790
- "demandedCommands",
4791
- "deprecatedOptions"
4792
- ];
4793
- arrayOptions.forEach((k) => {
4794
- tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k2) => !localLookup[k2]);
4795
- });
4796
- objectOptions.forEach((k) => {
4797
- tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k2) => !localLookup[k2]);
4798
- });
4799
- tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
4800
- __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
4801
- __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4802
- __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f") ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup) : validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4803
- __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f") ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset() : command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4804
- if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f"))
4805
- __classPrivateFieldSet(this, _YargsInstance_completion, completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4806
- __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
4807
- __classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
4808
- __classPrivateFieldSet(this, _YargsInstance_output, "", "f");
4809
- __classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
4810
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
4811
- this.parsed = false;
4812
- return this;
4813
- }
4814
- [kRebase](base, dir) {
4815
- return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
4816
- }
4817
- [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
4818
- let skipValidation = !!calledFromCommand || helpOnly;
4819
- args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
4820
- __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
4821
- __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
4822
- const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"];
4823
- const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
4824
- "populate--": true
4825
- });
4826
- const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
4827
- configuration: { "parse-positional-numbers": false, ...config }
4828
- }));
4829
- const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
4830
- let argvPromise = undefined;
4831
- const aliases = parsed.aliases;
4832
- let helpOptSet = false;
4833
- let versionOptSet = false;
4834
- Object.keys(argv).forEach((key) => {
4835
- if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) {
4836
- helpOptSet = true;
4837
- } else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) {
4838
- versionOptSet = true;
4647
+ const parsePositionalNumbers = this[kGetParserConfiguration]()["parse-positional-numbers"] || this[kGetParserConfiguration]()["parse-positional-numbers"] === undefined;
4648
+ if (parsePositionalNumbers) {
4649
+ argv = this[kParsePositionalNumbers](argv);
4839
4650
  }
4840
- });
4841
- argv.$0 = this.$0;
4842
- this.parsed = parsed;
4843
- if (commandIndex === 0) {
4844
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
4845
- }
4846
- try {
4847
- this[kGuessLocale]();
4848
- if (shortCircuit) {
4849
- return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
4651
+ if (runGlobalMiddleware) {
4652
+ argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4850
4653
  }
4851
- if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
4852
- const helpCmds = [__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k) => k.length > 1);
4853
- if (helpCmds.includes("" + argv._[argv._.length - 1])) {
4854
- argv._.pop();
4654
+ return argv;
4655
+ }
4656
+ [kReset](aliases = {}) {
4657
+ __classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
4658
+ const tmpOptions = {};
4659
+ tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
4660
+ tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
4661
+ const localLookup = {};
4662
+ tmpOptions.local.forEach((l) => {
4663
+ localLookup[l] = true;
4664
+ (aliases[l] || []).forEach((a) => {
4665
+ localLookup[a] = true;
4666
+ });
4667
+ });
4668
+ Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
4669
+ const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key) => !(key in localLookup));
4670
+ if (keys.length > 0) {
4671
+ acc[groupName] = keys;
4672
+ }
4673
+ return acc;
4674
+ }, {}));
4675
+ __classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
4676
+ const arrayOptions = [
4677
+ "array",
4678
+ "boolean",
4679
+ "string",
4680
+ "skipValidation",
4681
+ "count",
4682
+ "normalize",
4683
+ "number",
4684
+ "hiddenOptions"
4685
+ ];
4686
+ const objectOptions = [
4687
+ "narg",
4688
+ "key",
4689
+ "alias",
4690
+ "default",
4691
+ "defaultDescription",
4692
+ "config",
4693
+ "choices",
4694
+ "demandedOptions",
4695
+ "demandedCommands",
4696
+ "deprecatedOptions"
4697
+ ];
4698
+ arrayOptions.forEach((k) => {
4699
+ tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k2) => !localLookup[k2]);
4700
+ });
4701
+ objectOptions.forEach((k) => {
4702
+ tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k2) => !localLookup[k2]);
4703
+ });
4704
+ tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
4705
+ __classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
4706
+ __classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4707
+ __classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f") ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup) : validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4708
+ __classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f") ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset() : command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4709
+ if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f"))
4710
+ __classPrivateFieldSet(this, _YargsInstance_completion, completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
4711
+ __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
4712
+ __classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
4713
+ __classPrivateFieldSet(this, _YargsInstance_output, "", "f");
4714
+ __classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
4715
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
4716
+ this.parsed = false;
4717
+ return this;
4718
+ }
4719
+ [kRebase](base, dir) {
4720
+ return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
4721
+ }
4722
+ [kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
4723
+ let skipValidation = !!calledFromCommand || helpOnly;
4724
+ args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
4725
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
4726
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
4727
+ const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"];
4728
+ const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
4729
+ "populate--": true
4730
+ });
4731
+ const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
4732
+ configuration: { "parse-positional-numbers": false, ...config }
4733
+ }));
4734
+ const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
4735
+ let argvPromise = undefined;
4736
+ const aliases = parsed.aliases;
4737
+ let helpOptSet = false;
4738
+ let versionOptSet = false;
4739
+ Object.keys(argv).forEach((key) => {
4740
+ if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) {
4855
4741
  helpOptSet = true;
4742
+ } else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) {
4743
+ versionOptSet = true;
4856
4744
  }
4745
+ });
4746
+ argv.$0 = this.$0;
4747
+ this.parsed = parsed;
4748
+ if (commandIndex === 0) {
4749
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
4857
4750
  }
4858
- __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
4859
- const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
4860
- const requestCompletions = __classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey in argv;
4861
- const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
4862
- if (argv._.length) {
4863
- if (handlerKeys.length) {
4864
- let firstUnknownCommand;
4865
- for (let i = commandIndex || 0, cmd;argv._[i] !== undefined; i++) {
4866
- cmd = String(argv._[i]);
4867
- if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4868
- const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
4869
- return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4870
- } else if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4871
- firstUnknownCommand = cmd;
4872
- break;
4751
+ try {
4752
+ this[kGuessLocale]();
4753
+ if (shortCircuit) {
4754
+ return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
4755
+ }
4756
+ if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
4757
+ const helpCmds = [__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k) => k.length > 1);
4758
+ if (helpCmds.includes("" + argv._[argv._.length - 1])) {
4759
+ argv._.pop();
4760
+ helpOptSet = true;
4761
+ }
4762
+ }
4763
+ __classPrivateFieldSet(this, _YargsInstance_isGlobalContext, false, "f");
4764
+ const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
4765
+ const requestCompletions = __classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey in argv;
4766
+ const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
4767
+ if (argv._.length) {
4768
+ if (handlerKeys.length) {
4769
+ let firstUnknownCommand;
4770
+ for (let i = commandIndex || 0, cmd;argv._[i] !== undefined; i++) {
4771
+ cmd = String(argv._[i]);
4772
+ if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4773
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
4774
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4775
+ } else if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
4776
+ firstUnknownCommand = cmd;
4777
+ break;
4778
+ }
4779
+ }
4780
+ if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) {
4781
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
4873
4782
  }
4874
4783
  }
4875
- if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) {
4876
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
4784
+ if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) {
4785
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4786
+ setBlocking(true);
4787
+ this.showCompletionScript();
4788
+ this.exit(0);
4877
4789
  }
4878
4790
  }
4879
- if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) {
4880
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4881
- setBlocking(true);
4882
- this.showCompletionScript();
4883
- this.exit(0);
4791
+ if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
4792
+ const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
4793
+ return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4884
4794
  }
4885
- }
4886
- if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
4887
- const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
4888
- return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
4889
- }
4890
- if (requestCompletions) {
4891
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4892
- setBlocking(true);
4893
- args = [].concat(args);
4894
- const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
4895
- __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
4896
- if (err)
4897
- throw new YError(err.message);
4898
- (completions || []).forEach((completion2) => {
4899
- __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion2);
4900
- });
4901
- this.exit(0);
4902
- });
4903
- return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
4904
- }
4905
- if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
4906
- if (helpOptSet) {
4795
+ if (requestCompletions) {
4907
4796
  if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4908
4797
  setBlocking(true);
4909
- skipValidation = true;
4910
- this.showHelp("log");
4911
- this.exit(0);
4912
- } else if (versionOptSet) {
4913
- if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4914
- setBlocking(true);
4915
- skipValidation = true;
4916
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion("log");
4917
- this.exit(0);
4798
+ args = [].concat(args);
4799
+ const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
4800
+ __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
4801
+ if (err)
4802
+ throw new YError(err.message);
4803
+ (completions || []).forEach((completion2) => {
4804
+ __classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion2);
4805
+ });
4806
+ this.exit(0);
4807
+ });
4808
+ return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
4918
4809
  }
4919
- }
4920
- if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) {
4921
- skipValidation = Object.keys(argv).some((key) => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true);
4922
- }
4923
- if (!skipValidation) {
4924
- if (parsed.error)
4925
- throw new YError(parsed.error.message);
4926
- if (!requestCompletions) {
4927
- const validation2 = this[kRunValidation](aliases, {}, parsed.error);
4928
- if (!calledFromCommand) {
4929
- argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
4810
+ if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
4811
+ if (helpOptSet) {
4812
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4813
+ setBlocking(true);
4814
+ skipValidation = true;
4815
+ this.showHelp("log");
4816
+ this.exit(0);
4817
+ } else if (versionOptSet) {
4818
+ if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
4819
+ setBlocking(true);
4820
+ skipValidation = true;
4821
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion("log");
4822
+ this.exit(0);
4930
4823
  }
4931
- argvPromise = this[kValidateAsync](validation2, argvPromise !== null && argvPromise !== undefined ? argvPromise : argv);
4932
- if (isPromise(argvPromise) && !calledFromCommand) {
4933
- argvPromise = argvPromise.then(() => {
4934
- return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4935
- });
4824
+ }
4825
+ if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) {
4826
+ skipValidation = Object.keys(argv).some((key) => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true);
4827
+ }
4828
+ if (!skipValidation) {
4829
+ if (parsed.error)
4830
+ throw new YError(parsed.error.message);
4831
+ if (!requestCompletions) {
4832
+ const validation2 = this[kRunValidation](aliases, {}, parsed.error);
4833
+ if (!calledFromCommand) {
4834
+ argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
4835
+ }
4836
+ argvPromise = this[kValidateAsync](validation2, argvPromise !== null && argvPromise !== undefined ? argvPromise : argv);
4837
+ if (isPromise(argvPromise) && !calledFromCommand) {
4838
+ argvPromise = argvPromise.then(() => {
4839
+ return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
4840
+ });
4841
+ }
4936
4842
  }
4937
4843
  }
4938
- }
4939
- } catch (err) {
4940
- if (err instanceof YError)
4941
- __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
4942
- else
4943
- throw err;
4844
+ } catch (err) {
4845
+ if (err instanceof YError)
4846
+ __classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
4847
+ else
4848
+ throw err;
4849
+ }
4850
+ return this[kPostProcess](argvPromise !== null && argvPromise !== undefined ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
4851
+ }
4852
+ [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
4853
+ const demandedOptions = { ...this.getDemandedOptions() };
4854
+ return (argv) => {
4855
+ if (parseErrors)
4856
+ throw new YError(parseErrors.message);
4857
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
4858
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
4859
+ let failedStrictCommands = false;
4860
+ if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) {
4861
+ failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
4862
+ }
4863
+ if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) {
4864
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
4865
+ } else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) {
4866
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
4867
+ }
4868
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
4869
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
4870
+ __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
4871
+ };
4944
4872
  }
4945
- return this[kPostProcess](argvPromise !== null && argvPromise !== undefined ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
4946
- }
4947
- [kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
4948
- const demandedOptions = { ...this.getDemandedOptions() };
4949
- return (argv) => {
4950
- if (parseErrors)
4951
- throw new YError(parseErrors.message);
4952
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
4953
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
4954
- let failedStrictCommands = false;
4955
- if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) {
4956
- failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
4957
- }
4958
- if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) {
4959
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
4960
- } else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) {
4961
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
4962
- }
4963
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
4964
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
4965
- __classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
4966
- };
4967
- }
4968
- [kSetHasOutput]() {
4969
- __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4970
- }
4971
- [kTrackManuallySetKeys](keys) {
4972
- if (typeof keys === "string") {
4973
- __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
4974
- } else {
4975
- for (const k of keys) {
4976
- __classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
4873
+ [kSetHasOutput]() {
4874
+ __classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
4875
+ }
4876
+ [kTrackManuallySetKeys](keys) {
4877
+ if (typeof keys === "string") {
4878
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
4879
+ } else {
4880
+ for (const k of keys) {
4881
+ __classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
4882
+ }
4977
4883
  }
4978
4884
  }
4979
- }
4980
- }
4981
- function isYargsInstance(y) {
4982
- return !!y && typeof y.getInternalMethods === "function";
4983
- }
4984
-
4985
- // node_modules/yargs/index.mjs
4986
- var Yargs = YargsFactory(esm_default);
4987
- var yargs_default = Yargs;
4988
-
4989
- // ts/buildFbiProxy.ts
4990
- import { existsSync } from "fs";
4991
- import { chmod } from "fs/promises";
4992
- import path from "path";
4885
+ };
4886
+ });
4993
4887
 
4994
4888
  // ts/getProxyFilename.ts
4995
4889
  function getFbiProxyFilename() {
@@ -5004,9 +4898,6 @@ function getFbiProxyFilename() {
5004
4898
  }[process.platform + "-" + process.arch] || "fbi-proxy-linux-x64";
5005
4899
  }
5006
4900
 
5007
- // ts/dSpawn.ts
5008
- import { spawn } from "child_process";
5009
-
5010
4901
  // node_modules/from-node-stream/dist/index.js
5011
4902
  function fromReadable(i) {
5012
4903
  if (i instanceof ReadableStream)
@@ -5020,6 +4911,7 @@ function fromReadable(i) {
5020
4911
  cancel: (reason) => (i.destroy?.(reason), undefined)
5021
4912
  });
5022
4913
  }
4914
+ var init_dist = () => {};
5023
4915
 
5024
4916
  // node_modules/tsa-composer/dist/index.js
5025
4917
  function tsaComposer(slotParser, compose = (...zipped) => zipped.join("")) {
@@ -5032,8 +4924,10 @@ function tsaComposer(slotParser, compose = (...zipped) => zipped.join("")) {
5032
4924
  }, []));
5033
4925
  };
5034
4926
  }
4927
+ var init_dist2 = () => {};
5035
4928
 
5036
4929
  // ts/dSpawn.ts
4930
+ import { spawn } from "child_process";
5037
4931
  var dSpawn = ({ cwd = process.cwd(), env: env2 = process.env } = {}) => tsaComposer((slot) => typeof slot === "string" ? {
5038
4932
  raw: String(slot)
5039
4933
  } : slot, (...slots) => {
@@ -5102,13 +4996,482 @@ var dSpawn = ({ cwd = process.cwd(), env: env2 = process.env } = {}) => tsaCompo
5102
4996
  }
5103
4997
  });
5104
4998
  }
4999
+ }), $;
5000
+ var init_dSpawn = __esm(() => {
5001
+ init_dist();
5002
+ init_dist2();
5003
+ $ = Object.assign(dSpawn(), {
5004
+ opt: dSpawn,
5005
+ cwd: (path) => dSpawn({ cwd: path })
5006
+ });
5007
+ });
5008
+
5009
+ // node_modules/yargs/index.mjs
5010
+ var Yargs2, yargs_default2;
5011
+ var init_yargs = __esm(() => {
5012
+ init_esm();
5013
+ init_yargs_factory();
5014
+ Yargs2 = YargsFactory(esm_default);
5015
+ yargs_default2 = Yargs2;
5016
+ });
5017
+
5018
+ // ts/buildFbiProxy.ts
5019
+ import { existsSync as existsSync5 } from "fs";
5020
+ import { chmod as chmod5 } from "fs/promises";
5021
+ import path3 from "path";
5022
+ async function getFbiProxyBinary2({ rebuild = false, originalCwd = "" } = {}) {
5023
+ const isWin = process.platform === "win32";
5024
+ const binaryName = getFbiProxyFilename();
5025
+ const binarySuffix = isWin ? ".exe" : "";
5026
+ if (!rebuild && originalCwd) {
5027
+ const localBuilt = path3.join(originalCwd, `target/release/fbi-proxy${binarySuffix}`);
5028
+ if (existsSync5(localBuilt)) {
5029
+ console.log(`Using local build: ${localBuilt}`);
5030
+ await chmod5(localBuilt, 493).catch(() => {});
5031
+ return localBuilt;
5032
+ }
5033
+ }
5034
+ const dockerBinary = "/app/bin/fbi-proxy";
5035
+ if (!rebuild && existsSync5(dockerBinary)) {
5036
+ return dockerBinary;
5037
+ }
5038
+ const release = "./release/" + binaryName;
5039
+ const built = `./target/release/fbi-proxy${binarySuffix}`;
5040
+ if (!rebuild && existsSync5(built)) {
5041
+ await chmod5(built, 493).catch(() => {});
5042
+ return built;
5043
+ }
5044
+ if (!rebuild && existsSync5(release)) {
5045
+ await chmod5(release, 493).catch(() => {});
5046
+ return release;
5047
+ }
5048
+ await $`cargo build --release`;
5049
+ if (existsSync5(built)) {
5050
+ await chmod5(built, 493).catch(() => {});
5051
+ return built;
5052
+ }
5053
+ throw new Error("Oops, failed to build fbi-proxy binary. Please check your Rust setup.");
5054
+ }
5055
+ var init_buildFbiProxy = __esm(async () => {
5056
+ init_dSpawn();
5057
+ if (false) {}
5058
+ });
5059
+
5060
+ // ts/setup.ts
5061
+ var exports_setup = {};
5062
+ __export(exports_setup, {
5063
+ runSetup: () => runSetup
5064
+ });
5065
+ import { existsSync as existsSync6, readFileSync as readFileSync3 } from "node:fs";
5066
+ import { spawnSync } from "node:child_process";
5067
+ import { setTimeout as sleep } from "node:timers/promises";
5068
+ import path4 from "node:path";
5069
+ async function runSetup(args, ctx) {
5070
+ if (process.platform !== "darwin") {
5071
+ console.error("[setup] macOS only. On other OSes run `fbi-proxy --tls --domain <x>` directly.");
5072
+ process.exit(2);
5073
+ }
5074
+ const argv = await yargs_default2(args).scriptName("fbi-proxy setup").usage(`$0 [options]
5075
+
5076
+ Configure fbi-proxy so https://<domain>/ works naturally.`).option("domain", { type: "string", default: "fbi.com" }).option("port", {
5077
+ type: "number",
5078
+ default: 8443,
5079
+ description: "Backend port (oxmgr-managed daemon)"
5080
+ }).option("public-port", {
5081
+ type: "number",
5082
+ default: 443,
5083
+ description: "Public port pf redirects from"
5084
+ }).option("uninstall", {
5085
+ type: "boolean",
5086
+ default: false,
5087
+ description: "Tear down everything this command set up"
5088
+ }).help().argv;
5089
+ if (argv.uninstall)
5090
+ return uninstall();
5091
+ const domain = argv.domain;
5092
+ const port = argv.port;
5093
+ const publicPort = argv["public-port"];
5094
+ console.log(`[setup] target: https://${domain}/ → oxmgr proxy :${port}, pf :${publicPort}→:${port}`);
5095
+ const binary = await getFbiProxyBinary2({ originalCwd: ctx.originalCwd });
5096
+ const absBinary = path4.isAbsolute(binary) ? binary : path4.resolve(binary);
5097
+ console.log(`[setup] binary: ${absBinary}`);
5098
+ const home = process.env.HOME;
5099
+ const certDir = process.env.FBI_PROXY_CERT_DIR ?? path4.join(home, ".config/fbi-proxy/certs");
5100
+ const certPath = path4.join(certDir, `${domain}.pem`);
5101
+ spawnSync("oxmgr", ["delete", OXMGR_NAME], { stdio: "ignore" });
5102
+ const startResult = spawnSync("oxmgr", [
5103
+ "start",
5104
+ "--name",
5105
+ OXMGR_NAME,
5106
+ "--restart",
5107
+ "always",
5108
+ "--cwd",
5109
+ path4.dirname(absBinary),
5110
+ "--env",
5111
+ `HOME=${home}`,
5112
+ "--env",
5113
+ `PATH=${process.env.PATH || "/usr/local/bin:/usr/bin:/bin"}`,
5114
+ "--env",
5115
+ `FBI_PROXY_CERT_DIR=${certDir}`,
5116
+ `${absBinary} --tls --domain ${domain} --port ${port}`
5117
+ ], { stdio: "inherit" });
5118
+ if (startResult.status !== 0) {
5119
+ console.error("[setup] oxmgr start failed — is `oxmgr` installed? (`npm i -g oxmgr` or `brew install oxmgr`)");
5120
+ process.exit(startResult.status ?? 1);
5121
+ }
5122
+ spawnSync("oxmgr", ["service", "install"], { stdio: "ignore" });
5123
+ process.stdout.write("[setup] waiting for daemon");
5124
+ let listening = false;
5125
+ for (let i = 0;i < 30; i++) {
5126
+ await sleep(500);
5127
+ const probe = spawnSync("sh", [
5128
+ "-c",
5129
+ `curl -sk --max-time 1 https://127.0.0.1:${port}/ -o /dev/null && echo ok`
5130
+ ], { stdio: ["ignore", "pipe", "ignore"] });
5131
+ if (probe.stdout?.toString().includes("ok") && existsSync6(certPath)) {
5132
+ listening = true;
5133
+ break;
5134
+ }
5135
+ process.stdout.write(".");
5136
+ }
5137
+ process.stdout.write(`
5138
+ `);
5139
+ if (!listening) {
5140
+ console.error(`[setup] daemon did not come up on :${port} — check \`oxmgr logs ${OXMGR_NAME}\``);
5141
+ process.exit(1);
5142
+ }
5143
+ const certTrusted = isMacosCertTrusted(certPath);
5144
+ const pfActive = isPfRuleActive(publicPort, port);
5145
+ if (certTrusted && pfActive) {
5146
+ console.log("[setup] cert already trusted, pf forward already active");
5147
+ } else {
5148
+ const todo = [
5149
+ !certTrusted && "install cert to system trust",
5150
+ !pfActive && `install pf forward :${publicPort}→:${port}`
5151
+ ].filter(Boolean).join(" + ");
5152
+ console.log(`[setup] root needs to: ${todo}`);
5153
+ const script = buildRootBatch({
5154
+ certTrusted,
5155
+ pfActive,
5156
+ certPath,
5157
+ publicPort,
5158
+ port
5159
+ });
5160
+ if (!runAsRoot(script)) {
5161
+ console.error("[setup] root step failed (cert / pf install)");
5162
+ process.exit(1);
5163
+ }
5164
+ }
5165
+ if (!resolvesToLoopback(domain)) {
5166
+ console.log(`[setup] WARNING: ${domain} does not resolve to 127.0.0.1.`);
5167
+ console.log(" Quickfix: echo '127.0.0.1 " + domain + "' | sudo tee -a /etc/hosts");
5168
+ }
5169
+ const e2e = spawnSync("sh", ["-c", `curl -sf --max-time 5 https://${domain}/ -o /dev/null && echo ok`], { stdio: ["ignore", "pipe", "ignore"] });
5170
+ if (e2e.stdout?.toString().includes("ok")) {
5171
+ console.log(`[setup] ✓ https://${domain}/ reachable with trusted cert`);
5172
+ } else {
5173
+ console.log(`[setup] daemon up on :${port}, cert trusted, pf rule installed.`);
5174
+ console.log(`[setup] https://${domain}/ end-to-end check failed — most likely DNS (see warning above).`);
5175
+ }
5176
+ }
5177
+ async function uninstall() {
5178
+ console.log("[setup] uninstalling fbi-proxy daemon + pf forward…");
5179
+ spawnSync("oxmgr", ["delete", OXMGR_NAME], { stdio: "inherit" });
5180
+ const script = [
5181
+ `launchctl unload ${PF_PLIST} 2>/dev/null || true`,
5182
+ `rm -f ${PF_PLIST} ${ANCHOR_FILE}`,
5183
+ `/usr/bin/sed -i '' '/${escSed(PF_CONF_MARKER_BEGIN)}/,/${escSed(PF_CONF_MARKER_END)}/d' ${PF_CONF}`,
5184
+ `/sbin/pfctl -f ${PF_CONF} 2>/dev/null || true`,
5185
+ "echo uninstalled"
5186
+ ].join(`
5187
+ `);
5188
+ runAsRoot(script);
5189
+ console.log("[setup] done. Cert remains trusted (remove via Keychain Access if desired).");
5190
+ }
5191
+ function escSed(s) {
5192
+ return s.replace(/[\\/.*[\]^$]/g, "\\$&");
5193
+ }
5194
+ function buildRootBatch(opts) {
5195
+ const parts = [];
5196
+ if (!opts.certTrusted) {
5197
+ parts.push(`security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${shellQuote(opts.certPath)}`);
5198
+ }
5199
+ if (!opts.pfActive) {
5200
+ const anchorBody = `rdr pass on lo0 inet proto tcp from any to any port ${opts.publicPort} -> 127.0.0.1 port ${opts.port}
5201
+ `;
5202
+ const plistBody = pfLaunchDaemonPlist();
5203
+ parts.push(heredoc(ANCHOR_FILE, anchorBody));
5204
+ parts.push(`chmod 644 ${ANCHOR_FILE}`);
5205
+ parts.push(heredoc(PF_PLIST, plistBody));
5206
+ parts.push(`chown root:wheel ${PF_PLIST}`);
5207
+ parts.push(`chmod 644 ${PF_PLIST}`);
5208
+ parts.push(`/usr/bin/sed -i '' '/^# >>> ${escSed(ANCHOR_NAME)}/,/^# <<< ${escSed(ANCHOR_NAME)}/d' ${PF_CONF}`);
5209
+ parts.push(`cat > /tmp/fbi-proxy-pf.awk <<'__FBI_SETUP_EOF__'
5210
+ ` + `/^rdr-anchor "com\\.apple/ && !done {
5211
+ ` + ` print
5212
+ ` + ` print "${PF_CONF_MARKER_BEGIN}"
5213
+ ` + ` print "rdr-anchor \\"${ANCHOR_NAME}\\""
5214
+ ` + ` print "load anchor \\"${ANCHOR_NAME}\\" from \\"${ANCHOR_FILE}\\""
5215
+ ` + ` print "${PF_CONF_MARKER_END}"
5216
+ ` + ` done = 1
5217
+ ` + ` next
5218
+ ` + `}
5219
+ ` + `{ print }
5220
+ ` + `__FBI_SETUP_EOF__`);
5221
+ parts.push(`/usr/bin/awk -f /tmp/fbi-proxy-pf.awk ${PF_CONF} > /tmp/pf.conf.fbi-proxy.new`);
5222
+ parts.push(`mv /tmp/pf.conf.fbi-proxy.new ${PF_CONF}`);
5223
+ parts.push(`rm -f /tmp/fbi-proxy-pf.awk`);
5224
+ parts.push(`/sbin/pfctl -nf ${PF_CONF}`);
5225
+ parts.push(`launchctl unload ${PF_PLIST} 2>/dev/null || true`);
5226
+ parts.push(`launchctl load -w ${PF_PLIST}`);
5227
+ parts.push(`/sbin/pfctl -E 2>/dev/null || true`);
5228
+ parts.push(`/sbin/pfctl -f ${PF_CONF}`);
5229
+ }
5230
+ parts.push("echo OK");
5231
+ return parts.join(`
5232
+ `);
5233
+ }
5234
+ function heredoc(filePath, body) {
5235
+ return `cat > ${filePath} <<'__FBI_SETUP_EOF__'
5236
+ ${body}__FBI_SETUP_EOF__`;
5237
+ }
5238
+ function pfLaunchDaemonPlist() {
5239
+ return `<?xml version="1.0" encoding="UTF-8"?>
5240
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
5241
+ <plist version="1.0">
5242
+ <dict>
5243
+ <key>Label</key><string>${ANCHOR_NAME}-pf</string>
5244
+ <key>ProgramArguments</key>
5245
+ <array>
5246
+ <string>/bin/sh</string>
5247
+ <string>-c</string>
5248
+ <string>/sbin/pfctl -E 2>/dev/null; /sbin/pfctl -f ${PF_CONF}</string>
5249
+ </array>
5250
+ <key>RunAtLoad</key><true/>
5251
+ <key>StandardOutPath</key><string>/var/log/${ANCHOR_NAME}-pf.out.log</string>
5252
+ <key>StandardErrorPath</key><string>/var/log/${ANCHOR_NAME}-pf.err.log</string>
5253
+ </dict>
5254
+ </plist>
5255
+ `;
5256
+ }
5257
+ function isMacosCertTrusted(certPath) {
5258
+ if (!existsSync6(certPath))
5259
+ return false;
5260
+ const result = spawnSync("security", ["verify-cert", "-c", certPath], {
5261
+ stdio: "ignore"
5262
+ });
5263
+ return result.status === 0;
5264
+ }
5265
+ function isPfRuleActive(from, to) {
5266
+ if (!existsSync6(ANCHOR_FILE) || !existsSync6(PF_PLIST))
5267
+ return false;
5268
+ let conf = "";
5269
+ try {
5270
+ conf = readFileSync3(PF_CONF, "utf8");
5271
+ } catch {
5272
+ return false;
5273
+ }
5274
+ const markerIdx = conf.indexOf(PF_CONF_MARKER_BEGIN);
5275
+ if (markerIdx < 0)
5276
+ return false;
5277
+ const filterMatch = conf.match(/^anchor "com\.apple\/\*"$/m);
5278
+ const filterIdx = filterMatch?.index ?? -1;
5279
+ if (filterIdx >= 0 && markerIdx > filterIdx)
5280
+ return false;
5281
+ const probe = spawnSync("sudo", ["-n", "/sbin/pfctl", "-a", ANCHOR_NAME, "-s", "nat"], {
5282
+ stdio: ["ignore", "pipe", "ignore"]
5283
+ });
5284
+ if (probe.status !== 0)
5285
+ return true;
5286
+ const out = probe.stdout?.toString() ?? "";
5287
+ return out.includes(`port = ${from}`) && out.includes(`port ${to}`);
5288
+ }
5289
+ function resolvesToLoopback(domain) {
5290
+ const result = spawnSync("dig", ["+short", "+time=1", "+tries=1", domain], {
5291
+ stdio: ["ignore", "pipe", "ignore"]
5292
+ });
5293
+ return (result.stdout?.toString() ?? "").trim().startsWith("127.0.0.1");
5294
+ }
5295
+ function runAsRoot(script) {
5296
+ if (process.getuid?.() === 0) {
5297
+ return spawnSync("sh", ["-c", script], { stdio: "inherit" }).status === 0;
5298
+ }
5299
+ const hasTty = !!process.stdin.isTTY;
5300
+ if (hasTty) {
5301
+ console.log("[setup] (terminal sudo — enter password)");
5302
+ return spawnSync("sudo", ["sh", "-c", script], { stdio: "inherit" }).status === 0;
5303
+ }
5304
+ console.log("[setup] (opening macOS auth dialog — enter password)");
5305
+ const wrapped = `do shell script ${appleScriptQuote(script)} with administrator privileges`;
5306
+ return spawnSync("osascript", ["-e", wrapped], { stdio: "inherit" }).status === 0;
5307
+ }
5308
+ function shellQuote(s) {
5309
+ return `'${s.replace(/'/g, `'\\''`)}'`;
5310
+ }
5311
+ function appleScriptQuote(s) {
5312
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
5313
+ }
5314
+ var ANCHOR_NAME = "com.snomiao.fbi-proxy", ANCHOR_FILE, PF_PLIST, PF_CONF = "/etc/pf.conf", PF_CONF_MARKER_BEGIN, PF_CONF_MARKER_END, OXMGR_NAME = "fbi-proxy";
5315
+ var init_setup = __esm(async () => {
5316
+ init_yargs();
5317
+ await init_buildFbiProxy();
5318
+ ANCHOR_FILE = `/etc/pf.anchors/${ANCHOR_NAME}`;
5319
+ PF_PLIST = `/Library/LaunchDaemons/${ANCHOR_NAME}-pf.plist`;
5320
+ PF_CONF_MARKER_BEGIN = `# >>> ${ANCHOR_NAME} (managed by fbi-proxy setup) >>>`;
5321
+ PF_CONF_MARKER_END = `# <<< ${ANCHOR_NAME} <<<`;
5105
5322
  });
5106
- var $ = Object.assign(dSpawn(), {
5107
- opt: dSpawn,
5108
- cwd: (path) => dSpawn({ cwd: path })
5323
+
5324
+ // ts/cli.ts
5325
+ import { existsSync as existsSync7 } from "fs";
5326
+ import { spawnSync as spawnSync2 } from "child_process";
5327
+
5328
+ // node_modules/get-port/index.js
5329
+ import net from "node:net";
5330
+ import os from "node:os";
5331
+
5332
+ class Locked extends Error {
5333
+ constructor(port) {
5334
+ super(`${port} is locked`);
5335
+ }
5336
+ }
5337
+ var lockedPorts = {
5338
+ old: new Set,
5339
+ young: new Set
5340
+ };
5341
+ var releaseOldLockedPortsIntervalMs = 1000 * 15;
5342
+ var timeout;
5343
+ var getLocalHosts = () => {
5344
+ const interfaces = os.networkInterfaces();
5345
+ const results = new Set([undefined, "0.0.0.0"]);
5346
+ for (const _interface of Object.values(interfaces)) {
5347
+ for (const config of _interface) {
5348
+ results.add(config.address);
5349
+ }
5350
+ }
5351
+ return results;
5352
+ };
5353
+ var checkAvailablePort = (options) => new Promise((resolve, reject) => {
5354
+ const server = net.createServer();
5355
+ server.unref();
5356
+ server.on("error", reject);
5357
+ server.listen(options, () => {
5358
+ const { port } = server.address();
5359
+ server.close(() => {
5360
+ resolve(port);
5361
+ });
5362
+ });
5109
5363
  });
5364
+ var getAvailablePort = async (options, hosts) => {
5365
+ if (options.host || options.port === 0) {
5366
+ return checkAvailablePort(options);
5367
+ }
5368
+ for (const host of hosts) {
5369
+ try {
5370
+ await checkAvailablePort({ port: options.port, host });
5371
+ } catch (error) {
5372
+ if (!["EADDRNOTAVAIL", "EINVAL"].includes(error.code)) {
5373
+ throw error;
5374
+ }
5375
+ }
5376
+ }
5377
+ return options.port;
5378
+ };
5379
+ var portCheckSequence = function* (ports) {
5380
+ if (ports) {
5381
+ yield* ports;
5382
+ }
5383
+ yield 0;
5384
+ };
5385
+ async function getPorts(options) {
5386
+ let ports;
5387
+ let exclude = new Set;
5388
+ if (options) {
5389
+ if (options.port) {
5390
+ ports = typeof options.port === "number" ? [options.port] : options.port;
5391
+ }
5392
+ if (options.exclude) {
5393
+ const excludeIterable = options.exclude;
5394
+ if (typeof excludeIterable[Symbol.iterator] !== "function") {
5395
+ throw new TypeError("The `exclude` option must be an iterable.");
5396
+ }
5397
+ for (const element of excludeIterable) {
5398
+ if (typeof element !== "number") {
5399
+ throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");
5400
+ }
5401
+ if (!Number.isSafeInteger(element)) {
5402
+ throw new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);
5403
+ }
5404
+ }
5405
+ exclude = new Set(excludeIterable);
5406
+ }
5407
+ }
5408
+ if (timeout === undefined) {
5409
+ timeout = setTimeout(() => {
5410
+ timeout = undefined;
5411
+ lockedPorts.old = lockedPorts.young;
5412
+ lockedPorts.young = new Set;
5413
+ }, releaseOldLockedPortsIntervalMs);
5414
+ if (timeout.unref) {
5415
+ timeout.unref();
5416
+ }
5417
+ }
5418
+ const hosts = getLocalHosts();
5419
+ for (const port of portCheckSequence(ports)) {
5420
+ try {
5421
+ if (exclude.has(port)) {
5422
+ continue;
5423
+ }
5424
+ let availablePort = await getAvailablePort({ ...options, port }, hosts);
5425
+ while (lockedPorts.old.has(availablePort) || lockedPorts.young.has(availablePort)) {
5426
+ if (port !== 0) {
5427
+ throw new Locked(port);
5428
+ }
5429
+ availablePort = await getAvailablePort({ ...options, port }, hosts);
5430
+ }
5431
+ lockedPorts.young.add(availablePort);
5432
+ return availablePort;
5433
+ } catch (error) {
5434
+ if (!["EADDRINUSE", "EACCES"].includes(error.code) && !(error instanceof Locked)) {
5435
+ throw error;
5436
+ }
5437
+ }
5438
+ }
5439
+ throw new Error("No available ports found");
5440
+ }
5441
+
5442
+ // node_modules/hot-memo/dist/index.js
5443
+ var g = globalThis;
5444
+ g["_HOTMEMO_SALT_"] ??= new Date().getTime().toString(36) + Math.random().toString(36).slice(2);
5445
+ var cache = g["_HOTMEMO_CACHE_"] ??= new Map;
5446
+ async function hotMemo(fn, args = [], key = `_HOTMEMO_${g["_HOTMEMO_SALT_"]}_${String(fn) + "(" + JSON.stringify(args) + ")"}`) {
5447
+ if (cache.has(key)) {
5448
+ return cache.get(key);
5449
+ }
5450
+ const result = await fn(...args);
5451
+ cache.set(key, result);
5452
+ return result;
5453
+ }
5454
+ hotMemo.cache = cache;
5455
+
5456
+ // ts/cli.ts
5457
+ import path5 from "path";
5458
+
5459
+ // node_modules/yargs/index.mjs
5460
+ init_esm();
5461
+ init_yargs_factory();
5462
+ var Yargs = YargsFactory(esm_default);
5463
+ var yargs_default = Yargs;
5464
+
5465
+ // node_modules/yargs/helpers/helpers.mjs
5466
+ init_apply_extends();
5467
+ init_lib2();
5468
+ init_esm();
5110
5469
 
5111
5470
  // ts/buildFbiProxy.ts
5471
+ init_dSpawn();
5472
+ import { existsSync } from "fs";
5473
+ import { chmod } from "fs/promises";
5474
+ import path from "path";
5112
5475
  if (false) {}
5113
5476
  async function getFbiProxyBinary({ rebuild = false, originalCwd = "" } = {}) {
5114
5477
  const isWin = process.platform === "win32";
@@ -5145,6 +5508,8 @@ async function getFbiProxyBinary({ rebuild = false, originalCwd = "" } = {}) {
5145
5508
  }
5146
5509
 
5147
5510
  // ts/dSpawn.ts
5511
+ init_dist();
5512
+ init_dist2();
5148
5513
  import { spawn as spawn2 } from "child_process";
5149
5514
  var dSpawn2 = ({ cwd = process.cwd(), env: env2 = process.env } = {}) => tsaComposer((slot) => typeof slot === "string" ? {
5150
5515
  raw: String(slot)
@@ -5247,9 +5612,13 @@ function configFromEnv(domain) {
5247
5612
  const provider = process.env.FBI_AUTH_PROVIDER ?? "google";
5248
5613
  const clientId = process.env.FBI_AUTH_CLIENT_ID;
5249
5614
  const firebaseProjectId = process.env.FBI_AUTH_FIREBASE_PROJECT_ID;
5615
+ const localUser = process.env.FBI_AUTH_LOCAL_USER;
5250
5616
  if (provider === "firebase") {
5251
5617
  if (!firebaseProjectId)
5252
5618
  return null;
5619
+ } else if (provider === "snolab") {} else if (provider === "local") {
5620
+ if (!localUser)
5621
+ return null;
5253
5622
  } else {
5254
5623
  if (!clientId)
5255
5624
  return null;
@@ -5268,6 +5637,10 @@ function configFromEnv(domain) {
5268
5637
  apiKey: process.env.FBI_AUTH_FIREBASE_API_KEY,
5269
5638
  authDomain: process.env.FBI_AUTH_FIREBASE_AUTH_DOMAIN
5270
5639
  } : undefined,
5640
+ local: localUser ? {
5641
+ email: localUser,
5642
+ name: process.env.FBI_AUTH_LOCAL_NAME
5643
+ } : undefined,
5271
5644
  sessionSecret: process.env.FBI_AUTH_SESSION_SECRET ?? randomBytes(32).toString("base64url"),
5272
5645
  allowlist: parseAllowlistEnv()
5273
5646
  };
@@ -5433,6 +5806,7 @@ async function getPorts2(options) {
5433
5806
  }
5434
5807
 
5435
5808
  // ts/auth/spawnFbiAuth.ts
5809
+ init_dSpawn();
5436
5810
  async function spawnFbiAuth(opts) {
5437
5811
  const port = await getPorts2({ port: opts.preferredPort ?? 2433 });
5438
5812
  const entry = path2.resolve(import.meta.dir, "..", "..", "lib", "fbi-auth", "src", "server.ts");
@@ -5659,6 +6033,7 @@ function stripLeadingDot(d) {
5659
6033
  }
5660
6034
 
5661
6035
  // ts/auth/spawnCaddy.ts
6036
+ init_dSpawn();
5662
6037
  import { existsSync as existsSync4 } from "node:fs";
5663
6038
  import { access } from "node:fs/promises";
5664
6039
  import { constants as fsConstants } from "node:fs";
@@ -5904,7 +6279,28 @@ async function whichCaddy() {
5904
6279
 
5905
6280
  // ts/cli.ts
5906
6281
  var originalCwd = process.cwd();
5907
- process.chdir(path3.resolve(import.meta.dir, ".."));
6282
+ {
6283
+ const rawArgs = hideBin(process.argv);
6284
+ const firstPositional = rawArgs.find((a) => !a.startsWith("-"));
6285
+ const FOREGROUND_FLAGS = [
6286
+ "--dev",
6287
+ "--with-caddy",
6288
+ "--with-auth",
6289
+ "--tls",
6290
+ "--reconfigure"
6291
+ ];
6292
+ const wantsForeground = rawArgs.some((a) => FOREGROUND_FLAGS.some((f) => a === f || a.startsWith(`${f}=`)));
6293
+ const hasExplicitPortEnv = !!process.env.FBI_PROXY_PORT;
6294
+ const isSetupCmd = firstPositional === "setup";
6295
+ const isDefault = !firstPositional && !wantsForeground && !hasExplicitPortEnv;
6296
+ if (isSetupCmd || isDefault) {
6297
+ const { runSetup: runSetup2 } = await init_setup().then(() => exports_setup);
6298
+ const passArgs = rawArgs.filter((a) => a !== "setup");
6299
+ await runSetup2(passArgs, { originalCwd });
6300
+ process.exit(0);
6301
+ }
6302
+ }
6303
+ process.chdir(path5.resolve(import.meta.dir, ".."));
5908
6304
  var argv = await yargs_default(hideBin(process.argv)).option("dev", {
5909
6305
  type: "boolean",
5910
6306
  default: false,
@@ -5932,16 +6328,35 @@ var argv = await yargs_default(hideBin(process.argv)).option("dev", {
5932
6328
  type: "string",
5933
6329
  choices: ["auto", "internal"],
5934
6330
  description: "TLS strategy for --with-caddy. 'auto' uses ACME (Let's Encrypt); 'internal' uses Caddy's local CA. Defaults to 'internal' for fbi.com, 'auto' otherwise."
6331
+ }).option("tls", {
6332
+ type: "boolean",
6333
+ default: false,
6334
+ description: "Terminate TLS in the Rust proxy using a self-signed cert (no Caddy). Browser warning expected (Phase 1 \u2014 no system trust install). Use with --port 443 + sudo to serve standard HTTPS."
5935
6335
  }).help().argv;
6336
+ if (argv.tls && argv["with-caddy"]) {
6337
+ console.error("[fbi-proxy] --tls and --with-caddy are mutually exclusive (Caddy already terminates TLS).");
6338
+ process.exit(2);
6339
+ }
6340
+ var FBI_PROXY_PORT = process.env.FBI_PROXY_PORT || (argv.tls ? "443" : String(await getPorts({ port: 2432 })));
6341
+ if (argv.tls) {
6342
+ await ensureRootIfTlsNeedsIt({
6343
+ domain: argv.domain,
6344
+ port: Number(FBI_PROXY_PORT)
6345
+ });
6346
+ }
5936
6347
  console.log("Preparing Binaries");
5937
- var FBI_PROXY_PORT = process.env.FBI_PROXY_PORT || String(await getPorts({ port: 2432 }));
5938
6348
  var proxyProcess = await hotMemo(async () => {
5939
6349
  const proxy = await getFbiProxyBinary({ originalCwd });
5940
6350
  console.log("Starting Rust proxy server");
5941
6351
  const p = $2.opt({
5942
6352
  env: {
5943
6353
  ...process.env,
5944
- FBI_PROXY_PORT
6354
+ FBI_PROXY_PORT,
6355
+ ...argv.tls ? {
6356
+ FBI_PROXY_TLS: "true",
6357
+ FBI_PROXY_DOMAIN: argv.domain,
6358
+ ...process.env.FBI_PROXY_CERT_DIR ? { FBI_PROXY_CERT_DIR: process.env.FBI_PROXY_CERT_DIR } : {}
6359
+ } : {}
5945
6360
  }
5946
6361
  })`${proxy}`.process;
5947
6362
  p.on("exit", (code) => {
@@ -5984,6 +6399,57 @@ process.on("uncaughtException", (err) => {
5984
6399
  console.error("Uncaught exception:", err);
5985
6400
  exit();
5986
6401
  });
6402
+ async function ensureRootIfTlsNeedsIt(opts) {
6403
+ if (process.platform !== "darwin") {
6404
+ return;
6405
+ }
6406
+ if (process.getuid?.() === 0)
6407
+ return;
6408
+ const home = process.env.HOME ?? "";
6409
+ const certDir = process.env.FBI_PROXY_CERT_DIR ?? path5.join(home, ".config/fbi-proxy/certs");
6410
+ const slug = opts.domain || "localhost";
6411
+ const certPath = path5.join(certDir, `${slug}.pem`);
6412
+ const needsPortBind = opts.port < 1024;
6413
+ const certMissing = !existsSync7(certPath);
6414
+ const certUntrusted = !certMissing && !isMacosCertTrusted2(certPath);
6415
+ const needsTrustInstall = certMissing || certUntrusted;
6416
+ if (!needsPortBind && !needsTrustInstall)
6417
+ return;
6418
+ const reasons = [
6419
+ needsPortBind && `bind :${opts.port}`,
6420
+ needsTrustInstall && "install cert to system trust"
6421
+ ].filter(Boolean).join(" + ");
6422
+ console.log(`[fbi-proxy] --tls needs root to: ${reasons}`);
6423
+ const sudoArgs = [
6424
+ `HOME=${home}`,
6425
+ `FBI_PROXY_CERT_DIR=${certDir}`,
6426
+ process.execPath,
6427
+ ...process.argv.slice(1)
6428
+ ];
6429
+ const hasTty = !!process.stdin.isTTY;
6430
+ if (hasTty) {
6431
+ console.log(`[fbi-proxy] re-launching via sudo (terminal password prompt)\u2026`);
6432
+ const result2 = spawnSync2("sudo", sudoArgs, { stdio: "inherit" });
6433
+ process.exit(result2.status ?? 1);
6434
+ }
6435
+ console.log(`[fbi-proxy] no TTY \u2014 opening macOS authentication dialog\u2026`);
6436
+ const shellCmd = sudoArgs.map(shellQuote2).join(" ");
6437
+ const script = `do shell script ${appleScriptQuote2(shellCmd)} with administrator privileges`;
6438
+ const result = spawnSync2("osascript", ["-e", script], { stdio: "inherit" });
6439
+ process.exit(result.status ?? 1);
6440
+ }
6441
+ function shellQuote2(s) {
6442
+ return `'${s.replace(/'/g, `'\\''`)}'`;
6443
+ }
6444
+ function appleScriptQuote2(s) {
6445
+ return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
6446
+ }
6447
+ function isMacosCertTrusted2(certPath) {
6448
+ const result = spawnSync2("security", ["verify-cert", "-c", certPath], {
6449
+ stdio: "ignore"
6450
+ });
6451
+ return result.status === 0;
6452
+ }
5987
6453
  async function startFbiAuth(opts) {
5988
6454
  const configPath = defaultConfigPath();
5989
6455
  let cfg = await readConfigOrNull(configPath);