@vibe-agent-toolkit/utils 0.2.0-rc.1 → 0.2.0-rc.10
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 +69 -23
- package/dist/asset-reference.js +3 -11
- package/dist/asset-reference.js.map +1 -1
- package/dist/compare-code-units.d.ts +28 -0
- package/dist/compare-code-units.d.ts.map +1 -0
- package/dist/compare-code-units.js +33 -0
- package/dist/compare-code-units.js.map +1 -0
- package/dist/crawl-timing.d.ts +657 -0
- package/dist/crawl-timing.d.ts.map +1 -0
- package/dist/crawl-timing.js +765 -0
- package/dist/crawl-timing.js.map +1 -0
- package/dist/crawl.d.ts +2 -4
- package/dist/crawl.d.ts.map +1 -1
- package/dist/crawl.js +2 -4
- package/dist/crawl.js.map +1 -1
- package/dist/dirent-kind.d.ts +83 -0
- package/dist/dirent-kind.d.ts.map +1 -0
- package/dist/dirent-kind.js +129 -0
- package/dist/dirent-kind.js.map +1 -0
- package/dist/entrypoint.d.ts +54 -0
- package/dist/entrypoint.d.ts.map +1 -0
- package/dist/entrypoint.js +71 -0
- package/dist/entrypoint.js.map +1 -0
- package/dist/env-flag.d.ts +51 -0
- package/dist/env-flag.d.ts.map +1 -0
- package/dist/env-flag.js +62 -0
- package/dist/env-flag.js.map +1 -0
- package/dist/errors/errno.d.ts +51 -0
- package/dist/errors/errno.d.ts.map +1 -0
- package/dist/errors/errno.js +112 -0
- package/dist/errors/errno.js.map +1 -0
- package/dist/errors/vat-error.d.ts +60 -0
- package/dist/errors/vat-error.d.ts.map +1 -0
- package/dist/errors/vat-error.js +86 -0
- package/dist/errors/vat-error.js.map +1 -0
- package/dist/file-crawler.d.ts +60 -0
- package/dist/file-crawler.d.ts.map +1 -1
- package/dist/file-crawler.js +133 -29
- package/dist/file-crawler.js.map +1 -1
- package/dist/fs/file-hash.d.ts.map +1 -1
- package/dist/fs/file-hash.js +0 -1
- package/dist/fs/file-hash.js.map +1 -1
- package/dist/fs-utils.d.ts +422 -191
- package/dist/fs-utils.d.ts.map +1 -1
- package/dist/fs-utils.js +534 -204
- package/dist/fs-utils.js.map +1 -1
- package/dist/fs.d.ts +5 -2
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +9 -7
- package/dist/fs.js.map +1 -1
- package/dist/git-run.d.ts +167 -0
- package/dist/git-run.d.ts.map +1 -0
- package/dist/git-run.js +154 -0
- package/dist/git-run.js.map +1 -0
- package/dist/git-snapshot.d.ts +199 -0
- package/dist/git-snapshot.d.ts.map +1 -0
- package/dist/git-snapshot.js +250 -0
- package/dist/git-snapshot.js.map +1 -0
- package/dist/git-tracker.d.ts +166 -3
- package/dist/git-tracker.d.ts.map +1 -1
- package/dist/git-tracker.js +250 -22
- package/dist/git-tracker.js.map +1 -1
- package/dist/git-utils.d.ts +84 -1
- package/dist/git-utils.d.ts.map +1 -1
- package/dist/git-utils.js +208 -82
- package/dist/git-utils.js.map +1 -1
- package/dist/git.d.ts +13 -4
- package/dist/git.d.ts.map +1 -1
- package/dist/git.js +12 -4
- package/dist/git.js.map +1 -1
- package/dist/gitignore-checker.d.ts.map +1 -1
- package/dist/gitignore-checker.js +15 -6
- package/dist/gitignore-checker.js.map +1 -1
- package/dist/glob/glob-pattern.js +5 -5
- package/dist/glob/glob-pattern.js.map +1 -1
- package/dist/index.d.ts +32 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -50
- package/dist/index.js.map +1 -1
- package/dist/listing-refusal.d.ts +112 -0
- package/dist/listing-refusal.d.ts.map +1 -0
- package/dist/listing-refusal.js +105 -0
- package/dist/listing-refusal.js.map +1 -0
- package/dist/path-containment.d.ts +64 -0
- package/dist/path-containment.d.ts.map +1 -0
- package/dist/path-containment.js +111 -0
- package/dist/path-containment.js.map +1 -0
- package/dist/path-core.d.ts +113 -18
- package/dist/path-core.d.ts.map +1 -1
- package/dist/path-core.js +139 -23
- package/dist/path-core.js.map +1 -1
- package/dist/path-utils.d.ts.map +1 -1
- package/dist/path-utils.js +42 -47
- package/dist/path-utils.js.map +1 -1
- package/dist/path.d.ts +1 -1
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +1 -1
- package/dist/path.js.map +1 -1
- package/dist/process.d.ts +7 -0
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +7 -0
- package/dist/process.js.map +1 -1
- package/dist/project-utils.d.ts.map +1 -1
- package/dist/project-utils.js +15 -9
- package/dist/project-utils.js.map +1 -1
- package/dist/project.d.ts +7 -5
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +7 -5
- package/dist/project.js.map +1 -1
- package/dist/safe-exec.d.ts +40 -11
- package/dist/safe-exec.d.ts.map +1 -1
- package/dist/safe-exec.js +111 -25
- package/dist/safe-exec.js.map +1 -1
- package/dist/skill-targets.d.ts +2 -2
- package/dist/skill-targets.js +2 -2
- package/dist/skill-test/auth-resolver.d.ts +10 -2
- package/dist/skill-test/auth-resolver.d.ts.map +1 -1
- package/dist/skill-test/auth-resolver.js +26 -11
- package/dist/skill-test/auth-resolver.js.map +1 -1
- package/dist/skill-test/index.d.ts +1 -1
- package/dist/skill-test/index.d.ts.map +1 -1
- package/dist/skill-test/index.js +1 -1
- package/dist/skill-test/index.js.map +1 -1
- package/dist/skill-test/spawn-claude.d.ts +30 -1
- package/dist/skill-test/spawn-claude.d.ts.map +1 -1
- package/dist/skill-test/spawn-claude.js +71 -5
- package/dist/skill-test/spawn-claude.js.map +1 -1
- package/dist/skill-test/transcript.d.ts +41 -2
- package/dist/skill-test/transcript.d.ts.map +1 -1
- package/dist/skill-test/transcript.js +55 -10
- package/dist/skill-test/transcript.js.map +1 -1
- package/dist/spawn-hardened.js +0 -1
- package/dist/spawn-hardened.js.map +1 -1
- package/dist/stdio-blocking.js +13 -14
- package/dist/stdio-blocking.js.map +1 -1
- package/dist/test-helpers.d.ts +135 -100
- package/dist/test-helpers.d.ts.map +1 -1
- package/dist/test-helpers.js +224 -146
- package/dist/test-helpers.js.map +1 -1
- package/dist/testing/executables.d.ts +32 -0
- package/dist/testing/executables.d.ts.map +1 -0
- package/dist/testing/executables.js +70 -0
- package/dist/testing/executables.js.map +1 -0
- package/dist/testing/hostile-tree.d.ts +79 -0
- package/dist/testing/hostile-tree.d.ts.map +1 -0
- package/dist/testing/hostile-tree.js +164 -0
- package/dist/testing/hostile-tree.js.map +1 -0
- package/dist/testing/platform-gates.d.ts +31 -0
- package/dist/testing/platform-gates.d.ts.map +1 -0
- package/dist/testing/platform-gates.js +31 -0
- package/dist/testing/platform-gates.js.map +1 -0
- package/dist/testing/temp-dir.d.ts +255 -0
- package/dist/testing/temp-dir.d.ts.map +1 -0
- package/dist/testing/temp-dir.js +363 -0
- package/dist/testing/temp-dir.js.map +1 -0
- package/dist/testing.d.ts +94 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +119 -3
- package/dist/testing.js.map +1 -1
- package/dist/text-content.d.ts +197 -0
- package/dist/text-content.d.ts.map +1 -0
- package/dist/text-content.js +354 -0
- package/dist/text-content.js.map +1 -0
- package/dist/text-file.d.ts +45 -0
- package/dist/text-file.d.ts.map +1 -0
- package/dist/text-file.js +51 -0
- package/dist/text-file.js.map +1 -0
- package/dist/text.d.ts +16 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +16 -0
- package/dist/text.js.map +1 -0
- package/dist/timing-dump.d.ts +136 -0
- package/dist/timing-dump.d.ts.map +1 -0
- package/dist/timing-dump.js +229 -0
- package/dist/timing-dump.js.map +1 -0
- package/dist/windows-shell.d.ts +0 -1
- package/dist/windows-shell.d.ts.map +1 -1
- package/dist/windows-shell.js +0 -1
- package/dist/windows-shell.js.map +1 -1
- package/dist/zod-introspection.js +2 -2
- package/dist/zod-introspection.js.map +1 -1
- package/eslint/README.md +223 -49
- package/eslint/index.cjs +111 -97
- package/eslint/index.d.cts +16 -6
- package/eslint/rules/callee-name.cjs +23 -0
- package/eslint/rules/commands-import-boundary.cjs +148 -0
- package/eslint/rules/dead-import.cjs +1 -1
- package/eslint/rules/dirent-type-needs-symlink-check.cjs +282 -0
- package/eslint/rules/eslint-rule-factory.cjs +5 -2
- package/eslint/rules/exempt-path-matcher.cjs +2 -1
- package/eslint/rules/explicit-zod-strictness.cjs +120 -0
- package/eslint/rules/no-bare-dynamic-import-path.cjs +5 -1
- package/eslint/rules/no-bare-executable-spawn.cjs +70 -0
- package/eslint/rules/no-bare-symlink-in-tests.cjs +213 -0
- package/eslint/rules/no-blind-catch.cjs +171 -0
- package/eslint/rules/no-child-process-execSync.cjs +8 -0
- package/eslint/rules/no-decaying-referent.cjs +217 -0
- package/eslint/rules/no-dotdot-containment.cjs +160 -0
- package/eslint/rules/no-file-url-string-concat.cjs +4 -1
- package/eslint/rules/no-fragile-entrypoint-guard.cjs +228 -0
- package/eslint/rules/no-fs-mkdirSync.cjs +8 -0
- package/eslint/rules/no-fs-promises-cp.cjs +7 -0
- package/eslint/rules/no-fs-realpathSync.cjs +8 -0
- package/eslint/rules/no-hardcoded-path-split.cjs +29 -18
- package/eslint/rules/no-io-in-unit-tier.cjs +129 -0
- package/eslint/rules/no-literal-process-exit.cjs +129 -0
- package/eslint/rules/no-manual-path-normalize.cjs +136 -107
- package/eslint/rules/no-os-tmpdir.cjs +8 -0
- package/eslint/rules/no-path-operations-in-comparisons.cjs +7 -2
- package/eslint/rules/no-path-sep-in-strings.cjs +7 -2
- package/eslint/rules/no-path-startswith.cjs +7 -2
- package/eslint/rules/no-process-exit-in-phase.cjs +127 -0
- package/eslint/rules/no-raw-node-path.cjs +563 -0
- package/eslint/rules/no-raw-text-decode.cjs +305 -0
- package/eslint/rules/no-registry-count-pin.cjs +255 -0
- package/eslint/rules/no-self-package-import.cjs +168 -0
- package/eslint/rules/no-test-scoped-functions.cjs +10 -3
- package/eslint/rules/no-unix-shell-commands.cjs +6 -2
- package/eslint/rules/no-unsafe-root-join.cjs +23 -2
- package/eslint/rules/no-url-pathname-for-fs.cjs +5 -1
- package/eslint/rules/no-version-literal.cjs +151 -0
- package/eslint/rules/prefer-startswith-over-regex.cjs +9 -0
- package/eslint/rules/require-justified-skip.cjs +8 -2
- package/eslint/rules/safe-import.cjs +1 -1
- package/package.json +16 -16
- package/dist/link-auth/build-headers.d.ts +0 -34
- package/dist/link-auth/build-headers.d.ts.map +0 -1
- package/dist/link-auth/build-headers.js +0 -58
- package/dist/link-auth/build-headers.js.map +0 -1
- package/dist/link-auth/expand-macro.d.ts +0 -38
- package/dist/link-auth/expand-macro.d.ts.map +0 -1
- package/dist/link-auth/expand-macro.js +0 -133
- package/dist/link-auth/expand-macro.js.map +0 -1
- package/dist/link-auth/macros.yaml +0 -50
- package/dist/link-auth/resolve-token.d.ts +0 -83
- package/dist/link-auth/resolve-token.d.ts.map +0 -1
- package/dist/link-auth/resolve-token.js +0 -101
- package/dist/link-auth/resolve-token.js.map +0 -1
- package/dist/link-auth/resolve.d.ts +0 -102
- package/dist/link-auth/resolve.d.ts.map +0 -1
- package/dist/link-auth/resolve.js +0 -66
- package/dist/link-auth/resolve.js.map +0 -1
- package/dist/link-auth/rewrite.d.ts +0 -52
- package/dist/link-auth/rewrite.d.ts.map +0 -1
- package/dist/link-auth/rewrite.js +0 -102
- package/dist/link-auth/rewrite.js.map +0 -1
- package/dist/link-auth/select-provider.d.ts +0 -30
- package/dist/link-auth/select-provider.d.ts.map +0 -1
- package/dist/link-auth/select-provider.js +0 -55
- package/dist/link-auth/select-provider.js.map +0 -1
- package/dist/link-auth/template.d.ts +0 -40
- package/dist/link-auth/template.d.ts.map +0 -1
- package/dist/link-auth/template.js +0 -89
- package/dist/link-auth/template.js.map +0 -1
- package/dist/link-auth/transforms.d.ts +0 -46
- package/dist/link-auth/transforms.d.ts.map +0 -1
- package/dist/link-auth/transforms.js +0 -52
- package/dist/link-auth/transforms.js.map +0 -1
- package/dist/template-entry.d.ts +0 -10
- package/dist/template-entry.d.ts.map +0 -1
- package/dist/template-entry.js +0 -10
- package/dist/template-entry.js.map +0 -1
- package/dist/template.d.ts +0 -7
- package/dist/template.d.ts.map +0 -1
- package/dist/template.js +0 -18
- package/dist/template.js.map +0 -1
- package/eslint/rules/no-path-join.cjs +0 -14
- package/eslint/rules/no-path-relative.cjs +0 -14
- package/eslint/rules/no-path-resolve.cjs +0 -14
- package/eslint/rules/path-function-rule-factory.cjs +0 -496
package/dist/test-helpers.d.ts
CHANGED
|
@@ -1,118 +1,153 @@
|
|
|
1
|
+
declare const symlinkCapabilityBrand: unique symbol;
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @returns Absolute path to the created directory
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* // Create isolated database directory for system tests
|
|
15
|
-
* const dbPath = getTestOutputDir('rag-lancedb', 'system', 'databases', 'test-db');
|
|
16
|
-
* // Result: packages/rag-lancedb/.test-output/system/20260105-143022-abc123/databases/test-db
|
|
17
|
-
*
|
|
18
|
-
* // Create temporary file directory for integration tests
|
|
19
|
-
* const tempDir = getTestOutputDir('agent-skills', 'integration', 'temp-files');
|
|
20
|
-
* // Result: packages/agent-skills/.test-output/integration/20260105-143022-def456/temp-files
|
|
21
|
-
* ```
|
|
3
|
+
* Proof that this process can create filesystem symlinks.
|
|
4
|
+
*
|
|
5
|
+
* The only way to obtain one is {@link symlinkCapability}, and it exists at
|
|
6
|
+
* all only when a real probe already succeeded — so a function that requires
|
|
7
|
+
* this as a parameter cannot be reached by code that skipped the check. That
|
|
8
|
+
* is the point of branding it rather than passing a `boolean`: forgetting the
|
|
9
|
+
* check becomes a type error instead of a runtime `EPERM` on a machine you
|
|
10
|
+
* don't control.
|
|
22
11
|
*/
|
|
23
|
-
export
|
|
12
|
+
export type SymlinkCapability = {
|
|
13
|
+
readonly [symlinkCapabilityBrand]: true;
|
|
14
|
+
};
|
|
24
15
|
/**
|
|
25
|
-
*
|
|
26
|
-
* Useful for cleanup operations that need to remove all test output
|
|
16
|
+
* Whether this PROCESS can create symlinks — probed once and memoized.
|
|
27
17
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
18
|
+
* On Windows, `symlink()` needs either Developer Mode or
|
|
19
|
+
* `SeCreateSymbolicLinkPrivilege`. That privilege lives on the process's
|
|
20
|
+
* security token, not on any one directory: it cannot change between calls
|
|
21
|
+
* within a single run, so probing it once and reusing the result is a
|
|
22
|
+
* memoization, not a shortcut that risks a stale answer. (A filesystem that
|
|
23
|
+
* itself has no symlinks — some network shares, some FAT variants — answers
|
|
24
|
+
* `ENOTSUP` and is read as the same "no"; every fixture in this repo creates
|
|
25
|
+
* its roots under {@link normalizedTmpdir}, so it never arises here.)
|
|
26
|
+
*
|
|
27
|
+
* Because the answer is memoized for the whole process, what reads as "no"
|
|
28
|
+
* matters more than usual: a `null` here silently `skip()`s every symlink test
|
|
29
|
+
* for the rest of the run. So ONLY {@link SYMLINK_UNSUPPORTED_ERRNOS} is a
|
|
30
|
+
* no. A tmpdir that is unwritable or missing, or a bug, is not an answer about
|
|
31
|
+
* symlinks at all and stays loud rather than becoming a process-wide skip for
|
|
32
|
+
* a reason nothing reported.
|
|
33
|
+
*
|
|
34
|
+
* Fixtures that depend on symlinks must ask rather than assume — and, having
|
|
35
|
+
* asked, must SAY they skipped. A symlink case that silently no-ops reads as
|
|
36
|
+
* a passing test for a property nobody exercised.
|
|
37
|
+
*
|
|
38
|
+
* @returns A {@link SymlinkCapability} token when this process can create
|
|
39
|
+
* symlinks, else `null`. Route the `null` case through vitest's `skip()`
|
|
40
|
+
* rather than a plain `return`, so the skip is visible in the report.
|
|
36
41
|
*/
|
|
37
|
-
export declare function
|
|
42
|
+
export declare function symlinkCapability(): SymlinkCapability | null;
|
|
38
43
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* beforeEach(suite.beforeEach);
|
|
44
|
+
* Create a symlink — the one sanctioned call site for `fs.symlinkSync` in
|
|
45
|
+
* test code. Requires a {@link SymlinkCapability}, which only
|
|
46
|
+
* {@link symlinkCapability} can mint, so a test cannot reach the real
|
|
47
|
+
* syscall without first proving (or explicitly bypassing via `skip()`) that
|
|
48
|
+
* this host supports it.
|
|
49
|
+
*
|
|
50
|
+
* @param _cap - Proof from {@link symlinkCapability} that this host can create symlinks
|
|
51
|
+
* @param target - The existing path the new link should point at
|
|
52
|
+
* @param path - Where to create the link
|
|
53
|
+
* @param type - Windows-only link-type hint (`'file'` \| `'dir'` \| `'junction'`); ignored on POSIX
|
|
54
|
+
*/
|
|
55
|
+
export declare function createSymlink(_cap: SymlinkCapability, target: string, path: string, type?: 'dir' | 'file' | 'junction'): void;
|
|
56
|
+
/**
|
|
57
|
+
* The async counterpart of {@link createSymlink}, for fixtures already using
|
|
58
|
+
* `node:fs/promises`. Same capability requirement, same reasoning.
|
|
55
59
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
60
|
+
* @param _cap - Proof from {@link symlinkCapability} that this host can create symlinks
|
|
61
|
+
* @param target - The existing path the new link should point at
|
|
62
|
+
* @param path - Where to create the link
|
|
63
|
+
* @param type - Windows-only link-type hint (`'file'` \| `'dir'` \| `'junction'`); ignored on POSIX
|
|
62
64
|
*/
|
|
63
|
-
export declare function
|
|
64
|
-
beforeAll: () => Promise<void>;
|
|
65
|
-
afterAll: () => Promise<void>;
|
|
66
|
-
beforeEach: () => Promise<void>;
|
|
67
|
-
afterEach: () => Promise<void>;
|
|
68
|
-
getTempDir: () => string;
|
|
69
|
-
};
|
|
65
|
+
export declare function createSymlinkAsync(_cap: SymlinkCapability, target: string, path: string, type?: 'dir' | 'file' | 'junction'): Promise<void>;
|
|
70
66
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* with subdirectories for each test. This is 3-5x faster on Windows
|
|
74
|
-
* than creating a new mkdtemp for each test.
|
|
67
|
+
* The variables git exports into a hook, which a fixture must clear before it
|
|
68
|
+
* can fabricate its own.
|
|
75
69
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
70
|
+
* These are the ones git sets *for* you. Deliberately **not** the operator's own
|
|
71
|
+
* `GIT_CONFIG_COUNT`/`KEY_n`/`VALUE_n`/`GLOBAL`/`SYSTEM` channel — a test may be
|
|
72
|
+
* using that on purpose to point a clone at a local path, and clearing it sends
|
|
73
|
+
* the clone to the network instead.
|
|
74
|
+
*/
|
|
75
|
+
export declare const INHERITED_GIT_ENV: readonly ["GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_CEILING_DIRECTORIES", "GIT_COMMON_DIR", "GIT_CONFIG_PARAMETERS", "GIT_DIR", "GIT_DISCOVERY_ACROSS_FILESYSTEM", "GIT_GRAFT_FILE", "GIT_INDEX_FILE", "GIT_INDEX_VERSION", "GIT_NAMESPACE", "GIT_NOTES_REF", "GIT_OBJECT_DIRECTORY", "GIT_PREFIX", "GIT_SHALLOW_FILE", "GIT_WORK_TREE"];
|
|
76
|
+
/**
|
|
77
|
+
* Remove every inherited git redirection from `process.env`, and hand back the
|
|
78
|
+
* undo.
|
|
79
|
+
*
|
|
80
|
+
* A test that fabricates a hook environment has to start from a known-clean one,
|
|
81
|
+
* or it inherits whatever the *outer* runner exported and can no longer tell its
|
|
82
|
+
* own fixture apart from the ambient state — it then passes or fails for reasons
|
|
83
|
+
* it never set up. Restoring afterwards matters just as much: these are
|
|
84
|
+
* process-global, so a test that leaks `GIT_DIR` silently redirects every later
|
|
85
|
+
* test sharing the worker.
|
|
86
|
+
*
|
|
87
|
+
* ⚠️ **The key list is restated here on purpose, not by oversight.** Deriving it
|
|
88
|
+
* from `@vibe-validate/git`'s `stripGitEnv()` would be tidier, and it is exactly
|
|
89
|
+
* what this function did for one revision — but this module is the `./testing`
|
|
90
|
+
* subpath, which `subpath-purity.test.ts` pins as reaching **no third-party
|
|
91
|
+
* package at all** so it stays importable with zero dependencies installed. One
|
|
92
|
+
* import cost that property. The drift risk the derivation was avoiding is
|
|
93
|
+
* handled instead by {@link "../test/test-helpers-git-env.test".default}, which
|
|
94
|
+
* asserts this list equals what the shipped scrub removes.
|
|
95
|
+
*
|
|
96
|
+
* @returns A function restoring every variable to its prior value, putting back
|
|
97
|
+
* "was not set" as unset rather than as an empty string
|
|
78
98
|
*
|
|
79
99
|
* @example
|
|
80
100
|
* ```typescript
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* beforeAll(suite.beforeAll);
|
|
85
|
-
* afterAll(suite.afterAll);
|
|
86
|
-
* beforeEach(suite.beforeEach);
|
|
87
|
-
*
|
|
88
|
-
* it('test 1', () => {
|
|
89
|
-
* const tempDir = suite.getTempDir();
|
|
90
|
-
* // Use tempDir...
|
|
91
|
-
* });
|
|
92
|
-
* });
|
|
101
|
+
* let restoreGitEnv: () => void;
|
|
102
|
+
* beforeEach(() => { restoreGitEnv = detachGitEnv(); });
|
|
103
|
+
* afterEach(() => { restoreGitEnv(); });
|
|
93
104
|
* ```
|
|
94
105
|
*/
|
|
95
|
-
export declare function
|
|
96
|
-
beforeAll: () => void;
|
|
97
|
-
afterAll: () => void;
|
|
98
|
-
beforeEach: () => void;
|
|
99
|
-
afterEach: () => void;
|
|
100
|
-
getTempDir: () => string;
|
|
101
|
-
};
|
|
106
|
+
export declare function detachGitEnv(): () => void;
|
|
102
107
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
108
|
+
* The errno-shaped error a refused `fs` call throws: a message, the `code`,
|
|
109
|
+
* and the `syscall`, exactly as Node shapes one.
|
|
110
|
+
*/
|
|
111
|
+
export declare function errnoError(code: string, syscall: string, target: string): NodeJS.ErrnoException;
|
|
112
|
+
/** The sync `node:fs` calls a refusal can be injected into. */
|
|
113
|
+
export type RefusableSyncFsMethod = 'readdirSync' | 'readFileSync' | 'statSync' | 'lstatSync' | 'realpathSync' | 'renameSync' | 'rmSync' | 'unlinkSync';
|
|
114
|
+
/** The `node:fs/promises` calls a refusal can be injected into. */
|
|
115
|
+
export type RefusableAsyncFsMethod = 'readdir' | 'readFile' | 'stat' | 'lstat' | 'access';
|
|
116
|
+
/**
|
|
117
|
+
* Make `fs[method]` throw `code` for exactly `targetPath` until the returned
|
|
118
|
+
* restore is called; every other path, and every other method, stays real.
|
|
119
|
+
*
|
|
120
|
+
* A patch rather than a `chmod`: `chmod` reaches one errno (`EACCES`), only
|
|
121
|
+
* where POSIX modes bind, and not as root — and the property under test is
|
|
122
|
+
* "any refusal that is not an absence", so `EACCES`, `ELOOP`, `EMFILE` must all
|
|
123
|
+
* be reachable. What a walk under test meets is ONE refused call inside an
|
|
124
|
+
* otherwise ordinary tree; a walk that gave up entirely would pass a test where
|
|
125
|
+
* everything was refused.
|
|
126
|
+
*
|
|
127
|
+
* Lives in the shipped helpers because consumers in five packages each need to
|
|
128
|
+
* refuse a call, and the duplication gate refuses five copies.
|
|
129
|
+
*/
|
|
130
|
+
export declare function refuseSyncFs(method: RefusableSyncFsMethod, targetPath: string, code: string): () => void;
|
|
131
|
+
/**
|
|
132
|
+
* `fs/promises[method]` rejects with `code` for exactly `targetPath` until the
|
|
133
|
+
* returned restore is called; every other path, and every other method, is real.
|
|
134
|
+
*/
|
|
135
|
+
export declare function refuseAsyncFs(method: RefusableAsyncFsMethod, targetPath: string, code: string): () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Run `body` while `fs[method]` throws `code` for exactly `targetPath`; the
|
|
138
|
+
* patch is lifted however `body` exits. See {@link refuseSyncFs}.
|
|
139
|
+
*/
|
|
140
|
+
export declare function withSyncFsRefused<T>(method: RefusableSyncFsMethod, targetPath: string, code: string, body: () => T | Promise<T>): Promise<T>;
|
|
141
|
+
/**
|
|
142
|
+
* Run `body` with `fs.readdirSync` of exactly `directory` throwing an error
|
|
143
|
+
* carrying errno `code`. The listing case of {@link withSyncFsRefused}, named
|
|
144
|
+
* because refusing a LISTING is the question the crawler's consumers ask.
|
|
145
|
+
*
|
|
146
|
+
* @param directory - Absolute path of the one directory to refuse
|
|
147
|
+
* @param code - The errno to reject with
|
|
148
|
+
* @param body - Runs while the refusal is in force; may be async
|
|
149
|
+
* @returns Whatever `body` returned
|
|
116
150
|
*/
|
|
117
|
-
export declare function
|
|
151
|
+
export declare function withReaddirSyncRefused<T>(directory: string, code: string, body: () => T | Promise<T>): Promise<T>;
|
|
152
|
+
export {};
|
|
118
153
|
//# sourceMappingURL=test-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../src/test-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-helpers.d.ts","sourceRoot":"","sources":["../src/test-helpers.ts"],"names":[],"mappings":"AAQA,OAAO,CAAC,MAAM,sBAAsB,EAAE,OAAO,MAAM,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,CAAC,sBAAsB,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAe5E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,GAAG,IAAI,CAwB5D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GACjC,IAAI,CAEN;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,UAAU,GACjC,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,yUAgBpB,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,IAAI,MAAM,IAAI,CAoBzC;AAGD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,cAAc,CAE/F;AAED,+DAA+D;AAC/D,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,cAAc,GACd,YAAY,GACZ,QAAQ,GACR,YAAY,CAAC;AAEjB,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAiB1F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,IAAI,CAQxG;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,IAAI,CAQ1G;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,MAAM,EAAE,qBAAqB,EAC7B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAOZ;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
|