@visulima/vis 1.0.0-alpha.7 → 1.0.0-alpha.8
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 +27 -0
- package/dist/bin.js +314 -302
- package/dist/commands/cache.d.ts +2 -2
- package/dist/commands/hook/constants.d.ts +6 -1
- package/dist/commands/hook/index.d.ts +2 -2
- package/dist/commands/hook/list.d.ts +28 -0
- package/dist/commands/hook/migrate.d.ts +4 -1
- package/dist/commands/hook/prek-builtins.d.ts +8 -0
- package/dist/commands/hook/prek.d.ts +129 -0
- package/dist/commands/hook/run.d.ts +21 -0
- package/dist/commands/hook/validate.d.ts +17 -0
- package/dist/commands/migrate/index.d.ts +2 -2
- package/package.json +12 -10
package/dist/commands/cache.d.ts
CHANGED
|
@@ -81,6 +81,6 @@ declare const runPrune: (cacheDirectory: string, workspaceRoot: string, options:
|
|
|
81
81
|
* @returns Resolves when output has been written.
|
|
82
82
|
*/
|
|
83
83
|
declare const runSize: (cacheDirectory: string, format: string) => Promise<void>;
|
|
84
|
-
declare const
|
|
85
|
-
export default
|
|
84
|
+
declare const cacheCommands: Command[];
|
|
85
|
+
export default cacheCommands;
|
|
86
86
|
export { collectCacheEntries, formatAge, runClean, runList, runPrune, runSize };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
declare const HOOKS: readonly ["pre-commit", "pre-merge-commit", "prepare-commit-msg", "commit-msg", "post-commit", "applypatch-msg", "pre-applypatch", "post-applypatch", "pre-rebase", "post-rewrite", "post-checkout", "post-merge", "pre-push", "pre-auto-gc"];
|
|
2
2
|
declare const DEFAULT_HOOKS_DIRECTORY = ".vis-hooks";
|
|
3
|
+
declare const PREK_CONFIG_FILES: readonly [".pre-commit-config.yaml", ".pre-commit-config.yml", "prek.toml"];
|
|
4
|
+
declare const PREK_STAGE_ALIASES: Readonly<Record<string, string>>;
|
|
5
|
+
declare const PREK_SUPPORTED_STAGES: ReadonlySet<string>;
|
|
6
|
+
declare const PREK_STAGES_WITH_GIT_ARGS: ReadonlySet<string>;
|
|
7
|
+
declare const PREK_TRANSLATABLE_LANGUAGES: ReadonlySet<string>;
|
|
3
8
|
interface InstallResult {
|
|
4
9
|
isError: boolean;
|
|
5
10
|
message: string;
|
|
6
11
|
}
|
|
7
12
|
export type { InstallResult };
|
|
8
|
-
export { DEFAULT_HOOKS_DIRECTORY, HOOKS };
|
|
13
|
+
export { DEFAULT_HOOKS_DIRECTORY, HOOKS, PREK_CONFIG_FILES, PREK_STAGE_ALIASES, PREK_STAGES_WITH_GIT_ARGS, PREK_SUPPORTED_STAGES, PREK_TRANSLATABLE_LANGUAGES };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Command } from "@visulima/cerebro";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const hookCommands: Command[];
|
|
3
|
+
export default hookCommands;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface HookBlock {
|
|
2
|
+
command: string;
|
|
3
|
+
id: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
interface StageEntry {
|
|
7
|
+
blocks: HookBlock[];
|
|
8
|
+
rawLineCount: number;
|
|
9
|
+
stage: string;
|
|
10
|
+
}
|
|
11
|
+
interface ListResult {
|
|
12
|
+
hooksDirectory: string;
|
|
13
|
+
stages: StageEntry[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse a `.vis-hooks/{stage}` script into `# id: name` headers emitted by the
|
|
17
|
+
* migrator. Scripts authored by hand (no headers) surface as a single
|
|
18
|
+
* "(custom)" block.
|
|
19
|
+
*/
|
|
20
|
+
declare const parseStageScript: (content: string) => HookBlock[];
|
|
21
|
+
declare const listHooks: (root: string, hooksDirectory: string) => ListResult;
|
|
22
|
+
declare const formatListResult: (result: ListResult) => string[];
|
|
23
|
+
declare const runList: (hooksDirectory: string, logger: {
|
|
24
|
+
info: (message: string) => void;
|
|
25
|
+
}) => void;
|
|
26
|
+
export type { HookBlock, ListResult, StageEntry };
|
|
27
|
+
export { formatListResult, listHooks, parseStageScript, runList };
|
|
28
|
+
export { DEFAULT_HOOKS_DIRECTORY as LIST_DEFAULT_DIRECTORY } from "./constants.d.ts";
|
|
@@ -23,5 +23,8 @@ declare const cleanPackageJsonScripts: (root: string) => {
|
|
|
23
23
|
/**
|
|
24
24
|
* Migrates from husky to vis hooks.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
interface HuskyMigrateOptions {
|
|
27
|
+
dryRun?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const migrateFromHusky: (root: string, hooksDirectory: string, logger: Console, options?: HuskyMigrateOptions) => InstallResult;
|
|
27
30
|
export { cleanPackageJsonScripts, detectHuskyDirectory, detectPackageManager, migrateFromHusky, transformHookScript };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const PREK_RUNNER_FILENAME = "prek-runner.mjs";
|
|
2
|
+
declare const TYPES_EXTENSION_MAP: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
3
|
+
declare const METADATA_TYPE_TAGS: ReadonlyArray<string>;
|
|
4
|
+
declare const SHEBANG_INTERPRETER_MAP: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
5
|
+
declare const BUILTIN_HOOK_IDS: ReadonlyArray<string>;
|
|
6
|
+
declare const KNOWN_TYPE_TAGS: ReadonlyArray<string>;
|
|
7
|
+
declare const PREK_RUNNER_SOURCE: string;
|
|
8
|
+
export { BUILTIN_HOOK_IDS, KNOWN_TYPE_TAGS, METADATA_TYPE_TAGS, PREK_RUNNER_FILENAME, PREK_RUNNER_SOURCE, SHEBANG_INTERPRETER_MAP, TYPES_EXTENSION_MAP };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { InstallResult } from "./constants.d.ts";
|
|
2
|
+
interface PrekHookEntry {
|
|
3
|
+
additional_dependencies?: string[];
|
|
4
|
+
alias?: string;
|
|
5
|
+
always_run?: boolean;
|
|
6
|
+
args?: string[];
|
|
7
|
+
description?: string;
|
|
8
|
+
entry?: string;
|
|
9
|
+
exclude?: string;
|
|
10
|
+
exclude_types?: string[];
|
|
11
|
+
files?: string;
|
|
12
|
+
id?: string;
|
|
13
|
+
language?: string;
|
|
14
|
+
language_version?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
pass_filenames?: boolean;
|
|
17
|
+
stages?: string[];
|
|
18
|
+
types?: string[];
|
|
19
|
+
types_or?: string[];
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
}
|
|
22
|
+
interface PrekRepoEntry {
|
|
23
|
+
hooks?: PrekHookEntry[];
|
|
24
|
+
repo?: string;
|
|
25
|
+
rev?: string;
|
|
26
|
+
}
|
|
27
|
+
interface PrekConfig {
|
|
28
|
+
default_language_version?: Record<string, string>;
|
|
29
|
+
default_stages?: string[];
|
|
30
|
+
exclude?: string;
|
|
31
|
+
fail_fast?: boolean;
|
|
32
|
+
files?: string;
|
|
33
|
+
repos?: PrekRepoEntry[];
|
|
34
|
+
}
|
|
35
|
+
interface SkippedHook {
|
|
36
|
+
hookId: string;
|
|
37
|
+
reason: string;
|
|
38
|
+
repo: string;
|
|
39
|
+
}
|
|
40
|
+
interface AdditionalDep {
|
|
41
|
+
hookId: string;
|
|
42
|
+
name: string;
|
|
43
|
+
raw: string;
|
|
44
|
+
version: string;
|
|
45
|
+
}
|
|
46
|
+
interface ConversionResult {
|
|
47
|
+
additionalDeps: AdditionalDep[];
|
|
48
|
+
droppedFilters: string[];
|
|
49
|
+
manualSteps: string[];
|
|
50
|
+
scripts: Map<string, string>;
|
|
51
|
+
skippedHooks: SkippedHook[];
|
|
52
|
+
usesRunner: boolean;
|
|
53
|
+
}
|
|
54
|
+
interface MigrateLogger {
|
|
55
|
+
info: (message: string) => void;
|
|
56
|
+
warn: (message: string) => void;
|
|
57
|
+
}
|
|
58
|
+
declare const REMOTE_HOOK_BUILTIN_MAP: ReadonlyMap<string, string>;
|
|
59
|
+
/**
|
|
60
|
+
* Locate a prek config file under `root`. Returns the first match.
|
|
61
|
+
*/
|
|
62
|
+
declare const detectPrekConfig: (root: string) => string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Normalize a stage name, translating legacy pre-commit.com aliases.
|
|
65
|
+
*/
|
|
66
|
+
declare const mapPrekStage: (stage: string) => string;
|
|
67
|
+
/**
|
|
68
|
+
* Reduce a repo URL (https/git/ssh) to an `owner/repo` slug for builtin lookup.
|
|
69
|
+
*/
|
|
70
|
+
declare const normalizeRepoKey: (url: string) => string;
|
|
71
|
+
/**
|
|
72
|
+
* Parse a prek additional_dependencies entry into a (name, version) pair. Pip
|
|
73
|
+
* specifiers (e.g. `black==24.1.0`) return undefined so the caller can warn.
|
|
74
|
+
*/
|
|
75
|
+
declare const parseAdditionalDep: (spec: string) => {
|
|
76
|
+
name: string;
|
|
77
|
+
version: string;
|
|
78
|
+
} | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Determine the target stages for a hook, falling back to config defaults then `[pre-commit]`.
|
|
81
|
+
*/
|
|
82
|
+
declare const resolveStages: (entry: PrekHookEntry, defaultStages: string[] | undefined) => string[];
|
|
83
|
+
/**
|
|
84
|
+
* Build a shell command that routes through the prek-runner. All user strings
|
|
85
|
+
* pass via argv, so shell meta-characters in patterns/args can't escape the
|
|
86
|
+
* outer shell.
|
|
87
|
+
*/
|
|
88
|
+
declare const buildRunnerInvocation: (entry: PrekHookEntry, builtin?: string) => string;
|
|
89
|
+
/**
|
|
90
|
+
* Build the shell command line for a single hook entry. Stages where git
|
|
91
|
+
* passes an argument (commit-msg, prepare-commit-msg, post-*) bypass the
|
|
92
|
+
* runner because pre-commit's filter semantics don't apply to them.
|
|
93
|
+
*/
|
|
94
|
+
declare const buildHookCommand: (entry: PrekHookEntry, stage: string, builtin?: string) => string;
|
|
95
|
+
/**
|
|
96
|
+
* Convert a parsed prek config into a per-stage map of shell script bodies.
|
|
97
|
+
* Hooks we cannot translate (remote repos, language-specific toolchains) are
|
|
98
|
+
* reported back in `skippedHooks` for the caller to surface.
|
|
99
|
+
*/
|
|
100
|
+
declare const convertPrekConfig: (config: PrekConfig) => ConversionResult;
|
|
101
|
+
/**
|
|
102
|
+
* Parse a prek YAML config. Returns undefined if the content is empty or malformed.
|
|
103
|
+
*/
|
|
104
|
+
declare const parsePrekConfig: (content: string) => PrekConfig | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Load a prek config file from disk, dispatching to the YAML or TOML parser
|
|
107
|
+
* based on the extension. TOML parsing is delegated to `@visulima/fs/toml`
|
|
108
|
+
* (which wraps smol-toml), so we hit the same implementation the rest of the
|
|
109
|
+
* codebase uses for TOML.
|
|
110
|
+
*/
|
|
111
|
+
declare const loadPrekConfig: (configPath: string) => PrekConfig | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Merge collected additional_dependencies into the project's package.json
|
|
114
|
+
* devDependencies. Doesn't run install — just updates the manifest and asks
|
|
115
|
+
* the caller to run their package manager.
|
|
116
|
+
*/
|
|
117
|
+
declare const mergeAdditionalDependencies: (root: string, deps: ReadonlyArray<AdditionalDep>) => {
|
|
118
|
+
added: string[];
|
|
119
|
+
skipped: string[];
|
|
120
|
+
};
|
|
121
|
+
interface MigrateOptions {
|
|
122
|
+
dryRun?: boolean;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Migrates a prek / pre-commit framework configuration to vis hooks.
|
|
126
|
+
*/
|
|
127
|
+
declare const migrateFromPrek: (root: string, hooksDirectory: string, logger: MigrateLogger, options?: MigrateOptions) => InstallResult;
|
|
128
|
+
export type { AdditionalDep, ConversionResult, MigrateOptions, PrekConfig, PrekHookEntry, PrekRepoEntry, SkippedHook };
|
|
129
|
+
export { buildHookCommand, buildRunnerInvocation, convertPrekConfig, detectPrekConfig, loadPrekConfig, mapPrekStage, mergeAdditionalDependencies, migrateFromPrek, normalizeRepoKey, parseAdditionalDep, parsePrekConfig, REMOTE_HOOK_BUILTIN_MAP, resolveStages, };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface RunOptions {
|
|
2
|
+
allFiles?: boolean;
|
|
3
|
+
fromRef?: string;
|
|
4
|
+
lastCommit?: boolean;
|
|
5
|
+
stage?: string;
|
|
6
|
+
toRef?: string;
|
|
7
|
+
}
|
|
8
|
+
interface RunLogger {
|
|
9
|
+
info: (message: string) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const DEFAULT_STAGE = "pre-commit";
|
|
12
|
+
/**
|
|
13
|
+
* Invoke a previously-installed `.vis-hooks/{stage}` script directly,
|
|
14
|
+
* forwarding --all-files / --from-ref / --to-ref through environment variables
|
|
15
|
+
* that the bundled prek-runner honours. This makes CI usage trivial: run the
|
|
16
|
+
* same hook logic that fires at commit time, but over an explicit file set.
|
|
17
|
+
*/
|
|
18
|
+
declare const runHookStage: (root: string, hooksDirectory: string, options: RunOptions, logger: RunLogger) => number;
|
|
19
|
+
declare const runRun: (hooksDirectory: string, options: RunOptions, logger: RunLogger) => void;
|
|
20
|
+
export type { RunLogger, RunOptions };
|
|
21
|
+
export { DEFAULT_STAGE, runHookStage, runRun };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface ValidationIssue {
|
|
2
|
+
kind: "error" | "warning";
|
|
3
|
+
message: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
}
|
|
6
|
+
interface ValidationResult {
|
|
7
|
+
issues: ValidationIssue[];
|
|
8
|
+
ok: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const validateHooks: (root: string, hooksDirectory: string) => ValidationResult;
|
|
11
|
+
declare const formatValidationResult: (result: ValidationResult, hooksDirectory: string) => string[];
|
|
12
|
+
declare const runValidate: (hooksDirectory: string, logger: {
|
|
13
|
+
info: (message: string) => void;
|
|
14
|
+
warn: (message: string) => void;
|
|
15
|
+
}) => void;
|
|
16
|
+
export type { ValidationIssue, ValidationResult };
|
|
17
|
+
export { formatValidationResult, runValidate, validateHooks };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Command } from "@visulima/cerebro";
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const migrateCommands: Command[];
|
|
3
|
+
export default migrateCommands;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/vis",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"description": "A CLI task runner for monorepo workspaces, powered by @visulima/task-runner",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@visulima/secret-scanner": "1.0.0-alpha.1",
|
|
80
80
|
"@visulima/string": "3.0.0-alpha.11",
|
|
81
81
|
"@visulima/task-runner": "1.0.0-alpha.7",
|
|
82
|
-
"@visulima/tui": "1.0.0-alpha.
|
|
82
|
+
"@visulima/tui": "1.0.0-alpha.4",
|
|
83
83
|
"execa": "^9.6.1",
|
|
84
84
|
"giget": "^3.2.0",
|
|
85
85
|
"hookable": "^6.1.1",
|
|
@@ -88,20 +88,22 @@
|
|
|
88
88
|
"module-replacements": "^2.11.0",
|
|
89
89
|
"module-replacements-codemods": "^1.2.1",
|
|
90
90
|
"react": "19.2.5",
|
|
91
|
+
"react-reconciler": ">=0.33.0",
|
|
91
92
|
"semver": "^7.7.4",
|
|
93
|
+
"smol-toml": "^1.6.1",
|
|
92
94
|
"validate-npm-package-name": "^7.0.2",
|
|
93
95
|
"yaml": "2.8.3",
|
|
94
96
|
"zeptomatch": "^2.1.0"
|
|
95
97
|
},
|
|
96
98
|
"optionalDependencies": {
|
|
97
|
-
"@visulima/vis-binding-darwin-arm64": "1.0.0-alpha.
|
|
98
|
-
"@visulima/vis-binding-darwin-x64": "1.0.0-alpha.
|
|
99
|
-
"@visulima/vis-binding-linux-
|
|
100
|
-
"@visulima/vis-binding-linux-
|
|
101
|
-
"@visulima/vis-binding-linux-
|
|
102
|
-
"@visulima/vis-binding-
|
|
103
|
-
"@visulima/vis-binding-
|
|
104
|
-
"@visulima/vis-binding-win32-
|
|
99
|
+
"@visulima/vis-binding-darwin-arm64": "1.0.0-alpha.8",
|
|
100
|
+
"@visulima/vis-binding-darwin-x64": "1.0.0-alpha.8",
|
|
101
|
+
"@visulima/vis-binding-linux-x64-gnu": "1.0.0-alpha.8",
|
|
102
|
+
"@visulima/vis-binding-linux-arm64-gnu": "1.0.0-alpha.8",
|
|
103
|
+
"@visulima/vis-binding-linux-arm64-musl": "1.0.0-alpha.8",
|
|
104
|
+
"@visulima/vis-binding-linux-x64-musl": "1.0.0-alpha.8",
|
|
105
|
+
"@visulima/vis-binding-win32-x64-msvc": "1.0.0-alpha.8",
|
|
106
|
+
"@visulima/vis-binding-win32-arm64-msvc": "1.0.0-alpha.8"
|
|
105
107
|
},
|
|
106
108
|
"engines": {
|
|
107
109
|
"node": "^22.14.0 || >=24.10.0"
|