bun-workspaces 1.5.1 → 1.5.2

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.
Files changed (255) hide show
  1. package/bin/cli.js +0 -0
  2. package/package.json +1 -5
  3. package/src/1108.mjs +30 -0
  4. package/src/{cli/commands/commandsConfig.mjs → 2392.mjs} +52 -11
  5. package/src/4427.mjs +9 -0
  6. package/src/5166.mjs +8 -0
  7. package/src/8126.mjs +4 -0
  8. package/src/8257.mjs +4 -0
  9. package/src/{config/util/configLocation.mjs → 8529.mjs} +11 -2
  10. package/src/ai/mcp/bwMcpServer.mjs +213 -9
  11. package/src/ai/mcp/core/index.mjs +3 -1
  12. package/src/ai/mcp/core/server.mjs +1 -3
  13. package/src/ai/mcp/core/transport.mjs +1 -2
  14. package/src/ai/mcp/core/types.mjs +0 -1
  15. package/src/ai/mcp/index.mjs +3 -1
  16. package/src/ai/mcp/resources.mjs +1 -2
  17. package/src/ai/mcp/tools.mjs +1 -5
  18. package/src/cli/commands/commandHandlerUtils.mjs +2 -6
  19. package/src/cli/commands/commands.mjs +1 -4
  20. package/src/cli/commands/handleSimpleCommands.mjs +4 -10
  21. package/src/cli/commands/index.mjs +11 -2
  22. package/src/cli/commands/mcp.mjs +1 -4
  23. package/src/cli/commands/runScript/handleRunScript.mjs +1 -9
  24. package/src/cli/commands/runScript/index.mjs +3 -1
  25. package/src/cli/commands/runScript/output/index.mjs +3 -1
  26. package/src/cli/commands/runScript/output/outputStyle.mjs +1 -3
  27. package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +1 -6
  28. package/src/cli/commands/runScript/output/renderPlainOutput.mjs +1 -2
  29. package/src/cli/commands/runScript/output/sanitizeChunk.mjs +0 -1
  30. package/src/cli/createCli.mjs +2 -12
  31. package/src/cli/fatalErrorLogger.mjs +1 -2
  32. package/src/cli/globalOptions/globalOptions.mjs +2 -9
  33. package/src/cli/globalOptions/index.mjs +3 -2
  34. package/src/cli/index.d.ts +1025 -3
  35. package/src/cli/index.mjs +3 -1
  36. package/src/cli/middleware.mjs +1 -3
  37. package/src/config/index.mjs +3 -1
  38. package/src/config/public.d.ts +93 -10
  39. package/src/config/public.mjs +2 -6
  40. package/src/config/rootConfig/defineRootConfig.mjs +1 -2
  41. package/src/config/rootConfig/errors.mjs +1 -2
  42. package/src/config/rootConfig/index.mjs +2 -1
  43. package/src/config/rootConfig/loadRootConfig.mjs +1 -4
  44. package/src/config/rootConfig/rootConfig.mjs +1 -6
  45. package/src/config/rootConfig/rootConfigSchema.mjs +0 -1
  46. package/src/config/userEnvVars/index.mjs +3 -1
  47. package/src/config/userEnvVars/userEnvVars.mjs +3 -8
  48. package/src/config/util/ajvTypes.mjs +2 -1
  49. package/src/config/util/index.mjs +2 -1
  50. package/src/config/util/loadConfig.mjs +1 -6
  51. package/src/config/util/validateConfig.mjs +0 -1
  52. package/src/config/workspaceConfig/defineWorkspaceConfig.mjs +1 -2
  53. package/src/config/workspaceConfig/errors.mjs +1 -2
  54. package/src/config/workspaceConfig/index.mjs +2 -1
  55. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +2 -8
  56. package/src/config/workspaceConfig/workspaceConfig.mjs +1 -5
  57. package/src/config/workspaceConfig/workspaceConfigSchema.mjs +0 -1
  58. package/src/doctor/doctor.mjs +1 -5
  59. package/src/doctor/index.mjs +3 -1
  60. package/src/index.d.ts +458 -38
  61. package/src/index.mjs +4 -13
  62. package/src/internal/bun/bunLock.mjs +2 -4
  63. package/src/internal/bun/bunVersion.mjs +1 -3
  64. package/src/internal/bun/index.mjs +3 -1
  65. package/src/internal/bundledDeps/commander.mjs +3843 -0
  66. package/src/internal/bundledDeps/shellQuote.mjs +291 -0
  67. package/src/internal/core/error/error.mjs +0 -1
  68. package/src/internal/core/error/index.mjs +3 -1
  69. package/src/internal/core/index.mjs +3 -1
  70. package/src/internal/core/json/index.mjs +3 -1
  71. package/src/internal/core/json/json.mjs +3 -5
  72. package/src/internal/core/json/jsonc.mjs +0 -1
  73. package/src/internal/core/language/array/index.mjs +3 -1
  74. package/src/internal/core/language/array/optionalArray.mjs +0 -1
  75. package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +0 -1
  76. package/src/internal/core/language/asyncIterable/index.mjs +3 -1
  77. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +0 -1
  78. package/src/internal/core/language/events/typedEventTarget.mjs +0 -1
  79. package/src/internal/core/language/index.mjs +3 -1
  80. package/src/internal/core/language/regex/index.mjs +3 -1
  81. package/src/internal/core/language/regex/regex.mjs +0 -1
  82. package/src/internal/core/language/string/id.mjs +0 -1
  83. package/src/internal/core/language/string/index.mjs +3 -1
  84. package/src/internal/core/language/string/utf/eastAsianWidth.mjs +0 -1
  85. package/src/internal/core/language/string/utf/visibleLength.mjs +1 -2
  86. package/src/internal/core/language/types/index.mjs +3 -1
  87. package/src/internal/core/language/types/typeof.mjs +1 -3
  88. package/src/internal/core/language/types/types.mjs +3 -2
  89. package/src/internal/core/runtime/env.mjs +0 -1
  90. package/src/internal/core/runtime/index.mjs +3 -1
  91. package/src/internal/core/runtime/onExit.mjs +1 -2
  92. package/src/internal/core/runtime/os.mjs +1 -3
  93. package/src/internal/core/runtime/tempFile.mjs +1 -9
  94. package/src/internal/core/runtime/terminal.mjs +0 -1
  95. package/src/internal/generated/aiDocs/.gitkeep.mjs +1 -0
  96. package/src/internal/generated/aiDocs/docs.mjs +0 -1
  97. package/src/internal/logger/index.mjs +3 -1
  98. package/src/internal/logger/logger.mjs +4 -14
  99. package/src/internal/version.mjs +1 -2
  100. package/src/project/errors.mjs +1 -2
  101. package/src/project/implementations/fileSystemProject.mjs +3 -18
  102. package/src/project/implementations/memoryProject.mjs +1 -5
  103. package/src/project/implementations/projectBase.mjs +10 -19
  104. package/src/project/index.mjs +3 -1
  105. package/src/project/project.mjs +2 -1
  106. package/src/rslib-runtime.mjs +62 -0
  107. package/src/runScript/index.mjs +3 -1
  108. package/src/runScript/output/index.mjs +3 -1
  109. package/src/runScript/output/multiProcessOutput.mjs +1 -2
  110. package/src/runScript/output/outputStream.mjs +1 -1
  111. package/src/runScript/output/processOutput.mjs +1 -2
  112. package/src/runScript/parallel.mjs +4 -10
  113. package/src/runScript/recursion.mjs +1 -2
  114. package/src/runScript/runScript.mjs +1 -4
  115. package/src/runScript/runScripts.mjs +1 -6
  116. package/src/runScript/scriptCommand.mjs +1 -2
  117. package/src/runScript/scriptExecution.mjs +1 -3
  118. package/src/runScript/scriptRuntimeMetadata.mjs +38 -56
  119. package/src/runScript/scriptShellOption.mjs +5 -14
  120. package/src/runScript/subprocesses.mjs +1 -3
  121. package/src/workspaces/dependencyGraph/cycles.mjs +0 -1
  122. package/src/workspaces/dependencyGraph/index.mjs +3 -1
  123. package/src/workspaces/dependencyGraph/resolveDependencies.mjs +1 -2
  124. package/src/workspaces/dependencyGraph/validateDependencyRules.mjs +1 -3
  125. package/src/workspaces/errors.mjs +1 -2
  126. package/src/workspaces/findWorkspaces.mjs +1 -11
  127. package/src/workspaces/index.mjs +3 -1
  128. package/src/workspaces/packageJson.mjs +2 -7
  129. package/src/workspaces/workspace.mjs +2 -1
  130. package/src/workspaces/workspacePattern.mjs +4 -4
  131. package/src/ai/mcp/bwMcpServer.d.ts +0 -4
  132. package/src/ai/mcp/core/index.d.ts +0 -3
  133. package/src/ai/mcp/core/server.d.ts +0 -14
  134. package/src/ai/mcp/core/transport.d.ts +0 -12
  135. package/src/ai/mcp/core/types.d.ts +0 -104
  136. package/src/ai/mcp/index.d.ts +0 -2
  137. package/src/ai/mcp/resources.d.ts +0 -6
  138. package/src/ai/mcp/tools.d.ts +0 -6
  139. package/src/cli/commands/commandHandlerUtils.d.ts +0 -51
  140. package/src/cli/commands/commands.d.ts +0 -10
  141. package/src/cli/commands/commandsConfig.d.ts +0 -436
  142. package/src/cli/commands/handleSimpleCommands.d.ts +0 -21
  143. package/src/cli/commands/index.d.ts +0 -4
  144. package/src/cli/commands/mcp.d.ts +0 -3
  145. package/src/cli/commands/runScript/handleRunScript.d.ts +0 -3
  146. package/src/cli/commands/runScript/index.d.ts +0 -2
  147. package/src/cli/commands/runScript/output/index.d.ts +0 -1
  148. package/src/cli/commands/runScript/output/outputStyle.d.ts +0 -9
  149. package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +0 -75
  150. package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +0 -24
  151. package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +0 -4
  152. package/src/cli/createCli.d.ts +0 -26
  153. package/src/cli/fatalErrorLogger.d.ts +0 -1
  154. package/src/cli/globalOptions/globalOptions.d.ts +0 -43
  155. package/src/cli/globalOptions/globalOptionsConfig.d.ts +0 -52
  156. package/src/cli/globalOptions/globalOptionsConfig.mjs +0 -43
  157. package/src/cli/globalOptions/index.d.ts +0 -2
  158. package/src/cli/middleware.d.ts +0 -83
  159. package/src/config/index.d.ts +0 -3
  160. package/src/config/rootConfig/defineRootConfig.d.ts +0 -4
  161. package/src/config/rootConfig/errors.d.ts +0 -1
  162. package/src/config/rootConfig/index.d.ts +0 -5
  163. package/src/config/rootConfig/loadRootConfig.d.ts +0 -3
  164. package/src/config/rootConfig/rootConfig.d.ts +0 -25
  165. package/src/config/rootConfig/rootConfigLocation.d.ts +0 -2
  166. package/src/config/rootConfig/rootConfigLocation.mjs +0 -5
  167. package/src/config/rootConfig/rootConfigSchema.d.ts +0 -21
  168. package/src/config/userEnvVars/index.d.ts +0 -1
  169. package/src/config/userEnvVars/userEnvVars.d.ts +0 -13
  170. package/src/config/util/ajvTypes.d.ts +0 -10
  171. package/src/config/util/configLocation.d.ts +0 -18
  172. package/src/config/util/index.d.ts +0 -4
  173. package/src/config/util/loadConfig.d.ts +0 -18
  174. package/src/config/util/validateConfig.d.ts +0 -8
  175. package/src/config/workspaceConfig/defineWorkspaceConfig.d.ts +0 -7
  176. package/src/config/workspaceConfig/errors.d.ts +0 -1
  177. package/src/config/workspaceConfig/index.d.ts +0 -5
  178. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +0 -3
  179. package/src/config/workspaceConfig/workspaceConfig.d.ts +0 -56
  180. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +0 -2
  181. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +0 -5
  182. package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +0 -56
  183. package/src/doctor/doctor.d.ts +0 -35
  184. package/src/doctor/index.d.ts +0 -1
  185. package/src/internal/bun/bunLock.d.ts +0 -20
  186. package/src/internal/bun/bunVersion.d.ts +0 -21
  187. package/src/internal/bun/index.d.ts +0 -2
  188. package/src/internal/core/error/error.d.ts +0 -13
  189. package/src/internal/core/error/index.d.ts +0 -1
  190. package/src/internal/core/index.d.ts +0 -4
  191. package/src/internal/core/json/index.d.ts +0 -2
  192. package/src/internal/core/json/json.d.ts +0 -49
  193. package/src/internal/core/json/jsonc.d.ts +0 -9
  194. package/src/internal/core/language/array/index.d.ts +0 -1
  195. package/src/internal/core/language/array/optionalArray.d.ts +0 -15
  196. package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +0 -16
  197. package/src/internal/core/language/asyncIterable/index.d.ts +0 -2
  198. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +0 -5
  199. package/src/internal/core/language/events/typedEventTarget.d.ts +0 -50
  200. package/src/internal/core/language/index.d.ts +0 -5
  201. package/src/internal/core/language/regex/index.d.ts +0 -1
  202. package/src/internal/core/language/regex/regex.d.ts +0 -3
  203. package/src/internal/core/language/string/id.d.ts +0 -1
  204. package/src/internal/core/language/string/index.d.ts +0 -1
  205. package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +0 -16
  206. package/src/internal/core/language/string/utf/visibleLength.d.ts +0 -5
  207. package/src/internal/core/language/types/index.d.ts +0 -2
  208. package/src/internal/core/language/types/typeof.d.ts +0 -102
  209. package/src/internal/core/language/types/types.d.ts +0 -19
  210. package/src/internal/core/runtime/env.d.ts +0 -6
  211. package/src/internal/core/runtime/index.d.ts +0 -5
  212. package/src/internal/core/runtime/onExit.d.ts +0 -4
  213. package/src/internal/core/runtime/os.d.ts +0 -6
  214. package/src/internal/core/runtime/tempFile.d.ts +0 -20
  215. package/src/internal/core/runtime/terminal.d.ts +0 -1
  216. package/src/internal/docs/apiQuickstart.d.ts +0 -3
  217. package/src/internal/docs/apiQuickstart.mjs +0 -132
  218. package/src/internal/docs/cliQuickstart.d.ts +0 -2
  219. package/src/internal/docs/cliQuickstart.mjs +0 -86
  220. package/src/internal/docs/index.d.ts +0 -2
  221. package/src/internal/docs/index.mjs +0 -2
  222. package/src/internal/generated/aiDocs/docs.d.ts +0 -10
  223. package/src/internal/logger/index.d.ts +0 -1
  224. package/src/internal/logger/logger.d.ts +0 -45
  225. package/src/internal/version.d.ts +0 -1
  226. package/src/project/errors.d.ts +0 -5
  227. package/src/project/implementations/fileSystemProject.d.ts +0 -148
  228. package/src/project/implementations/memoryProject.d.ts +0 -41
  229. package/src/project/implementations/projectBase.d.ts +0 -37
  230. package/src/project/index.d.ts +0 -5
  231. package/src/project/project.d.ts +0 -79
  232. package/src/runScript/index.d.ts +0 -7
  233. package/src/runScript/output/index.d.ts +0 -3
  234. package/src/runScript/output/multiProcessOutput.d.ts +0 -14
  235. package/src/runScript/output/outputStream.d.ts +0 -1
  236. package/src/runScript/output/processOutput.d.ts +0 -33
  237. package/src/runScript/parallel.d.ts +0 -24
  238. package/src/runScript/recursion.d.ts +0 -4
  239. package/src/runScript/runScript.d.ts +0 -45
  240. package/src/runScript/runScripts.d.ts +0 -65
  241. package/src/runScript/scriptCommand.d.ts +0 -33
  242. package/src/runScript/scriptExecution.d.ts +0 -9
  243. package/src/runScript/scriptRuntimeMetadata.d.ts +0 -73
  244. package/src/runScript/scriptShellOption.d.ts +0 -8
  245. package/src/runScript/subprocesses.d.ts +0 -11
  246. package/src/workspaces/dependencyGraph/cycles.d.ts +0 -9
  247. package/src/workspaces/dependencyGraph/index.d.ts +0 -3
  248. package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +0 -18
  249. package/src/workspaces/dependencyGraph/validateDependencyRules.d.ts +0 -7
  250. package/src/workspaces/errors.d.ts +0 -14
  251. package/src/workspaces/findWorkspaces.d.ts +0 -24
  252. package/src/workspaces/index.d.ts +0 -4
  253. package/src/workspaces/packageJson.d.ts +0 -31
  254. package/src/workspaces/workspace.d.ts +0 -21
  255. package/src/workspaces/workspacePattern.d.ts +0 -22
