@visulima/vis 1.0.0-alpha.5 → 1.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +157 -81
- package/README.md +144 -14
- package/dist/ai-analysis.d.ts +3 -17
- package/dist/ai-cache.d.ts +1 -1
- package/dist/ai-types.d.ts +16 -0
- package/dist/bin.js +352 -221
- package/dist/cache-directory.d.ts +73 -0
- package/dist/codeowners.d.ts +30 -0
- package/dist/commands/action-graph.d.ts +8 -0
- package/dist/commands/audit.d.ts +3 -3
- package/dist/commands/cache.d.ts +86 -0
- package/dist/commands/ci.d.ts +19 -0
- package/dist/commands/docker.d.ts +22 -0
- package/dist/commands/generate.d.ts +10 -0
- package/dist/commands/ignore-helpers.d.ts +157 -0
- package/dist/commands/ignore.d.ts +17 -0
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/list.d.ts +3 -0
- package/dist/commands/migrate/backup.d.ts +8 -0
- package/dist/commands/migrate/constants.d.ts +6 -2
- package/dist/commands/migrate/gitleaks.d.ts +29 -0
- package/dist/commands/migrate/json.d.ts +4 -2
- package/dist/commands/migrate/kingfisher.d.ts +14 -0
- package/dist/commands/migrate/moon.d.ts +5 -0
- package/dist/commands/migrate/nano-staged.d.ts +30 -0
- package/dist/commands/migrate/nx.d.ts +12 -0
- package/dist/commands/migrate/prompt.d.ts +2 -0
- package/dist/commands/migrate/secretlint.d.ts +14 -0
- package/dist/commands/migrate/shared.d.ts +29 -0
- package/dist/commands/migrate/turborepo.d.ts +11 -0
- package/dist/commands/migrate/types.d.ts +8 -1
- package/dist/commands/migrate/verify.d.ts +12 -0
- package/dist/commands/run.d.ts +13 -0
- package/dist/commands/sbom.d.ts +10 -0
- package/dist/commands/secrets.d.ts +3 -0
- package/dist/commands/staged.d.ts +7 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/sync.d.ts +16 -0
- package/dist/commands/task-why.d.ts +3 -0
- package/dist/config.d.ts +17 -2
- package/dist/config.js +1 -1
- package/dist/docker.d.ts +73 -0
- package/dist/flakiness.d.ts +40 -0
- package/dist/generate/discover.d.ts +29 -0
- package/dist/generate/index.d.ts +32 -0
- package/dist/generate/index.js +1 -0
- package/dist/generate/loader.d.ts +15 -0
- package/dist/generate/moon-adapter/filename-interp.d.ts +42 -0
- package/dist/generate/moon-adapter/filters.d.ts +22 -0
- package/dist/generate/moon-adapter/frontmatter.d.ts +39 -0
- package/dist/generate/moon-adapter/index.d.ts +19 -0
- package/dist/generate/moon-adapter/tera-subset.d.ts +85 -0
- package/dist/generate/moon-adapter/util.d.ts +14 -0
- package/dist/generate/prompts.d.ts +25 -0
- package/dist/generate/remote.d.ts +43 -0
- package/dist/generate/runner.d.ts +37 -0
- package/dist/generate/types.d.ts +152 -0
- package/dist/hooks.d.ts +118 -0
- package/dist/native-binding.d.ts +8 -1
- package/dist/packem_chunks/index.js +7 -0
- package/dist/packem_chunks/loader.js +1 -0
- package/dist/packem_shared/otelPlugin-CJLkguJ8.js +1 -0
- package/dist/plugins/otel.d.ts +63 -0
- package/dist/pm-runner.d.ts +24 -3
- package/dist/run-report.d.ts +40 -0
- package/dist/runtime-check.d.ts +27 -0
- package/dist/sbom/cyclonedx.d.ts +39 -0
- package/dist/sbom/installed-package.d.ts +49 -0
- package/dist/sbom/license.d.ts +31 -0
- package/dist/sbom/lockfile.d.ts +34 -0
- package/dist/sbom/purl.d.ts +25 -0
- package/dist/sbom/resolve-specifier.d.ts +24 -0
- package/dist/sbom/types.d.ts +196 -0
- package/dist/secrets/baseline.d.ts +20 -0
- package/dist/secrets/format.d.ts +14 -0
- package/dist/secrets/git.d.ts +6 -0
- package/dist/secrets/spinner.d.ts +9 -0
- package/dist/selectors.d.ts +81 -0
- package/dist/shell-history.d.ts +16 -0
- package/dist/staged/cli-parse.d.ts +18 -0
- package/dist/staged/config.d.ts +14 -0
- package/dist/staged/errors/apply-empty-commit-error.d.ts +4 -0
- package/dist/staged/errors/config-error.d.ts +4 -0
- package/dist/staged/errors/get-backup-stash-error.d.ts +4 -0
- package/dist/staged/errors/git-error.d.ts +6 -0
- package/dist/staged/errors/index.d.ts +12 -0
- package/dist/staged/errors/restore-original-state-error.d.ts +4 -0
- package/dist/staged/errors/staged-error.d.ts +8 -0
- package/dist/staged/errors/task-error.d.ts +6 -0
- package/dist/staged/git/diff.d.ts +76 -0
- package/dist/staged/git/exec.d.ts +43 -0
- package/dist/staged/git/index.d.ts +77 -0
- package/dist/staged/git/stash.d.ts +37 -0
- package/dist/staged/index.d.ts +13 -0
- package/dist/staged/match.d.ts +12 -0
- package/dist/staged/renderer/index.d.ts +9 -0
- package/dist/staged/renderer/ink/index.d.ts +4 -0
- package/dist/staged/renderer/plain.d.ts +12 -0
- package/dist/staged/tasks/build.d.ts +13 -0
- package/dist/staged/tasks/exec.d.ts +56 -0
- package/dist/staged/tasks/run.d.ts +26 -0
- package/dist/staged/types.d.ts +173 -0
- package/dist/target-discovery.d.ts +59 -0
- package/dist/target-options.d.ts +261 -0
- package/dist/tui/components/OutputPanel.d.ts +2 -1
- package/dist/tui/components/TaskListPanel.d.ts +1 -1
- package/dist/tui/components/TaskStore.d.ts +1 -1
- package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +1 -1
- package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +1 -1
- package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +1 -1
- package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +1 -1
- package/dist/tui/components/devcontainer/types.d.ts +4 -4
- package/dist/tui/components/graph/GraphStore.d.ts +1 -1
- package/dist/tui/components/graph/ProjectDetailPanel.d.ts +1 -1
- package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +1 -1
- package/dist/tui/components/optimize/OptimizeStore.d.ts +1 -1
- package/dist/tui/components/update/PackageDetailPanel.d.ts +1 -1
- package/dist/tui/components/update/PackageListPanel.d.ts +2 -2
- package/dist/tui/components/update/UpdateStore.d.ts +1 -1
- package/dist/tui/components/update/VisUpdateApp.d.ts +3 -3
- package/dist/tui/dynamic-life-cycle.d.ts +2 -1
- package/dist/tui/static-life-cycle.d.ts +7 -1
- package/dist/watch.d.ts +65 -0
- package/dist/workspace.d.ts +326 -6
- package/index.js +727 -554
- package/package.json +38 -32
- package/schemas/project.schema.json +344 -0
- package/schemas/vis-config.schema.json +331 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
declare const DEFAULT_DIFF_FILTER = "ACMR";
|
|
2
|
+
/**
|
|
3
|
+
* Lists paths staged as "intent to add" (`git add -N`). These entries crash
|
|
4
|
+
* `git stash create` with `Entry 'path' not uptodate. Cannot merge.`
|
|
5
|
+
* We detect them via `git diff-files --raw`, which emits an all-zero new sha
|
|
6
|
+
* with status `A` for intent-to-add entries (regular worktree-vs-index diffs
|
|
7
|
+
* show a real blob sha for unstaged edits).
|
|
8
|
+
*
|
|
9
|
+
* The caller temporarily unstages them before the backup stash runs, and
|
|
10
|
+
* restores the intent-to-add state in cleanup. See lint-staged issue #990.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getIntentToAddPaths: (cwd: string) => Promise<string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Lists untracked, non-ignored files in the working tree. Used by
|
|
15
|
+
* `--autoStage` to pick up files a task created during the run.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getUntrackedFiles: (cwd: string) => Promise<string[]>;
|
|
18
|
+
/** Removes the listed paths from the index (`git rm --cached`), leaving the on-disk content alone. */
|
|
19
|
+
export declare const removeFromIndex: (paths: ReadonlyArray<string>, options: {
|
|
20
|
+
readonly cwd: string;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Lists files captured by the current diff — by default, staged files
|
|
24
|
+
* matching the `ACMR` filter. When `diff` is set the range overrides
|
|
25
|
+
* `--staged` (matching lint-staged's `--diff` CLI flag).
|
|
26
|
+
*/
|
|
27
|
+
export declare const getFiles: (options: {
|
|
28
|
+
readonly cwd: string;
|
|
29
|
+
readonly diff?: string;
|
|
30
|
+
readonly diffFilter?: string;
|
|
31
|
+
readonly workTree?: string;
|
|
32
|
+
}) => Promise<string[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Captures the unstaged delta for a list of paths as a git patch. The
|
|
35
|
+
* resulting buffer can be re-applied with `git apply` after tasks run.
|
|
36
|
+
* Returns `null` when there are no unstaged changes for any of the paths.
|
|
37
|
+
*
|
|
38
|
+
* Splits `paths` into batches to stay under `ARG_MAX` on large staged
|
|
39
|
+
* sets. Patch fragments from each batch concatenate cleanly because
|
|
40
|
+
* every fragment starts with its own `diff --git` header.
|
|
41
|
+
*
|
|
42
|
+
* Appends a trailing newline when git's stdout doesn't end in one —
|
|
43
|
+
* `git apply` rejects patches without a final newline as "corrupt patch
|
|
44
|
+
* at line N" even with `--recount --unidiff-zero`.
|
|
45
|
+
*/
|
|
46
|
+
export declare const capturePatch: (paths: ReadonlyArray<string>, options: {
|
|
47
|
+
readonly cwd: string;
|
|
48
|
+
}) => Promise<Buffer | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the worktree-relative paths that have both staged and unstaged modifications.
|
|
51
|
+
*
|
|
52
|
+
* `git status --porcelain=v1 -z` uses NUL record separators and splits rename/copy entries
|
|
53
|
+
* across two records: the status+new-path record, then a second record holding the old path.
|
|
54
|
+
* We walk the records, consuming the trailing old-path record for R/C statuses so they
|
|
55
|
+
* don't leak into the next iteration as a malformed status line.
|
|
56
|
+
*/
|
|
57
|
+
export declare const getPartiallyStagedFiles: (cwd: string) => Promise<string[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Restores working-tree content for the given paths from the index.
|
|
60
|
+
* Uses `--pathspec-from-file` with NUL-separated stdin so huge lists
|
|
61
|
+
* don't blow past `ARG_MAX`.
|
|
62
|
+
*/
|
|
63
|
+
export declare const checkoutPaths: (paths: ReadonlyArray<string>, options: {
|
|
64
|
+
readonly cwd: string;
|
|
65
|
+
}) => Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Refreshes the index against the working tree. Runs `git update-index --again`
|
|
68
|
+
* first (lint-staged v17 behaviour — improves compatibility when the original
|
|
69
|
+
* commit used a pathspec instead of an explicit `git add`), then falls back
|
|
70
|
+
* to `git add -u` against the originally-staged paths to handle deletions
|
|
71
|
+
* that `update-index --again` can't express.
|
|
72
|
+
*/
|
|
73
|
+
export declare const updateIndexAgain: (paths: ReadonlyArray<string>, options: {
|
|
74
|
+
readonly cwd: string;
|
|
75
|
+
}) => Promise<void>;
|
|
76
|
+
export { DEFAULT_DIFF_FILTER };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface GitExecOptions {
|
|
2
|
+
readonly cwd: string;
|
|
3
|
+
/** Environment overrides merged on top of `process.env`. */
|
|
4
|
+
readonly env?: Record<string, string>;
|
|
5
|
+
/** Pipe stdin as a Buffer (used for `git apply`). */
|
|
6
|
+
readonly input?: Buffer | string;
|
|
7
|
+
/** Ignore non-zero exit codes; useful for `rev-parse` checks. */
|
|
8
|
+
readonly lenient?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface GitExecResult {
|
|
11
|
+
readonly exitCode: number;
|
|
12
|
+
readonly stderr: string;
|
|
13
|
+
readonly stdout: string;
|
|
14
|
+
}
|
|
15
|
+
/** Runs `git` with the given args. Throws `GitError` on non-zero unless `lenient`. */
|
|
16
|
+
export declare const git: (args: ReadonlyArray<string>, options: GitExecOptions) => Promise<GitExecResult>;
|
|
17
|
+
/** Convenience: returns trimmed stdout from a successful git invocation. */
|
|
18
|
+
export declare const gitOut: (args: ReadonlyArray<string>, options: GitExecOptions) => Promise<string>;
|
|
19
|
+
/** Returns true if `cwd` is inside a git working tree. */
|
|
20
|
+
export declare const isGitRepo: (cwd: string) => Promise<boolean>;
|
|
21
|
+
/** Returns the absolute path to the repository's `.git` directory. */
|
|
22
|
+
export declare const getGitDirectory: (cwd: string) => Promise<string>;
|
|
23
|
+
/** Returns the absolute path to the working-tree root. */
|
|
24
|
+
export declare const getWorkTree: (cwd: string) => Promise<string>;
|
|
25
|
+
/** Returns the current index tree sha (via `git write-tree`). */
|
|
26
|
+
export declare const writeIndexTree: (cwd: string) => Promise<string>;
|
|
27
|
+
/** Returns the tree sha for `HEAD`. Empty string when there is no commit yet. */
|
|
28
|
+
export declare const headTreeSha: (cwd: string) => Promise<string>;
|
|
29
|
+
/** Minimum git version required by the staged workflow — matches lint-staged v17. */
|
|
30
|
+
export declare const MIN_GIT_VERSION: {
|
|
31
|
+
readonly major: 2;
|
|
32
|
+
readonly minor: 32;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Parses `git --version` output (e.g. `git version 2.45.1.windows.2`) into a
|
|
36
|
+
* `{ major, minor }` tuple. Returns `null` when the shape isn't recognised.
|
|
37
|
+
*/
|
|
38
|
+
export declare const parseGitVersion: (output: string) => {
|
|
39
|
+
major: number;
|
|
40
|
+
minor: number;
|
|
41
|
+
} | null;
|
|
42
|
+
/** Throws `GitError` when the installed git is older than {@link MIN_GIT_VERSION}. */
|
|
43
|
+
export declare const assertGitVersion: (cwd: string) => Promise<void>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { RunOptions } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Encapsulates the full git side-effect sequence around task execution:
|
|
4
|
+
* take a backup stash, hide unstaged deltas, run tasks, re-stage fixes,
|
|
5
|
+
* reapply hidden deltas, and revert on failure. Mirrors lint-staged's
|
|
6
|
+
* GitWorkflow state machine with equivalent flag behavior.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitWorkflow {
|
|
9
|
+
stagedFiles: string[];
|
|
10
|
+
partiallyStaged: string[];
|
|
11
|
+
workTree: string;
|
|
12
|
+
gitDir: string;
|
|
13
|
+
/** Index tree sha captured at the end of `prepare()`, before tasks run. */
|
|
14
|
+
preTaskIndexTree: string;
|
|
15
|
+
/** Index tree sha captured at the end of `applyModifications()`, after tasks' in-place edits are staged. */
|
|
16
|
+
postTaskIndexTree: string;
|
|
17
|
+
/** HEAD tree sha captured in `prepare()` — used to detect empty-after-revert commits. */
|
|
18
|
+
headTree: string;
|
|
19
|
+
/** Becomes true after a successful `revert()` so the caller can skip the unstaged-patch re-apply that would duplicate the restored deltas. */
|
|
20
|
+
revertApplied: boolean;
|
|
21
|
+
/** Emitted by `prepare()` when we skip the backup stash but still have partially-staged files — the caller can surface this to the user. */
|
|
22
|
+
warnings: string[];
|
|
23
|
+
private readonly cwd;
|
|
24
|
+
private readonly options;
|
|
25
|
+
private patch;
|
|
26
|
+
private backupStashSha;
|
|
27
|
+
private merge;
|
|
28
|
+
private readonly shouldStash;
|
|
29
|
+
private readonly shouldHidePartial;
|
|
30
|
+
private readonly shouldHideUnstaged;
|
|
31
|
+
private readonly shouldHideAll;
|
|
32
|
+
/** Sha of the hide-all push stash (if `--hide-all` is set), tracked separately from the create+store backup. */
|
|
33
|
+
private hideAllStashSha;
|
|
34
|
+
/** Paths that were `git add -N`'d (intent-to-add) — removed from the index before stashing, restored after. */
|
|
35
|
+
private intentToAddPaths;
|
|
36
|
+
/** Untracked files observed at the end of `prepare()`. Diffed post-run to detect task-created files for `--autoStage`. */
|
|
37
|
+
private preTaskUntracked;
|
|
38
|
+
constructor(options: RunOptions);
|
|
39
|
+
prepare(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Refreshes the index against the working tree, so task edits
|
|
42
|
+
* (including deletions of already-tracked files) are re-staged.
|
|
43
|
+
* Uses `git update-index --again` for parity with lint-staged v17,
|
|
44
|
+
* which behaves correctly when the original commit used a pathspec.
|
|
45
|
+
*/
|
|
46
|
+
applyModifications({ autoStage }?: {
|
|
47
|
+
readonly autoStage?: boolean;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/** True when tasks modified at least one staged file's content (index tree changed). */
|
|
50
|
+
indexTreeChanged(): boolean;
|
|
51
|
+
/** True when the post-task index tree matches HEAD — i.e. tasks reverted every staged change. */
|
|
52
|
+
postTaskIndexMatchesHead(): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Re-applies the hidden unstaged patch. Falls back to 3-way on conflict.
|
|
55
|
+
* Skips silently when `revert()` already restored the working tree from the backup stash,
|
|
56
|
+
* since the stash already carries those deltas and re-applying would duplicate them.
|
|
57
|
+
* When `--hide-all` is active this is also a no-op — the `popHideAllStash()` call in
|
|
58
|
+
* `cleanup()` handles restore for that mode.
|
|
59
|
+
*/
|
|
60
|
+
restoreUnstagedChanges(): Promise<void>;
|
|
61
|
+
/** Restores index + working tree from the backup stash and drops it. */
|
|
62
|
+
revert(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* On success, drops the backup stash and pops the hide-all stash (if any).
|
|
65
|
+
* On failure without --revert, leaves the backup stash in place so the
|
|
66
|
+
* user can recover manually.
|
|
67
|
+
*/
|
|
68
|
+
cleanup(success: boolean): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns a user-facing hint that points at the backup stash when
|
|
71
|
+
* tasks failed and we kept it around (no --revert).
|
|
72
|
+
*/
|
|
73
|
+
recoveryHint(): string | null;
|
|
74
|
+
private hideUnstagedChanges;
|
|
75
|
+
private snapshotMergeState;
|
|
76
|
+
private restoreMergeState;
|
|
77
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Message prefix stored on the stash entry. A per-process suffix is appended at creation time so concurrent `vis staged` invocations don't collide. */
|
|
2
|
+
declare const STASH_MESSAGE_PREFIX = "vis_staged_automatic_backup";
|
|
3
|
+
/**
|
|
4
|
+
* Creates and stores a hidden backup stash. Uses `git stash create +
|
|
5
|
+
* store` instead of `git stash push` so the working tree and index are
|
|
6
|
+
* left untouched — pushing would mutate the worktree, which breaks
|
|
7
|
+
* concurrent editors and file watchers.
|
|
8
|
+
*
|
|
9
|
+
* Returns the stash commit sha, or `null` when there is nothing to
|
|
10
|
+
* stash (e.g. a fresh repo with only an initial commit).
|
|
11
|
+
*/
|
|
12
|
+
export declare const createBackupStash: (cwd: string) => Promise<string | null>;
|
|
13
|
+
/**
|
|
14
|
+
* Stashes every unstaged change and untracked file on top of the index,
|
|
15
|
+
* leaving only staged content in the working tree. Unlike
|
|
16
|
+
* {@link createBackupStash}, this uses `git stash push --include-untracked`
|
|
17
|
+
* because `git stash create` cannot capture untracked files.
|
|
18
|
+
*
|
|
19
|
+
* Returns the stash commit sha so the caller can drop or apply it later.
|
|
20
|
+
*/
|
|
21
|
+
export declare const createHideAllStash: (cwd: string) => Promise<string | null>;
|
|
22
|
+
/** Drops the stash entry that resolves to `sha`, if one is present. */
|
|
23
|
+
export declare const dropBackupStash: (cwd: string, sha: string | null) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Restores the working tree and index from the backup stash. Used by
|
|
26
|
+
* the revert path when tasks failed and we need to leave the repo in
|
|
27
|
+
* its pre-task state.
|
|
28
|
+
*/
|
|
29
|
+
export declare const applyBackupStash: (cwd: string, sha: string | null) => Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Pops the hide-all stash back onto the working tree — restoring
|
|
32
|
+
* previously-hidden unstaged edits and untracked files. The index is
|
|
33
|
+
* left untouched so task-driven edits that we already re-staged
|
|
34
|
+
* survive the restore.
|
|
35
|
+
*/
|
|
36
|
+
export declare const popHideAllStash: (cwd: string, sha: string | null) => Promise<void>;
|
|
37
|
+
export { STASH_MESSAGE_PREFIX };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RunOptions, RunResult } from "./types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Runs staged tasks end-to-end: backup, hide unstaged, match files,
|
|
4
|
+
* execute commands, re-stage fixes, reapply unstaged deltas, cleanup.
|
|
5
|
+
* Returns `{ success, ranTasks, failedCommands }`.
|
|
6
|
+
*
|
|
7
|
+
* Throws on setup-level failures (no git repo, invalid config). Task
|
|
8
|
+
* failures are reported via the return value when `continueOnError` is
|
|
9
|
+
* enabled, otherwise they end the run with `success: false`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const runStaged: (options?: RunOptions) => Promise<RunResult>;
|
|
12
|
+
export { ApplyEmptyCommitError, ConfigError, GetBackupStashError, GitError, RestoreOriginalStateError, StagedError, TaskError } from "./index.d.ts";
|
|
13
|
+
export type { RunOptions, RunResult, StagedConfig } from "./types.d.ts";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface MatchOptions {
|
|
2
|
+
readonly caseInsensitive?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare const matchFiles: (pattern: string, files: ReadonlyArray<string>, cwd: string, options?: MatchOptions) => string[];
|
|
5
|
+
/**
|
|
6
|
+
* Filters a staged file list against a top-level ignore list. A file is
|
|
7
|
+
* dropped when any of the ignore patterns matches — basename-style for
|
|
8
|
+
* patterns without a path separator, path-style relative to `cwd`
|
|
9
|
+
* otherwise. Mirrors the `matchFiles` semantics (including `caseInsensitive`)
|
|
10
|
+
* so users don't have to think twice about the ignore syntax.
|
|
11
|
+
*/
|
|
12
|
+
export declare const applyIgnore: (files: ReadonlyArray<string>, ignore: ReadonlyArray<string> | undefined, cwd: string, options?: MatchOptions) => string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Renderer, RunOptions } from "../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Picks the right renderer for the runtime environment and option flags.
|
|
4
|
+
* Plain renderer runs in CI, non-TTY terminals, and when `debug`, `quiet`,
|
|
5
|
+
* or `TERM=dumb` is set. Everywhere else the Ink tree renderer engages.
|
|
6
|
+
*/
|
|
7
|
+
export declare const pickRenderer: (options: RunOptions) => Promise<Renderer>;
|
|
8
|
+
export { createInkRenderer } from "./index.d.ts";
|
|
9
|
+
export { createPlainRenderer } from "./plain.d.ts";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Renderer } from "../types.d.ts";
|
|
2
|
+
interface PlainRendererOptions {
|
|
3
|
+
readonly quiet?: boolean;
|
|
4
|
+
readonly verbose?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Line-based renderer suitable for CI, non-TTY terminals, and `--debug` /
|
|
8
|
+
* `--quiet` runs. Matches listr2's verbose renderer contract: one line
|
|
9
|
+
* per lifecycle event, no cursor manipulation, stable output for logs.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createPlainRenderer: (options?: PlainRendererOptions) => Renderer;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CustomTask, PatternDescriptor, StagedTask } from "../types.d.ts";
|
|
2
|
+
declare const isCustomTask: (value: unknown) => value is CustomTask;
|
|
3
|
+
export interface BuildTaskGraphOptions {
|
|
4
|
+
/** Match globs case-insensitively — enable on HFS+/APFS (macOS) and NTFS (Windows). */
|
|
5
|
+
readonly caseInsensitive?: boolean;
|
|
6
|
+
readonly config: Readonly<Record<string, StagedTask>>;
|
|
7
|
+
readonly cwd: string;
|
|
8
|
+
readonly files: ReadonlyArray<string>;
|
|
9
|
+
readonly relative?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Builds the list of pattern descriptors that the runner will execute. */
|
|
12
|
+
export declare const buildTaskGraph: (options: BuildTaskGraphOptions) => Promise<PatternDescriptor[]>;
|
|
13
|
+
export { isCustomTask };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal quote-aware argv splitter. Handles single and double quotes,
|
|
3
|
+
* backslash escapes (both outside and inside double quotes, matching
|
|
4
|
+
* POSIX shell semantics), and collapses runs of whitespace — enough for
|
|
5
|
+
* the shell-like syntax users put in their staged config without
|
|
6
|
+
* dragging in `string-argv`.
|
|
7
|
+
*
|
|
8
|
+
* Inside single quotes everything is literal (POSIX semantics). Inside
|
|
9
|
+
* double quotes, `\"` and `\\` are interpreted; other backslash
|
|
10
|
+
* sequences are preserved verbatim.
|
|
11
|
+
*
|
|
12
|
+
* Throws `ConfigError` on unterminated quotes so typos in config fail
|
|
13
|
+
* fast instead of silently swallowing the rest of the command.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseCommandString: (input: string) => string[];
|
|
16
|
+
/**
|
|
17
|
+
* Platform-aware default for the maximum per-invocation argv byte length.
|
|
18
|
+
*
|
|
19
|
+
* Linux `execve()` caps `ARG_MAX` at ~128 KiB on most kernels; macOS sits at
|
|
20
|
+
* 256 KiB. Windows `CreateProcess` caps the full command line at 32,767
|
|
21
|
+
* UTF-16 code units (~65 KiB in the worst ASCII case, tighter for non-ASCII),
|
|
22
|
+
* so we pick a conservative 28 KiB limit there to leave headroom for the
|
|
23
|
+
* argv prefix and environment overhead that Node splices in.
|
|
24
|
+
*/
|
|
25
|
+
declare const DEFAULT_MAX_ARG_LENGTH: number;
|
|
26
|
+
/**
|
|
27
|
+
* Splits `files` into chunks whose combined byte length (plus a shared
|
|
28
|
+
* fixed-prefix length) does not exceed `maxArgLength`. Guarantees at
|
|
29
|
+
* least one file per chunk so extremely long individual paths still
|
|
30
|
+
* make it through.
|
|
31
|
+
*/
|
|
32
|
+
export declare const chunkFiles: (files: ReadonlyArray<string>, fixedPrefixLength: number, maxArgLength: number) => string[][];
|
|
33
|
+
export interface ExecCommandOptions {
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
readonly env?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Signal delivered to the child process when `signal` fires. Defaults to `SIGTERM`
|
|
38
|
+
* (graceful). Use `SIGKILL` for fast-fail runs where graceful shutdown is not
|
|
39
|
+
* worth the wait.
|
|
40
|
+
*/
|
|
41
|
+
readonly killSignal?: NodeJS.Signals;
|
|
42
|
+
readonly maxArgLength?: number;
|
|
43
|
+
/** Aborted when the caller cancels the run (e.g. another task failed without `continueOnError`). */
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
}
|
|
46
|
+
export interface ExecCommandResult {
|
|
47
|
+
readonly durationMs: number;
|
|
48
|
+
readonly output: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Runs a command once per file-chunk, concatenating stdout/stderr for
|
|
52
|
+
* renderer consumption. Throws `TaskError` on the first failing chunk
|
|
53
|
+
* or when the caller's `AbortSignal` fires mid-invocation.
|
|
54
|
+
*/
|
|
55
|
+
export declare const execCommand: (command: string, files: ReadonlyArray<string>, options: ExecCommandOptions) => Promise<ExecCommandResult>;
|
|
56
|
+
export { DEFAULT_MAX_ARG_LENGTH };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PatternDescriptor, Renderer } from "../types.d.ts";
|
|
2
|
+
export interface RunTasksOptions {
|
|
3
|
+
readonly concurrent: boolean | number;
|
|
4
|
+
readonly continueOnError: boolean;
|
|
5
|
+
readonly cwd: string;
|
|
6
|
+
/** External cancellation (e.g. SIGINT handler). When fired, cancels like a task failure. */
|
|
7
|
+
readonly externalSignal?: AbortSignal;
|
|
8
|
+
/** Signal delivered to in-flight child processes when the run cancels. Defaults to `SIGTERM`. */
|
|
9
|
+
readonly killSignal?: NodeJS.Signals;
|
|
10
|
+
readonly maxArgLength?: number;
|
|
11
|
+
readonly verbose?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface RunTasksResult {
|
|
14
|
+
readonly failedCommands: string[];
|
|
15
|
+
readonly success: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Runs pattern tasks with pattern-level concurrency and command-level
|
|
19
|
+
* serial execution. Emits lifecycle events through the renderer.
|
|
20
|
+
*
|
|
21
|
+
* When a command fails and `continueOnError` is off, the shared
|
|
22
|
+
* `AbortController` is aborted so any execa children currently running
|
|
23
|
+
* in other workers exit promptly rather than running to completion on
|
|
24
|
+
* a doomed run.
|
|
25
|
+
*/
|
|
26
|
+
export declare const runTasks: (patterns: ReadonlyArray<PatternDescriptor>, renderer: Renderer, options: RunTasksOptions) => Promise<RunTasksResult>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for the in-house staged-files workflow that replaces
|
|
3
|
+
* the `lint-staged` peer dependency. The surface mirrors lint-staged's
|
|
4
|
+
* so existing configs and the `vis staged` command contract survive.
|
|
5
|
+
*/
|
|
6
|
+
/** Status of a single task or pattern in the runner lifecycle. */
|
|
7
|
+
export type TaskStatus = "failed" | "pending" | "running" | "skipped" | "success";
|
|
8
|
+
/**
|
|
9
|
+
* Custom task form — `{ title, task }` — analogous to lint-staged's
|
|
10
|
+
* listr-style task objects. `task` receives the matched absolute paths
|
|
11
|
+
* and returns a promise that resolves on success or rejects on failure.
|
|
12
|
+
*/
|
|
13
|
+
export interface CustomTask {
|
|
14
|
+
readonly task: (files: string[]) => Promise<unknown> | unknown;
|
|
15
|
+
readonly title: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A task value as authored by the user. Command strings are split into
|
|
19
|
+
* argv and invoked with the matched file paths appended. Arrays run
|
|
20
|
+
* serially. Functions receive the matched paths and return further
|
|
21
|
+
* task values (possibly async). `{ title, task }` objects run `task`
|
|
22
|
+
* directly with no argv construction.
|
|
23
|
+
*/
|
|
24
|
+
export type StagedTask = CustomTask | StagedTaskFunction | ReadonlyArray<CustomTask | StagedTaskFunction | string> | string | ReadonlyArray<string>;
|
|
25
|
+
export type StagedTaskFunction = (files: string[]) => Promise<StagedTaskResult> | StagedTaskResult;
|
|
26
|
+
export type StagedTaskResult = CustomTask | ReadonlyArray<CustomTask | string> | string | ReadonlyArray<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Config object mapping glob patterns (basename or path-style) to tasks.
|
|
29
|
+
* A top-level function form lets the user generate the entire config
|
|
30
|
+
* from the staged file list.
|
|
31
|
+
*/
|
|
32
|
+
export type StagedConfig = Readonly<Record<string, StagedTask>> | StagedConfigFunction;
|
|
33
|
+
export type StagedConfigFunction = (files: string[]) => Promise<Record<string, StagedTask>> | Record<string, StagedTask>;
|
|
34
|
+
/** Options accepted by `runStaged`. Mirrors the lint-staged CLI surface. */
|
|
35
|
+
export interface RunOptions {
|
|
36
|
+
/** Allow empty commits when tasks revert every staged change. */
|
|
37
|
+
readonly allowEmpty?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* When a task writes *new* files that sit outside the originally-staged
|
|
40
|
+
* set, automatically stage them too. Defaults to `false` — only tasks
|
|
41
|
+
* explicitly called out to produce new artefacts should set this (e.g.
|
|
42
|
+
* codegen, lockfile regeneration). Closes nano-staged #43.
|
|
43
|
+
*/
|
|
44
|
+
readonly autoStage?: boolean;
|
|
45
|
+
/** Concurrency: `true` (unbounded), `false` (serial), or a positive integer. */
|
|
46
|
+
readonly concurrent?: boolean | number;
|
|
47
|
+
/** Inline staged config — the single source of truth at runtime. Supplied by `vis staged` from `vis.config.ts`. */
|
|
48
|
+
readonly config?: StagedConfig;
|
|
49
|
+
/** Run all tasks to completion even if one fails. */
|
|
50
|
+
readonly continueOnError?: boolean;
|
|
51
|
+
/** Working directory used for git and task execution. */
|
|
52
|
+
readonly cwd?: string;
|
|
53
|
+
/** Enable debug logging and force the plain renderer. */
|
|
54
|
+
readonly debug?: boolean;
|
|
55
|
+
/** Override the default `--staged` diff scope with an arbitrary git range. Implies `--no-stash`. */
|
|
56
|
+
readonly diff?: string;
|
|
57
|
+
/** Override the default `--diff-filter=ACMR`. */
|
|
58
|
+
readonly diffFilter?: string;
|
|
59
|
+
/** Exit with a non-zero status if tasks modified tracked files. Implies `--no-revert`. */
|
|
60
|
+
readonly failOnChanges?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Hide every unstaged change *and* every untracked file before running
|
|
63
|
+
* tasks. Useful for tools like Knip that inspect the whole worktree.
|
|
64
|
+
* Backed by a `git stash --include-untracked` so restore is automatic.
|
|
65
|
+
*/
|
|
66
|
+
readonly hideAll?: boolean;
|
|
67
|
+
/** Hide unstaged edits on partially-staged files (default: `true`). Set `false` to disable. */
|
|
68
|
+
readonly hidePartiallyStaged?: boolean;
|
|
69
|
+
/** Hide unstaged changes on every tracked file, not only partially-staged ones. */
|
|
70
|
+
readonly hideUnstaged?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Glob patterns for files to exclude from every task. Applied to the
|
|
73
|
+
* staged file list before pattern matching, so an `ignore` hit drops
|
|
74
|
+
* a file from *all* tasks regardless of which globs would otherwise
|
|
75
|
+
* have picked it up. Closes lint-staged issue #1722.
|
|
76
|
+
*/
|
|
77
|
+
readonly ignore?: ReadonlyArray<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Signal used to kill in-flight task subprocesses when the run is
|
|
80
|
+
* cancelled (another task failed without `continueOnError`, or the
|
|
81
|
+
* user hit Ctrl+C). Defaults to `SIGTERM`, which lets well-behaved
|
|
82
|
+
* tools flush before exiting. Use `SIGKILL` for fast-fail runs
|
|
83
|
+
* where graceful shutdown is not worth the wait.
|
|
84
|
+
* @default "SIGTERM"
|
|
85
|
+
*/
|
|
86
|
+
readonly killSignal?: NodeJS.Signals;
|
|
87
|
+
/** Cap on combined argv byte length per command invocation. Defaults to a conservative OS limit. */
|
|
88
|
+
readonly maxArgLength?: number;
|
|
89
|
+
/** Suppress progress output entirely. */
|
|
90
|
+
readonly quiet?: boolean;
|
|
91
|
+
/** Pass matched paths to tasks relative to `cwd` instead of absolute. */
|
|
92
|
+
readonly relative?: boolean;
|
|
93
|
+
/** Revert the working tree from the backup stash when a task fails. */
|
|
94
|
+
readonly revert?: boolean;
|
|
95
|
+
/** Take a backup stash before running tasks (default: `true`). Set `false` to disable. */
|
|
96
|
+
readonly stash?: boolean;
|
|
97
|
+
/** Show task stdout/stderr on success, not only on failure. */
|
|
98
|
+
readonly verbose?: boolean;
|
|
99
|
+
}
|
|
100
|
+
/** A runtime descriptor for a single command belonging to a pattern. */
|
|
101
|
+
export interface CommandDescriptor {
|
|
102
|
+
/** Resolved command template; absent for custom tasks. */
|
|
103
|
+
readonly command?: string;
|
|
104
|
+
/** Matched files (absolute or relative, per `relative` option). */
|
|
105
|
+
readonly files: ReadonlyArray<string>;
|
|
106
|
+
/** A stable id for renderer lookups. */
|
|
107
|
+
readonly id: string;
|
|
108
|
+
/** Custom task callback; only set when `source === "custom"`. */
|
|
109
|
+
readonly run?: (files: string[]) => Promise<unknown> | unknown;
|
|
110
|
+
readonly source: "custom" | "function" | "string";
|
|
111
|
+
readonly title: string;
|
|
112
|
+
}
|
|
113
|
+
/** A runtime descriptor for a glob pattern and its resolved commands. */
|
|
114
|
+
export interface PatternDescriptor {
|
|
115
|
+
readonly commands: ReadonlyArray<CommandDescriptor>;
|
|
116
|
+
readonly files: ReadonlyArray<string>;
|
|
117
|
+
readonly id: string;
|
|
118
|
+
readonly pattern: string;
|
|
119
|
+
readonly title: string;
|
|
120
|
+
}
|
|
121
|
+
/** Events emitted by the runner and consumed by a renderer. */
|
|
122
|
+
export interface RunnerEvents {
|
|
123
|
+
commandEnd: {
|
|
124
|
+
readonly commandId: string;
|
|
125
|
+
readonly durationMs: number;
|
|
126
|
+
readonly error?: Error;
|
|
127
|
+
readonly output?: string;
|
|
128
|
+
readonly patternId: string;
|
|
129
|
+
readonly status: TaskStatus;
|
|
130
|
+
};
|
|
131
|
+
commandStart: {
|
|
132
|
+
readonly commandId: string;
|
|
133
|
+
readonly patternId: string;
|
|
134
|
+
};
|
|
135
|
+
error: {
|
|
136
|
+
readonly error?: Error;
|
|
137
|
+
readonly message: string;
|
|
138
|
+
};
|
|
139
|
+
info: {
|
|
140
|
+
readonly message: string;
|
|
141
|
+
};
|
|
142
|
+
patternEnd: {
|
|
143
|
+
readonly patternId: string;
|
|
144
|
+
readonly status: TaskStatus;
|
|
145
|
+
};
|
|
146
|
+
patternStart: {
|
|
147
|
+
readonly patternId: string;
|
|
148
|
+
};
|
|
149
|
+
start: {
|
|
150
|
+
readonly patterns: ReadonlyArray<PatternDescriptor>;
|
|
151
|
+
};
|
|
152
|
+
warn: {
|
|
153
|
+
readonly message: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** Abstract renderer contract — plain and Ink implementations conform. */
|
|
157
|
+
export interface Renderer {
|
|
158
|
+
commandEnd: (payload: RunnerEvents["commandEnd"]) => void;
|
|
159
|
+
commandStart: (payload: RunnerEvents["commandStart"]) => void;
|
|
160
|
+
error: (payload: RunnerEvents["error"]) => void;
|
|
161
|
+
info: (payload: RunnerEvents["info"]) => void;
|
|
162
|
+
patternEnd: (payload: RunnerEvents["patternEnd"]) => void;
|
|
163
|
+
patternStart: (payload: RunnerEvents["patternStart"]) => void;
|
|
164
|
+
start: (payload: RunnerEvents["start"]) => void;
|
|
165
|
+
stop: () => Promise<void> | void;
|
|
166
|
+
warn: (payload: RunnerEvents["warn"]) => void;
|
|
167
|
+
}
|
|
168
|
+
/** Outcome of a `runStaged` invocation. */
|
|
169
|
+
export interface RunResult {
|
|
170
|
+
readonly failedCommands: ReadonlyArray<string>;
|
|
171
|
+
readonly ranTasks: boolean;
|
|
172
|
+
readonly success: boolean;
|
|
173
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { WorkspaceConfiguration } from "@visulima/task-runner";
|
|
2
|
+
import type { ProjectOptionsIndex } from "./workspace.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Collects every unique target name across all projects in the workspace.
|
|
5
|
+
* @param workspace The discovered workspace configuration.
|
|
6
|
+
* @returns Sorted array of unique target names.
|
|
7
|
+
*/
|
|
8
|
+
export declare const collectAvailableTargets: (workspace: WorkspaceConfiguration) => string[];
|
|
9
|
+
/**
|
|
10
|
+
* Builds a `{alias → canonicalTargetName}` lookup from declared
|
|
11
|
+
* `aliases` on any `VisTargetConfiguration` in the workspace. Aliases
|
|
12
|
+
* are treated as workspace-global — the first declaration wins and
|
|
13
|
+
* later ones are silently ignored (prefer explicit canonical names
|
|
14
|
+
* when aliases collide).
|
|
15
|
+
*
|
|
16
|
+
* Canonical target names themselves are not added to the map — only
|
|
17
|
+
* declared aliases — so `resolveTargetAlias` leaves non-alias input
|
|
18
|
+
* unchanged.
|
|
19
|
+
*/
|
|
20
|
+
export declare const buildAliasMap: (projectOptions: ProjectOptionsIndex) => Map<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves a user-typed target name to its canonical form, or returns
|
|
23
|
+
* the input unchanged when no alias matches.
|
|
24
|
+
*/
|
|
25
|
+
export declare const resolveTargetAlias: (name: string, aliases: Map<string, string>) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Suggests the closest matching target name for a typo.
|
|
28
|
+
* @param input The unknown target name the user typed.
|
|
29
|
+
* @param available Known target names.
|
|
30
|
+
* @param maxDistance Maximum edit distance to consider (default 3).
|
|
31
|
+
* @returns The best match, or `undefined` if nothing is close enough.
|
|
32
|
+
*/
|
|
33
|
+
export declare const suggestTarget: (input: string, available: string[], maxDistance?: number) => string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Returns up to `limit` closest-matching target names within
|
|
36
|
+
* `maxDistance` edit distance, sorted by ascending distance.
|
|
37
|
+
*
|
|
38
|
+
* Used by the missing-target error output to offer several candidates
|
|
39
|
+
* — one suggestion often reads as authoritative, three reads as
|
|
40
|
+
* "pick whichever you meant", which is friendlier at scale.
|
|
41
|
+
*/
|
|
42
|
+
export declare const suggestTargets: (input: string, available: string[], limit?: number, maxDistance?: number) => string[];
|
|
43
|
+
/**
|
|
44
|
+
* Formats the available targets list for display.
|
|
45
|
+
* @param targets Sorted target names.
|
|
46
|
+
* @returns Formatted string for CLI output.
|
|
47
|
+
*/
|
|
48
|
+
export declare const formatTargetList: (targets: string[]) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Prompts the user to pick a target from `targets` via an interactive
|
|
51
|
+
* numbered readline prompt. Accepts either the index (1-based) or the
|
|
52
|
+
* target name; empty input or Ctrl-C aborts with `undefined`.
|
|
53
|
+
*
|
|
54
|
+
* Uses Node's built-in readline rather than a TUI dependency — this
|
|
55
|
+
* keeps the bare `vis run` flow lightweight and works in any TTY.
|
|
56
|
+
* Mirrors vite-task's `vp run` (no args) interactive selector.
|
|
57
|
+
* @returns The chosen target name, or `undefined` if the user aborts.
|
|
58
|
+
*/
|
|
59
|
+
export declare const promptTargetInteractively: (targets: string[]) => Promise<string | undefined>;
|