@halecraft/verify 1.0.0 → 1.2.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 +216 -13
- package/bin/verify.mjs +120 -134
- package/dist/index.d.ts +157 -11
- package/dist/index.js +495 -111
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -8,8 +8,13 @@ interface VerificationCommand {
|
|
|
8
8
|
args: string[];
|
|
9
9
|
/** Working directory (defaults to cwd) */
|
|
10
10
|
cwd?: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Environment variables to set.
|
|
13
|
+
* Set to null to explicitly unset an inherited variable.
|
|
14
|
+
*/
|
|
15
|
+
env?: Record<string, string | null>;
|
|
16
|
+
/** Timeout in milliseconds (process killed with SIGTERM if exceeded) */
|
|
17
|
+
timeout?: number;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Result from parsing command output
|
|
@@ -48,8 +53,8 @@ interface VerificationNode {
|
|
|
48
53
|
key: string;
|
|
49
54
|
/** Human-readable name */
|
|
50
55
|
name?: string;
|
|
51
|
-
/** Command to run (leaf nodes only) */
|
|
52
|
-
run?: VerificationCommand | string
|
|
56
|
+
/** Command to run (leaf nodes only) - string commands are executed via shell */
|
|
57
|
+
run?: VerificationCommand | string;
|
|
53
58
|
/** Child verification nodes */
|
|
54
59
|
children?: VerificationNode[];
|
|
55
60
|
/** Execution strategy for children (default: parallel) */
|
|
@@ -66,6 +71,20 @@ interface VerificationNode {
|
|
|
66
71
|
* Can specify task keys (e.g., "format") or full paths (e.g., "types:tsc").
|
|
67
72
|
*/
|
|
68
73
|
reportingDependsOn?: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Timeout in milliseconds for string commands.
|
|
76
|
+
* Process is killed with SIGTERM if exceeded.
|
|
77
|
+
* For VerificationCommand objects, use the timeout field on the command itself.
|
|
78
|
+
*/
|
|
79
|
+
timeout?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Environment variables for this task and its children.
|
|
82
|
+
* Inherits from parent tasks and config-level env.
|
|
83
|
+
* Child tasks can override parent values.
|
|
84
|
+
* Set to null to explicitly unset an inherited variable.
|
|
85
|
+
* For VerificationCommand objects, command-level env takes precedence.
|
|
86
|
+
*/
|
|
87
|
+
env?: Record<string, string | null>;
|
|
69
88
|
}
|
|
70
89
|
/**
|
|
71
90
|
* Options for the verification runner
|
|
@@ -85,6 +104,8 @@ interface VerifyOptions {
|
|
|
85
104
|
topLevelOnly?: boolean;
|
|
86
105
|
/** Force sequential output (disable live dashboard) */
|
|
87
106
|
noTty?: boolean;
|
|
107
|
+
/** Arguments to pass through to the underlying command (requires single task filter) */
|
|
108
|
+
passthrough?: string[];
|
|
88
109
|
}
|
|
89
110
|
/**
|
|
90
111
|
* Package discovery options for monorepos
|
|
@@ -107,6 +128,12 @@ interface VerifyConfig {
|
|
|
107
128
|
packages?: PackageDiscoveryOptions;
|
|
108
129
|
/** Default options */
|
|
109
130
|
options?: VerifyOptions;
|
|
131
|
+
/**
|
|
132
|
+
* Global environment variables applied to all tasks.
|
|
133
|
+
* Set to null to explicitly unset an inherited variable.
|
|
134
|
+
* Recommend setting NO_COLOR: "1" here to disable colors in output.
|
|
135
|
+
*/
|
|
136
|
+
env?: Record<string, string | null>;
|
|
110
137
|
}
|
|
111
138
|
/**
|
|
112
139
|
* Result of a single verification task
|
|
@@ -140,6 +167,11 @@ interface TaskResult {
|
|
|
140
167
|
* Only set when suppressed is true.
|
|
141
168
|
*/
|
|
142
169
|
suppressedBy?: string;
|
|
170
|
+
/**
|
|
171
|
+
* Whether this task was terminated due to timeout.
|
|
172
|
+
* Only set when the task exceeded its configured timeout.
|
|
173
|
+
*/
|
|
174
|
+
timedOut?: boolean;
|
|
143
175
|
}
|
|
144
176
|
/**
|
|
145
177
|
* Overall verification run result
|
|
@@ -157,6 +189,17 @@ interface VerifyResult {
|
|
|
157
189
|
tasks: TaskResult[];
|
|
158
190
|
}
|
|
159
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Error thrown when config validation fails
|
|
194
|
+
*/
|
|
195
|
+
declare class ConfigError extends Error {
|
|
196
|
+
readonly configPath?: string | undefined;
|
|
197
|
+
constructor(message: string, configPath?: string | undefined);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Validate a config object and return typed result
|
|
201
|
+
*/
|
|
202
|
+
declare function validateConfig(value: unknown, configPath?: string): VerifyConfig;
|
|
160
203
|
/**
|
|
161
204
|
* Helper function for defining config with type inference
|
|
162
205
|
*/
|
|
@@ -209,6 +252,53 @@ declare function discoverPackages(rootDir: string, options?: PackageDiscoveryOpt
|
|
|
209
252
|
*/
|
|
210
253
|
declare function hasPackageChanged(_packagePath: string, _baseBranch?: string): Promise<boolean>;
|
|
211
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Result of resolving a filter to a valid task path
|
|
257
|
+
*/
|
|
258
|
+
interface ResolvedFilter {
|
|
259
|
+
/** The original filter string provided by the user */
|
|
260
|
+
original: string;
|
|
261
|
+
/** The resolved full task path */
|
|
262
|
+
resolved: string;
|
|
263
|
+
/** Whether this was resolved via child shortcut (e.g., "tsc" → "types:tsc") */
|
|
264
|
+
wasShortcut: boolean;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Error thrown when a task filter doesn't match any existing task
|
|
268
|
+
*/
|
|
269
|
+
declare class TaskNotFoundError extends Error {
|
|
270
|
+
readonly filter: string;
|
|
271
|
+
readonly suggestion: string | undefined;
|
|
272
|
+
readonly availableTasks: string[];
|
|
273
|
+
readonly exitCode = 2;
|
|
274
|
+
constructor(filter: string, suggestion: string | undefined, availableTasks: string[]);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Error thrown when a task filter matches multiple tasks ambiguously
|
|
278
|
+
*/
|
|
279
|
+
declare class AmbiguousTaskError extends Error {
|
|
280
|
+
readonly filter: string;
|
|
281
|
+
readonly matches: string[];
|
|
282
|
+
readonly exitCode = 2;
|
|
283
|
+
constructor(filter: string, matches: string[]);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Find the single best suggestion using Levenshtein distance.
|
|
287
|
+
* Returns undefined if no good match (distance > threshold).
|
|
288
|
+
*/
|
|
289
|
+
declare function findBestSuggestion(availablePaths: string[], invalidFilter: string): string | undefined;
|
|
290
|
+
/**
|
|
291
|
+
* Resolve and validate all filters before running any tasks.
|
|
292
|
+
* Fails fast on first invalid filter.
|
|
293
|
+
*
|
|
294
|
+
* @param nodes - The verification task tree
|
|
295
|
+
* @param filters - User-provided filter strings
|
|
296
|
+
* @returns Array of resolved filters
|
|
297
|
+
* @throws TaskNotFoundError if a filter doesn't match any task
|
|
298
|
+
* @throws AmbiguousTaskError if a filter matches multiple tasks
|
|
299
|
+
*/
|
|
300
|
+
declare function resolveFilters(nodes: VerificationNode[], filters: string[]): ResolvedFilter[];
|
|
301
|
+
|
|
212
302
|
/**
|
|
213
303
|
* A detected task candidate from package.json
|
|
214
304
|
*/
|
|
@@ -233,7 +323,7 @@ interface DetectedTask {
|
|
|
233
323
|
}
|
|
234
324
|
/**
|
|
235
325
|
* Detect tasks with proper package manager commands
|
|
236
|
-
* Uses optimized direct
|
|
326
|
+
* Uses optimized direct binary names when possible, falls back to package manager
|
|
237
327
|
*/
|
|
238
328
|
declare function detectTasks(cwd: string): DetectedTask[];
|
|
239
329
|
|
|
@@ -308,6 +398,35 @@ declare const tscParser: OutputParser;
|
|
|
308
398
|
*/
|
|
309
399
|
declare const vitestParser: OutputParser;
|
|
310
400
|
|
|
401
|
+
/**
|
|
402
|
+
* Parser ID constants for type-safe parser references.
|
|
403
|
+
* Use these instead of magic strings when specifying parsers in config.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* import { parsers } from "@halecraft/verify"
|
|
408
|
+
*
|
|
409
|
+
* export default defineConfig({
|
|
410
|
+
* tasks: [
|
|
411
|
+
* { key: "test", run: "vitest run", parser: parsers.vitest },
|
|
412
|
+
* ],
|
|
413
|
+
* })
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
declare const parsers: {
|
|
417
|
+
/** Vitest/Jest test runner output parser */
|
|
418
|
+
readonly vitest: "vitest";
|
|
419
|
+
/** TypeScript compiler (tsc/tsgo) output parser */
|
|
420
|
+
readonly tsc: "tsc";
|
|
421
|
+
/** Biome/ESLint linter output parser */
|
|
422
|
+
readonly biome: "biome";
|
|
423
|
+
/** Go test runner output parser */
|
|
424
|
+
readonly gotest: "gotest";
|
|
425
|
+
/** Generic fallback parser */
|
|
426
|
+
readonly generic: "generic";
|
|
427
|
+
};
|
|
428
|
+
/** Type for valid parser IDs */
|
|
429
|
+
type ParserId = (typeof parsers)[keyof typeof parsers];
|
|
311
430
|
/**
|
|
312
431
|
* Registry for output parsers
|
|
313
432
|
*/
|
|
@@ -325,7 +444,7 @@ declare class ParserRegistry {
|
|
|
325
444
|
/**
|
|
326
445
|
* Auto-detect parser based on command
|
|
327
446
|
*/
|
|
328
|
-
detectParser(cmd: string):
|
|
447
|
+
detectParser(cmd: string): ParserId;
|
|
329
448
|
/**
|
|
330
449
|
* Parse output using the specified or auto-detected parser
|
|
331
450
|
*/
|
|
@@ -387,9 +506,9 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
387
506
|
*/
|
|
388
507
|
protected getTaskDepth(path: string): number;
|
|
389
508
|
/**
|
|
390
|
-
*
|
|
509
|
+
* Collect task depths from verification tree using walkNodes
|
|
391
510
|
*/
|
|
392
|
-
protected collectTaskDepths(nodes: VerificationNode[]
|
|
511
|
+
protected collectTaskDepths(nodes: VerificationNode[]): void;
|
|
393
512
|
/**
|
|
394
513
|
* Extract summary from task result
|
|
395
514
|
*/
|
|
@@ -426,7 +545,7 @@ declare class LiveDashboardReporter extends BaseReporter {
|
|
|
426
545
|
*/
|
|
427
546
|
onStart(tasks: VerificationNode[]): void;
|
|
428
547
|
/**
|
|
429
|
-
*
|
|
548
|
+
* Collect tasks from verification tree using walkNodes
|
|
430
549
|
*/
|
|
431
550
|
private collectTasks;
|
|
432
551
|
/**
|
|
@@ -505,7 +624,8 @@ declare class VerificationRunner {
|
|
|
505
624
|
private options;
|
|
506
625
|
private callbacks;
|
|
507
626
|
private dependencyTracker;
|
|
508
|
-
|
|
627
|
+
private configEnv;
|
|
628
|
+
constructor(options?: VerifyOptions, registry?: ParserRegistry, callbacks?: RunnerCallbacks, configEnv?: Record<string, string | null>);
|
|
509
629
|
/**
|
|
510
630
|
* Run all verification tasks
|
|
511
631
|
*/
|
|
@@ -520,6 +640,32 @@ declare class VerificationRunner {
|
|
|
520
640
|
private runNode;
|
|
521
641
|
}
|
|
522
642
|
|
|
643
|
+
/**
|
|
644
|
+
* Path separator used in task paths
|
|
645
|
+
*/
|
|
646
|
+
declare const PATH_SEPARATOR = ":";
|
|
647
|
+
/**
|
|
648
|
+
* Build a task path from parent path and key
|
|
649
|
+
*/
|
|
650
|
+
declare function buildTaskPath(parentPath: string, key: string): string;
|
|
651
|
+
/**
|
|
652
|
+
* Visitor function called for each node during tree traversal
|
|
653
|
+
*/
|
|
654
|
+
type NodeVisitor = (node: VerificationNode, path: string, depth: number) => void;
|
|
655
|
+
/**
|
|
656
|
+
* Walk all nodes in a verification tree in depth-first order
|
|
657
|
+
*
|
|
658
|
+
* @param nodes - The nodes to walk
|
|
659
|
+
* @param visitor - Function called for each node with (node, path, depth)
|
|
660
|
+
* @param parentPath - Parent path prefix (used for recursion)
|
|
661
|
+
* @param depth - Current depth (used for recursion)
|
|
662
|
+
*/
|
|
663
|
+
declare function walkNodes(nodes: VerificationNode[], visitor: NodeVisitor, parentPath?: string, depth?: number): void;
|
|
664
|
+
/**
|
|
665
|
+
* Collect all task paths from a verification tree
|
|
666
|
+
*/
|
|
667
|
+
declare function collectPaths(nodes: VerificationNode[]): string[];
|
|
668
|
+
|
|
523
669
|
/**
|
|
524
670
|
* Run verification with the given config and options
|
|
525
671
|
*/
|
|
@@ -529,4 +675,4 @@ declare function verify(config: VerifyConfig, cliOptions?: Partial<VerifyOptions
|
|
|
529
675
|
*/
|
|
530
676
|
declare function verifyFromConfig(cwd?: string, cliOptions?: Partial<VerifyOptions>): Promise<VerifyResult>;
|
|
531
677
|
|
|
532
|
-
export { type DetectedTask, type DiscoveredPackage, type ExecutionStrategy, type InitOptions, type InitResult, JSONReporter, LiveDashboardReporter, type OutputFormat, type OutputParser, type PackageDiscoveryOptions, type ParsedResult, ParserRegistry, QuietReporter, type Reporter, type RunnerCallbacks, SequentialReporter, SequentialReporter as TTYReporter, type TaskResult, type VerificationCommand, type VerificationNode, VerificationRunner, type VerifyConfig, type VerifyOptions, type VerifyResult, biomeParser, createReporter, defaultRegistry, defineConfig, defineTask, detectTasks, discoverPackages, findConfigFile, generateConfigContent, genericParser, gotestParser, hasPackageChanged, loadConfig, loadConfigFromCwd, mergeOptions, runInit, tscParser, verify, verifyFromConfig, vitestParser };
|
|
678
|
+
export { AmbiguousTaskError, ConfigError, type DetectedTask, type DiscoveredPackage, type ExecutionStrategy, type InitOptions, type InitResult, JSONReporter, LiveDashboardReporter, type NodeVisitor, type OutputFormat, type OutputParser, PATH_SEPARATOR, type PackageDiscoveryOptions, type ParsedResult, type ParserId, ParserRegistry, QuietReporter, type Reporter, type ResolvedFilter, type RunnerCallbacks, SequentialReporter, SequentialReporter as TTYReporter, TaskNotFoundError, type TaskResult, type VerificationCommand, type VerificationNode, VerificationRunner, type VerifyConfig, type VerifyOptions, type VerifyResult, biomeParser, buildTaskPath, collectPaths, createReporter, defaultRegistry, defineConfig, defineTask, detectTasks, discoverPackages, findBestSuggestion, findConfigFile, generateConfigContent, genericParser, gotestParser, hasPackageChanged, loadConfig, loadConfigFromCwd, mergeOptions, parsers, resolveFilters, runInit, tscParser, validateConfig, verify, verifyFromConfig, vitestParser, walkNodes };
|