@socketsecurity/lib 5.25.1 → 5.26.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/CHANGELOG.md +344 -1184
- package/README.md +1 -1
- package/dist/abort.js +7 -6
- package/dist/agent.js +16 -15
- package/dist/ansi.js +3 -2
- package/dist/archives.js +18 -17
- package/dist/argv/flags.js +29 -28
- package/dist/argv/parse.js +4 -3
- package/dist/arrays.js +3 -2
- package/dist/bin.js +12 -11
- package/dist/cacache.js +16 -11
- package/dist/cache-with-ttl.js +26 -21
- package/dist/colors.js +2 -1
- package/dist/constants/licenses.js +2 -1
- package/dist/constants/lifecycle-script-names.js +2 -1
- package/dist/constants/maintained-node-versions.js +2 -1
- package/dist/constants/node.js +4 -3
- package/dist/constants/package-default-socket-categories.js +2 -1
- package/dist/constants/packages.js +4 -3
- package/dist/constants/socket.js +1 -1
- package/dist/cover/code.js +9 -8
- package/dist/cover/formatters.js +12 -11
- package/dist/cover/type.js +5 -4
- package/dist/crypto.d.ts +36 -0
- package/dist/{effects/ultra.js → crypto.js} +33 -37
- package/dist/debug.js +12 -15
- package/dist/dlx/arborist.js +10 -9
- package/dist/dlx/binary.js +27 -24
- package/dist/dlx/cache.js +2 -10
- package/dist/dlx/detect.js +6 -5
- package/dist/dlx/integrity.js +13 -11
- package/dist/dlx/lockfile.js +7 -6
- package/dist/dlx/manifest.js +6 -5
- package/dist/dlx/package.js +17 -16
- package/dist/dlx/packages.js +6 -5
- package/dist/dlx/paths.d.ts +1 -1
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +4 -3
- package/dist/effects/shimmer-keyframes.d.ts +62 -0
- package/dist/effects/shimmer-keyframes.js +55 -0
- package/dist/effects/shimmer-terminal.d.ts +66 -0
- package/dist/effects/shimmer-terminal.js +57 -0
- package/dist/effects/shimmer.d.ts +293 -0
- package/dist/effects/shimmer.js +180 -0
- package/dist/env/rewire.js +4 -3
- package/dist/env.js +5 -4
- package/dist/errors.js +1 -1
- package/dist/external/@npmcli/package-json/lib/read-package.js +10 -10
- package/dist/external/@npmcli/package-json.js +372 -372
- package/dist/external/@npmcli/promise-spawn.js +24 -24
- package/dist/external/@socketregistry/packageurl-js.js +19 -18
- package/dist/external/@socketregistry/yocto-spinner.js +4 -3
- package/dist/external/@yarnpkg/extensions.js +2 -1
- package/dist/external/adm-zip.js +70 -70
- package/dist/external/debug.js +22 -22
- package/dist/external/external-pack.js +45 -45
- package/dist/external/fast-sort.js +5 -5
- package/dist/external/libnpmexec.js +4 -3
- package/dist/external/npm-pack.js +369 -369
- package/dist/external/p-map.js +9 -9
- package/dist/external/pico-pack.js +190 -190
- package/dist/external/pony-cause.js +2 -1
- package/dist/external/spdx-pack.js +11 -10
- package/dist/external/tar-fs.js +58 -58
- package/dist/external/which.js +13 -13
- package/dist/external/yargs-parser.js +71 -71
- package/dist/fs.js +19 -23
- package/dist/git.js +14 -13
- package/dist/github.d.ts +34 -0
- package/dist/github.js +248 -23
- package/dist/globs.d.ts +20 -0
- package/dist/globs.js +134 -25
- package/dist/http-request.d.ts +4 -3
- package/dist/http-request.js +39 -32
- package/dist/ipc-cli.js +2 -1
- package/dist/ipc.js +5 -4
- package/dist/json/edit.js +4 -3
- package/dist/json/format.js +3 -2
- package/dist/json/parse.js +7 -6
- package/dist/links.js +2 -1
- package/dist/logger.js +21 -14
- package/dist/memoization.js +16 -15
- package/dist/objects.js +2 -2
- package/dist/packages/edit.js +8 -7
- package/dist/packages/exports.js +17 -16
- package/dist/packages/isolation.js +20 -13
- package/dist/packages/licenses.js +6 -3
- package/dist/packages/manifest.js +2 -1
- package/dist/packages/normalize.js +8 -4
- package/dist/packages/operations.js +5 -4
- package/dist/packages/provenance.js +7 -6
- package/dist/packages/specs.js +2 -1
- package/dist/packages/validation.js +2 -1
- package/dist/paths/normalize.js +32 -40
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.js +3 -2
- package/dist/performance.js +19 -18
- package/dist/primordials.d.ts +9 -0
- package/dist/primordials.js +17 -0
- package/dist/process-lock.js +14 -13
- package/dist/promise-queue.js +17 -9
- package/dist/promises.d.ts +29 -6
- package/dist/promises.js +19 -15
- package/dist/regexps.js +9 -8
- package/dist/releases/github-api.d.ts +56 -0
- package/dist/releases/github-api.js +275 -0
- package/dist/releases/github-archives.d.ts +60 -0
- package/dist/releases/github-archives.js +136 -0
- package/dist/releases/github-assets.d.ts +21 -0
- package/dist/releases/github-assets.js +52 -0
- package/dist/releases/github-auth.d.ts +16 -0
- package/dist/releases/github-auth.js +51 -0
- package/dist/releases/github-downloads.d.ts +42 -0
- package/dist/releases/github-downloads.js +155 -0
- package/dist/releases/github-types.d.ts +66 -0
- package/dist/{effects/types.js → releases/github-types.js} +2 -2
- package/dist/releases/socket-btm.d.ts +1 -1
- package/dist/releases/socket-btm.js +17 -17
- package/dist/schema/parse.js +2 -1
- package/dist/schema/validate.js +6 -5
- package/dist/shadow.js +2 -1
- package/dist/signal-exit.js +2 -2
- package/dist/spawn.js +45 -35
- package/dist/spinner.d.ts +13 -6
- package/dist/spinner.js +75 -57
- package/dist/ssri.js +8 -7
- package/dist/stdio/footer.js +13 -12
- package/dist/stdio/header.js +5 -4
- package/dist/stdio/progress.js +13 -12
- package/dist/strings.js +19 -18
- package/dist/suppress-warnings.js +2 -2
- package/dist/tables.js +16 -13
- package/dist/temporary-executor.js +2 -1
- package/dist/themes/context.js +2 -1
- package/dist/themes/types.d.ts +1 -1
- package/dist/themes/utils.d.ts +8 -3
- package/dist/themes/utils.js +29 -5
- package/dist/url.js +4 -3
- package/package.json +44 -20
- package/dist/effects/text-shimmer.d.ts +0 -58
- package/dist/effects/text-shimmer.js +0 -192
- package/dist/effects/types.d.ts +0 -47
- package/dist/effects/ultra.d.ts +0 -22
- package/dist/releases/github.d.ts +0 -234
- package/dist/releases/github.js +0 -417
- package/dist/themes/index.d.ts +0 -49
- package/dist/themes/index.js +0 -60
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { ArrayIsArray: _p_ArrayIsArray, ObjectCreate: _p_ObjectCreate } = require('../primordials.js')
|
|
1
|
+
const { ArrayIsArray: _p_ArrayIsArray, JSONParse: _p_JSONParse, MathFloor: _p_MathFloor, MathMin: _p_MathMin, NumberIsSafeInteger: _p_NumberIsSafeInteger, ObjectAssign: _p_ObjectAssign, ObjectCreate: _p_ObjectCreate, ObjectDefineProperty: _p_ObjectDefineProperty, ObjectEntries: _p_ObjectEntries, ObjectKeys: _p_ObjectKeys, RegExpCtor: _p_RegExpCtor, SetCtor: _p_SetCtor, StringPrototypeCharAt: _p_StringPrototypeCharAt, StringPrototypeSubstring: _p_StringPrototypeSubstring } = require('../primordials.js')
|
|
2
2
|
"use strict";
|
|
3
3
|
/**
|
|
4
4
|
* Bundled from yargs-parser
|
|
@@ -40,7 +40,7 @@ function camelCase(str) {
|
|
|
40
40
|
let nextChrUpper = false;
|
|
41
41
|
const leadingHyphens = str.match(/^-+/);
|
|
42
42
|
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
|
|
43
|
-
let chr = str
|
|
43
|
+
let chr = _p_StringPrototypeCharAt(str, i);
|
|
44
44
|
if (nextChrUpper) {
|
|
45
45
|
nextChrUpper = false;
|
|
46
46
|
chr = chr.toUpperCase();
|
|
@@ -59,10 +59,10 @@ function decamelize(str, joinString) {
|
|
|
59
59
|
joinString = joinString || "-";
|
|
60
60
|
let notCamelcase = "";
|
|
61
61
|
for (let i = 0; i < str.length; i++) {
|
|
62
|
-
const chrLower = lowercase
|
|
63
|
-
const chrString = str
|
|
62
|
+
const chrLower = _p_StringPrototypeCharAt(lowercase, i);
|
|
63
|
+
const chrString = _p_StringPrototypeCharAt(str, i);
|
|
64
64
|
if (chrLower !== chrString && i > 0) {
|
|
65
|
-
notCamelcase += `${joinString}${lowercase
|
|
65
|
+
notCamelcase += `${joinString}${_p_StringPrototypeCharAt(lowercase, i)}`;
|
|
66
66
|
} else {
|
|
67
67
|
notCamelcase += chrString;
|
|
68
68
|
}
|
|
@@ -101,7 +101,7 @@ function tokenizeArgString(argString) {
|
|
|
101
101
|
const args = [];
|
|
102
102
|
for (let ii = 0; ii < argString.length; ii++) {
|
|
103
103
|
prevC = c;
|
|
104
|
-
c = argString
|
|
104
|
+
c = _p_StringPrototypeCharAt(argString, ii);
|
|
105
105
|
if (c === " " && !opening) {
|
|
106
106
|
if (!(prevC === " ")) {
|
|
107
107
|
i++;
|
|
@@ -143,7 +143,7 @@ function combineAliases(aliases) {
|
|
|
143
143
|
const aliasArrays = [];
|
|
144
144
|
const combined = /* @__PURE__ */ _p_ObjectCreate(null);
|
|
145
145
|
let change = true;
|
|
146
|
-
|
|
146
|
+
_p_ObjectKeys(aliases).forEach(function(key) {
|
|
147
147
|
aliasArrays.push([].concat(aliases[key], key));
|
|
148
148
|
});
|
|
149
149
|
while (change) {
|
|
@@ -198,7 +198,7 @@ var init_yargs_parser = __esm({
|
|
|
198
198
|
mixin = _mixin;
|
|
199
199
|
}
|
|
200
200
|
parse(argsInput, options) {
|
|
201
|
-
const opts =
|
|
201
|
+
const opts = _p_ObjectAssign({
|
|
202
202
|
alias: void 0,
|
|
203
203
|
array: void 0,
|
|
204
204
|
boolean: void 0,
|
|
@@ -218,8 +218,8 @@ var init_yargs_parser = __esm({
|
|
|
218
218
|
}, options);
|
|
219
219
|
const args = tokenizeArgString(argsInput);
|
|
220
220
|
const inputIsString = typeof argsInput === "string";
|
|
221
|
-
const aliases = combineAliases(
|
|
222
|
-
const configuration =
|
|
221
|
+
const aliases = combineAliases(_p_ObjectAssign(/* @__PURE__ */ _p_ObjectCreate(null), opts.alias));
|
|
222
|
+
const configuration = _p_ObjectAssign({
|
|
223
223
|
"boolean-negation": true,
|
|
224
224
|
"camel-case-expansion": true,
|
|
225
225
|
"combine-arrays": false,
|
|
@@ -239,32 +239,32 @@ var init_yargs_parser = __esm({
|
|
|
239
239
|
"strip-dashed": false,
|
|
240
240
|
"unknown-options-as-args": false
|
|
241
241
|
}, opts.configuration);
|
|
242
|
-
const defaults =
|
|
242
|
+
const defaults = _p_ObjectAssign(/* @__PURE__ */ _p_ObjectCreate(null), opts.default);
|
|
243
243
|
const configObjects = opts.configObjects || [];
|
|
244
244
|
const envPrefix = opts.envPrefix;
|
|
245
245
|
const notFlagsOption = configuration["populate--"];
|
|
246
246
|
const notFlagsArgv = notFlagsOption ? "--" : "_";
|
|
247
|
-
const newAliases = /* @__PURE__ */
|
|
248
|
-
const defaulted = /* @__PURE__ */
|
|
247
|
+
const newAliases = /* @__PURE__ */ _p_ObjectCreate(null);
|
|
248
|
+
const defaulted = /* @__PURE__ */ _p_ObjectCreate(null);
|
|
249
249
|
const __ = opts.__ || mixin.format;
|
|
250
250
|
const flags = {
|
|
251
|
-
aliases: /* @__PURE__ */
|
|
252
|
-
arrays: /* @__PURE__ */
|
|
253
|
-
bools: /* @__PURE__ */
|
|
254
|
-
strings: /* @__PURE__ */
|
|
255
|
-
numbers: /* @__PURE__ */
|
|
256
|
-
counts: /* @__PURE__ */
|
|
257
|
-
normalize: /* @__PURE__ */
|
|
258
|
-
configs: /* @__PURE__ */
|
|
259
|
-
nargs: /* @__PURE__ */
|
|
260
|
-
coercions: /* @__PURE__ */
|
|
251
|
+
aliases: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
252
|
+
arrays: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
253
|
+
bools: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
254
|
+
strings: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
255
|
+
numbers: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
256
|
+
counts: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
257
|
+
normalize: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
258
|
+
configs: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
259
|
+
nargs: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
260
|
+
coercions: /* @__PURE__ */ _p_ObjectCreate(null),
|
|
261
261
|
keys: []
|
|
262
262
|
};
|
|
263
263
|
const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
|
|
264
|
-
const negatedBoolean = new
|
|
264
|
+
const negatedBoolean = new _p_RegExpCtor("^--" + configuration["negation-prefix"] + "(.+)");
|
|
265
265
|
[].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
|
|
266
266
|
const key = typeof opt === "object" ? opt.key : opt;
|
|
267
|
-
const assignment =
|
|
267
|
+
const assignment = _p_ObjectKeys(opt).map(function(key2) {
|
|
268
268
|
const arrayFlagKeys = {
|
|
269
269
|
boolean: "bools",
|
|
270
270
|
string: "strings",
|
|
@@ -299,7 +299,7 @@ var init_yargs_parser = __esm({
|
|
|
299
299
|
flags.keys.push(key);
|
|
300
300
|
});
|
|
301
301
|
if (typeof opts.narg === "object") {
|
|
302
|
-
|
|
302
|
+
_p_ObjectEntries(opts.narg).forEach(([key, value]) => {
|
|
303
303
|
if (typeof value === "number") {
|
|
304
304
|
flags.nargs[key] = value;
|
|
305
305
|
flags.keys.push(key);
|
|
@@ -307,7 +307,7 @@ var init_yargs_parser = __esm({
|
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
if (typeof opts.coerce === "object") {
|
|
310
|
-
|
|
310
|
+
_p_ObjectEntries(opts.coerce).forEach(([key, value]) => {
|
|
311
311
|
if (typeof value === "function") {
|
|
312
312
|
flags.coercions[key] = value;
|
|
313
313
|
flags.keys.push(key);
|
|
@@ -315,13 +315,13 @@ var init_yargs_parser = __esm({
|
|
|
315
315
|
});
|
|
316
316
|
}
|
|
317
317
|
if (typeof opts.config !== "undefined") {
|
|
318
|
-
if (
|
|
318
|
+
if (_p_ArrayIsArray(opts.config) || typeof opts.config === "string") {
|
|
319
319
|
;
|
|
320
320
|
[].concat(opts.config).filter(Boolean).forEach(function(key) {
|
|
321
321
|
flags.configs[key] = true;
|
|
322
322
|
});
|
|
323
323
|
} else if (typeof opts.config === "object") {
|
|
324
|
-
|
|
324
|
+
_p_ObjectEntries(opts.config).forEach(([key, value]) => {
|
|
325
325
|
if (typeof value === "boolean" || typeof value === "function") {
|
|
326
326
|
flags.configs[key] = value;
|
|
327
327
|
}
|
|
@@ -329,7 +329,7 @@ var init_yargs_parser = __esm({
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
extendAliases(opts.key, aliases, opts.default, flags.arrays);
|
|
332
|
-
|
|
332
|
+
_p_ObjectKeys(defaults).forEach(function(key) {
|
|
333
333
|
(flags.aliases[key] || []).forEach(function(alias) {
|
|
334
334
|
defaults[alias] = defaults[key];
|
|
335
335
|
});
|
|
@@ -337,7 +337,7 @@ var init_yargs_parser = __esm({
|
|
|
337
337
|
let error = null;
|
|
338
338
|
checkConfiguration();
|
|
339
339
|
let notFlags = [];
|
|
340
|
-
const argv =
|
|
340
|
+
const argv = _p_ObjectAssign(/* @__PURE__ */ _p_ObjectCreate(null), { _: [] });
|
|
341
341
|
const argvReturn = {};
|
|
342
342
|
for (let i = 0; i < args.length; i++) {
|
|
343
343
|
const arg = args[i];
|
|
@@ -355,7 +355,7 @@ var init_yargs_parser = __esm({
|
|
|
355
355
|
continue;
|
|
356
356
|
} else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
|
|
357
357
|
m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
|
|
358
|
-
if (m !== null &&
|
|
358
|
+
if (m !== null && _p_ArrayIsArray(m) && m.length >= 3) {
|
|
359
359
|
if (checkAllAliases(m[1], flags.arrays)) {
|
|
360
360
|
i = eatArray(i, m[1], args, m[2]);
|
|
361
361
|
} else if (checkAllAliases(m[1], flags.nargs) !== false) {
|
|
@@ -366,13 +366,13 @@ var init_yargs_parser = __esm({
|
|
|
366
366
|
}
|
|
367
367
|
} else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
|
|
368
368
|
m = arg.match(negatedBoolean);
|
|
369
|
-
if (m !== null &&
|
|
369
|
+
if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
|
|
370
370
|
key = m[1];
|
|
371
371
|
setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false);
|
|
372
372
|
}
|
|
373
373
|
} else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
|
|
374
374
|
m = arg.match(/^--?(.+)/);
|
|
375
|
-
if (m !== null &&
|
|
375
|
+
if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
|
|
376
376
|
key = m[1];
|
|
377
377
|
if (checkAllAliases(key, flags.arrays)) {
|
|
378
378
|
i = eatArray(i, key, args);
|
|
@@ -393,13 +393,13 @@ var init_yargs_parser = __esm({
|
|
|
393
393
|
}
|
|
394
394
|
} else if (arg.match(/^-.\..+=/)) {
|
|
395
395
|
m = arg.match(/^-([^=]+)=([\s\S]*)$/);
|
|
396
|
-
if (m !== null &&
|
|
396
|
+
if (m !== null && _p_ArrayIsArray(m) && m.length >= 3) {
|
|
397
397
|
setArg(m[1], m[2]);
|
|
398
398
|
}
|
|
399
399
|
} else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
|
|
400
400
|
next = args[i + 1];
|
|
401
401
|
m = arg.match(/^-(.\..+)/);
|
|
402
|
-
if (m !== null &&
|
|
402
|
+
if (m !== null && _p_ArrayIsArray(m) && m.length >= 2) {
|
|
403
403
|
key = m[1];
|
|
404
404
|
if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
|
405
405
|
setArg(key, next);
|
|
@@ -483,7 +483,7 @@ var init_yargs_parser = __esm({
|
|
|
483
483
|
applyCoercions(argv);
|
|
484
484
|
if (configuration["set-placeholder-key"])
|
|
485
485
|
setPlaceholderKeys(argv);
|
|
486
|
-
|
|
486
|
+
_p_ObjectKeys(flags.counts).forEach(function(key) {
|
|
487
487
|
if (!hasKey(argv, key.split(".")))
|
|
488
488
|
setArg(key, 0);
|
|
489
489
|
});
|
|
@@ -493,13 +493,13 @@ var init_yargs_parser = __esm({
|
|
|
493
493
|
argv[notFlagsArgv].push(key);
|
|
494
494
|
});
|
|
495
495
|
if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) {
|
|
496
|
-
|
|
496
|
+
_p_ObjectKeys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
|
|
497
497
|
delete argv[key];
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
if (configuration["strip-aliased"]) {
|
|
501
501
|
;
|
|
502
|
-
[].concat(...
|
|
502
|
+
[].concat(..._p_ObjectKeys(aliases).map((k) => aliases[k])).forEach((alias) => {
|
|
503
503
|
if (configuration["camel-case-expansion"] && alias.includes("-")) {
|
|
504
504
|
delete argv[alias.split(".").map((prop) => camelCase(prop)).join(".")];
|
|
505
505
|
}
|
|
@@ -540,7 +540,7 @@ var init_yargs_parser = __esm({
|
|
|
540
540
|
if (available < toEat)
|
|
541
541
|
error = Error(__("Not enough arguments following: %s", key));
|
|
542
542
|
}
|
|
543
|
-
let consumed =
|
|
543
|
+
let consumed = _p_MathMin(available, toEat);
|
|
544
544
|
if (!isUndefined(argAfterEqualSign) && consumed > 0) {
|
|
545
545
|
setArg(key, argAfterEqualSign);
|
|
546
546
|
consumed--;
|
|
@@ -560,7 +560,7 @@ var init_yargs_parser = __esm({
|
|
|
560
560
|
} else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
|
|
561
561
|
if (defaults[key] !== void 0) {
|
|
562
562
|
const defVal = defaults[key];
|
|
563
|
-
argsToSet =
|
|
563
|
+
argsToSet = _p_ArrayIsArray(defVal) ? defVal : [defVal];
|
|
564
564
|
}
|
|
565
565
|
} else {
|
|
566
566
|
if (!isUndefined(argAfterEqualSign)) {
|
|
@@ -614,7 +614,7 @@ var init_yargs_parser = __esm({
|
|
|
614
614
|
if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
|
|
615
615
|
const keys = [key].concat(flags.aliases[key] || []);
|
|
616
616
|
keys.forEach(function(key2) {
|
|
617
|
-
|
|
617
|
+
_p_ObjectDefineProperty(argvReturn, key2, {
|
|
618
618
|
enumerable: true,
|
|
619
619
|
get() {
|
|
620
620
|
return val;
|
|
@@ -645,14 +645,14 @@ var init_yargs_parser = __esm({
|
|
|
645
645
|
if (typeof val === "string")
|
|
646
646
|
val = val === "true";
|
|
647
647
|
}
|
|
648
|
-
let value =
|
|
648
|
+
let value = _p_ArrayIsArray(val) ? val.map(function(v) {
|
|
649
649
|
return maybeCoerceNumber(key, v);
|
|
650
650
|
}) : maybeCoerceNumber(key, val);
|
|
651
651
|
if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) {
|
|
652
652
|
value = increment();
|
|
653
653
|
}
|
|
654
654
|
if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
|
|
655
|
-
if (
|
|
655
|
+
if (_p_ArrayIsArray(val))
|
|
656
656
|
value = val.map((val2) => {
|
|
657
657
|
return mixin.normalize(val2);
|
|
658
658
|
});
|
|
@@ -665,8 +665,8 @@ var init_yargs_parser = __esm({
|
|
|
665
665
|
function maybeCoerceNumber(key, value) {
|
|
666
666
|
if (!configuration["parse-positional-numbers"] && key === "_")
|
|
667
667
|
return value;
|
|
668
|
-
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !
|
|
669
|
-
const shouldCoerceNumber = looksLikeNumber(value) && configuration["parse-numbers"] &&
|
|
668
|
+
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !_p_ArrayIsArray(value)) {
|
|
669
|
+
const shouldCoerceNumber = looksLikeNumber(value) && configuration["parse-numbers"] && _p_NumberIsSafeInteger(_p_MathFloor(parseFloat(`${value}`)));
|
|
670
670
|
if (shouldCoerceNumber || !isUndefined(value) && checkAllAliases(key, flags.numbers)) {
|
|
671
671
|
value = Number(value);
|
|
672
672
|
}
|
|
@@ -675,9 +675,9 @@ var init_yargs_parser = __esm({
|
|
|
675
675
|
}
|
|
676
676
|
__name(maybeCoerceNumber, "maybeCoerceNumber");
|
|
677
677
|
function setConfig(argv2) {
|
|
678
|
-
const configLookup = /* @__PURE__ */
|
|
678
|
+
const configLookup = /* @__PURE__ */ _p_ObjectCreate(null);
|
|
679
679
|
applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
|
|
680
|
-
|
|
680
|
+
_p_ObjectKeys(flags.configs).forEach(function(configKey) {
|
|
681
681
|
const configPath = argv2[configKey] || configLookup[configKey];
|
|
682
682
|
if (configPath) {
|
|
683
683
|
try {
|
|
@@ -709,10 +709,10 @@ var init_yargs_parser = __esm({
|
|
|
709
709
|
}
|
|
710
710
|
__name(setConfig, "setConfig");
|
|
711
711
|
function setConfigObject(config, prev) {
|
|
712
|
-
|
|
712
|
+
_p_ObjectKeys(config).forEach(function(key) {
|
|
713
713
|
const value = config[key];
|
|
714
714
|
const fullKey = prev ? prev + "." + key : key;
|
|
715
|
-
if (typeof value === "object" && value !== null && !
|
|
715
|
+
if (typeof value === "object" && value !== null && !_p_ArrayIsArray(value) && configuration["dot-notation"]) {
|
|
716
716
|
setConfigObject(value, fullKey);
|
|
717
717
|
} else {
|
|
718
718
|
if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) {
|
|
@@ -735,11 +735,11 @@ var init_yargs_parser = __esm({
|
|
|
735
735
|
return;
|
|
736
736
|
const prefix = typeof envPrefix === "string" ? envPrefix : "";
|
|
737
737
|
const env2 = mixin.env();
|
|
738
|
-
|
|
738
|
+
_p_ObjectKeys(env2).forEach(function(envVar) {
|
|
739
739
|
if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
|
|
740
740
|
const keys = envVar.split("__").map(function(key, i) {
|
|
741
741
|
if (i === 0) {
|
|
742
|
-
key = key
|
|
742
|
+
key = _p_StringPrototypeSubstring(key, prefix.length);
|
|
743
743
|
}
|
|
744
744
|
return camelCase(key);
|
|
745
745
|
});
|
|
@@ -752,8 +752,8 @@ var init_yargs_parser = __esm({
|
|
|
752
752
|
__name(applyEnvVars, "applyEnvVars");
|
|
753
753
|
function applyCoercions(argv2) {
|
|
754
754
|
let coerce;
|
|
755
|
-
const applied = /* @__PURE__ */ new
|
|
756
|
-
|
|
755
|
+
const applied = /* @__PURE__ */ new _p_SetCtor();
|
|
756
|
+
_p_ObjectKeys(argv2).forEach(function(key) {
|
|
757
757
|
if (!applied.has(key)) {
|
|
758
758
|
coerce = checkAllAliases(key, flags.coercions);
|
|
759
759
|
if (typeof coerce === "function") {
|
|
@@ -782,7 +782,7 @@ var init_yargs_parser = __esm({
|
|
|
782
782
|
}
|
|
783
783
|
__name(setPlaceholderKeys, "setPlaceholderKeys");
|
|
784
784
|
function applyDefaultsAndAliases(obj, aliases2, defaults2, canLog = false) {
|
|
785
|
-
|
|
785
|
+
_p_ObjectKeys(defaults2).forEach(function(key) {
|
|
786
786
|
if (!hasKey(obj, key.split("."))) {
|
|
787
787
|
setKey(obj, key.split("."), defaults2[key]);
|
|
788
788
|
if (canLog)
|
|
@@ -819,8 +819,8 @@ var init_yargs_parser = __esm({
|
|
|
819
819
|
if (typeof o === "object" && o[key2] === void 0) {
|
|
820
820
|
o[key2] = {};
|
|
821
821
|
}
|
|
822
|
-
if (typeof o[key2] !== "object" ||
|
|
823
|
-
if (
|
|
822
|
+
if (typeof o[key2] !== "object" || _p_ArrayIsArray(o[key2])) {
|
|
823
|
+
if (_p_ArrayIsArray(o[key2])) {
|
|
824
824
|
o[key2].push({});
|
|
825
825
|
} else {
|
|
826
826
|
o[key2] = [o[key2], {}];
|
|
@@ -832,19 +832,19 @@ var init_yargs_parser = __esm({
|
|
|
832
832
|
});
|
|
833
833
|
const key = sanitizeKey(keys[keys.length - 1]);
|
|
834
834
|
const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
|
|
835
|
-
const isValueArray =
|
|
835
|
+
const isValueArray = _p_ArrayIsArray(value);
|
|
836
836
|
let duplicate = configuration["duplicate-arguments-array"];
|
|
837
837
|
if (!duplicate && checkAllAliases(key, flags.nargs)) {
|
|
838
838
|
duplicate = true;
|
|
839
|
-
if (!isUndefined(o[key]) && flags.nargs[key] === 1 ||
|
|
839
|
+
if (!isUndefined(o[key]) && flags.nargs[key] === 1 || _p_ArrayIsArray(o[key]) && o[key].length === flags.nargs[key]) {
|
|
840
840
|
o[key] = void 0;
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
843
|
if (value === increment()) {
|
|
844
844
|
o[key] = increment(o[key]);
|
|
845
|
-
} else if (
|
|
845
|
+
} else if (_p_ArrayIsArray(o[key])) {
|
|
846
846
|
if (duplicate && isTypeArray && isValueArray) {
|
|
847
|
-
o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (
|
|
847
|
+
o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (_p_ArrayIsArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
|
|
848
848
|
} else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
|
|
849
849
|
o[key] = value;
|
|
850
850
|
} else {
|
|
@@ -861,7 +861,7 @@ var init_yargs_parser = __esm({
|
|
|
861
861
|
__name(setKey, "setKey");
|
|
862
862
|
function extendAliases(...args2) {
|
|
863
863
|
args2.forEach(function(obj) {
|
|
864
|
-
|
|
864
|
+
_p_ObjectKeys(obj || {}).forEach(function(key) {
|
|
865
865
|
if (flags.aliases[key])
|
|
866
866
|
return;
|
|
867
867
|
flags.aliases[key] = [].concat(aliases[key] || []);
|
|
@@ -894,16 +894,16 @@ var init_yargs_parser = __esm({
|
|
|
894
894
|
__name(extendAliases, "extendAliases");
|
|
895
895
|
function checkAllAliases(key, flag) {
|
|
896
896
|
const toCheck = [].concat(flags.aliases[key] || [], key);
|
|
897
|
-
const keys =
|
|
897
|
+
const keys = _p_ObjectKeys(flag);
|
|
898
898
|
const setAlias = toCheck.find((key2) => keys.includes(key2));
|
|
899
899
|
return setAlias ? flag[setAlias] : false;
|
|
900
900
|
}
|
|
901
901
|
__name(checkAllAliases, "checkAllAliases");
|
|
902
902
|
function hasAnyFlag(key) {
|
|
903
|
-
const flagsKeys =
|
|
903
|
+
const flagsKeys = _p_ObjectKeys(flags);
|
|
904
904
|
const toCheck = [].concat(flagsKeys.map((k) => flags[k]));
|
|
905
905
|
return toCheck.some(function(flag) {
|
|
906
|
-
return
|
|
906
|
+
return _p_ArrayIsArray(flag) ? flag.includes(key) : flag[key];
|
|
907
907
|
});
|
|
908
908
|
}
|
|
909
909
|
__name(hasAnyFlag, "hasAnyFlag");
|
|
@@ -991,7 +991,7 @@ var init_yargs_parser = __esm({
|
|
|
991
991
|
}
|
|
992
992
|
__name(isUndefined, "isUndefined");
|
|
993
993
|
function checkConfiguration() {
|
|
994
|
-
|
|
994
|
+
_p_ObjectKeys(flags.counts).find((key) => {
|
|
995
995
|
if (checkAllAliases(key, flags.arrays)) {
|
|
996
996
|
error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
|
|
997
997
|
return true;
|
|
@@ -1004,12 +1004,12 @@ var init_yargs_parser = __esm({
|
|
|
1004
1004
|
}
|
|
1005
1005
|
__name(checkConfiguration, "checkConfiguration");
|
|
1006
1006
|
return {
|
|
1007
|
-
aliases:
|
|
1008
|
-
argv:
|
|
1007
|
+
aliases: _p_ObjectAssign({}, flags.aliases),
|
|
1008
|
+
argv: _p_ObjectAssign(argvReturn, argv),
|
|
1009
1009
|
configuration,
|
|
1010
|
-
defaulted:
|
|
1010
|
+
defaulted: _p_ObjectAssign({}, defaulted),
|
|
1011
1011
|
error,
|
|
1012
|
-
newAliases:
|
|
1012
|
+
newAliases: _p_ObjectAssign({}, newAliases)
|
|
1013
1013
|
};
|
|
1014
1014
|
}
|
|
1015
1015
|
};
|
|
@@ -1057,7 +1057,7 @@ var init_lib = __esm({
|
|
|
1057
1057
|
if (typeof require2 !== "undefined") {
|
|
1058
1058
|
return require2(path);
|
|
1059
1059
|
} else if (path.match(/\.json$/)) {
|
|
1060
|
-
return
|
|
1060
|
+
return _p_JSONParse((0, import_fs.readFileSync)(path, "utf8"));
|
|
1061
1061
|
} else {
|
|
1062
1062
|
throw Error("only .json config files are supported in ESM");
|
|
1063
1063
|
}
|
package/dist/fs.js
CHANGED
|
@@ -73,6 +73,7 @@ var import_rewire = require("./paths/rewire");
|
|
|
73
73
|
var import_socket = require("./paths/socket");
|
|
74
74
|
var import_promises = require("./promises");
|
|
75
75
|
var import_sorts = require("./sorts");
|
|
76
|
+
var import_primordials = require("./primordials");
|
|
76
77
|
const abortSignal = (0, import_process.getAbortSignal)();
|
|
77
78
|
const NEWLINE_REGEX = /\n/g;
|
|
78
79
|
const defaultRemoveOptions = (0, import_objects.objectFreeze)({
|
|
@@ -84,7 +85,6 @@ const defaultRemoveOptions = (0, import_objects.objectFreeze)({
|
|
|
84
85
|
});
|
|
85
86
|
let _del;
|
|
86
87
|
let _cachedAllowedDirs;
|
|
87
|
-
let _buffer;
|
|
88
88
|
let _fs;
|
|
89
89
|
let _path;
|
|
90
90
|
function getAllowedDirectories() {
|
|
@@ -99,13 +99,6 @@ function getAllowedDirectories() {
|
|
|
99
99
|
return _cachedAllowedDirs;
|
|
100
100
|
}
|
|
101
101
|
// @__NO_SIDE_EFFECTS__
|
|
102
|
-
function getBuffer() {
|
|
103
|
-
if (_buffer === void 0) {
|
|
104
|
-
_buffer = require("node:buffer");
|
|
105
|
-
}
|
|
106
|
-
return _buffer;
|
|
107
|
-
}
|
|
108
|
-
// @__NO_SIDE_EFFECTS__
|
|
109
102
|
function getDel() {
|
|
110
103
|
if (_del === void 0) {
|
|
111
104
|
_del = require("./external/del");
|
|
@@ -144,8 +137,8 @@ function innerReadDirNames(dirents, dirname, options) {
|
|
|
144
137
|
// @__NO_SIDE_EFFECTS__
|
|
145
138
|
function stringify(json, EOL, finalEOL, replacer, spaces = 2) {
|
|
146
139
|
const EOF = finalEOL ? EOL : "";
|
|
147
|
-
const str =
|
|
148
|
-
return `${
|
|
140
|
+
const str = (0, import_primordials.JSONStringify)(json, replacer, spaces);
|
|
141
|
+
return `${(0, import_primordials.StringPrototypeReplace)(str, NEWLINE_REGEX, EOL)}${EOF}`;
|
|
149
142
|
}
|
|
150
143
|
// @__NO_SIDE_EFFECTS__
|
|
151
144
|
async function findUp(name, options) {
|
|
@@ -465,14 +458,14 @@ async function readJson(filepath, options) {
|
|
|
465
458
|
if (shouldThrow) {
|
|
466
459
|
const code = e.code;
|
|
467
460
|
if (code === "ENOENT") {
|
|
468
|
-
throw new
|
|
461
|
+
throw new import_primordials.ErrorCtor(
|
|
469
462
|
`JSON file not found: ${filepath}
|
|
470
463
|
Ensure the file exists or create it with the expected structure.`,
|
|
471
464
|
{ cause: e }
|
|
472
465
|
);
|
|
473
466
|
}
|
|
474
467
|
if (code === "EACCES" || code === "EPERM") {
|
|
475
|
-
throw new
|
|
468
|
+
throw new import_primordials.ErrorCtor(
|
|
476
469
|
`Permission denied reading JSON file: ${filepath}
|
|
477
470
|
Check file permissions or run with appropriate access.`,
|
|
478
471
|
{ cause: e }
|
|
@@ -508,14 +501,14 @@ function readJsonSync(filepath, options) {
|
|
|
508
501
|
if (shouldThrow) {
|
|
509
502
|
const code = e.code;
|
|
510
503
|
if (code === "ENOENT") {
|
|
511
|
-
throw new
|
|
504
|
+
throw new import_primordials.ErrorCtor(
|
|
512
505
|
`JSON file not found: ${filepath}
|
|
513
506
|
Ensure the file exists or create it with the expected structure.`,
|
|
514
507
|
{ cause: e }
|
|
515
508
|
);
|
|
516
509
|
}
|
|
517
510
|
if (code === "EACCES" || code === "EPERM") {
|
|
518
|
-
throw new
|
|
511
|
+
throw new import_primordials.ErrorCtor(
|
|
519
512
|
`Permission denied reading JSON file: ${filepath}
|
|
520
513
|
Check file permissions or run with appropriate access.`,
|
|
521
514
|
{ cause: e }
|
|
@@ -541,9 +534,9 @@ async function safeDelete(filepath, options) {
|
|
|
541
534
|
const allInAllowedDirs = patterns.every((pattern) => {
|
|
542
535
|
const resolvedPath = path.resolve(pattern);
|
|
543
536
|
for (const allowedDir of allowedDirs) {
|
|
544
|
-
const isInAllowedDir =
|
|
537
|
+
const isInAllowedDir = (0, import_primordials.StringPrototypeStartsWith)(resolvedPath, allowedDir + path.sep) || resolvedPath === allowedDir;
|
|
545
538
|
const relativePath = path.relative(allowedDir, resolvedPath);
|
|
546
|
-
const isGoingBackward =
|
|
539
|
+
const isGoingBackward = (0, import_primordials.StringPrototypeStartsWith)(relativePath, "..");
|
|
547
540
|
if (isInAllowedDir && !isGoingBackward) {
|
|
548
541
|
return true;
|
|
549
542
|
}
|
|
@@ -583,9 +576,9 @@ function safeDeleteSync(filepath, options) {
|
|
|
583
576
|
const allInAllowedDirs = patterns.every((pattern) => {
|
|
584
577
|
const resolvedPath = path.resolve(pattern);
|
|
585
578
|
for (const allowedDir of allowedDirs) {
|
|
586
|
-
const isInAllowedDir =
|
|
579
|
+
const isInAllowedDir = (0, import_primordials.StringPrototypeStartsWith)(resolvedPath, allowedDir + path.sep) || resolvedPath === allowedDir;
|
|
587
580
|
const relativePath = path.relative(allowedDir, resolvedPath);
|
|
588
|
-
const isGoingBackward =
|
|
581
|
+
const isGoingBackward = (0, import_primordials.StringPrototypeStartsWith)(relativePath, "..");
|
|
589
582
|
if (isInAllowedDir && !isGoingBackward) {
|
|
590
583
|
return true;
|
|
591
584
|
}
|
|
@@ -613,7 +606,12 @@ function safeDeleteSync(filepath, options) {
|
|
|
613
606
|
lastError = e;
|
|
614
607
|
if (attempt < maxRetries) {
|
|
615
608
|
const waitMs = delay;
|
|
616
|
-
|
|
609
|
+
(0, import_primordials.AtomicsWait)(
|
|
610
|
+
new import_primordials.Int32ArrayCtor(new import_primordials.SharedArrayBufferCtor(4)),
|
|
611
|
+
0,
|
|
612
|
+
0,
|
|
613
|
+
waitMs
|
|
614
|
+
);
|
|
617
615
|
delay *= 2;
|
|
618
616
|
}
|
|
619
617
|
}
|
|
@@ -665,8 +663,7 @@ async function safeReadFile(filepath, options) {
|
|
|
665
663
|
return void 0;
|
|
666
664
|
}
|
|
667
665
|
if (shouldReturnBuffer) {
|
|
668
|
-
|
|
669
|
-
return Buffer2.isBuffer(defaultValue) ? defaultValue : void 0;
|
|
666
|
+
return (0, import_primordials.BufferIsBuffer)(defaultValue) ? defaultValue : void 0;
|
|
670
667
|
}
|
|
671
668
|
return typeof defaultValue === "string" ? defaultValue : String(defaultValue);
|
|
672
669
|
}
|
|
@@ -690,8 +687,7 @@ function safeReadFileSync(filepath, options) {
|
|
|
690
687
|
return void 0;
|
|
691
688
|
}
|
|
692
689
|
if (shouldReturnBuffer) {
|
|
693
|
-
|
|
694
|
-
return Buffer2.isBuffer(defaultValue) ? defaultValue : void 0;
|
|
690
|
+
return (0, import_primordials.BufferIsBuffer)(defaultValue) ? defaultValue : void 0;
|
|
695
691
|
}
|
|
696
692
|
return typeof defaultValue === "string" ? defaultValue : String(defaultValue);
|
|
697
693
|
}
|