package-json-scripts-portability 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/dist/analyze-script.d.mts +34 -0
  3. package/dist/analyze-script.mjs +48 -0
  4. package/dist/command-checker.mjs +295 -0
  5. package/dist/command-usage.mjs +364 -0
  6. package/dist/commands.mjs +520 -0
  7. package/dist/context.mjs +18 -0
  8. package/dist/fixes.d.mts +9 -0
  9. package/dist/fixes.mjs +210 -0
  10. package/dist/index.d.mts +6 -118
  11. package/dist/index.mjs +4 -3787
  12. package/dist/line-break-checker.mjs +71 -0
  13. package/dist/messages.mjs +30 -0
  14. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-difference.mjs +11 -0
  15. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-includes.mjs +8 -0
  16. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs +13 -0
  17. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-is-subset.mjs +16 -0
  18. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/arrayify.mjs +7 -0
  19. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/iterable/sliding-window.mjs +30 -0
  20. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert-computed.mjs +42 -0
  21. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert.mjs +40 -0
  22. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/math/clamp.mjs +7 -0
  23. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/path/to-forward-slashes.mjs +8 -0
  24. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/predicate/is-array.mjs +39 -0
  25. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/set/set-has.mjs +8 -0
  26. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after-last.mjs +24 -0
  27. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-before.mjs +24 -0
  28. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/truncate.mjs +46 -0
  29. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/ts/all-union-members.mjs +45 -0
  30. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/types/maybe-readonly-array.d.mts +17 -0
  31. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/value/is-equal.mjs +37 -0
  32. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/@antfu/utils/dist/index.mjs +5 -0
  33. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/globalThis.mjs +5 -0
  34. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceBy.mjs +40 -0
  35. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceWith.mjs +37 -0
  36. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/intersectionWith.mjs +43 -0
  37. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/isSubsetWith.mjs +36 -0
  38. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/bigint/clamp.mjs +15 -0
  39. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getSymbols.mjs +5 -0
  40. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/getTag.mjs +13 -0
  41. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/regexMultiByte.mjs +10 -0
  42. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/_internal/tags.mjs +27 -0
  43. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/predicate/isObject.mjs +28 -0
  44. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/string/truncate.mjs +78 -0
  45. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/compat/util/eq.mjs +18 -0
  46. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/function/noop.mjs +12 -0
  47. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/math/clamp.mjs +23 -0
  48. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isBuffer.mjs +24 -0
  49. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqual.mjs +21 -0
  50. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isEqualWith.mjs +151 -0
  51. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/predicate/isPlainObject.mjs +50 -0
  52. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/remeda/dist/isArray.mjs +18 -0
  53. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/array-includes.mjs +5 -0
  54. package/dist/node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/ts-extras/distribution/set-has.mjs +5 -0
  55. package/dist/platforms.d.mts +8 -0
  56. package/dist/platforms.mjs +26 -0
  57. package/dist/redirection-checker.mjs +117 -0
  58. package/dist/reporter.d.mts +32 -0
  59. package/dist/reporter.mjs +98 -0
  60. package/dist/runners.d.mts +24 -0
  61. package/dist/runners.mjs +118 -0
  62. package/dist/script-analyzer.mjs +551 -0
  63. package/dist/word-checker.mjs +444 -0
  64. package/dist/words.mjs +43 -0
  65. package/package.json +22 -20
