@visulima/task-runner 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +61 -0
- package/README.md +193 -51
- package/dist/affected.d.ts +37 -3
- package/dist/command-parser/expand-arguments.d.ts +11 -0
- package/dist/command-parser/expand-shortcut.d.ts +15 -0
- package/dist/command-parser/expand-wildcard.d.ts +13 -0
- package/dist/command-parser/index.d.ts +18 -0
- package/dist/command-parser/strip-quotes.d.ts +6 -0
- package/dist/concurrent-fallback.d.ts +16 -0
- package/dist/concurrent.d.ts +23 -0
- package/dist/detect-shell.d.ts +19 -0
- package/dist/flow-controllers/index.d.ts +7 -0
- package/dist/flow-controllers/input-handler.d.ts +44 -0
- package/dist/flow-controllers/log-timings.d.ts +18 -0
- package/dist/flow-controllers/restart-process.d.ts +21 -0
- package/dist/flow-controllers/teardown.d.ts +22 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.js +26 -12
- package/dist/native-binding.d.ts +44 -2
- package/dist/packem_shared/{Cache-IYpTYVUC.js → Cache-C23LywYn.js} +2 -3
- package/dist/packem_shared/{FingerprintManager-D6Y0erg-.js → FingerprintManager-Cu-ta9ee.js} +0 -1
- package/dist/packem_shared/{IncrementalFileHasher-Ds3J6dgb.js → IncrementalFileHasher-Cm_kJY5V.js} +1 -1
- package/dist/packem_shared/{TaskOrchestrator-BvYs3ONw.js → TaskOrchestrator-lLn-PH1m.js} +2 -5
- package/dist/packem_shared/TerminalBuffer-D6zP2zLh.js +250 -0
- package/dist/packem_shared/{filterAffectedTasks-I-18zPg6.js → buildForwardDependencyMap-Cu08NWB1.js} +58 -20
- package/dist/packem_shared/{computeTaskHash-BoCnnvIJ.js → computeTaskHash-B2SVZqgp.js} +1 -2
- package/dist/packem_shared/createInputHandler-DTfePcTG.js +37 -0
- package/dist/packem_shared/{defaultTaskRunner-CrW4v5Ye.js → defaultTaskRunner-X1MIynHu.js} +6 -7
- package/dist/packem_shared/detectScriptShell-CR-xXKA4.js +53 -0
- package/dist/packem_shared/enforceProjectConstraints-_Ej0zHch.js +90 -0
- package/dist/packem_shared/expandArguments-0AwD2BIA.js +26 -0
- package/dist/packem_shared/expandShortcut-BVG05ee4.js +23 -0
- package/dist/packem_shared/expandWildcard-B0xN_knq.js +107 -0
- package/dist/packem_shared/{findCycle-DF4_BRdO.js → findCycle-DefgNYhg.js} +1 -1
- package/dist/packem_shared/formatTimingTable-3qtCM552.js +46 -0
- package/dist/packem_shared/isNativeAvailable-BpD28A6Z.js +44 -0
- package/dist/packem_shared/parseCommands-D-IgF8Zh.js +26 -0
- package/dist/packem_shared/{TaskScheduler-CJilHDta.js → parsePartition-C4-P5RjK.js} +44 -1
- package/dist/packem_shared/{projectGraphToDot-VdTjHcVp.js → projectGraphToDot-C8uYeaPo.js} +20 -3
- package/dist/packem_shared/runConcurrentFallback-3q46z4AS.js +357 -0
- package/dist/packem_shared/runConcurrently-ATDwJNR6.js +67 -0
- package/dist/packem_shared/runTeardown-BAezH79J.js +49 -0
- package/dist/packem_shared/stripQuotes-Cey-zwFf.js +9 -0
- package/dist/packem_shared/withRestart-BREjRJa4.js +49 -0
- package/dist/project-constraints.d.ts +16 -0
- package/dist/task-scheduler.d.ts +23 -0
- package/dist/terminal-buffer.d.ts +29 -0
- package/dist/types.d.ts +220 -1
- package/index.js +599 -0
- package/package.json +14 -13
- package/binding.js +0 -204
- package/dist/packem_shared/isNativeAvailable-BWhnZ4ES.js +0 -19
- package/dist/packem_shared/{RemoteCache-BDqrnDEi.js → RemoteCache-BFceSe4a.js} +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -160,6 +160,81 @@ export interface EnvironmentInput {
|
|
|
160
160
|
export interface ExternalDependencyInput {
|
|
161
161
|
externalDependencies: string[];
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Defines tag-based dependency rules.
|
|
165
|
+
* Each key is a tag name. The value is the list of tags that a dependency
|
|
166
|
+
* must have at least one of, when the source project has that tag.
|
|
167
|
+
*
|
|
168
|
+
* Example: `{ "frontend": ["shared", "frontend"] }` means a project tagged
|
|
169
|
+
* "frontend" can only depend on projects tagged "shared" or "frontend".
|
|
170
|
+
*/
|
|
171
|
+
export type TagRelationships = Record<string, string[]>;
|
|
172
|
+
/**
|
|
173
|
+
* Defines project-type-based dependency rules.
|
|
174
|
+
*/
|
|
175
|
+
export interface TypeBoundaries {
|
|
176
|
+
/**
|
|
177
|
+
* Custom rules mapping project types to allowed dependency types.
|
|
178
|
+
* Example: `{ "application": ["library"] }` means applications can only
|
|
179
|
+
* depend on libraries.
|
|
180
|
+
*/
|
|
181
|
+
allowedDependencyTypes?: Record<string, string[]>;
|
|
182
|
+
/**
|
|
183
|
+
* When true, no project may depend on an "application" type project.
|
|
184
|
+
* Applications are typically deployment targets, not libraries.
|
|
185
|
+
* @default true
|
|
186
|
+
*/
|
|
187
|
+
enforceApplicationBoundary?: boolean;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Rules based on the dependency kind (dependencies vs devDependencies vs peerDependencies).
|
|
191
|
+
*/
|
|
192
|
+
export interface DependencyKindRules {
|
|
193
|
+
/**
|
|
194
|
+
* When true, a "library" project must not have workspace-internal devDependencies
|
|
195
|
+
* on other libraries that are also in its production dependencies.
|
|
196
|
+
* Prevents publishing libraries that silently rely on dev-only workspace packages.
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
noDevDependencyOnProductionDep?: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* When true, production `dependencies` must not point to "application" type projects.
|
|
202
|
+
* devDependencies on applications are allowed (e.g., for testing).
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
noProductionDependencyOnApplication?: boolean;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Configuration for project constraint enforcement.
|
|
209
|
+
*/
|
|
210
|
+
export interface ConstraintsConfig {
|
|
211
|
+
/** Rules based on the dependency kind (static vs devDependency vs peerDependency) */
|
|
212
|
+
dependencyKindRules?: DependencyKindRules;
|
|
213
|
+
/** Tag-based dependency rules */
|
|
214
|
+
tagRelationships?: TagRelationships;
|
|
215
|
+
/** Project-type-based dependency rules */
|
|
216
|
+
typeBoundaries?: TypeBoundaries;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A single constraint violation detected in the project graph.
|
|
220
|
+
*/
|
|
221
|
+
export interface ConstraintViolation {
|
|
222
|
+
/** The project being depended on */
|
|
223
|
+
dependencyProject: string;
|
|
224
|
+
/** Human-readable description of the violation */
|
|
225
|
+
message: string;
|
|
226
|
+
/** The type of rule that was violated */
|
|
227
|
+
rule: "dependency-kind" | "tag-relationship" | "type-boundary";
|
|
228
|
+
/** The project that has the invalid dependency */
|
|
229
|
+
sourceProject: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Controls how far to traverse the dependency graph in a given direction.
|
|
233
|
+
* - "none": Don't traverse — only directly changed projects are included.
|
|
234
|
+
* - "direct": Include only immediate neighbors (one hop).
|
|
235
|
+
* - "deep": Include all transitive neighbors (full chain).
|
|
236
|
+
*/
|
|
237
|
+
export type AffectedScope = "deep" | "direct" | "none";
|
|
163
238
|
/**
|
|
164
239
|
* Workspace configuration containing all project configurations.
|
|
165
240
|
*/
|
|
@@ -167,6 +242,15 @@ export interface WorkspaceConfiguration {
|
|
|
167
242
|
/** All projects in the workspace, keyed by project name */
|
|
168
243
|
projects: Record<string, ProjectConfiguration>;
|
|
169
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* The kind of dependency relationship between projects.
|
|
247
|
+
* - "static": Production dependency (from `dependencies` in package.json)
|
|
248
|
+
* - "dynamic": Dynamically resolved dependency (e.g., lazy imports)
|
|
249
|
+
* - "implicit": Declared via `implicitDependencies` in project config
|
|
250
|
+
* - "devDependency": Development-only dependency (from `devDependencies`)
|
|
251
|
+
* - "peerDependency": Peer dependency (from `peerDependencies`)
|
|
252
|
+
*/
|
|
253
|
+
export type DependencyType = "devDependency" | "dynamic" | "implicit" | "peerDependency" | "static";
|
|
170
254
|
/**
|
|
171
255
|
* A dependency relationship in the project graph.
|
|
172
256
|
*/
|
|
@@ -176,7 +260,7 @@ export interface ProjectGraphDependency {
|
|
|
176
260
|
/** The target project */
|
|
177
261
|
target: string;
|
|
178
262
|
/** The type of dependency */
|
|
179
|
-
type:
|
|
263
|
+
type: DependencyType;
|
|
180
264
|
}
|
|
181
265
|
/**
|
|
182
266
|
* A node in the project graph.
|
|
@@ -370,6 +454,141 @@ export interface TaskRunnerContext {
|
|
|
370
454
|
/** The workspace root directory */
|
|
371
455
|
workspaceRoot: string;
|
|
372
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Input for a concurrent command -- either a string or a config object.
|
|
459
|
+
*/
|
|
460
|
+
export type ConcurrentCommandInput = string | {
|
|
461
|
+
command: string;
|
|
462
|
+
cwd?: string;
|
|
463
|
+
env?: Record<string, string>;
|
|
464
|
+
name?: string;
|
|
465
|
+
stdin?: "inherit" | "null" | "pipe" | "pty";
|
|
466
|
+
/** Initial PTY dimensions (only used when stdin is "pty"). */
|
|
467
|
+
ptySize?: {
|
|
468
|
+
cols: number;
|
|
469
|
+
rows: number;
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* Configuration for a single command to run concurrently.
|
|
474
|
+
*/
|
|
475
|
+
export interface ConcurrentCommandConfig {
|
|
476
|
+
/** The command string to execute (passed to shell). */
|
|
477
|
+
command: string;
|
|
478
|
+
/** Working directory for the command. */
|
|
479
|
+
cwd?: string;
|
|
480
|
+
/** Additional environment variables merged with process env. */
|
|
481
|
+
env?: Record<string, string>;
|
|
482
|
+
/** Human-readable name for this command (used in prefixes/logs). */
|
|
483
|
+
name?: string;
|
|
484
|
+
/** Whether to use shell execution (default: true). */
|
|
485
|
+
shell?: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* Stdin mode for the child process.
|
|
488
|
+
* - "null" (default): stdin closed, child cannot read input
|
|
489
|
+
* - "pipe": stdin is piped, can be written to programmatically
|
|
490
|
+
* - "inherit": child inherits parent's stdin (for interactive commands like vite dev)
|
|
491
|
+
* - "pty": child runs inside a pseudo-terminal (isatty() returns true, enables interactive prompts)
|
|
492
|
+
*/
|
|
493
|
+
stdin?: "inherit" | "null" | "pipe" | "pty";
|
|
494
|
+
/**
|
|
495
|
+
* Initial PTY dimensions. Only used when stdin is "pty".
|
|
496
|
+
* Defaults to 80x24 if not specified.
|
|
497
|
+
*/
|
|
498
|
+
ptySize?: {
|
|
499
|
+
cols: number;
|
|
500
|
+
rows: number;
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Options controlling the concurrent runner behavior.
|
|
505
|
+
*/
|
|
506
|
+
export interface ConcurrentRunnerOptions {
|
|
507
|
+
/** Conditions under which to kill other processes: "success", "failure". */
|
|
508
|
+
killOthers?: ("failure" | "success")[];
|
|
509
|
+
/** Signal to send when killing processes (default: "SIGTERM"). */
|
|
510
|
+
killSignal?: string;
|
|
511
|
+
/** Milliseconds to wait after kill signal before sending SIGKILL (default: 5000). */
|
|
512
|
+
killTimeout?: number;
|
|
513
|
+
/** Maximum number of processes to run simultaneously. 0 = unlimited. */
|
|
514
|
+
maxProcesses?: number;
|
|
515
|
+
/** Callback for real-time process events. */
|
|
516
|
+
onEvent?: (event: ProcessEvent) => void;
|
|
517
|
+
/** Restart options for failed commands. */
|
|
518
|
+
restart?: {
|
|
519
|
+
/** Delay between restarts in ms. "exponential" for 2^attempt * 1000ms. */
|
|
520
|
+
delay?: number | "exponential";
|
|
521
|
+
/** Maximum restart attempts per command. 0 = no restarts. -1 = infinite. */
|
|
522
|
+
tries: number;
|
|
523
|
+
};
|
|
524
|
+
/**
|
|
525
|
+
* Custom shell path for command execution.
|
|
526
|
+
* Overrides the platform default (/bin/sh on Unix, cmd.exe on Windows).
|
|
527
|
+
* Automatically detected from npm's `script-shell` config if not set.
|
|
528
|
+
*/
|
|
529
|
+
shellPath?: string;
|
|
530
|
+
/** Success condition: "first", "last", "all", or "command-<name|index>". */
|
|
531
|
+
successCondition?: string;
|
|
532
|
+
/** Commands to run sequentially after all processes complete. */
|
|
533
|
+
teardown?: string[];
|
|
534
|
+
/** Working directory for teardown commands. */
|
|
535
|
+
teardownCwd?: string;
|
|
536
|
+
/** Print a timing summary table after completion. Default: false. */
|
|
537
|
+
timings?: boolean;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* An event emitted during concurrent execution.
|
|
541
|
+
*/
|
|
542
|
+
export interface ProcessEvent {
|
|
543
|
+
/** Command name (for close events). */
|
|
544
|
+
commandName?: string;
|
|
545
|
+
/** Duration in milliseconds (for close events). */
|
|
546
|
+
durationMs?: number;
|
|
547
|
+
/** Exit code (for close events). */
|
|
548
|
+
exitCode?: number;
|
|
549
|
+
/** Index of the command that produced this event. */
|
|
550
|
+
index: number;
|
|
551
|
+
/** Whether the process was killed (for close events). */
|
|
552
|
+
killed?: boolean;
|
|
553
|
+
/** Kill the child process/PTY. Only present on "started" events. */
|
|
554
|
+
kill?: (signal?: string) => void;
|
|
555
|
+
/** Event type: "stdout", "stderr", "close", "error", "started". */
|
|
556
|
+
kind: "close" | "error" | "started" | "stderr" | "stdout";
|
|
557
|
+
/** Error message (for error events). */
|
|
558
|
+
message?: string;
|
|
559
|
+
/** Resize the child's PTY. Only present on "started" events with stdin "pty". */
|
|
560
|
+
resize?: (cols: number, rows: number) => void;
|
|
561
|
+
/** Text content (for stdout/stderr events). */
|
|
562
|
+
text?: string;
|
|
563
|
+
/** Write data to the child's stdin (pipe) or PTY. Only present on "started" events. */
|
|
564
|
+
write?: (data: string) => void;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Result of a close event for a single command.
|
|
568
|
+
*/
|
|
569
|
+
export interface ConcurrentCloseEvent {
|
|
570
|
+
/** The command string that was executed. */
|
|
571
|
+
command: string;
|
|
572
|
+
/** Duration in milliseconds. */
|
|
573
|
+
durationMs: number;
|
|
574
|
+
/** Exit code. -1 if killed by signal. */
|
|
575
|
+
exitCode: number;
|
|
576
|
+
/** Index of the command. */
|
|
577
|
+
index: number;
|
|
578
|
+
/** Whether the process was forcefully killed. */
|
|
579
|
+
killed: boolean;
|
|
580
|
+
/** The command name (if provided). */
|
|
581
|
+
name?: string;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Overall result of a concurrent run.
|
|
585
|
+
*/
|
|
586
|
+
export interface ConcurrentRunResult {
|
|
587
|
+
/** Close events for all commands, in completion order. */
|
|
588
|
+
closeEvents: ConcurrentCloseEvent[];
|
|
589
|
+
/** Whether the run succeeded according to the success condition. */
|
|
590
|
+
success: boolean;
|
|
591
|
+
}
|
|
373
592
|
/**
|
|
374
593
|
* Interface for lifecycle event handlers.
|
|
375
594
|
*/
|