npm-pkg-lint 5.1.12 → 5.2.1

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/index.js CHANGED
@@ -38,3172 +38,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
38
38
  mod
39
39
  ));
40
40
 
41
- // node_modules/argparse/lib/sub.js
42
- var require_sub = __commonJS({
43
- "node_modules/argparse/lib/sub.js"(exports, module) {
44
- "use strict";
45
- var { inspect } = __require("util");
46
- module.exports = function sub(pattern, ...values) {
47
- let regex = /%(?:(%)|(-)?(\*)?(?:\((\w+)\))?([A-Za-z]))/g;
48
- let result = pattern.replace(regex, function(_2, is_literal, is_left_align, is_padded, name, format) {
49
- if (is_literal) return "%";
50
- let padded_count = 0;
51
- if (is_padded) {
52
- if (values.length === 0) throw new TypeError("not enough arguments for format string");
53
- padded_count = values.shift();
54
- if (!Number.isInteger(padded_count)) throw new TypeError("* wants int");
55
- }
56
- let str;
57
- if (name !== void 0) {
58
- let dict = values[0];
59
- if (typeof dict !== "object" || dict === null) throw new TypeError("format requires a mapping");
60
- if (!(name in dict)) throw new TypeError(`no such key: '${name}'`);
61
- str = dict[name];
62
- } else {
63
- if (values.length === 0) throw new TypeError("not enough arguments for format string");
64
- str = values.shift();
65
- }
66
- switch (format) {
67
- case "s":
68
- str = String(str);
69
- break;
70
- case "r":
71
- str = inspect(str);
72
- break;
73
- case "d":
74
- case "i":
75
- if (typeof str !== "number") {
76
- throw new TypeError(`%${format} format: a number is required, not ${typeof str}`);
77
- }
78
- str = String(str.toFixed(0));
79
- break;
80
- default:
81
- throw new TypeError(`unsupported format character '${format}'`);
82
- }
83
- if (padded_count > 0) {
84
- return is_left_align ? str.padEnd(padded_count) : str.padStart(padded_count);
85
- } else {
86
- return str;
87
- }
88
- });
89
- if (values.length) {
90
- if (values.length === 1 && typeof values[0] === "object" && values[0] !== null) {
91
- } else {
92
- throw new TypeError("not all arguments converted during string formatting");
93
- }
94
- }
95
- return result;
96
- };
97
- }
98
- });
99
-
100
- // node_modules/argparse/lib/textwrap.js
101
- var require_textwrap = __commonJS({
102
- "node_modules/argparse/lib/textwrap.js"(exports, module) {
103
- "use strict";
104
- var wordsep_simple_re = /([\t\n\x0b\x0c\r ]+)/;
105
- var TextWrapper = class {
106
- /*
107
- * Object for wrapping/filling text. The public interface consists of
108
- * the wrap() and fill() methods; the other methods are just there for
109
- * subclasses to override in order to tweak the default behaviour.
110
- * If you want to completely replace the main wrapping algorithm,
111
- * you'll probably have to override _wrap_chunks().
112
- *
113
- * Several instance attributes control various aspects of wrapping:
114
- * width (default: 70)
115
- * the maximum width of wrapped lines (unless break_long_words
116
- * is false)
117
- * initial_indent (default: "")
118
- * string that will be prepended to the first line of wrapped
119
- * output. Counts towards the line's width.
120
- * subsequent_indent (default: "")
121
- * string that will be prepended to all lines save the first
122
- * of wrapped output; also counts towards each line's width.
123
- * expand_tabs (default: true)
124
- * Expand tabs in input text to spaces before further processing.
125
- * Each tab will become 0 .. 'tabsize' spaces, depending on its position
126
- * in its line. If false, each tab is treated as a single character.
127
- * tabsize (default: 8)
128
- * Expand tabs in input text to 0 .. 'tabsize' spaces, unless
129
- * 'expand_tabs' is false.
130
- * replace_whitespace (default: true)
131
- * Replace all whitespace characters in the input text by spaces
132
- * after tab expansion. Note that if expand_tabs is false and
133
- * replace_whitespace is true, every tab will be converted to a
134
- * single space!
135
- * fix_sentence_endings (default: false)
136
- * Ensure that sentence-ending punctuation is always followed
137
- * by two spaces. Off by default because the algorithm is
138
- * (unavoidably) imperfect.
139
- * break_long_words (default: true)
140
- * Break words longer than 'width'. If false, those words will not
141
- * be broken, and some lines might be longer than 'width'.
142
- * break_on_hyphens (default: true)
143
- * Allow breaking hyphenated words. If true, wrapping will occur
144
- * preferably on whitespaces and right after hyphens part of
145
- * compound words.
146
- * drop_whitespace (default: true)
147
- * Drop leading and trailing whitespace from lines.
148
- * max_lines (default: None)
149
- * Truncate wrapped lines.
150
- * placeholder (default: ' [...]')
151
- * Append to the last line of truncated text.
152
- */
153
- constructor(options = {}) {
154
- let {
155
- width = 70,
156
- initial_indent = "",
157
- subsequent_indent = "",
158
- expand_tabs = true,
159
- replace_whitespace = true,
160
- fix_sentence_endings = false,
161
- break_long_words = true,
162
- drop_whitespace = true,
163
- break_on_hyphens = true,
164
- tabsize = 8,
165
- max_lines = void 0,
166
- placeholder = " [...]"
167
- } = options;
168
- this.width = width;
169
- this.initial_indent = initial_indent;
170
- this.subsequent_indent = subsequent_indent;
171
- this.expand_tabs = expand_tabs;
172
- this.replace_whitespace = replace_whitespace;
173
- this.fix_sentence_endings = fix_sentence_endings;
174
- this.break_long_words = break_long_words;
175
- this.drop_whitespace = drop_whitespace;
176
- this.break_on_hyphens = break_on_hyphens;
177
- this.tabsize = tabsize;
178
- this.max_lines = max_lines;
179
- this.placeholder = placeholder;
180
- }
181
- // -- Private methods -----------------------------------------------
182
- // (possibly useful for subclasses to override)
183
- _munge_whitespace(text) {
184
- if (this.expand_tabs) {
185
- text = text.replace(/\t/g, " ".repeat(this.tabsize));
186
- }
187
- if (this.replace_whitespace) {
188
- text = text.replace(/[\t\n\x0b\x0c\r]/g, " ");
189
- }
190
- return text;
191
- }
192
- _split(text) {
193
- let chunks = text.split(wordsep_simple_re);
194
- chunks = chunks.filter(Boolean);
195
- return chunks;
196
- }
197
- _handle_long_word(reversed_chunks, cur_line, cur_len, width) {
198
- let space_left;
199
- if (width < 1) {
200
- space_left = 1;
201
- } else {
202
- space_left = width - cur_len;
203
- }
204
- if (this.break_long_words) {
205
- cur_line.push(reversed_chunks[reversed_chunks.length - 1].slice(0, space_left));
206
- reversed_chunks[reversed_chunks.length - 1] = reversed_chunks[reversed_chunks.length - 1].slice(space_left);
207
- } else if (!cur_line) {
208
- cur_line.push(...reversed_chunks.pop());
209
- }
210
- }
211
- _wrap_chunks(chunks) {
212
- let lines = [];
213
- let indent;
214
- if (this.width <= 0) {
215
- throw Error(`invalid width ${this.width} (must be > 0)`);
216
- }
217
- if (this.max_lines !== void 0) {
218
- if (this.max_lines > 1) {
219
- indent = this.subsequent_indent;
220
- } else {
221
- indent = this.initial_indent;
222
- }
223
- if (indent.length + this.placeholder.trimStart().length > this.width) {
224
- throw Error("placeholder too large for max width");
225
- }
226
- }
227
- chunks = chunks.reverse();
228
- while (chunks.length > 0) {
229
- let cur_line = [];
230
- let cur_len = 0;
231
- let indent2;
232
- if (lines) {
233
- indent2 = this.subsequent_indent;
234
- } else {
235
- indent2 = this.initial_indent;
236
- }
237
- let width = this.width - indent2.length;
238
- if (this.drop_whitespace && chunks[chunks.length - 1].trim() === "" && lines.length > 0) {
239
- chunks.pop();
240
- }
241
- while (chunks.length > 0) {
242
- let l = chunks[chunks.length - 1].length;
243
- if (cur_len + l <= width) {
244
- cur_line.push(chunks.pop());
245
- cur_len += l;
246
- } else {
247
- break;
248
- }
249
- }
250
- if (chunks.length && chunks[chunks.length - 1].length > width) {
251
- this._handle_long_word(chunks, cur_line, cur_len, width);
252
- cur_len = cur_line.map((l) => l.length).reduce((a, b2) => a + b2, 0);
253
- }
254
- if (this.drop_whitespace && cur_line.length > 0 && cur_line[cur_line.length - 1].trim() === "") {
255
- cur_len -= cur_line[cur_line.length - 1].length;
256
- cur_line.pop();
257
- }
258
- if (cur_line) {
259
- if (this.max_lines === void 0 || lines.length + 1 < this.max_lines || (chunks.length === 0 || this.drop_whitespace && chunks.length === 1 && !chunks[0].trim()) && cur_len <= width) {
260
- lines.push(indent2 + cur_line.join(""));
261
- } else {
262
- let had_break = false;
263
- while (cur_line) {
264
- if (cur_line[cur_line.length - 1].trim() && cur_len + this.placeholder.length <= width) {
265
- cur_line.push(this.placeholder);
266
- lines.push(indent2 + cur_line.join(""));
267
- had_break = true;
268
- break;
269
- }
270
- cur_len -= cur_line[-1].length;
271
- cur_line.pop();
272
- }
273
- if (!had_break) {
274
- if (lines) {
275
- let prev_line = lines[lines.length - 1].trimEnd();
276
- if (prev_line.length + this.placeholder.length <= this.width) {
277
- lines[lines.length - 1] = prev_line + this.placeholder;
278
- break;
279
- }
280
- }
281
- lines.push(indent2 + this.placeholder.lstrip());
282
- }
283
- break;
284
- }
285
- }
286
- }
287
- return lines;
288
- }
289
- _split_chunks(text) {
290
- text = this._munge_whitespace(text);
291
- return this._split(text);
292
- }
293
- // -- Public interface ----------------------------------------------
294
- wrap(text) {
295
- let chunks = this._split_chunks(text);
296
- return this._wrap_chunks(chunks);
297
- }
298
- fill(text) {
299
- return this.wrap(text).join("\n");
300
- }
301
- };
302
- function wrap(text, options = {}) {
303
- let { width = 70, ...kwargs } = options;
304
- let w2 = new TextWrapper(Object.assign({ width }, kwargs));
305
- return w2.wrap(text);
306
- }
307
- function fill(text, options = {}) {
308
- let { width = 70, ...kwargs } = options;
309
- let w2 = new TextWrapper(Object.assign({ width }, kwargs));
310
- return w2.fill(text);
311
- }
312
- var _whitespace_only_re = /^[ \t]+$/mg;
313
- var _leading_whitespace_re = /(^[ \t]*)(?:[^ \t\n])/mg;
314
- function dedent(text) {
315
- let margin = void 0;
316
- text = text.replace(_whitespace_only_re, "");
317
- let indents = text.match(_leading_whitespace_re) || [];
318
- for (let indent of indents) {
319
- indent = indent.slice(0, -1);
320
- if (margin === void 0) {
321
- margin = indent;
322
- } else if (indent.startsWith(margin)) {
323
- } else if (margin.startsWith(indent)) {
324
- margin = indent;
325
- } else {
326
- for (let i = 0; i < margin.length && i < indent.length; i++) {
327
- if (margin[i] !== indent[i]) {
328
- margin = margin.slice(0, i);
329
- break;
330
- }
331
- }
332
- }
333
- }
334
- if (margin) {
335
- text = text.replace(new RegExp("^" + margin, "mg"), "");
336
- }
337
- return text;
338
- }
339
- module.exports = { wrap, fill, dedent };
340
- }
341
- });
342
-
343
- // node_modules/argparse/argparse.js
344
- var require_argparse = __commonJS({
345
- "node_modules/argparse/argparse.js"(exports, module) {
346
- "use strict";
347
- var SUPPRESS = "==SUPPRESS==";
348
- var OPTIONAL = "?";
349
- var ZERO_OR_MORE = "*";
350
- var ONE_OR_MORE = "+";
351
- var PARSER = "A...";
352
- var REMAINDER = "...";
353
- var _UNRECOGNIZED_ARGS_ATTR = "_unrecognized_args";
354
- var assert = __require("assert");
355
- var util = __require("util");
356
- var fs8 = __require("fs");
357
- var sub = require_sub();
358
- var path8 = __require("path");
359
- var repr = util.inspect;
360
- function get_argv() {
361
- return process.argv.slice(1);
362
- }
363
- function get_terminal_size() {
364
- return {
365
- columns: +process.env.COLUMNS || process.stdout.columns || 80
366
- };
367
- }
368
- function hasattr(object, name) {
369
- return Object.prototype.hasOwnProperty.call(object, name);
370
- }
371
- function getattr(object, name, value) {
372
- return hasattr(object, name) ? object[name] : value;
373
- }
374
- function setattr(object, name, value) {
375
- object[name] = value;
376
- }
377
- function setdefault(object, name, value) {
378
- if (!hasattr(object, name)) object[name] = value;
379
- return object[name];
380
- }
381
- function delattr(object, name) {
382
- delete object[name];
383
- }
384
- function range(from, to2, step = 1) {
385
- if (arguments.length === 1) [to2, from] = [from, 0];
386
- if (typeof from !== "number" || typeof to2 !== "number" || typeof step !== "number") {
387
- throw new TypeError("argument cannot be interpreted as an integer");
388
- }
389
- if (step === 0) throw new TypeError("range() arg 3 must not be zero");
390
- let result = [];
391
- if (step > 0) {
392
- for (let i = from; i < to2; i += step) result.push(i);
393
- } else {
394
- for (let i = from; i > to2; i += step) result.push(i);
395
- }
396
- return result;
397
- }
398
- function splitlines(str, keepends = false) {
399
- let result;
400
- if (!keepends) {
401
- result = str.split(/\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/);
402
- } else {
403
- result = [];
404
- let parts = str.split(/(\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029])/);
405
- for (let i = 0; i < parts.length; i += 2) {
406
- result.push(parts[i] + (i + 1 < parts.length ? parts[i + 1] : ""));
407
- }
408
- }
409
- if (!result[result.length - 1]) result.pop();
410
- return result;
411
- }
412
- function _string_lstrip(string, prefix_chars) {
413
- let idx = 0;
414
- while (idx < string.length && prefix_chars.includes(string[idx])) idx++;
415
- return idx ? string.slice(idx) : string;
416
- }
417
- function _string_split(string, sep, maxsplit) {
418
- let result = string.split(sep);
419
- if (result.length > maxsplit) {
420
- result = result.slice(0, maxsplit).concat([result.slice(maxsplit).join(sep)]);
421
- }
422
- return result;
423
- }
424
- function _array_equal(array1, array2) {
425
- if (array1.length !== array2.length) return false;
426
- for (let i = 0; i < array1.length; i++) {
427
- if (array1[i] !== array2[i]) return false;
428
- }
429
- return true;
430
- }
431
- function _array_remove(array, item) {
432
- let idx = array.indexOf(item);
433
- if (idx === -1) throw new TypeError(sub("%r not in list", item));
434
- array.splice(idx, 1);
435
- }
436
- function _choices_to_array(choices) {
437
- if (choices === void 0) {
438
- return [];
439
- } else if (Array.isArray(choices)) {
440
- return choices;
441
- } else if (choices !== null && typeof choices[Symbol.iterator] === "function") {
442
- return Array.from(choices);
443
- } else if (typeof choices === "object" && choices !== null) {
444
- return Object.keys(choices);
445
- } else {
446
- throw new Error(sub("invalid choices value: %r", choices));
447
- }
448
- }
449
- function _callable(cls) {
450
- let result = {
451
- // object is needed for inferred class name
452
- [cls.name]: function(...args) {
453
- let this_class = new.target === result || !new.target;
454
- return Reflect.construct(cls, args, this_class ? cls : new.target);
455
- }
456
- };
457
- result[cls.name].prototype = cls.prototype;
458
- cls.prototype[Symbol.toStringTag] = cls.name;
459
- return result[cls.name];
460
- }
461
- function _alias(object, from, to2) {
462
- try {
463
- let name = object.constructor.name;
464
- Object.defineProperty(object, from, {
465
- value: util.deprecate(object[to2], sub(
466
- "%s.%s() is renamed to %s.%s()",
467
- name,
468
- from,
469
- name,
470
- to2
471
- )),
472
- enumerable: false
473
- });
474
- } catch {
475
- }
476
- }
477
- function _camelcase_alias(_class) {
478
- for (let name of Object.getOwnPropertyNames(_class.prototype)) {
479
- let camelcase = name.replace(/\w_[a-z]/g, (s3) => s3[0] + s3[2].toUpperCase());
480
- if (camelcase !== name) _alias(_class.prototype, camelcase, name);
481
- }
482
- return _class;
483
- }
484
- function _to_legacy_name(key) {
485
- key = key.replace(/\w_[a-z]/g, (s3) => s3[0] + s3[2].toUpperCase());
486
- if (key === "default") key = "defaultValue";
487
- if (key === "const") key = "constant";
488
- return key;
489
- }
490
- function _to_new_name(key) {
491
- if (key === "defaultValue") key = "default";
492
- if (key === "constant") key = "const";
493
- key = key.replace(/[A-Z]/g, (c) => "_" + c.toLowerCase());
494
- return key;
495
- }
496
- var no_default = /* @__PURE__ */ Symbol("no_default_value");
497
- function _parse_opts(args, descriptor) {
498
- function get_name() {
499
- let stack = new Error().stack.split("\n").map((x) => x.match(/^ at (.*) \(.*\)$/)).filter(Boolean).map((m2) => m2[1]).map((fn) => fn.match(/[^ .]*$/)[0]);
500
- if (stack.length && stack[0] === get_name.name) stack.shift();
501
- if (stack.length && stack[0] === _parse_opts.name) stack.shift();
502
- return stack.length ? stack[0] : "";
503
- }
504
- args = Array.from(args);
505
- let kwargs = {};
506
- let result = [];
507
- let last_opt = args.length && args[args.length - 1];
508
- if (typeof last_opt === "object" && last_opt !== null && !Array.isArray(last_opt) && (!last_opt.constructor || last_opt.constructor.name === "Object")) {
509
- kwargs = Object.assign({}, args.pop());
510
- }
511
- let renames = [];
512
- for (let key of Object.keys(descriptor)) {
513
- let old_name = _to_legacy_name(key);
514
- if (old_name !== key && old_name in kwargs) {
515
- if (key in kwargs) {
516
- } else {
517
- kwargs[key] = kwargs[old_name];
518
- }
519
- renames.push([old_name, key]);
520
- delete kwargs[old_name];
521
- }
522
- }
523
- if (renames.length) {
524
- let name = get_name();
525
- deprecate("camelcase_" + name, sub(
526
- "%s(): following options are renamed: %s",
527
- name,
528
- renames.map(([a, b2]) => sub("%r -> %r", a, b2))
529
- ));
530
- }
531
- let missing_positionals = [];
532
- let positional_count = args.length;
533
- for (let [key, def] of Object.entries(descriptor)) {
534
- if (key[0] === "*") {
535
- if (key.length > 0 && key[1] === "*") {
536
- let renames2 = [];
537
- for (let key2 of Object.keys(kwargs)) {
538
- let new_name = _to_new_name(key2);
539
- if (new_name !== key2 && key2 in kwargs) {
540
- if (new_name in kwargs) {
541
- } else {
542
- kwargs[new_name] = kwargs[key2];
543
- }
544
- renames2.push([key2, new_name]);
545
- delete kwargs[key2];
546
- }
547
- }
548
- if (renames2.length) {
549
- let name = get_name();
550
- deprecate("camelcase_" + name, sub(
551
- "%s(): following options are renamed: %s",
552
- name,
553
- renames2.map(([a, b2]) => sub("%r -> %r", a, b2))
554
- ));
555
- }
556
- result.push(kwargs);
557
- kwargs = {};
558
- } else {
559
- result.push(args);
560
- args = [];
561
- }
562
- } else if (key in kwargs && args.length > 0) {
563
- throw new TypeError(sub("%s() got multiple values for argument %r", get_name(), key));
564
- } else if (key in kwargs) {
565
- result.push(kwargs[key]);
566
- delete kwargs[key];
567
- } else if (args.length > 0) {
568
- result.push(args.shift());
569
- } else if (def !== no_default) {
570
- result.push(def);
571
- } else {
572
- missing_positionals.push(key);
573
- }
574
- }
575
- if (Object.keys(kwargs).length) {
576
- throw new TypeError(sub(
577
- "%s() got an unexpected keyword argument %r",
578
- get_name(),
579
- Object.keys(kwargs)[0]
580
- ));
581
- }
582
- if (args.length) {
583
- let from = Object.entries(descriptor).filter(([k2, v2]) => k2[0] !== "*" && v2 !== no_default).length;
584
- let to2 = Object.entries(descriptor).filter(([k2]) => k2[0] !== "*").length;
585
- throw new TypeError(sub(
586
- "%s() takes %s positional argument%s but %s %s given",
587
- get_name(),
588
- from === to2 ? sub("from %s to %s", from, to2) : to2,
589
- from === to2 && to2 === 1 ? "" : "s",
590
- positional_count,
591
- positional_count === 1 ? "was" : "were"
592
- ));
593
- }
594
- if (missing_positionals.length) {
595
- let strs = missing_positionals.map(repr);
596
- if (strs.length > 1) strs[strs.length - 1] = "and " + strs[strs.length - 1];
597
- let str_joined = strs.join(strs.length === 2 ? "" : ", ");
598
- throw new TypeError(sub(
599
- "%s() missing %i required positional argument%s: %s",
600
- get_name(),
601
- strs.length,
602
- strs.length === 1 ? "" : "s",
603
- str_joined
604
- ));
605
- }
606
- return result;
607
- }
608
- var _deprecations = {};
609
- function deprecate(id, string) {
610
- _deprecations[id] = _deprecations[id] || util.deprecate(() => {
611
- }, string);
612
- _deprecations[id]();
613
- }
614
- function _AttributeHolder(cls = Object) {
615
- return class _AttributeHolder extends cls {
616
- [util.inspect.custom]() {
617
- let type_name = this.constructor.name;
618
- let arg_strings = [];
619
- let star_args = {};
620
- for (let arg of this._get_args()) {
621
- arg_strings.push(repr(arg));
622
- }
623
- for (let [name, value] of this._get_kwargs()) {
624
- if (/^[a-z_][a-z0-9_$]*$/i.test(name)) {
625
- arg_strings.push(sub("%s=%r", name, value));
626
- } else {
627
- star_args[name] = value;
628
- }
629
- }
630
- if (Object.keys(star_args).length) {
631
- arg_strings.push(sub("**%s", repr(star_args)));
632
- }
633
- return sub("%s(%s)", type_name, arg_strings.join(", "));
634
- }
635
- toString() {
636
- return this[util.inspect.custom]();
637
- }
638
- _get_kwargs() {
639
- return Object.entries(this);
640
- }
641
- _get_args() {
642
- return [];
643
- }
644
- };
645
- }
646
- function _copy_items(items) {
647
- if (items === void 0) {
648
- return [];
649
- }
650
- return items.slice(0);
651
- }
652
- var HelpFormatter = _camelcase_alias(_callable(class HelpFormatter {
653
- /*
654
- * Formatter for generating usage messages and argument help strings.
655
- *
656
- * Only the name of this class is considered a public API. All the methods
657
- * provided by the class are considered an implementation detail.
658
- */
659
- constructor() {
660
- let [
661
- prog,
662
- indent_increment,
663
- max_help_position,
664
- width
665
- ] = _parse_opts(arguments, {
666
- prog: no_default,
667
- indent_increment: 2,
668
- max_help_position: 24,
669
- width: void 0
670
- });
671
- if (width === void 0) {
672
- width = get_terminal_size().columns;
673
- width -= 2;
674
- }
675
- this._prog = prog;
676
- this._indent_increment = indent_increment;
677
- this._max_help_position = Math.min(
678
- max_help_position,
679
- Math.max(width - 20, indent_increment * 2)
680
- );
681
- this._width = width;
682
- this._current_indent = 0;
683
- this._level = 0;
684
- this._action_max_length = 0;
685
- this._root_section = this._Section(this, void 0);
686
- this._current_section = this._root_section;
687
- this._whitespace_matcher = /[ \t\n\r\f\v]+/g;
688
- this._long_break_matcher = /\n\n\n+/g;
689
- }
690
- // ===============================
691
- // Section and indentation methods
692
- // ===============================
693
- _indent() {
694
- this._current_indent += this._indent_increment;
695
- this._level += 1;
696
- }
697
- _dedent() {
698
- this._current_indent -= this._indent_increment;
699
- assert(this._current_indent >= 0, "Indent decreased below 0.");
700
- this._level -= 1;
701
- }
702
- _add_item(func, args) {
703
- this._current_section.items.push([func, args]);
704
- }
705
- // ========================
706
- // Message building methods
707
- // ========================
708
- start_section(heading) {
709
- this._indent();
710
- let section = this._Section(this, this._current_section, heading);
711
- this._add_item(section.format_help.bind(section), []);
712
- this._current_section = section;
713
- }
714
- end_section() {
715
- this._current_section = this._current_section.parent;
716
- this._dedent();
717
- }
718
- add_text(text) {
719
- if (text !== SUPPRESS && text !== void 0) {
720
- this._add_item(this._format_text.bind(this), [text]);
721
- }
722
- }
723
- add_usage(usage, actions, groups, prefix2 = void 0) {
724
- if (usage !== SUPPRESS) {
725
- let args = [usage, actions, groups, prefix2];
726
- this._add_item(this._format_usage.bind(this), args);
727
- }
728
- }
729
- add_argument(action) {
730
- if (action.help !== SUPPRESS) {
731
- let invocations = [this._format_action_invocation(action)];
732
- for (let subaction of this._iter_indented_subactions(action)) {
733
- invocations.push(this._format_action_invocation(subaction));
734
- }
735
- let invocation_length = Math.max(...invocations.map((invocation) => invocation.length));
736
- let action_length = invocation_length + this._current_indent;
737
- this._action_max_length = Math.max(
738
- this._action_max_length,
739
- action_length
740
- );
741
- this._add_item(this._format_action.bind(this), [action]);
742
- }
743
- }
744
- add_arguments(actions) {
745
- for (let action of actions) {
746
- this.add_argument(action);
747
- }
748
- }
749
- // =======================
750
- // Help-formatting methods
751
- // =======================
752
- format_help() {
753
- let help = this._root_section.format_help();
754
- if (help) {
755
- help = help.replace(this._long_break_matcher, "\n\n");
756
- help = help.replace(/^\n+|\n+$/g, "") + "\n";
757
- }
758
- return help;
759
- }
760
- _join_parts(part_strings) {
761
- return part_strings.filter((part) => part && part !== SUPPRESS).join("");
762
- }
763
- _format_usage(usage, actions, groups, prefix2) {
764
- if (prefix2 === void 0) {
765
- prefix2 = "usage: ";
766
- }
767
- if (usage !== void 0) {
768
- usage = sub(usage, { prog: this._prog });
769
- } else if (usage === void 0 && !actions.length) {
770
- usage = sub("%(prog)s", { prog: this._prog });
771
- } else if (usage === void 0) {
772
- let prog = sub("%(prog)s", { prog: this._prog });
773
- let optionals = [];
774
- let positionals = [];
775
- for (let action of actions) {
776
- if (action.option_strings.length) {
777
- optionals.push(action);
778
- } else {
779
- positionals.push(action);
780
- }
781
- }
782
- let action_usage = this._format_actions_usage([].concat(optionals).concat(positionals), groups);
783
- usage = [prog, action_usage].map(String).join(" ");
784
- let text_width = this._width - this._current_indent;
785
- if (prefix2.length + usage.length > text_width) {
786
- let part_regexp = /\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+/g;
787
- let opt_usage = this._format_actions_usage(optionals, groups);
788
- let pos_usage = this._format_actions_usage(positionals, groups);
789
- let opt_parts = opt_usage.match(part_regexp) || [];
790
- let pos_parts = pos_usage.match(part_regexp) || [];
791
- assert(opt_parts.join(" ") === opt_usage);
792
- assert(pos_parts.join(" ") === pos_usage);
793
- let get_lines = (parts, indent, prefix3 = void 0) => {
794
- let lines2 = [];
795
- let line = [];
796
- let line_len;
797
- if (prefix3 !== void 0) {
798
- line_len = prefix3.length - 1;
799
- } else {
800
- line_len = indent.length - 1;
801
- }
802
- for (let part of parts) {
803
- if (line_len + 1 + part.length > text_width && line) {
804
- lines2.push(indent + line.join(" "));
805
- line = [];
806
- line_len = indent.length - 1;
807
- }
808
- line.push(part);
809
- line_len += part.length + 1;
810
- }
811
- if (line.length) {
812
- lines2.push(indent + line.join(" "));
813
- }
814
- if (prefix3 !== void 0) {
815
- lines2[0] = lines2[0].slice(indent.length);
816
- }
817
- return lines2;
818
- };
819
- let lines;
820
- if (prefix2.length + prog.length <= 0.75 * text_width) {
821
- let indent = " ".repeat(prefix2.length + prog.length + 1);
822
- if (opt_parts.length) {
823
- lines = get_lines([prog].concat(opt_parts), indent, prefix2);
824
- lines = lines.concat(get_lines(pos_parts, indent));
825
- } else if (pos_parts.length) {
826
- lines = get_lines([prog].concat(pos_parts), indent, prefix2);
827
- } else {
828
- lines = [prog];
829
- }
830
- } else {
831
- let indent = " ".repeat(prefix2.length);
832
- let parts = [].concat(opt_parts).concat(pos_parts);
833
- lines = get_lines(parts, indent);
834
- if (lines.length > 1) {
835
- lines = [];
836
- lines = lines.concat(get_lines(opt_parts, indent));
837
- lines = lines.concat(get_lines(pos_parts, indent));
838
- }
839
- lines = [prog].concat(lines);
840
- }
841
- usage = lines.join("\n");
842
- }
843
- }
844
- return sub("%s%s\n\n", prefix2, usage);
845
- }
846
- _format_actions_usage(actions, groups) {
847
- let group_actions = /* @__PURE__ */ new Set();
848
- let inserts = {};
849
- for (let group of groups) {
850
- let start = actions.indexOf(group._group_actions[0]);
851
- if (start === -1) {
852
- continue;
853
- } else {
854
- let end = start + group._group_actions.length;
855
- if (_array_equal(actions.slice(start, end), group._group_actions)) {
856
- for (let action of group._group_actions) {
857
- group_actions.add(action);
858
- }
859
- if (!group.required) {
860
- if (start in inserts) {
861
- inserts[start] += " [";
862
- } else {
863
- inserts[start] = "[";
864
- }
865
- if (end in inserts) {
866
- inserts[end] += "]";
867
- } else {
868
- inserts[end] = "]";
869
- }
870
- } else {
871
- if (start in inserts) {
872
- inserts[start] += " (";
873
- } else {
874
- inserts[start] = "(";
875
- }
876
- if (end in inserts) {
877
- inserts[end] += ")";
878
- } else {
879
- inserts[end] = ")";
880
- }
881
- }
882
- for (let i of range(start + 1, end)) {
883
- inserts[i] = "|";
884
- }
885
- }
886
- }
887
- }
888
- let parts = [];
889
- for (let [i, action] of Object.entries(actions)) {
890
- if (action.help === SUPPRESS) {
891
- parts.push(void 0);
892
- if (inserts[+i] === "|") {
893
- delete inserts[+i];
894
- } else if (inserts[+i + 1] === "|") {
895
- delete inserts[+i + 1];
896
- }
897
- } else if (!action.option_strings.length) {
898
- let default_value = this._get_default_metavar_for_positional(action);
899
- let part = this._format_args(action, default_value);
900
- if (group_actions.has(action)) {
901
- if (part[0] === "[" && part[part.length - 1] === "]") {
902
- part = part.slice(1, -1);
903
- }
904
- }
905
- parts.push(part);
906
- } else {
907
- let option_string = action.option_strings[0];
908
- let part;
909
- if (action.nargs === 0) {
910
- part = action.format_usage();
911
- } else {
912
- let default_value = this._get_default_metavar_for_optional(action);
913
- let args_string = this._format_args(action, default_value);
914
- part = sub("%s %s", option_string, args_string);
915
- }
916
- if (!action.required && !group_actions.has(action)) {
917
- part = sub("[%s]", part);
918
- }
919
- parts.push(part);
920
- }
921
- }
922
- for (let i of Object.keys(inserts).map(Number).sort((a, b2) => b2 - a)) {
923
- parts.splice(+i, 0, inserts[+i]);
924
- }
925
- let text = parts.filter(Boolean).join(" ");
926
- text = text.replace(/([\[(]) /g, "$1");
927
- text = text.replace(/ ([\])])/g, "$1");
928
- text = text.replace(/[\[(] *[\])]/g, "");
929
- text = text.replace(/\(([^|]*)\)/g, "$1", text);
930
- text = text.trim();
931
- return text;
932
- }
933
- _format_text(text) {
934
- if (text.includes("%(prog)")) {
935
- text = sub(text, { prog: this._prog });
936
- }
937
- let text_width = Math.max(this._width - this._current_indent, 11);
938
- let indent = " ".repeat(this._current_indent);
939
- return this._fill_text(text, text_width, indent) + "\n\n";
940
- }
941
- _format_action(action) {
942
- let help_position = Math.min(
943
- this._action_max_length + 2,
944
- this._max_help_position
945
- );
946
- let help_width = Math.max(this._width - help_position, 11);
947
- let action_width = help_position - this._current_indent - 2;
948
- let action_header = this._format_action_invocation(action);
949
- let indent_first;
950
- if (!action.help) {
951
- let tup = [this._current_indent, "", action_header];
952
- action_header = sub("%*s%s\n", ...tup);
953
- } else if (action_header.length <= action_width) {
954
- let tup = [this._current_indent, "", action_width, action_header];
955
- action_header = sub("%*s%-*s ", ...tup);
956
- indent_first = 0;
957
- } else {
958
- let tup = [this._current_indent, "", action_header];
959
- action_header = sub("%*s%s\n", ...tup);
960
- indent_first = help_position;
961
- }
962
- let parts = [action_header];
963
- if (action.help) {
964
- let help_text = this._expand_help(action);
965
- let help_lines = this._split_lines(help_text, help_width);
966
- parts.push(sub("%*s%s\n", indent_first, "", help_lines[0]));
967
- for (let line of help_lines.slice(1)) {
968
- parts.push(sub("%*s%s\n", help_position, "", line));
969
- }
970
- } else if (!action_header.endsWith("\n")) {
971
- parts.push("\n");
972
- }
973
- for (let subaction of this._iter_indented_subactions(action)) {
974
- parts.push(this._format_action(subaction));
975
- }
976
- return this._join_parts(parts);
977
- }
978
- _format_action_invocation(action) {
979
- if (!action.option_strings.length) {
980
- let default_value = this._get_default_metavar_for_positional(action);
981
- let metavar = this._metavar_formatter(action, default_value)(1)[0];
982
- return metavar;
983
- } else {
984
- let parts = [];
985
- if (action.nargs === 0) {
986
- parts = parts.concat(action.option_strings);
987
- } else {
988
- let default_value = this._get_default_metavar_for_optional(action);
989
- let args_string = this._format_args(action, default_value);
990
- for (let option_string of action.option_strings) {
991
- parts.push(sub("%s %s", option_string, args_string));
992
- }
993
- }
994
- return parts.join(", ");
995
- }
996
- }
997
- _metavar_formatter(action, default_metavar) {
998
- let result;
999
- if (action.metavar !== void 0) {
1000
- result = action.metavar;
1001
- } else if (action.choices !== void 0) {
1002
- let choice_strs = _choices_to_array(action.choices).map(String);
1003
- result = sub("{%s}", choice_strs.join(","));
1004
- } else {
1005
- result = default_metavar;
1006
- }
1007
- function format(tuple_size) {
1008
- if (Array.isArray(result)) {
1009
- return result;
1010
- } else {
1011
- return Array(tuple_size).fill(result);
1012
- }
1013
- }
1014
- return format;
1015
- }
1016
- _format_args(action, default_metavar) {
1017
- let get_metavar = this._metavar_formatter(action, default_metavar);
1018
- let result;
1019
- if (action.nargs === void 0) {
1020
- result = sub("%s", ...get_metavar(1));
1021
- } else if (action.nargs === OPTIONAL) {
1022
- result = sub("[%s]", ...get_metavar(1));
1023
- } else if (action.nargs === ZERO_OR_MORE) {
1024
- let metavar = get_metavar(1);
1025
- if (metavar.length === 2) {
1026
- result = sub("[%s [%s ...]]", ...metavar);
1027
- } else {
1028
- result = sub("[%s ...]", ...metavar);
1029
- }
1030
- } else if (action.nargs === ONE_OR_MORE) {
1031
- result = sub("%s [%s ...]", ...get_metavar(2));
1032
- } else if (action.nargs === REMAINDER) {
1033
- result = "...";
1034
- } else if (action.nargs === PARSER) {
1035
- result = sub("%s ...", ...get_metavar(1));
1036
- } else if (action.nargs === SUPPRESS) {
1037
- result = "";
1038
- } else {
1039
- let formats;
1040
- try {
1041
- formats = range(action.nargs).map(() => "%s");
1042
- } catch (err) {
1043
- throw new TypeError("invalid nargs value");
1044
- }
1045
- result = sub(formats.join(" "), ...get_metavar(action.nargs));
1046
- }
1047
- return result;
1048
- }
1049
- _expand_help(action) {
1050
- let params = Object.assign({ prog: this._prog }, action);
1051
- for (let name of Object.keys(params)) {
1052
- if (params[name] === SUPPRESS) {
1053
- delete params[name];
1054
- }
1055
- }
1056
- for (let name of Object.keys(params)) {
1057
- if (params[name] && params[name].name) {
1058
- params[name] = params[name].name;
1059
- }
1060
- }
1061
- if (params.choices !== void 0) {
1062
- let choices_str = _choices_to_array(params.choices).map(String).join(", ");
1063
- params.choices = choices_str;
1064
- }
1065
- for (let key of Object.keys(params)) {
1066
- let old_name = _to_legacy_name(key);
1067
- if (old_name !== key) {
1068
- params[old_name] = params[key];
1069
- }
1070
- }
1071
- return sub(this._get_help_string(action), params);
1072
- }
1073
- *_iter_indented_subactions(action) {
1074
- if (typeof action._get_subactions === "function") {
1075
- this._indent();
1076
- yield* action._get_subactions();
1077
- this._dedent();
1078
- }
1079
- }
1080
- _split_lines(text, width) {
1081
- text = text.replace(this._whitespace_matcher, " ").trim();
1082
- let textwrap = require_textwrap();
1083
- return textwrap.wrap(text, { width });
1084
- }
1085
- _fill_text(text, width, indent) {
1086
- text = text.replace(this._whitespace_matcher, " ").trim();
1087
- let textwrap = require_textwrap();
1088
- return textwrap.fill(text, {
1089
- width,
1090
- initial_indent: indent,
1091
- subsequent_indent: indent
1092
- });
1093
- }
1094
- _get_help_string(action) {
1095
- return action.help;
1096
- }
1097
- _get_default_metavar_for_optional(action) {
1098
- return action.dest.toUpperCase();
1099
- }
1100
- _get_default_metavar_for_positional(action) {
1101
- return action.dest;
1102
- }
1103
- }));
1104
- HelpFormatter.prototype._Section = _callable(class _Section {
1105
- constructor(formatter, parent, heading = void 0) {
1106
- this.formatter = formatter;
1107
- this.parent = parent;
1108
- this.heading = heading;
1109
- this.items = [];
1110
- }
1111
- format_help() {
1112
- if (this.parent !== void 0) {
1113
- this.formatter._indent();
1114
- }
1115
- let item_help = this.formatter._join_parts(this.items.map(([func, args]) => func.apply(null, args)));
1116
- if (this.parent !== void 0) {
1117
- this.formatter._dedent();
1118
- }
1119
- if (!item_help) {
1120
- return "";
1121
- }
1122
- let heading;
1123
- if (this.heading !== SUPPRESS && this.heading !== void 0) {
1124
- let current_indent = this.formatter._current_indent;
1125
- heading = sub("%*s%s:\n", current_indent, "", this.heading);
1126
- } else {
1127
- heading = "";
1128
- }
1129
- return this.formatter._join_parts(["\n", heading, item_help, "\n"]);
1130
- }
1131
- });
1132
- var RawDescriptionHelpFormatter = _camelcase_alias(_callable(class RawDescriptionHelpFormatter extends HelpFormatter {
1133
- /*
1134
- * Help message formatter which retains any formatting in descriptions.
1135
- *
1136
- * Only the name of this class is considered a public API. All the methods
1137
- * provided by the class are considered an implementation detail.
1138
- */
1139
- _fill_text(text, width, indent) {
1140
- return splitlines(text, true).map((line) => indent + line).join("");
1141
- }
1142
- }));
1143
- var RawTextHelpFormatter = _camelcase_alias(_callable(class RawTextHelpFormatter extends RawDescriptionHelpFormatter {
1144
- /*
1145
- * Help message formatter which retains formatting of all help text.
1146
- *
1147
- * Only the name of this class is considered a public API. All the methods
1148
- * provided by the class are considered an implementation detail.
1149
- */
1150
- _split_lines(text) {
1151
- return splitlines(text);
1152
- }
1153
- }));
1154
- var ArgumentDefaultsHelpFormatter = _camelcase_alias(_callable(class ArgumentDefaultsHelpFormatter extends HelpFormatter {
1155
- /*
1156
- * Help message formatter which adds default values to argument help.
1157
- *
1158
- * Only the name of this class is considered a public API. All the methods
1159
- * provided by the class are considered an implementation detail.
1160
- */
1161
- _get_help_string(action) {
1162
- let help = action.help;
1163
- if (!action.help.includes("%(default)") && !action.help.includes("%(defaultValue)")) {
1164
- if (action.default !== SUPPRESS) {
1165
- let defaulting_nargs = [OPTIONAL, ZERO_OR_MORE];
1166
- if (action.option_strings.length || defaulting_nargs.includes(action.nargs)) {
1167
- help += " (default: %(default)s)";
1168
- }
1169
- }
1170
- }
1171
- return help;
1172
- }
1173
- }));
1174
- var MetavarTypeHelpFormatter = _camelcase_alias(_callable(class MetavarTypeHelpFormatter extends HelpFormatter {
1175
- /*
1176
- * Help message formatter which uses the argument 'type' as the default
1177
- * metavar value (instead of the argument 'dest')
1178
- *
1179
- * Only the name of this class is considered a public API. All the methods
1180
- * provided by the class are considered an implementation detail.
1181
- */
1182
- _get_default_metavar_for_optional(action) {
1183
- return typeof action.type === "function" ? action.type.name : action.type;
1184
- }
1185
- _get_default_metavar_for_positional(action) {
1186
- return typeof action.type === "function" ? action.type.name : action.type;
1187
- }
1188
- }));
1189
- function _get_action_name(argument) {
1190
- if (argument === void 0) {
1191
- return void 0;
1192
- } else if (argument.option_strings.length) {
1193
- return argument.option_strings.join("/");
1194
- } else if (![void 0, SUPPRESS].includes(argument.metavar)) {
1195
- return argument.metavar;
1196
- } else if (![void 0, SUPPRESS].includes(argument.dest)) {
1197
- return argument.dest;
1198
- } else {
1199
- return void 0;
1200
- }
1201
- }
1202
- var ArgumentError = _callable(class ArgumentError extends Error {
1203
- /*
1204
- * An error from creating or using an argument (optional or positional).
1205
- *
1206
- * The string value of this exception is the message, augmented with
1207
- * information about the argument that caused it.
1208
- */
1209
- constructor(argument, message) {
1210
- super();
1211
- this.name = "ArgumentError";
1212
- this._argument_name = _get_action_name(argument);
1213
- this._message = message;
1214
- this.message = this.str();
1215
- }
1216
- str() {
1217
- let format;
1218
- if (this._argument_name === void 0) {
1219
- format = "%(message)s";
1220
- } else {
1221
- format = "argument %(argument_name)s: %(message)s";
1222
- }
1223
- return sub(format, {
1224
- message: this._message,
1225
- argument_name: this._argument_name
1226
- });
1227
- }
1228
- });
1229
- var ArgumentTypeError = _callable(class ArgumentTypeError extends Error {
1230
- /*
1231
- * An error from trying to convert a command line string to a type.
1232
- */
1233
- constructor(message) {
1234
- super(message);
1235
- this.name = "ArgumentTypeError";
1236
- }
1237
- });
1238
- var Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(Function) {
1239
- /*
1240
- * Information about how to convert command line strings to Python objects.
1241
- *
1242
- * Action objects are used by an ArgumentParser to represent the information
1243
- * needed to parse a single argument from one or more strings from the
1244
- * command line. The keyword arguments to the Action constructor are also
1245
- * all attributes of Action instances.
1246
- *
1247
- * Keyword Arguments:
1248
- *
1249
- * - option_strings -- A list of command-line option strings which
1250
- * should be associated with this action.
1251
- *
1252
- * - dest -- The name of the attribute to hold the created object(s)
1253
- *
1254
- * - nargs -- The number of command-line arguments that should be
1255
- * consumed. By default, one argument will be consumed and a single
1256
- * value will be produced. Other values include:
1257
- * - N (an integer) consumes N arguments (and produces a list)
1258
- * - '?' consumes zero or one arguments
1259
- * - '*' consumes zero or more arguments (and produces a list)
1260
- * - '+' consumes one or more arguments (and produces a list)
1261
- * Note that the difference between the default and nargs=1 is that
1262
- * with the default, a single value will be produced, while with
1263
- * nargs=1, a list containing a single value will be produced.
1264
- *
1265
- * - const -- The value to be produced if the option is specified and the
1266
- * option uses an action that takes no values.
1267
- *
1268
- * - default -- The value to be produced if the option is not specified.
1269
- *
1270
- * - type -- A callable that accepts a single string argument, and
1271
- * returns the converted value. The standard Python types str, int,
1272
- * float, and complex are useful examples of such callables. If None,
1273
- * str is used.
1274
- *
1275
- * - choices -- A container of values that should be allowed. If not None,
1276
- * after a command-line argument has been converted to the appropriate
1277
- * type, an exception will be raised if it is not a member of this
1278
- * collection.
1279
- *
1280
- * - required -- True if the action must always be specified at the
1281
- * command line. This is only meaningful for optional command-line
1282
- * arguments.
1283
- *
1284
- * - help -- The help string describing the argument.
1285
- *
1286
- * - metavar -- The name to be used for the option's argument with the
1287
- * help string. If None, the 'dest' value will be used as the name.
1288
- */
1289
- constructor() {
1290
- let [
1291
- option_strings,
1292
- dest,
1293
- nargs,
1294
- const_value,
1295
- default_value,
1296
- type,
1297
- choices,
1298
- required,
1299
- help,
1300
- metavar
1301
- ] = _parse_opts(arguments, {
1302
- option_strings: no_default,
1303
- dest: no_default,
1304
- nargs: void 0,
1305
- const: void 0,
1306
- default: void 0,
1307
- type: void 0,
1308
- choices: void 0,
1309
- required: false,
1310
- help: void 0,
1311
- metavar: void 0
1312
- });
1313
- super("return arguments.callee.call.apply(arguments.callee, arguments)");
1314
- this.option_strings = option_strings;
1315
- this.dest = dest;
1316
- this.nargs = nargs;
1317
- this.const = const_value;
1318
- this.default = default_value;
1319
- this.type = type;
1320
- this.choices = choices;
1321
- this.required = required;
1322
- this.help = help;
1323
- this.metavar = metavar;
1324
- }
1325
- _get_kwargs() {
1326
- let names = [
1327
- "option_strings",
1328
- "dest",
1329
- "nargs",
1330
- "const",
1331
- "default",
1332
- "type",
1333
- "choices",
1334
- "help",
1335
- "metavar"
1336
- ];
1337
- return names.map((name) => [name, getattr(this, name)]);
1338
- }
1339
- format_usage() {
1340
- return this.option_strings[0];
1341
- }
1342
- call() {
1343
- throw new Error(".call() not defined");
1344
- }
1345
- }));
1346
- var BooleanOptionalAction = _camelcase_alias(_callable(class BooleanOptionalAction extends Action {
1347
- constructor() {
1348
- let [
1349
- option_strings,
1350
- dest,
1351
- default_value,
1352
- type,
1353
- choices,
1354
- required,
1355
- help,
1356
- metavar
1357
- ] = _parse_opts(arguments, {
1358
- option_strings: no_default,
1359
- dest: no_default,
1360
- default: void 0,
1361
- type: void 0,
1362
- choices: void 0,
1363
- required: false,
1364
- help: void 0,
1365
- metavar: void 0
1366
- });
1367
- let _option_strings = [];
1368
- for (let option_string of option_strings) {
1369
- _option_strings.push(option_string);
1370
- if (option_string.startsWith("--")) {
1371
- option_string = "--no-" + option_string.slice(2);
1372
- _option_strings.push(option_string);
1373
- }
1374
- }
1375
- if (help !== void 0 && default_value !== void 0) {
1376
- help += ` (default: ${default_value})`;
1377
- }
1378
- super({
1379
- option_strings: _option_strings,
1380
- dest,
1381
- nargs: 0,
1382
- default: default_value,
1383
- type,
1384
- choices,
1385
- required,
1386
- help,
1387
- metavar
1388
- });
1389
- }
1390
- call(parser, namespace, values, option_string = void 0) {
1391
- if (this.option_strings.includes(option_string)) {
1392
- setattr(namespace, this.dest, !option_string.startsWith("--no-"));
1393
- }
1394
- }
1395
- format_usage() {
1396
- return this.option_strings.join(" | ");
1397
- }
1398
- }));
1399
- var _StoreAction = _callable(class _StoreAction extends Action {
1400
- constructor() {
1401
- let [
1402
- option_strings,
1403
- dest,
1404
- nargs,
1405
- const_value,
1406
- default_value,
1407
- type,
1408
- choices,
1409
- required,
1410
- help,
1411
- metavar
1412
- ] = _parse_opts(arguments, {
1413
- option_strings: no_default,
1414
- dest: no_default,
1415
- nargs: void 0,
1416
- const: void 0,
1417
- default: void 0,
1418
- type: void 0,
1419
- choices: void 0,
1420
- required: false,
1421
- help: void 0,
1422
- metavar: void 0
1423
- });
1424
- if (nargs === 0) {
1425
- throw new TypeError("nargs for store actions must be != 0; if you have nothing to store, actions such as store true or store const may be more appropriate");
1426
- }
1427
- if (const_value !== void 0 && nargs !== OPTIONAL) {
1428
- throw new TypeError(sub("nargs must be %r to supply const", OPTIONAL));
1429
- }
1430
- super({
1431
- option_strings,
1432
- dest,
1433
- nargs,
1434
- const: const_value,
1435
- default: default_value,
1436
- type,
1437
- choices,
1438
- required,
1439
- help,
1440
- metavar
1441
- });
1442
- }
1443
- call(parser, namespace, values) {
1444
- setattr(namespace, this.dest, values);
1445
- }
1446
- });
1447
- var _StoreConstAction = _callable(class _StoreConstAction extends Action {
1448
- constructor() {
1449
- let [
1450
- option_strings,
1451
- dest,
1452
- const_value,
1453
- default_value,
1454
- required,
1455
- help
1456
- //, metavar
1457
- ] = _parse_opts(arguments, {
1458
- option_strings: no_default,
1459
- dest: no_default,
1460
- const: no_default,
1461
- default: void 0,
1462
- required: false,
1463
- help: void 0,
1464
- metavar: void 0
1465
- });
1466
- super({
1467
- option_strings,
1468
- dest,
1469
- nargs: 0,
1470
- const: const_value,
1471
- default: default_value,
1472
- required,
1473
- help
1474
- });
1475
- }
1476
- call(parser, namespace) {
1477
- setattr(namespace, this.dest, this.const);
1478
- }
1479
- });
1480
- var _StoreTrueAction = _callable(class _StoreTrueAction extends _StoreConstAction {
1481
- constructor() {
1482
- let [
1483
- option_strings,
1484
- dest,
1485
- default_value,
1486
- required,
1487
- help
1488
- ] = _parse_opts(arguments, {
1489
- option_strings: no_default,
1490
- dest: no_default,
1491
- default: false,
1492
- required: false,
1493
- help: void 0
1494
- });
1495
- super({
1496
- option_strings,
1497
- dest,
1498
- const: true,
1499
- default: default_value,
1500
- required,
1501
- help
1502
- });
1503
- }
1504
- });
1505
- var _StoreFalseAction = _callable(class _StoreFalseAction extends _StoreConstAction {
1506
- constructor() {
1507
- let [
1508
- option_strings,
1509
- dest,
1510
- default_value,
1511
- required,
1512
- help
1513
- ] = _parse_opts(arguments, {
1514
- option_strings: no_default,
1515
- dest: no_default,
1516
- default: true,
1517
- required: false,
1518
- help: void 0
1519
- });
1520
- super({
1521
- option_strings,
1522
- dest,
1523
- const: false,
1524
- default: default_value,
1525
- required,
1526
- help
1527
- });
1528
- }
1529
- });
1530
- var _AppendAction = _callable(class _AppendAction extends Action {
1531
- constructor() {
1532
- let [
1533
- option_strings,
1534
- dest,
1535
- nargs,
1536
- const_value,
1537
- default_value,
1538
- type,
1539
- choices,
1540
- required,
1541
- help,
1542
- metavar
1543
- ] = _parse_opts(arguments, {
1544
- option_strings: no_default,
1545
- dest: no_default,
1546
- nargs: void 0,
1547
- const: void 0,
1548
- default: void 0,
1549
- type: void 0,
1550
- choices: void 0,
1551
- required: false,
1552
- help: void 0,
1553
- metavar: void 0
1554
- });
1555
- if (nargs === 0) {
1556
- throw new TypeError("nargs for append actions must be != 0; if arg strings are not supplying the value to append, the append const action may be more appropriate");
1557
- }
1558
- if (const_value !== void 0 && nargs !== OPTIONAL) {
1559
- throw new TypeError(sub("nargs must be %r to supply const", OPTIONAL));
1560
- }
1561
- super({
1562
- option_strings,
1563
- dest,
1564
- nargs,
1565
- const: const_value,
1566
- default: default_value,
1567
- type,
1568
- choices,
1569
- required,
1570
- help,
1571
- metavar
1572
- });
1573
- }
1574
- call(parser, namespace, values) {
1575
- let items = getattr(namespace, this.dest, void 0);
1576
- items = _copy_items(items);
1577
- items.push(values);
1578
- setattr(namespace, this.dest, items);
1579
- }
1580
- });
1581
- var _AppendConstAction = _callable(class _AppendConstAction extends Action {
1582
- constructor() {
1583
- let [
1584
- option_strings,
1585
- dest,
1586
- const_value,
1587
- default_value,
1588
- required,
1589
- help,
1590
- metavar
1591
- ] = _parse_opts(arguments, {
1592
- option_strings: no_default,
1593
- dest: no_default,
1594
- const: no_default,
1595
- default: void 0,
1596
- required: false,
1597
- help: void 0,
1598
- metavar: void 0
1599
- });
1600
- super({
1601
- option_strings,
1602
- dest,
1603
- nargs: 0,
1604
- const: const_value,
1605
- default: default_value,
1606
- required,
1607
- help,
1608
- metavar
1609
- });
1610
- }
1611
- call(parser, namespace) {
1612
- let items = getattr(namespace, this.dest, void 0);
1613
- items = _copy_items(items);
1614
- items.push(this.const);
1615
- setattr(namespace, this.dest, items);
1616
- }
1617
- });
1618
- var _CountAction = _callable(class _CountAction extends Action {
1619
- constructor() {
1620
- let [
1621
- option_strings,
1622
- dest,
1623
- default_value,
1624
- required,
1625
- help
1626
- ] = _parse_opts(arguments, {
1627
- option_strings: no_default,
1628
- dest: no_default,
1629
- default: void 0,
1630
- required: false,
1631
- help: void 0
1632
- });
1633
- super({
1634
- option_strings,
1635
- dest,
1636
- nargs: 0,
1637
- default: default_value,
1638
- required,
1639
- help
1640
- });
1641
- }
1642
- call(parser, namespace) {
1643
- let count = getattr(namespace, this.dest, void 0);
1644
- if (count === void 0) {
1645
- count = 0;
1646
- }
1647
- setattr(namespace, this.dest, count + 1);
1648
- }
1649
- });
1650
- var _HelpAction = _callable(class _HelpAction extends Action {
1651
- constructor() {
1652
- let [
1653
- option_strings,
1654
- dest,
1655
- default_value,
1656
- help
1657
- ] = _parse_opts(arguments, {
1658
- option_strings: no_default,
1659
- dest: SUPPRESS,
1660
- default: SUPPRESS,
1661
- help: void 0
1662
- });
1663
- super({
1664
- option_strings,
1665
- dest,
1666
- default: default_value,
1667
- nargs: 0,
1668
- help
1669
- });
1670
- }
1671
- call(parser) {
1672
- parser.print_help();
1673
- parser.exit();
1674
- }
1675
- });
1676
- var _VersionAction = _callable(class _VersionAction extends Action {
1677
- constructor() {
1678
- let [
1679
- option_strings,
1680
- version2,
1681
- dest,
1682
- default_value,
1683
- help
1684
- ] = _parse_opts(arguments, {
1685
- option_strings: no_default,
1686
- version: void 0,
1687
- dest: SUPPRESS,
1688
- default: SUPPRESS,
1689
- help: "show program's version number and exit"
1690
- });
1691
- super({
1692
- option_strings,
1693
- dest,
1694
- default: default_value,
1695
- nargs: 0,
1696
- help
1697
- });
1698
- this.version = version2;
1699
- }
1700
- call(parser) {
1701
- let version2 = this.version;
1702
- if (version2 === void 0) {
1703
- version2 = parser.version;
1704
- }
1705
- let formatter = parser._get_formatter();
1706
- formatter.add_text(version2);
1707
- parser._print_message(formatter.format_help(), process.stdout);
1708
- parser.exit();
1709
- }
1710
- });
1711
- var _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction extends Action {
1712
- constructor() {
1713
- let [
1714
- option_strings,
1715
- prog,
1716
- parser_class,
1717
- dest,
1718
- required,
1719
- help,
1720
- metavar
1721
- ] = _parse_opts(arguments, {
1722
- option_strings: no_default,
1723
- prog: no_default,
1724
- parser_class: no_default,
1725
- dest: SUPPRESS,
1726
- required: false,
1727
- help: void 0,
1728
- metavar: void 0
1729
- });
1730
- let name_parser_map = {};
1731
- super({
1732
- option_strings,
1733
- dest,
1734
- nargs: PARSER,
1735
- choices: name_parser_map,
1736
- required,
1737
- help,
1738
- metavar
1739
- });
1740
- this._prog_prefix = prog;
1741
- this._parser_class = parser_class;
1742
- this._name_parser_map = name_parser_map;
1743
- this._choices_actions = [];
1744
- }
1745
- add_parser() {
1746
- let [
1747
- name,
1748
- kwargs
1749
- ] = _parse_opts(arguments, {
1750
- name: no_default,
1751
- "**kwargs": no_default
1752
- });
1753
- if (kwargs.prog === void 0) {
1754
- kwargs.prog = sub("%s %s", this._prog_prefix, name);
1755
- }
1756
- let aliases = getattr(kwargs, "aliases", []);
1757
- delete kwargs.aliases;
1758
- if ("help" in kwargs) {
1759
- let help = kwargs.help;
1760
- delete kwargs.help;
1761
- let choice_action = this._ChoicesPseudoAction(name, aliases, help);
1762
- this._choices_actions.push(choice_action);
1763
- }
1764
- let parser = new this._parser_class(kwargs);
1765
- this._name_parser_map[name] = parser;
1766
- for (let alias of aliases) {
1767
- this._name_parser_map[alias] = parser;
1768
- }
1769
- return parser;
1770
- }
1771
- _get_subactions() {
1772
- return this._choices_actions;
1773
- }
1774
- call(parser, namespace, values) {
1775
- let parser_name = values[0];
1776
- let arg_strings = values.slice(1);
1777
- if (this.dest !== SUPPRESS) {
1778
- setattr(namespace, this.dest, parser_name);
1779
- }
1780
- if (hasattr(this._name_parser_map, parser_name)) {
1781
- parser = this._name_parser_map[parser_name];
1782
- } else {
1783
- let args = {
1784
- parser_name,
1785
- choices: this._name_parser_map.join(", ")
1786
- };
1787
- let msg = sub("unknown parser %(parser_name)r (choices: %(choices)s)", args);
1788
- throw new ArgumentError(this, msg);
1789
- }
1790
- let subnamespace;
1791
- [subnamespace, arg_strings] = parser.parse_known_args(arg_strings, void 0);
1792
- for (let [key, value] of Object.entries(subnamespace)) {
1793
- setattr(namespace, key, value);
1794
- }
1795
- if (arg_strings.length) {
1796
- setdefault(namespace, _UNRECOGNIZED_ARGS_ATTR, []);
1797
- getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).push(...arg_strings);
1798
- }
1799
- }
1800
- }));
1801
- _SubParsersAction.prototype._ChoicesPseudoAction = _callable(class _ChoicesPseudoAction extends Action {
1802
- constructor(name, aliases, help) {
1803
- let metavar = name, dest = name;
1804
- if (aliases.length) {
1805
- metavar += sub(" (%s)", aliases.join(", "));
1806
- }
1807
- super({ option_strings: [], dest, help, metavar });
1808
- }
1809
- });
1810
- var _ExtendAction = _callable(class _ExtendAction extends _AppendAction {
1811
- call(parser, namespace, values) {
1812
- let items = getattr(namespace, this.dest, void 0);
1813
- items = _copy_items(items);
1814
- items = items.concat(values);
1815
- setattr(namespace, this.dest, items);
1816
- }
1817
- });
1818
- var FileType = _callable(class FileType extends Function {
1819
- /*
1820
- * Factory for creating file object types
1821
- *
1822
- * Instances of FileType are typically passed as type= arguments to the
1823
- * ArgumentParser add_argument() method.
1824
- *
1825
- * Keyword Arguments:
1826
- * - mode -- A string indicating how the file is to be opened. Accepts the
1827
- * same values as the builtin open() function.
1828
- * - bufsize -- The file's desired buffer size. Accepts the same values as
1829
- * the builtin open() function.
1830
- * - encoding -- The file's encoding. Accepts the same values as the
1831
- * builtin open() function.
1832
- * - errors -- A string indicating how encoding and decoding errors are to
1833
- * be handled. Accepts the same value as the builtin open() function.
1834
- */
1835
- constructor() {
1836
- let [
1837
- flags,
1838
- encoding,
1839
- mode,
1840
- autoClose,
1841
- emitClose,
1842
- start,
1843
- end,
1844
- highWaterMark,
1845
- fs9
1846
- ] = _parse_opts(arguments, {
1847
- flags: "r",
1848
- encoding: void 0,
1849
- mode: void 0,
1850
- // 0o666
1851
- autoClose: void 0,
1852
- // true
1853
- emitClose: void 0,
1854
- // false
1855
- start: void 0,
1856
- // 0
1857
- end: void 0,
1858
- // Infinity
1859
- highWaterMark: void 0,
1860
- // 64 * 1024
1861
- fs: void 0
1862
- });
1863
- super("return arguments.callee.call.apply(arguments.callee, arguments)");
1864
- Object.defineProperty(this, "name", {
1865
- get() {
1866
- return sub("FileType(%r)", flags);
1867
- }
1868
- });
1869
- this._flags = flags;
1870
- this._options = {};
1871
- if (encoding !== void 0) this._options.encoding = encoding;
1872
- if (mode !== void 0) this._options.mode = mode;
1873
- if (autoClose !== void 0) this._options.autoClose = autoClose;
1874
- if (emitClose !== void 0) this._options.emitClose = emitClose;
1875
- if (start !== void 0) this._options.start = start;
1876
- if (end !== void 0) this._options.end = end;
1877
- if (highWaterMark !== void 0) this._options.highWaterMark = highWaterMark;
1878
- if (fs9 !== void 0) this._options.fs = fs9;
1879
- }
1880
- call(string) {
1881
- if (string === "-") {
1882
- if (this._flags.includes("r")) {
1883
- return process.stdin;
1884
- } else if (this._flags.includes("w")) {
1885
- return process.stdout;
1886
- } else {
1887
- let msg = sub('argument "-" with mode %r', this._flags);
1888
- throw new TypeError(msg);
1889
- }
1890
- }
1891
- let fd;
1892
- try {
1893
- fd = fs8.openSync(string, this._flags, this._options.mode);
1894
- } catch (e) {
1895
- let args = { filename: string, error: e.message };
1896
- let message = "can't open '%(filename)s': %(error)s";
1897
- throw new ArgumentTypeError(sub(message, args));
1898
- }
1899
- let options = Object.assign({ fd, flags: this._flags }, this._options);
1900
- if (this._flags.includes("r")) {
1901
- return fs8.createReadStream(void 0, options);
1902
- } else if (this._flags.includes("w")) {
1903
- return fs8.createWriteStream(void 0, options);
1904
- } else {
1905
- let msg = sub('argument "%s" with mode %r', string, this._flags);
1906
- throw new TypeError(msg);
1907
- }
1908
- }
1909
- [util.inspect.custom]() {
1910
- let args = [this._flags];
1911
- let kwargs = Object.entries(this._options).map(([k2, v2]) => {
1912
- if (k2 === "mode") v2 = { value: v2, [util.inspect.custom]() {
1913
- return "0o" + this.value.toString(8);
1914
- } };
1915
- return [k2, v2];
1916
- });
1917
- let args_str = [].concat(args.filter((arg) => arg !== -1).map(repr)).concat(kwargs.filter(([, arg]) => arg !== void 0).map(([kw, arg]) => sub("%s=%r", kw, arg))).join(", ");
1918
- return sub("%s(%s)", this.constructor.name, args_str);
1919
- }
1920
- toString() {
1921
- return this[util.inspect.custom]();
1922
- }
1923
- });
1924
- var Namespace = _callable(class Namespace extends _AttributeHolder() {
1925
- /*
1926
- * Simple object for storing attributes.
1927
- *
1928
- * Implements equality by attribute names and values, and provides a simple
1929
- * string representation.
1930
- */
1931
- constructor(options = {}) {
1932
- super();
1933
- Object.assign(this, options);
1934
- }
1935
- });
1936
- Namespace.prototype[Symbol.toStringTag] = void 0;
1937
- var _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer {
1938
- constructor() {
1939
- let [
1940
- description,
1941
- prefix_chars,
1942
- argument_default,
1943
- conflict_handler
1944
- ] = _parse_opts(arguments, {
1945
- description: no_default,
1946
- prefix_chars: no_default,
1947
- argument_default: no_default,
1948
- conflict_handler: no_default
1949
- });
1950
- this.description = description;
1951
- this.argument_default = argument_default;
1952
- this.prefix_chars = prefix_chars;
1953
- this.conflict_handler = conflict_handler;
1954
- this._registries = {};
1955
- this.register("action", void 0, _StoreAction);
1956
- this.register("action", "store", _StoreAction);
1957
- this.register("action", "store_const", _StoreConstAction);
1958
- this.register("action", "store_true", _StoreTrueAction);
1959
- this.register("action", "store_false", _StoreFalseAction);
1960
- this.register("action", "append", _AppendAction);
1961
- this.register("action", "append_const", _AppendConstAction);
1962
- this.register("action", "count", _CountAction);
1963
- this.register("action", "help", _HelpAction);
1964
- this.register("action", "version", _VersionAction);
1965
- this.register("action", "parsers", _SubParsersAction);
1966
- this.register("action", "extend", _ExtendAction);
1967
- ["storeConst", "storeTrue", "storeFalse", "appendConst"].forEach((old_name) => {
1968
- let new_name = _to_new_name(old_name);
1969
- this.register("action", old_name, util.deprecate(
1970
- this._registry_get("action", new_name),
1971
- sub('{action: "%s"} is renamed to {action: "%s"}', old_name, new_name)
1972
- ));
1973
- });
1974
- this._get_handler();
1975
- this._actions = [];
1976
- this._option_string_actions = {};
1977
- this._action_groups = [];
1978
- this._mutually_exclusive_groups = [];
1979
- this._defaults = {};
1980
- this._negative_number_matcher = /^-\d+$|^-\d*\.\d+$/;
1981
- this._has_negative_number_optionals = [];
1982
- }
1983
- // ====================
1984
- // Registration methods
1985
- // ====================
1986
- register(registry_name, value, object) {
1987
- let registry = setdefault(this._registries, registry_name, {});
1988
- registry[value] = object;
1989
- }
1990
- _registry_get(registry_name, value, default_value = void 0) {
1991
- return getattr(this._registries[registry_name], value, default_value);
1992
- }
1993
- // ==================================
1994
- // Namespace default accessor methods
1995
- // ==================================
1996
- set_defaults(kwargs) {
1997
- Object.assign(this._defaults, kwargs);
1998
- for (let action of this._actions) {
1999
- if (action.dest in kwargs) {
2000
- action.default = kwargs[action.dest];
2001
- }
2002
- }
2003
- }
2004
- get_default(dest) {
2005
- for (let action of this._actions) {
2006
- if (action.dest === dest && action.default !== void 0) {
2007
- return action.default;
2008
- }
2009
- }
2010
- return this._defaults[dest];
2011
- }
2012
- // =======================
2013
- // Adding argument actions
2014
- // =======================
2015
- add_argument() {
2016
- let [
2017
- args,
2018
- kwargs
2019
- ] = _parse_opts(arguments, {
2020
- "*args": no_default,
2021
- "**kwargs": no_default
2022
- });
2023
- if (args.length === 1 && Array.isArray(args[0])) {
2024
- args = args[0];
2025
- deprecate(
2026
- "argument-array",
2027
- sub("use add_argument(%(args)s, {...}) instead of add_argument([ %(args)s ], { ... })", {
2028
- args: args.map(repr).join(", ")
2029
- })
2030
- );
2031
- }
2032
- let chars = this.prefix_chars;
2033
- if (!args.length || args.length === 1 && !chars.includes(args[0][0])) {
2034
- if (args.length && "dest" in kwargs) {
2035
- throw new TypeError("dest supplied twice for positional argument");
2036
- }
2037
- kwargs = this._get_positional_kwargs(...args, kwargs);
2038
- } else {
2039
- kwargs = this._get_optional_kwargs(...args, kwargs);
2040
- }
2041
- if (!("default" in kwargs)) {
2042
- let dest = kwargs.dest;
2043
- if (dest in this._defaults) {
2044
- kwargs.default = this._defaults[dest];
2045
- } else if (this.argument_default !== void 0) {
2046
- kwargs.default = this.argument_default;
2047
- }
2048
- }
2049
- let action_class = this._pop_action_class(kwargs);
2050
- if (typeof action_class !== "function") {
2051
- throw new TypeError(sub('unknown action "%s"', action_class));
2052
- }
2053
- let action = new action_class(kwargs);
2054
- let type_func = this._registry_get("type", action.type, action.type);
2055
- if (typeof type_func !== "function") {
2056
- throw new TypeError(sub("%r is not callable", type_func));
2057
- }
2058
- if (type_func === FileType) {
2059
- throw new TypeError(sub("%r is a FileType class object, instance of it must be passed", type_func));
2060
- }
2061
- if ("_get_formatter" in this) {
2062
- try {
2063
- this._get_formatter()._format_args(action, void 0);
2064
- } catch (err) {
2065
- if (err instanceof TypeError && err.message !== "invalid nargs value") {
2066
- throw new TypeError("length of metavar tuple does not match nargs");
2067
- } else {
2068
- throw err;
2069
- }
2070
- }
2071
- }
2072
- return this._add_action(action);
2073
- }
2074
- add_argument_group() {
2075
- let group = _ArgumentGroup(this, ...arguments);
2076
- this._action_groups.push(group);
2077
- return group;
2078
- }
2079
- add_mutually_exclusive_group() {
2080
- let group = _MutuallyExclusiveGroup(this, ...arguments);
2081
- this._mutually_exclusive_groups.push(group);
2082
- return group;
2083
- }
2084
- _add_action(action) {
2085
- this._check_conflict(action);
2086
- this._actions.push(action);
2087
- action.container = this;
2088
- for (let option_string of action.option_strings) {
2089
- this._option_string_actions[option_string] = action;
2090
- }
2091
- for (let option_string of action.option_strings) {
2092
- if (this._negative_number_matcher.test(option_string)) {
2093
- if (!this._has_negative_number_optionals.length) {
2094
- this._has_negative_number_optionals.push(true);
2095
- }
2096
- }
2097
- }
2098
- return action;
2099
- }
2100
- _remove_action(action) {
2101
- _array_remove(this._actions, action);
2102
- }
2103
- _add_container_actions(container) {
2104
- let title_group_map = {};
2105
- for (let group of this._action_groups) {
2106
- if (group.title in title_group_map) {
2107
- let msg = "cannot merge actions - two groups are named %r";
2108
- throw new TypeError(sub(msg, group.title));
2109
- }
2110
- title_group_map[group.title] = group;
2111
- }
2112
- let group_map = /* @__PURE__ */ new Map();
2113
- for (let group of container._action_groups) {
2114
- if (!(group.title in title_group_map)) {
2115
- title_group_map[group.title] = this.add_argument_group({
2116
- title: group.title,
2117
- description: group.description,
2118
- conflict_handler: group.conflict_handler
2119
- });
2120
- }
2121
- for (let action of group._group_actions) {
2122
- group_map.set(action, title_group_map[group.title]);
2123
- }
2124
- }
2125
- for (let group of container._mutually_exclusive_groups) {
2126
- let mutex_group = this.add_mutually_exclusive_group({
2127
- required: group.required
2128
- });
2129
- for (let action of group._group_actions) {
2130
- group_map.set(action, mutex_group);
2131
- }
2132
- }
2133
- for (let action of container._actions) {
2134
- group_map.get(action)._add_action(action);
2135
- }
2136
- }
2137
- _get_positional_kwargs() {
2138
- let [
2139
- dest,
2140
- kwargs
2141
- ] = _parse_opts(arguments, {
2142
- dest: no_default,
2143
- "**kwargs": no_default
2144
- });
2145
- if ("required" in kwargs) {
2146
- let msg = "'required' is an invalid argument for positionals";
2147
- throw new TypeError(msg);
2148
- }
2149
- if (![OPTIONAL, ZERO_OR_MORE].includes(kwargs.nargs)) {
2150
- kwargs.required = true;
2151
- }
2152
- if (kwargs.nargs === ZERO_OR_MORE && !("default" in kwargs)) {
2153
- kwargs.required = true;
2154
- }
2155
- return Object.assign(kwargs, { dest, option_strings: [] });
2156
- }
2157
- _get_optional_kwargs() {
2158
- let [
2159
- args,
2160
- kwargs
2161
- ] = _parse_opts(arguments, {
2162
- "*args": no_default,
2163
- "**kwargs": no_default
2164
- });
2165
- let option_strings = [];
2166
- let long_option_strings = [];
2167
- let option_string;
2168
- for (option_string of args) {
2169
- if (!this.prefix_chars.includes(option_string[0])) {
2170
- let args2 = {
2171
- option: option_string,
2172
- prefix_chars: this.prefix_chars
2173
- };
2174
- let msg = "invalid option string %(option)r: must start with a character %(prefix_chars)r";
2175
- throw new TypeError(sub(msg, args2));
2176
- }
2177
- option_strings.push(option_string);
2178
- if (option_string.length > 1 && this.prefix_chars.includes(option_string[1])) {
2179
- long_option_strings.push(option_string);
2180
- }
2181
- }
2182
- let dest = kwargs.dest;
2183
- delete kwargs.dest;
2184
- if (dest === void 0) {
2185
- let dest_option_string;
2186
- if (long_option_strings.length) {
2187
- dest_option_string = long_option_strings[0];
2188
- } else {
2189
- dest_option_string = option_strings[0];
2190
- }
2191
- dest = _string_lstrip(dest_option_string, this.prefix_chars);
2192
- if (!dest) {
2193
- let msg = "dest= is required for options like %r";
2194
- throw new TypeError(sub(msg, option_string));
2195
- }
2196
- dest = dest.replace(/-/g, "_");
2197
- }
2198
- return Object.assign(kwargs, { dest, option_strings });
2199
- }
2200
- _pop_action_class(kwargs, default_value = void 0) {
2201
- let action = getattr(kwargs, "action", default_value);
2202
- delete kwargs.action;
2203
- return this._registry_get("action", action, action);
2204
- }
2205
- _get_handler() {
2206
- let handler_func_name = sub("_handle_conflict_%s", this.conflict_handler);
2207
- if (typeof this[handler_func_name] === "function") {
2208
- return this[handler_func_name];
2209
- } else {
2210
- let msg = "invalid conflict_resolution value: %r";
2211
- throw new TypeError(sub(msg, this.conflict_handler));
2212
- }
2213
- }
2214
- _check_conflict(action) {
2215
- let confl_optionals = [];
2216
- for (let option_string of action.option_strings) {
2217
- if (hasattr(this._option_string_actions, option_string)) {
2218
- let confl_optional = this._option_string_actions[option_string];
2219
- confl_optionals.push([option_string, confl_optional]);
2220
- }
2221
- }
2222
- if (confl_optionals.length) {
2223
- let conflict_handler = this._get_handler();
2224
- conflict_handler.call(this, action, confl_optionals);
2225
- }
2226
- }
2227
- _handle_conflict_error(action, conflicting_actions) {
2228
- let message = conflicting_actions.length === 1 ? "conflicting option string: %s" : "conflicting option strings: %s";
2229
- let conflict_string = conflicting_actions.map(([
2230
- option_string
2231
- /*, action*/
2232
- ]) => option_string).join(", ");
2233
- throw new ArgumentError(action, sub(message, conflict_string));
2234
- }
2235
- _handle_conflict_resolve(action, conflicting_actions) {
2236
- for (let [option_string, action2] of conflicting_actions) {
2237
- _array_remove(action2.option_strings, option_string);
2238
- delete this._option_string_actions[option_string];
2239
- if (!action2.option_strings.length) {
2240
- action2.container._remove_action(action2);
2241
- }
2242
- }
2243
- }
2244
- }));
2245
- var _ArgumentGroup = _callable(class _ArgumentGroup extends _ActionsContainer {
2246
- constructor() {
2247
- let [
2248
- container,
2249
- title,
2250
- description,
2251
- kwargs
2252
- ] = _parse_opts(arguments, {
2253
- container: no_default,
2254
- title: void 0,
2255
- description: void 0,
2256
- "**kwargs": no_default
2257
- });
2258
- setdefault(kwargs, "conflict_handler", container.conflict_handler);
2259
- setdefault(kwargs, "prefix_chars", container.prefix_chars);
2260
- setdefault(kwargs, "argument_default", container.argument_default);
2261
- super(Object.assign({ description }, kwargs));
2262
- this.title = title;
2263
- this._group_actions = [];
2264
- this._registries = container._registries;
2265
- this._actions = container._actions;
2266
- this._option_string_actions = container._option_string_actions;
2267
- this._defaults = container._defaults;
2268
- this._has_negative_number_optionals = container._has_negative_number_optionals;
2269
- this._mutually_exclusive_groups = container._mutually_exclusive_groups;
2270
- }
2271
- _add_action(action) {
2272
- action = super._add_action(action);
2273
- this._group_actions.push(action);
2274
- return action;
2275
- }
2276
- _remove_action(action) {
2277
- super._remove_action(action);
2278
- _array_remove(this._group_actions, action);
2279
- }
2280
- });
2281
- var _MutuallyExclusiveGroup = _callable(class _MutuallyExclusiveGroup extends _ArgumentGroup {
2282
- constructor() {
2283
- let [
2284
- container,
2285
- required
2286
- ] = _parse_opts(arguments, {
2287
- container: no_default,
2288
- required: false
2289
- });
2290
- super(container);
2291
- this.required = required;
2292
- this._container = container;
2293
- }
2294
- _add_action(action) {
2295
- if (action.required) {
2296
- let msg = "mutually exclusive arguments must be optional";
2297
- throw new TypeError(msg);
2298
- }
2299
- action = this._container._add_action(action);
2300
- this._group_actions.push(action);
2301
- return action;
2302
- }
2303
- _remove_action(action) {
2304
- this._container._remove_action(action);
2305
- _array_remove(this._group_actions, action);
2306
- }
2307
- });
2308
- var ArgumentParser2 = _camelcase_alias(_callable(class ArgumentParser extends _AttributeHolder(_ActionsContainer) {
2309
- /*
2310
- * Object for parsing command line strings into Python objects.
2311
- *
2312
- * Keyword Arguments:
2313
- * - prog -- The name of the program (default: sys.argv[0])
2314
- * - usage -- A usage message (default: auto-generated from arguments)
2315
- * - description -- A description of what the program does
2316
- * - epilog -- Text following the argument descriptions
2317
- * - parents -- Parsers whose arguments should be copied into this one
2318
- * - formatter_class -- HelpFormatter class for printing help messages
2319
- * - prefix_chars -- Characters that prefix optional arguments
2320
- * - fromfile_prefix_chars -- Characters that prefix files containing
2321
- * additional arguments
2322
- * - argument_default -- The default value for all arguments
2323
- * - conflict_handler -- String indicating how to handle conflicts
2324
- * - add_help -- Add a -h/-help option
2325
- * - allow_abbrev -- Allow long options to be abbreviated unambiguously
2326
- * - exit_on_error -- Determines whether or not ArgumentParser exits with
2327
- * error info when an error occurs
2328
- */
2329
- constructor() {
2330
- let [
2331
- prog,
2332
- usage,
2333
- description,
2334
- epilog,
2335
- parents,
2336
- formatter_class,
2337
- prefix_chars,
2338
- fromfile_prefix_chars,
2339
- argument_default,
2340
- conflict_handler,
2341
- add_help,
2342
- allow_abbrev,
2343
- exit_on_error,
2344
- debug,
2345
- // LEGACY (v1 compatibility), debug mode
2346
- version2
2347
- // LEGACY (v1 compatibility), version
2348
- ] = _parse_opts(arguments, {
2349
- prog: void 0,
2350
- usage: void 0,
2351
- description: void 0,
2352
- epilog: void 0,
2353
- parents: [],
2354
- formatter_class: HelpFormatter,
2355
- prefix_chars: "-",
2356
- fromfile_prefix_chars: void 0,
2357
- argument_default: void 0,
2358
- conflict_handler: "error",
2359
- add_help: true,
2360
- allow_abbrev: true,
2361
- exit_on_error: true,
2362
- debug: void 0,
2363
- // LEGACY (v1 compatibility), debug mode
2364
- version: void 0
2365
- // LEGACY (v1 compatibility), version
2366
- });
2367
- if (debug !== void 0) {
2368
- deprecate(
2369
- "debug",
2370
- 'The "debug" argument to ArgumentParser is deprecated. Please override ArgumentParser.exit function instead.'
2371
- );
2372
- }
2373
- if (version2 !== void 0) {
2374
- deprecate(
2375
- "version",
2376
- `The "version" argument to ArgumentParser is deprecated. Please use add_argument(..., { action: 'version', version: 'N', ... }) instead.`
2377
- );
2378
- }
2379
- super({
2380
- description,
2381
- prefix_chars,
2382
- argument_default,
2383
- conflict_handler
2384
- });
2385
- if (prog === void 0) {
2386
- prog = path8.basename(get_argv()[0] || "");
2387
- }
2388
- this.prog = prog;
2389
- this.usage = usage;
2390
- this.epilog = epilog;
2391
- this.formatter_class = formatter_class;
2392
- this.fromfile_prefix_chars = fromfile_prefix_chars;
2393
- this.add_help = add_help;
2394
- this.allow_abbrev = allow_abbrev;
2395
- this.exit_on_error = exit_on_error;
2396
- this.debug = debug;
2397
- this._positionals = this.add_argument_group("positional arguments");
2398
- this._optionals = this.add_argument_group("optional arguments");
2399
- this._subparsers = void 0;
2400
- function identity(string) {
2401
- return string;
2402
- }
2403
- this.register("type", void 0, identity);
2404
- this.register("type", null, identity);
2405
- this.register("type", "auto", identity);
2406
- this.register("type", "int", function(x) {
2407
- let result = Number(x);
2408
- if (!Number.isInteger(result)) {
2409
- throw new TypeError(sub("could not convert string to int: %r", x));
2410
- }
2411
- return result;
2412
- });
2413
- this.register("type", "float", function(x) {
2414
- let result = Number(x);
2415
- if (isNaN(result)) {
2416
- throw new TypeError(sub("could not convert string to float: %r", x));
2417
- }
2418
- return result;
2419
- });
2420
- this.register("type", "str", String);
2421
- this.register(
2422
- "type",
2423
- "string",
2424
- util.deprecate(String, 'use {type:"str"} or {type:String} instead of {type:"string"}')
2425
- );
2426
- let default_prefix = prefix_chars.includes("-") ? "-" : prefix_chars[0];
2427
- if (this.add_help) {
2428
- this.add_argument(
2429
- default_prefix + "h",
2430
- default_prefix.repeat(2) + "help",
2431
- {
2432
- action: "help",
2433
- default: SUPPRESS,
2434
- help: "show this help message and exit"
2435
- }
2436
- );
2437
- }
2438
- if (version2) {
2439
- this.add_argument(
2440
- default_prefix + "v",
2441
- default_prefix.repeat(2) + "version",
2442
- {
2443
- action: "version",
2444
- default: SUPPRESS,
2445
- version: this.version,
2446
- help: "show program's version number and exit"
2447
- }
2448
- );
2449
- }
2450
- for (let parent of parents) {
2451
- this._add_container_actions(parent);
2452
- Object.assign(this._defaults, parent._defaults);
2453
- }
2454
- }
2455
- // =======================
2456
- // Pretty __repr__ methods
2457
- // =======================
2458
- _get_kwargs() {
2459
- let names = [
2460
- "prog",
2461
- "usage",
2462
- "description",
2463
- "formatter_class",
2464
- "conflict_handler",
2465
- "add_help"
2466
- ];
2467
- return names.map((name) => [name, getattr(this, name)]);
2468
- }
2469
- // ==================================
2470
- // Optional/Positional adding methods
2471
- // ==================================
2472
- add_subparsers() {
2473
- let [
2474
- kwargs
2475
- ] = _parse_opts(arguments, {
2476
- "**kwargs": no_default
2477
- });
2478
- if (this._subparsers !== void 0) {
2479
- this.error("cannot have multiple subparser arguments");
2480
- }
2481
- setdefault(kwargs, "parser_class", this.constructor);
2482
- if ("title" in kwargs || "description" in kwargs) {
2483
- let title = getattr(kwargs, "title", "subcommands");
2484
- let description = getattr(kwargs, "description", void 0);
2485
- delete kwargs.title;
2486
- delete kwargs.description;
2487
- this._subparsers = this.add_argument_group(title, description);
2488
- } else {
2489
- this._subparsers = this._positionals;
2490
- }
2491
- if (kwargs.prog === void 0) {
2492
- let formatter = this._get_formatter();
2493
- let positionals = this._get_positional_actions();
2494
- let groups = this._mutually_exclusive_groups;
2495
- formatter.add_usage(this.usage, positionals, groups, "");
2496
- kwargs.prog = formatter.format_help().trim();
2497
- }
2498
- let parsers_class = this._pop_action_class(kwargs, "parsers");
2499
- let action = new parsers_class(Object.assign({ option_strings: [] }, kwargs));
2500
- this._subparsers._add_action(action);
2501
- return action;
2502
- }
2503
- _add_action(action) {
2504
- if (action.option_strings.length) {
2505
- this._optionals._add_action(action);
2506
- } else {
2507
- this._positionals._add_action(action);
2508
- }
2509
- return action;
2510
- }
2511
- _get_optional_actions() {
2512
- return this._actions.filter((action) => action.option_strings.length);
2513
- }
2514
- _get_positional_actions() {
2515
- return this._actions.filter((action) => !action.option_strings.length);
2516
- }
2517
- // =====================================
2518
- // Command line argument parsing methods
2519
- // =====================================
2520
- parse_args(args = void 0, namespace = void 0) {
2521
- let argv;
2522
- [args, argv] = this.parse_known_args(args, namespace);
2523
- if (argv && argv.length > 0) {
2524
- let msg = "unrecognized arguments: %s";
2525
- this.error(sub(msg, argv.join(" ")));
2526
- }
2527
- return args;
2528
- }
2529
- parse_known_args(args = void 0, namespace = void 0) {
2530
- if (args === void 0) {
2531
- args = get_argv().slice(1);
2532
- }
2533
- if (namespace === void 0) {
2534
- namespace = new Namespace();
2535
- }
2536
- for (let action of this._actions) {
2537
- if (action.dest !== SUPPRESS) {
2538
- if (!hasattr(namespace, action.dest)) {
2539
- if (action.default !== SUPPRESS) {
2540
- setattr(namespace, action.dest, action.default);
2541
- }
2542
- }
2543
- }
2544
- }
2545
- for (let dest of Object.keys(this._defaults)) {
2546
- if (!hasattr(namespace, dest)) {
2547
- setattr(namespace, dest, this._defaults[dest]);
2548
- }
2549
- }
2550
- if (this.exit_on_error) {
2551
- try {
2552
- [namespace, args] = this._parse_known_args(args, namespace);
2553
- } catch (err) {
2554
- if (err instanceof ArgumentError) {
2555
- this.error(err.message);
2556
- } else {
2557
- throw err;
2558
- }
2559
- }
2560
- } else {
2561
- [namespace, args] = this._parse_known_args(args, namespace);
2562
- }
2563
- if (hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR)) {
2564
- args = args.concat(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR));
2565
- delattr(namespace, _UNRECOGNIZED_ARGS_ATTR);
2566
- }
2567
- return [namespace, args];
2568
- }
2569
- _parse_known_args(arg_strings, namespace) {
2570
- if (this.fromfile_prefix_chars !== void 0) {
2571
- arg_strings = this._read_args_from_files(arg_strings);
2572
- }
2573
- let action_conflicts = /* @__PURE__ */ new Map();
2574
- for (let mutex_group of this._mutually_exclusive_groups) {
2575
- let group_actions = mutex_group._group_actions;
2576
- for (let [i, mutex_action] of Object.entries(mutex_group._group_actions)) {
2577
- let conflicts = action_conflicts.get(mutex_action) || [];
2578
- conflicts = conflicts.concat(group_actions.slice(0, +i));
2579
- conflicts = conflicts.concat(group_actions.slice(+i + 1));
2580
- action_conflicts.set(mutex_action, conflicts);
2581
- }
2582
- }
2583
- let option_string_indices = {};
2584
- let arg_string_pattern_parts = [];
2585
- let arg_strings_iter = Object.entries(arg_strings)[Symbol.iterator]();
2586
- for (let [i, arg_string] of arg_strings_iter) {
2587
- if (arg_string === "--") {
2588
- arg_string_pattern_parts.push("-");
2589
- for ([i, arg_string] of arg_strings_iter) {
2590
- arg_string_pattern_parts.push("A");
2591
- }
2592
- } else {
2593
- let option_tuple = this._parse_optional(arg_string);
2594
- let pattern;
2595
- if (option_tuple === void 0) {
2596
- pattern = "A";
2597
- } else {
2598
- option_string_indices[i] = option_tuple;
2599
- pattern = "O";
2600
- }
2601
- arg_string_pattern_parts.push(pattern);
2602
- }
2603
- }
2604
- let arg_strings_pattern = arg_string_pattern_parts.join("");
2605
- let seen_actions = /* @__PURE__ */ new Set();
2606
- let seen_non_default_actions = /* @__PURE__ */ new Set();
2607
- let extras;
2608
- let take_action = (action, argument_strings, option_string = void 0) => {
2609
- seen_actions.add(action);
2610
- let argument_values = this._get_values(action, argument_strings);
2611
- if (argument_values !== action.default) {
2612
- seen_non_default_actions.add(action);
2613
- for (let conflict_action of action_conflicts.get(action) || []) {
2614
- if (seen_non_default_actions.has(conflict_action)) {
2615
- let msg = "not allowed with argument %s";
2616
- let action_name = _get_action_name(conflict_action);
2617
- throw new ArgumentError(action, sub(msg, action_name));
2618
- }
2619
- }
2620
- }
2621
- if (argument_values !== SUPPRESS) {
2622
- action(this, namespace, argument_values, option_string);
2623
- }
2624
- };
2625
- let consume_optional = (start_index2) => {
2626
- let option_tuple = option_string_indices[start_index2];
2627
- let [action, option_string, explicit_arg] = option_tuple;
2628
- let action_tuples = [];
2629
- let stop;
2630
- for (; ; ) {
2631
- if (action === void 0) {
2632
- extras.push(arg_strings[start_index2]);
2633
- return start_index2 + 1;
2634
- }
2635
- if (explicit_arg !== void 0) {
2636
- let arg_count = this._match_argument(action, "A");
2637
- let chars = this.prefix_chars;
2638
- if (arg_count === 0 && !chars.includes(option_string[1])) {
2639
- action_tuples.push([action, [], option_string]);
2640
- let char = option_string[0];
2641
- option_string = char + explicit_arg[0];
2642
- let new_explicit_arg = explicit_arg.slice(1) || void 0;
2643
- let optionals_map = this._option_string_actions;
2644
- if (hasattr(optionals_map, option_string)) {
2645
- action = optionals_map[option_string];
2646
- explicit_arg = new_explicit_arg;
2647
- } else {
2648
- let msg = "ignored explicit argument %r";
2649
- throw new ArgumentError(action, sub(msg, explicit_arg));
2650
- }
2651
- } else if (arg_count === 1) {
2652
- stop = start_index2 + 1;
2653
- let args = [explicit_arg];
2654
- action_tuples.push([action, args, option_string]);
2655
- break;
2656
- } else {
2657
- let msg = "ignored explicit argument %r";
2658
- throw new ArgumentError(action, sub(msg, explicit_arg));
2659
- }
2660
- } else {
2661
- let start = start_index2 + 1;
2662
- let selected_patterns = arg_strings_pattern.slice(start);
2663
- let arg_count = this._match_argument(action, selected_patterns);
2664
- stop = start + arg_count;
2665
- let args = arg_strings.slice(start, stop);
2666
- action_tuples.push([action, args, option_string]);
2667
- break;
2668
- }
2669
- }
2670
- assert(action_tuples.length);
2671
- for (let [action2, args, option_string2] of action_tuples) {
2672
- take_action(action2, args, option_string2);
2673
- }
2674
- return stop;
2675
- };
2676
- let positionals = this._get_positional_actions();
2677
- let consume_positionals = (start_index2) => {
2678
- let selected_pattern = arg_strings_pattern.slice(start_index2);
2679
- let arg_counts = this._match_arguments_partial(positionals, selected_pattern);
2680
- for (let i = 0; i < positionals.length && i < arg_counts.length; i++) {
2681
- let action = positionals[i];
2682
- let arg_count = arg_counts[i];
2683
- let args = arg_strings.slice(start_index2, start_index2 + arg_count);
2684
- start_index2 += arg_count;
2685
- take_action(action, args);
2686
- }
2687
- positionals = positionals.slice(arg_counts.length);
2688
- return start_index2;
2689
- };
2690
- extras = [];
2691
- let start_index = 0;
2692
- let max_option_string_index = Math.max(-1, ...Object.keys(option_string_indices).map(Number));
2693
- while (start_index <= max_option_string_index) {
2694
- let next_option_string_index = Math.min(
2695
- ...Object.keys(option_string_indices).map(Number).filter((index) => index >= start_index)
2696
- );
2697
- if (start_index !== next_option_string_index) {
2698
- let positionals_end_index = consume_positionals(start_index);
2699
- if (positionals_end_index > start_index) {
2700
- start_index = positionals_end_index;
2701
- continue;
2702
- } else {
2703
- start_index = positionals_end_index;
2704
- }
2705
- }
2706
- if (!(start_index in option_string_indices)) {
2707
- let strings = arg_strings.slice(start_index, next_option_string_index);
2708
- extras = extras.concat(strings);
2709
- start_index = next_option_string_index;
2710
- }
2711
- start_index = consume_optional(start_index);
2712
- }
2713
- let stop_index = consume_positionals(start_index);
2714
- extras = extras.concat(arg_strings.slice(stop_index));
2715
- let required_actions = [];
2716
- for (let action of this._actions) {
2717
- if (!seen_actions.has(action)) {
2718
- if (action.required) {
2719
- required_actions.push(_get_action_name(action));
2720
- } else {
2721
- if (action.default !== void 0 && typeof action.default === "string" && hasattr(namespace, action.dest) && action.default === getattr(namespace, action.dest)) {
2722
- setattr(
2723
- namespace,
2724
- action.dest,
2725
- this._get_value(action, action.default)
2726
- );
2727
- }
2728
- }
2729
- }
2730
- }
2731
- if (required_actions.length) {
2732
- this.error(sub(
2733
- "the following arguments are required: %s",
2734
- required_actions.join(", ")
2735
- ));
2736
- }
2737
- for (let group of this._mutually_exclusive_groups) {
2738
- if (group.required) {
2739
- let no_actions_used = true;
2740
- for (let action of group._group_actions) {
2741
- if (seen_non_default_actions.has(action)) {
2742
- no_actions_used = false;
2743
- break;
2744
- }
2745
- }
2746
- if (no_actions_used) {
2747
- let names = group._group_actions.filter((action) => action.help !== SUPPRESS).map((action) => _get_action_name(action));
2748
- let msg = "one of the arguments %s is required";
2749
- this.error(sub(msg, names.join(" ")));
2750
- }
2751
- }
2752
- }
2753
- return [namespace, extras];
2754
- }
2755
- _read_args_from_files(arg_strings) {
2756
- let new_arg_strings = [];
2757
- for (let arg_string of arg_strings) {
2758
- if (!arg_string || !this.fromfile_prefix_chars.includes(arg_string[0])) {
2759
- new_arg_strings.push(arg_string);
2760
- } else {
2761
- try {
2762
- let args_file = fs8.readFileSync(arg_string.slice(1), "utf8");
2763
- let arg_strings2 = [];
2764
- for (let arg_line of splitlines(args_file)) {
2765
- for (let arg of this.convert_arg_line_to_args(arg_line)) {
2766
- arg_strings2.push(arg);
2767
- }
2768
- }
2769
- arg_strings2 = this._read_args_from_files(arg_strings2);
2770
- new_arg_strings = new_arg_strings.concat(arg_strings2);
2771
- } catch (err) {
2772
- this.error(err.message);
2773
- }
2774
- }
2775
- }
2776
- return new_arg_strings;
2777
- }
2778
- convert_arg_line_to_args(arg_line) {
2779
- return [arg_line];
2780
- }
2781
- _match_argument(action, arg_strings_pattern) {
2782
- let nargs_pattern = this._get_nargs_pattern(action);
2783
- let match2 = arg_strings_pattern.match(new RegExp("^" + nargs_pattern));
2784
- if (match2 === null) {
2785
- let nargs_errors = {
2786
- undefined: "expected one argument",
2787
- [OPTIONAL]: "expected at most one argument",
2788
- [ONE_OR_MORE]: "expected at least one argument"
2789
- };
2790
- let msg = nargs_errors[action.nargs];
2791
- if (msg === void 0) {
2792
- msg = sub(action.nargs === 1 ? "expected %s argument" : "expected %s arguments", action.nargs);
2793
- }
2794
- throw new ArgumentError(action, msg);
2795
- }
2796
- return match2[1].length;
2797
- }
2798
- _match_arguments_partial(actions, arg_strings_pattern) {
2799
- let result = [];
2800
- for (let i of range(actions.length, 0, -1)) {
2801
- let actions_slice = actions.slice(0, i);
2802
- let pattern = actions_slice.map((action) => this._get_nargs_pattern(action)).join("");
2803
- let match2 = arg_strings_pattern.match(new RegExp("^" + pattern));
2804
- if (match2 !== null) {
2805
- result = result.concat(match2.slice(1).map((string) => string.length));
2806
- break;
2807
- }
2808
- }
2809
- return result;
2810
- }
2811
- _parse_optional(arg_string) {
2812
- if (!arg_string) {
2813
- return void 0;
2814
- }
2815
- if (!this.prefix_chars.includes(arg_string[0])) {
2816
- return void 0;
2817
- }
2818
- if (arg_string in this._option_string_actions) {
2819
- let action = this._option_string_actions[arg_string];
2820
- return [action, arg_string, void 0];
2821
- }
2822
- if (arg_string.length === 1) {
2823
- return void 0;
2824
- }
2825
- if (arg_string.includes("=")) {
2826
- let [option_string, explicit_arg] = _string_split(arg_string, "=", 1);
2827
- if (option_string in this._option_string_actions) {
2828
- let action = this._option_string_actions[option_string];
2829
- return [action, option_string, explicit_arg];
2830
- }
2831
- }
2832
- let option_tuples = this._get_option_tuples(arg_string);
2833
- if (option_tuples.length > 1) {
2834
- let options = option_tuples.map(([
2835
- ,
2836
- option_string
2837
- /*, explicit_arg*/
2838
- ]) => option_string).join(", ");
2839
- let args = { option: arg_string, matches: options };
2840
- let msg = "ambiguous option: %(option)s could match %(matches)s";
2841
- this.error(sub(msg, args));
2842
- } else if (option_tuples.length === 1) {
2843
- let [option_tuple] = option_tuples;
2844
- return option_tuple;
2845
- }
2846
- if (this._negative_number_matcher.test(arg_string)) {
2847
- if (!this._has_negative_number_optionals.length) {
2848
- return void 0;
2849
- }
2850
- }
2851
- if (arg_string.includes(" ")) {
2852
- return void 0;
2853
- }
2854
- return [void 0, arg_string, void 0];
2855
- }
2856
- _get_option_tuples(option_string) {
2857
- let result = [];
2858
- let chars = this.prefix_chars;
2859
- if (chars.includes(option_string[0]) && chars.includes(option_string[1])) {
2860
- if (this.allow_abbrev) {
2861
- let option_prefix, explicit_arg;
2862
- if (option_string.includes("=")) {
2863
- [option_prefix, explicit_arg] = _string_split(option_string, "=", 1);
2864
- } else {
2865
- option_prefix = option_string;
2866
- explicit_arg = void 0;
2867
- }
2868
- for (let option_string2 of Object.keys(this._option_string_actions)) {
2869
- if (option_string2.startsWith(option_prefix)) {
2870
- let action = this._option_string_actions[option_string2];
2871
- let tup = [action, option_string2, explicit_arg];
2872
- result.push(tup);
2873
- }
2874
- }
2875
- }
2876
- } else if (chars.includes(option_string[0]) && !chars.includes(option_string[1])) {
2877
- let option_prefix = option_string;
2878
- let explicit_arg = void 0;
2879
- let short_option_prefix = option_string.slice(0, 2);
2880
- let short_explicit_arg = option_string.slice(2);
2881
- for (let option_string2 of Object.keys(this._option_string_actions)) {
2882
- if (option_string2 === short_option_prefix) {
2883
- let action = this._option_string_actions[option_string2];
2884
- let tup = [action, option_string2, short_explicit_arg];
2885
- result.push(tup);
2886
- } else if (option_string2.startsWith(option_prefix)) {
2887
- let action = this._option_string_actions[option_string2];
2888
- let tup = [action, option_string2, explicit_arg];
2889
- result.push(tup);
2890
- }
2891
- }
2892
- } else {
2893
- this.error(sub("unexpected option string: %s", option_string));
2894
- }
2895
- return result;
2896
- }
2897
- _get_nargs_pattern(action) {
2898
- let nargs = action.nargs;
2899
- let nargs_pattern;
2900
- if (nargs === void 0) {
2901
- nargs_pattern = "(-*A-*)";
2902
- } else if (nargs === OPTIONAL) {
2903
- nargs_pattern = "(-*A?-*)";
2904
- } else if (nargs === ZERO_OR_MORE) {
2905
- nargs_pattern = "(-*[A-]*)";
2906
- } else if (nargs === ONE_OR_MORE) {
2907
- nargs_pattern = "(-*A[A-]*)";
2908
- } else if (nargs === REMAINDER) {
2909
- nargs_pattern = "([-AO]*)";
2910
- } else if (nargs === PARSER) {
2911
- nargs_pattern = "(-*A[-AO]*)";
2912
- } else if (nargs === SUPPRESS) {
2913
- nargs_pattern = "(-*-*)";
2914
- } else {
2915
- nargs_pattern = sub("(-*%s-*)", "A".repeat(nargs).split("").join("-*"));
2916
- }
2917
- if (action.option_strings.length) {
2918
- nargs_pattern = nargs_pattern.replace(/-\*/g, "");
2919
- nargs_pattern = nargs_pattern.replace(/-/g, "");
2920
- }
2921
- return nargs_pattern;
2922
- }
2923
- // ========================
2924
- // Alt command line argument parsing, allowing free intermix
2925
- // ========================
2926
- parse_intermixed_args(args = void 0, namespace = void 0) {
2927
- let argv;
2928
- [args, argv] = this.parse_known_intermixed_args(args, namespace);
2929
- if (argv.length) {
2930
- let msg = "unrecognized arguments: %s";
2931
- this.error(sub(msg, argv.join(" ")));
2932
- }
2933
- return args;
2934
- }
2935
- parse_known_intermixed_args(args = void 0, namespace = void 0) {
2936
- let extras;
2937
- let positionals = this._get_positional_actions();
2938
- let a = positionals.filter((action) => [PARSER, REMAINDER].includes(action.nargs));
2939
- if (a.length) {
2940
- throw new TypeError(sub("parse_intermixed_args: positional arg with nargs=%s", a[0].nargs));
2941
- }
2942
- for (let group of this._mutually_exclusive_groups) {
2943
- for (let action of group._group_actions) {
2944
- if (positionals.includes(action)) {
2945
- throw new TypeError("parse_intermixed_args: positional in mutuallyExclusiveGroup");
2946
- }
2947
- }
2948
- }
2949
- let save_usage;
2950
- try {
2951
- save_usage = this.usage;
2952
- let remaining_args;
2953
- try {
2954
- if (this.usage === void 0) {
2955
- this.usage = this.format_usage().slice(7);
2956
- }
2957
- for (let action of positionals) {
2958
- action.save_nargs = action.nargs;
2959
- action.nargs = SUPPRESS;
2960
- action.save_default = action.default;
2961
- action.default = SUPPRESS;
2962
- }
2963
- [namespace, remaining_args] = this.parse_known_args(
2964
- args,
2965
- namespace
2966
- );
2967
- for (let action of positionals) {
2968
- let attr = getattr(namespace, action.dest);
2969
- if (Array.isArray(attr) && attr.length === 0) {
2970
- console.warn(sub("Do not expect %s in %s", action.dest, namespace));
2971
- delattr(namespace, action.dest);
2972
- }
2973
- }
2974
- } finally {
2975
- for (let action of positionals) {
2976
- action.nargs = action.save_nargs;
2977
- action.default = action.save_default;
2978
- }
2979
- }
2980
- let optionals = this._get_optional_actions();
2981
- try {
2982
- for (let action of optionals) {
2983
- action.save_required = action.required;
2984
- action.required = false;
2985
- }
2986
- for (let group of this._mutually_exclusive_groups) {
2987
- group.save_required = group.required;
2988
- group.required = false;
2989
- }
2990
- [namespace, extras] = this.parse_known_args(
2991
- remaining_args,
2992
- namespace
2993
- );
2994
- } finally {
2995
- for (let action of optionals) {
2996
- action.required = action.save_required;
2997
- }
2998
- for (let group of this._mutually_exclusive_groups) {
2999
- group.required = group.save_required;
3000
- }
3001
- }
3002
- } finally {
3003
- this.usage = save_usage;
3004
- }
3005
- return [namespace, extras];
3006
- }
3007
- // ========================
3008
- // Value conversion methods
3009
- // ========================
3010
- _get_values(action, arg_strings) {
3011
- if (![PARSER, REMAINDER].includes(action.nargs)) {
3012
- try {
3013
- _array_remove(arg_strings, "--");
3014
- } catch (err) {
3015
- }
3016
- }
3017
- let value;
3018
- if (!arg_strings.length && action.nargs === OPTIONAL) {
3019
- if (action.option_strings.length) {
3020
- value = action.const;
3021
- } else {
3022
- value = action.default;
3023
- }
3024
- if (typeof value === "string") {
3025
- value = this._get_value(action, value);
3026
- this._check_value(action, value);
3027
- }
3028
- } else if (!arg_strings.length && action.nargs === ZERO_OR_MORE && !action.option_strings.length) {
3029
- if (action.default !== void 0) {
3030
- value = action.default;
3031
- } else {
3032
- value = arg_strings;
3033
- }
3034
- this._check_value(action, value);
3035
- } else if (arg_strings.length === 1 && [void 0, OPTIONAL].includes(action.nargs)) {
3036
- let arg_string = arg_strings[0];
3037
- value = this._get_value(action, arg_string);
3038
- this._check_value(action, value);
3039
- } else if (action.nargs === REMAINDER) {
3040
- value = arg_strings.map((v2) => this._get_value(action, v2));
3041
- } else if (action.nargs === PARSER) {
3042
- value = arg_strings.map((v2) => this._get_value(action, v2));
3043
- this._check_value(action, value[0]);
3044
- } else if (action.nargs === SUPPRESS) {
3045
- value = SUPPRESS;
3046
- } else {
3047
- value = arg_strings.map((v2) => this._get_value(action, v2));
3048
- for (let v2 of value) {
3049
- this._check_value(action, v2);
3050
- }
3051
- }
3052
- return value;
3053
- }
3054
- _get_value(action, arg_string) {
3055
- let type_func = this._registry_get("type", action.type, action.type);
3056
- if (typeof type_func !== "function") {
3057
- let msg = "%r is not callable";
3058
- throw new ArgumentError(action, sub(msg, type_func));
3059
- }
3060
- let result;
3061
- try {
3062
- try {
3063
- result = type_func(arg_string);
3064
- } catch (err) {
3065
- if (err instanceof TypeError && /Class constructor .* cannot be invoked without 'new'/.test(err.message)) {
3066
- result = new type_func(arg_string);
3067
- } else {
3068
- throw err;
3069
- }
3070
- }
3071
- } catch (err) {
3072
- if (err instanceof ArgumentTypeError) {
3073
- let msg = err.message;
3074
- throw new ArgumentError(action, msg);
3075
- } else if (err instanceof TypeError) {
3076
- let name = getattr(action.type, "name", repr(action.type));
3077
- let args = { type: name, value: arg_string };
3078
- let msg = "invalid %(type)s value: %(value)r";
3079
- throw new ArgumentError(action, sub(msg, args));
3080
- } else {
3081
- throw err;
3082
- }
3083
- }
3084
- return result;
3085
- }
3086
- _check_value(action, value) {
3087
- if (action.choices !== void 0 && !_choices_to_array(action.choices).includes(value)) {
3088
- let args = {
3089
- value,
3090
- choices: _choices_to_array(action.choices).map(repr).join(", ")
3091
- };
3092
- let msg = "invalid choice: %(value)r (choose from %(choices)s)";
3093
- throw new ArgumentError(action, sub(msg, args));
3094
- }
3095
- }
3096
- // =======================
3097
- // Help-formatting methods
3098
- // =======================
3099
- format_usage() {
3100
- let formatter = this._get_formatter();
3101
- formatter.add_usage(
3102
- this.usage,
3103
- this._actions,
3104
- this._mutually_exclusive_groups
3105
- );
3106
- return formatter.format_help();
3107
- }
3108
- format_help() {
3109
- let formatter = this._get_formatter();
3110
- formatter.add_usage(
3111
- this.usage,
3112
- this._actions,
3113
- this._mutually_exclusive_groups
3114
- );
3115
- formatter.add_text(this.description);
3116
- for (let action_group of this._action_groups) {
3117
- formatter.start_section(action_group.title);
3118
- formatter.add_text(action_group.description);
3119
- formatter.add_arguments(action_group._group_actions);
3120
- formatter.end_section();
3121
- }
3122
- formatter.add_text(this.epilog);
3123
- return formatter.format_help();
3124
- }
3125
- _get_formatter() {
3126
- return new this.formatter_class({ prog: this.prog });
3127
- }
3128
- // =====================
3129
- // Help-printing methods
3130
- // =====================
3131
- print_usage(file = void 0) {
3132
- if (file === void 0) file = process.stdout;
3133
- this._print_message(this.format_usage(), file);
3134
- }
3135
- print_help(file = void 0) {
3136
- if (file === void 0) file = process.stdout;
3137
- this._print_message(this.format_help(), file);
3138
- }
3139
- _print_message(message, file = void 0) {
3140
- if (message) {
3141
- if (file === void 0) file = process.stderr;
3142
- file.write(message);
3143
- }
3144
- }
3145
- // ===============
3146
- // Exiting methods
3147
- // ===============
3148
- exit(status = 0, message = void 0) {
3149
- if (message) {
3150
- this._print_message(message, process.stderr);
3151
- }
3152
- process.exit(status);
3153
- }
3154
- error(message) {
3155
- if (this.debug === true) throw new Error(message);
3156
- this.print_usage(process.stderr);
3157
- let args = { prog: this.prog, message };
3158
- this.exit(2, sub("%(prog)s: error: %(message)s\n", args));
3159
- }
3160
- }));
3161
- module.exports = {
3162
- ArgumentParser: ArgumentParser2,
3163
- ArgumentError,
3164
- ArgumentTypeError,
3165
- BooleanOptionalAction,
3166
- FileType,
3167
- HelpFormatter,
3168
- ArgumentDefaultsHelpFormatter,
3169
- RawDescriptionHelpFormatter,
3170
- RawTextHelpFormatter,
3171
- MetavarTypeHelpFormatter,
3172
- Namespace,
3173
- Action,
3174
- ONE_OR_MORE,
3175
- OPTIONAL,
3176
- PARSER,
3177
- REMAINDER,
3178
- SUPPRESS,
3179
- ZERO_OR_MORE
3180
- };
3181
- Object.defineProperty(module.exports, "Const", {
3182
- get() {
3183
- let result = {};
3184
- Object.entries({ ONE_OR_MORE, OPTIONAL, PARSER, REMAINDER, SUPPRESS, ZERO_OR_MORE }).forEach(([n, v2]) => {
3185
- Object.defineProperty(result, n, {
3186
- get() {
3187
- deprecate(n, sub("use argparse.%s instead of argparse.Const.%s", n, n));
3188
- return v2;
3189
- }
3190
- });
3191
- });
3192
- Object.entries({ _UNRECOGNIZED_ARGS_ATTR }).forEach(([n, v2]) => {
3193
- Object.defineProperty(result, n, {
3194
- get() {
3195
- deprecate(n, sub("argparse.Const.%s is an internal symbol and will no longer be available", n));
3196
- return v2;
3197
- }
3198
- });
3199
- });
3200
- return result;
3201
- },
3202
- enumerable: false
3203
- });
3204
- }
3205
- });
3206
-
3207
41
  // node_modules/tmp/lib/tmp.js