@@ -0,0 +1,71 @@
1
+ import { rangeInScript } from "./context.mjs";
2
+ import { joinLinesFix } from "./fixes.mjs";
3
+ import { slidingWindow } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/iterable/sliding-window.mjs";
4
+ // src/line-break-checker.ts
5
+ const ONE_LINE_SUGGESTION = "Put the command on one line instead.";
6
+ /** Checks line breaks, after which cmd.exe ignores the rest of the script */
7
+ var LineBreakChecker = class {
8
+ /** Ranges of reported line breaks in the analyzed script, e.g. to skip them in nested scripts */
9
+ #lineBreaks = [];
10
+ #multilineSources = /* @__PURE__ */ new Set();
11
+ #reporter;
12
+ constructor(reporter) {
13
+ this.#reporter = reporter;
14
+ }
15
+ /**
16
+ * Reports a line break in a command, e.g. after a `\` line continuation or in a quoted string.
17
+ * @param node The command
18
+ * @param context Where the command is
19
+ */
20
+ checkCommandLineBreak(node, context) {
21
+ const newline = context.source.slice(node.pos, node.end).indexOf("\n");
22
+ if (newline === -1) return;
23
+ const position = node.pos + newline;
24
+ const isInWord = [
25
+ node.name,
26
+ ...node.prefix,
27
+ ...node.suffix
28
+ ].some((item) => item && item.pos <= position && position < item.end);
29
+ const isQuoted = isInWord && context.source[position - 1] !== "\\";
30
+ this.reportLineBreak(context, position, ONE_LINE_SUGGESTION, isInWord ? void 0 : joinLinesFix(context.source, position, position + 1), isQuoted);
31
+ }
32
+ /**
33
+ * Reports a line break after an operator of a list or pipeline, e.g. after `||`.
34
+ * @param commands The commands that the operators join
35
+ * @param context Where the commands are
36
+ */
37
+ checkOperatorLineBreaks(commands, context) {
38
+ for (const [command, next] of slidingWindow(commands, 2)) {
39
+ const between = context.source.slice(command.end, next.pos);
40
+ const newline = between.indexOf("\n");
41
+ if (newline !== -1) {
42
+ const position = command.end + newline;
43
+ this.reportLineBreak(context, position, ONE_LINE_SUGGESTION, between.includes("#") ? void 0 : joinLinesFix(context.source, position, next.pos));
44
+ return;
45
+ }
46
+ }
47
+ }
48
+ /**
49
+ * Reports a line break, after which cmd.exe ignores the rest of the script, once per source.
50
+ * @param context Where the line break is
51
+ * @param position Where the line break is in the source
52
+ * @param suggestion What to do instead
53
+ * @param fix A fix for the report
54
+ * @param isPortableSupported Whether Yarn's shell supports it, e.g. in quotes
55
+ */
56
+ reportLineBreak(context, position, suggestion, fix, isPortableSupported = false) {
57
+ const lineBreak = {
58
+ end: position + 1,
59
+ pos: position
60
+ };
61
+ const range = rangeInScript(context, lineBreak);
62
+ if (this.#lineBreaks.some((reported) => reported.pos < range.end && range.pos < reported.end) || this.#multilineSources.has(context.source)) return;
63
+ if (this.#reporter.reportSyntax(context, lineBreak, "posix", isPortableSupported, "unsupportedSyntax", {
64
+ suggestion,
65
+ syntax: "A multi-line script"
66
+ }, fix).length === 0) return;
67
+ this.#multilineSources.add(context.source);
68
+ this.#lineBreaks.push(range);
69
+ }
70
+ };
71
+ export { LineBreakChecker };
@@ -0,0 +1,30 @@
1
+ import { truncate as truncate$2 } from "./node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/truncate.mjs";
2
+ // src/messages.ts
3
+ const BASH_4_SUGGESTION = "It needs Bash 4 or later, which macOS doesn't ship; use a Node.js script instead.";
4
+ const BASH_SUGGESTION = "Scripts run with `sh` (which isn't Bash on e.g. Debian/Ubuntu) or cmd.exe (on Windows).";
5
+ const CROSS_ENV_SUGGESTION = "Use `cross-env` instead.";
6
+ const CROSS_ENV_VARIABLE_SUGGESTION = "`cross-env` only replaces `$VAR` and `${VAR}` in all versions; use a Node.js script instead.";
7
+ const DEFAULT_SUGGESTION = "Use a cross-platform package or a Node.js script instead.";
8
+ const NODE_SCRIPT_SUGGESTION = "Use a Node.js script instead.";
9
+ const RIMRAF_SUGGESTION = "Use `rimraf` instead.";
10
+ const SHELL_SCRIPT_SUGGESTION = "Shell scripts require a POSIX shell; use a Node.js script instead.";
11
+ const VARIABLE_SUGGESTION = "Use `cross-env` or a Node.js script instead.";
12
+ /** Joins names for people, e.g. "macOS, Linux, and Windows" */
13
+ const listFormat = new Intl.ListFormat("en");
14
+ /** Maximum length of script text in a report message */
15
+ const MAX_SNIPPET_CHARACTERS = 40;
16
+ const WHITESPACE = /\s+/g;
17
+ /**
18
+ * Shortens script text for a report message.
19
+ * @param text Text from the script
20
+ * @returns The text on a single line, cut off at the maximum length
21
+ */
22
+ const truncate = (text) => truncate$2(text.replaceAll(WHITESPACE, " "), { length: MAX_SNIPPET_CHARACTERS });
23
+ /**
24
+ * Describes a fix that replaces script text, e.g. "Replace `rm -rf` with `rimraf`.".
25
+ * @param original The replaced text
26
+ * @param replacement The text that replaces it
27
+ * @returns The description
28
+ */
29
+ const describeReplacement = (original, replacement) => `Replace \`${truncate(original)}\` with \`${truncate(replacement)}\`.`;
30
+ export { BASH_4_SUGGESTION, BASH_SUGGESTION, CROSS_ENV_SUGGESTION, CROSS_ENV_VARIABLE_SUGGESTION, DEFAULT_SUGGESTION, NODE_SCRIPT_SUGGESTION, RIMRAF_SUGGESTION, SHELL_SCRIPT_SUGGESTION, VARIABLE_SUGGESTION, describeReplacement, listFormat, truncate };
@@ -0,0 +1,11 @@
1
+ import { differenceBy } from "../vendor/es-toolkit/dist/array/differenceBy.mjs";
2
+ import { differenceWith } from "../vendor/es-toolkit/dist/array/differenceWith.mjs";
3
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-difference.mjs
4
+ function arrayDifference(firstArray, secondArray, fn) {
5
+ if (!fn) {
6
+ const secondSet = new Set(secondArray);
7
+ return firstArray.filter((item) => !secondSet.has(item));
8
+ }
9
+ return fn.length === 2 ? differenceWith(firstArray, secondArray, fn) : differenceBy(firstArray, secondArray, fn);
10
+ }
11
+ export { arrayDifference };
@@ -0,0 +1,8 @@
1
+ import { arrayIncludes as arrayIncludes$1 } from "../vendor/ts-extras/distribution/array-includes.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-includes.mjs
3
+ /**
4
+ * Checks whether an array has a value, like `Array.prototype.includes`, but as a type guard: when
5
+ * it returns `true`, the value is narrowed to the element type of the array
6
+ */
7
+ const arrayIncludes = arrayIncludes$1;
8
+ export { arrayIncludes };
@@ -0,0 +1,13 @@
1
+ import { intersectionWith } from "../vendor/es-toolkit/dist/array/intersectionWith.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-intersection.mjs
3
+ function arrayIntersection(firstArray, secondArray, fn) {
4
+ if (!fn) {
5
+ const secondSet = new Set(secondArray);
6
+ return firstArray.filter((item) => secondSet.has(item));
7
+ }
8
+ if (fn.length === 2) return intersectionWith(firstArray, secondArray, fn);
9
+ const mapper = fn;
10
+ const secondKeys = new Set(secondArray.map((item) => mapper(item)));
11
+ return firstArray.filter((item) => secondKeys.has(mapper(item)));
12
+ }
13
+ export { arrayIntersection };
@@ -0,0 +1,16 @@
1
+ import { isSubsetWith } from "../vendor/es-toolkit/dist/array/isSubsetWith.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/array-is-subset.mjs
3
+ function arrayIsSubset(superset, subset, fn) {
4
+ if (!fn) {
5
+ const supersetSet = new Set(superset);
6
+ return subset.every((item) => supersetSet.has(item));
7
+ }
8
+ if (fn.length === 2) {
9
+ const areItemsEqual = fn;
10
+ return isSubsetWith(superset, subset, (subsetItem, supersetItem) => areItemsEqual(supersetItem, subsetItem));
11
+ }
12
+ const mapper = fn;
13
+ const mappedSuperset = new Set(superset.map((item) => mapper(item)));
14
+ return subset.every((item) => mappedSuperset.has(mapper(item)));
15
+ }
16
+ export { arrayIsSubset };
@@ -0,0 +1,7 @@
1
+ import { isArray } from "../predicate/is-array.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/array/arrayify.mjs
3
+ function arrayify(value, shouldWrapNullish = false) {
4
+ if (value == null) return shouldWrapNullish ? [value] : [];
5
+ return isArray(value) ? value : [value];
6
+ }
7
+ export { arrayify };
@@ -0,0 +1,30 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/iterable/sliding-window.mjs
2
+ function* generateWindows(iterable, size, step, shouldYieldPartialWindows) {
3
+ const buffer = [];
4
+ let skip = 0;
5
+ for (const item of iterable) {
6
+ if (skip > 0) {
7
+ skip--;
8
+ continue;
9
+ }
10
+ buffer.push(item);
11
+ if (buffer.length !== size) continue;
12
+ yield buffer.slice();
13
+ if (step >= size) {
14
+ buffer.length = 0;
15
+ skip = step - size;
16
+ } else buffer.splice(0, step);
17
+ }
18
+ if (!shouldYieldPartialWindows || buffer.length === 0) return;
19
+ yield buffer.slice();
20
+ while (buffer.length > step) {
21
+ buffer.splice(0, step);
22
+ yield buffer.slice();
23
+ }
24
+ }
25
+ function slidingWindow(iterable, size, step = 1, { partialWindows = false } = {}) {
26
+ if (!Number.isSafeInteger(size) || size < 1) throw new Error("`size` must be a positive integer.");
27
+ if (!Number.isSafeInteger(step) || step < 1) throw new Error("`step` must be a positive integer.");
28
+ return generateWindows(iterable, size, step, partialWindows);
29
+ }
30
+ export { slidingWindow };
@@ -0,0 +1,42 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert-computed.mjs
2
+ /**
3
+ * Returns the value stored under `key`, first inserting the result of `computeDefaultValue` when
4
+ * the key is not present.
5
+ *
6
+ * The lazy counterpart of `mapGetOrInsert`: `computeDefaultValue` runs only on a miss, so it suits
7
+ * defaults that are expensive to build, must not be shared between keys, or have side effects.
8
+ * An already present value is never overwritten, and a stored `undefined` counts as present.
9
+ *
10
+ * Calls the native `Map#getOrInsertComputed` when the map has it, which doesn't call the `has`,
11
+ * `get` and `set` methods of the map: a `Map` subclass that overrides them should override
12
+ * `getOrInsertComputed` too.
13
+ * @param map - The map to read from.
14
+ * Mutated only when `key` is not present.
15
+ * @param key - The key to look up.
16
+ * @param computeDefaultValue - Produces the value to insert.
17
+ * Called with `key`, and only when `key` is not present.
18
+ * @returns The value already stored under `key`, or the computed value when it has just been
19
+ * inserted.
20
+ * @example
21
+ * // Grouping entries by key: every miss gets its own array
22
+ * const entriesByPackageId = new Map<string, Entry[]>();
23
+ * mapGetOrInsertComputed(entriesByPackageId, packageId, () => []).push(newEntry);
24
+ * @example
25
+ * // The looked-up key is passed to the factory
26
+ * const messagesByChannel = new Map<string, string[]>();
27
+ * mapGetOrInsertComputed(messagesByChannel, 'general', (channel) => [`joined ${channel}`]);
28
+ * // ['joined general']
29
+ * @example
30
+ * // Nothing is computed for a key that is already there
31
+ * mapGetOrInsertComputed(new Map([['alice', 10]]), 'alice', () => expensiveDefault());
32
+ * // 10, `expensiveDefault` never runs
33
+ */
34
+ const mapGetOrInsertComputed = (map, key, computeDefaultValue) => {
35
+ const nativeMap = map;
36
+ if (nativeMap.getOrInsertComputed) return nativeMap.getOrInsertComputed(key, computeDefaultValue);
37
+ if (map.has(key)) return map.get(key);
38
+ const defaultValue = computeDefaultValue(key);
39
+ map.set(key, defaultValue);
40
+ return defaultValue;
41
+ };
42
+ export { mapGetOrInsertComputed };
@@ -0,0 +1,40 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/map/map-get-or-insert.mjs
2
+ /**
3
+ * Returns the value stored under `key`, first inserting `defaultValue` when the key is not present.
4
+ *
5
+ * The return type is not optional, unlike `Map#get`, so the result is directly usable, which
6
+ * collapses the usual "look up, create when missing, then use" dance into a single expression.
7
+ * An already present value is never overwritten, and a stored `undefined` counts as present.
8
+ *
9
+ * `defaultValue` is evaluated by the caller on every call, even when `key` is already present.
10
+ * Use `mapGetOrInsertComputed` when producing it is expensive or has side effects.
11
+ *
12
+ * Calls the native `Map#getOrInsert` when the map has it, which doesn't call the `has`, `get` and
13
+ * `set` methods of the map: a `Map` subclass that overrides them should override `getOrInsert` too.
14
+ * @param map - The map to read from.
15
+ * Mutated only when `key` is not present.
16
+ * @param key - The key to look up.
17
+ * @param defaultValue - The value to insert and return when `key` is not present.
18
+ * @returns The value already stored under `key`, or `defaultValue` when it has just been inserted.
19
+ * @example
20
+ * // Appending to an array-valued map without a separate existence check
21
+ * const tagsByPostId = new Map<string, string[]>();
22
+ * mapGetOrInsert(tagsByPostId, 'post-1', []).push('typescript');
23
+ * // Map { 'post-1' => ['typescript'] }
24
+ * @example
25
+ * // An existing value is returned as-is
26
+ * mapGetOrInsert(new Map([['alice', 10]]), 'alice', 0);
27
+ * // 10
28
+ * @example
29
+ * // A stored `undefined` is a value, not a miss
30
+ * mapGetOrInsert(new Map<string, number | undefined>([['a', undefined]]), 'a', 42);
31
+ * // undefined
32
+ */
33
+ const mapGetOrInsert = (map, key, defaultValue) => {
34
+ const nativeMap = map;
35
+ if (nativeMap.getOrInsert) return nativeMap.getOrInsert(key, defaultValue);
36
+ if (map.has(key)) return map.get(key);
37
+ map.set(key, defaultValue);
38
+ return defaultValue;
39
+ };
40
+ export { mapGetOrInsert };
@@ -0,0 +1,7 @@
1
+ import { clamp as clamp$1 } from "../vendor/es-toolkit/dist/bigint/clamp.mjs";
2
+ import { clamp as clamp$2 } from "../vendor/es-toolkit/dist/math/clamp.mjs";
3
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/math/clamp.mjs
4
+ function clamp(value, bound1, bound2) {
5
+ return typeof value === "bigint" ? clamp$1(value, bound1, bound2) : clamp$2(value, bound1, bound2);
6
+ }
7
+ export { clamp };
@@ -0,0 +1,8 @@
1
+ import { slash } from "../vendor/@antfu/utils/dist/index.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/path/to-forward-slashes.mjs
3
+ /**
4
+ * Replaces every backslash in a path with a forward slash, turning a Windows path into the form
5
+ * that URLs, glob patterns and POSIX tools expect
6
+ */
7
+ const toForwardSlashes = slash;
8
+ export { toForwardSlashes };
@@ -0,0 +1,39 @@
1
+ import { isArray as isArray$1 } from "../vendor/remeda/dist/isArray.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/predicate/is-array.mjs
3
+ /**
4
+ * Checks whether a value is an array, like `Array.isArray`, but also narrows readonly arrays.
5
+ *
6
+ * `Array.isArray` narrows to `any[]`, and a readonly array is not assignable to it.
7
+ * So for a `T | readonly T[]` value, it gives `any[]` when `true` and keeps `readonly T[]` when
8
+ * `false`.
9
+ * This guard narrows to the array members of the value's type (or to `readonly unknown[]` if
10
+ * there are none) when `true`, and removes them when `false`.
11
+ * @param data - The value to check.
12
+ * @returns `true` if `data` is an array, `false` otherwise.
13
+ * @example
14
+ * declare const paths: string | readonly string[];
15
+ *
16
+ * if (isArray(paths)) {
17
+ * paths; // readonly string[]
18
+ * } else {
19
+ * paths; // string
20
+ * }
21
+ * @example
22
+ * // Mutable arrays and tuples keep their types
23
+ * declare const size: number | [width: number, height: number];
24
+ *
25
+ * const [width, height] = isArray(size) ? size : [size, size];
26
+ * @example
27
+ * // Narrows `unknown` to a readonly array, so its elements can't be modified by mistake
28
+ * declare const value: unknown;
29
+ *
30
+ * if (isArray(value)) {
31
+ * value; // readonly unknown[]
32
+ * }
33
+ * @example
34
+ * isArray([1, 2, 3]); // true
35
+ * isArray(new Set([1, 2, 3])); // false
36
+ * isArray({length: 0}); // false
37
+ */
38
+ const isArray = isArray$1;
39
+ export { isArray };
@@ -0,0 +1,8 @@
1
+ import { setHas as setHas$1 } from "../vendor/ts-extras/distribution/set-has.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/set/set-has.mjs
3
+ /**
4
+ * Checks whether a set has a value, like `Set.prototype.has`, but as a type guard: when it returns
5
+ * `true`, the value is narrowed to the element type of the set
6
+ */
7
+ const setHas = setHas$1;
8
+ export { setHas };
@@ -0,0 +1,24 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-after-last.mjs
2
+ /**
3
+ * Gets the part of a string after the last occurrence of a delimiter.
4
+ * When the delimiter is missing, returns `fallback`, which defaults to the
5
+ * whole string.
6
+ * @param text - The string to search.
7
+ * @param delimiter - The substring to search for.
8
+ * @param fallback - What to return when the delimiter is missing (defaults to `text`).
9
+ * @returns The part after the last delimiter, or `fallback`.
10
+ * @example
11
+ * substringAfterLast('src/utils/index.ts', '/');
12
+ * // 'index.ts'
13
+ * @example
14
+ * // File extension, empty when there is none
15
+ * substringAfterLast('index.test.ts', '.', '');
16
+ * // 'ts'
17
+ * substringAfterLast('Makefile', '.', '');
18
+ * // ''
19
+ */
20
+ const substringAfterLast = (text, delimiter, fallback = text) => {
21
+ const index = text.lastIndexOf(delimiter);
22
+ return index === -1 ? fallback : text.slice(index + delimiter.length);
23
+ };
24
+ export { substringAfterLast };
@@ -0,0 +1,24 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/substring-before.mjs
2
+ /**
3
+ * Gets the part of a string before the first occurrence of a delimiter.
4
+ * When the delimiter is missing, returns `fallback`, which defaults to the
5
+ * whole string.
6
+ * @param text - The string to search.
7
+ * @param delimiter - The substring to search for.
8
+ * @param fallback - What to return when the delimiter is missing (defaults to `text`).
9
+ * @returns The part before the first delimiter, or `fallback`.
10
+ * @example
11
+ * substringBefore('index.test.ts', '.');
12
+ * // 'index'
13
+ * substringBefore('README', '.');
14
+ * // 'README'
15
+ * @example
16
+ * // A different result for a missing delimiter
17
+ * substringBefore('no-scheme', '://', '');
18
+ * // ''
19
+ */
20
+ const substringBefore = (text, delimiter, fallback = text) => {
21
+ const index = text.indexOf(delimiter);
22
+ return index === -1 ? fallback : text.slice(0, index);
23
+ };
24
+ export { substringBefore };
@@ -0,0 +1,46 @@
1
+ import { truncate as truncate$1 } from "../vendor/es-toolkit/dist/compat/string/truncate.mjs";
2
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/string/truncate.mjs
3
+ /**
4
+ * Shortens a string to a maximum length, replacing the removed part with an
5
+ * omission (`'...'` by default).
6
+ * Strings that fit are returned as is.
7
+ * The length is counted in code points, so emoji are never split in half.
8
+ *
9
+ * The removed part is at the end by default; pass `position: 'start'` to keep
10
+ * the end (like the end of a long path), or `'middle'` to keep both ends (like
11
+ * a file name with its extension).
12
+ * With the default `'end'` position, a `separator` makes the cut happen before
13
+ * its last match within the limit, to avoid cutting a word in half.
14
+ * When a match starts right at the limit, the string is cut there.
15
+ * When `length` is shorter than the omission, a string that doesn't fit becomes
16
+ * the omission alone, which is longer than `length`.
17
+ * @param text - The string to truncate.
18
+ * @param options - `length` (`30` by default), `omission` (`'...'` by default), `position` (`'end'`
19
+ * by default) and `separator`.
20
+ * @returns The string, shortened if needed.
21
+ * @example
22
+ * truncate('hi-diddly-ho there, neighborino');
23
+ * // 'hi-diddly-ho there, neighbo...'
24
+ * truncate('hi-diddly-ho there, neighborino', {length: 24, separator: ' '});
25
+ * // 'hi-diddly-ho there,...'
26
+ * @example
27
+ * // Keep the end or both ends
28
+ * truncate('/home/user/projects/utilery/src/index.ts', {length: 20, position: 'start'});
29
+ * // '...lery/src/index.ts'
30
+ * truncate('a-very-long-file-name.tar.gz', {length: 16, position: 'middle'});
31
+ * // 'a-very-...tar.gz'
32
+ */
33
+ const truncate = (text, options = {}) => {
34
+ const { length = 30, omission = "...", position = "end", separator } = options;
35
+ if (position === "end") return truncate$1(text, {
36
+ length,
37
+ omission,
38
+ ...separator != null && { separator }
39
+ });
40
+ const characters = [...text];
41
+ if (characters.length <= length) return text;
42
+ const keptLength = Math.max(Math.floor(length) - [...omission].length, 0) || 0;
43
+ const headLength = position === "middle" ? Math.ceil(keptLength / 2) : 0;
44
+ return characters.slice(0, headLength).join("") + omission + characters.slice(characters.length - (keptLength - headLength)).join("");
45
+ };
46
+ export { truncate };
@@ -0,0 +1,45 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/ts/all-union-members.mjs
2
+ /**
3
+ * Builds a compile-time guard that a tuple lists every member of `Union`
4
+ * exactly once: no missing members, no extras and no duplicates.
5
+ * It is meant to keep a runtime list in sync with a union type: whenever the
6
+ * union changes, the tuple stops type-checking until it is updated to match.
7
+ *
8
+ * Because TypeScript cannot infer one type argument while another is given
9
+ * explicitly, the union is passed to the outer call and the tuple is inferred
10
+ * by the returned function.
11
+ * At runtime the returned function is the identity function: all of the work
12
+ * happens in the type system.
13
+ * An invalid tuple fails to type-check with a message that names the missing,
14
+ * extra or duplicated members (see {@link AllUnionMembers}).
15
+ *
16
+ * By default the result is widened to a mutable tuple; pass `{readonly: true}`
17
+ * as the second type argument to preserve the `readonly` tuple type instead.
18
+ * @returns A function that accepts the tuple and returns it unchanged, typed as
19
+ * the tuple of `Union`'s members (mutable by default, `readonly` on request).
20
+ * @example
21
+ * type Fruit = 'apple' | 'banana' | 'cherry';
22
+ *
23
+ * // OK: lists every member exactly once
24
+ * const fruits = allUnionMembers<Fruit>()(['apple', 'banana', 'cherry']);
25
+ * // type: ['apple', 'banana', 'cherry']
26
+ * @example
27
+ * // Error: "...is missing these union members": "cherry"
28
+ * allUnionMembers<Fruit>()(['apple', 'banana']);
29
+ * @example
30
+ * // Error: 'apple' is duplicated
31
+ * allUnionMembers<Fruit>()(['apple', 'banana', 'cherry', 'apple']);
32
+ * @example
33
+ * // Error: 'date' is not a member of `Fruit`
34
+ * allUnionMembers<Fruit>()(['apple', 'banana', 'cherry', 'date']);
35
+ * @example
36
+ * // Keep the tuple `readonly`
37
+ * const readonlyFruits = allUnionMembers<Fruit, {readonly: true}>()([
38
+ * 'apple',
39
+ * 'banana',
40
+ * 'cherry',
41
+ * ]);
42
+ * // type: readonly ['apple', 'banana', 'cherry']
43
+ */
44
+ const allUnionMembers = () => (members) => members;
45
+ export { allUnionMembers };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A value or a readonly array of such values: `T | readonly T[]`.
3
+ *
4
+ * Unlike `MaybeArray`, it also accepts readonly arrays and tuples (like `as const` literals), so
5
+ * it fits parameters and options that only read the array.
6
+ * To tell the two cases apart, use `isArray`: unlike `Array.isArray`, it narrows this type in
7
+ * both branches.
8
+ * @example
9
+ * const watch = (paths: MaybeReadonlyArray<string>) => {
10
+ * const list = isArray(paths) ? paths : [paths]; // readonly string[]
11
+ * // ...
12
+ * };
13
+ *
14
+ * watch('src');
15
+ * watch(['src', 'test'] as const); // an error with `MaybeArray<string>`
16
+ */
17
+ export type MaybeReadonlyArray<T> = T | readonly T[];
@@ -0,0 +1,37 @@
1
+ import { isEqual as isEqual$1 } from "../vendor/es-toolkit/dist/predicate/isEqual.mjs";
2
+ import { isEqualWith } from "../vendor/es-toolkit/dist/predicate/isEqualWith.mjs";
3
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/value/is-equal.mjs
4
+ /**
5
+ * Performs a deep equality comparison between two values.
6
+ * Handles `Date`, `RegExp`, nested objects, arrays, `Map`, `Set`, and circular
7
+ * references.
8
+ *
9
+ * When the third argument is omitted, the values are compared with the default
10
+ * strategy.
11
+ * When a `customizer` is provided, it is invoked for every visited value-pair
12
+ * and may return `true` or `false` to override the default; returning
13
+ * `undefined` falls back to the default strategy.
14
+ * @param a - The first value to compare.
15
+ * @param b - The second value to compare.
16
+ * @param customizer - Optional comparator invoked as
17
+ * `(x, y, property, xParent, yParent, stack)` for each visited value-pair.
18
+ * @returns `true` if the values are deeply equal, otherwise `false`.
19
+ * @example
20
+ * // Basic deep equality
21
+ * isEqual({a: 1, b: [2, 3]}, {a: 1, b: [2, 3]});
22
+ * // true
23
+ * @example
24
+ * // Built-in types
25
+ * isEqual(new Date('2020-01-01'), new Date('2020-01-01'));
26
+ * // true
27
+ * @example
28
+ * // With a customizer: case-insensitive string comparison
29
+ * isEqual('Hello', 'hello', (x, y) => {
30
+ * if (typeof x === 'string' && typeof y === 'string') {
31
+ * return x.toLowerCase() === y.toLowerCase();
32
+ * }
33
+ * });
34
+ * // true
35
+ */
36
+ const isEqual = (a, b, customizer) => customizer ? isEqualWith(a, b, customizer) : isEqual$1(a, b);
37
+ export { isEqual };
@@ -0,0 +1,5 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/@antfu/utils/dist/index.mjs
2
+ function slash(str) {
3
+ return str.replace(/\\/g, "/");
4
+ }
5
+ export { slash };
@@ -0,0 +1,5 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/_internal/globalThis.mjs
2
+ const globalThis_ = typeof globalThis === "object" && globalThis || typeof window === "object" && window || typeof self === "object" && self || typeof global === "object" && global || (function() {
3
+ return this;
4
+ })();
5
+ export { globalThis_ as globalThis };
@@ -0,0 +1,40 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceBy.mjs
2
+ /**
3
+ * Computes the difference between two arrays after mapping their elements through a provided function.
4
+ *
5
+ * This function takes two arrays and a mapper function. It returns a new array containing the elements
6
+ * that are present in the first array but not in the second array, based on the identity calculated
7
+ * by the mapper function.
8
+ *
9
+ * Essentially, it filters out any elements from the first array that, when
10
+ * mapped, match an element in the mapped version of the second array.
11
+ *
12
+ * @template T, U
13
+ * @param firstArr - The primary array from which to derive the difference.
14
+ * @param secondArr - The array containing elements to be excluded from the first array.
15
+ * @param mapper - The function to map the elements of both arrays. This function
16
+ * is applied to each element in both arrays, and the comparison is made based on the mapped values.
17
+ * @returns A new array containing the elements from the first array that do not have a corresponding
18
+ * mapped identity in the second array.
19
+ *
20
+ * @example
21
+ * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
22
+ * const array2 = [{ id: 2 }, { id: 4 }];
23
+ * const mapper = item => item.id;
24
+ * const result = differenceBy(array1, array2, mapper);
25
+ * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are in both arrays and are excluded from the result.
26
+ *
27
+ * @example
28
+ * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
29
+ * const array2 = [2, 4];
30
+ * const mapper = item => (typeof item === 'object' ? item.id : item);
31
+ * const result = differenceBy(array1, array2, mapper);
32
+ * // result will be [{ id: 1 }, { id: 3 }] since 2 is present in both arrays after mapping, and is excluded from the result.
33
+ */
34
+ function differenceBy(firstArr, secondArr, mapper) {
35
+ const mappedSecondSet = new Set(secondArr.map((item) => mapper(item)));
36
+ return firstArr.filter((item) => {
37
+ return !mappedSecondSet.has(mapper(item));
38
+ });
39
+ }
40
+ export { differenceBy };
@@ -0,0 +1,37 @@
1
+ // node_modules/.pnpm/utilery@0.4.0/node_modules/utilery/dist/vendor/es-toolkit/dist/array/differenceWith.mjs
2
+ /**
3
+ * Computes the difference between two arrays based on a custom equality function.
4
+ *
5
+ * This function takes two arrays and a custom comparison function. It returns a new array containing
6
+ * the elements that are present in the first array but not in the second array. The comparison to determine
7
+ * if elements are equal is made using the provided custom function.
8
+ *
9
+ * @template T, U
10
+ * @param firstArr - The array from which to get the difference.
11
+ * @param secondArr - The array containing elements to exclude from the first array.
12
+ * @param areItemsEqual - A function to determine if two items are equal.
13
+ * @returns A new array containing the elements from the first array that do not match any elements in the second array
14
+ * according to the custom equality function.
15
+ *
16
+ * @example
17
+ * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
18
+ * const array2 = [{ id: 2 }, { id: 4 }];
19
+ * const areItemsEqual = (a, b) => a.id === b.id;
20
+ * const result = differenceWith(array1, array2, areItemsEqual);
21
+ * // result will be [{ id: 1 }, { id: 3 }] since the elements with id 2 are considered equal and are excluded from the result.
22
+ *
23
+ * @example
24
+ * const array1 = [{ id: 1 }, { id: 2 }, { id: 3 }];
25
+ * const array2 = [2, 4];
26
+ * const areItemsEqual = (a, b) => a.id === b;
27
+ * const result = differenceWith(array1, array2, areItemsEqual);
28
+ * // result will be [{ id: 1 }, { id: 3 }] since the element with id 2 is considered equal to the second array's element and is excluded from the result.
29
+ */
30
+ function differenceWith(firstArr, secondArr, areItemsEqual) {
31
+ return firstArr.filter((firstItem) => {
32
+ return secondArr.every((secondItem) => {
33
+ return !areItemsEqual(firstItem, secondItem);
34
+ });
35
+ });
36
+ }
37
+ export { differenceWith };