@@ -1,3 +1,1025 @@
1
- export * from "./createCli";
2
- export * from "./commands";
3
- export * from "./globalOptions";
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /** Does not change an object type, but remaps it for cleaner Intellisense only */
4
+ export type Simplify<T extends object> = {
5
+ [K in keyof T]: T[K];
6
+ };
7
+ /** A normal `AsyncIterable` that is only intended for `for await` style iteration */
8
+ export type SimpleAsyncIterable<T> = AsyncIterable<T, void, undefined>;
9
+ declare const SCRIPT_SHELL_OPTIONS: readonly ["bun", "system"];
10
+ export type ScriptShellOption = (typeof SCRIPT_SHELL_OPTIONS)[number];
11
+ export type ShellOption = ScriptShellOption | "default";
12
+ declare const PARALLEL_MAX_VALUES: readonly ["auto", "unbounded", "default"];
13
+ export type PercentageValue = `${number}%`;
14
+ /**
15
+ * The maximum number of scripts that can run in parallel.
16
+ *
17
+ * - `number`: The exact number of scripts that can run in parallel.
18
+ * - `"auto"`: The number of available logical CPU threads.
19
+ * - `"unbounded"`: No limit.
20
+ * - `"default"`: The default value, either "auto" or the value of the root config's "parallelMax" option.
21
+ * - `"${number}%"`: A percentage of the available logical CPU threads (e.g. "50%").
22
+ */
23
+ export type ParallelMaxValue =
24
+ | number
25
+ | (typeof PARALLEL_MAX_VALUES)[number]
26
+ | PercentageValue;
27
+ export type WorkspaceDependenciesRule = {
28
+ allowPatterns?: string[];
29
+ denyPatterns?: string[];
30
+ };
31
+ export type WorkspaceRules = {
32
+ workspaceDependencies?: WorkspaceDependenciesRule;
33
+ };
34
+ /** Configuration that applies to a specific package.json script */
35
+ export type ScriptConfig = {
36
+ /**
37
+ * The order in which the script should be executed.
38
+ *
39
+ * Scripts with no `order` set will be executed in alphanumerical order
40
+ * of their relative path from the project root.
41
+ */
42
+ order?: number;
43
+ };
44
+ export type ResolvedWorkspaceConfig = {
45
+ aliases: string[];
46
+ tags: string[];
47
+ scripts: Record<string, ScriptConfig>;
48
+ rules: WorkspaceRules;
49
+ };
50
+ export type ResolvedRootConfig = {
51
+ defaults: {
52
+ parallelMax: number;
53
+ shell: ScriptShellOption;
54
+ /** `undefined` means the value was not set in the input config */
55
+ includeRootWorkspace: boolean | undefined;
56
+ };
57
+ };
58
+ export type OutputStreamName = "stdout" | "stderr";
59
+ export type ProcessOutputChunk<
60
+ Chunk = unknown,
61
+ Metadata extends object = object,
62
+ > = {
63
+ /** The metadata for the script that produced the output chunk */
64
+ metadata: Metadata;
65
+ /** The output chunk */
66
+ chunk: Chunk;
67
+ };
68
+ export type ByteChunk<Metadata extends object = object> = ProcessOutputChunk<
69
+ Uint8Array<ArrayBufferLike>,
70
+ Metadata
71
+ >;
72
+ export type TextChunk<Metadata extends object = object> = ProcessOutputChunk<
73
+ string,
74
+ Metadata
75
+ >;
76
+ export type BytesOutput<Metadata extends object = object> = SimpleAsyncIterable<
77
+ ByteChunk<Metadata>
78
+ >;
79
+ export type TextOutput<Metadata extends object = object> = SimpleAsyncIterable<
80
+ TextChunk<Metadata>
81
+ >;
82
+ export interface MultiProcessOutput<Metadata extends object = object> {
83
+ bytes(): BytesOutput<Metadata>;
84
+ text(): TextOutput<Metadata>;
85
+ }
86
+ /** Metadata about a nested package within a Bun monorepo */
87
+ export type Workspace = {
88
+ /** The name of the workspace from its `package.json` */
89
+ name: string;
90
+ /** Whether the workspace is the root workspace */
91
+ isRoot: boolean;
92
+ /** The relative path to the workspace from the root `package.json` */
93
+ path: string;
94
+ /** The pattern from `"workspaces"` in the root `package.json`that this workspace was matched from*/
95
+ matchPattern: string;
96
+ /** The scripts available in package.json */
97
+ scripts: string[];
98
+ /** Aliases assigned via the `"alias"` field in the workspace's config */
99
+ aliases: string[];
100
+ /** Tags assigned via the `"tags"` field in the workspace's config */
101
+ tags: string[];
102
+ /** Names of workspaces that this workspace depends on */
103
+ dependencies: string[];
104
+ /** Names of workspaces that depend on this workspace */
105
+ dependents: string[];
106
+ };
107
+ declare const WORKSPACE_SCRIPT_COMMAND_METHODS: readonly ["cd", "filter"];
108
+ export type WorkspaceScriptCommandMethod =
109
+ (typeof WORKSPACE_SCRIPT_COMMAND_METHODS)[number];
110
+ /** Basic metadata to run a script, the command string and the directory to run it in */
111
+ export interface ScriptCommand {
112
+ /** The command string to run */
113
+ command: string;
114
+ /** The directory to run the command in */
115
+ workingDirectory: string;
116
+ }
117
+ export type RunScriptExit<ScriptMetadata extends object = object> = {
118
+ exitCode: number;
119
+ signal: NodeJS.Signals | null;
120
+ success: boolean;
121
+ /** Whether the script was skipped due to a failed dependency */
122
+ skipped?: boolean;
123
+ startTimeISO: string;
124
+ endTimeISO: string;
125
+ durationMs: number;
126
+ metadata: ScriptMetadata;
127
+ };
128
+ export type RunScriptsSummary<ScriptMetadata extends object = object> = {
129
+ totalCount: number;
130
+ successCount: number;
131
+ failureCount: number;
132
+ allSuccess: boolean;
133
+ startTimeISO: string;
134
+ endTimeISO: string;
135
+ durationMs: number;
136
+ scriptResults: RunScriptExit<ScriptMetadata>[];
137
+ };
138
+ export type ScriptEventName = "start" | "skip" | "exit";
139
+ export type RunScriptsParallelOptions = {
140
+ max: ParallelMaxValue;
141
+ };
142
+ /** Metadata about a {@link Project}'s script, including the workspaces that have it in their package.json */
143
+ export type WorkspaceScriptMetadata = {
144
+ name: string;
145
+ workspaces: Workspace[];
146
+ };
147
+ /** Arguments for {@link Project.createScriptCommand} */
148
+ export type CreateProjectScriptCommandOptions = {
149
+ /** The workspace to run the script in */
150
+ workspaceNameOrAlias: string;
151
+ /** The name of the script to run */
152
+ scriptName: string;
153
+ /**
154
+ * The method to use to run the script.
155
+ * Either run in the workspace directory or use bun's --filter option.
156
+ * Defaults to "cd".
157
+ */
158
+ method?: WorkspaceScriptCommandMethod;
159
+ /** The arguments to append to the command */
160
+ args?: string;
161
+ };
162
+ /** Result of {@link Project.createScriptCommand}. Includes a command string that will run a workspace's script. */
163
+ export type CreateProjectScriptCommandResult = {
164
+ /** Data including a command string using the `bun`
165
+ * CLI that will run a workspace's script and the
166
+ * directory to run it in. */
167
+ commandDetails: ScriptCommand;
168
+ /** The name of the script to run */
169
+ scriptName: string;
170
+ /** The workspace that the script belongs to */
171
+ workspace: Workspace;
172
+ };
173
+ /** The config for a project and its workspaces */
174
+ export type ProjectConfig = {
175
+ root: ResolvedRootConfig;
176
+ /** A map of workspace names to their resolved config */
177
+ workspaces: Record<string, ResolvedWorkspaceConfig>;
178
+ };
179
+ /**
180
+ * A project contains a collection of workspaces and is the core of `bun-workspaces`'s functionality.
181
+ *
182
+ * Typically based on a root package.json file's `"workspaces"` field and any matching nested package.json files that are found.
183
+ */
184
+ export interface Project {
185
+ /** The name of the project. This is typically the name of the root package.json unless otherwise provided. */
186
+ name: string;
187
+ /** The root directory of the project */
188
+ rootDirectory: string;
189
+ /** The root workspace of the project */
190
+ rootWorkspace: Workspace;
191
+ /** The list of all workspaces in the project */
192
+ workspaces: Workspace[];
193
+ /** The config for the project and its workspaces */
194
+ config: ProjectConfig;
195
+ /** The means by which the project was created */
196
+ sourceType: "fileSystem" | "memory";
197
+ /** Find a workspace by its package.json name */
198
+ findWorkspaceByName(workspaceName: string): Workspace | null;
199
+ /** Find a workspace by a workspace alias */
200
+ findWorkspaceByAlias(alias: string): Workspace | null;
201
+ /** Find a workspace that matches a workspace's name or an alias if no name matches. */
202
+ findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
203
+ /** Find a list of workspaces that have a given tag in their configuration */
204
+ listWorkspacesWithTag(tag: string): Workspace[];
205
+ /** Accepts a wildcard pattern for finding a list of workspaces by their name*/
206
+ findWorkspacesByPattern(workspacePattern: string): Workspace[];
207
+ /** Get an array of all workspaces that have a given script in their package.json */
208
+ listWorkspacesWithScript(scriptName: string): Workspace[];
209
+ /** Get a mapping of all scripts to the workspaces that have them in their package.json */
210
+ mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
211
+ /** Get a mapping of all tags to the workspaces that have them in their config */
212
+ mapTagsToWorkspaces(): Record<string, Workspace[]>;
213
+ /** Create metadata that can be used to run a workspace's script */
214
+ createScriptCommand(
215
+ options: CreateProjectScriptCommandOptions,
216
+ ): CreateProjectScriptCommandResult;
217
+ }
218
+ declare abstract class ProjectBase implements Project {
219
+ abstract readonly name: string;
220
+ abstract readonly rootDirectory: string;
221
+ abstract readonly rootWorkspace: Workspace;
222
+ abstract readonly workspaces: Workspace[];
223
+ abstract readonly sourceType: "fileSystem" | "memory";
224
+ abstract readonly config: ProjectConfig;
225
+ constructor(_ignoreBunVersion?: boolean);
226
+ listWorkspacesWithScript(scriptName: string): Workspace[];
227
+ mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
228
+ mapTagsToWorkspaces(): Record<string, Workspace[]>;
229
+ findWorkspaceByName(workspaceName: string): Workspace | null;
230
+ findWorkspaceByAlias(alias: string): Workspace | null;
231
+ findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
232
+ listWorkspacesWithTag(tag: string): Workspace[];
233
+ findWorkspacesByPattern(...workspacePatterns: string[]): Workspace[];
234
+ createScriptCommand(
235
+ options: CreateProjectScriptCommandOptions,
236
+ ): CreateProjectScriptCommandResult;
237
+ }
238
+ /** Arguments for {@link createFileSystemProject} */
239
+ export type CreateFileSystemProjectOptions = {
240
+ /** The directory containing the root package.json. Often the same root as a git repository. Relative to process.cwd(). The default is process.cwd(). */
241
+ rootDirectory?: string;
242
+ /**
243
+ * The name of the project.
244
+ *
245
+ * By default will use the root package.json name
246
+ */
247
+ name?: string;
248
+ /** Whether to include the root workspace as a normal workspace. This overrides any config or env var settings. */
249
+ includeRootWorkspace?: boolean;
250
+ };
251
+ export type InlineScriptOptions = {
252
+ /** A name to act as a label for the inline script */
253
+ scriptName?: string;
254
+ /** Whether to run the script as an inline command */
255
+ shell?: ShellOption;
256
+ };
257
+ /** Arguments for `FileSystemProject.runWorkspaceScript` */
258
+ export type RunWorkspaceScriptOptions = {
259
+ /** The name of the workspace to run the script in */
260
+ workspaceNameOrAlias: string;
261
+ /** The name of the script to run, or an inline command when `inline` is true */
262
+ script: string;
263
+ /** Whether to run the script as an inline command */
264
+ inline?: boolean | InlineScriptOptions;
265
+ /** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
266
+ args?: string | string[];
267
+ /** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
268
+ ignoreOutput?: boolean;
269
+ };
270
+ /** Metadata associated with a workspace script */
271
+ export type RunWorkspaceScriptMetadata = {
272
+ /** The workspace that the script was run in */
273
+ workspace: Workspace;
274
+ };
275
+ export type RunWorkspaceScriptExit = Simplify<
276
+ RunScriptExit<RunWorkspaceScriptMetadata>
277
+ >;
278
+ export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
279
+ RunWorkspaceScriptMetadata & {
280
+ streamName: OutputStreamName;
281
+ }
282
+ >;
283
+ /** Result of `FileSystemProject.runWorkspaceScript` */
284
+ export type RunWorkspaceScriptResult = {
285
+ /** Use to get the output of the script */
286
+ output: RunWorkspaceScriptProcessOutput;
287
+ /** The exit result of the script */
288
+ exit: Promise<RunWorkspaceScriptExit>;
289
+ };
290
+ export type ParallelOption = boolean | RunScriptsParallelOptions;
291
+ export type ScriptEventMetadata = {
292
+ /** The workspace that the script event occurred in */
293
+ workspace: Workspace;
294
+ /** The exit result of the script */
295
+ exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
296
+ };
297
+ export type OnScriptEventCallback = (
298
+ /** The event that occurred */
299
+ event: ScriptEventName,
300
+ /** The metadata for the script event */
301
+ metadata: ScriptEventMetadata,
302
+ ) => unknown;
303
+ /** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
304
+ export type RunScriptAcrossWorkspacesOptions = {
305
+ /**
306
+ * Workspace names, aliases, or patterns including a wildcard.
307
+ *
308
+ * When not provided, all workspaces that the script can be ran in will be used.
309
+ */
310
+ workspacePatterns?: string[];
311
+ /** The name of the script to run, or an inline command when `inline` is true */
312
+ script: string;
313
+ /** Whether to run the script as an inline command */
314
+ inline?: boolean | InlineScriptOptions;
315
+ /** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
316
+ args?: string | string[];
317
+ /** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
318
+ parallel?: ParallelOption;
319
+ /** When `true`, run scripts so that dependent workspaces run only after their dependencies */
320
+ dependencyOrder?: boolean;
321
+ /** When `true`, continue running scripts even if a dependency fails (Only relevant when `dependencyOrder` is `true`) */
322
+ ignoreDependencyFailure?: boolean;
323
+ /** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
324
+ ignoreOutput?: boolean;
325
+ /** Callback to invoke when a script event occurs (start, skip, exit) */
326
+ onScriptEvent?: OnScriptEventCallback;
327
+ };
328
+ export type RunScriptAcrossWorkspacesSummary = Simplify<
329
+ RunScriptsSummary<RunWorkspaceScriptMetadata>
330
+ >;
331
+ export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
332
+ RunWorkspaceScriptMetadata & {
333
+ streamName: OutputStreamName;
334
+ }
335
+ >;
336
+ /** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
337
+ export type RunScriptAcrossWorkspacesResult = {
338
+ /** Use to get the output of the scripts */
339
+ output: RunScriptAcrossWorkspacesOutput;
340
+ /** The summary of the script run with exit details for each workspace */
341
+ summary: Promise<RunScriptAcrossWorkspacesSummary>;
342
+ /** The workspaces targeted */
343
+ workspaces: Workspace[];
344
+ };
345
+ declare class _FileSystemProject extends ProjectBase implements Project {
346
+ #private;
347
+ readonly rootDirectory: string;
348
+ readonly workspaces: Workspace[];
349
+ readonly name: string;
350
+ readonly sourceType = "fileSystem";
351
+ readonly config: ProjectConfig;
352
+ readonly rootWorkspace: Workspace;
353
+ constructor(options: CreateFileSystemProjectOptions);
354
+ runWorkspaceScript(
355
+ options: RunWorkspaceScriptOptions,
356
+ ): RunWorkspaceScriptResult;
357
+ runScriptAcrossWorkspaces(
358
+ options: RunScriptAcrossWorkspacesOptions,
359
+ ): RunScriptAcrossWorkspacesResult;
360
+ }
361
+ /** An implementation of {@link Project} that is created from a root directory in the file system. */
362
+ export type FileSystemProject = Simplify<_FileSystemProject>;
363
+ declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
364
+ export type LogLevel = (typeof LOG_LEVELS)[number];
365
+ export type LogLevelSetting = LogLevel | "silent";
366
+ export interface CliCommandConfig {
367
+ command: string;
368
+ isGlobal: boolean;
369
+ aliases: string[] | readonly string[];
370
+ description: string;
371
+ options: Record<
372
+ string,
373
+ {
374
+ flags: string[] | readonly string[];
375
+ description: string;
376
+ values?: string[];
377
+ deprecated?: boolean;
378
+ }
379
+ >;
380
+ }
381
+ export type CliCommandName = keyof typeof CLI_COMMANDS_CONFIG;
382
+ export type CliGlobalCommandName = {
383
+ [K in CliCommandName]: (typeof CLI_COMMANDS_CONFIG)[K] extends {
384
+ isGlobal: true;
385
+ }
386
+ ? K
387
+ : never;
388
+ }[CliCommandName];
389
+ export type CliProjectCommandName = Exclude<
390
+ CliCommandName,
391
+ CliGlobalCommandName
392
+ >;
393
+ export declare const JSON_FLAGS: readonly ["-j", "--json"];
394
+ export declare const PRETTY_FLAGS: readonly ["-p", "--pretty"];
395
+ export declare const CLI_COMMANDS_CONFIG: {
396
+ readonly doctor: {
397
+ readonly command: "doctor";
398
+ readonly isGlobal: true;
399
+ readonly aliases: [];
400
+ readonly description: "Print diagnostic information";
401
+ readonly options: {
402
+ readonly json: {
403
+ readonly flags: readonly ["-j", "--json"];
404
+ readonly description: "Output as JSON";
405
+ };
406
+ readonly pretty: {
407
+ readonly flags: readonly ["-p", "--pretty"];
408
+ readonly description: "Pretty print JSON";
409
+ };
410
+ };
411
+ };
412
+ readonly listWorkspaces: {
413
+ readonly command: "list-workspaces [workspacePatterns...]";
414
+ readonly isGlobal: false;
415
+ readonly aliases: ["ls", "list"];
416
+ readonly description: "List all workspaces";
417
+ readonly options: {
418
+ readonly workspacePatterns: {
419
+ readonly flags: ["-W", "--workspace-patterns <patterns>"];
420
+ readonly description: "Workspace patterns to match, separated by spaces";
421
+ };
422
+ readonly nameOnly: {
423
+ readonly flags: ["-n", "--name-only"];
424
+ readonly description: "Only show workspace names";
425
+ };
426
+ readonly json: {
427
+ readonly flags: readonly ["-j", "--json"];
428
+ readonly description: "Output as JSON";
429
+ };
430
+ readonly pretty: {
431
+ readonly flags: readonly ["-p", "--pretty"];
432
+ readonly description: "Pretty print JSON";
433
+ };
434
+ };
435
+ };
436
+ readonly listScripts: {
437
+ readonly command: "list-scripts";
438
+ readonly isGlobal: false;
439
+ readonly aliases: ["ls-scripts"];
440
+ readonly description: "List all scripts available with their workspaces";
441
+ readonly options: {
442
+ readonly nameOnly: {
443
+ readonly flags: ["-n", "--name-only"];
444
+ readonly description: "Only show script names";
445
+ };
446
+ readonly json: {
447
+ readonly flags: readonly ["-j", "--json"];
448
+ readonly description: "Output as JSON";
449
+ };
450
+ readonly pretty: {
451
+ readonly flags: readonly ["-p", "--pretty"];
452
+ readonly description: "Pretty print JSON";
453
+ };
454
+ };
455
+ };
456
+ readonly workspaceInfo: {
457
+ readonly command: "workspace-info <workspaceName>";
458
+ readonly isGlobal: false;
459
+ readonly aliases: ["info"];
460
+ readonly description: "Show information about a workspace";
461
+ readonly options: {
462
+ readonly json: {
463
+ readonly flags: readonly ["-j", "--json"];
464
+ readonly description: "Output as JSON";
465
+ };
466
+ readonly pretty: {
467
+ readonly flags: readonly ["-p", "--pretty"];
468
+ readonly description: "Pretty print JSON";
469
+ };
470
+ };
471
+ };
472
+ readonly scriptInfo: {
473
+ readonly command: "script-info <script>";
474
+ readonly isGlobal: false;
475
+ readonly aliases: [];
476
+ readonly description: "Show information about a script";
477
+ readonly options: {
478
+ readonly workspacesOnly: {
479
+ readonly flags: ["-w", "--workspaces-only"];
480
+ readonly description: "Only show script's workspace names";
481
+ };
482
+ readonly json: {
483
+ readonly flags: readonly ["-j", "--json"];
484
+ readonly description: "Output as JSON";
485
+ };
486
+ readonly pretty: {
487
+ readonly flags: readonly ["-p", "--pretty"];
488
+ readonly description: "Pretty print JSON";
489
+ };
490
+ };
491
+ };
492
+ readonly listTags: {
493
+ readonly command: "list-tags";
494
+ readonly isGlobal: false;
495
+ readonly aliases: ["ls-tags"];
496
+ readonly description: "List all tags available with their workspaces";
497
+ readonly options: {
498
+ readonly nameOnly: {
499
+ readonly flags: ["-n", "--name-only"];
500
+ readonly description: "Only show tag names";
501
+ };
502
+ readonly json: {
503
+ readonly flags: readonly ["-j", "--json"];
504
+ readonly description: "Output as JSON";
505
+ };
506
+ readonly pretty: {
507
+ readonly flags: readonly ["-p", "--pretty"];
508
+ readonly description: "Pretty print JSON";
509
+ };
510
+ };
511
+ };
512
+ readonly tagInfo: {
513
+ readonly command: "tag-info <tag>";
514
+ readonly isGlobal: false;
515
+ readonly aliases: [];
516
+ readonly description: "Show information about a tag";
517
+ readonly options: {
518
+ readonly json: {
519
+ readonly flags: readonly ["-j", "--json"];
520
+ readonly description: "Output as JSON";
521
+ };
522
+ readonly pretty: {
523
+ readonly flags: readonly ["-p", "--pretty"];
524
+ readonly description: "Pretty print JSON";
525
+ };
526
+ };
527
+ };
528
+ readonly mcpServer: {
529
+ readonly command: "mcp-server";
530
+ readonly isGlobal: false;
531
+ readonly aliases: [];
532
+ readonly description: "Start the bun-workspaces MCP (Model Context Protocol) server over stdio";
533
+ readonly options: {};
534
+ };
535
+ readonly runScript: {
536
+ readonly command: "run-script [script] [workspacePatterns...]";
537
+ readonly isGlobal: false;
538
+ readonly aliases: ["run"];
539
+ readonly description: 'Run a script in all workspaces that have it in their "scripts" field in package.json';
540
+ readonly options: {
541
+ readonly script: {
542
+ readonly flags: ["-S", "--script <script>"];
543
+ readonly description: "The script to run.";
544
+ };
545
+ readonly workspacePatterns: {
546
+ readonly flags: ["-W", "--workspace-patterns <patterns>"];
547
+ readonly description: "Workspace patterns to match, separated by spaces.";
548
+ };
549
+ readonly parallel: {
550
+ readonly flags: ["-P", "--parallel [max]"];
551
+ readonly description: 'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"';
552
+ };
553
+ readonly args: {
554
+ readonly flags: ["-a", "--args <args>"];
555
+ readonly description: "Args to append to the script command";
556
+ };
557
+ readonly outputStyle: {
558
+ readonly flags: ["-o", "--output-style <style>"];
559
+ readonly description: "The output style to use";
560
+ readonly values: ["grouped", "prefixed", "plain", "none"];
561
+ };
562
+ readonly groupedLines: {
563
+ readonly flags: ["-L", "--grouped-lines <count>"];
564
+ readonly description: 'With grouped output, the max preview lines (number or "auto", default "auto")';
565
+ };
566
+ readonly noPrefix: {
567
+ readonly flags: ["-N", "--no-prefix"];
568
+ readonly description: "(DEPRECATED) Use --output-style=plain instead";
569
+ readonly deprecated: true;
570
+ };
571
+ readonly inline: {
572
+ readonly flags: ["-i", "--inline"];
573
+ readonly description: "Run the script as an inline command from the workspace directory";
574
+ };
575
+ readonly inlineName: {
576
+ readonly flags: ["-I", "--inline-name <name>"];
577
+ readonly description: "An optional name for the script when --inline is passed";
578
+ };
579
+ readonly shell: {
580
+ readonly flags: ["-s", "--shell <shell>"];
581
+ readonly values: ["bun", "system", "default"];
582
+ readonly description: "When using --inline, the shell to use to run the script";
583
+ };
584
+ readonly depOrder: {
585
+ readonly flags: ["-d", "--dep-order"];
586
+ readonly description: "Scripts for dependent workspaces run only after their dependencies";
587
+ };
588
+ readonly ignoreDepFailure: {
589
+ readonly flags: ["-f", "--ignore-dep-failure"];
590
+ readonly description: "In dependency order, continue running scripts even if a dependency fails";
591
+ };
592
+ readonly jsonOutfile: {
593
+ readonly flags: ["-j", "--json-outfile <file>"];
594
+ readonly description: "Output results in a JSON file";
595
+ };
596
+ };
597
+ };
598
+ };
599
+ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
600
+ | {
601
+ readonly command: "doctor";
602
+ readonly isGlobal: true;
603
+ readonly aliases: [];
604
+ readonly description: "Print diagnostic information";
605
+ readonly options: {
606
+ readonly json: {
607
+ readonly flags: readonly ["-j", "--json"];
608
+ readonly description: "Output as JSON";
609
+ };
610
+ readonly pretty: {
611
+ readonly flags: readonly ["-p", "--pretty"];
612
+ readonly description: "Pretty print JSON";
613
+ };
614
+ };
615
+ }
616
+ | {
617
+ readonly command: "list-workspaces [workspacePatterns...]";
618
+ readonly isGlobal: false;
619
+ readonly aliases: ["ls", "list"];
620
+ readonly description: "List all workspaces";
621
+ readonly options: {
622
+ readonly workspacePatterns: {
623
+ readonly flags: ["-W", "--workspace-patterns <patterns>"];
624
+ readonly description: "Workspace patterns to match, separated by spaces";
625
+ };
626
+ readonly nameOnly: {
627
+ readonly flags: ["-n", "--name-only"];
628
+ readonly description: "Only show workspace names";
629
+ };
630
+ readonly json: {
631
+ readonly flags: readonly ["-j", "--json"];
632
+ readonly description: "Output as JSON";
633
+ };
634
+ readonly pretty: {
635
+ readonly flags: readonly ["-p", "--pretty"];
636
+ readonly description: "Pretty print JSON";
637
+ };
638
+ };
639
+ }
640
+ | {
641
+ readonly command: "list-scripts";
642
+ readonly isGlobal: false;
643
+ readonly aliases: ["ls-scripts"];
644
+ readonly description: "List all scripts available with their workspaces";
645
+ readonly options: {
646
+ readonly nameOnly: {
647
+ readonly flags: ["-n", "--name-only"];
648
+ readonly description: "Only show script names";
649
+ };
650
+ readonly json: {
651
+ readonly flags: readonly ["-j", "--json"];
652
+ readonly description: "Output as JSON";
653
+ };
654
+ readonly pretty: {
655
+ readonly flags: readonly ["-p", "--pretty"];
656
+ readonly description: "Pretty print JSON";
657
+ };
658
+ };
659
+ }
660
+ | {
661
+ readonly command: "workspace-info <workspaceName>";
662
+ readonly isGlobal: false;
663
+ readonly aliases: ["info"];
664
+ readonly description: "Show information about a workspace";
665
+ readonly options: {
666
+ readonly json: {
667
+ readonly flags: readonly ["-j", "--json"];
668
+ readonly description: "Output as JSON";
669
+ };
670
+ readonly pretty: {
671
+ readonly flags: readonly ["-p", "--pretty"];
672
+ readonly description: "Pretty print JSON";
673
+ };
674
+ };
675
+ }
676
+ | {
677
+ readonly command: "script-info <script>";
678
+ readonly isGlobal: false;
679
+ readonly aliases: [];
680
+ readonly description: "Show information about a script";
681
+ readonly options: {
682
+ readonly workspacesOnly: {
683
+ readonly flags: ["-w", "--workspaces-only"];
684
+ readonly description: "Only show script's workspace names";
685
+ };
686
+ readonly json: {
687
+ readonly flags: readonly ["-j", "--json"];
688
+ readonly description: "Output as JSON";
689
+ };
690
+ readonly pretty: {
691
+ readonly flags: readonly ["-p", "--pretty"];
692
+ readonly description: "Pretty print JSON";
693
+ };
694
+ };
695
+ }
696
+ | {
697
+ readonly command: "list-tags";
698
+ readonly isGlobal: false;
699
+ readonly aliases: ["ls-tags"];
700
+ readonly description: "List all tags available with their workspaces";
701
+ readonly options: {
702
+ readonly nameOnly: {
703
+ readonly flags: ["-n", "--name-only"];
704
+ readonly description: "Only show tag names";
705
+ };
706
+ readonly json: {
707
+ readonly flags: readonly ["-j", "--json"];
708
+ readonly description: "Output as JSON";
709
+ };
710
+ readonly pretty: {
711
+ readonly flags: readonly ["-p", "--pretty"];
712
+ readonly description: "Pretty print JSON";
713
+ };
714
+ };
715
+ }
716
+ | {
717
+ readonly command: "tag-info <tag>";
718
+ readonly isGlobal: false;
719
+ readonly aliases: [];
720
+ readonly description: "Show information about a tag";
721
+ readonly options: {
722
+ readonly json: {
723
+ readonly flags: readonly ["-j", "--json"];
724
+ readonly description: "Output as JSON";
725
+ };
726
+ readonly pretty: {
727
+ readonly flags: readonly ["-p", "--pretty"];
728
+ readonly description: "Pretty print JSON";
729
+ };
730
+ };
731
+ }
732
+ | {
733
+ readonly command: "mcp-server";
734
+ readonly isGlobal: false;
735
+ readonly aliases: [];
736
+ readonly description: "Start the bun-workspaces MCP (Model Context Protocol) server over stdio";
737
+ readonly options: {};
738
+ }
739
+ | {
740
+ readonly command: "run-script [script] [workspacePatterns...]";
741
+ readonly isGlobal: false;
742
+ readonly aliases: ["run"];
743
+ readonly description: 'Run a script in all workspaces that have it in their "scripts" field in package.json';
744
+ readonly options: {
745
+ readonly script: {
746
+ readonly flags: ["-S", "--script <script>"];
747
+ readonly description: "The script to run.";
748
+ };
749
+ readonly workspacePatterns: {
750
+ readonly flags: ["-W", "--workspace-patterns <patterns>"];
751
+ readonly description: "Workspace patterns to match, separated by spaces.";
752
+ };
753
+ readonly parallel: {
754
+ readonly flags: ["-P", "--parallel [max]"];
755
+ readonly description: 'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"';
756
+ };
757
+ readonly args: {
758
+ readonly flags: ["-a", "--args <args>"];
759
+ readonly description: "Args to append to the script command";
760
+ };
761
+ readonly outputStyle: {
762
+ readonly flags: ["-o", "--output-style <style>"];
763
+ readonly description: "The output style to use";
764
+ readonly values: ["grouped", "prefixed", "plain", "none"];
765
+ };
766
+ readonly groupedLines: {
767
+ readonly flags: ["-L", "--grouped-lines <count>"];
768
+ readonly description: 'With grouped output, the max preview lines (number or "auto", default "auto")';
769
+ };
770
+ readonly noPrefix: {
771
+ readonly flags: ["-N", "--no-prefix"];
772
+ readonly description: "(DEPRECATED) Use --output-style=plain instead";
773
+ readonly deprecated: true;
774
+ };
775
+ readonly inline: {
776
+ readonly flags: ["-i", "--inline"];
777
+ readonly description: "Run the script as an inline command from the workspace directory";
778
+ };
779
+ readonly inlineName: {
780
+ readonly flags: ["-I", "--inline-name <name>"];
781
+ readonly description: "An optional name for the script when --inline is passed";
782
+ };
783
+ readonly shell: {
784
+ readonly flags: ["-s", "--shell <shell>"];
785
+ readonly values: ["bun", "system", "default"];
786
+ readonly description: "When using --inline, the shell to use to run the script";
787
+ };
788
+ readonly depOrder: {
789
+ readonly flags: ["-d", "--dep-order"];
790
+ readonly description: "Scripts for dependent workspaces run only after their dependencies";
791
+ };
792
+ readonly ignoreDepFailure: {
793
+ readonly flags: ["-f", "--ignore-dep-failure"];
794
+ readonly description: "In dependency order, continue running scripts even if a dependency fails";
795
+ };
796
+ readonly jsonOutfile: {
797
+ readonly flags: ["-j", "--json-outfile <file>"];
798
+ readonly description: "Output results in a JSON file";
799
+ };
800
+ };
801
+ };
802
+ export declare const getCliCommandNames: () => CliCommandName[];
803
+ export interface CliGlobalOptions {
804
+ logLevel: LogLevelSetting;
805
+ cwd: string;
806
+ includeRoot: boolean;
807
+ workspaceRoot: boolean;
808
+ }
809
+ export interface CliGlobalOptionConfig {
810
+ mainOption: string;
811
+ shortOption: string;
812
+ description: string;
813
+ defaultValue: string;
814
+ values: string[] | null;
815
+ param: string;
816
+ }
817
+ export type CliGlobalOptionName = keyof CliGlobalOptions;
818
+ export declare const getCliGlobalOptionConfig: (
819
+ optionName: CliGlobalOptionName,
820
+ ) =>
821
+ | {
822
+ readonly mainOption: "--log-level";
823
+ readonly shortOption: "-l";
824
+ readonly description: "Log levels";
825
+ readonly defaultValue: "info";
826
+ readonly values: ("debug" | "info" | "warn" | "error" | "silent")[];
827
+ readonly param: "level";
828
+ }
829
+ | {
830
+ readonly mainOption: "--cwd";
831
+ readonly shortOption: "-d";
832
+ readonly description: "Working directory";
833
+ readonly defaultValue: "";
834
+ readonly values: null;
835
+ readonly param: "path";
836
+ }
837
+ | {
838
+ readonly mainOption: "--include-root";
839
+ readonly shortOption: "-r";
840
+ readonly description: "Include the root workspace as a normal workspace";
841
+ readonly defaultValue: "";
842
+ readonly values: null;
843
+ readonly param: "";
844
+ }
845
+ | {
846
+ readonly mainOption: "--workspace-root";
847
+ readonly shortOption: "-w";
848
+ readonly description: "Run from the project root above the current working directory";
849
+ readonly defaultValue: "";
850
+ readonly values: null;
851
+ readonly param: "";
852
+ };
853
+ export declare const getCliGlobalOptionNames: () => CliGlobalOptionName[];
854
+ /** @todo DRY use of output text in cases such as having no workspaces/scripts */
855
+ export type GlobalCommandContext = {
856
+ program: Command;
857
+ postTerminatorArgs: string[];
858
+ middleware: CliMiddleware;
859
+ outputWriters: Required<WriteOutputOptions>;
860
+ terminalWidth: number;
861
+ terminalHeight: number;
862
+ };
863
+ export type ProjectCommandContext = GlobalCommandContext & {
864
+ project: FileSystemProject;
865
+ projectError: Error | null;
866
+ };
867
+ export type InitProgramContext = {
868
+ commanderProgram: CommanderProgram;
869
+ argv: string[];
870
+ };
871
+ export type ProcessArgvContext = {
872
+ commanderProgram: CommanderProgram;
873
+ args: string[];
874
+ postTerminatorArgs: string[];
875
+ };
876
+ export type ProcessWorkingDirectoryContext = {
877
+ commanderProgram: CommanderProgram;
878
+ workingDirectory: string;
879
+ exists: boolean;
880
+ isDirectory: boolean;
881
+ };
882
+ export type FindProjectContext = {
883
+ commanderProgram: CommanderProgram;
884
+ project: FileSystemProject;
885
+ projectError: Error | null;
886
+ };
887
+ export type PreParseContext = {
888
+ commanderProgram: CommanderProgram;
889
+ args: string[];
890
+ project: FileSystemProject;
891
+ projectError: Error | null;
892
+ };
893
+ export type PostParseContext = {
894
+ commanderProgram: CommanderProgram;
895
+ args: string[];
896
+ project: FileSystemProject;
897
+ projectError: Error | null;
898
+ };
899
+ export type CommandMiddlewareContext<C extends CliCommandName> = {
900
+ commanderProgram: CommanderProgram;
901
+ commandName: C;
902
+ commandContext: C extends CliGlobalCommandName
903
+ ? GlobalCommandContext
904
+ : ProjectCommandContext;
905
+ commanderActionArgs: unknown[];
906
+ };
907
+ export type CommandMiddleware = <C extends CliCommandName>(
908
+ context: CommandMiddlewareContext<C>,
909
+ ) => CommanderProgram;
910
+ export type CliMiddleware = {
911
+ /** The first callback when the Commander program is created */
912
+ initProgram: (context: InitProgramContext) => CommanderProgram;
913
+ /** Before the true parsing, just splitting the argv into args and post-terminator args */
914
+ processArgv: (context: ProcessArgvContext) => CommanderProgram;
915
+ /** Before the working directory is changed */
916
+ processWorkingDirectory: (
917
+ context: ProcessWorkingDirectoryContext,
918
+ ) => CommanderProgram;
919
+ /** After the project has been initialized from global options */
920
+ findProject: (context: FindProjectContext) => CommanderProgram;
921
+ /** Before the Commander program parses the args */
922
+ preParse: (context: PreParseContext) => CommanderProgram;
923
+ /** After the Commander program has parsed the args (runs in finally block) */
924
+ postParse: (context: PostParseContext) => CommanderProgram;
925
+ /** Before a command is handled */
926
+ preHandleCommand: CommandMiddleware;
927
+ /** After a command is handled */
928
+ postHandleCommand: CommandMiddleware;
929
+ /** After the program has been parsed */
930
+ catchError: (error: Error) => unknown;
931
+ };
932
+ export type CliMiddlewareOptions = Partial<CliMiddleware>;
933
+ export interface WriteOutputOptions {
934
+ stdout?: (...args: Parameters<typeof process.stdout.write>) => void;
935
+ stderr?: (...args: Parameters<typeof process.stderr.write>) => void;
936
+ }
937
+ export interface RunCliOptions {
938
+ argv?: string[];
939
+ /** Should be `true` if args do not include the binary name (e.g. `bunx bun-workspaces`) */
940
+ programmatic?: true;
941
+ middleware?: CliMiddlewareOptions;
942
+ writeOutput?: WriteOutputOptions;
943
+ terminalWidth?: number;
944
+ terminalHeight?: number;
945
+ }
946
+ export interface CLI {
947
+ run: (options?: RunCliOptions) => Promise<void>;
948
+ }
949
+ export interface CreateCliOptions {
950
+ defaultCwd?: string;
951
+ /** Always handled when the result `.run()` is called */
952
+ defaultMiddleware?: CliMiddlewareOptions;
953
+ }
954
+ export declare const createCli: ({
955
+ defaultCwd,
956
+ defaultMiddleware,
957
+ }?: CreateCliOptions) => CLI;
958
+ export declare const defineGlobalCommands: (
959
+ context: GlobalCommandContext,
960
+ ) => void;
961
+ export declare const defineProjectCommands: (
962
+ context: ProjectCommandContext,
963
+ ) => void;
964
+ export declare const mcpServer: (
965
+ context: ProjectCommandContext,
966
+ ) => import("commander").Command;
967
+ export declare const runScript: (
968
+ context: ProjectCommandContext,
969
+ ) => import("commander").Command;
970
+ export type RenderPlainOutputOptions = {
971
+ stripDisruptiveControls?: boolean;
972
+ prefix?: boolean;
973
+ };
974
+ export declare function generatePlainOutputLines(
975
+ output: RunScriptAcrossWorkspacesOutput,
976
+ { stripDisruptiveControls, prefix }: RenderPlainOutputOptions,
977
+ ): AsyncGenerator<
978
+ {
979
+ line: string;
980
+ metadata: RunWorkspaceScriptMetadata & {
981
+ streamName: OutputStreamName;
982
+ };
983
+ },
984
+ void,
985
+ unknown
986
+ >;
987
+ export declare const renderPlainOutput: (
988
+ output: RunScriptAcrossWorkspacesOutput,
989
+ outputWriters: Required<WriteOutputOptions>,
990
+ { stripDisruptiveControls, prefix }: RenderPlainOutputOptions,
991
+ ) => Promise<void>;
992
+ export declare const initializeWithGlobalOptions: (
993
+ program: Command,
994
+ args: string[],
995
+ middleware: CliMiddleware,
996
+ ) => {
997
+ project: Simplify<{
998
+ readonly rootDirectory: string;
999
+ readonly workspaces: Workspace[];
1000
+ readonly name: string;
1001
+ readonly sourceType: "fileSystem";
1002
+ readonly config: ProjectConfig;
1003
+ readonly rootWorkspace: Workspace;
1004
+ runWorkspaceScript(
1005
+ options: RunWorkspaceScriptOptions,
1006
+ ): RunWorkspaceScriptResult;
1007
+ runScriptAcrossWorkspaces(
1008
+ options: RunScriptAcrossWorkspacesOptions,
1009
+ ): RunScriptAcrossWorkspacesResult;
1010
+ listWorkspacesWithScript(scriptName: string): Workspace[];
1011
+ mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
1012
+ mapTagsToWorkspaces(): Record<string, Workspace[]>;
1013
+ findWorkspaceByName(workspaceName: string): Workspace | null;
1014
+ findWorkspaceByAlias(alias: string): Workspace | null;
1015
+ findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
1016
+ listWorkspacesWithTag(tag: string): Workspace[];
1017
+ findWorkspacesByPattern(...workspacePatterns: string[]): Workspace[];
1018
+ createScriptCommand(
1019
+ options: CreateProjectScriptCommandOptions,
1020
+ ): CreateProjectScriptCommandResult;
1021
+ }>;
1022
+ projectError: Error | null;
1023
+ };
1024
+
1025
+ export {};