3208
42
  var require_tmp = __commonJS({
3209
43
  "node_modules/tmp/lib/tmp.js"(exports, module) {
@@ -5576,6 +2410,7 @@ var require_semver2 = __commonJS({
5576
2410
  import { createWriteStream, existsSync, promises as fs7, readFileSync } from "node:fs";
5577
2411
  import path7 from "node:path";
5578
2412
  import { fileURLToPath as fileURLToPath4 } from "node:url";
2413
+ import { parseArgs } from "node:util";
5579
2414
 
5580
2415
  // node_modules/@html-validate/stylish/dist/esm/node.js
5581
2416
  import { styleText } from "node:util";
@@ -7261,9 +4096,6 @@ function parse(text, options) {
7261
4096
  );
7262
4097
  }
7263
4098
 
7264
- // src/index.ts
7265
- var import_argparse = __toESM(require_argparse(), 1);
7266
-
7267
4099
  // node_modules/find-up/index.js
7268
4100
  import path2 from "node:path";
7269
4101
 
@@ -7755,7 +4587,7 @@ import * as Ps from "zlib";
7755
4587
  import en from "zlib";
7756
4588
  import { posix as Zt } from "node:path";
7757
4589
  import { basename as _n } from "node:path";
7758
- import ui from "fs";
4590
+ import mi from "fs";
7759
4591
  import X from "fs";
7760
4592
  import js from "path";
7761
4593
  import { win32 as Pn } from "node:path";
@@ -7763,7 +4595,7 @@ import ar from "path";
7763
4595
  import Br from "node:fs";
7764
4596
  import co from "node:assert";
7765
4597
  import { randomBytes as Mr } from "node:crypto";
7766
- import m from "node:fs";
4598
+ import u from "node:fs";
7767
4599
  import R from "node:path";
7768
4600
  import pr from "fs";
7769
4601
  import wi from "node:fs";
@@ -8121,7 +4953,7 @@ var Jr = I.writev;
8121
4953
  var ht = /* @__PURE__ */ Symbol("_autoClose");
8122
4954
  var H = /* @__PURE__ */ Symbol("_close");
8123
4955
  var te = /* @__PURE__ */ Symbol("_ended");
8124
- var u = /* @__PURE__ */ Symbol("_fd");
4956
+ var m = /* @__PURE__ */ Symbol("_fd");
8125
4957
  var Ni = /* @__PURE__ */ Symbol("_finished");
8126
4958
  var tt2 = /* @__PURE__ */ Symbol("_flags");
8127
4959
  var Ai = /* @__PURE__ */ Symbol("_flush");
@@ -8148,7 +4980,7 @@ var Me = /* @__PURE__ */ Symbol("_defaultFlag");
8148
4980
  var bt = /* @__PURE__ */ Symbol("_errored");
8149
4981
  var _t = class extends A {
8150
4982
  [bt] = false;
8151
- [u];
4983
+ [m];
8152
4984
  [U];
8153
4985
  [Ci];
8154
4986
  [j] = false;
@@ -8157,10 +4989,10 @@ var _t = class extends A {
8157
4989
  [ht];
8158
4990
  constructor(t, e) {
8159
4991
  if (e = e || {}, super(e), this.readable = true, this.writable = false, typeof t != "string") throw new TypeError("path must be a string");
8160
- this[bt] = false, this[u] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ci] = e.readSize || 16 * 1024 * 1024, this[j] = false, this[Fi] = typeof e.size == "number" ? e.size : 1 / 0, this[ee] = this[Fi], this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : true, typeof this[u] == "number" ? this[zt]() : this[at]();
4992
+ this[bt] = false, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[U] = t, this[Ci] = e.readSize || 16 * 1024 * 1024, this[j] = false, this[Fi] = typeof e.size == "number" ? e.size : 1 / 0, this[ee] = this[Fi], this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : true, typeof this[m] == "number" ? this[zt]() : this[at]();
8161
4993
  }
8162
4994
  get fd() {
8163
- return this[u];
4995
+ return this[m];
8164
4996
  }
8165
4997
  get path() {
8166
4998
  return this[U];
@@ -8175,7 +5007,7 @@ var _t = class extends A {
8175
5007
  I.open(this[U], "r", (t, e) => this[Ht](t, e));
8176
5008
  }
8177
5009
  [Ht](t, e) {
8178
- t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[zt]());
5010
+ t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[zt]());
8179
5011
  }
8180
5012
  [vi]() {
8181
5013
  return Buffer.allocUnsafe(Math.min(this[Ci], this[ee]));
@@ -8185,16 +5017,16 @@ var _t = class extends A {
8185
5017
  this[j] = true;
8186
5018
  let t = this[vi]();
8187
5019
  if (t.length === 0) return process.nextTick(() => this[Ii](null, 0, t));
8188
- I.read(this[u], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
5020
+ I.read(this[m], t, 0, t.length, null, (e, i, r) => this[Ii](e, i, r));
8189
5021
  }
8190
5022
  }
8191
5023
  [Ii](t, e, i) {
8192
5024
  this[j] = false, t ? this[Ut](t) : this[ki](e, i) && this[zt]();
8193
5025
  }
8194
5026
  [H]() {
8195
- if (this[ht] && typeof this[u] == "number") {
8196
- let t = this[u];
8197
- this[u] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
5027
+ if (this[ht] && typeof this[m] == "number") {
5028
+ let t = this[m];
5029
+ this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
8198
5030
  }
8199
5031
  }
8200
5032
  [Ut](t) {
@@ -8210,7 +5042,7 @@ var _t = class extends A {
8210
5042
  case "finish":
8211
5043
  return false;
8212
5044
  case "drain":
8213
- return typeof this[u] == "number" && this[zt](), false;
5045
+ return typeof this[m] == "number" && this[zt](), false;
8214
5046
  case "error":
8215
5047
  return this[bt] ? false : (this[bt] = true, super.emit(t, ...e));
8216
5048
  default:
@@ -8233,7 +5065,7 @@ var Be = class extends _t {
8233
5065
  if (!this[j]) {
8234
5066
  this[j] = true;
8235
5067
  do {
8236
- let e = this[vi](), i = e.length === 0 ? 0 : I.readSync(this[u], e, 0, e.length, null);
5068
+ let e = this[vi](), i = e.length === 0 ? 0 : I.readSync(this[m], e, 0, e.length, null);
8237
5069
  if (!this[ki](i, e)) break;
8238
5070
  } while (true);
8239
5071
  this[j] = false;
@@ -8244,9 +5076,9 @@ var Be = class extends _t {
8244
5076
  }
8245
5077
  }
8246
5078
  [H]() {
8247
- if (this[ht] && typeof this[u] == "number") {
8248
- let t = this[u];
8249
- this[u] = void 0, I.closeSync(t), this.emit("close");
5079
+ if (this[ht] && typeof this[m] == "number") {
5080
+ let t = this[m];
5081
+ this[m] = void 0, I.closeSync(t), this.emit("close");
8250
5082
  }
8251
5083
  }
8252
5084
  };
@@ -8261,15 +5093,15 @@ var et = class extends Qr {
8261
5093
  [U];
8262
5094
  [ie];
8263
5095
  [ht];
8264
- [u];
5096
+ [m];
8265
5097
  [Me];
8266
5098
  [tt2];
8267
5099
  [Ni] = false;
8268
5100
  [ot];
8269
5101
  constructor(t, e) {
8270
- e = e || {}, super(e), this[U] = t, this[u] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[ot] = typeof e.start == "number" ? e.start : void 0, this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : true;
5102
+ e = e || {}, super(e), this[U] = t, this[m] = typeof e.fd == "number" ? e.fd : void 0, this[ie] = e.mode === void 0 ? 438 : e.mode, this[ot] = typeof e.start == "number" ? e.start : void 0, this[ht] = typeof e.autoClose == "boolean" ? e.autoClose : true;
8271
5103
  let i = this[ot] !== void 0 ? "r+" : "w";
8272
- this[Me] = e.flags === void 0, this[tt2] = e.flags === void 0 ? i : e.flags, this[u] === void 0 && this[at]();
5104
+ this[Me] = e.flags === void 0, this[tt2] = e.flags === void 0 ? i : e.flags, this[m] === void 0 && this[at]();
8273
5105
  }
8274
5106
  emit(t, ...e) {
8275
5107
  if (t === "error") {
@@ -8279,7 +5111,7 @@ var et = class extends Qr {
8279
5111
  return super.emit(t, ...e);
8280
5112
  }
8281
5113
  get fd() {
8282
- return this[u];
5114
+ return this[m];
8283
5115
  }
8284
5116
  get path() {
8285
5117
  return this[U];
@@ -8291,16 +5123,16 @@ var et = class extends Qr {
8291
5123
  I.open(this[U], this[tt2], this[ie], (t, e) => this[Ht](t, e));
8292
5124
  }
8293
5125
  [Ht](t, e) {
8294
- this[Me] && this[tt2] === "r+" && t && t.code === "ENOENT" ? (this[tt2] = "w", this[at]()) : t ? this[Ut](t) : (this[u] = e, this.emit("open", e), this[gt] || this[Ai]());
5126
+ this[Me] && this[tt2] === "r+" && t && t.code === "ENOENT" ? (this[tt2] = "w", this[at]()) : t ? this[Ut](t) : (this[m] = e, this.emit("open", e), this[gt] || this[Ai]());
8295
5127
  }
8296
5128
  end(t, e) {
8297
- return t && this.write(t, e), this[te] = true, !this[gt] && !this[Y].length && typeof this[u] == "number" && this[Pt](null, 0), this;
5129
+ return t && this.write(t, e), this[te] = true, !this[gt] && !this[Y].length && typeof this[m] == "number" && this[Pt](null, 0), this;
8298
5130
  }
8299
5131
  write(t, e) {
8300
- return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", new Error("write() after end()")), false) : this[u] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[ke] = true, false) : (this[gt] = true, this[ve](t), true);
5132
+ return typeof t == "string" && (t = Buffer.from(t, e)), this[te] ? (this.emit("error", new Error("write() after end()")), false) : this[m] === void 0 || this[gt] || this[Y].length ? (this[Y].push(t), this[ke] = true, false) : (this[gt] = true, this[ve](t), true);
8301
5133
  }
8302
5134
  [ve](t) {
8303
- I.write(this[u], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
5135
+ I.write(this[m], t, 0, t.length, this[ot], (e, i) => this[Pt](e, i));
8304
5136
  }
8305
5137
  [Pt](t, e) {
8306
5138
  t ? this[Ut](t) : (this[ot] !== void 0 && typeof e == "number" && (this[ot] += e), this[Y].length ? this[Ai]() : (this[gt] = false, this[te] && !this[Ni] ? (this[Ni] = true, this[H](), this.emit("finish")) : this[ke] && (this[ke] = false, this.emit("drain"))));
@@ -8310,13 +5142,13 @@ var et = class extends Qr {
8310
5142
  else if (this[Y].length === 1) this[ve](this[Y].pop());
8311
5143
  else {
8312
5144
  let t = this[Y];
8313
- this[Y] = [], Jr(this[u], t, this[ot], (e, i) => this[Pt](e, i));
5145
+ this[Y] = [], Jr(this[m], t, this[ot], (e, i) => this[Pt](e, i));
8314
5146
  }
8315
5147
  }
8316
5148
  [H]() {
8317
- if (this[ht] && typeof this[u] == "number") {
8318
- let t = this[u];
8319
- this[u] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
5149
+ if (this[ht] && typeof this[m] == "number") {
5150
+ let t = this[m];
5151
+ this[m] = void 0, I.close(t, (e) => e ? this.emit("error", e) : this.emit("close"));
8320
5152
  }
8321
5153
  }
8322
5154
  };
@@ -8333,15 +5165,15 @@ var Wt = class extends et {
8333
5165
  this[Ht](null, t);
8334
5166
  }
8335
5167
  [H]() {
8336
- if (this[ht] && typeof this[u] == "number") {
8337
- let t = this[u];
8338
- this[u] = void 0, I.closeSync(t), this.emit("close");
5168
+ if (this[ht] && typeof this[m] == "number") {
5169
+ let t = this[m];
5170
+ this[m] = void 0, I.closeSync(t), this.emit("close");
8339
5171
  }
8340
5172
  }
8341
5173
  [ve](t) {
8342
5174
  let e = true;
8343
5175
  try {
8344
- this[Pt](null, I.writeSync(this[u], t, 0, t.length, this[ot])), e = false;
5176
+ this[Pt](null, I.writeSync(this[m], t, 0, t.length, this[ot])), e = false;
8345
5177
  } finally {
8346
5178
  if (e) try {
8347
5179
  this[H]();
@@ -8600,7 +5432,7 @@ var dn = (s3) => Ve.has(s3);
8600
5432
  var Ui = /* @__PURE__ */ new Set(["0", "", "1", "2", "3", "4", "5", "6", "7", "D"]);
8601
5433
  var oe = /* @__PURE__ */ new Map([["0", "File"], ["", "OldFile"], ["1", "Link"], ["2", "SymbolicLink"], ["3", "CharacterDevice"], ["4", "BlockDevice"], ["5", "Directory"], ["6", "FIFO"], ["7", "ContiguousFile"], ["g", "GlobalExtendedHeader"], ["x", "ExtendedHeader"], ["A", "SolarisACL"], ["D", "GNUDumpDir"], ["I", "Inode"], ["K", "NextFileHasLongLinkpath"], ["L", "NextFileHasLongPath"], ["M", "ContinuationFile"], ["N", "OldGnuLongPath"], ["S", "SparseFile"], ["V", "TapeVolumeHeader"], ["X", "OldExtendedHeader"]]);
8602
5434
  var Ve = new Map(Array.from(oe).map((s3) => [s3[1], s3[0]]));
8603
- var mn = (s3) => s3 === void 0 || s3 < 0 ? void 0 : s3;
5435
+ var un = (s3) => s3 === void 0 || s3 < 0 ? void 0 : s3;
8604
5436
  var F = class {
8605
5437
  cksumValid = false;
8606
5438
  needPax = false;
@@ -8629,7 +5461,7 @@ var F = class {
8629
5461
  decode(t, e, i, r) {
8630
5462
  if (e || (e = 0), !t || !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
8631
5463
  let n = xt(t, e + 156, 1), o = Ui.has(n), h = o ? i : void 0, a = o ? r : void 0;
8632
- if (this.path = h?.path ?? xt(t, e, 100), this.mode = h?.mode ?? a?.mode ?? lt(t, e + 100, 8), this.uid = h?.uid ?? a?.uid ?? lt(t, e + 108, 8), this.gid = h?.gid ?? a?.gid ?? lt(t, e + 116, 8), this.size = mn(h?.size ?? a?.size ?? lt(t, e + 124, 12)), this.mtime = h?.mtime ?? a?.mtime ?? Wi(t, e + 136, 12), this.cksum = lt(t, e + 148, 12), a && this.#i(a, true), h && this.#i(h), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = h?.uname ?? a?.uname ?? xt(t, e + 265, 32), this.gname = h?.gname ?? a?.gname ?? xt(t, e + 297, 32), this.devmaj = h?.devmaj ?? a?.devmaj ?? lt(t, e + 329, 8) ?? 0, this.devmin = h?.devmin ?? a?.devmin ?? lt(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
5464
+ if (this.path = h?.path ?? xt(t, e, 100), this.mode = h?.mode ?? a?.mode ?? lt(t, e + 100, 8), this.uid = h?.uid ?? a?.uid ?? lt(t, e + 108, 8), this.gid = h?.gid ?? a?.gid ?? lt(t, e + 116, 8), this.size = un(h?.size ?? a?.size ?? lt(t, e + 124, 12)), this.mtime = h?.mtime ?? a?.mtime ?? Wi(t, e + 136, 12), this.cksum = lt(t, e + 148, 12), a && this.#i(a, true), h && this.#i(h), ne(n) && (this.#t = n || "0"), this.#t === "0" && this.path.slice(-1) === "/" && (this.#t = "5"), this.#t === "5" && (this.size = 0), this.linkpath = xt(t, e + 157, 100), t.subarray(e + 257, e + 265).toString() === "ustar\x0000") if (this.uname = h?.uname ?? a?.uname ?? xt(t, e + 265, 32), this.gname = h?.gname ?? a?.gname ?? xt(t, e + 297, 32), this.devmaj = h?.devmaj ?? a?.devmaj ?? lt(t, e + 329, 8) ?? 0, this.devmin = h?.devmin ?? a?.devmin ?? lt(t, e + 337, 8) ?? 0, t[e + 475] !== 0) {
8633
5465
  let c = xt(t, e + 345, 155);
8634
5466
  this.path = c + "/" + this.path;
8635
5467
  } else {
@@ -8646,7 +5478,7 @@ var F = class {
8646
5478
  }
8647
5479
  encode(t, e = 0) {
8648
5480
  if (t || (t = this.block = Buffer.alloc(512)), this.#t === "Unsupported" && (this.#t = "0"), !(t.length >= e + 512)) throw new Error("need 512 bytes for header");
8649
- let i = this.ctime || this.atime ? 130 : 155, r = un(this.path || "", i), n = r[0], o = r[1];
5481
+ let i = this.ctime || this.atime ? 130 : 155, r = mn(this.path || "", i), n = r[0], o = r[1];
8650
5482
  this.needPax = !!r[2], this.needPax = Lt(t, e, 100, n) || this.needPax, this.needPax = ct(t, e + 100, 8, this.mode) || this.needPax, this.needPax = ct(t, e + 108, 8, this.uid) || this.needPax, this.needPax = ct(t, e + 116, 8, this.gid) || this.needPax, this.needPax = ct(t, e + 124, 12, this.size) || this.needPax, this.needPax = Gi(t, e + 136, 12, this.mtime) || this.needPax, t[e + 156] = Number(this.#t.codePointAt(0)), this.needPax = Lt(t, e + 157, 100, this.linkpath) || this.needPax, t.write("ustar\x0000", e + 257, 8), this.needPax = Lt(t, e + 265, 32, this.uname) || this.needPax, this.needPax = Lt(t, e + 297, 32, this.gname) || this.needPax, this.needPax = ct(t, e + 329, 8, this.devmaj) || this.needPax, this.needPax = ct(t, e + 337, 8, this.devmin) || this.needPax, this.needPax = Lt(t, e + 345, i, o) || this.needPax, t[e + 475] !== 0 ? this.needPax = Lt(t, e + 345, 155, o) || this.needPax : (this.needPax = Lt(t, e + 345, 130, o) || this.needPax, this.needPax = Gi(t, e + 476, 12, this.atime) || this.needPax, this.needPax = Gi(t, e + 488, 12, this.ctime) || this.needPax);
8651
5483
  let h = 256;
8652
5484
  for (let a = e; a < e + 148; a++) h += t[a];
@@ -8666,7 +5498,7 @@ var F = class {
8666
5498
  else throw new TypeError("invalid entry type: " + t);
8667
5499
  }
8668
5500
  };
8669
- var un = (s3, t) => {
5501
+ var mn = (s3, t) => {
8670
5502
  let i = s3, r = "", n, o = Zt.parse(s3).root || ".";
8671
5503
  if (Buffer.byteLength(i) < 100) n = [i, r, false];
8672
5504
  else {
@@ -8859,7 +5691,7 @@ var dt = /* @__PURE__ */ Symbol("meta");
8859
5691
  var Ys = /* @__PURE__ */ Symbol("emitMeta");
8860
5692
  var p = /* @__PURE__ */ Symbol("buffer");
8861
5693
  var st = /* @__PURE__ */ Symbol("queue");
8862
- var mt = /* @__PURE__ */ Symbol("ended");
5694
+ var ut = /* @__PURE__ */ Symbol("ended");
8863
5695
  var Yi = /* @__PURE__ */ Symbol("emittedEnd");
8864
5696
  var At = /* @__PURE__ */ Symbol("emit");
8865
5697
  var w = /* @__PURE__ */ Symbol("unzip");
@@ -8901,7 +5733,7 @@ var rt = class extends Dn {
8901
5733
  [dt] = "";
8902
5734
  [V];
8903
5735
  [he];
8904
- [mt] = false;
5736
+ [ut] = false;
8905
5737
  [w];
8906
5738
  [$] = false;
8907
5739
  [It];
@@ -9039,7 +5871,7 @@ var rt = class extends Dn {
9039
5871
  }
9040
5872
  }
9041
5873
  let h = this.brotli === void 0 && !o;
9042
- if (this[w] === false && h) if (t.length < 512) if (this[mt]) this.brotli = true;
5874
+ if (this[w] === false && h) if (t.length < 512) if (this[ut]) this.brotli = true;
9043
5875
  else return this[p] = t, i?.(), true;
9044
5876
  else try {
9045
5877
  new F(t.subarray(0, 512)), this.brotli = false;
@@ -9047,13 +5879,13 @@ var rt = class extends Dn {
9047
5879
  this.brotli = true;
9048
5880
  }
9049
5881
  if (this[w] === void 0 || this[w] === false && (this.brotli || o)) {
9050
- let a = this[mt];
9051
- this[mt] = false, this[w] = this[w] === void 0 ? new Ue({}) : o ? new Ke({}) : new Ge({}), this[w].on("data", (c) => {
5882
+ let a = this[ut];
5883
+ this[ut] = false, this[w] = this[w] === void 0 ? new Ue({}) : o ? new Ke({}) : new Ge({}), this[w].on("data", (c) => {
9052
5884
  this[Xs](c) && this[Xe](c);
9053
5885
  }), this[w].on("error", (c) => {
9054
5886
  this[$] || this.abort(c);
9055
5887
  }), this[w].on("end", () => {
9056
- this[mt] = true, this[Xe]();
5888
+ this[ut] = true, this[Xe]();
9057
5889
  }), this[Yt] = true, this[le] += t.length;
9058
5890
  let l = !!this[w][a ? "end" : "write"](t);
9059
5891
  return this[Yt] = false, i?.(), l;
@@ -9067,7 +5899,7 @@ var rt = class extends Dn {
9067
5899
  t && !this[$] && (this[p] = this[p] ? Buffer.concat([this[p], t]) : t);
9068
5900
  }
9069
5901
  [Qe]() {
9070
- if (this[mt] && !this[Yi] && !this[$] && !this[ae]) {
5902
+ if (this[ut] && !this[Yi] && !this[$] && !this[ae]) {
9071
5903
  this[Yi] = true;
9072
5904
  let t = this[Nt];
9073
5905
  if (t?.blockRemain) {
@@ -9092,7 +5924,7 @@ var rt = class extends Dn {
9092
5924
  }
9093
5925
  this[ae] = false;
9094
5926
  }
9095
- (!this[p] || this[mt]) && this[Qe]();
5927
+ (!this[p] || this[ut]) && this[Qe]();
9096
5928
  }
9097
5929
  [qe](t) {
9098
5930
  let e = 0, i = t.length;
@@ -9114,10 +5946,10 @@ var rt = class extends Dn {
9114
5946
  e < i && (this[p] = this[p] ? Buffer.concat([t.subarray(e), this[p]]) : t.subarray(e));
9115
5947
  }
9116
5948
  end(t, e, i) {
9117
- return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[$] || (this[w] ? (t && (this[le] += t.length, this[w].write(t)), this[w].end()) : (this[mt] = true, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Qe]())), this;
5949
+ return typeof t == "function" && (i = t, e = void 0, t = void 0), typeof e == "function" && (i = e, e = void 0), typeof t == "string" && (t = Buffer.from(t, e)), i && this.once("finish", i), this[$] || (this[w] ? (t && (this[le] += t.length, this[w].write(t)), this[w].end()) : (this[ut] = true, (this.brotli === void 0 || this.zstd === void 0) && (t = t || Buffer.alloc(0)), t && this.write(t), this[Qe]())), this;
9118
5950
  }
9119
5951
  };
9120
- var ut = (s3) => {
5952
+ var mt = (s3) => {
9121
5953
  let t = s3.length - 1, e = -1;
9122
5954
  for (; t > -1 && s3.charAt(t) === "/"; ) e = t, t--;
9123
5955
  return e === -1 ? s3 : s3.slice(0, e);
@@ -9129,16 +5961,17 @@ var vn = (s3) => {
9129
5961
  } : (e) => e.resume();
9130
5962
  };
9131
5963
  var Qi = (s3, t) => {
9132
- let e = new Map(t.map((n) => [ut(n), true])), i = s3.filter, r = (n, o = "") => {
9133
- let h = o || kn(n).root || ".", a;
9134
- if (n === h) a = false;
5964
+ let e = new Map(t.map((o) => [mt(o), true])), i = s3.filter, r = 100, n = (o, h = "", a = 0) => {
5965
+ if (a >= r) return e.set(o, false), false;
5966
+ let l = h || kn(o).root || ".", c;
5967
+ if (o === l) c = false;
9135
5968
  else {
9136
- let l = e.get(n);
9137
- a = l !== void 0 ? l : r(Fn(n), h);
5969
+ let d = e.get(o);
5970
+ c = d !== void 0 ? d : n(Fn(o), l, a + 1);
9138
5971
  }
9139
- return e.set(n, a), a;
5972
+ return e.set(o, c), c;
9140
5973
  };
9141
- s3.filter = i ? (n, o) => i(n, o) && r(ut(n)) : (n) => r(ut(n));
5974
+ s3.filter = i ? (o, h) => i(o, h) && n(mt(o)) : (o) => n(mt(o));
9142
5975
  };
9143
5976
  var Mn = (s3) => {
9144
5977
  let t = new rt(s3), e = s3.file, i;
@@ -9195,7 +6028,7 @@ var Un = new Map(ei.map((s3, t) => [s3, ji[t]]));
9195
6028
  var Hn = new Map(ji.map((s3, t) => [s3, ei[t]]));
9196
6029
  var ts = (s3) => ei.reduce((t, e) => t.split(e).join(Un.get(e)), s3);
9197
6030
  var Qs = (s3) => ji.reduce((t, e) => t.split(e).join(Hn.get(e)), s3);
9198
- var rr = (s3, t) => t ? (s3 = f(s3).replace(/^\.(\/|$)/, ""), ut(t) + "/" + s3) : f(s3);
6031
+ var rr = (s3, t) => t ? (s3 = f(s3).replace(/^\.(\/|$)/, ""), mt(t) + "/" + s3) : f(s3);
9199
6032
  var Wn = 16 * 1024 * 1024;
9200
6033
  var tr = /* @__PURE__ */ Symbol("process");
9201
6034
  var er = /* @__PURE__ */ Symbol("file");
@@ -9622,16 +6455,16 @@ var hi = class s2 {
9622
6455
  }
9623
6456
  };
9624
6457
  function Zn(s3, t, e) {
9625
- let i = t, r = t ? t.next : s3.head, n = new me(e, i, r, s3);
6458
+ let i = t, r = t ? t.next : s3.head, n = new ue(e, i, r, s3);
9626
6459
  return n.next === void 0 && (s3.tail = n), n.prev === void 0 && (s3.head = n), s3.length++, n;
9627
6460
  }
9628
6461
  function Yn(s3, t) {
9629
- s3.tail = new me(t, s3.tail, void 0, s3), s3.head || (s3.head = s3.tail), s3.length++;
6462
+ s3.tail = new ue(t, s3.tail, void 0, s3), s3.head || (s3.head = s3.tail), s3.length++;
9630
6463
  }
9631
6464
  function Kn(s3, t) {
9632
- s3.head = new me(t, void 0, s3.head, s3), s3.tail || (s3.tail = s3.head), s3.length++;
6465
+ s3.head = new ue(t, void 0, s3.head, s3), s3.tail || (s3.tail = s3.head), s3.length++;
9633
6466
  }
9634
- var me = class {
6467
+ var ue = class {
9635
6468
  list;
9636
6469
  next;
9637
6470
  prev;
@@ -9656,7 +6489,7 @@ var pi = class {
9656
6489
  };
9657
6490
  var nr = Buffer.alloc(1024);
9658
6491
  var li = /* @__PURE__ */ Symbol("onStat");
9659
- var ue = /* @__PURE__ */ Symbol("ended");
6492
+ var me = /* @__PURE__ */ Symbol("ended");
9660
6493
  var W = /* @__PURE__ */ Symbol("queue");
9661
6494
  var pe = /* @__PURE__ */ Symbol("pendingLinks");
9662
6495
  var Et = /* @__PURE__ */ Symbol("current");
@@ -9668,12 +6501,12 @@ var ls = /* @__PURE__ */ Symbol("jobDone");
9668
6501
  var ci = /* @__PURE__ */ Symbol("addFSEntry");
9669
6502
  var or = /* @__PURE__ */ Symbol("addTarEntry");
9670
6503
  var ds = /* @__PURE__ */ Symbol("stat");
9671
- var ms = /* @__PURE__ */ Symbol("readdir");
6504
+ var us = /* @__PURE__ */ Symbol("readdir");
9672
6505
  var fi = /* @__PURE__ */ Symbol("onreaddir");
9673
6506
  var di = /* @__PURE__ */ Symbol("pipe");
9674
6507
  var hr = /* @__PURE__ */ Symbol("entry");
9675
6508
  var cs = /* @__PURE__ */ Symbol("entryOpt");
9676
- var mi = /* @__PURE__ */ Symbol("writeEntryClass");
6509
+ var ui = /* @__PURE__ */ Symbol("writeEntryClass");
9677
6510
  var lr = /* @__PURE__ */ Symbol("write");
9678
6511
  var fs2 = /* @__PURE__ */ Symbol("ondrain");
9679
6512
  var wt = class extends A {
@@ -9697,21 +6530,21 @@ var wt = class extends A {
9697
6530
  mtime;
9698
6531
  filter;
9699
6532
  jobs;
9700
- [mi];
6533
+ [ui];
9701
6534
  onWriteEntry;
9702
6535
  [W];
9703
6536
  [pe] = /* @__PURE__ */ new Map();
9704
6537
  [G] = 0;
9705
6538
  [Ee] = false;
9706
- [ue] = false;
6539
+ [me] = false;
9707
6540
  constructor(t = {}) {
9708
- if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[mi] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
6541
+ if (super(), this.opt = t, this.file = t.file || "", this.cwd = t.cwd || process.cwd(), this.maxReadSize = t.maxReadSize, this.preservePaths = !!t.preservePaths, this.strict = !!t.strict, this.noPax = !!t.noPax, this.prefix = f(t.prefix || ""), this.linkCache = t.linkCache || /* @__PURE__ */ new Map(), this.statCache = t.statCache || /* @__PURE__ */ new Map(), this.readdirCache = t.readdirCache || /* @__PURE__ */ new Map(), this.onWriteEntry = t.onWriteEntry, this[ui] = de, typeof t.onwarn == "function" && this.on("warn", t.onwarn), this.portable = !!t.portable, t.gzip || t.brotli || t.zstd) {
9709
6542
  if ((t.gzip ? 1 : 0) + (t.brotli ? 1 : 0) + (t.zstd ? 1 : 0) > 1) throw new TypeError("gzip, brotli, zstd are mutually exclusive");
9710
6543
  if (t.gzip && (typeof t.gzip != "object" && (t.gzip = {}), this.portable && (t.gzip.portable = true), this.zip = new ze(t.gzip)), t.brotli && (typeof t.brotli != "object" && (t.brotli = {}), this.zip = new We(t.brotli)), t.zstd && (typeof t.zstd != "object" && (t.zstd = {}), this.zip = new Ye(t.zstd)), !this.zip) throw new Error("impossible");
9711
6544
  let e = this.zip;
9712
6545
  e.on("data", (i) => super.write(i)), e.on("end", () => super.end()), e.on("drain", () => this[fs2]()), this.on("resume", () => e.resume());
9713
6546
  } else this.on("drain", this[fs2]);
9714
- this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => true, this[W] = new hi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[Ee] = false, this[ue] = false;
6547
+ this.noDirRecurse = !!t.noDirRecurse, this.follow = !!t.follow, this.noMtime = !!t.noMtime, t.mtime && (this.mtime = t.mtime), this.filter = typeof t.filter == "function" ? t.filter : () => true, this[W] = new hi(), this[G] = 0, this.jobs = Number(t.jobs) || 4, this[Ee] = false, this[me] = false;
9715
6548
  }
9716
6549
  [lr](t) {
9717
6550
  return super.write(t);
@@ -9720,10 +6553,10 @@ var wt = class extends A {
9720
6553
  return this.write(t), this;
9721
6554
  }
9722
6555
  end(t, e, i) {
9723
- return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[ue] = true, this[Ft](), i && i(), this;
6556
+ return typeof t == "function" && (i = t, t = void 0), typeof e == "function" && (i = e, e = void 0), t && this.add(t), this[me] = true, this[Ft](), i && i(), this;
9724
6557
  }
9725
6558
  write(t) {
9726
- if (this[ue]) throw new Error("write after end");
6559
+ if (this[me]) throw new Error("write after end");
9727
6560
  return typeof t == "string" ? this[ci](t) : this[or](t), this.flowing;
9728
6561
  }
9729
6562
  [or](t) {
@@ -9742,7 +6575,7 @@ var wt = class extends A {
9742
6575
  [ds](t) {
9743
6576
  t.pending = true, this[G] += 1;
9744
6577
  let e = this.follow ? "stat" : "lstat";
9745
- ui[e](t.absolute, (i, r) => {
6578
+ mi[e](t.absolute, (i, r) => {
9746
6579
  t.pending = false, this[G] -= 1, i ? this.emit("error", i) : this[li](t, r);
9747
6580
  });
9748
6581
  }
@@ -9755,8 +6588,8 @@ var wt = class extends A {
9755
6588
  }
9756
6589
  this[Ft]();
9757
6590
  }
9758
- [ms](t) {
9759
- t.pending = true, this[G] += 1, ui.readdir(t.absolute, (e, i) => {
6591
+ [us](t) {
6592
+ t.pending = true, this[G] += 1, mi.readdir(t.absolute, (e, i) => {
9760
6593
  if (t.pending = false, this[G] -= 1, e) return this.emit("error", e);
9761
6594
  this[fi](t, i);
9762
6595
  });
@@ -9771,7 +6604,7 @@ var wt = class extends A {
9771
6604
  let e = t.next;
9772
6605
  this[W].removeNode(t), t.next = e;
9773
6606
  }
9774
- this[Ee] = false, this[ue] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(nr) : (super.write(nr), super.end()));
6607
+ this[Ee] = false, this[me] && this[W].length === 0 && this[G] === 0 && (this.zip ? this.zip.end(nr) : (super.write(nr), super.end()));
9775
6608
  }
9776
6609
  }
9777
6610
  get [Et]() {
@@ -9802,7 +6635,7 @@ var wt = class extends A {
9802
6635
  if (t.stat && !t.ignore) {
9803
6636
  if (!this.noDirRecurse && t.stat.isDirectory() && !t.readdir) {
9804
6637
  let e = this.readdirCache.get(t.absolute);
9805
- if (e ? this[fi](t, e) : this[ms](t), !t.readdir) return;
6638
+ if (e ? this[fi](t, e) : this[us](t), !t.readdir) return;
9806
6639
  }
9807
6640
  if (t.entry = this[hr](t), !t.entry) {
9808
6641
  t.ignore = true;
@@ -9818,7 +6651,7 @@ var wt = class extends A {
9818
6651
  [hr](t) {
9819
6652
  this[G] += 1;
9820
6653
  try {
9821
- return new this[mi](t.path, this[cs](t)).on("end", () => this[ls](t)).on("error", (i) => this.emit("error", i));
6654
+ return new this[ui](t.path, this[cs](t)).on("end", () => this[ls](t)).on("error", (i) => this.emit("error", i));
9822
6655
  } catch (e) {
9823
6656
  this.emit("error", e);
9824
6657
  }
@@ -9849,7 +6682,7 @@ var wt = class extends A {
9849
6682
  var kt = class extends wt {
9850
6683
  sync = true;
9851
6684
  constructor(t) {
9852
- super(t), this[mi] = ni;
6685
+ super(t), this[ui] = ni;
9853
6686
  }
9854
6687
  pause() {
9855
6688
  }
@@ -9857,10 +6690,10 @@ var kt = class extends wt {
9857
6690
  }
9858
6691
  [ds](t) {
9859
6692
  let e = this.follow ? "statSync" : "lstatSync";
9860
- this[li](t, ui[e](t.absolute));
6693
+ this[li](t, mi[e](t.absolute));
9861
6694
  }
9862
- [ms](t) {
9863
- this[fi](t, ui.readdirSync(t.absolute));
6695
+ [us](t) {
6696
+ this[fi](t, mi.readdirSync(t.absolute));
9864
6697
  }
9865
6698
  [di](t) {
9866
6699
  let e = t.entry, i = this.zip;
@@ -9911,13 +6744,13 @@ var Qn = K(Vn, $n, Xn, qn, (s3, t) => {
9911
6744
  });
9912
6745
  var Jn = process.env.__FAKE_PLATFORM__ || process.platform;
9913
6746
  var Er = Jn === "win32";
9914
- var { O_CREAT: wr, O_NOFOLLOW: mr, O_TRUNC: Sr, O_WRONLY: yr } = pr.constants;
6747
+ var { O_CREAT: wr, O_NOFOLLOW: ur, O_TRUNC: Sr, O_WRONLY: yr } = pr.constants;
9915
6748
  var Rr = Number(process.env.__FAKE_FS_O_FILENAME__) || pr.constants.UV_FS_O_FILEMAP || 0;
9916
6749
  var jn = Er && !!Rr;
9917
6750
  var to = 512 * 1024;
9918
6751
  var eo = Rr | Sr | wr | yr;
9919
- var ur = !Er && typeof mr == "number" ? mr | Sr | wr | yr : null;
9920
- var us = ur !== null ? () => ur : jn ? (s3) => s3 < to ? eo : "w" : () => "w";
6752
+ var mr = !Er && typeof ur == "number" ? ur | Sr | wr | yr : null;
6753
+ var ms = mr !== null ? () => mr : jn ? (s3) => s3 < to ? eo : "w" : () => "w";
9921
6754
  var ps = (s3, t, e) => {
9922
6755
  try {
9923
6756
  return wi.lchownSync(s3, t, e);
@@ -10085,7 +6918,7 @@ var yi = class {
10085
6918
  #i = /* @__PURE__ */ new Map();
10086
6919
  #s = /* @__PURE__ */ new Set();
10087
6920
  reserve(t, e) {
10088
- t = ao ? ["win32 parallelization disabled"] : t.map((r) => ut(xr(Tr(r))));
6921
+ t = ao ? ["win32 parallelization disabled"] : t.map((r) => mt(xr(Tr(r))));
10089
6922
  let i = new Set(t.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
10090
6923
  this.#i.set(e, { dirs: i, paths: t });
10091
6924
  for (let r of t) {
@@ -10173,19 +7006,19 @@ var _e = /* @__PURE__ */ Symbol("gid");
10173
7006
  var Oe = /* @__PURE__ */ Symbol("checkedCwd");
10174
7007
  var fo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
10175
7008
  var Te = fo === "win32";
10176
- var mo = 1024;
10177
- var uo = (s3, t) => {
10178
- if (!Te) return m.unlink(s3, t);
7009
+ var uo = 1024;
7010
+ var mo = (s3, t) => {
7011
+ if (!Te) return u.unlink(s3, t);
10179
7012
  let e = s3 + ".DELETE." + Mr(16).toString("hex");
10180
- m.rename(s3, e, (i) => {
7013
+ u.rename(s3, e, (i) => {
10181
7014
  if (i) return t(i);
10182
- m.unlink(e, t);
7015
+ u.unlink(e, t);
10183
7016
  });
10184
7017
  };
10185
7018
  var po = (s3) => {
10186
- if (!Te) return m.unlinkSync(s3);
7019
+ if (!Te) return u.unlinkSync(s3);
10187
7020
  let t = s3 + ".DELETE." + Mr(16).toString("hex");
10188
- m.renameSync(s3, t), m.unlinkSync(t);
7021
+ u.renameSync(s3, t), u.unlinkSync(t);
10189
7022
  };
10190
7023
  var vr = (s3, t, e) => s3 !== void 0 && s3 === s3 >>> 0 ? s3 : t !== void 0 && t === t >>> 0 ? t : e;
10191
7024
  var Xt = class extends rt {
@@ -10225,7 +7058,7 @@ var Xt = class extends rt {
10225
7058
  if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
10226
7059
  this.uid = t.uid, this.gid = t.gid, this.setOwner = true;
10227
7060
  } else this.uid = void 0, this.gid = void 0, this.setOwner = false;
10228
- this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : mo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(R.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
7061
+ this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? process.getuid?.() === 0 : !!t.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : uo, this.forceChown = t.forceChown === true, this.win32 = !!t.win32 || Te, this.newer = !!t.newer, this.keep = !!t.keep, this.noMtime = !!t.noMtime, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.cwd = f(R.resolve(t.cwd || process.cwd())), this.strip = Number(t.strip) || 0, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : Lr() : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
10229
7062
  }
10230
7063
  warn(t, e, i = {}) {
10231
7064
  return (t === "TAR_BAD_ARCHIVE" || t === "TAR_ABORT") && (i.recoverable = false), super.warn(t, e, i);
@@ -10299,18 +7132,18 @@ var Xt = class extends rt {
10299
7132
  return vr(this.gid, t.gid, this.processGid);
10300
7133
  }
10301
7134
  [Ts](t, e) {
10302
- let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), { flags: us(t.size), mode: i, autoClose: false });
7135
+ let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = new et(String(t.absolute), { flags: ms(t.size), mode: i, autoClose: false });
10303
7136
  r.on("error", (a) => {
10304
- r.fd && m.close(r.fd, () => {
7137
+ r.fd && u.close(r.fd, () => {
10305
7138
  }), r.write = () => true, this[O](a, t), e();
10306
7139
  });
10307
7140
  let n = 1, o = (a) => {
10308
7141
  if (a) {
10309
- r.fd && m.close(r.fd, () => {
7142
+ r.fd && u.close(r.fd, () => {
10310
7143
  }), this[O](a, t), e();
10311
7144
  return;
10312
7145
  }
10313
- --n === 0 && r.fd !== void 0 && m.close(r.fd, (l) => {
7146
+ --n === 0 && r.fd !== void 0 && u.close(r.fd, (l) => {
10314
7147
  l ? this[O](l, t) : this[$t](), e();
10315
7148
  });
10316
7149
  };
@@ -10319,12 +7152,12 @@ var Xt = class extends rt {
10319
7152
  if (typeof l == "number" && t.mtime && !this.noMtime) {
10320
7153
  n++;
10321
7154
  let c = t.atime || /* @__PURE__ */ new Date(), d = t.mtime;
10322
- m.futimes(l, c, d, (y) => y ? m.utimes(a, c, d, (T) => o(T && y)) : o());
7155
+ u.futimes(l, c, d, (y) => y ? u.utimes(a, c, d, (T) => o(T && y)) : o());
10323
7156
  }
10324
7157
  if (typeof l == "number" && this[ge](t)) {
10325
7158
  n++;
10326
7159
  let c = this[be](t), d = this[_e](t);
10327
- typeof c == "number" && typeof d == "number" && m.fchown(l, c, d, (y) => y ? m.chown(a, c, d, (T) => o(T && y)) : o());
7160
+ typeof c == "number" && typeof d == "number" && u.fchown(l, c, d, (y) => y ? u.chown(a, c, d, (T) => o(T && y)) : o());
10328
7161
  }
10329
7162
  o();
10330
7163
  });
@@ -10343,7 +7176,7 @@ var Xt = class extends rt {
10343
7176
  let n = 1, o = () => {
10344
7177
  --n === 0 && (e(), this[$t](), t.resume());
10345
7178
  };
10346
- t.mtime && !this.noMtime && (n++, m.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, m.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
7179
+ t.mtime && !this.noMtime && (n++, u.utimes(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime, o)), this[ge](t) && (n++, u.chown(String(t.absolute), Number(this[be](t)), Number(this[_e](t)), o)), o();
10347
7180
  });
10348
7181
  }
10349
7182
  [Cr](t) {
@@ -10365,7 +7198,7 @@ var Xt = class extends rt {
10365
7198
  let o = i.shift();
10366
7199
  if (this.preservePaths || o === void 0) return r();
10367
7200
  let h = R.resolve(e, o);
10368
- m.lstat(h, (a, l) => {
7201
+ u.lstat(h, (a, l) => {
10369
7202
  if (a) return r();
10370
7203
  if (l?.isSymbolicLink()) return n(new St(h, R.resolve(h, i.join("/"))));
10371
7204
  this[Re](t, h, i, r, n);
@@ -10412,7 +7245,7 @@ var Xt = class extends rt {
10412
7245
  }
10413
7246
  o();
10414
7247
  }, o = () => {
10415
- m.lstat(String(t.absolute), (h, a) => {
7248
+ u.lstat(String(t.absolute), (h, a) => {
10416
7249
  if (a && (this.keep || this.newer && a.mtime > (t.mtime ?? a.mtime))) {
10417
7250
  this[Ls](t), i();
10418
7251
  return;
@@ -10421,12 +7254,12 @@ var Xt = class extends rt {
10421
7254
  if (a.isDirectory()) {
10422
7255
  if (t.type === "Directory") {
10423
7256
  let l = this.chmod && t.mode && (a.mode & 4095) !== t.mode, c = (d) => this[P](d ?? null, t, i);
10424
- return l ? m.chmod(String(t.absolute), Number(t.mode), c) : c();
7257
+ return l ? u.chmod(String(t.absolute), Number(t.mode), c) : c();
10425
7258
  }
10426
- if (t.absolute !== this.cwd) return m.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
7259
+ if (t.absolute !== this.cwd) return u.rmdir(String(t.absolute), (l) => this[P](l ?? null, t, i));
10427
7260
  }
10428
7261
  if (t.absolute === this.cwd) return this[P](null, t, i);
10429
- uo(String(t.absolute), (l) => this[P](l ?? null, t, i));
7262
+ mo(String(t.absolute), (l) => this[P](l ?? null, t, i));
10430
7263
  });
10431
7264
  };
10432
7265
  this[Oe] ? n() : r();
@@ -10451,7 +7284,7 @@ var Xt = class extends rt {
10451
7284
  }
10452
7285
  }
10453
7286
  [gi](t, e, i, r) {
10454
- m[i](e, String(t.absolute), (n) => {
7287
+ u[i](e, String(t.absolute), (n) => {
10455
7288
  n ? this[O](n, t) : (this[$t](), t.resume()), r();
10456
7289
  });
10457
7290
  }
@@ -10482,17 +7315,17 @@ var xe = class extends Xt {
10482
7315
  if (o) return this[O](o, t);
10483
7316
  }
10484
7317
  }
10485
- let [e, i] = ye(() => m.lstatSync(String(t.absolute)));
7318
+ let [e, i] = ye(() => u.lstatSync(String(t.absolute)));
10486
7319
  if (i && (this.keep || this.newer && i.mtime > (t.mtime ?? i.mtime))) return this[Ls](t);
10487
7320
  if (e || this[Os](t, i)) return this[P](null, t);
10488
7321
  if (i.isDirectory()) {
10489
7322
  if (t.type === "Directory") {
10490
7323
  let o = this.chmod && t.mode && (i.mode & 4095) !== t.mode, [h] = o ? ye(() => {
10491
- m.chmodSync(String(t.absolute), Number(t.mode));
7324
+ u.chmodSync(String(t.absolute), Number(t.mode));
10492
7325
  }) : [];
10493
7326
  return this[P](h, t);
10494
7327
  }
10495
- let [n] = ye(() => m.rmdirSync(String(t.absolute)));
7328
+ let [n] = ye(() => u.rmdirSync(String(t.absolute)));
10496
7329
  this[P](n, t);
10497
7330
  }
10498
7331
  let [r] = t.absolute === this.cwd ? [] : ye(() => po(String(t.absolute)));
@@ -10502,21 +7335,21 @@ var xe = class extends Xt {
10502
7335
  let i = typeof t.mode == "number" ? t.mode & 4095 : this.fmode, r = (h) => {
10503
7336
  let a;
10504
7337
  try {
10505
- m.closeSync(n);
7338
+ u.closeSync(n);
10506
7339
  } catch (l) {
10507
7340
  a = l;
10508
7341
  }
10509
7342
  (h || a) && this[O](h || a, t), e();
10510
7343
  }, n;
10511
7344
  try {
10512
- n = m.openSync(String(t.absolute), us(t.size), i);
7345
+ n = u.openSync(String(t.absolute), ms(t.size), i);
10513
7346
  } catch (h) {
10514
7347
  return r(h);
10515
7348
  }
10516
7349
  let o = this.transform && this.transform(t) || t;
10517
7350
  o !== t && (o.on("error", (h) => this[O](h, t)), t.pipe(o)), o.on("data", (h) => {
10518
7351
  try {
10519
- m.writeSync(n, h, 0, h.length);
7352
+ u.writeSync(n, h, 0, h.length);
10520
7353
  } catch (a) {
10521
7354
  r(a);
10522
7355
  }
@@ -10525,10 +7358,10 @@ var xe = class extends Xt {
10525
7358
  if (t.mtime && !this.noMtime) {
10526
7359
  let a = t.atime || /* @__PURE__ */ new Date(), l = t.mtime;
10527
7360
  try {
10528
- m.futimesSync(n, a, l);
7361
+ u.futimesSync(n, a, l);
10529
7362
  } catch (c) {
10530
7363
  try {
10531
- m.utimesSync(String(t.absolute), a, l);
7364
+ u.utimesSync(String(t.absolute), a, l);
10532
7365
  } catch {
10533
7366
  h = c;
10534
7367
  }
@@ -10537,10 +7370,10 @@ var xe = class extends Xt {
10537
7370
  if (this[ge](t)) {
10538
7371
  let a = this[be](t), l = this[_e](t);
10539
7372
  try {
10540
- m.fchownSync(n, Number(a), Number(l));
7373
+ u.fchownSync(n, Number(a), Number(l));
10541
7374
  } catch (c) {
10542
7375
  try {
10543
- m.chownSync(String(t.absolute), Number(a), Number(l));
7376
+ u.chownSync(String(t.absolute), Number(a), Number(l));
10544
7377
  } catch {
10545
7378
  h = h || c;
10546
7379
  }
@@ -10556,11 +7389,11 @@ var xe = class extends Xt {
10556
7389
  return;
10557
7390
  }
10558
7391
  if (t.mtime && !this.noMtime) try {
10559
- m.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
7392
+ u.utimesSync(String(t.absolute), t.atime || /* @__PURE__ */ new Date(), t.mtime);
10560
7393
  } catch {
10561
7394
  }
10562
7395
  if (this[ge](t)) try {
10563
- m.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
7396
+ u.chownSync(String(t.absolute), Number(this[be](t)), Number(this[_e](t)));
10564
7397
  } catch {
10565
7398
  }
10566
7399
  e(), t.resume();
@@ -10577,7 +7410,7 @@ var xe = class extends Xt {
10577
7410
  let o = e;
10578
7411
  for (let h of i) {
10579
7412
  o = R.resolve(o, h);
10580
- let [a, l] = ye(() => m.lstatSync(o));
7413
+ let [a, l] = ye(() => u.lstatSync(o));
10581
7414
  if (a) return r();
10582
7415
  if (l.isSymbolicLink()) return n(new St(o, R.resolve(e, i.join("/"))));
10583
7416
  }
@@ -10586,7 +7419,7 @@ var xe = class extends Xt {
10586
7419
  [gi](t, e, i, r) {
10587
7420
  let n = `${i}Sync`;
10588
7421
  try {
10589
- m[n](e, String(t.absolute)), r(), t.resume();
7422
+ u[n](e, String(t.absolute)), r(), t.resume();
10590
7423
  } catch (o) {
10591
7424
  return this[O](o, t);
10592
7425
  }
@@ -12482,6 +9315,31 @@ async function verify(pkg, pkgAst, pkgPath, tarball, options) {
12482
9315
  var pkgFilepath = fileURLToPath4(new URL("../package.json", import.meta.url));
12483
9316
  var { version } = JSON.parse(readFileSync(pkgFilepath, "utf-8"));
12484
9317
  var PACKAGE_JSON = "package.json";
9318
+ var HELP_TEXT = `usage: index.js [-h] [-v] [-t TARBALL] [-p PKGFILE] [--cache CACHE]
9319
+ [--allow-dependency DEPENDENCY] [--allow-types-dependencies]
9320
+ [--ignore-missing-fields] [--ignore-node-version [MAJOR]]
9321
+
9322
+ Opiniated linter for NPM package tarball and package.json metadata
9323
+
9324
+ options:
9325
+ -h, --help show this help message and exit
9326
+ -v, --version show program's version number and exit
9327
+ -t, --tarball TARBALL
9328
+ specify tarball location
9329
+ -p, --pkgfile PKGFILE
9330
+ specify package.json location
9331
+ --cache CACHE specify cache directory
9332
+ --allow-dependency DEPENDENCY
9333
+ explicitly allow given dependency (can be given
9334
+ multiple times or as a comma-separated list)
9335
+ --allow-types-dependencies
9336
+ allow production dependencies to \`@types/*\`
9337
+ --ignore-missing-fields
9338
+ ignore errors for missing fields (but still checks for
9339
+ empty and valid)
9340
+ --ignore-node-version [MAJOR]
9341
+ ignore error for outdated node version (restricted to MAJOR version if given)
9342
+ `;
12485
9343
  async function preloadStdin() {
12486
9344
  return new Promise((resolve, reject) => {
12487
9345
  import_tmp.default.file((err, path8, fd) => {
@@ -12538,51 +9396,77 @@ async function getPackageJson(args, regenerateReportName) {
12538
9396
  }
12539
9397
  return { pkg: void 0, pkgAst: void 0, pkgPath: void 0 };
12540
9398
  }
12541
- async function run() {
12542
- const parser = new import_argparse.ArgumentParser({
12543
- description: "Opiniated linter for NPM package tarball and package.json metadata"
12544
- });
12545
- parser.add_argument("-v", "--version", { action: "version", version });
12546
- parser.add_argument("-t", "--tarball", { help: "specify tarball location" });
12547
- parser.add_argument("-p", "--pkgfile", { help: "specify package.json location" });
12548
- parser.add_argument("--cache", { help: "specify cache directory" });
12549
- parser.add_argument("--allow-dependency", {
12550
- action: "append",
12551
- default: [],
12552
- metavar: "DEPENDENCY",
12553
- help: "explicitly allow given dependency (can be given multiple times or as a comma-separated list)"
12554
- });
12555
- parser.add_argument("--allow-types-dependencies", {
12556
- action: "store_true",
12557
- help: "allow production dependencies to `@types/*`"
12558
- });
12559
- parser.add_argument("--ignore-missing-fields", {
12560
- action: "store_true",
12561
- help: "ignore errors for missing fields (but still checks for empty and valid)"
12562
- });
12563
- parser.add_argument("--ignore-node-version", {
12564
- nargs: "?",
12565
- metavar: "MAJOR",
12566
- type: "int",
12567
- default: false,
12568
- const: true,
12569
- help: "ignore error for outdated node version (restricted to MAJOR version if given)"
9399
+ function extractIgnoreNodeVersion(argv) {
9400
+ const FLAG = "--ignore-node-version";
9401
+ const rest = [];
9402
+ let value = false;
9403
+ for (let i = 0; i < argv.length; i++) {
9404
+ const arg = argv[i];
9405
+ if (arg === FLAG) {
9406
+ const next = argv[i + 1];
9407
+ if (typeof next === "string" && !next.startsWith("-")) {
9408
+ value = parseIgnoreNodeVersionValue(next);
9409
+ i++;
9410
+ } else {
9411
+ value = true;
9412
+ }
9413
+ continue;
9414
+ }
9415
+ if (arg.startsWith(`${FLAG}=`)) {
9416
+ value = parseIgnoreNodeVersionValue(arg.slice(FLAG.length + 1));
9417
+ continue;
9418
+ }
9419
+ rest.push(arg);
9420
+ }
9421
+ return { value, rest };
9422
+ }
9423
+ function parseIgnoreNodeVersionValue(raw) {
9424
+ const parsed = Number(raw);
9425
+ if (!Number.isSafeInteger(parsed)) {
9426
+ throw new TypeError(`argument --ignore-node-version: invalid int value: '${raw}'`);
9427
+ }
9428
+ return parsed;
9429
+ }
9430
+ function parseCliArgs(argv) {
9431
+ const { value: ignoreNodeVersion, rest } = extractIgnoreNodeVersion(argv);
9432
+ const { values } = parseArgs({
9433
+ args: rest,
9434
+ options: {
9435
+ help: { type: "boolean", short: "h" },
9436
+ version: { type: "boolean", short: "v" },
9437
+ tarball: { type: "string", short: "t" },
9438
+ pkgfile: { type: "string", short: "p" },
9439
+ cache: { type: "string" },
9440
+ "allow-dependency": { type: "string", multiple: true, default: [] },
9441
+ "allow-types-dependencies": { type: "boolean" },
9442
+ "ignore-missing-fields": { type: "boolean" }
9443
+ },
9444
+ strict: true
12570
9445
  });
12571
- const args = parser.parse_args();
12572
- const allowedDependencies2 = new Set(args.allow_dependency.flatMap((it2) => it2.split(",")));
12573
- if (args.cache) {
12574
- await setCacheDirecory(args.cache);
9446
+ if (values.help) {
9447
+ return { action: "help" };
12575
9448
  }
12576
- let regenerateReportName = false;
12577
- if (args.tarball === "-") {
12578
- args.tarball = await preloadStdin();
12579
- regenerateReportName = true;
9449
+ if (values.version) {
9450
+ return { action: "version" };
12580
9451
  }
9452
+ return {
9453
+ action: "run",
9454
+ args: {
9455
+ cache: values.cache,
9456
+ pkgfile: values.pkgfile,
9457
+ tarball: values.tarball,
9458
+ ignoreMissingFields: values["ignore-missing-fields"],
9459
+ ignoreNodeVersion,
9460
+ allowDependency: values["allow-dependency"],
9461
+ allowTypesDependencies: values["allow-types-dependencies"]
9462
+ }
9463
+ };
9464
+ }
9465
+ async function loadPackage(args, regenerateReportName) {
12581
9466
  const { pkg, pkgAst, pkgPath } = await getPackageJson(args, regenerateReportName);
12582
9467
  if (!pkg) {
12583
9468
  console.error("Failed to locate package.json and no location was specificed with `--pkgfile'");
12584
- process.exitCode = 1;
12585
- return;
9469
+ return void 0;
12586
9470
  }
12587
9471
  const tarball = {
12588
9472
  filePath: args.tarball ?? tarballLocation(pkg, pkgPath),
@@ -12590,15 +9474,49 @@ async function run() {
12590
9474
  };
12591
9475
  if (!existsSync(tarball.filePath)) {
12592
9476
  console.error(`"${tarball.filePath}" does not exist, did you forget to run \`npm pack'?`);
9477
+ return void 0;
9478
+ }
9479
+ return { pkg, pkgAst, pkgPath, tarball };
9480
+ }
9481
+ async function run() {
9482
+ let cli;
9483
+ try {
9484
+ cli = parseCliArgs(process.argv.slice(2));
9485
+ } catch (err) {
9486
+ console.error(err instanceof Error ? err.message : String(err));
9487
+ process.exitCode = 1;
9488
+ return;
9489
+ }
9490
+ if (cli.action === "help") {
9491
+ console.log(HELP_TEXT);
9492
+ return;
9493
+ }
9494
+ if (cli.action === "version") {
9495
+ console.log(version);
9496
+ return;
9497
+ }
9498
+ const { args } = cli;
9499
+ const allowedDependencies2 = new Set(args.allowDependency.flatMap((it2) => it2.split(",")));
9500
+ if (args.cache) {
9501
+ await setCacheDirecory(args.cache);
9502
+ }
9503
+ let regenerateReportName = false;
9504
+ if (args.tarball === "-") {
9505
+ args.tarball = await preloadStdin();
9506
+ regenerateReportName = true;
9507
+ }
9508
+ const loaded = await loadPackage(args, regenerateReportName);
9509
+ if (!loaded) {
12593
9510
  process.exitCode = 1;
12594
9511
  return;
12595
9512
  }
9513
+ const { pkg, pkgAst, pkgPath, tarball } = loaded;
12596
9514
  setupBlacklist(pkg.name);
12597
9515
  const options = {
12598
9516
  allowedDependencies: allowedDependencies2,
12599
- allowTypesDependencies: args.allow_types_dependencies,
12600
- ignoreMissingFields: args.ignore_missing_fields,
12601
- ignoreNodeVersion: args.ignore_node_version
9517
+ allowTypesDependencies: args.allowTypesDependencies,
9518
+ ignoreMissingFields: args.ignoreMissingFields,
9519
+ ignoreNodeVersion: args.ignoreNodeVersion
12602
9520
  };
12603
9521
  const results = await verify(pkg, pkgAst, pkgPath, tarball, options);
12604
9522
  for (const result of results) {