@apocaliss92/addon-series-scraper 0.0.0-stage → 0.1.21
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/CHANGELOG.md +174 -0
- package/README.md +134 -2
- package/assets/icon.svg +22 -0
- package/dist/_stub.js +11345 -0
- package/dist/_virtual_mf-localSharedImportMap___mfe_internal__addon_series_scraper_page__mf_owner__1-C2oznnyl.js +82 -0
- package/dist/addon.js +377 -0
- package/dist/dist-CXrbtx5R.js +19 -0
- package/dist/docker-import-C1Os3QjE.js +316 -0
- package/dist/embedded.js +925 -0
- package/dist/esm-BaRSigns.js +1331 -0
- package/dist/extract-zip-cgdW-jDq.js +1346 -0
- package/dist/helpers-BBnuD0Mu.js +5 -0
- package/dist/helpers-CpKI7ps_.js +9 -0
- package/dist/hostInit-D1MnMgTc.js +177 -0
- package/dist/index.js +3 -0
- package/dist/pendingShares-CffjjPWP.js +38 -0
- package/dist/proxy-Btrb1iBN.js +233455 -0
- package/dist/pump-DDROyUu9.js +161 -0
- package/dist/remoteEntry.js +783 -0
- package/dist/rolldown-runtime-cIwnrN2i.js +46 -0
- package/dist/state-store-DT6l2jtx.js +420 -0
- package/dist/tar-fs-ZoqVwI4a.js +2673 -0
- package/dist/utils-CHYfMMdo.js +2951 -0
- package/dist/yargs-CBdcwHg0.js +2867 -0
- package/i18n/en.json +43 -0
- package/i18n/it.json +43 -0
- package/package.json +107 -4
|
@@ -0,0 +1,1331 @@
|
|
|
1
|
+
import { createRequire as __scraperCreateRequire, createRequire as __createRequire } from "node:module";
|
|
2
|
+
__scraperCreateRequire(import.meta.url);
|
|
3
|
+
import { n as __esmMin } from "./rolldown-runtime-cIwnrN2i.js";
|
|
4
|
+
import { notStrictEqual, strictEqual } from "assert";
|
|
5
|
+
import { basename, dirname, extname, normalize, relative, resolve } from "path";
|
|
6
|
+
import { readFileSync, readdirSync, statSync, writeFile } from "fs";
|
|
7
|
+
import { format, inspect } from "util";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
function __require() {
|
|
10
|
+
const require = __createRequire(import.meta.url);
|
|
11
|
+
__require = () => require;
|
|
12
|
+
return require;
|
|
13
|
+
}
|
|
14
|
+
// node_modules/yargs/build/lib/yerror.js
|
|
15
|
+
var YError;
|
|
16
|
+
var init_yerror = __esmMin((() => {
|
|
17
|
+
YError = class YError extends Error {
|
|
18
|
+
constructor(msg) {
|
|
19
|
+
super(msg || "yargs error");
|
|
20
|
+
this.name = "YError";
|
|
21
|
+
if (Error.captureStackTrace) Error.captureStackTrace(this, YError);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}));
|
|
25
|
+
// node_modules/yargs/build/lib/utils/process-argv.js
|
|
26
|
+
function getProcessArgvBinIndex() {
|
|
27
|
+
if (isBundledElectronApp()) return 0;
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
function isBundledElectronApp() {
|
|
31
|
+
return isElectronApp() && !process.defaultApp;
|
|
32
|
+
}
|
|
33
|
+
function isElectronApp() {
|
|
34
|
+
return !!process.versions.electron;
|
|
35
|
+
}
|
|
36
|
+
function hideBin(argv) {
|
|
37
|
+
return argv.slice(getProcessArgvBinIndex() + 1);
|
|
38
|
+
}
|
|
39
|
+
function getProcessArgvBin() {
|
|
40
|
+
return process.argv[getProcessArgvBinIndex()];
|
|
41
|
+
}
|
|
42
|
+
var init_process_argv = __esmMin((() => {}));
|
|
43
|
+
// node_modules/yargs-parser/build/lib/string-utils.js
|
|
44
|
+
/**
|
|
45
|
+
* @license
|
|
46
|
+
* Copyright (c) 2016, Contributors
|
|
47
|
+
* SPDX-License-Identifier: ISC
|
|
48
|
+
*/
|
|
49
|
+
function camelCase(str) {
|
|
50
|
+
if (!(str !== str.toLowerCase() && str !== str.toUpperCase())) str = str.toLowerCase();
|
|
51
|
+
if (str.indexOf("-") === -1 && str.indexOf("_") === -1) return str;
|
|
52
|
+
else {
|
|
53
|
+
let camelcase = "";
|
|
54
|
+
let nextChrUpper = false;
|
|
55
|
+
const leadingHyphens = str.match(/^-+/);
|
|
56
|
+
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
|
|
57
|
+
let chr = str.charAt(i);
|
|
58
|
+
if (nextChrUpper) {
|
|
59
|
+
nextChrUpper = false;
|
|
60
|
+
chr = chr.toUpperCase();
|
|
61
|
+
}
|
|
62
|
+
if (i !== 0 && (chr === "-" || chr === "_")) nextChrUpper = true;
|
|
63
|
+
else if (chr !== "-" && chr !== "_") camelcase += chr;
|
|
64
|
+
}
|
|
65
|
+
return camelcase;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function decamelize(str, joinString) {
|
|
69
|
+
const lowercase = str.toLowerCase();
|
|
70
|
+
joinString = joinString || "-";
|
|
71
|
+
let notCamelcase = "";
|
|
72
|
+
for (let i = 0; i < str.length; i++) {
|
|
73
|
+
const chrLower = lowercase.charAt(i);
|
|
74
|
+
const chrString = str.charAt(i);
|
|
75
|
+
if (chrLower !== chrString && i > 0) notCamelcase += `${joinString}${lowercase.charAt(i)}`;
|
|
76
|
+
else notCamelcase += chrString;
|
|
77
|
+
}
|
|
78
|
+
return notCamelcase;
|
|
79
|
+
}
|
|
80
|
+
function looksLikeNumber(x) {
|
|
81
|
+
if (x === null || x === void 0) return false;
|
|
82
|
+
if (typeof x === "number") return true;
|
|
83
|
+
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
|
84
|
+
if (/^0[^.]/.test(x)) return false;
|
|
85
|
+
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
86
|
+
}
|
|
87
|
+
__esmMin((() => {}));
|
|
88
|
+
// node_modules/yargs-parser/build/lib/tokenize-arg-string.js
|
|
89
|
+
/**
|
|
90
|
+
* @license
|
|
91
|
+
* Copyright (c) 2016, Contributors
|
|
92
|
+
* SPDX-License-Identifier: ISC
|
|
93
|
+
*/
|
|
94
|
+
function tokenizeArgString(argString) {
|
|
95
|
+
if (Array.isArray(argString)) return argString.map((e) => typeof e !== "string" ? e + "" : e);
|
|
96
|
+
argString = argString.trim();
|
|
97
|
+
let i = 0;
|
|
98
|
+
let prevC = null;
|
|
99
|
+
let c = null;
|
|
100
|
+
let opening = null;
|
|
101
|
+
const args = [];
|
|
102
|
+
for (let ii = 0; ii < argString.length; ii++) {
|
|
103
|
+
prevC = c;
|
|
104
|
+
c = argString.charAt(ii);
|
|
105
|
+
if (c === " " && !opening) {
|
|
106
|
+
if (!(prevC === " ")) i++;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (c === opening) opening = null;
|
|
110
|
+
else if ((c === "'" || c === "\"") && !opening) opening = c;
|
|
111
|
+
if (!args[i]) args[i] = "";
|
|
112
|
+
args[i] += c;
|
|
113
|
+
}
|
|
114
|
+
return args;
|
|
115
|
+
}
|
|
116
|
+
__esmMin((() => {}));
|
|
117
|
+
// node_modules/yargs-parser/build/lib/yargs-parser-types.js
|
|
118
|
+
var DefaultValuesForTypeKey;
|
|
119
|
+
var init_yargs_parser_types = __esmMin((() => {
|
|
120
|
+
/**
|
|
121
|
+
* @license
|
|
122
|
+
* Copyright (c) 2016, Contributors
|
|
123
|
+
* SPDX-License-Identifier: ISC
|
|
124
|
+
*/
|
|
125
|
+
(function(DefaultValuesForTypeKey) {
|
|
126
|
+
DefaultValuesForTypeKey["BOOLEAN"] = "boolean";
|
|
127
|
+
DefaultValuesForTypeKey["STRING"] = "string";
|
|
128
|
+
DefaultValuesForTypeKey["NUMBER"] = "number";
|
|
129
|
+
DefaultValuesForTypeKey["ARRAY"] = "array";
|
|
130
|
+
})(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
|
|
131
|
+
}));
|
|
132
|
+
// node_modules/yargs-parser/build/lib/yargs-parser.js
|
|
133
|
+
/**
|
|
134
|
+
* @license
|
|
135
|
+
* Copyright (c) 2016, Contributors
|
|
136
|
+
* SPDX-License-Identifier: ISC
|
|
137
|
+
*/
|
|
138
|
+
function combineAliases(aliases) {
|
|
139
|
+
const aliasArrays = [];
|
|
140
|
+
const combined = Object.create(null);
|
|
141
|
+
let change = true;
|
|
142
|
+
Object.keys(aliases).forEach(function(key) {
|
|
143
|
+
aliasArrays.push([].concat(aliases[key], key));
|
|
144
|
+
});
|
|
145
|
+
while (change) {
|
|
146
|
+
change = false;
|
|
147
|
+
for (let i = 0; i < aliasArrays.length; i++) for (let ii = i + 1; ii < aliasArrays.length; ii++) if (aliasArrays[i].filter(function(v) {
|
|
148
|
+
return aliasArrays[ii].indexOf(v) !== -1;
|
|
149
|
+
}).length) {
|
|
150
|
+
aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
|
|
151
|
+
aliasArrays.splice(ii, 1);
|
|
152
|
+
change = true;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
aliasArrays.forEach(function(aliasArray) {
|
|
157
|
+
aliasArray = aliasArray.filter(function(v, i, self) {
|
|
158
|
+
return self.indexOf(v) === i;
|
|
159
|
+
});
|
|
160
|
+
const lastAlias = aliasArray.pop();
|
|
161
|
+
if (lastAlias !== void 0 && typeof lastAlias === "string") combined[lastAlias] = aliasArray;
|
|
162
|
+
});
|
|
163
|
+
return combined;
|
|
164
|
+
}
|
|
165
|
+
function increment(orig) {
|
|
166
|
+
return orig !== void 0 ? orig + 1 : 1;
|
|
167
|
+
}
|
|
168
|
+
function sanitizeKey(key) {
|
|
169
|
+
if (key === "__proto__") return "___proto___";
|
|
170
|
+
return key;
|
|
171
|
+
}
|
|
172
|
+
function stripQuotes(val) {
|
|
173
|
+
return typeof val === "string" && (val[0] === "'" || val[0] === "\"") && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
|
|
174
|
+
}
|
|
175
|
+
var mixin$1, YargsParser;
|
|
176
|
+
var init_yargs_parser = __esmMin((() => {
|
|
177
|
+
init_yargs_parser_types();
|
|
178
|
+
YargsParser = class {
|
|
179
|
+
constructor(_mixin) {
|
|
180
|
+
mixin$1 = _mixin;
|
|
181
|
+
}
|
|
182
|
+
parse(argsInput, options) {
|
|
183
|
+
const opts = Object.assign({
|
|
184
|
+
alias: void 0,
|
|
185
|
+
array: void 0,
|
|
186
|
+
boolean: void 0,
|
|
187
|
+
config: void 0,
|
|
188
|
+
configObjects: void 0,
|
|
189
|
+
configuration: void 0,
|
|
190
|
+
coerce: void 0,
|
|
191
|
+
count: void 0,
|
|
192
|
+
default: void 0,
|
|
193
|
+
envPrefix: void 0,
|
|
194
|
+
narg: void 0,
|
|
195
|
+
normalize: void 0,
|
|
196
|
+
string: void 0,
|
|
197
|
+
number: void 0,
|
|
198
|
+
__: void 0,
|
|
199
|
+
key: void 0
|
|
200
|
+
}, options);
|
|
201
|
+
const args = tokenizeArgString(argsInput);
|
|
202
|
+
const inputIsString = typeof argsInput === "string";
|
|
203
|
+
const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
|
|
204
|
+
const configuration = Object.assign({
|
|
205
|
+
"boolean-negation": true,
|
|
206
|
+
"camel-case-expansion": true,
|
|
207
|
+
"combine-arrays": false,
|
|
208
|
+
"dot-notation": true,
|
|
209
|
+
"duplicate-arguments-array": true,
|
|
210
|
+
"flatten-duplicate-arrays": true,
|
|
211
|
+
"greedy-arrays": true,
|
|
212
|
+
"halt-at-non-option": false,
|
|
213
|
+
"nargs-eats-options": false,
|
|
214
|
+
"negation-prefix": "no-",
|
|
215
|
+
"parse-numbers": true,
|
|
216
|
+
"parse-positional-numbers": true,
|
|
217
|
+
"populate--": false,
|
|
218
|
+
"set-placeholder-key": false,
|
|
219
|
+
"short-option-groups": true,
|
|
220
|
+
"strip-aliased": false,
|
|
221
|
+
"strip-dashed": false,
|
|
222
|
+
"unknown-options-as-args": false
|
|
223
|
+
}, opts.configuration);
|
|
224
|
+
const defaults = Object.assign(Object.create(null), opts.default);
|
|
225
|
+
const configObjects = opts.configObjects || [];
|
|
226
|
+
const envPrefix = opts.envPrefix;
|
|
227
|
+
const notFlagsOption = configuration["populate--"];
|
|
228
|
+
const notFlagsArgv = notFlagsOption ? "--" : "_";
|
|
229
|
+
const newAliases = Object.create(null);
|
|
230
|
+
const defaulted = Object.create(null);
|
|
231
|
+
const __ = opts.__ || mixin$1.format;
|
|
232
|
+
const flags = {
|
|
233
|
+
aliases: Object.create(null),
|
|
234
|
+
arrays: Object.create(null),
|
|
235
|
+
bools: Object.create(null),
|
|
236
|
+
strings: Object.create(null),
|
|
237
|
+
numbers: Object.create(null),
|
|
238
|
+
counts: Object.create(null),
|
|
239
|
+
normalize: Object.create(null),
|
|
240
|
+
configs: Object.create(null),
|
|
241
|
+
nargs: Object.create(null),
|
|
242
|
+
coercions: Object.create(null),
|
|
243
|
+
keys: []
|
|
244
|
+
};
|
|
245
|
+
const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
|
|
246
|
+
const negatedBoolean = new RegExp("^--" + configuration["negation-prefix"] + "(.+)");
|
|
247
|
+
[].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
|
|
248
|
+
const key = typeof opt === "object" ? opt.key : opt;
|
|
249
|
+
const assignment = Object.keys(opt).map(function(key) {
|
|
250
|
+
return {
|
|
251
|
+
boolean: "bools",
|
|
252
|
+
string: "strings",
|
|
253
|
+
number: "numbers"
|
|
254
|
+
}[key];
|
|
255
|
+
}).filter(Boolean).pop();
|
|
256
|
+
if (assignment) flags[assignment][key] = true;
|
|
257
|
+
flags.arrays[key] = true;
|
|
258
|
+
flags.keys.push(key);
|
|
259
|
+
});
|
|
260
|
+
[].concat(opts.boolean || []).filter(Boolean).forEach(function(key) {
|
|
261
|
+
flags.bools[key] = true;
|
|
262
|
+
flags.keys.push(key);
|
|
263
|
+
});
|
|
264
|
+
[].concat(opts.string || []).filter(Boolean).forEach(function(key) {
|
|
265
|
+
flags.strings[key] = true;
|
|
266
|
+
flags.keys.push(key);
|
|
267
|
+
});
|
|
268
|
+
[].concat(opts.number || []).filter(Boolean).forEach(function(key) {
|
|
269
|
+
flags.numbers[key] = true;
|
|
270
|
+
flags.keys.push(key);
|
|
271
|
+
});
|
|
272
|
+
[].concat(opts.count || []).filter(Boolean).forEach(function(key) {
|
|
273
|
+
flags.counts[key] = true;
|
|
274
|
+
flags.keys.push(key);
|
|
275
|
+
});
|
|
276
|
+
[].concat(opts.normalize || []).filter(Boolean).forEach(function(key) {
|
|
277
|
+
flags.normalize[key] = true;
|
|
278
|
+
flags.keys.push(key);
|
|
279
|
+
});
|
|
280
|
+
if (typeof opts.narg === "object") Object.entries(opts.narg).forEach(([key, value]) => {
|
|
281
|
+
if (typeof value === "number") {
|
|
282
|
+
flags.nargs[key] = value;
|
|
283
|
+
flags.keys.push(key);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
if (typeof opts.coerce === "object") Object.entries(opts.coerce).forEach(([key, value]) => {
|
|
287
|
+
if (typeof value === "function") {
|
|
288
|
+
flags.coercions[key] = value;
|
|
289
|
+
flags.keys.push(key);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
if (typeof opts.config !== "undefined") {
|
|
293
|
+
if (Array.isArray(opts.config) || typeof opts.config === "string") [].concat(opts.config).filter(Boolean).forEach(function(key) {
|
|
294
|
+
flags.configs[key] = true;
|
|
295
|
+
});
|
|
296
|
+
else if (typeof opts.config === "object") Object.entries(opts.config).forEach(([key, value]) => {
|
|
297
|
+
if (typeof value === "boolean" || typeof value === "function") flags.configs[key] = value;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
extendAliases(opts.key, aliases, opts.default, flags.arrays);
|
|
301
|
+
Object.keys(defaults).forEach(function(key) {
|
|
302
|
+
(flags.aliases[key] || []).forEach(function(alias) {
|
|
303
|
+
defaults[alias] = defaults[key];
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
let error = null;
|
|
307
|
+
checkConfiguration();
|
|
308
|
+
let notFlags = [];
|
|
309
|
+
const argv = Object.assign(Object.create(null), { _: [] });
|
|
310
|
+
const argvReturn = {};
|
|
311
|
+
for (let i = 0; i < args.length; i++) {
|
|
312
|
+
const arg = args[i];
|
|
313
|
+
const truncatedArg = arg.replace(/^-{3,}/, "---");
|
|
314
|
+
let broken;
|
|
315
|
+
let key;
|
|
316
|
+
let letters;
|
|
317
|
+
let m;
|
|
318
|
+
let next;
|
|
319
|
+
let value;
|
|
320
|
+
if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) pushPositional(arg);
|
|
321
|
+
else if (truncatedArg.match(/^---+(=|$)/)) {
|
|
322
|
+
pushPositional(arg);
|
|
323
|
+
continue;
|
|
324
|
+
} else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
|
|
325
|
+
m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
|
|
326
|
+
if (m !== null && Array.isArray(m) && m.length >= 3) {
|
|
327
|
+
if (checkAllAliases(m[1], flags.arrays)) i = eatArray(i, m[1], args, m[2]);
|
|
328
|
+
else if (checkAllAliases(m[1], flags.nargs) !== false) i = eatNargs(i, m[1], args, m[2]);
|
|
329
|
+
else setArg(m[1], m[2], true);
|
|
330
|
+
}
|
|
331
|
+
} else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
|
|
332
|
+
m = arg.match(negatedBoolean);
|
|
333
|
+
if (m !== null && Array.isArray(m) && m.length >= 2) {
|
|
334
|
+
key = m[1];
|
|
335
|
+
setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
|
|
336
|
+
}
|
|
337
|
+
} else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
|
|
338
|
+
m = arg.match(/^--?(.+)/);
|
|
339
|
+
if (m !== null && Array.isArray(m) && m.length >= 2) {
|
|
340
|
+
key = m[1];
|
|
341
|
+
if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
|
|
342
|
+
else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
|
|
343
|
+
else {
|
|
344
|
+
next = args[i + 1];
|
|
345
|
+
if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
|
346
|
+
setArg(key, next);
|
|
347
|
+
i++;
|
|
348
|
+
} else if (/^(true|false)$/.test(next)) {
|
|
349
|
+
setArg(key, next);
|
|
350
|
+
i++;
|
|
351
|
+
} else setArg(key, defaultValue(key));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} else if (arg.match(/^-.\..+=/)) {
|
|
355
|
+
m = arg.match(/^-([^=]+)=([\s\S]*)$/);
|
|
356
|
+
if (m !== null && Array.isArray(m) && m.length >= 3) setArg(m[1], m[2]);
|
|
357
|
+
} else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
|
|
358
|
+
next = args[i + 1];
|
|
359
|
+
m = arg.match(/^-(.\..+)/);
|
|
360
|
+
if (m !== null && Array.isArray(m) && m.length >= 2) {
|
|
361
|
+
key = m[1];
|
|
362
|
+
if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
|
363
|
+
setArg(key, next);
|
|
364
|
+
i++;
|
|
365
|
+
} else setArg(key, defaultValue(key));
|
|
366
|
+
}
|
|
367
|
+
} else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
|
|
368
|
+
letters = arg.slice(1, -1).split("");
|
|
369
|
+
broken = false;
|
|
370
|
+
for (let j = 0; j < letters.length; j++) {
|
|
371
|
+
next = arg.slice(j + 2);
|
|
372
|
+
if (letters[j + 1] && letters[j + 1] === "=") {
|
|
373
|
+
value = arg.slice(j + 3);
|
|
374
|
+
key = letters[j];
|
|
375
|
+
if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args, value);
|
|
376
|
+
else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args, value);
|
|
377
|
+
else setArg(key, value);
|
|
378
|
+
broken = true;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
if (next === "-") {
|
|
382
|
+
setArg(letters[j], next);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) {
|
|
386
|
+
setArg(letters[j], next);
|
|
387
|
+
broken = true;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
|
391
|
+
setArg(letters[j], next);
|
|
392
|
+
broken = true;
|
|
393
|
+
break;
|
|
394
|
+
} else setArg(letters[j], defaultValue(letters[j]));
|
|
395
|
+
}
|
|
396
|
+
key = arg.slice(-1)[0];
|
|
397
|
+
if (!broken && key !== "-") {
|
|
398
|
+
if (checkAllAliases(key, flags.arrays)) i = eatArray(i, key, args);
|
|
399
|
+
else if (checkAllAliases(key, flags.nargs) !== false) i = eatNargs(i, key, args);
|
|
400
|
+
else {
|
|
401
|
+
next = args[i + 1];
|
|
402
|
+
if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
|
403
|
+
setArg(key, next);
|
|
404
|
+
i++;
|
|
405
|
+
} else if (/^(true|false)$/.test(next)) {
|
|
406
|
+
setArg(key, next);
|
|
407
|
+
i++;
|
|
408
|
+
} else setArg(key, defaultValue(key));
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
} else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
|
|
412
|
+
key = arg.slice(1);
|
|
413
|
+
setArg(key, defaultValue(key));
|
|
414
|
+
} else if (arg === "--") {
|
|
415
|
+
notFlags = args.slice(i + 1);
|
|
416
|
+
break;
|
|
417
|
+
} else if (configuration["halt-at-non-option"]) {
|
|
418
|
+
notFlags = args.slice(i);
|
|
419
|
+
break;
|
|
420
|
+
} else pushPositional(arg);
|
|
421
|
+
}
|
|
422
|
+
applyEnvVars(argv, true);
|
|
423
|
+
applyEnvVars(argv, false);
|
|
424
|
+
setConfig(argv);
|
|
425
|
+
setConfigObjects();
|
|
426
|
+
applyDefaultsAndAliases(argv, flags.aliases, defaults, true);
|
|
427
|
+
applyCoercions(argv);
|
|
428
|
+
if (configuration["set-placeholder-key"]) setPlaceholderKeys(argv);
|
|
429
|
+
Object.keys(flags.counts).forEach(function(key) {
|
|
430
|
+
if (!hasKey(argv, key.split("."))) setArg(key, 0);
|
|
431
|
+
});
|
|
432
|
+
if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = [];
|
|
433
|
+
notFlags.forEach(function(key) {
|
|
434
|
+
argv[notFlagsArgv].push(key);
|
|
435
|
+
});
|
|
436
|
+
if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) Object.keys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
|
|
437
|
+
delete argv[key];
|
|
438
|
+
});
|
|
439
|
+
if (configuration["strip-aliased"]) [].concat(...Object.keys(aliases).map((k) => aliases[k])).forEach((alias) => {
|
|
440
|
+
if (configuration["camel-case-expansion"] && alias.includes("-")) delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")];
|
|
441
|
+
delete argv[alias];
|
|
442
|
+
});
|
|
443
|
+
function pushPositional(arg) {
|
|
444
|
+
const maybeCoercedNumber = maybeCoerceNumber("_", arg);
|
|
445
|
+
if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") argv._.push(maybeCoercedNumber);
|
|
446
|
+
}
|
|
447
|
+
function eatNargs(i, key, args, argAfterEqualSign) {
|
|
448
|
+
let ii;
|
|
449
|
+
let toEat = checkAllAliases(key, flags.nargs);
|
|
450
|
+
toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
|
|
451
|
+
if (toEat === 0) {
|
|
452
|
+
if (!isUndefined(argAfterEqualSign)) error = Error(__("Argument unexpected for: %s", key));
|
|
453
|
+
setArg(key, defaultValue(key));
|
|
454
|
+
return i;
|
|
455
|
+
}
|
|
456
|
+
let available = isUndefined(argAfterEqualSign) ? 0 : 1;
|
|
457
|
+
if (configuration["nargs-eats-options"]) {
|
|
458
|
+
if (args.length - (i + 1) + available < toEat) error = Error(__("Not enough arguments following: %s", key));
|
|
459
|
+
available = toEat;
|
|
460
|
+
} else {
|
|
461
|
+
for (ii = i + 1; ii < args.length; ii++) if (!args[ii].match(/^-[^0-9]/) || args[ii].match(negative) || isUnknownOptionAsArg(args[ii])) available++;
|
|
462
|
+
else break;
|
|
463
|
+
if (available < toEat) error = Error(__("Not enough arguments following: %s", key));
|
|
464
|
+
}
|
|
465
|
+
let consumed = Math.min(available, toEat);
|
|
466
|
+
if (!isUndefined(argAfterEqualSign) && consumed > 0) {
|
|
467
|
+
setArg(key, argAfterEqualSign);
|
|
468
|
+
consumed--;
|
|
469
|
+
}
|
|
470
|
+
for (ii = i + 1; ii < consumed + i + 1; ii++) setArg(key, args[ii]);
|
|
471
|
+
return i + consumed;
|
|
472
|
+
}
|
|
473
|
+
function eatArray(i, key, args, argAfterEqualSign) {
|
|
474
|
+
let argsToSet = [];
|
|
475
|
+
let next = argAfterEqualSign || args[i + 1];
|
|
476
|
+
const nargsCount = checkAllAliases(key, flags.nargs);
|
|
477
|
+
if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) argsToSet.push(true);
|
|
478
|
+
else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
|
|
479
|
+
if (defaults[key] !== void 0) {
|
|
480
|
+
const defVal = defaults[key];
|
|
481
|
+
argsToSet = Array.isArray(defVal) ? defVal : [defVal];
|
|
482
|
+
}
|
|
483
|
+
} else {
|
|
484
|
+
if (!isUndefined(argAfterEqualSign)) argsToSet.push(processValue(key, argAfterEqualSign, true));
|
|
485
|
+
for (let ii = i + 1; ii < args.length; ii++) {
|
|
486
|
+
if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount) break;
|
|
487
|
+
next = args[ii];
|
|
488
|
+
if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) break;
|
|
489
|
+
i = ii;
|
|
490
|
+
argsToSet.push(processValue(key, next, inputIsString));
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) error = Error(__("Not enough arguments following: %s", key));
|
|
494
|
+
setArg(key, argsToSet);
|
|
495
|
+
return i;
|
|
496
|
+
}
|
|
497
|
+
function setArg(key, val, shouldStripQuotes = inputIsString) {
|
|
498
|
+
if (/-/.test(key) && configuration["camel-case-expansion"]) addNewAlias(key, key.split(".").map(function(prop) {
|
|
499
|
+
return camelCase(prop);
|
|
500
|
+
}).join("."));
|
|
501
|
+
const value = processValue(key, val, shouldStripQuotes);
|
|
502
|
+
const splitKey = key.split(".");
|
|
503
|
+
setKey(argv, splitKey, value);
|
|
504
|
+
if (flags.aliases[key]) flags.aliases[key].forEach(function(x) {
|
|
505
|
+
const keyProperties = x.split(".");
|
|
506
|
+
setKey(argv, keyProperties, value);
|
|
507
|
+
});
|
|
508
|
+
if (splitKey.length > 1 && configuration["dot-notation"]) (flags.aliases[splitKey[0]] || []).forEach(function(x) {
|
|
509
|
+
let keyProperties = x.split(".");
|
|
510
|
+
const a = [].concat(splitKey);
|
|
511
|
+
a.shift();
|
|
512
|
+
keyProperties = keyProperties.concat(a);
|
|
513
|
+
if (!(flags.aliases[key] || []).includes(keyProperties.join("."))) setKey(argv, keyProperties, value);
|
|
514
|
+
});
|
|
515
|
+
if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) [key].concat(flags.aliases[key] || []).forEach(function(key) {
|
|
516
|
+
Object.defineProperty(argvReturn, key, {
|
|
517
|
+
enumerable: true,
|
|
518
|
+
get() {
|
|
519
|
+
return val;
|
|
520
|
+
},
|
|
521
|
+
set(value) {
|
|
522
|
+
val = typeof value === "string" ? mixin$1.normalize(value) : value;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
function addNewAlias(key, alias) {
|
|
528
|
+
if (!(flags.aliases[key] && flags.aliases[key].length)) {
|
|
529
|
+
flags.aliases[key] = [alias];
|
|
530
|
+
newAliases[alias] = true;
|
|
531
|
+
}
|
|
532
|
+
if (!(flags.aliases[alias] && flags.aliases[alias].length)) addNewAlias(alias, key);
|
|
533
|
+
}
|
|
534
|
+
function processValue(key, val, shouldStripQuotes) {
|
|
535
|
+
if (shouldStripQuotes) val = stripQuotes(val);
|
|
536
|
+
if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
|
|
537
|
+
if (typeof val === "string") val = val === "true";
|
|
538
|
+
}
|
|
539
|
+
let value = Array.isArray(val) ? val.map(function(v) {
|
|
540
|
+
return maybeCoerceNumber(key, v);
|
|
541
|
+
}) : maybeCoerceNumber(key, val);
|
|
542
|
+
if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) value = increment();
|
|
543
|
+
if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
|
|
544
|
+
if (Array.isArray(val)) value = val.map((val) => {
|
|
545
|
+
return mixin$1.normalize(val);
|
|
546
|
+
});
|
|
547
|
+
else value = mixin$1.normalize(val);
|
|
548
|
+
}
|
|
549
|
+
return value;
|
|
550
|
+
}
|
|
551
|
+
function maybeCoerceNumber(key, value) {
|
|
552
|
+
if (!configuration["parse-positional-numbers"] && key === "_") return value;
|
|
553
|
+
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
|
|
554
|
+
if (looksLikeNumber(value) && configuration["parse-numbers"] && Number.isSafeInteger(Math.floor(parseFloat(`${value}`))) || !isUndefined(value) && checkAllAliases(key, flags.numbers)) value = Number(value);
|
|
555
|
+
}
|
|
556
|
+
return value;
|
|
557
|
+
}
|
|
558
|
+
function setConfig(argv) {
|
|
559
|
+
const configLookup = Object.create(null);
|
|
560
|
+
applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
|
|
561
|
+
Object.keys(flags.configs).forEach(function(configKey) {
|
|
562
|
+
const configPath = argv[configKey] || configLookup[configKey];
|
|
563
|
+
if (configPath) try {
|
|
564
|
+
let config = null;
|
|
565
|
+
const resolvedConfigPath = mixin$1.resolve(mixin$1.cwd(), configPath);
|
|
566
|
+
const resolveConfig = flags.configs[configKey];
|
|
567
|
+
if (typeof resolveConfig === "function") {
|
|
568
|
+
try {
|
|
569
|
+
config = resolveConfig(resolvedConfigPath);
|
|
570
|
+
} catch (e) {
|
|
571
|
+
config = e;
|
|
572
|
+
}
|
|
573
|
+
if (config instanceof Error) {
|
|
574
|
+
error = config;
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
} else config = mixin$1.require(resolvedConfigPath);
|
|
578
|
+
setConfigObject(config);
|
|
579
|
+
} catch (ex) {
|
|
580
|
+
if (ex.name === "PermissionDenied") error = ex;
|
|
581
|
+
else if (argv[configKey]) error = Error(__("Invalid JSON config file: %s", configPath));
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function setConfigObject(config, prev) {
|
|
586
|
+
Object.keys(config).forEach(function(key) {
|
|
587
|
+
const value = config[key];
|
|
588
|
+
const fullKey = prev ? prev + "." + key : key;
|
|
589
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && configuration["dot-notation"]) setConfigObject(value, fullKey);
|
|
590
|
+
else if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) setArg(fullKey, value);
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
function setConfigObjects() {
|
|
594
|
+
if (typeof configObjects !== "undefined") configObjects.forEach(function(configObject) {
|
|
595
|
+
setConfigObject(configObject);
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
function applyEnvVars(argv, configOnly) {
|
|
599
|
+
if (typeof envPrefix === "undefined") return;
|
|
600
|
+
const prefix = typeof envPrefix === "string" ? envPrefix : "";
|
|
601
|
+
const env = mixin$1.env();
|
|
602
|
+
Object.keys(env).forEach(function(envVar) {
|
|
603
|
+
if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
|
|
604
|
+
const keys = envVar.split("__").map(function(key, i) {
|
|
605
|
+
if (i === 0) key = key.substring(prefix.length);
|
|
606
|
+
return camelCase(key);
|
|
607
|
+
});
|
|
608
|
+
if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv, keys)) setArg(keys.join("."), env[envVar]);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function applyCoercions(argv) {
|
|
613
|
+
let coerce;
|
|
614
|
+
const applied = /* @__PURE__ */ new Set();
|
|
615
|
+
Object.keys(argv).forEach(function(key) {
|
|
616
|
+
if (!applied.has(key)) {
|
|
617
|
+
coerce = checkAllAliases(key, flags.coercions);
|
|
618
|
+
if (typeof coerce === "function") try {
|
|
619
|
+
const value = maybeCoerceNumber(key, coerce(argv[key]));
|
|
620
|
+
[].concat(flags.aliases[key] || [], key).forEach((ali) => {
|
|
621
|
+
applied.add(ali);
|
|
622
|
+
argv[ali] = value;
|
|
623
|
+
});
|
|
624
|
+
} catch (err) {
|
|
625
|
+
error = err;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
function setPlaceholderKeys(argv) {
|
|
631
|
+
flags.keys.forEach((key) => {
|
|
632
|
+
if (~key.indexOf(".")) return;
|
|
633
|
+
if (typeof argv[key] === "undefined") argv[key] = void 0;
|
|
634
|
+
});
|
|
635
|
+
return argv;
|
|
636
|
+
}
|
|
637
|
+
function applyDefaultsAndAliases(obj, aliases, defaults, canLog = false) {
|
|
638
|
+
Object.keys(defaults).forEach(function(key) {
|
|
639
|
+
if (!hasKey(obj, key.split("."))) {
|
|
640
|
+
setKey(obj, key.split("."), defaults[key]);
|
|
641
|
+
if (canLog) defaulted[key] = true;
|
|
642
|
+
(aliases[key] || []).forEach(function(x) {
|
|
643
|
+
if (hasKey(obj, x.split("."))) return;
|
|
644
|
+
setKey(obj, x.split("."), defaults[key]);
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function hasKey(obj, keys) {
|
|
650
|
+
let o = obj;
|
|
651
|
+
if (!configuration["dot-notation"]) keys = [keys.join(".")];
|
|
652
|
+
keys.slice(0, -1).forEach(function(key) {
|
|
653
|
+
o = o[key] || {};
|
|
654
|
+
});
|
|
655
|
+
const key = keys[keys.length - 1];
|
|
656
|
+
if (typeof o !== "object") return false;
|
|
657
|
+
else return key in o;
|
|
658
|
+
}
|
|
659
|
+
function setKey(obj, keys, value) {
|
|
660
|
+
let o = obj;
|
|
661
|
+
if (!configuration["dot-notation"]) keys = [keys.join(".")];
|
|
662
|
+
keys.slice(0, -1).forEach(function(key) {
|
|
663
|
+
key = sanitizeKey(key);
|
|
664
|
+
if (typeof o === "object" && o[key] === void 0) o[key] = {};
|
|
665
|
+
if (typeof o[key] !== "object" || Array.isArray(o[key])) {
|
|
666
|
+
if (Array.isArray(o[key])) o[key].push({});
|
|
667
|
+
else o[key] = [o[key], {}];
|
|
668
|
+
o = o[key][o[key].length - 1];
|
|
669
|
+
} else o = o[key];
|
|
670
|
+
});
|
|
671
|
+
const key = sanitizeKey(keys[keys.length - 1]);
|
|
672
|
+
const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
|
|
673
|
+
const isValueArray = Array.isArray(value);
|
|
674
|
+
let duplicate = configuration["duplicate-arguments-array"];
|
|
675
|
+
if (!duplicate && checkAllAliases(key, flags.nargs)) {
|
|
676
|
+
duplicate = true;
|
|
677
|
+
if (!isUndefined(o[key]) && flags.nargs[key] === 1 || Array.isArray(o[key]) && o[key].length === flags.nargs[key]) o[key] = void 0;
|
|
678
|
+
}
|
|
679
|
+
if (value === increment()) o[key] = increment(o[key]);
|
|
680
|
+
else if (Array.isArray(o[key])) {
|
|
681
|
+
if (duplicate && isTypeArray && isValueArray) o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
|
|
682
|
+
else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) o[key] = value;
|
|
683
|
+
else o[key] = o[key].concat([value]);
|
|
684
|
+
} else if (o[key] === void 0 && isTypeArray) o[key] = isValueArray ? value : [value];
|
|
685
|
+
else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) o[key] = [o[key], value];
|
|
686
|
+
else o[key] = value;
|
|
687
|
+
}
|
|
688
|
+
function extendAliases(...args) {
|
|
689
|
+
args.forEach(function(obj) {
|
|
690
|
+
Object.keys(obj || {}).forEach(function(key) {
|
|
691
|
+
if (flags.aliases[key]) return;
|
|
692
|
+
flags.aliases[key] = [].concat(aliases[key] || []);
|
|
693
|
+
flags.aliases[key].concat(key).forEach(function(x) {
|
|
694
|
+
if (/-/.test(x) && configuration["camel-case-expansion"]) {
|
|
695
|
+
const c = camelCase(x);
|
|
696
|
+
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
|
|
697
|
+
flags.aliases[key].push(c);
|
|
698
|
+
newAliases[c] = true;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
flags.aliases[key].concat(key).forEach(function(x) {
|
|
703
|
+
if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
|
|
704
|
+
const c = decamelize(x, "-");
|
|
705
|
+
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
|
|
706
|
+
flags.aliases[key].push(c);
|
|
707
|
+
newAliases[c] = true;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
flags.aliases[key].forEach(function(x) {
|
|
712
|
+
flags.aliases[x] = [key].concat(flags.aliases[key].filter(function(y) {
|
|
713
|
+
return x !== y;
|
|
714
|
+
}));
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function checkAllAliases(key, flag) {
|
|
720
|
+
const toCheck = [].concat(flags.aliases[key] || [], key);
|
|
721
|
+
const keys = Object.keys(flag);
|
|
722
|
+
const setAlias = toCheck.find((key) => keys.includes(key));
|
|
723
|
+
return setAlias ? flag[setAlias] : false;
|
|
724
|
+
}
|
|
725
|
+
function hasAnyFlag(key) {
|
|
726
|
+
const flagsKeys = Object.keys(flags);
|
|
727
|
+
return [].concat(flagsKeys.map((k) => flags[k])).some(function(flag) {
|
|
728
|
+
return Array.isArray(flag) ? flag.includes(key) : flag[key];
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
function hasFlagsMatching(arg, ...patterns) {
|
|
732
|
+
return [].concat(...patterns).some(function(pattern) {
|
|
733
|
+
const match = arg.match(pattern);
|
|
734
|
+
return match && hasAnyFlag(match[1]);
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
function hasAllShortFlags(arg) {
|
|
738
|
+
if (arg.match(negative) || !arg.match(/^-[^-]+/)) return false;
|
|
739
|
+
let hasAllFlags = true;
|
|
740
|
+
let next;
|
|
741
|
+
const letters = arg.slice(1).split("");
|
|
742
|
+
for (let j = 0; j < letters.length; j++) {
|
|
743
|
+
next = arg.slice(j + 2);
|
|
744
|
+
if (!hasAnyFlag(letters[j])) {
|
|
745
|
+
hasAllFlags = false;
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
if (letters[j + 1] && letters[j + 1] === "=" || next === "-" || /[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) || letters[j + 1] && letters[j + 1].match(/\W/)) break;
|
|
749
|
+
}
|
|
750
|
+
return hasAllFlags;
|
|
751
|
+
}
|
|
752
|
+
function isUnknownOptionAsArg(arg) {
|
|
753
|
+
return configuration["unknown-options-as-args"] && isUnknownOption(arg);
|
|
754
|
+
}
|
|
755
|
+
function isUnknownOption(arg) {
|
|
756
|
+
arg = arg.replace(/^-{3,}/, "--");
|
|
757
|
+
if (arg.match(negative)) return false;
|
|
758
|
+
if (hasAllShortFlags(arg)) return false;
|
|
759
|
+
return !hasFlagsMatching(arg, /^-+([^=]+?)=[\s\S]*$/, negatedBoolean, /^-+([^=]+?)$/, /^-+([^=]+?)-$/, /^-+([^=]+?\d+)$/, /^-+([^=]+?)\W+.*$/);
|
|
760
|
+
}
|
|
761
|
+
function defaultValue(key) {
|
|
762
|
+
if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) return defaults[key];
|
|
763
|
+
else return defaultForType(guessType(key));
|
|
764
|
+
}
|
|
765
|
+
function defaultForType(type) {
|
|
766
|
+
return {
|
|
767
|
+
[DefaultValuesForTypeKey.BOOLEAN]: true,
|
|
768
|
+
[DefaultValuesForTypeKey.STRING]: "",
|
|
769
|
+
[DefaultValuesForTypeKey.NUMBER]: void 0,
|
|
770
|
+
[DefaultValuesForTypeKey.ARRAY]: []
|
|
771
|
+
}[type];
|
|
772
|
+
}
|
|
773
|
+
function guessType(key) {
|
|
774
|
+
let type = DefaultValuesForTypeKey.BOOLEAN;
|
|
775
|
+
if (checkAllAliases(key, flags.strings)) type = DefaultValuesForTypeKey.STRING;
|
|
776
|
+
else if (checkAllAliases(key, flags.numbers)) type = DefaultValuesForTypeKey.NUMBER;
|
|
777
|
+
else if (checkAllAliases(key, flags.bools)) type = DefaultValuesForTypeKey.BOOLEAN;
|
|
778
|
+
else if (checkAllAliases(key, flags.arrays)) type = DefaultValuesForTypeKey.ARRAY;
|
|
779
|
+
return type;
|
|
780
|
+
}
|
|
781
|
+
function isUndefined(num) {
|
|
782
|
+
return num === void 0;
|
|
783
|
+
}
|
|
784
|
+
function checkConfiguration() {
|
|
785
|
+
Object.keys(flags.counts).find((key) => {
|
|
786
|
+
if (checkAllAliases(key, flags.arrays)) {
|
|
787
|
+
error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
|
|
788
|
+
return true;
|
|
789
|
+
} else if (checkAllAliases(key, flags.nargs)) {
|
|
790
|
+
error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key));
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
return false;
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
aliases: Object.assign({}, flags.aliases),
|
|
798
|
+
argv: Object.assign(argvReturn, argv),
|
|
799
|
+
configuration,
|
|
800
|
+
defaulted: Object.assign({}, defaulted),
|
|
801
|
+
error,
|
|
802
|
+
newAliases: Object.assign({}, newAliases)
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}));
|
|
807
|
+
// node_modules/yargs-parser/build/lib/index.js
|
|
808
|
+
var _a, _b, _c, minNodeVersion, nodeVersion, env, parser, yargsParser;
|
|
809
|
+
var init_lib$2 = __esmMin((() => {
|
|
810
|
+
init_yargs_parser();
|
|
811
|
+
minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
|
|
812
|
+
nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
|
|
813
|
+
/**
|
|
814
|
+
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
|
815
|
+
* CJS and ESM environments.
|
|
816
|
+
*
|
|
817
|
+
* @license
|
|
818
|
+
* Copyright (c) 2016, Contributors
|
|
819
|
+
* SPDX-License-Identifier: ISC
|
|
820
|
+
*/
|
|
821
|
+
if (nodeVersion) {
|
|
822
|
+
if (Number(nodeVersion.match(/^([^.]+)/)[1]) < minNodeVersion) throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
|
|
823
|
+
}
|
|
824
|
+
env = process ? process.env : {};
|
|
825
|
+
parser = new YargsParser({
|
|
826
|
+
cwd: process.cwd,
|
|
827
|
+
env: () => {
|
|
828
|
+
return env;
|
|
829
|
+
},
|
|
830
|
+
format,
|
|
831
|
+
normalize,
|
|
832
|
+
resolve,
|
|
833
|
+
require: (path) => {
|
|
834
|
+
if (typeof /* @__PURE__ */ __require() !== "undefined") return (/* @__PURE__ */ __require())(path);
|
|
835
|
+
else if (path.match(/\.json$/)) return JSON.parse(readFileSync(path, "utf8"));
|
|
836
|
+
else throw Error("only .json config files are supported in ESM");
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
yargsParser = function Parser(args, opts) {
|
|
840
|
+
return parser.parse(args.slice(), opts).argv;
|
|
841
|
+
};
|
|
842
|
+
yargsParser.detailed = function(args, opts) {
|
|
843
|
+
return parser.parse(args.slice(), opts);
|
|
844
|
+
};
|
|
845
|
+
yargsParser.camelCase = camelCase;
|
|
846
|
+
yargsParser.decamelize = decamelize;
|
|
847
|
+
yargsParser.looksLikeNumber = looksLikeNumber;
|
|
848
|
+
}));
|
|
849
|
+
// node_modules/cliui/build/lib/index.js
|
|
850
|
+
function addBorder(col, ts, style) {
|
|
851
|
+
if (col.border) {
|
|
852
|
+
if (/[.']-+[.']/.test(ts)) return "";
|
|
853
|
+
if (ts.trim().length !== 0) return style;
|
|
854
|
+
return " ";
|
|
855
|
+
}
|
|
856
|
+
return "";
|
|
857
|
+
}
|
|
858
|
+
function _minWidth(col) {
|
|
859
|
+
const padding = col.padding || [];
|
|
860
|
+
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
|
861
|
+
if (col.border) return minWidth + 4;
|
|
862
|
+
return minWidth;
|
|
863
|
+
}
|
|
864
|
+
function getWindowWidth() {
|
|
865
|
+
/* istanbul ignore next: depends on terminal */
|
|
866
|
+
if (typeof process === "object" && process.stdout && process.stdout.columns) return process.stdout.columns;
|
|
867
|
+
return 80;
|
|
868
|
+
}
|
|
869
|
+
function alignRight(str, width) {
|
|
870
|
+
str = str.trim();
|
|
871
|
+
const strWidth = mixin.stringWidth(str);
|
|
872
|
+
if (strWidth < width) return " ".repeat(width - strWidth) + str;
|
|
873
|
+
return str;
|
|
874
|
+
}
|
|
875
|
+
function alignCenter(str, width) {
|
|
876
|
+
str = str.trim();
|
|
877
|
+
const strWidth = mixin.stringWidth(str);
|
|
878
|
+
/* istanbul ignore next */
|
|
879
|
+
if (strWidth >= width) return str;
|
|
880
|
+
return " ".repeat(width - strWidth >> 1) + str;
|
|
881
|
+
}
|
|
882
|
+
function cliui(opts, _mixin) {
|
|
883
|
+
mixin = _mixin;
|
|
884
|
+
return new UI({
|
|
885
|
+
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
|
886
|
+
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
var align, top, right, bottom, left, UI, mixin;
|
|
890
|
+
var init_lib$1 = __esmMin((() => {
|
|
891
|
+
align = {
|
|
892
|
+
right: alignRight,
|
|
893
|
+
center: alignCenter
|
|
894
|
+
};
|
|
895
|
+
top = 0;
|
|
896
|
+
right = 1;
|
|
897
|
+
bottom = 2;
|
|
898
|
+
left = 3;
|
|
899
|
+
UI = class {
|
|
900
|
+
constructor(opts) {
|
|
901
|
+
var _a;
|
|
902
|
+
this.width = opts.width;
|
|
903
|
+
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
|
904
|
+
this.rows = [];
|
|
905
|
+
}
|
|
906
|
+
span(...args) {
|
|
907
|
+
const cols = this.div(...args);
|
|
908
|
+
cols.span = true;
|
|
909
|
+
}
|
|
910
|
+
resetOutput() {
|
|
911
|
+
this.rows = [];
|
|
912
|
+
}
|
|
913
|
+
div(...args) {
|
|
914
|
+
if (args.length === 0) this.div("");
|
|
915
|
+
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === "string") return this.applyLayoutDSL(args[0]);
|
|
916
|
+
const cols = args.map((arg) => {
|
|
917
|
+
if (typeof arg === "string") return this.colFromString(arg);
|
|
918
|
+
return arg;
|
|
919
|
+
});
|
|
920
|
+
this.rows.push(cols);
|
|
921
|
+
return cols;
|
|
922
|
+
}
|
|
923
|
+
shouldApplyLayoutDSL(...args) {
|
|
924
|
+
return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]);
|
|
925
|
+
}
|
|
926
|
+
applyLayoutDSL(str) {
|
|
927
|
+
const rows = str.split("\n").map((row) => row.split(" "));
|
|
928
|
+
let leftColumnWidth = 0;
|
|
929
|
+
rows.forEach((columns) => {
|
|
930
|
+
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) leftColumnWidth = Math.min(Math.floor(this.width * .5), mixin.stringWidth(columns[0]));
|
|
931
|
+
});
|
|
932
|
+
rows.forEach((columns) => {
|
|
933
|
+
this.div(...columns.map((r, i) => {
|
|
934
|
+
return {
|
|
935
|
+
text: r.trim(),
|
|
936
|
+
padding: this.measurePadding(r),
|
|
937
|
+
width: i === 0 && columns.length > 1 ? leftColumnWidth : void 0
|
|
938
|
+
};
|
|
939
|
+
}));
|
|
940
|
+
});
|
|
941
|
+
return this.rows[this.rows.length - 1];
|
|
942
|
+
}
|
|
943
|
+
colFromString(text) {
|
|
944
|
+
return {
|
|
945
|
+
text,
|
|
946
|
+
padding: this.measurePadding(text)
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
measurePadding(str) {
|
|
950
|
+
const noAnsi = mixin.stripAnsi(str);
|
|
951
|
+
return [
|
|
952
|
+
0,
|
|
953
|
+
noAnsi.match(/\s*$/)[0].length,
|
|
954
|
+
0,
|
|
955
|
+
noAnsi.match(/^\s*/)[0].length
|
|
956
|
+
];
|
|
957
|
+
}
|
|
958
|
+
toString() {
|
|
959
|
+
const lines = [];
|
|
960
|
+
this.rows.forEach((row) => {
|
|
961
|
+
this.rowToString(row, lines);
|
|
962
|
+
});
|
|
963
|
+
return lines.filter((line) => !line.hidden).map((line) => line.text).join("\n");
|
|
964
|
+
}
|
|
965
|
+
rowToString(row, lines) {
|
|
966
|
+
this.rasterize(row).forEach((rrow, r) => {
|
|
967
|
+
let str = "";
|
|
968
|
+
rrow.forEach((col, c) => {
|
|
969
|
+
const { width } = row[c];
|
|
970
|
+
const wrapWidth = this.negatePadding(row[c]);
|
|
971
|
+
let ts = col;
|
|
972
|
+
if (wrapWidth > mixin.stringWidth(col)) ts += " ".repeat(wrapWidth - mixin.stringWidth(col));
|
|
973
|
+
if (row[c].align && row[c].align !== "left" && this.wrap) {
|
|
974
|
+
ts = (0, align[row[c].align])(ts, wrapWidth);
|
|
975
|
+
if (mixin.stringWidth(ts) < wrapWidth) ts += " ".repeat((width || 0) - mixin.stringWidth(ts) - 1);
|
|
976
|
+
}
|
|
977
|
+
const padding = row[c].padding || [
|
|
978
|
+
0,
|
|
979
|
+
0,
|
|
980
|
+
0,
|
|
981
|
+
0
|
|
982
|
+
];
|
|
983
|
+
if (padding[left]) str += " ".repeat(padding[left]);
|
|
984
|
+
str += addBorder(row[c], ts, "| ");
|
|
985
|
+
str += ts;
|
|
986
|
+
str += addBorder(row[c], ts, " |");
|
|
987
|
+
if (padding[right]) str += " ".repeat(padding[right]);
|
|
988
|
+
if (r === 0 && lines.length > 0) str = this.renderInline(str, lines[lines.length - 1]);
|
|
989
|
+
});
|
|
990
|
+
lines.push({
|
|
991
|
+
text: str.replace(/ +$/, ""),
|
|
992
|
+
span: row.span
|
|
993
|
+
});
|
|
994
|
+
});
|
|
995
|
+
return lines;
|
|
996
|
+
}
|
|
997
|
+
renderInline(source, previousLine) {
|
|
998
|
+
const match = source.match(/^ */);
|
|
999
|
+
const leadingWhitespace = match ? match[0].length : 0;
|
|
1000
|
+
const target = previousLine.text;
|
|
1001
|
+
const targetTextWidth = mixin.stringWidth(target.trimRight());
|
|
1002
|
+
if (!previousLine.span) return source;
|
|
1003
|
+
if (!this.wrap) {
|
|
1004
|
+
previousLine.hidden = true;
|
|
1005
|
+
return target + source;
|
|
1006
|
+
}
|
|
1007
|
+
if (leadingWhitespace < targetTextWidth) return source;
|
|
1008
|
+
previousLine.hidden = true;
|
|
1009
|
+
return target.trimRight() + " ".repeat(leadingWhitespace - targetTextWidth) + source.trimLeft();
|
|
1010
|
+
}
|
|
1011
|
+
rasterize(row) {
|
|
1012
|
+
const rrows = [];
|
|
1013
|
+
const widths = this.columnWidths(row);
|
|
1014
|
+
let wrapped;
|
|
1015
|
+
row.forEach((col, c) => {
|
|
1016
|
+
col.width = widths[c];
|
|
1017
|
+
if (this.wrap) wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split("\n");
|
|
1018
|
+
else wrapped = col.text.split("\n");
|
|
1019
|
+
if (col.border) {
|
|
1020
|
+
wrapped.unshift("." + "-".repeat(this.negatePadding(col) + 2) + ".");
|
|
1021
|
+
wrapped.push("'" + "-".repeat(this.negatePadding(col) + 2) + "'");
|
|
1022
|
+
}
|
|
1023
|
+
if (col.padding) {
|
|
1024
|
+
wrapped.unshift(...new Array(col.padding[top] || 0).fill(""));
|
|
1025
|
+
wrapped.push(...new Array(col.padding[bottom] || 0).fill(""));
|
|
1026
|
+
}
|
|
1027
|
+
wrapped.forEach((str, r) => {
|
|
1028
|
+
if (!rrows[r]) rrows.push([]);
|
|
1029
|
+
const rrow = rrows[r];
|
|
1030
|
+
for (let i = 0; i < c; i++) if (rrow[i] === void 0) rrow.push("");
|
|
1031
|
+
rrow.push(str);
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
return rrows;
|
|
1035
|
+
}
|
|
1036
|
+
negatePadding(col) {
|
|
1037
|
+
let wrapWidth = col.width || 0;
|
|
1038
|
+
if (col.padding) wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
|
1039
|
+
if (col.border) wrapWidth -= 4;
|
|
1040
|
+
return wrapWidth;
|
|
1041
|
+
}
|
|
1042
|
+
columnWidths(row) {
|
|
1043
|
+
if (!this.wrap) return row.map((col) => {
|
|
1044
|
+
return col.width || mixin.stringWidth(col.text);
|
|
1045
|
+
});
|
|
1046
|
+
let unset = row.length;
|
|
1047
|
+
let remainingWidth = this.width;
|
|
1048
|
+
const widths = row.map((col) => {
|
|
1049
|
+
if (col.width) {
|
|
1050
|
+
unset--;
|
|
1051
|
+
remainingWidth -= col.width;
|
|
1052
|
+
return col.width;
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
|
1056
|
+
return widths.map((w, i) => {
|
|
1057
|
+
if (w === void 0) return Math.max(unsetWidth, _minWidth(row[i]));
|
|
1058
|
+
return w;
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
}));
|
|
1063
|
+
// node_modules/cliui/build/lib/string-utils.js
|
|
1064
|
+
function stripAnsi(str) {
|
|
1065
|
+
return str.replace(ansi, "");
|
|
1066
|
+
}
|
|
1067
|
+
function wrap(str, width) {
|
|
1068
|
+
const [start, end] = str.match(ansi) || ["", ""];
|
|
1069
|
+
str = stripAnsi(str);
|
|
1070
|
+
let wrapped = "";
|
|
1071
|
+
for (let i = 0; i < str.length; i++) {
|
|
1072
|
+
if (i !== 0 && i % width === 0) wrapped += "\n";
|
|
1073
|
+
wrapped += str.charAt(i);
|
|
1074
|
+
}
|
|
1075
|
+
if (start && end) wrapped = `${start}${wrapped}${end}`;
|
|
1076
|
+
return wrapped;
|
|
1077
|
+
}
|
|
1078
|
+
var ansi;
|
|
1079
|
+
var init_string_utils = __esmMin((() => {
|
|
1080
|
+
ansi = /* @__PURE__ */ new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
|
|
1081
|
+
}));
|
|
1082
|
+
// node_modules/cliui/index.mjs
|
|
1083
|
+
function ui(opts) {
|
|
1084
|
+
return cliui(opts, {
|
|
1085
|
+
stringWidth: (str) => {
|
|
1086
|
+
return [...str].length;
|
|
1087
|
+
},
|
|
1088
|
+
stripAnsi,
|
|
1089
|
+
wrap
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
var init_cliui = __esmMin((() => {
|
|
1093
|
+
init_lib$1();
|
|
1094
|
+
init_string_utils();
|
|
1095
|
+
}));
|
|
1096
|
+
// node_modules/escalade/sync/index.mjs
|
|
1097
|
+
function sync_default(start, callback) {
|
|
1098
|
+
let dir = resolve(".", start);
|
|
1099
|
+
let tmp;
|
|
1100
|
+
if (!statSync(dir).isDirectory()) dir = dirname(dir);
|
|
1101
|
+
while (true) {
|
|
1102
|
+
tmp = callback(dir, readdirSync(dir));
|
|
1103
|
+
if (tmp) return resolve(dir, tmp);
|
|
1104
|
+
dir = dirname(tmp = dir);
|
|
1105
|
+
if (tmp === dir) break;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
var init_sync = __esmMin((() => {}));
|
|
1109
|
+
// node_modules/y18n/build/lib/platform-shims/node.js
|
|
1110
|
+
var node_default;
|
|
1111
|
+
var init_node = __esmMin((() => {
|
|
1112
|
+
node_default = {
|
|
1113
|
+
fs: {
|
|
1114
|
+
readFileSync,
|
|
1115
|
+
writeFile
|
|
1116
|
+
},
|
|
1117
|
+
format,
|
|
1118
|
+
resolve,
|
|
1119
|
+
exists: (file) => {
|
|
1120
|
+
try {
|
|
1121
|
+
return statSync(file).isFile();
|
|
1122
|
+
} catch (err) {
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
};
|
|
1127
|
+
}));
|
|
1128
|
+
// node_modules/y18n/build/lib/index.js
|
|
1129
|
+
function y18n$1(opts, _shim) {
|
|
1130
|
+
shim = _shim;
|
|
1131
|
+
const y18n = new Y18N(opts);
|
|
1132
|
+
return {
|
|
1133
|
+
__: y18n.__.bind(y18n),
|
|
1134
|
+
__n: y18n.__n.bind(y18n),
|
|
1135
|
+
setLocale: y18n.setLocale.bind(y18n),
|
|
1136
|
+
getLocale: y18n.getLocale.bind(y18n),
|
|
1137
|
+
updateLocale: y18n.updateLocale.bind(y18n),
|
|
1138
|
+
locale: y18n.locale
|
|
1139
|
+
};
|
|
1140
|
+
}
|
|
1141
|
+
var shim, Y18N;
|
|
1142
|
+
var init_lib = __esmMin((() => {
|
|
1143
|
+
Y18N = class {
|
|
1144
|
+
constructor(opts) {
|
|
1145
|
+
opts = opts || {};
|
|
1146
|
+
this.directory = opts.directory || "./locales";
|
|
1147
|
+
this.updateFiles = typeof opts.updateFiles === "boolean" ? opts.updateFiles : true;
|
|
1148
|
+
this.locale = opts.locale || "en";
|
|
1149
|
+
this.fallbackToLanguage = typeof opts.fallbackToLanguage === "boolean" ? opts.fallbackToLanguage : true;
|
|
1150
|
+
this.cache = Object.create(null);
|
|
1151
|
+
this.writeQueue = [];
|
|
1152
|
+
}
|
|
1153
|
+
__(...args) {
|
|
1154
|
+
if (typeof arguments[0] !== "string") return this._taggedLiteral(arguments[0], ...arguments);
|
|
1155
|
+
const str = args.shift();
|
|
1156
|
+
let cb = function() {};
|
|
1157
|
+
if (typeof args[args.length - 1] === "function") cb = args.pop();
|
|
1158
|
+
cb = cb || function() {};
|
|
1159
|
+
if (!this.cache[this.locale]) this._readLocaleFile();
|
|
1160
|
+
if (!this.cache[this.locale][str] && this.updateFiles) {
|
|
1161
|
+
this.cache[this.locale][str] = str;
|
|
1162
|
+
this._enqueueWrite({
|
|
1163
|
+
directory: this.directory,
|
|
1164
|
+
locale: this.locale,
|
|
1165
|
+
cb
|
|
1166
|
+
});
|
|
1167
|
+
} else cb();
|
|
1168
|
+
return shim.format.apply(shim.format, [this.cache[this.locale][str] || str].concat(args));
|
|
1169
|
+
}
|
|
1170
|
+
__n() {
|
|
1171
|
+
const args = Array.prototype.slice.call(arguments);
|
|
1172
|
+
const singular = args.shift();
|
|
1173
|
+
const plural = args.shift();
|
|
1174
|
+
const quantity = args.shift();
|
|
1175
|
+
let cb = function() {};
|
|
1176
|
+
if (typeof args[args.length - 1] === "function") cb = args.pop();
|
|
1177
|
+
if (!this.cache[this.locale]) this._readLocaleFile();
|
|
1178
|
+
let str = quantity === 1 ? singular : plural;
|
|
1179
|
+
if (this.cache[this.locale][singular]) str = this.cache[this.locale][singular][quantity === 1 ? "one" : "other"];
|
|
1180
|
+
if (!this.cache[this.locale][singular] && this.updateFiles) {
|
|
1181
|
+
this.cache[this.locale][singular] = {
|
|
1182
|
+
one: singular,
|
|
1183
|
+
other: plural
|
|
1184
|
+
};
|
|
1185
|
+
this._enqueueWrite({
|
|
1186
|
+
directory: this.directory,
|
|
1187
|
+
locale: this.locale,
|
|
1188
|
+
cb
|
|
1189
|
+
});
|
|
1190
|
+
} else cb();
|
|
1191
|
+
const values = [str];
|
|
1192
|
+
if (~str.indexOf("%d")) values.push(quantity);
|
|
1193
|
+
return shim.format.apply(shim.format, values.concat(args));
|
|
1194
|
+
}
|
|
1195
|
+
setLocale(locale) {
|
|
1196
|
+
this.locale = locale;
|
|
1197
|
+
}
|
|
1198
|
+
getLocale() {
|
|
1199
|
+
return this.locale;
|
|
1200
|
+
}
|
|
1201
|
+
updateLocale(obj) {
|
|
1202
|
+
if (!this.cache[this.locale]) this._readLocaleFile();
|
|
1203
|
+
for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) this.cache[this.locale][key] = obj[key];
|
|
1204
|
+
}
|
|
1205
|
+
_taggedLiteral(parts, ...args) {
|
|
1206
|
+
let str = "";
|
|
1207
|
+
parts.forEach(function(part, i) {
|
|
1208
|
+
const arg = args[i + 1];
|
|
1209
|
+
str += part;
|
|
1210
|
+
if (typeof arg !== "undefined") str += "%s";
|
|
1211
|
+
});
|
|
1212
|
+
return this.__.apply(this, [str].concat([].slice.call(args, 1)));
|
|
1213
|
+
}
|
|
1214
|
+
_enqueueWrite(work) {
|
|
1215
|
+
this.writeQueue.push(work);
|
|
1216
|
+
if (this.writeQueue.length === 1) this._processWriteQueue();
|
|
1217
|
+
}
|
|
1218
|
+
_processWriteQueue() {
|
|
1219
|
+
const _this = this;
|
|
1220
|
+
const work = this.writeQueue[0];
|
|
1221
|
+
const directory = work.directory;
|
|
1222
|
+
const locale = work.locale;
|
|
1223
|
+
const cb = work.cb;
|
|
1224
|
+
const languageFile = this._resolveLocaleFile(directory, locale);
|
|
1225
|
+
const serializedLocale = JSON.stringify(this.cache[locale], null, 2);
|
|
1226
|
+
shim.fs.writeFile(languageFile, serializedLocale, "utf-8", function(err) {
|
|
1227
|
+
_this.writeQueue.shift();
|
|
1228
|
+
if (_this.writeQueue.length > 0) _this._processWriteQueue();
|
|
1229
|
+
cb(err);
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
_readLocaleFile() {
|
|
1233
|
+
let localeLookup = {};
|
|
1234
|
+
const languageFile = this._resolveLocaleFile(this.directory, this.locale);
|
|
1235
|
+
try {
|
|
1236
|
+
if (shim.fs.readFileSync) localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, "utf-8"));
|
|
1237
|
+
} catch (err) {
|
|
1238
|
+
if (err instanceof SyntaxError) err.message = "syntax error in " + languageFile;
|
|
1239
|
+
if (err.code === "ENOENT") localeLookup = {};
|
|
1240
|
+
else throw err;
|
|
1241
|
+
}
|
|
1242
|
+
this.cache[this.locale] = localeLookup;
|
|
1243
|
+
}
|
|
1244
|
+
_resolveLocaleFile(directory, locale) {
|
|
1245
|
+
let file = shim.resolve(directory, "./", locale + ".json");
|
|
1246
|
+
if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf("_")) {
|
|
1247
|
+
const languageFile = shim.resolve(directory, "./", locale.split("_")[0] + ".json");
|
|
1248
|
+
if (this._fileExistsSync(languageFile)) file = languageFile;
|
|
1249
|
+
}
|
|
1250
|
+
return file;
|
|
1251
|
+
}
|
|
1252
|
+
_fileExistsSync(file) {
|
|
1253
|
+
return shim.exists(file);
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
}));
|
|
1257
|
+
// node_modules/y18n/index.mjs
|
|
1258
|
+
var y18n;
|
|
1259
|
+
var init_y18n = __esmMin((() => {
|
|
1260
|
+
init_node();
|
|
1261
|
+
init_lib();
|
|
1262
|
+
y18n = (opts) => {
|
|
1263
|
+
return y18n$1(opts, node_default);
|
|
1264
|
+
};
|
|
1265
|
+
}));
|
|
1266
|
+
// node_modules/yargs/lib/platform-shims/esm.mjs
|
|
1267
|
+
var REQUIRE_ERROR, REQUIRE_DIRECTORY_ERROR, __dirname, mainFilename, esm_default;
|
|
1268
|
+
var init_esm = __esmMin((() => {
|
|
1269
|
+
init_cliui();
|
|
1270
|
+
init_sync();
|
|
1271
|
+
init_lib$2();
|
|
1272
|
+
init_yerror();
|
|
1273
|
+
init_y18n();
|
|
1274
|
+
REQUIRE_ERROR = "require is not supported by ESM";
|
|
1275
|
+
REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM";
|
|
1276
|
+
try {
|
|
1277
|
+
__dirname = fileURLToPath(import.meta.url);
|
|
1278
|
+
} catch (e) {
|
|
1279
|
+
__dirname = process.cwd();
|
|
1280
|
+
}
|
|
1281
|
+
mainFilename = __dirname.substring(0, __dirname.lastIndexOf("node_modules"));
|
|
1282
|
+
esm_default = {
|
|
1283
|
+
assert: {
|
|
1284
|
+
notStrictEqual,
|
|
1285
|
+
strictEqual
|
|
1286
|
+
},
|
|
1287
|
+
cliui: ui,
|
|
1288
|
+
findUp: sync_default,
|
|
1289
|
+
getEnv: (key) => {
|
|
1290
|
+
return process.env[key];
|
|
1291
|
+
},
|
|
1292
|
+
inspect,
|
|
1293
|
+
getCallerFile: () => {
|
|
1294
|
+
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
|
1295
|
+
},
|
|
1296
|
+
getProcessArgvBin,
|
|
1297
|
+
mainFilename: mainFilename || process.cwd(),
|
|
1298
|
+
Parser: yargsParser,
|
|
1299
|
+
path: {
|
|
1300
|
+
basename,
|
|
1301
|
+
dirname,
|
|
1302
|
+
extname,
|
|
1303
|
+
relative,
|
|
1304
|
+
resolve
|
|
1305
|
+
},
|
|
1306
|
+
process: {
|
|
1307
|
+
argv: () => process.argv,
|
|
1308
|
+
cwd: process.cwd,
|
|
1309
|
+
emitWarning: (warning, type) => process.emitWarning(warning, type),
|
|
1310
|
+
execPath: () => process.execPath,
|
|
1311
|
+
exit: process.exit,
|
|
1312
|
+
nextTick: process.nextTick,
|
|
1313
|
+
stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null
|
|
1314
|
+
},
|
|
1315
|
+
readFileSync,
|
|
1316
|
+
require: () => {
|
|
1317
|
+
throw new YError(REQUIRE_ERROR);
|
|
1318
|
+
},
|
|
1319
|
+
requireDirectory: () => {
|
|
1320
|
+
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
|
1321
|
+
},
|
|
1322
|
+
stringWidth: (str) => {
|
|
1323
|
+
return [...str].length;
|
|
1324
|
+
},
|
|
1325
|
+
y18n: y18n({
|
|
1326
|
+
directory: resolve(__dirname, "../../../locales"),
|
|
1327
|
+
updateFiles: false
|
|
1328
|
+
})
|
|
1329
|
+
};
|
|
1330
|
+
}));
|
|
1331
|
+
export { hideBin as a, init_yerror as c, yargsParser as i, init_esm as n, init_process_argv as o, init_lib$2 as r, YError as s, esm_default as t };
|