vouchington-tooling 0.53.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +99 -12
- package/dist/agent-blackboard/index.d.mts +0 -1
- package/dist/agent-blackboard/index.mjs +0 -23
- package/dist/cli/commands/agent-blackboard-flags.d.mts +0 -1
- package/dist/cli/commands/agent-blackboard-flags.mjs +0 -9
- package/dist/cli/commands/agent-blackboard.d.mts +0 -2
- package/dist/cli/commands/agent-blackboard.mjs +7 -121
- package/dist/cli/commands/story-coverage.d.mts +2 -0
- package/dist/cli/commands/story-coverage.mjs +56 -0
- package/dist/cli/index.mjs +6 -0
- package/dist/cli/optional-peer.d.mts +5 -0
- package/dist/cli/optional-peer.mjs +17 -0
- package/dist/cli/parse-forwarded-commands.d.mts +3 -0
- package/dist/cli/parse-forwarded-commands.mjs +2 -0
- package/dist/cli/parse-story-coverage-fields.d.mts +19 -0
- package/dist/cli/parse-story-coverage-fields.mjs +69 -0
- package/dist/cli/parse-story-coverage.d.mts +8 -0
- package/dist/cli/parse-story-coverage.mjs +34 -0
- package/dist/cli/parse.d.mts +5 -1
- package/dist/cli/parse.mjs +3 -0
- package/dist/cli/story-coverage-lazy.d.mts +3 -0
- package/dist/cli/story-coverage-lazy.mjs +6 -0
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +8 -7
- package/dist/host-storage/check.d.mts +38 -0
- package/dist/host-storage/check.mjs +109 -0
- package/dist/host-storage/cli.d.mts +7 -0
- package/dist/host-storage/cli.mjs +102 -0
- package/dist/host-storage/host-storage.test-helpers.d.mts +26 -0
- package/dist/host-storage/host-storage.test-helpers.mjs +58 -0
- package/dist/host-storage/index.d.mts +3 -0
- package/dist/host-storage/index.mjs +3 -0
- package/dist/host-storage/preflight.d.mts +22 -0
- package/dist/host-storage/preflight.mjs +105 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/playwright/assertions.d.mts +1 -0
- package/dist/playwright/assertions.mjs +5 -0
- package/dist/playwright/blocked-external-network.d.mts +15 -0
- package/dist/playwright/blocked-external-network.mjs +73 -0
- package/dist/playwright/browser-dialog-issues.d.mts +12 -0
- package/dist/playwright/browser-dialog-issues.mjs +29 -0
- package/dist/playwright/browser-errors.d.mts +23 -0
- package/dist/playwright/browser-errors.mjs +130 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.d.mts +31 -0
- package/dist/playwright/browser-issue-monitor.test-helpers.mjs +51 -0
- package/dist/playwright/browser-issue-records.d.mts +42 -0
- package/dist/playwright/browser-issue-records.mjs +148 -0
- package/dist/playwright/browser-test.d.mts +22 -0
- package/dist/playwright/browser-test.mjs +68 -0
- package/dist/playwright/expect-no-broken-images.d.mts +17 -0
- package/dist/playwright/expect-no-broken-images.mjs +39 -0
- package/dist/playwright/index.d.mts +32 -0
- package/dist/playwright/index.mjs +22 -0
- package/dist/playwright/mobile-assertions.d.mts +14 -0
- package/dist/playwright/mobile-assertions.mjs +43 -0
- package/dist/playwright/monitored-test-info.d.mts +14 -0
- package/dist/playwright/monitored-test-info.mjs +1 -0
- package/dist/playwright/navigate-to.d.mts +27 -0
- package/dist/playwright/navigate-to.mjs +39 -0
- package/dist/playwright/radix-select.d.mts +18 -0
- package/dist/playwright/radix-select.mjs +19 -0
- package/dist/playwright/random-id.d.mts +34 -0
- package/dist/playwright/random-id.mjs +37 -0
- package/dist/playwright/retry-on-connection-lost.d.mts +7 -0
- package/dist/playwright/retry-on-connection-lost.mjs +107 -0
- package/dist/playwright/scroll-to-load-more.d.mts +37 -0
- package/dist/playwright/scroll-to-load-more.mjs +158 -0
- package/dist/playwright/storybook.d.mts +2 -0
- package/dist/playwright/storybook.mjs +13 -0
- package/dist/playwright/test-fixtures.d.mts +1 -0
- package/dist/playwright/test-fixtures.mjs +2 -0
- package/dist/playwright/test-lifecycle-reporter.d.mts +27 -0
- package/dist/playwright/test-lifecycle-reporter.mjs +57 -0
- package/dist/playwright/totp.d.mts +6 -0
- package/dist/playwright/totp.mjs +37 -0
- package/dist/playwright/turnstile-stub.d.mts +8 -0
- package/dist/playwright/turnstile-stub.mjs +61 -0
- package/dist/playwright/viewport-constants.d.mts +30 -0
- package/dist/playwright/viewport-constants.mjs +9 -0
- package/dist/playwright/virtual-authenticator.d.mts +5 -0
- package/dist/playwright/virtual-authenticator.mjs +15 -0
- package/dist/playwright/wait-for-hydration.d.mts +29 -0
- package/dist/playwright/wait-for-hydration.mjs +81 -0
- package/dist/shell-parse/ansi-c-string.d.mts +12 -0
- package/dist/shell-parse/ansi-c-string.mjs +80 -0
- package/dist/shell-parse/index.d.mts +20 -0
- package/dist/shell-parse/index.mjs +15 -0
- package/dist/shell-parse/shell-command-substitution-reads.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitution-reads.mjs +53 -0
- package/dist/shell-parse/shell-command-substitutions.d.mts +8 -0
- package/dist/shell-parse/shell-command-substitutions.mjs +52 -0
- package/dist/shell-parse/shell-command-wrappers.d.mts +26 -0
- package/dist/shell-parse/shell-command-wrappers.mjs +143 -0
- package/dist/shell-parse/shell-commands.d.mts +24 -0
- package/dist/shell-parse/shell-commands.mjs +155 -0
- package/dist/shell-parse/shell-heredoc-delimiter.d.mts +5 -0
- package/dist/shell-parse/shell-heredoc-delimiter.mjs +52 -0
- package/dist/shell-parse/shell-heredoc-parser.d.mts +7 -0
- package/dist/shell-parse/shell-heredoc-parser.mjs +49 -0
- package/dist/shell-parse/shell-heredoc-quote-state.d.mts +19 -0
- package/dist/shell-parse/shell-heredoc-quote-state.mjs +40 -0
- package/dist/shell-parse/shell-heredoc.d.mts +10 -0
- package/dist/shell-parse/shell-heredoc.mjs +90 -0
- package/dist/shell-parse/shell-redirections.d.mts +5 -0
- package/dist/shell-parse/shell-redirections.mjs +34 -0
- package/dist/shell-parse/shell-script-operand.d.mts +13 -0
- package/dist/shell-parse/shell-script-operand.mjs +103 -0
- package/dist/shell-parse/shell-stdin-script.d.mts +6 -0
- package/dist/shell-parse/shell-stdin-script.mjs +61 -0
- package/dist/shell-parse/shell-token-utils.d.mts +9 -0
- package/dist/shell-parse/shell-token-utils.mjs +33 -0
- package/dist/shell-parse/shell-tokenizer-comments.d.mts +1 -0
- package/dist/shell-parse/shell-tokenizer-comments.mjs +57 -0
- package/dist/shell-parse/shell-tokenizer-operators.d.mts +14 -0
- package/dist/shell-parse/shell-tokenizer-operators.mjs +47 -0
- package/dist/shell-parse/shell-tokenizer.d.mts +12 -0
- package/dist/shell-parse/shell-tokenizer.mjs +104 -0
- package/dist/story-coverage/analyze.d.mts +8 -0
- package/dist/story-coverage/analyze.mjs +24 -0
- package/dist/story-coverage/check.d.mts +11 -0
- package/dist/story-coverage/check.mjs +42 -0
- package/dist/story-coverage/components.d.mts +10 -0
- package/dist/story-coverage/components.mjs +40 -0
- package/dist/story-coverage/coverage.d.mts +10 -0
- package/dist/story-coverage/coverage.mjs +43 -0
- package/dist/story-coverage/index.d.mts +13 -0
- package/dist/story-coverage/index.mjs +7 -0
- package/dist/story-coverage/messages.d.mts +10 -0
- package/dist/story-coverage/messages.mjs +42 -0
- package/dist/story-coverage/options.d.mts +27 -0
- package/dist/story-coverage/options.mjs +51 -0
- package/dist/story-coverage/workspace.d.mts +2 -0
- package/dist/story-coverage/workspace.mjs +27 -0
- package/dist/test-helpers/cancel-runs.test-helpers.d.mts +39 -0
- package/dist/test-helpers/cancel-runs.test-helpers.mjs +124 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.d.mts +12 -0
- package/dist/test-helpers/run-bounded-exit-observer.test-helpers.mjs +68 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.d.mts +18 -0
- package/dist/test-helpers/run-bounded-output-fixture.test-helpers.mjs +162 -0
- package/dist/vitest-diagnostics/browser.d.mts +2 -0
- package/dist/vitest-diagnostics/browser.mjs +6 -0
- package/dist/vitest-diagnostics/index.d.mts +14 -23
- package/dist/vitest-diagnostics/index.mjs +8 -124
- package/dist/vitest-diagnostics/report-summary.d.mts +22 -0
- package/dist/vitest-diagnostics/report-summary.mjs +123 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.d.mts +6 -0
- package/dist/vitest-diagnostics/vitest-fake-timer-guard.mjs +34 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.d.mts +1 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-detection.mjs +8 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.d.mts +17 -1
- package/dist/vitest-diagnostics/vitest-fork-leak-diagnostics.mjs +44 -2
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.d.mts +55 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake-samples.mjs +74 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.d.mts +19 -0
- package/dist/vitest-diagnostics/vitest-fork-leak-handshake.mjs +136 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-dns.mjs +54 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.d.mts +8 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-host.mjs +48 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.d.mts +14 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist-socket.mjs +39 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.d.mts +7 -0
- package/dist/vitest-diagnostics/vitest-network-allowlist.mjs +72 -0
- package/dist/vitest-diagnostics/vitest-process-resources.d.mts +10 -0
- package/dist/vitest-diagnostics/vitest-process-resources.mjs +54 -0
- package/dist/vitest-effective-timeout/cap.d.mts +9 -0
- package/dist/vitest-effective-timeout/cap.mjs +28 -0
- package/dist/vitest-effective-timeout/check-profiles.d.mts +15 -0
- package/dist/vitest-effective-timeout/check-profiles.mjs +52 -0
- package/dist/vitest-effective-timeout/config-file.d.mts +6 -0
- package/dist/vitest-effective-timeout/config-file.mjs +23 -0
- package/dist/vitest-effective-timeout/fixtures.d.mts +2 -0
- package/dist/vitest-effective-timeout/fixtures.mjs +18 -0
- package/dist/vitest-effective-timeout/index.d.mts +7 -0
- package/dist/vitest-effective-timeout/index.mjs +4 -0
- package/dist/vitest-effective-timeout/profiles.d.mts +10 -0
- package/dist/vitest-effective-timeout/profiles.mjs +33 -0
- package/dist/vitest-effective-timeout/run-profile.d.mts +31 -0
- package/dist/vitest-effective-timeout/run-profile.mjs +95 -0
- package/docs/mcp-server.md +2 -13
- package/package.json +37 -2
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/chromium-launch-probe.d.mts +7 -0
- package/scripts/chromium-launch-probe.mjs +101 -0
- package/scripts/run-bounded-fixtures/run-bounded-backpressure.py +186 -0
- package/scripts/run-bounded-fixtures/run-bounded-merged-output.py +75 -0
- package/scripts/run-bounded-fixtures/run-bounded-reset-socket.py +25 -0
- package/scripts/run-bounded.py +199 -0
- package/scripts/run_bounded_process.py +129 -0
- package/scripts/worktree/git-index-lock.sh +16 -0
- package/scripts/worktree/git-worktrees.sh +23 -20
- package/scripts/worktree/reset-worktree-run.sh +199 -0
- package/scripts/worktree/reset-worktree.sh +122 -0
- package/skills/blackboard/SKILL.md +4 -64
- package/skills/stacked-prs/SKILL.md +1 -1
- package/skills/stacked-prs/references/drain.md +2 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function commandSegmentStart(tokens: string[], index: number, isSeparator?: typeof isShellCommandSeparator): number;
|
|
2
|
+
export declare function isShellAssignment(token: string): boolean;
|
|
3
|
+
/** The variable a plain `NAME=value` assignment sets, or null for any other word. */
|
|
4
|
+
export declare function plainShellAssignment(token: string): {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
} | null;
|
|
8
|
+
export declare function isShellCommandSeparator(token: string): boolean;
|
|
9
|
+
export declare function nextShellCommandSeparatorIndex(tokens: string[], startIndex: number): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// `NAME=value`, `NAME+=value`, and `NAME[SUB]=value`. Only the plain form gives the command a value
|
|
2
|
+
// the hook can read: `+=` appends to a value it cannot see, and an array element is never exported.
|
|
3
|
+
const SHELL_ASSIGNMENT_RE = /^([A-Za-z_][A-Za-z0-9_]*)(\[[^\]]*\])?(\+)?=/;
|
|
4
|
+
const SHELL_COMMAND_SEPARATORS = new Set(['&&', '&', '(', ')', ';', '|', '||', '\n', '{', '}']);
|
|
5
|
+
export function commandSegmentStart(tokens, index, isSeparator = isShellCommandSeparator) {
|
|
6
|
+
for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
|
|
7
|
+
if (isSeparator(tokens[cursor])) {
|
|
8
|
+
return cursor + 1;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
export function isShellAssignment(token) {
|
|
14
|
+
return SHELL_ASSIGNMENT_RE.test(token);
|
|
15
|
+
}
|
|
16
|
+
/** The variable a plain `NAME=value` assignment sets, or null for any other word. */
|
|
17
|
+
export function plainShellAssignment(token) {
|
|
18
|
+
const match = SHELL_ASSIGNMENT_RE.exec(token);
|
|
19
|
+
if (match === null || match[2] !== undefined || match[3] !== undefined)
|
|
20
|
+
return null;
|
|
21
|
+
return { name: match[1], value: token.slice(match[0].length) };
|
|
22
|
+
}
|
|
23
|
+
export function isShellCommandSeparator(token) {
|
|
24
|
+
return SHELL_COMMAND_SEPARATORS.has(token);
|
|
25
|
+
}
|
|
26
|
+
export function nextShellCommandSeparatorIndex(tokens, startIndex) {
|
|
27
|
+
for (let index = startIndex; index < tokens.length; index += 1) {
|
|
28
|
+
if (isShellCommandSeparator(tokens[index])) {
|
|
29
|
+
return index;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return tokens.length;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripUnquotedShellComments(command: string): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readAnsiCString } from "./ansi-c-string.mjs";
|
|
2
|
+
export function stripUnquotedShellComments(command) {
|
|
3
|
+
let result = '';
|
|
4
|
+
let quote = null;
|
|
5
|
+
let escaping = false;
|
|
6
|
+
let wordStarted = false;
|
|
7
|
+
for (let index = 0; index < command.length; index += 1) {
|
|
8
|
+
const char = command[index];
|
|
9
|
+
if (escaping) {
|
|
10
|
+
result += char;
|
|
11
|
+
escaping = false;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (quote === null && char === '$' && command[index + 1] === "'") {
|
|
15
|
+
const ansiString = readAnsiCString(command, index + 2);
|
|
16
|
+
if (ansiString !== null) {
|
|
17
|
+
result += command.slice(index, ansiString.endIndex + 1);
|
|
18
|
+
wordStarted = true;
|
|
19
|
+
index = ansiString.endIndex;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (char === '\\' && quote !== "'") {
|
|
24
|
+
result += char;
|
|
25
|
+
wordStarted = true;
|
|
26
|
+
escaping = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (quote !== null) {
|
|
30
|
+
result += char;
|
|
31
|
+
if (char === quote) {
|
|
32
|
+
quote = null;
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (char === "'" || char === '"') {
|
|
37
|
+
result += char;
|
|
38
|
+
quote = char;
|
|
39
|
+
wordStarted = true;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (char === '#' && !wordStarted) {
|
|
43
|
+
while (index + 1 < command.length && command[index + 1] !== '\n') {
|
|
44
|
+
index += 1;
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
result += char;
|
|
49
|
+
if (char === '\n' || /\s/.test(char) || /[&|;()]/.test(char)) {
|
|
50
|
+
wordStarted = false;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
wordStarted = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ShellWord } from './shell-tokenizer.mts';
|
|
2
|
+
type SeparatorState = {
|
|
3
|
+
char: string;
|
|
4
|
+
command: string;
|
|
5
|
+
expandable: boolean;
|
|
6
|
+
index: number;
|
|
7
|
+
options: {
|
|
8
|
+
splitRedirections?: boolean;
|
|
9
|
+
};
|
|
10
|
+
token: string;
|
|
11
|
+
tokens: ShellWord[];
|
|
12
|
+
};
|
|
13
|
+
export declare function consumeShellSeparator(state: SeparatorState): number | undefined;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isRedirectionFd, shellRedirectionOperatorAt } from "./shell-redirections.mjs";
|
|
2
|
+
function pushStateToken(state) {
|
|
3
|
+
if (state.token === '')
|
|
4
|
+
return;
|
|
5
|
+
state.tokens.push({ expandable: state.expandable, value: state.token });
|
|
6
|
+
state.token = '';
|
|
7
|
+
state.expandable = false;
|
|
8
|
+
}
|
|
9
|
+
export function consumeShellSeparator(state) {
|
|
10
|
+
const redirectionOperator = state.options.splitRedirections === true
|
|
11
|
+
? shellRedirectionOperatorAt(state.command, state.index)
|
|
12
|
+
: null;
|
|
13
|
+
if (redirectionOperator !== null) {
|
|
14
|
+
if (isRedirectionFd(state.token)) {
|
|
15
|
+
state.tokens.push({
|
|
16
|
+
expandable: state.expandable,
|
|
17
|
+
value: `${state.token}${redirectionOperator}`,
|
|
18
|
+
});
|
|
19
|
+
state.token = '';
|
|
20
|
+
state.expandable = false;
|
|
21
|
+
}
|
|
22
|
+
else if (state.token !== '') {
|
|
23
|
+
pushStateToken(state);
|
|
24
|
+
state.tokens.push({ expandable: false, value: redirectionOperator });
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
state.tokens.push({ expandable: false, value: redirectionOperator });
|
|
28
|
+
}
|
|
29
|
+
return state.index + redirectionOperator.length - 1;
|
|
30
|
+
}
|
|
31
|
+
const { char } = state;
|
|
32
|
+
if (char === '&' || char === '|' || char === ';' || char === '(' || char === ')') {
|
|
33
|
+
pushStateToken(state);
|
|
34
|
+
const previousToken = state.tokens.at(-1)?.value;
|
|
35
|
+
if ((char === '&' && previousToken === '&') || (char === '|' && previousToken === '|')) {
|
|
36
|
+
state.tokens[state.tokens.length - 1] = {
|
|
37
|
+
expandable: false,
|
|
38
|
+
value: `${previousToken}${char}`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
state.tokens.push({ expandable: false, value: char });
|
|
43
|
+
}
|
|
44
|
+
return state.index;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { stripUnquotedShellComments } from './shell-tokenizer-comments.mts';
|
|
2
|
+
export type ShellWord = {
|
|
3
|
+
expandable: boolean;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function tokenizeShellWordsDetailed(command: string, options?: {
|
|
7
|
+
splitRedirections?: boolean;
|
|
8
|
+
}): ShellWord[];
|
|
9
|
+
export declare function tokenizeShellWords(command: string, options?: {
|
|
10
|
+
splitRedirections?: boolean;
|
|
11
|
+
}): string[];
|
|
12
|
+
export { stripUnquotedShellComments };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { readAnsiCString } from "./ansi-c-string.mjs";
|
|
2
|
+
import { consumeShellSeparator } from "./shell-tokenizer-operators.mjs";
|
|
3
|
+
import { stripUnquotedShellComments } from "./shell-tokenizer-comments.mjs";
|
|
4
|
+
const DOUBLE_QUOTE_ESCAPE_CHARS = new Set(['$', '`', '"', '\\', '\n']);
|
|
5
|
+
export function tokenizeShellWordsDetailed(command, options = {}) {
|
|
6
|
+
const commandWithoutComments = stripUnquotedShellComments(command);
|
|
7
|
+
const tokens = [];
|
|
8
|
+
let token = '';
|
|
9
|
+
let expandable = false;
|
|
10
|
+
let quote = null;
|
|
11
|
+
let escaping = false;
|
|
12
|
+
function pushToken() {
|
|
13
|
+
if (token === '')
|
|
14
|
+
return;
|
|
15
|
+
tokens.push({ expandable, value: token });
|
|
16
|
+
token = '';
|
|
17
|
+
expandable = false;
|
|
18
|
+
}
|
|
19
|
+
for (let index = 0; index < commandWithoutComments.length; index += 1) {
|
|
20
|
+
const char = commandWithoutComments[index];
|
|
21
|
+
if (escaping) {
|
|
22
|
+
if (char === '\n') {
|
|
23
|
+
// Line continuation: bash removes `\<newline>` unquoted and in double quotes.
|
|
24
|
+
}
|
|
25
|
+
else if (quote === '"' && !DOUBLE_QUOTE_ESCAPE_CHARS.has(char)) {
|
|
26
|
+
token += `\\${char}`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
token += char;
|
|
30
|
+
}
|
|
31
|
+
escaping = false;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (quote === null && char === '$' && commandWithoutComments[index + 1] === "'") {
|
|
35
|
+
const ansiString = readAnsiCString(commandWithoutComments, index + 2);
|
|
36
|
+
if (ansiString !== null) {
|
|
37
|
+
token += ansiString.value;
|
|
38
|
+
index = ansiString.endIndex;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (char === '\\') {
|
|
43
|
+
if (quote === "'") {
|
|
44
|
+
token += char;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
escaping = true;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (quote !== "'" && (char === '$' || char === '`'))
|
|
51
|
+
expandable = true;
|
|
52
|
+
if (quote !== null) {
|
|
53
|
+
if (char === quote) {
|
|
54
|
+
quote = null;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
token += char;
|
|
58
|
+
}
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (char === "'" || char === '"') {
|
|
62
|
+
quote = char;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (char === '\n') {
|
|
66
|
+
pushToken();
|
|
67
|
+
tokens.push({ expandable: false, value: '\n' });
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (/\s/.test(char)) {
|
|
71
|
+
pushToken();
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const separator = {
|
|
75
|
+
char,
|
|
76
|
+
command: commandWithoutComments,
|
|
77
|
+
expandable,
|
|
78
|
+
index,
|
|
79
|
+
options,
|
|
80
|
+
token,
|
|
81
|
+
tokens,
|
|
82
|
+
};
|
|
83
|
+
const consumedIndex = consumeShellSeparator(separator);
|
|
84
|
+
token = separator.token;
|
|
85
|
+
expandable = separator.expandable;
|
|
86
|
+
if (consumedIndex !== undefined) {
|
|
87
|
+
index = consumedIndex;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (quote === null &&
|
|
91
|
+
(char === '*' ||
|
|
92
|
+
char === '?' ||
|
|
93
|
+
char === '[' ||
|
|
94
|
+
(char === '{' && /^\{[^}]*(?:,|\.\.)[^}]*\}/.test(commandWithoutComments.slice(index)))))
|
|
95
|
+
expandable = true;
|
|
96
|
+
token += char;
|
|
97
|
+
}
|
|
98
|
+
pushToken();
|
|
99
|
+
return tokens;
|
|
100
|
+
}
|
|
101
|
+
export function tokenizeShellWords(command, options = {}) {
|
|
102
|
+
return tokenizeShellWordsDetailed(command, options).map((token) => token.value);
|
|
103
|
+
}
|
|
104
|
+
export { stripUnquotedShellComments };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TypeScriptModuleFacts } from 'no-mistakes';
|
|
2
|
+
import { type SourceModuleGraph } from '../source-module-graph/index.mts';
|
|
3
|
+
import type { StoryCoverageConfig } from './options.mts';
|
|
4
|
+
export type StorySourceAnalysis = {
|
|
5
|
+
graph: SourceModuleGraph;
|
|
6
|
+
modules: ReadonlyMap<string, TypeScriptModuleFacts>;
|
|
7
|
+
};
|
|
8
|
+
export declare function analyzeStorySources(files: readonly string[], config: StoryCoverageConfig): Promise<StorySourceAnalysis>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { relative, resolve } from 'node:path';
|
|
2
|
+
import { analyzeTypeScriptModules } from 'no-mistakes';
|
|
3
|
+
import { createSourceModuleGraph } from "../source-module-graph/index.mjs";
|
|
4
|
+
export async function analyzeStorySources(files, config) {
|
|
5
|
+
const facts = await analyzeTypeScriptModules({ root: config.root, files: [...files] });
|
|
6
|
+
const modules = new Map();
|
|
7
|
+
for (const item of facts.modules) {
|
|
8
|
+
const file = relative(config.root, resolve(config.root, item.fileName)).replaceAll('\\', '/');
|
|
9
|
+
if (!item.complete)
|
|
10
|
+
throw new Error(`Incomplete source module facts: ${file}`);
|
|
11
|
+
modules.set(file, item);
|
|
12
|
+
}
|
|
13
|
+
if (modules.size !== files.length || files.some((file) => !modules.has(file))) {
|
|
14
|
+
throw new Error('Incomplete story source inventory');
|
|
15
|
+
}
|
|
16
|
+
const graph = createSourceModuleGraph({
|
|
17
|
+
root: config.root,
|
|
18
|
+
extensions: config.sourceExtensions,
|
|
19
|
+
aliases: config.aliases,
|
|
20
|
+
files,
|
|
21
|
+
facts,
|
|
22
|
+
});
|
|
23
|
+
return { graph, modules };
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type NamespaceComponentImport } from './coverage.mts';
|
|
2
|
+
import { type MissingComponent } from './messages.mts';
|
|
3
|
+
import { type StoryCoverageRequest } from './options.mts';
|
|
4
|
+
export type StoryCoverageReport = {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
namespaceImports: NamespaceComponentImport[];
|
|
7
|
+
excludedKeys: string[];
|
|
8
|
+
missingComponents: MissingComponent[];
|
|
9
|
+
messages: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function checkStoryCoverage(request: StoryCoverageRequest, files?: readonly string[]): Promise<StoryCoverageReport>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { analyzeStorySources } from "./analyze.mjs";
|
|
2
|
+
import { componentExports } from "./components.mjs";
|
|
3
|
+
import { coveredComponentKeys, namespaceComponentImports, reachableStoryFiles, } from "./coverage.mjs";
|
|
4
|
+
import { formatExclusionsMessage, formatMissingComponentsMessage, formatNamespaceImportsMessage, } from "./messages.mjs";
|
|
5
|
+
import { storyCoverageConfig, } from "./options.mjs";
|
|
6
|
+
import { workspaceFiles } from "./workspace.mjs";
|
|
7
|
+
export async function checkStoryCoverage(request, files) {
|
|
8
|
+
const config = storyCoverageConfig(request);
|
|
9
|
+
const inventory = [...new Set(files ?? workspaceFiles(config))];
|
|
10
|
+
if (inventory.length === 0)
|
|
11
|
+
return coverageReport(config, [], new Set(), []);
|
|
12
|
+
const analysis = await analyzeStorySources(inventory, config);
|
|
13
|
+
const storyFiles = reachableStoryFiles(inventory, analysis.graph, config);
|
|
14
|
+
return coverageReport(config, namespaceComponentImports(storyFiles, analysis.graph, config), coveredComponentKeys(storyFiles, analysis.graph, config), componentExports(inventory, analysis.modules, config));
|
|
15
|
+
}
|
|
16
|
+
function coverageReport(config, namespaceImports, covered, components) {
|
|
17
|
+
const excludedKeys = Object.keys(config.exclusions).toSorted();
|
|
18
|
+
const excluded = new Set(excludedKeys);
|
|
19
|
+
const missingComponents = components
|
|
20
|
+
.flatMap((component) => covered.has(component.key) || excluded.has(component.key)
|
|
21
|
+
? []
|
|
22
|
+
: [
|
|
23
|
+
{
|
|
24
|
+
component: component.displayName,
|
|
25
|
+
exportName: component.exportName,
|
|
26
|
+
file: component.file,
|
|
27
|
+
},
|
|
28
|
+
])
|
|
29
|
+
.toSorted((left, right) => left.file.localeCompare(right.file) || left.exportName.localeCompare(right.exportName));
|
|
30
|
+
const messages = [
|
|
31
|
+
formatNamespaceImportsMessage(namespaceImports, config),
|
|
32
|
+
formatExclusionsMessage(excludedKeys),
|
|
33
|
+
formatMissingComponentsMessage(missingComponents, config),
|
|
34
|
+
].filter((message) => message !== '');
|
|
35
|
+
return {
|
|
36
|
+
ok: messages.length === 0,
|
|
37
|
+
namespaceImports,
|
|
38
|
+
excludedKeys,
|
|
39
|
+
missingComponents,
|
|
40
|
+
messages,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TypeScriptModuleFacts } from 'no-mistakes';
|
|
2
|
+
import { type StoryCoverageConfig } from './options.mts';
|
|
3
|
+
export type ComponentExport = {
|
|
4
|
+
key: string;
|
|
5
|
+
file: string;
|
|
6
|
+
exportName: string;
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function exportKey(file: string, exportName: string): string;
|
|
10
|
+
export declare function componentExports(files: readonly string[], modules: ReadonlyMap<string, TypeScriptModuleFacts>, config: StoryCoverageConfig): ComponentExport[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { patternMatches } from "./options.mjs";
|
|
4
|
+
export function exportKey(file, exportName) {
|
|
5
|
+
return `${file}#${exportName}`;
|
|
6
|
+
}
|
|
7
|
+
export function componentExports(files, modules, config) {
|
|
8
|
+
const found = [];
|
|
9
|
+
for (const file of files) {
|
|
10
|
+
if (!isComponentFile(file, config))
|
|
11
|
+
continue;
|
|
12
|
+
if (!patternMatches(config.marker, readFileSync(join(config.root, file), 'utf8')))
|
|
13
|
+
continue;
|
|
14
|
+
const facts = modules.get(file);
|
|
15
|
+
if (!facts?.complete)
|
|
16
|
+
throw new Error(`Incomplete component module facts: ${file}`);
|
|
17
|
+
for (const item of facts.exports) {
|
|
18
|
+
if (item.specifier || item.typeOnly)
|
|
19
|
+
continue;
|
|
20
|
+
if (item.exported !== 'default' && !/^[A-Z][A-Za-z0-9]*$/.test(item.exported))
|
|
21
|
+
continue;
|
|
22
|
+
found.push({
|
|
23
|
+
key: exportKey(file, item.exported),
|
|
24
|
+
file,
|
|
25
|
+
exportName: item.exported,
|
|
26
|
+
displayName: item.exported === 'default' ? item.local || 'default' : item.exported,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return found;
|
|
31
|
+
}
|
|
32
|
+
function isComponentFile(file, config) {
|
|
33
|
+
if (!file.startsWith(config.componentRoot))
|
|
34
|
+
return false;
|
|
35
|
+
if (!config.componentExtensions.some((extension) => file.endsWith(extension)))
|
|
36
|
+
return false;
|
|
37
|
+
if (file.includes('/__tests__/') || file.includes('.test.'))
|
|
38
|
+
return false;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SourceModuleGraph } from '../source-module-graph/index.mts';
|
|
2
|
+
import { type StoryCoverageConfig } from './options.mts';
|
|
3
|
+
export type NamespaceComponentImport = {
|
|
4
|
+
file: string;
|
|
5
|
+
source: string;
|
|
6
|
+
local: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function reachableStoryFiles(files: readonly string[], graph: SourceModuleGraph, config: StoryCoverageConfig): string[];
|
|
9
|
+
export declare function coveredComponentKeys(storyFiles: readonly string[], graph: SourceModuleGraph, config: StoryCoverageConfig): Set<string>;
|
|
10
|
+
export declare function namespaceComponentImports(storyFiles: readonly string[], graph: SourceModuleGraph, config: StoryCoverageConfig): NamespaceComponentImport[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { patternMatches } from "./options.mjs";
|
|
2
|
+
import { exportKey } from "./components.mjs";
|
|
3
|
+
export function reachableStoryFiles(files, graph, config) {
|
|
4
|
+
const stories = files.filter((file) => file.startsWith(config.storyRoot) && patternMatches(config.storyFilePattern, file));
|
|
5
|
+
return graph
|
|
6
|
+
.reachableFrom(stories, { runtimeOnly: true })
|
|
7
|
+
.filter((file) => file.startsWith(config.storyRoot));
|
|
8
|
+
}
|
|
9
|
+
export function coveredComponentKeys(storyFiles, graph, config) {
|
|
10
|
+
const covered = new Set();
|
|
11
|
+
for (const file of storyFiles) {
|
|
12
|
+
for (const entry of graph.runtimeImports(file)) {
|
|
13
|
+
const resolved = graph.resolveSource(file, entry.specifier);
|
|
14
|
+
if (!resolved?.startsWith(config.componentRoot))
|
|
15
|
+
continue;
|
|
16
|
+
for (const binding of entry.bindings) {
|
|
17
|
+
if (binding.kind === 'namespace')
|
|
18
|
+
continue;
|
|
19
|
+
covered.add(exportKey(resolved, binding.imported));
|
|
20
|
+
const owner = graph.resolveExportOwner(resolved, binding.imported);
|
|
21
|
+
if (owner)
|
|
22
|
+
covered.add(exportKey(owner.file, owner.exportName));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return covered;
|
|
27
|
+
}
|
|
28
|
+
export function namespaceComponentImports(storyFiles, graph, config) {
|
|
29
|
+
const imports = [];
|
|
30
|
+
for (const file of storyFiles) {
|
|
31
|
+
for (const entry of graph.runtimeImports(file)) {
|
|
32
|
+
const resolved = graph.resolveSource(file, entry.specifier);
|
|
33
|
+
if (!resolved?.startsWith(config.componentRoot))
|
|
34
|
+
continue;
|
|
35
|
+
for (const binding of entry.bindings) {
|
|
36
|
+
if (binding.kind !== 'namespace')
|
|
37
|
+
continue;
|
|
38
|
+
imports.push({ file, source: entry.specifier, local: binding.local });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return imports;
|
|
43
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { analyzeStorySources } from './analyze.mts';
|
|
2
|
+
export type { StorySourceAnalysis } from './analyze.mts';
|
|
3
|
+
export { checkStoryCoverage } from './check.mts';
|
|
4
|
+
export type { StoryCoverageReport } from './check.mts';
|
|
5
|
+
export { componentExports, exportKey } from './components.mts';
|
|
6
|
+
export type { ComponentExport } from './components.mts';
|
|
7
|
+
export { coveredComponentKeys, namespaceComponentImports, reachableStoryFiles, } from './coverage.mts';
|
|
8
|
+
export type { NamespaceComponentImport } from './coverage.mts';
|
|
9
|
+
export { formatExclusionsMessage, formatMissingComponentsMessage, formatNamespaceImportsMessage, } from './messages.mts';
|
|
10
|
+
export type { MissingComponent } from './messages.mts';
|
|
11
|
+
export { storyCoverageConfig } from './options.mts';
|
|
12
|
+
export type { StoryCoverageConfig, StoryCoverageRequest } from './options.mts';
|
|
13
|
+
export { workspaceFiles } from './workspace.mts';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { analyzeStorySources } from "./analyze.mjs";
|
|
2
|
+
export { checkStoryCoverage } from "./check.mjs";
|
|
3
|
+
export { componentExports, exportKey } from "./components.mjs";
|
|
4
|
+
export { coveredComponentKeys, namespaceComponentImports, reachableStoryFiles, } from "./coverage.mjs";
|
|
5
|
+
export { formatExclusionsMessage, formatMissingComponentsMessage, formatNamespaceImportsMessage, } from "./messages.mjs";
|
|
6
|
+
export { storyCoverageConfig } from "./options.mjs";
|
|
7
|
+
export { workspaceFiles } from "./workspace.mjs";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { StoryCoverageConfig } from './options.mts';
|
|
2
|
+
import type { NamespaceComponentImport } from './coverage.mts';
|
|
3
|
+
export type MissingComponent = {
|
|
4
|
+
component: string;
|
|
5
|
+
exportName: string;
|
|
6
|
+
file: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function formatMissingComponentsMessage(missingComponents: readonly MissingComponent[], config: StoryCoverageConfig): string;
|
|
9
|
+
export declare function formatNamespaceImportsMessage(namespaceImports: readonly NamespaceComponentImport[], config: StoryCoverageConfig): string;
|
|
10
|
+
export declare function formatExclusionsMessage(excludedKeys: readonly string[]): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export function formatMissingComponentsMessage(missingComponents, config) {
|
|
2
|
+
if (missingComponents.length === 0)
|
|
3
|
+
return '';
|
|
4
|
+
const lines = [
|
|
5
|
+
`${missingComponents.length} component(s) matching the marker have no story coverage.`,
|
|
6
|
+
'',
|
|
7
|
+
`For each missing component, add a story under ${config.storyRoot} that imports and uses the component at runtime.`,
|
|
8
|
+
'',
|
|
9
|
+
`Use 'default' for default exports when matching the key reported below.`,
|
|
10
|
+
`The zero-exclusion ratchet rejects entries in ${config.exclusionsLabel}.`,
|
|
11
|
+
'',
|
|
12
|
+
'Missing components:',
|
|
13
|
+
];
|
|
14
|
+
for (const { component, exportName, file } of missingComponents) {
|
|
15
|
+
lines.push(` ${component} — ${file}#${exportName}`);
|
|
16
|
+
lines.push('');
|
|
17
|
+
}
|
|
18
|
+
return lines.join('\n');
|
|
19
|
+
}
|
|
20
|
+
export function formatNamespaceImportsMessage(namespaceImports, config) {
|
|
21
|
+
if (namespaceImports.length === 0)
|
|
22
|
+
return '';
|
|
23
|
+
const lines = [
|
|
24
|
+
`${namespaceImports.length} story file(s) use namespace imports (* as ...) from ${config.componentRoot} — individual component coverage cannot be tracked:`,
|
|
25
|
+
'',
|
|
26
|
+
];
|
|
27
|
+
for (const { file, source, local } of namespaceImports) {
|
|
28
|
+
lines.push(` ${file}: import * as ${local} from '${source}'`);
|
|
29
|
+
}
|
|
30
|
+
lines.push('');
|
|
31
|
+
lines.push('Fix: replace namespace imports with named imports for the specific components used.');
|
|
32
|
+
return lines.join('\n');
|
|
33
|
+
}
|
|
34
|
+
export function formatExclusionsMessage(excludedKeys) {
|
|
35
|
+
if (excludedKeys.length === 0)
|
|
36
|
+
return '';
|
|
37
|
+
return [
|
|
38
|
+
`${excludedKeys.length} component story exclusion(s) remain after the zero-exclusion ratchet:`,
|
|
39
|
+
...excludedKeys.map((key) => ` - ${key}`),
|
|
40
|
+
'Add direct story coverage instead of adding exclusions.',
|
|
41
|
+
].join('\n');
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type StoryCoverageRequest = {
|
|
2
|
+
root: string;
|
|
3
|
+
componentRoot: string;
|
|
4
|
+
storyRoot: string;
|
|
5
|
+
aliases?: Readonly<Record<string, string>>;
|
|
6
|
+
sourceExtensions: readonly string[];
|
|
7
|
+
componentExtensions: readonly string[];
|
|
8
|
+
marker: RegExp;
|
|
9
|
+
storyFilePattern: RegExp;
|
|
10
|
+
exclusions?: Readonly<Record<string, unknown>>;
|
|
11
|
+
exclusionsLabel?: string;
|
|
12
|
+
};
|
|
13
|
+
export type StoryCoverageConfig = {
|
|
14
|
+
root: string;
|
|
15
|
+
componentRoot: string;
|
|
16
|
+
storyRoot: string;
|
|
17
|
+
aliases: Readonly<Record<string, string>>;
|
|
18
|
+
sourceExtensions: readonly string[];
|
|
19
|
+
componentExtensions: readonly string[];
|
|
20
|
+
marker: RegExp;
|
|
21
|
+
storyFilePattern: RegExp;
|
|
22
|
+
exclusions: Readonly<Record<string, unknown>>;
|
|
23
|
+
exclusionsLabel: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function storyCoverageConfig(request: StoryCoverageRequest): StoryCoverageConfig;
|
|
26
|
+
/** Resets `lastIndex` so a global or sticky pattern can match more than once. */
|
|
27
|
+
export declare function patternMatches(pattern: RegExp, value: string): boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
export function storyCoverageConfig(request) {
|
|
3
|
+
const componentRoot = directoryRoot(request.componentRoot, 'componentRoot');
|
|
4
|
+
const storyRoot = directoryRoot(request.storyRoot, 'storyRoot');
|
|
5
|
+
if (componentRoot.startsWith(storyRoot) || storyRoot.startsWith(componentRoot)) {
|
|
6
|
+
throw new Error('componentRoot and storyRoot must not overlap');
|
|
7
|
+
}
|
|
8
|
+
requireExtensions(request.sourceExtensions, 'sourceExtensions');
|
|
9
|
+
requireExtensions(request.componentExtensions, 'componentExtensions');
|
|
10
|
+
if (request.exclusions !== undefined && !plainRecord(request.exclusions)) {
|
|
11
|
+
throw new Error('exclusions must be a plain object');
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
root: resolve(request.root),
|
|
15
|
+
componentRoot,
|
|
16
|
+
storyRoot,
|
|
17
|
+
aliases: request.aliases ?? {},
|
|
18
|
+
sourceExtensions: request.sourceExtensions,
|
|
19
|
+
componentExtensions: request.componentExtensions,
|
|
20
|
+
marker: request.marker,
|
|
21
|
+
storyFilePattern: request.storyFilePattern,
|
|
22
|
+
exclusions: request.exclusions ?? {},
|
|
23
|
+
exclusionsLabel: request.exclusionsLabel ?? 'the exclusions map',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** Resets `lastIndex` so a global or sticky pattern can match more than once. */
|
|
27
|
+
export function patternMatches(pattern, value) {
|
|
28
|
+
pattern.lastIndex = 0;
|
|
29
|
+
return pattern.test(value);
|
|
30
|
+
}
|
|
31
|
+
function directoryRoot(value, label) {
|
|
32
|
+
const normalized = value.replaceAll('\\', '/').replace(/^\.\//, '');
|
|
33
|
+
if (normalized.startsWith('/') ||
|
|
34
|
+
normalized.split('/').includes('..') ||
|
|
35
|
+
normalized === '' ||
|
|
36
|
+
normalized === '.') {
|
|
37
|
+
throw new Error(`${label} must be a relative directory inside the root`);
|
|
38
|
+
}
|
|
39
|
+
return normalized.endsWith('/') ? normalized : `${normalized}/`;
|
|
40
|
+
}
|
|
41
|
+
function requireExtensions(extensions, label) {
|
|
42
|
+
if (extensions.length === 0)
|
|
43
|
+
throw new Error(`${label} must not be empty`);
|
|
44
|
+
for (const extension of extensions) {
|
|
45
|
+
if (!extension.startsWith('.'))
|
|
46
|
+
throw new Error(`${label} entries must start with '.'`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function plainRecord(value) {
|
|
50
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
51
|
+
}
|