bun-workspaces 1.8.2 → 1.9.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 +51 -13
- package/package.json +1 -1
- package/src/2392.mjs +184 -3
- package/src/5166.mjs +1 -0
- package/src/8529.mjs +10 -0
- package/src/affected/affectedBaseRef.mjs +12 -0
- package/src/affected/externalDependencyChanges.mjs +47 -0
- package/src/affected/fileAffectedWorkspaces.mjs +145 -53
- package/src/affected/gitAffectedFiles.mjs +44 -1
- package/src/affected/gitAffectedWorkspaces.mjs +73 -3
- package/src/affected/index.mjs +2 -0
- package/src/ai/mcp/serverState.mjs +1 -1
- package/src/cli/commands/commandHandlerUtils.mjs +12 -7
- package/src/cli/commands/commands.mjs +4 -1
- package/src/cli/commands/handleSimpleCommands.mjs +2 -2
- package/src/cli/commands/listAffected.mjs +184 -0
- package/src/cli/commands/runScript/handleRunAffected.mjs +99 -0
- package/src/cli/commands/runScript/handleRunScript.mjs +19 -202
- package/src/cli/commands/runScript/index.mjs +1 -0
- package/src/cli/commands/runScript/scriptRunFlow.mjs +213 -0
- package/src/cli/index.d.ts +749 -134
- package/src/config/public.d.ts +66 -2
- package/src/config/rootConfig/rootConfig.mjs +4 -0
- package/src/config/rootConfig/rootConfigSchema.mjs +3 -0
- package/src/config/workspaceConfig/mergeWorkspaceConfig.mjs +33 -19
- package/src/config/workspaceConfig/workspaceConfig.mjs +3 -0
- package/src/config/workspaceConfig/workspaceConfigSchema.mjs +26 -0
- package/src/index.d.ts +307 -5
- package/src/index.mjs +1 -0
- package/src/internal/bun/bunLock.mjs +33 -0
- package/src/internal/generated/aiDocs/docs.mjs +152 -3
- package/src/internal/generated/ajv/validateRootConfig.mjs +1 -1
- package/src/internal/generated/ajv/validateWorkspaceConfig.mjs +1 -1
- package/src/project/implementations/fileSystemProject/affectedWorkspaces.mjs +225 -0
- package/src/project/implementations/{fileSystemProject.mjs → fileSystemProject/fileSystemProject.mjs} +169 -12
- package/src/project/implementations/fileSystemProject/index.mjs +4 -0
- package/src/project/implementations/memoryProject.mjs +1 -0
- package/src/project/index.mjs +1 -1
- package/src/rslib-runtime.mjs +0 -31
- package/src/workspaces/applyWorkspacePatternConfigs.mjs +10 -1
- package/src/workspaces/dependencyGraph/resolveDependencies.mjs +68 -18
- package/src/workspaces/findWorkspaces.mjs +1 -0
- package/src/workspaces/workspace.mjs +8 -2
package/src/cli/index.d.ts
CHANGED
|
@@ -42,6 +42,47 @@ export type WorkspaceDependenciesRule = {
|
|
|
42
42
|
export type WorkspaceRules = {
|
|
43
43
|
workspaceDependencies?: WorkspaceDependenciesRule;
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Configured inputs for a script.
|
|
47
|
+
*
|
|
48
|
+
* These can be used to specify the files and workspace patterns
|
|
49
|
+
* that should be considered inputs for the script.
|
|
50
|
+
*
|
|
51
|
+
* The default inputs when not provided are all git-trackable files in the workspace.
|
|
52
|
+
*/
|
|
53
|
+
export type WorkspaceInputsConfig = {
|
|
54
|
+
/**
|
|
55
|
+
* File paths, directory paths, or globs relative to the workspace's path.
|
|
56
|
+
*
|
|
57
|
+
* Prefix with `!` to exclude.
|
|
58
|
+
*
|
|
59
|
+
* The default inputs when not provided are all git-trackable files in the workspace.
|
|
60
|
+
*
|
|
61
|
+
* Files that are not git-trackable are not considered inputs.
|
|
62
|
+
*
|
|
63
|
+
* Paths with a leading `/` are relative to the project root.
|
|
64
|
+
*/
|
|
65
|
+
files?: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Matched workspaces are treated as inputs for the script.
|
|
68
|
+
*
|
|
69
|
+
* For example, when workspaces are provided here, they will
|
|
70
|
+
* be treated like dependencies in the affected workspace resolution.
|
|
71
|
+
*/
|
|
72
|
+
workspacePatterns?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Filters which of the workspace's declared external (non-workspace) deps
|
|
75
|
+
* participate in lockfile-change detection.
|
|
76
|
+
*
|
|
77
|
+
* - When omitted, every declared external dep participates (default).
|
|
78
|
+
* - When set to an empty array, no external deps participate (the workspace
|
|
79
|
+
* will not be flagged from a lockfile change unless something else makes it so).
|
|
80
|
+
* - When set to a non-empty list of package names, only the listed names
|
|
81
|
+
* participate. Names not present in the workspace's actual
|
|
82
|
+
* `externalDependencies` are silently ignored.
|
|
83
|
+
*/
|
|
84
|
+
externalDependencies?: string[];
|
|
85
|
+
};
|
|
45
86
|
/** Configuration that applies to a specific package.json script */
|
|
46
87
|
export type ScriptConfig = {
|
|
47
88
|
/**
|
|
@@ -51,6 +92,15 @@ export type ScriptConfig = {
|
|
|
51
92
|
* of their relative path from the project root.
|
|
52
93
|
*/
|
|
53
94
|
order?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Inputs for the script.
|
|
97
|
+
*
|
|
98
|
+
* These can be used to specify the files and workspace patterns
|
|
99
|
+
* that should be considered inputs for the script.
|
|
100
|
+
*
|
|
101
|
+
* The default inputs when not provided are all git-trackable files in the workspace.
|
|
102
|
+
*/
|
|
103
|
+
inputs?: WorkspaceInputsConfig;
|
|
54
104
|
};
|
|
55
105
|
/** Configuration that applies to a specific workspace */
|
|
56
106
|
export type WorkspaceConfig = {
|
|
@@ -75,12 +125,18 @@ export type WorkspaceConfig = {
|
|
|
75
125
|
* Rules that validate the workspace.
|
|
76
126
|
*/
|
|
77
127
|
rules?: WorkspaceRules;
|
|
128
|
+
/**
|
|
129
|
+
* The default inputs for the workspace
|
|
130
|
+
* applied to all scripts that don't configure their own inputs.
|
|
131
|
+
*/
|
|
132
|
+
defaultInputs?: WorkspaceInputsConfig;
|
|
78
133
|
};
|
|
79
134
|
export type ResolvedWorkspaceConfig = {
|
|
80
135
|
aliases: string[];
|
|
81
136
|
tags: string[];
|
|
82
137
|
scripts: Record<string, ScriptConfig>;
|
|
83
138
|
rules: WorkspaceRules;
|
|
139
|
+
defaultInputs?: WorkspaceInputsConfig;
|
|
84
140
|
};
|
|
85
141
|
/** Static workspace context passed to a {@link WorkspacePatternConfigFactory}.
|
|
86
142
|
* Contains only the immutable, package.json-derived fields — not config-derived fields like aliases or tags. */
|
|
@@ -112,6 +168,7 @@ export type ResolvedRootConfig = {
|
|
|
112
168
|
shell: ScriptShellOption;
|
|
113
169
|
/** `undefined` means the value was not set in the input config */
|
|
114
170
|
includeRootWorkspace: boolean | undefined;
|
|
171
|
+
affectedBaseRef: string;
|
|
115
172
|
};
|
|
116
173
|
workspacePatternConfigs: WorkspacePatternConfigEntry[];
|
|
117
174
|
};
|
|
@@ -143,6 +200,39 @@ export interface MultiProcessOutput<Metadata extends object = object> {
|
|
|
143
200
|
bytes(): BytesOutput<Metadata>;
|
|
144
201
|
text(): TextOutput<Metadata>;
|
|
145
202
|
}
|
|
203
|
+
/** Catalog reference info attached to an `ExternalDependency` that uses a `catalog:` ref */
|
|
204
|
+
export type ExternalDependencyCatalog = {
|
|
205
|
+
/** Catalog name from the `catalog:<name>` ref. Empty string for the default catalog (`catalog:`). */
|
|
206
|
+
name: string;
|
|
207
|
+
};
|
|
208
|
+
declare const EXTERNAL_DEPENDENCY_SOURCES: readonly [
|
|
209
|
+
"dependencies",
|
|
210
|
+
"devDependencies",
|
|
211
|
+
"peerDependencies",
|
|
212
|
+
"optionalDependencies",
|
|
213
|
+
];
|
|
214
|
+
export type ExternalDependencySource =
|
|
215
|
+
(typeof EXTERNAL_DEPENDENCY_SOURCES)[number];
|
|
216
|
+
/** A non-workspace package the workspace declares (resolved via package.json + catalogs) */
|
|
217
|
+
export type ExternalDependency = {
|
|
218
|
+
/** The package name as it appears in `node_modules` */
|
|
219
|
+
name: string;
|
|
220
|
+
/**
|
|
221
|
+
* Version specifier from `package.json`, with `catalog:`/`catalog:<name>` references
|
|
222
|
+
* resolved to the catalog's value. If the catalog reference cannot be resolved, the
|
|
223
|
+
* literal `catalog:` / `catalog:<name>` string is preserved.
|
|
224
|
+
*/
|
|
225
|
+
version: string;
|
|
226
|
+
/**
|
|
227
|
+
* Which `package.json` dependency map this dep was declared in. When a dep
|
|
228
|
+
* appears in multiple maps, `dependencies` wins over the others, and any
|
|
229
|
+
* non-`devDependencies` source wins over `devDependencies`. One entry per
|
|
230
|
+
* unique name.
|
|
231
|
+
*/
|
|
232
|
+
source: ExternalDependencySource;
|
|
233
|
+
/** Present when the dep was declared via a `catalog:` reference in `package.json` */
|
|
234
|
+
catalog?: ExternalDependencyCatalog;
|
|
235
|
+
};
|
|
146
236
|
/** Metadata about a nested package within a Bun monorepo */
|
|
147
237
|
export type Workspace = {
|
|
148
238
|
/** The name of the workspace from its `package.json` */
|
|
@@ -163,6 +253,8 @@ export type Workspace = {
|
|
|
163
253
|
dependencies: string[];
|
|
164
254
|
/** Names of workspaces that depend on this workspace */
|
|
165
255
|
dependents: string[];
|
|
256
|
+
/** Non-workspace package dependencies declared by this workspace */
|
|
257
|
+
externalDependencies: ExternalDependency[];
|
|
166
258
|
};
|
|
167
259
|
declare const WORKSPACE_SCRIPT_COMMAND_METHODS: readonly ["cd", "filter"];
|
|
168
260
|
export type WorkspaceScriptCommandMethod =
|
|
@@ -295,134 +387,6 @@ declare abstract class ProjectBase implements Project {
|
|
|
295
387
|
options: CreateProjectScriptCommandOptions,
|
|
296
388
|
): CreateProjectScriptCommandResult;
|
|
297
389
|
}
|
|
298
|
-
/** Arguments for {@link createFileSystemProject} */
|
|
299
|
-
export type CreateFileSystemProjectOptions = {
|
|
300
|
-
/** The directory containing the root package.json. Often the same root as a git repository. Relative to process.cwd(). The default is process.cwd(). */
|
|
301
|
-
rootDirectory?: string;
|
|
302
|
-
/**
|
|
303
|
-
* The name of the project.
|
|
304
|
-
*
|
|
305
|
-
* By default will use the root package.json name
|
|
306
|
-
*/
|
|
307
|
-
name?: string;
|
|
308
|
-
/** Whether to include the root workspace as a normal workspace. This overrides any config or env var settings. */
|
|
309
|
-
includeRootWorkspace?: boolean;
|
|
310
|
-
};
|
|
311
|
-
export type InlineScriptOptions = {
|
|
312
|
-
/** A name to act as a label for the inline script */
|
|
313
|
-
scriptName?: string;
|
|
314
|
-
/** Whether to use the system shell or Bun shell */
|
|
315
|
-
shell?: ShellOption;
|
|
316
|
-
};
|
|
317
|
-
/** Arguments for `FileSystemProject.runWorkspaceScript` */
|
|
318
|
-
export type RunWorkspaceScriptOptions = {
|
|
319
|
-
/** The name of the workspace to run the script in */
|
|
320
|
-
workspaceNameOrAlias: string;
|
|
321
|
-
/** The name of the script to run, or an inline command when `inline` is true */
|
|
322
|
-
script: string;
|
|
323
|
-
/** Whether to run the script as an inline command */
|
|
324
|
-
inline?: boolean | InlineScriptOptions;
|
|
325
|
-
/** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
|
|
326
|
-
args?: string | string[];
|
|
327
|
-
/** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
|
|
328
|
-
ignoreOutput?: boolean;
|
|
329
|
-
};
|
|
330
|
-
/** Metadata associated with a workspace script */
|
|
331
|
-
export type RunWorkspaceScriptMetadata = {
|
|
332
|
-
/** The workspace that the script was run in */
|
|
333
|
-
workspace: Workspace;
|
|
334
|
-
};
|
|
335
|
-
export type RunWorkspaceScriptExit = Simplify<
|
|
336
|
-
RunScriptExit<RunWorkspaceScriptMetadata>
|
|
337
|
-
>;
|
|
338
|
-
export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
|
|
339
|
-
RunWorkspaceScriptMetadata & {
|
|
340
|
-
streamName: OutputStreamName;
|
|
341
|
-
}
|
|
342
|
-
>;
|
|
343
|
-
/** Result of `FileSystemProject.runWorkspaceScript` */
|
|
344
|
-
export type RunWorkspaceScriptResult = {
|
|
345
|
-
/** Use to get the output of the script */
|
|
346
|
-
output: RunWorkspaceScriptProcessOutput;
|
|
347
|
-
/** The exit result of the script */
|
|
348
|
-
exit: Promise<RunWorkspaceScriptExit>;
|
|
349
|
-
};
|
|
350
|
-
export type ParallelOption = boolean | RunScriptsParallelOptions;
|
|
351
|
-
export type ScriptEventMetadata = {
|
|
352
|
-
/** The workspace that the script event occurred in */
|
|
353
|
-
workspace: Workspace;
|
|
354
|
-
/** The exit result of the script */
|
|
355
|
-
exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
|
|
356
|
-
};
|
|
357
|
-
export type OnScriptEventCallback = (
|
|
358
|
-
/** The event that occurred */
|
|
359
|
-
event: ScriptEventName,
|
|
360
|
-
/** The metadata for the script event */
|
|
361
|
-
metadata: ScriptEventMetadata,
|
|
362
|
-
) => unknown;
|
|
363
|
-
/** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
364
|
-
export type RunScriptAcrossWorkspacesOptions = {
|
|
365
|
-
/**
|
|
366
|
-
* Workspace names, aliases, or patterns including a wildcard.
|
|
367
|
-
*
|
|
368
|
-
* When not provided, all workspaces that the script can be ran in will be used.
|
|
369
|
-
*/
|
|
370
|
-
workspacePatterns?: string[];
|
|
371
|
-
/** The name of the script to run, or an inline command when `inline` is true */
|
|
372
|
-
script: string;
|
|
373
|
-
/** Whether to run the script as an inline command */
|
|
374
|
-
inline?: boolean | InlineScriptOptions;
|
|
375
|
-
/** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
|
|
376
|
-
args?: string | string[];
|
|
377
|
-
/** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
|
|
378
|
-
parallel?: ParallelOption;
|
|
379
|
-
/** When `true`, run scripts so that dependent workspaces run only after their dependencies */
|
|
380
|
-
dependencyOrder?: boolean;
|
|
381
|
-
/** When `true`, continue running scripts even if a dependency fails (Only relevant when `dependencyOrder` is `true`) */
|
|
382
|
-
ignoreDependencyFailure?: boolean;
|
|
383
|
-
/** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
|
|
384
|
-
ignoreOutput?: boolean;
|
|
385
|
-
/** Callback to invoke when a script event occurs (start, skip, exit) */
|
|
386
|
-
onScriptEvent?: OnScriptEventCallback;
|
|
387
|
-
};
|
|
388
|
-
export type RunScriptAcrossWorkspacesSummary = Simplify<
|
|
389
|
-
RunScriptsSummary<RunWorkspaceScriptMetadata>
|
|
390
|
-
>;
|
|
391
|
-
export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
|
|
392
|
-
RunWorkspaceScriptMetadata & {
|
|
393
|
-
streamName: OutputStreamName;
|
|
394
|
-
}
|
|
395
|
-
>;
|
|
396
|
-
/** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
397
|
-
export type RunScriptAcrossWorkspacesResult = {
|
|
398
|
-
/** Use to get the output of the scripts */
|
|
399
|
-
output: RunScriptAcrossWorkspacesOutput;
|
|
400
|
-
/** The summary of the script run with exit details for each workspace */
|
|
401
|
-
summary: Promise<RunScriptAcrossWorkspacesSummary>;
|
|
402
|
-
/** The workspaces targeted */
|
|
403
|
-
workspaces: Workspace[];
|
|
404
|
-
};
|
|
405
|
-
declare class _FileSystemProject extends ProjectBase implements Project {
|
|
406
|
-
#private;
|
|
407
|
-
readonly rootDirectory: string;
|
|
408
|
-
readonly workspaces: Workspace[];
|
|
409
|
-
readonly name: string;
|
|
410
|
-
readonly sourceType = "fileSystem";
|
|
411
|
-
readonly config: ProjectConfig;
|
|
412
|
-
readonly rootWorkspace: Workspace;
|
|
413
|
-
constructor(options: CreateFileSystemProjectOptions);
|
|
414
|
-
runWorkspaceScript(
|
|
415
|
-
options: RunWorkspaceScriptOptions,
|
|
416
|
-
): RunWorkspaceScriptResult;
|
|
417
|
-
runScriptAcrossWorkspaces(
|
|
418
|
-
options: RunScriptAcrossWorkspacesOptions,
|
|
419
|
-
): RunScriptAcrossWorkspacesResult;
|
|
420
|
-
}
|
|
421
|
-
/** An implementation of {@link Project} that is created from a root directory in the file system. */
|
|
422
|
-
export type FileSystemProject = Simplify<_FileSystemProject>;
|
|
423
|
-
declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
424
|
-
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
425
|
-
export type LogLevelSetting = LogLevel | "silent";
|
|
426
390
|
export interface CliCommandConfig {
|
|
427
391
|
command: string;
|
|
428
392
|
isGlobal: boolean;
|
|
@@ -477,7 +441,7 @@ export declare const CLI_COMMANDS_CONFIG: {
|
|
|
477
441
|
readonly options: {
|
|
478
442
|
readonly workspacePatterns: {
|
|
479
443
|
readonly flags: ["-W", "--workspace-patterns <patterns>"];
|
|
480
|
-
readonly description: "Workspace patterns to match, separated by spaces";
|
|
444
|
+
readonly description: "Workspace patterns to match, separated by whitespace. Use backslashes to escape spaces if needed.";
|
|
481
445
|
};
|
|
482
446
|
readonly nameOnly: {
|
|
483
447
|
readonly flags: ["-n", "--name-only"];
|
|
@@ -592,6 +556,70 @@ export declare const CLI_COMMANDS_CONFIG: {
|
|
|
592
556
|
readonly description: "Start the bun-workspaces MCP (Model Context Protocol) server over stdio";
|
|
593
557
|
readonly options: {};
|
|
594
558
|
};
|
|
559
|
+
readonly listAffected: {
|
|
560
|
+
readonly command: "list-affected";
|
|
561
|
+
readonly isGlobal: false;
|
|
562
|
+
readonly aliases: ["ls-affected"];
|
|
563
|
+
readonly description: "List workspaces affected by a set of changed files (git or file list)";
|
|
564
|
+
readonly options: {
|
|
565
|
+
readonly base: {
|
|
566
|
+
readonly flags: ["-B", "--base <ref>"];
|
|
567
|
+
readonly description: "Git base ref to diff against (default is main if not configured). Cannot be used with --files";
|
|
568
|
+
};
|
|
569
|
+
readonly head: {
|
|
570
|
+
readonly flags: ["-H", "--head <ref>"];
|
|
571
|
+
readonly description: "Git head ref to diff against (default: HEAD). Cannot be used with --files";
|
|
572
|
+
};
|
|
573
|
+
readonly files: {
|
|
574
|
+
readonly flags: ["-F", "--files <files>"];
|
|
575
|
+
readonly description: "Changed files (paths/dirs/globs, '!' to exclude), separated by spaces. Use backslashes to escape spaces if needed. Bypasses git, so cannot be used with --base or --head.";
|
|
576
|
+
};
|
|
577
|
+
readonly script: {
|
|
578
|
+
readonly flags: ["-S", "--script <script>"];
|
|
579
|
+
readonly description: "Resolve inputs for the named script";
|
|
580
|
+
};
|
|
581
|
+
readonly ignoreUntracked: {
|
|
582
|
+
readonly flags: ["--ignore-untracked"];
|
|
583
|
+
readonly description: "Exclude untracked files";
|
|
584
|
+
};
|
|
585
|
+
readonly ignoreUnstaged: {
|
|
586
|
+
readonly flags: ["--ignore-unstaged"];
|
|
587
|
+
readonly description: "Exclude unstaged files";
|
|
588
|
+
};
|
|
589
|
+
readonly ignoreStaged: {
|
|
590
|
+
readonly flags: ["--ignore-staged"];
|
|
591
|
+
readonly description: "Exclude staged files";
|
|
592
|
+
};
|
|
593
|
+
readonly ignoreUncommitted: {
|
|
594
|
+
readonly flags: ["--ignore-uncommitted"];
|
|
595
|
+
readonly description: "Exclude all uncommitted changes (staged, unstaged, untracked)";
|
|
596
|
+
};
|
|
597
|
+
readonly ignoreWorkspaceDeps: {
|
|
598
|
+
readonly flags: ["--ignore-workspace-deps"];
|
|
599
|
+
readonly description: "Ignore workspace dependencies derived from package.json files";
|
|
600
|
+
};
|
|
601
|
+
readonly ignoreExternalDeps: {
|
|
602
|
+
readonly flags: ["--ignore-external-deps"];
|
|
603
|
+
readonly description: "Ignore changes to external dependencies (e.g. npm packages) versions in bun.lock";
|
|
604
|
+
};
|
|
605
|
+
readonly explain: {
|
|
606
|
+
readonly flags: ["-e", "--explain"];
|
|
607
|
+
readonly description: "Include changed-file counts and dependency reasons. With --json, outputs the full result object";
|
|
608
|
+
};
|
|
609
|
+
readonly detailed: {
|
|
610
|
+
readonly flags: ["-D", "--detailed"];
|
|
611
|
+
readonly description: "With --explain, render full per-file data and dependency edge chains";
|
|
612
|
+
};
|
|
613
|
+
readonly json: {
|
|
614
|
+
readonly flags: readonly ["-j", "--json"];
|
|
615
|
+
readonly description: "Output as JSON";
|
|
616
|
+
};
|
|
617
|
+
readonly pretty: {
|
|
618
|
+
readonly flags: readonly ["-p", "--pretty"];
|
|
619
|
+
readonly description: "Pretty print JSON";
|
|
620
|
+
};
|
|
621
|
+
};
|
|
622
|
+
};
|
|
595
623
|
readonly runScript: {
|
|
596
624
|
readonly command: "run-script [script] [workspacePatterns...]";
|
|
597
625
|
readonly isGlobal: false;
|
|
@@ -600,11 +628,106 @@ export declare const CLI_COMMANDS_CONFIG: {
|
|
|
600
628
|
readonly options: {
|
|
601
629
|
readonly script: {
|
|
602
630
|
readonly flags: ["-S", "--script <script>"];
|
|
603
|
-
readonly description: "The script to run.";
|
|
631
|
+
readonly description: "The script to run. (Alternative to positional argument)";
|
|
604
632
|
};
|
|
605
633
|
readonly workspacePatterns: {
|
|
606
634
|
readonly flags: ["-W", "--workspace-patterns <patterns>"];
|
|
607
|
-
readonly description: "Workspace patterns to match, separated by spaces.";
|
|
635
|
+
readonly description: "Workspace patterns to match, separated by spaces. (Alternative to positional arguments)";
|
|
636
|
+
};
|
|
637
|
+
readonly parallel: {
|
|
638
|
+
readonly flags: ["-P", "--parallel [max]"];
|
|
639
|
+
readonly description: 'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"';
|
|
640
|
+
};
|
|
641
|
+
readonly args: {
|
|
642
|
+
readonly flags: ["-a", "--args <args>"];
|
|
643
|
+
readonly description: "Args to append to the script command";
|
|
644
|
+
};
|
|
645
|
+
readonly outputStyle: {
|
|
646
|
+
readonly flags: ["-o", "--output-style <style>"];
|
|
647
|
+
readonly description: "The output style to use";
|
|
648
|
+
readonly values: ["grouped", "prefixed", "plain", "none"];
|
|
649
|
+
};
|
|
650
|
+
readonly groupedLines: {
|
|
651
|
+
readonly flags: ["-L", "--grouped-lines <count>"];
|
|
652
|
+
readonly description: 'With grouped output, the max preview lines (number or "auto", default "auto")';
|
|
653
|
+
};
|
|
654
|
+
readonly noPrefix: {
|
|
655
|
+
readonly flags: ["-N", "--no-prefix"];
|
|
656
|
+
readonly description: "(DEPRECATED) Use --output-style=plain instead";
|
|
657
|
+
readonly deprecated: true;
|
|
658
|
+
};
|
|
659
|
+
readonly inline: {
|
|
660
|
+
readonly flags: ["-i", "--inline"];
|
|
661
|
+
readonly description: "Run the script as an inline command from the workspace directory";
|
|
662
|
+
};
|
|
663
|
+
readonly inlineName: {
|
|
664
|
+
readonly flags: ["-I", "--inline-name <name>"];
|
|
665
|
+
readonly description: "An optional name for the script when --inline is passed";
|
|
666
|
+
};
|
|
667
|
+
readonly shell: {
|
|
668
|
+
readonly flags: ["-s", "--shell <shell>"];
|
|
669
|
+
readonly values: ["bun", "system", "default"];
|
|
670
|
+
readonly description: "When using --inline, the shell to use to run the script";
|
|
671
|
+
};
|
|
672
|
+
readonly depOrder: {
|
|
673
|
+
readonly flags: ["-d", "--dep-order"];
|
|
674
|
+
readonly description: "Scripts for dependent workspaces run only after their dependencies";
|
|
675
|
+
};
|
|
676
|
+
readonly ignoreDepFailure: {
|
|
677
|
+
readonly flags: ["-f", "--ignore-dep-failure"];
|
|
678
|
+
readonly description: "In dependency order, continue running scripts even if a dependency fails";
|
|
679
|
+
};
|
|
680
|
+
readonly jsonOutfile: {
|
|
681
|
+
readonly flags: ["-j", "--json-outfile <file>"];
|
|
682
|
+
readonly description: "Output results in a JSON file";
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
};
|
|
686
|
+
readonly runAffected: {
|
|
687
|
+
readonly command: "run-affected [script]";
|
|
688
|
+
readonly isGlobal: false;
|
|
689
|
+
readonly aliases: [];
|
|
690
|
+
readonly description: "Run a script across the workspaces affected by a set of changed files (git or file list)";
|
|
691
|
+
readonly options: {
|
|
692
|
+
readonly script: {
|
|
693
|
+
readonly flags: ["-S", "--script <script>"];
|
|
694
|
+
readonly description: "The script to run. (Alternative to positional argument)";
|
|
695
|
+
};
|
|
696
|
+
readonly base: {
|
|
697
|
+
readonly flags: ["-B", "--base <ref>"];
|
|
698
|
+
readonly description: "Git base ref to diff against (default is main if not configured). Cannot be used with --files";
|
|
699
|
+
};
|
|
700
|
+
readonly head: {
|
|
701
|
+
readonly flags: ["-H", "--head <ref>"];
|
|
702
|
+
readonly description: 'Git head ref to diff against (default "HEAD"). Cannot be used with --files';
|
|
703
|
+
};
|
|
704
|
+
readonly files: {
|
|
705
|
+
readonly flags: ["-F", "--files <files>"];
|
|
706
|
+
readonly description: "Changed files (paths/dirs/globs, '!' to exclude), separated by whitespace. Use backslashes to escape spaces if needed. Bypasses git, so cannot be used with --base or --head.";
|
|
707
|
+
};
|
|
708
|
+
readonly ignoreUntracked: {
|
|
709
|
+
readonly flags: ["--ignore-untracked"];
|
|
710
|
+
readonly description: "Exclude untracked files";
|
|
711
|
+
};
|
|
712
|
+
readonly ignoreUnstaged: {
|
|
713
|
+
readonly flags: ["--ignore-unstaged"];
|
|
714
|
+
readonly description: "Exclude unstaged files";
|
|
715
|
+
};
|
|
716
|
+
readonly ignoreStaged: {
|
|
717
|
+
readonly flags: ["--ignore-staged"];
|
|
718
|
+
readonly description: "Exclude staged files";
|
|
719
|
+
};
|
|
720
|
+
readonly ignoreUncommitted: {
|
|
721
|
+
readonly flags: ["--ignore-uncommitted"];
|
|
722
|
+
readonly description: "Exclude all uncommitted changes (staged, unstaged, untracked)";
|
|
723
|
+
};
|
|
724
|
+
readonly ignoreWorkspaceDeps: {
|
|
725
|
+
readonly flags: ["--ignore-workspace-deps"];
|
|
726
|
+
readonly description: "Ignore workspace dependencies derived from package.json files";
|
|
727
|
+
};
|
|
728
|
+
readonly ignoreExternalDeps: {
|
|
729
|
+
readonly flags: ["--ignore-external-deps"];
|
|
730
|
+
readonly description: "Ignore changes to external dependencies (e.g. npm packages) versions in bun.lock";
|
|
608
731
|
};
|
|
609
732
|
readonly parallel: {
|
|
610
733
|
readonly flags: ["-P", "--parallel [max]"];
|
|
@@ -681,7 +804,7 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
|
|
|
681
804
|
readonly options: {
|
|
682
805
|
readonly workspacePatterns: {
|
|
683
806
|
readonly flags: ["-W", "--workspace-patterns <patterns>"];
|
|
684
|
-
readonly description: "Workspace patterns to match, separated by spaces";
|
|
807
|
+
readonly description: "Workspace patterns to match, separated by whitespace. Use backslashes to escape spaces if needed.";
|
|
685
808
|
};
|
|
686
809
|
readonly nameOnly: {
|
|
687
810
|
readonly flags: ["-n", "--name-only"];
|
|
@@ -796,6 +919,70 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
|
|
|
796
919
|
readonly description: "Start the bun-workspaces MCP (Model Context Protocol) server over stdio";
|
|
797
920
|
readonly options: {};
|
|
798
921
|
}
|
|
922
|
+
| {
|
|
923
|
+
readonly command: "list-affected";
|
|
924
|
+
readonly isGlobal: false;
|
|
925
|
+
readonly aliases: ["ls-affected"];
|
|
926
|
+
readonly description: "List workspaces affected by a set of changed files (git or file list)";
|
|
927
|
+
readonly options: {
|
|
928
|
+
readonly base: {
|
|
929
|
+
readonly flags: ["-B", "--base <ref>"];
|
|
930
|
+
readonly description: "Git base ref to diff against (default is main if not configured). Cannot be used with --files";
|
|
931
|
+
};
|
|
932
|
+
readonly head: {
|
|
933
|
+
readonly flags: ["-H", "--head <ref>"];
|
|
934
|
+
readonly description: "Git head ref to diff against (default: HEAD). Cannot be used with --files";
|
|
935
|
+
};
|
|
936
|
+
readonly files: {
|
|
937
|
+
readonly flags: ["-F", "--files <files>"];
|
|
938
|
+
readonly description: "Changed files (paths/dirs/globs, '!' to exclude), separated by spaces. Use backslashes to escape spaces if needed. Bypasses git, so cannot be used with --base or --head.";
|
|
939
|
+
};
|
|
940
|
+
readonly script: {
|
|
941
|
+
readonly flags: ["-S", "--script <script>"];
|
|
942
|
+
readonly description: "Resolve inputs for the named script";
|
|
943
|
+
};
|
|
944
|
+
readonly ignoreUntracked: {
|
|
945
|
+
readonly flags: ["--ignore-untracked"];
|
|
946
|
+
readonly description: "Exclude untracked files";
|
|
947
|
+
};
|
|
948
|
+
readonly ignoreUnstaged: {
|
|
949
|
+
readonly flags: ["--ignore-unstaged"];
|
|
950
|
+
readonly description: "Exclude unstaged files";
|
|
951
|
+
};
|
|
952
|
+
readonly ignoreStaged: {
|
|
953
|
+
readonly flags: ["--ignore-staged"];
|
|
954
|
+
readonly description: "Exclude staged files";
|
|
955
|
+
};
|
|
956
|
+
readonly ignoreUncommitted: {
|
|
957
|
+
readonly flags: ["--ignore-uncommitted"];
|
|
958
|
+
readonly description: "Exclude all uncommitted changes (staged, unstaged, untracked)";
|
|
959
|
+
};
|
|
960
|
+
readonly ignoreWorkspaceDeps: {
|
|
961
|
+
readonly flags: ["--ignore-workspace-deps"];
|
|
962
|
+
readonly description: "Ignore workspace dependencies derived from package.json files";
|
|
963
|
+
};
|
|
964
|
+
readonly ignoreExternalDeps: {
|
|
965
|
+
readonly flags: ["--ignore-external-deps"];
|
|
966
|
+
readonly description: "Ignore changes to external dependencies (e.g. npm packages) versions in bun.lock";
|
|
967
|
+
};
|
|
968
|
+
readonly explain: {
|
|
969
|
+
readonly flags: ["-e", "--explain"];
|
|
970
|
+
readonly description: "Include changed-file counts and dependency reasons. With --json, outputs the full result object";
|
|
971
|
+
};
|
|
972
|
+
readonly detailed: {
|
|
973
|
+
readonly flags: ["-D", "--detailed"];
|
|
974
|
+
readonly description: "With --explain, render full per-file data and dependency edge chains";
|
|
975
|
+
};
|
|
976
|
+
readonly json: {
|
|
977
|
+
readonly flags: readonly ["-j", "--json"];
|
|
978
|
+
readonly description: "Output as JSON";
|
|
979
|
+
};
|
|
980
|
+
readonly pretty: {
|
|
981
|
+
readonly flags: readonly ["-p", "--pretty"];
|
|
982
|
+
readonly description: "Pretty print JSON";
|
|
983
|
+
};
|
|
984
|
+
};
|
|
985
|
+
}
|
|
799
986
|
| {
|
|
800
987
|
readonly command: "run-script [script] [workspacePatterns...]";
|
|
801
988
|
readonly isGlobal: false;
|
|
@@ -804,11 +991,106 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
|
|
|
804
991
|
readonly options: {
|
|
805
992
|
readonly script: {
|
|
806
993
|
readonly flags: ["-S", "--script <script>"];
|
|
807
|
-
readonly description: "The script to run.";
|
|
994
|
+
readonly description: "The script to run. (Alternative to positional argument)";
|
|
808
995
|
};
|
|
809
996
|
readonly workspacePatterns: {
|
|
810
997
|
readonly flags: ["-W", "--workspace-patterns <patterns>"];
|
|
811
|
-
readonly description: "Workspace patterns to match, separated by spaces.";
|
|
998
|
+
readonly description: "Workspace patterns to match, separated by spaces. (Alternative to positional arguments)";
|
|
999
|
+
};
|
|
1000
|
+
readonly parallel: {
|
|
1001
|
+
readonly flags: ["-P", "--parallel [max]"];
|
|
1002
|
+
readonly description: 'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"';
|
|
1003
|
+
};
|
|
1004
|
+
readonly args: {
|
|
1005
|
+
readonly flags: ["-a", "--args <args>"];
|
|
1006
|
+
readonly description: "Args to append to the script command";
|
|
1007
|
+
};
|
|
1008
|
+
readonly outputStyle: {
|
|
1009
|
+
readonly flags: ["-o", "--output-style <style>"];
|
|
1010
|
+
readonly description: "The output style to use";
|
|
1011
|
+
readonly values: ["grouped", "prefixed", "plain", "none"];
|
|
1012
|
+
};
|
|
1013
|
+
readonly groupedLines: {
|
|
1014
|
+
readonly flags: ["-L", "--grouped-lines <count>"];
|
|
1015
|
+
readonly description: 'With grouped output, the max preview lines (number or "auto", default "auto")';
|
|
1016
|
+
};
|
|
1017
|
+
readonly noPrefix: {
|
|
1018
|
+
readonly flags: ["-N", "--no-prefix"];
|
|
1019
|
+
readonly description: "(DEPRECATED) Use --output-style=plain instead";
|
|
1020
|
+
readonly deprecated: true;
|
|
1021
|
+
};
|
|
1022
|
+
readonly inline: {
|
|
1023
|
+
readonly flags: ["-i", "--inline"];
|
|
1024
|
+
readonly description: "Run the script as an inline command from the workspace directory";
|
|
1025
|
+
};
|
|
1026
|
+
readonly inlineName: {
|
|
1027
|
+
readonly flags: ["-I", "--inline-name <name>"];
|
|
1028
|
+
readonly description: "An optional name for the script when --inline is passed";
|
|
1029
|
+
};
|
|
1030
|
+
readonly shell: {
|
|
1031
|
+
readonly flags: ["-s", "--shell <shell>"];
|
|
1032
|
+
readonly values: ["bun", "system", "default"];
|
|
1033
|
+
readonly description: "When using --inline, the shell to use to run the script";
|
|
1034
|
+
};
|
|
1035
|
+
readonly depOrder: {
|
|
1036
|
+
readonly flags: ["-d", "--dep-order"];
|
|
1037
|
+
readonly description: "Scripts for dependent workspaces run only after their dependencies";
|
|
1038
|
+
};
|
|
1039
|
+
readonly ignoreDepFailure: {
|
|
1040
|
+
readonly flags: ["-f", "--ignore-dep-failure"];
|
|
1041
|
+
readonly description: "In dependency order, continue running scripts even if a dependency fails";
|
|
1042
|
+
};
|
|
1043
|
+
readonly jsonOutfile: {
|
|
1044
|
+
readonly flags: ["-j", "--json-outfile <file>"];
|
|
1045
|
+
readonly description: "Output results in a JSON file";
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
| {
|
|
1050
|
+
readonly command: "run-affected [script]";
|
|
1051
|
+
readonly isGlobal: false;
|
|
1052
|
+
readonly aliases: [];
|
|
1053
|
+
readonly description: "Run a script across the workspaces affected by a set of changed files (git or file list)";
|
|
1054
|
+
readonly options: {
|
|
1055
|
+
readonly script: {
|
|
1056
|
+
readonly flags: ["-S", "--script <script>"];
|
|
1057
|
+
readonly description: "The script to run. (Alternative to positional argument)";
|
|
1058
|
+
};
|
|
1059
|
+
readonly base: {
|
|
1060
|
+
readonly flags: ["-B", "--base <ref>"];
|
|
1061
|
+
readonly description: "Git base ref to diff against (default is main if not configured). Cannot be used with --files";
|
|
1062
|
+
};
|
|
1063
|
+
readonly head: {
|
|
1064
|
+
readonly flags: ["-H", "--head <ref>"];
|
|
1065
|
+
readonly description: 'Git head ref to diff against (default "HEAD"). Cannot be used with --files';
|
|
1066
|
+
};
|
|
1067
|
+
readonly files: {
|
|
1068
|
+
readonly flags: ["-F", "--files <files>"];
|
|
1069
|
+
readonly description: "Changed files (paths/dirs/globs, '!' to exclude), separated by whitespace. Use backslashes to escape spaces if needed. Bypasses git, so cannot be used with --base or --head.";
|
|
1070
|
+
};
|
|
1071
|
+
readonly ignoreUntracked: {
|
|
1072
|
+
readonly flags: ["--ignore-untracked"];
|
|
1073
|
+
readonly description: "Exclude untracked files";
|
|
1074
|
+
};
|
|
1075
|
+
readonly ignoreUnstaged: {
|
|
1076
|
+
readonly flags: ["--ignore-unstaged"];
|
|
1077
|
+
readonly description: "Exclude unstaged files";
|
|
1078
|
+
};
|
|
1079
|
+
readonly ignoreStaged: {
|
|
1080
|
+
readonly flags: ["--ignore-staged"];
|
|
1081
|
+
readonly description: "Exclude staged files";
|
|
1082
|
+
};
|
|
1083
|
+
readonly ignoreUncommitted: {
|
|
1084
|
+
readonly flags: ["--ignore-uncommitted"];
|
|
1085
|
+
readonly description: "Exclude all uncommitted changes (staged, unstaged, untracked)";
|
|
1086
|
+
};
|
|
1087
|
+
readonly ignoreWorkspaceDeps: {
|
|
1088
|
+
readonly flags: ["--ignore-workspace-deps"];
|
|
1089
|
+
readonly description: "Ignore workspace dependencies derived from package.json files";
|
|
1090
|
+
};
|
|
1091
|
+
readonly ignoreExternalDeps: {
|
|
1092
|
+
readonly flags: ["--ignore-external-deps"];
|
|
1093
|
+
readonly description: "Ignore changes to external dependencies (e.g. npm packages) versions in bun.lock";
|
|
812
1094
|
};
|
|
813
1095
|
readonly parallel: {
|
|
814
1096
|
readonly flags: ["-P", "--parallel [max]"];
|
|
@@ -860,6 +1142,9 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
|
|
|
860
1142
|
};
|
|
861
1143
|
};
|
|
862
1144
|
export declare const getCliCommandNames: () => CliCommandName[];
|
|
1145
|
+
declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
1146
|
+
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
1147
|
+
export type LogLevelSetting = LogLevel | "silent";
|
|
863
1148
|
export interface CliGlobalOptions {
|
|
864
1149
|
logLevel: LogLevelSetting;
|
|
865
1150
|
cwd: string;
|
|
@@ -911,6 +1196,326 @@ export declare const getCliGlobalOptionConfig: (
|
|
|
911
1196
|
readonly param: "";
|
|
912
1197
|
};
|
|
913
1198
|
export declare const getCliGlobalOptionNames: () => CliGlobalOptionName[];
|
|
1199
|
+
/**
|
|
1200
|
+
* A version delta for a single workspace's external dependency between
|
|
1201
|
+
* two reference points (typically `baseRef` vs `headRef`).
|
|
1202
|
+
*
|
|
1203
|
+
* `baseVersion`/`headVersion` are `null` when the dep was absent at that
|
|
1204
|
+
* side of the comparison (added or removed). When both are non-null and
|
|
1205
|
+
* differ, the version was upgraded/downgraded.
|
|
1206
|
+
*
|
|
1207
|
+
* All four `package.json` dependency map sources participate. For
|
|
1208
|
+
* `optionalDependencies` and `peerDependencies`, lockfile presence is the
|
|
1209
|
+
* effective gate — if bun didn't resolve a version (e.g. an optional native
|
|
1210
|
+
* binding skipped on this platform), no change is emitted.
|
|
1211
|
+
*/
|
|
1212
|
+
export type ExternalDependencyChange = {
|
|
1213
|
+
/** The package name */
|
|
1214
|
+
name: string;
|
|
1215
|
+
/** Which `package.json` dependency map this dep was declared in */
|
|
1216
|
+
source: ExternalDependencySource;
|
|
1217
|
+
/** Version at the base point; `null` if absent */
|
|
1218
|
+
baseVersion: string | null;
|
|
1219
|
+
/** Version at the head point; `null` if absent */
|
|
1220
|
+
headVersion: string | null;
|
|
1221
|
+
};
|
|
1222
|
+
export type AffectedDependencyEdgeSource = "input" | "package";
|
|
1223
|
+
export interface AffectedDependencyChainEntry {
|
|
1224
|
+
workspaceName: string;
|
|
1225
|
+
/**
|
|
1226
|
+
* The kind of edge that led to this workspace from the previous chain entry.
|
|
1227
|
+
* Undefined for the starting workspace at the head of the chain.
|
|
1228
|
+
*
|
|
1229
|
+
* "package" means the dependency is a true package.json-resolved dependency.
|
|
1230
|
+
*
|
|
1231
|
+
* "input" means the dependency comes from the workspace's workspace pattern inputs,
|
|
1232
|
+
* from defaultInputs or a script's inputs.
|
|
1233
|
+
*/
|
|
1234
|
+
edgeSource?: AffectedDependencyEdgeSource;
|
|
1235
|
+
}
|
|
1236
|
+
declare const GIT_AFFECTED_FILE_REASONS: readonly [
|
|
1237
|
+
"diff",
|
|
1238
|
+
"staged",
|
|
1239
|
+
"unstaged",
|
|
1240
|
+
"untracked",
|
|
1241
|
+
];
|
|
1242
|
+
export type GitAffectedFileReason = (typeof GIT_AFFECTED_FILE_REASONS)[number];
|
|
1243
|
+
export type AffectedChangedFile = {
|
|
1244
|
+
/** The path to the file, relative to the project root */
|
|
1245
|
+
projectFilePath: string;
|
|
1246
|
+
/** The matched input for the file */
|
|
1247
|
+
inputMatch: string;
|
|
1248
|
+
/** Present when `diffSource` is "git": the reasons for the file being affected */
|
|
1249
|
+
gitReasons?: GitAffectedFileReason[];
|
|
1250
|
+
};
|
|
1251
|
+
export type AffectedDependency = {
|
|
1252
|
+
/** The name of the dependency */
|
|
1253
|
+
dependencyName: string;
|
|
1254
|
+
/** The chain of dependencies that led to the affected workspace */
|
|
1255
|
+
chain: AffectedDependencyChainEntry[];
|
|
1256
|
+
};
|
|
1257
|
+
export type AffectedWorkspaceResult = {
|
|
1258
|
+
workspace: Workspace;
|
|
1259
|
+
inputs: WorkspaceInputsConfig;
|
|
1260
|
+
isAffected: boolean;
|
|
1261
|
+
affectedReasons: {
|
|
1262
|
+
changedFiles: AffectedChangedFile[];
|
|
1263
|
+
dependencies: AffectedDependency[];
|
|
1264
|
+
/**
|
|
1265
|
+
* External (non-workspace) dependency version deltas. In `git` mode the
|
|
1266
|
+
* `baseVersion`/`headVersion` carry resolved versions from `bun.lock` at
|
|
1267
|
+
* each ref. In `fileList` mode where `bun.lock` was listed as changed,
|
|
1268
|
+
* both fields are `null` since no version comparison is possible.
|
|
1269
|
+
*/
|
|
1270
|
+
externalDependencies: ExternalDependencyChange[];
|
|
1271
|
+
};
|
|
1272
|
+
};
|
|
1273
|
+
/** The source for changed files */
|
|
1274
|
+
export type AffectedDiffSource = "git" | "fileList";
|
|
1275
|
+
export type AffectedWorkspacesMetadata = {
|
|
1276
|
+
/** The source for changed files */
|
|
1277
|
+
diffSource: AffectedDiffSource;
|
|
1278
|
+
/** When `diffSource` is "git" */
|
|
1279
|
+
git?: {
|
|
1280
|
+
/** The base ref as provided (or the resolved default) */
|
|
1281
|
+
baseRef: string;
|
|
1282
|
+
/** The head ref as provided (or the resolved default) */
|
|
1283
|
+
headRef: string;
|
|
1284
|
+
/** The full SHA `baseRef` resolves to */
|
|
1285
|
+
baseSha: string;
|
|
1286
|
+
/** The full SHA `headRef` resolves to */
|
|
1287
|
+
headSha: string;
|
|
1288
|
+
};
|
|
1289
|
+
};
|
|
1290
|
+
export type AffectedWorkspacesResult = {
|
|
1291
|
+
/** Metadata based on the parameters given */
|
|
1292
|
+
metadata: AffectedWorkspacesMetadata;
|
|
1293
|
+
/** The workspaces and their affected reasons */
|
|
1294
|
+
workspaceResults: AffectedWorkspaceResult[];
|
|
1295
|
+
};
|
|
1296
|
+
export type BaseAffectedWorkspacesOptions<
|
|
1297
|
+
AcceptsScript extends boolean = true,
|
|
1298
|
+
> = {
|
|
1299
|
+
/** Skip cascading affected workspaces through `workspace:*` dependencies */
|
|
1300
|
+
ignoreWorkspaceDependencies?: boolean;
|
|
1301
|
+
/**
|
|
1302
|
+
* Skip lockfile-based external dependency version tracking. In `git` mode
|
|
1303
|
+
* this prevents reading `bun.lock` at base and head refs. In `fileList`
|
|
1304
|
+
* mode this prevents `bun.lock` (when present in `changedFiles`) from
|
|
1305
|
+
* triggering external-dep workspaces.
|
|
1306
|
+
*/
|
|
1307
|
+
ignoreExternalDependencies?: boolean;
|
|
1308
|
+
} & (AcceptsScript extends true
|
|
1309
|
+
? {
|
|
1310
|
+
script?: string;
|
|
1311
|
+
}
|
|
1312
|
+
: object);
|
|
1313
|
+
export type GitAffectedWorkspacesOptions<AcceptsScript extends boolean = true> =
|
|
1314
|
+
BaseAffectedWorkspacesOptions<AcceptsScript> & {
|
|
1315
|
+
/** Whether to use git to determine affected workspaces or a list of given files */
|
|
1316
|
+
diffSource: "git";
|
|
1317
|
+
diffOptions?: {
|
|
1318
|
+
/**
|
|
1319
|
+
* The base git ref to compare against.
|
|
1320
|
+
*
|
|
1321
|
+
* Default is "main" when not provided or
|
|
1322
|
+
* when the default is not set by the
|
|
1323
|
+
* root config or env var.
|
|
1324
|
+
*/
|
|
1325
|
+
baseRef?: string;
|
|
1326
|
+
/**
|
|
1327
|
+
* The head git ref to compare against.
|
|
1328
|
+
*
|
|
1329
|
+
* Default is "HEAD" when not provided.
|
|
1330
|
+
*/
|
|
1331
|
+
headRef?: string;
|
|
1332
|
+
/** Exclude untracked files */
|
|
1333
|
+
ignoreUntracked?: boolean;
|
|
1334
|
+
/** Ignore staged files */
|
|
1335
|
+
ignoreStaged?: boolean;
|
|
1336
|
+
/** Ignore unstaged files */
|
|
1337
|
+
ignoreUnstaged?: boolean;
|
|
1338
|
+
/** Exclude any uncommitted files (ignores staged, unstaged, and untracked) */
|
|
1339
|
+
ignoreUncommitted?: boolean;
|
|
1340
|
+
};
|
|
1341
|
+
};
|
|
1342
|
+
export type FileListAffectedWorkspacesOptions<
|
|
1343
|
+
AcceptsScript extends boolean = true,
|
|
1344
|
+
> = BaseAffectedWorkspacesOptions<AcceptsScript> & {
|
|
1345
|
+
/** Whether to use git or a list of given files to determine affected workspaces */
|
|
1346
|
+
diffSource: "fileList";
|
|
1347
|
+
/**
|
|
1348
|
+
* File paths, directories, or glob patterns relative to the project root.
|
|
1349
|
+
*
|
|
1350
|
+
* - File paths are matched literally. Paths that don't exist on disk
|
|
1351
|
+
* pass through as-is.
|
|
1352
|
+
* - Directories are walked recursively into a flat file list. The
|
|
1353
|
+
* `node_modules` and `.git` directories are skipped during the walk.
|
|
1354
|
+
* - Globs are expanded via `bun.Glob` against the project root and
|
|
1355
|
+
* only match files that currently exist.
|
|
1356
|
+
* - Prefix with `!` to exclude. Exclusions are expanded the same way
|
|
1357
|
+
* and removed from the include set.
|
|
1358
|
+
*/
|
|
1359
|
+
changedFiles: string[];
|
|
1360
|
+
};
|
|
1361
|
+
export type DetermineAffectedWorkspacesOptions<
|
|
1362
|
+
AcceptScript extends boolean = true,
|
|
1363
|
+
> =
|
|
1364
|
+
| GitAffectedWorkspacesOptions<AcceptScript>
|
|
1365
|
+
| FileListAffectedWorkspacesOptions<AcceptScript>;
|
|
1366
|
+
/** Arguments for {@link createFileSystemProject} */
|
|
1367
|
+
export type CreateFileSystemProjectOptions = {
|
|
1368
|
+
/** The directory containing the root package.json. Often the same root as a git repository. Relative to process.cwd(). The default is process.cwd(). */
|
|
1369
|
+
rootDirectory?: string;
|
|
1370
|
+
/**
|
|
1371
|
+
* The name of the project.
|
|
1372
|
+
*
|
|
1373
|
+
* By default will use the root package.json name
|
|
1374
|
+
*/
|
|
1375
|
+
name?: string;
|
|
1376
|
+
/** Whether to include the root workspace as a normal workspace. This overrides any config or env var settings. */
|
|
1377
|
+
includeRootWorkspace?: boolean;
|
|
1378
|
+
};
|
|
1379
|
+
export type InlineScriptOptions = {
|
|
1380
|
+
/** A name to act as a label for the inline script */
|
|
1381
|
+
scriptName?: string;
|
|
1382
|
+
/** Whether to use the system shell or Bun shell */
|
|
1383
|
+
shell?: ShellOption;
|
|
1384
|
+
};
|
|
1385
|
+
/** Arguments for `FileSystemProject.runWorkspaceScript` */
|
|
1386
|
+
export type RunWorkspaceScriptOptions = {
|
|
1387
|
+
/** The name of the workspace to run the script in */
|
|
1388
|
+
workspaceNameOrAlias: string;
|
|
1389
|
+
/** The name of the script to run, or an inline command when `inline` is true */
|
|
1390
|
+
script: string;
|
|
1391
|
+
/** Whether to run the script as an inline command */
|
|
1392
|
+
inline?: boolean | InlineScriptOptions;
|
|
1393
|
+
/** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
|
|
1394
|
+
args?: string | string[];
|
|
1395
|
+
/** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
|
|
1396
|
+
ignoreOutput?: boolean;
|
|
1397
|
+
};
|
|
1398
|
+
/** Metadata associated with a workspace script */
|
|
1399
|
+
export type RunWorkspaceScriptMetadata = {
|
|
1400
|
+
/** The workspace that the script was run in */
|
|
1401
|
+
workspace: Workspace;
|
|
1402
|
+
};
|
|
1403
|
+
export type RunWorkspaceScriptExit = Simplify<
|
|
1404
|
+
RunScriptExit<RunWorkspaceScriptMetadata>
|
|
1405
|
+
>;
|
|
1406
|
+
export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
|
|
1407
|
+
RunWorkspaceScriptMetadata & {
|
|
1408
|
+
streamName: OutputStreamName;
|
|
1409
|
+
}
|
|
1410
|
+
>;
|
|
1411
|
+
/** Result of `FileSystemProject.runWorkspaceScript` */
|
|
1412
|
+
export type RunWorkspaceScriptResult = {
|
|
1413
|
+
/** Use to get the output of the script */
|
|
1414
|
+
output: RunWorkspaceScriptProcessOutput;
|
|
1415
|
+
/** The exit result of the script */
|
|
1416
|
+
exit: Promise<RunWorkspaceScriptExit>;
|
|
1417
|
+
};
|
|
1418
|
+
export type ParallelOption = boolean | RunScriptsParallelOptions;
|
|
1419
|
+
export type ScriptEventMetadata = {
|
|
1420
|
+
/** The workspace that the script event occurred in */
|
|
1421
|
+
workspace: Workspace;
|
|
1422
|
+
/** The exit result of the script */
|
|
1423
|
+
exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
|
|
1424
|
+
};
|
|
1425
|
+
export type OnScriptEventCallback = (
|
|
1426
|
+
/** The event that occurred */
|
|
1427
|
+
event: ScriptEventName,
|
|
1428
|
+
/** The metadata for the script event */
|
|
1429
|
+
metadata: ScriptEventMetadata,
|
|
1430
|
+
) => unknown;
|
|
1431
|
+
/** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
1432
|
+
export type RunScriptAcrossWorkspacesOptions = {
|
|
1433
|
+
/**
|
|
1434
|
+
* Workspace names, aliases, or patterns including a wildcard.
|
|
1435
|
+
*
|
|
1436
|
+
* When not provided, all workspaces that the script can be ran in will be used.
|
|
1437
|
+
*/
|
|
1438
|
+
workspacePatterns?: string[];
|
|
1439
|
+
/** The name of the script to run, or an inline command when `inline` is true */
|
|
1440
|
+
script: string;
|
|
1441
|
+
/** Whether to run the script as an inline command */
|
|
1442
|
+
inline?: boolean | InlineScriptOptions;
|
|
1443
|
+
/** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
|
|
1444
|
+
args?: string | string[];
|
|
1445
|
+
/** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
|
|
1446
|
+
parallel?: ParallelOption;
|
|
1447
|
+
/** When `true`, run scripts so that dependent workspaces run only after their dependencies */
|
|
1448
|
+
dependencyOrder?: boolean;
|
|
1449
|
+
/** When `true`, continue running scripts even if a dependency fails (Only relevant when `dependencyOrder` is `true`) */
|
|
1450
|
+
ignoreDependencyFailure?: boolean;
|
|
1451
|
+
/** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
|
|
1452
|
+
ignoreOutput?: boolean;
|
|
1453
|
+
/** Callback to invoke when a script event occurs (start, skip, exit) */
|
|
1454
|
+
onScriptEvent?: OnScriptEventCallback;
|
|
1455
|
+
};
|
|
1456
|
+
export type RunScriptAcrossWorkspacesSummary = Simplify<
|
|
1457
|
+
RunScriptsSummary<RunWorkspaceScriptMetadata>
|
|
1458
|
+
>;
|
|
1459
|
+
export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
|
|
1460
|
+
RunWorkspaceScriptMetadata & {
|
|
1461
|
+
streamName: OutputStreamName;
|
|
1462
|
+
}
|
|
1463
|
+
>;
|
|
1464
|
+
/** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
1465
|
+
export type RunScriptAcrossWorkspacesResult = {
|
|
1466
|
+
/** Use to get the output of the scripts */
|
|
1467
|
+
output: RunScriptAcrossWorkspacesOutput;
|
|
1468
|
+
/** The summary of the script run with exit details for each workspace */
|
|
1469
|
+
summary: Promise<RunScriptAcrossWorkspacesSummary>;
|
|
1470
|
+
/** The workspaces targeted */
|
|
1471
|
+
workspaces: Workspace[];
|
|
1472
|
+
};
|
|
1473
|
+
export type RunAffectedWorkspaceScriptOptions = {
|
|
1474
|
+
/**
|
|
1475
|
+
* Options for resolving the affected workspaces. The `script` field is
|
|
1476
|
+
* intentionally omitted — it is derived from `scriptOptions` (the inline
|
|
1477
|
+
* script name when running inline, the script name otherwise) so that
|
|
1478
|
+
* inputs resolution always tracks the script being run.
|
|
1479
|
+
*/
|
|
1480
|
+
affectedOptions: DetermineAffectedWorkspacesOptions<false>;
|
|
1481
|
+
scriptOptions: Omit<RunScriptAcrossWorkspacesOptions, "workspacePatterns">;
|
|
1482
|
+
};
|
|
1483
|
+
declare class _FileSystemProject extends ProjectBase implements Project {
|
|
1484
|
+
#private;
|
|
1485
|
+
readonly rootDirectory: string;
|
|
1486
|
+
readonly workspaces: Workspace[];
|
|
1487
|
+
readonly name: string;
|
|
1488
|
+
readonly sourceType = "fileSystem";
|
|
1489
|
+
readonly config: ProjectConfig;
|
|
1490
|
+
readonly rootWorkspace: Workspace;
|
|
1491
|
+
constructor(options: CreateFileSystemProjectOptions);
|
|
1492
|
+
runWorkspaceScript(
|
|
1493
|
+
options: RunWorkspaceScriptOptions,
|
|
1494
|
+
): RunWorkspaceScriptResult;
|
|
1495
|
+
runScriptAcrossWorkspaces(
|
|
1496
|
+
options: RunScriptAcrossWorkspacesOptions,
|
|
1497
|
+
): RunScriptAcrossWorkspacesResult;
|
|
1498
|
+
/**
|
|
1499
|
+
* Determine the affected workspaces based on the given options.
|
|
1500
|
+
*
|
|
1501
|
+
* Returns a summary of all workspaces, whether they are affected or not,
|
|
1502
|
+
* and the reasons why they are affected.
|
|
1503
|
+
*/
|
|
1504
|
+
determineAffectedWorkspaces(
|
|
1505
|
+
options: DetermineAffectedWorkspacesOptions,
|
|
1506
|
+
): Promise<AffectedWorkspacesResult>;
|
|
1507
|
+
/**
|
|
1508
|
+
* Run the script across the affected workspaces.
|
|
1509
|
+
*
|
|
1510
|
+
* Similar to {@link runScriptAcrossWorkspaces}, but only runs the script across the affected workspaces.
|
|
1511
|
+
*/
|
|
1512
|
+
runAffectedWorkspaceScript({
|
|
1513
|
+
affectedOptions,
|
|
1514
|
+
scriptOptions,
|
|
1515
|
+
}: RunAffectedWorkspaceScriptOptions): Promise<RunScriptAcrossWorkspacesResult>;
|
|
1516
|
+
}
|
|
1517
|
+
/** An implementation of {@link Project} that is created from a root directory in the file system. */
|
|
1518
|
+
export type FileSystemProject = Simplify<_FileSystemProject>;
|
|
914
1519
|
/** @todo DRY use of output text in cases such as having no workspaces/scripts */
|
|
915
1520
|
export type GlobalCommandContext = {
|
|
916
1521
|
program: Command;
|
|
@@ -1028,6 +1633,9 @@ export declare const mcpServer: (
|
|
|
1028
1633
|
export declare const runScript: (
|
|
1029
1634
|
context: ProjectCommandContext,
|
|
1030
1635
|
) => import("commander").Command;
|
|
1636
|
+
export declare const runAffected: (
|
|
1637
|
+
context: ProjectCommandContext,
|
|
1638
|
+
) => import("commander").Command;
|
|
1031
1639
|
export type RenderPlainOutputOptions = {
|
|
1032
1640
|
stripDisruptiveControls?: boolean;
|
|
1033
1641
|
prefix?: boolean;
|
|
@@ -1068,6 +1676,13 @@ export declare const initializeWithGlobalOptions: (
|
|
|
1068
1676
|
runScriptAcrossWorkspaces(
|
|
1069
1677
|
options: RunScriptAcrossWorkspacesOptions,
|
|
1070
1678
|
): RunScriptAcrossWorkspacesResult;
|
|
1679
|
+
determineAffectedWorkspaces(
|
|
1680
|
+
options: DetermineAffectedWorkspacesOptions,
|
|
1681
|
+
): Promise<AffectedWorkspacesResult>;
|
|
1682
|
+
runAffectedWorkspaceScript({
|
|
1683
|
+
affectedOptions,
|
|
1684
|
+
scriptOptions,
|
|
1685
|
+
}: RunAffectedWorkspaceScriptOptions): Promise<RunScriptAcrossWorkspacesResult>;
|
|
1071
1686
|
listWorkspacesWithScript(scriptName: string): Workspace[];
|
|
1072
1687
|
mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
|
|
1073
1688
|
mapTagsToWorkspaces(): Record<string, Workspace[]>;
|