bun-workspaces 1.5.1 → 1.6.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.
Files changed (260) hide show
  1. package/README.md +96 -2
  2. package/bin/cli.js +0 -0
  3. package/package.json +1 -5
  4. package/src/1108.mjs +30 -0
  5. package/src/{cli/commands/commandsConfig.mjs → 2392.mjs} +52 -11
  6. package/src/4427.mjs +9 -0
  7. package/src/5166.mjs +8 -0
  8. package/src/8126.mjs +4 -0
  9. package/src/8257.mjs +4 -0
  10. package/src/{config/util/configLocation.mjs → 8529.mjs} +11 -2
  11. package/src/ai/mcp/bwMcpServer.mjs +299 -9
  12. package/src/ai/mcp/core/index.mjs +3 -1
  13. package/src/ai/mcp/core/server.mjs +1 -3
  14. package/src/ai/mcp/core/transport.mjs +1 -2
  15. package/src/ai/mcp/core/types.mjs +0 -1
  16. package/src/ai/mcp/index.mjs +3 -1
  17. package/src/ai/mcp/resources.mjs +1 -2
  18. package/src/ai/mcp/tools.mjs +1 -5
  19. package/src/cli/commands/commandHandlerUtils.mjs +2 -6
  20. package/src/cli/commands/commands.mjs +1 -4
  21. package/src/cli/commands/handleSimpleCommands.mjs +4 -10
  22. package/src/cli/commands/index.mjs +11 -2
  23. package/src/cli/commands/mcp.mjs +1 -4
  24. package/src/cli/commands/runScript/handleRunScript.mjs +1 -9
  25. package/src/cli/commands/runScript/index.mjs +3 -1
  26. package/src/cli/commands/runScript/output/index.mjs +3 -1
  27. package/src/cli/commands/runScript/output/outputStyle.mjs +1 -3
  28. package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +1 -6
  29. package/src/cli/commands/runScript/output/renderPlainOutput.mjs +1 -2
  30. package/src/cli/commands/runScript/output/sanitizeChunk.mjs +0 -1
  31. package/src/cli/createCli.mjs +2 -12
  32. package/src/cli/fatalErrorLogger.mjs +1 -2
  33. package/src/cli/globalOptions/globalOptions.mjs +2 -9
  34. package/src/cli/globalOptions/index.mjs +3 -2
  35. package/src/cli/index.d.ts +1085 -3
  36. package/src/cli/index.mjs +3 -1
  37. package/src/cli/middleware.mjs +1 -3
  38. package/src/config/index.mjs +3 -1
  39. package/src/config/public.d.ts +151 -10
  40. package/src/config/public.mjs +4 -6
  41. package/src/config/rootConfig/defineRootConfig.mjs +1 -2
  42. package/src/config/rootConfig/errors.mjs +1 -2
  43. package/src/config/rootConfig/index.mjs +3 -1
  44. package/src/config/rootConfig/loadRootConfig.mjs +1 -4
  45. package/src/config/rootConfig/mergeRootConfig.mjs +24 -0
  46. package/src/config/rootConfig/rootConfig.mjs +8 -6
  47. package/src/config/rootConfig/rootConfigSchema.mjs +19 -1
  48. package/src/config/userEnvVars/index.mjs +3 -1
  49. package/src/config/userEnvVars/userEnvVars.mjs +3 -8
  50. package/src/config/util/ajvTypes.mjs +2 -1
  51. package/src/config/util/index.mjs +2 -1
  52. package/src/config/util/loadConfig.mjs +1 -6
  53. package/src/config/util/validateConfig.mjs +0 -1
  54. package/src/config/workspaceConfig/defineWorkspaceConfig.mjs +1 -2
  55. package/src/config/workspaceConfig/errors.mjs +1 -2
  56. package/src/config/workspaceConfig/index.mjs +3 -1
  57. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +2 -8
  58. package/src/config/workspaceConfig/mergeWorkspaceConfig.mjs +75 -0
  59. package/src/config/workspaceConfig/workspaceConfig.mjs +1 -13
  60. package/src/config/workspaceConfig/workspaceConfigSchema.mjs +0 -1
  61. package/src/doctor/doctor.mjs +1 -5
  62. package/src/doctor/index.mjs +3 -1
  63. package/src/index.d.ts +516 -38
  64. package/src/index.mjs +4 -13
  65. package/src/internal/bun/bunLock.mjs +2 -4
  66. package/src/internal/bun/bunVersion.mjs +1 -3
  67. package/src/internal/bun/index.mjs +3 -1
  68. package/src/internal/bundledDeps/commander.mjs +3843 -0
  69. package/src/internal/bundledDeps/shellQuote.mjs +291 -0
  70. package/src/internal/core/error/error.mjs +0 -1
  71. package/src/internal/core/error/index.mjs +3 -1
  72. package/src/internal/core/index.mjs +3 -1
  73. package/src/internal/core/json/index.mjs +3 -1
  74. package/src/internal/core/json/json.mjs +3 -5
  75. package/src/internal/core/json/jsonc.mjs +0 -1
  76. package/src/internal/core/language/array/index.mjs +3 -1
  77. package/src/internal/core/language/array/optionalArray.mjs +0 -1
  78. package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +0 -1
  79. package/src/internal/core/language/asyncIterable/index.mjs +3 -1
  80. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +0 -1
  81. package/src/internal/core/language/events/typedEventTarget.mjs +0 -1
  82. package/src/internal/core/language/index.mjs +3 -1
  83. package/src/internal/core/language/regex/index.mjs +3 -1
  84. package/src/internal/core/language/regex/regex.mjs +0 -1
  85. package/src/internal/core/language/string/id.mjs +0 -1
  86. package/src/internal/core/language/string/index.mjs +3 -1
  87. package/src/internal/core/language/string/utf/eastAsianWidth.mjs +0 -1
  88. package/src/internal/core/language/string/utf/visibleLength.mjs +1 -2
  89. package/src/internal/core/language/types/index.mjs +3 -1
  90. package/src/internal/core/language/types/typeof.mjs +1 -3
  91. package/src/internal/core/language/types/types.mjs +3 -2
  92. package/src/internal/core/runtime/env.mjs +0 -1
  93. package/src/internal/core/runtime/index.mjs +3 -1
  94. package/src/internal/core/runtime/onExit.mjs +1 -2
  95. package/src/internal/core/runtime/os.mjs +1 -3
  96. package/src/internal/core/runtime/tempFile.mjs +1 -9
  97. package/src/internal/core/runtime/terminal.mjs +0 -1
  98. package/src/internal/generated/aiDocs/.gitkeep.mjs +1 -0
  99. package/src/internal/generated/aiDocs/docs.mjs +92 -15
  100. package/src/internal/generated/ajv/validateRootConfig.mjs +1 -1
  101. package/src/internal/logger/index.mjs +3 -1
  102. package/src/internal/logger/logger.mjs +4 -14
  103. package/src/internal/version.mjs +1 -2
  104. package/src/project/errors.mjs +1 -2
  105. package/src/project/implementations/fileSystemProject.mjs +4 -18
  106. package/src/project/implementations/memoryProject.mjs +1 -5
  107. package/src/project/implementations/projectBase.mjs +10 -19
  108. package/src/project/index.mjs +3 -1
  109. package/src/project/project.mjs +2 -1
  110. package/src/rslib-runtime.mjs +62 -0
  111. package/src/runScript/index.mjs +3 -1
  112. package/src/runScript/output/index.mjs +3 -1
  113. package/src/runScript/output/multiProcessOutput.mjs +1 -2
  114. package/src/runScript/output/outputStream.mjs +1 -1
  115. package/src/runScript/output/processOutput.mjs +1 -2
  116. package/src/runScript/parallel.mjs +4 -10
  117. package/src/runScript/recursion.mjs +1 -2
  118. package/src/runScript/runScript.mjs +1 -4
  119. package/src/runScript/runScripts.mjs +1 -6
  120. package/src/runScript/scriptCommand.mjs +1 -2
  121. package/src/runScript/scriptExecution.mjs +1 -3
  122. package/src/runScript/scriptRuntimeMetadata.mjs +38 -56
  123. package/src/runScript/scriptShellOption.mjs +5 -14
  124. package/src/runScript/subprocesses.mjs +1 -3
  125. package/src/workspaces/applyWorkspacePatternConfigs.mjs +58 -0
  126. package/src/workspaces/dependencyGraph/cycles.mjs +0 -1
  127. package/src/workspaces/dependencyGraph/index.mjs +3 -1
  128. package/src/workspaces/dependencyGraph/resolveDependencies.mjs +1 -2
  129. package/src/workspaces/dependencyGraph/validateDependencyRules.mjs +12 -13
  130. package/src/workspaces/errors.mjs +1 -2
  131. package/src/workspaces/findWorkspaces.mjs +11 -11
  132. package/src/workspaces/index.mjs +3 -1
  133. package/src/workspaces/packageJson.mjs +2 -7
  134. package/src/workspaces/workspace.mjs +2 -1
  135. package/src/workspaces/workspacePattern.mjs +4 -4
  136. package/src/ai/mcp/bwMcpServer.d.ts +0 -4
  137. package/src/ai/mcp/core/index.d.ts +0 -3
  138. package/src/ai/mcp/core/server.d.ts +0 -14
  139. package/src/ai/mcp/core/transport.d.ts +0 -12
  140. package/src/ai/mcp/core/types.d.ts +0 -104
  141. package/src/ai/mcp/index.d.ts +0 -2
  142. package/src/ai/mcp/resources.d.ts +0 -6
  143. package/src/ai/mcp/tools.d.ts +0 -6
  144. package/src/cli/commands/commandHandlerUtils.d.ts +0 -51
  145. package/src/cli/commands/commands.d.ts +0 -10
  146. package/src/cli/commands/commandsConfig.d.ts +0 -436
  147. package/src/cli/commands/handleSimpleCommands.d.ts +0 -21
  148. package/src/cli/commands/index.d.ts +0 -4
  149. package/src/cli/commands/mcp.d.ts +0 -3
  150. package/src/cli/commands/runScript/handleRunScript.d.ts +0 -3
  151. package/src/cli/commands/runScript/index.d.ts +0 -2
  152. package/src/cli/commands/runScript/output/index.d.ts +0 -1
  153. package/src/cli/commands/runScript/output/outputStyle.d.ts +0 -9
  154. package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +0 -75
  155. package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +0 -24
  156. package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +0 -4
  157. package/src/cli/createCli.d.ts +0 -26
  158. package/src/cli/fatalErrorLogger.d.ts +0 -1
  159. package/src/cli/globalOptions/globalOptions.d.ts +0 -43
  160. package/src/cli/globalOptions/globalOptionsConfig.d.ts +0 -52
  161. package/src/cli/globalOptions/globalOptionsConfig.mjs +0 -43
  162. package/src/cli/globalOptions/index.d.ts +0 -2
  163. package/src/cli/middleware.d.ts +0 -83
  164. package/src/config/index.d.ts +0 -3
  165. package/src/config/rootConfig/defineRootConfig.d.ts +0 -4
  166. package/src/config/rootConfig/errors.d.ts +0 -1
  167. package/src/config/rootConfig/index.d.ts +0 -5
  168. package/src/config/rootConfig/loadRootConfig.d.ts +0 -3
  169. package/src/config/rootConfig/rootConfig.d.ts +0 -25
  170. package/src/config/rootConfig/rootConfigLocation.d.ts +0 -2
  171. package/src/config/rootConfig/rootConfigLocation.mjs +0 -5
  172. package/src/config/rootConfig/rootConfigSchema.d.ts +0 -21
  173. package/src/config/userEnvVars/index.d.ts +0 -1
  174. package/src/config/userEnvVars/userEnvVars.d.ts +0 -13
  175. package/src/config/util/ajvTypes.d.ts +0 -10
  176. package/src/config/util/configLocation.d.ts +0 -18
  177. package/src/config/util/index.d.ts +0 -4
  178. package/src/config/util/loadConfig.d.ts +0 -18
  179. package/src/config/util/validateConfig.d.ts +0 -8
  180. package/src/config/workspaceConfig/defineWorkspaceConfig.d.ts +0 -7
  181. package/src/config/workspaceConfig/errors.d.ts +0 -1
  182. package/src/config/workspaceConfig/index.d.ts +0 -5
  183. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +0 -3
  184. package/src/config/workspaceConfig/workspaceConfig.d.ts +0 -56
  185. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +0 -2
  186. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +0 -5
  187. package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +0 -56
  188. package/src/doctor/doctor.d.ts +0 -35
  189. package/src/doctor/index.d.ts +0 -1
  190. package/src/internal/bun/bunLock.d.ts +0 -20
  191. package/src/internal/bun/bunVersion.d.ts +0 -21
  192. package/src/internal/bun/index.d.ts +0 -2
  193. package/src/internal/core/error/error.d.ts +0 -13
  194. package/src/internal/core/error/index.d.ts +0 -1
  195. package/src/internal/core/index.d.ts +0 -4
  196. package/src/internal/core/json/index.d.ts +0 -2
  197. package/src/internal/core/json/json.d.ts +0 -49
  198. package/src/internal/core/json/jsonc.d.ts +0 -9
  199. package/src/internal/core/language/array/index.d.ts +0 -1
  200. package/src/internal/core/language/array/optionalArray.d.ts +0 -15
  201. package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +0 -16
  202. package/src/internal/core/language/asyncIterable/index.d.ts +0 -2
  203. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +0 -5
  204. package/src/internal/core/language/events/typedEventTarget.d.ts +0 -50
  205. package/src/internal/core/language/index.d.ts +0 -5
  206. package/src/internal/core/language/regex/index.d.ts +0 -1
  207. package/src/internal/core/language/regex/regex.d.ts +0 -3
  208. package/src/internal/core/language/string/id.d.ts +0 -1
  209. package/src/internal/core/language/string/index.d.ts +0 -1
  210. package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +0 -16
  211. package/src/internal/core/language/string/utf/visibleLength.d.ts +0 -5
  212. package/src/internal/core/language/types/index.d.ts +0 -2
  213. package/src/internal/core/language/types/typeof.d.ts +0 -102
  214. package/src/internal/core/language/types/types.d.ts +0 -19
  215. package/src/internal/core/runtime/env.d.ts +0 -6
  216. package/src/internal/core/runtime/index.d.ts +0 -5
  217. package/src/internal/core/runtime/onExit.d.ts +0 -4
  218. package/src/internal/core/runtime/os.d.ts +0 -6
  219. package/src/internal/core/runtime/tempFile.d.ts +0 -20
  220. package/src/internal/core/runtime/terminal.d.ts +0 -1
  221. package/src/internal/docs/apiQuickstart.d.ts +0 -3
  222. package/src/internal/docs/apiQuickstart.mjs +0 -132
  223. package/src/internal/docs/cliQuickstart.d.ts +0 -2
  224. package/src/internal/docs/cliQuickstart.mjs +0 -86
  225. package/src/internal/docs/index.d.ts +0 -2
  226. package/src/internal/docs/index.mjs +0 -2
  227. package/src/internal/generated/aiDocs/docs.d.ts +0 -10
  228. package/src/internal/logger/index.d.ts +0 -1
  229. package/src/internal/logger/logger.d.ts +0 -45
  230. package/src/internal/version.d.ts +0 -1
  231. package/src/project/errors.d.ts +0 -5
  232. package/src/project/implementations/fileSystemProject.d.ts +0 -148
  233. package/src/project/implementations/memoryProject.d.ts +0 -41
  234. package/src/project/implementations/projectBase.d.ts +0 -37
  235. package/src/project/index.d.ts +0 -5
  236. package/src/project/project.d.ts +0 -79
  237. package/src/runScript/index.d.ts +0 -7
  238. package/src/runScript/output/index.d.ts +0 -3
  239. package/src/runScript/output/multiProcessOutput.d.ts +0 -14
  240. package/src/runScript/output/outputStream.d.ts +0 -1
  241. package/src/runScript/output/processOutput.d.ts +0 -33
  242. package/src/runScript/parallel.d.ts +0 -24
  243. package/src/runScript/recursion.d.ts +0 -4
  244. package/src/runScript/runScript.d.ts +0 -45
  245. package/src/runScript/runScripts.d.ts +0 -65
  246. package/src/runScript/scriptCommand.d.ts +0 -33
  247. package/src/runScript/scriptExecution.d.ts +0 -9
  248. package/src/runScript/scriptRuntimeMetadata.d.ts +0 -73
  249. package/src/runScript/scriptShellOption.d.ts +0 -8
  250. package/src/runScript/subprocesses.d.ts +0 -11
  251. package/src/workspaces/dependencyGraph/cycles.d.ts +0 -9
  252. package/src/workspaces/dependencyGraph/index.d.ts +0 -3
  253. package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +0 -18
  254. package/src/workspaces/dependencyGraph/validateDependencyRules.d.ts +0 -7
  255. package/src/workspaces/errors.d.ts +0 -14
  256. package/src/workspaces/findWorkspaces.d.ts +0 -24
  257. package/src/workspaces/index.d.ts +0 -4
  258. package/src/workspaces/packageJson.d.ts +0 -31
  259. package/src/workspaces/workspace.d.ts +0 -21
  260. package/src/workspaces/workspacePattern.d.ts +0 -22
@@ -1,45 +0,0 @@
1
- export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
2
- export type LogLevel = (typeof LOG_LEVELS)[number];
3
- export type LogLevelSetting = LogLevel | "silent";
4
- export declare const LOGGER_ERRORS: import("../core").DefinedErrors<"InvalidLogLevel">;
5
- export declare const validateLogLevel: (level: LogLevelSetting) => void;
6
- export type LogMetadata = Record<string, unknown>;
7
- export interface Log<
8
- Message extends string | Error = string,
9
- Metadata extends LogMetadata = LogMetadata,
10
- > {
11
- message: Message;
12
- level: LogLevel;
13
- metadata: Metadata;
14
- time: Date;
15
- }
16
- export type Logger = {
17
- name: string;
18
- log<
19
- Message extends string | Error = string,
20
- Metadata extends LogMetadata = LogMetadata,
21
- >(
22
- message: Message,
23
- level: LogLevel,
24
- metadata?: Metadata,
25
- ): Log<Message, Metadata>;
26
- printLevel: LogLevelSetting;
27
- setPrintStdout: (
28
- stdout: (...args: Parameters<typeof process.stdout.write>) => void,
29
- ) => void;
30
- setPrintStderr: (
31
- stderr: (...args: Parameters<typeof process.stderr.write>) => void,
32
- ) => void;
33
- } & {
34
- [Level in LogLevel]: <
35
- Message extends string | Error = string,
36
- Metadata extends LogMetadata = LogMetadata,
37
- >(
38
- message: Message,
39
- metadata?: Metadata,
40
- ) => Log<Message, Metadata>;
41
- };
42
- export declare const createLogger: (name: string) => Logger;
43
- export declare const logger: Logger;
44
- /** Set the global logging level. Defaults to "info" or "error" when `NODE_ENV` is "test" */
45
- export declare const setLogLevel: (level: LogLevelSetting) => void;
@@ -1 +0,0 @@
1
- export declare const BUN_WORKSPACES_VERSION: string;
@@ -1,5 +0,0 @@
1
- export declare const PROJECT_ERRORS: import("../internal/core").DefinedErrors<
2
- | "ProjectWorkspaceNotFound"
3
- | "WorkspaceScriptDoesNotExist"
4
- | "RecursiveWorkspaceScript"
5
- >;
@@ -1,148 +0,0 @@
1
- import type { Simplify } from "../../internal/core";
2
- import {
3
- type RunScriptsParallelOptions,
4
- type RunScriptsSummary,
5
- type RunScriptExit,
6
- type OutputStreamName,
7
- type ScriptEventName,
8
- } from "../../runScript";
9
- import type { MultiProcessOutput } from "../../runScript/output/multiProcessOutput";
10
- import { type ScriptShellOption } from "../../runScript/scriptShellOption";
11
- import { type Workspace } from "../../workspaces";
12
- import type { Project, ProjectConfig } from "../project";
13
- import { ProjectBase } from "./projectBase";
14
- /** Arguments for {@link createFileSystemProject} */
15
- export type CreateFileSystemProjectOptions = {
16
- /** The directory containing the root package.json. Often the same root as a git repository. Relative to process.cwd(). The default is process.cwd(). */
17
- rootDirectory?: string;
18
- /**
19
- * The name of the project.
20
- *
21
- * By default will use the root package.json name
22
- */
23
- name?: string;
24
- /** Whether to include the root workspace as a normal workspace. This overrides any config or env var settings. */
25
- includeRootWorkspace?: boolean;
26
- };
27
- export type ShellOption = ScriptShellOption | "default";
28
- export type InlineScriptOptions = {
29
- /** A name to act as a label for the inline script */
30
- scriptName?: string;
31
- /** Whether to run the script as an inline command */
32
- shell?: ShellOption;
33
- };
34
- /** Arguments for `FileSystemProject.runWorkspaceScript` */
35
- export type RunWorkspaceScriptOptions = {
36
- /** The name of the workspace to run the script in */
37
- workspaceNameOrAlias: string;
38
- /** The name of the script to run, or an inline command when `inline` is true */
39
- script: string;
40
- /** Whether to run the script as an inline command */
41
- inline?: boolean | InlineScriptOptions;
42
- /** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
43
- args?: string | string[];
44
- /** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
45
- ignoreOutput?: boolean;
46
- };
47
- /** Metadata associated with a workspace script */
48
- export type RunWorkspaceScriptMetadata = {
49
- /** The workspace that the script was run in */
50
- workspace: Workspace;
51
- };
52
- export type RunWorkspaceScriptExit = Simplify<
53
- RunScriptExit<RunWorkspaceScriptMetadata>
54
- >;
55
- export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
56
- RunWorkspaceScriptMetadata & {
57
- streamName: OutputStreamName;
58
- }
59
- >;
60
- /** Result of `FileSystemProject.runWorkspaceScript` */
61
- export type RunWorkspaceScriptResult = {
62
- /** Use to get the output of the script */
63
- output: RunWorkspaceScriptProcessOutput;
64
- /** The exit result of the script */
65
- exit: Promise<RunWorkspaceScriptExit>;
66
- };
67
- export type ParallelOption = boolean | RunScriptsParallelOptions;
68
- export type ScriptEventMetadata = {
69
- /** The workspace that the script event occurred in */
70
- workspace: Workspace;
71
- /** The exit result of the script */
72
- exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
73
- };
74
- export type OnScriptEventCallback = (
75
- /** The event that occurred */
76
- event: ScriptEventName,
77
- /** The metadata for the script event */
78
- metadata: ScriptEventMetadata,
79
- ) => unknown;
80
- /** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
81
- export type RunScriptAcrossWorkspacesOptions = {
82
- /**
83
- * Workspace names, aliases, or patterns including a wildcard.
84
- *
85
- * When not provided, all workspaces that the script can be ran in will be used.
86
- */
87
- workspacePatterns?: string[];
88
- /** The name of the script to run, or an inline command when `inline` is true */
89
- script: string;
90
- /** Whether to run the script as an inline command */
91
- inline?: boolean | InlineScriptOptions;
92
- /** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
93
- args?: string | string[];
94
- /** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
95
- parallel?: ParallelOption;
96
- /** When `true`, run scripts so that dependent workspaces run only after their dependencies */
97
- dependencyOrder?: boolean;
98
- /** When `true`, continue running scripts even if a dependency fails (Only relevant when `dependencyOrder` is `true`) */
99
- ignoreDependencyFailure?: boolean;
100
- /** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
101
- ignoreOutput?: boolean;
102
- /** Callback to invoke when a script event occurs (start, skip, exit) */
103
- onScriptEvent?: OnScriptEventCallback;
104
- };
105
- export type RunScriptAcrossWorkspacesSummary = Simplify<
106
- RunScriptsSummary<RunWorkspaceScriptMetadata>
107
- >;
108
- export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
109
- RunWorkspaceScriptMetadata & {
110
- streamName: OutputStreamName;
111
- }
112
- >;
113
- /** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
114
- export type RunScriptAcrossWorkspacesResult = {
115
- /** Use to get the output of the scripts */
116
- output: RunScriptAcrossWorkspacesOutput;
117
- /** The summary of the script run with exit details for each workspace */
118
- summary: Promise<RunScriptAcrossWorkspacesSummary>;
119
- /** The workspaces targeted */
120
- workspaces: Workspace[];
121
- };
122
- declare class _FileSystemProject extends ProjectBase implements Project {
123
- #private;
124
- readonly rootDirectory: string;
125
- readonly workspaces: Workspace[];
126
- readonly name: string;
127
- readonly sourceType = "fileSystem";
128
- readonly config: ProjectConfig;
129
- readonly rootWorkspace: Workspace;
130
- constructor(options: CreateFileSystemProjectOptions);
131
- runWorkspaceScript(
132
- options: RunWorkspaceScriptOptions,
133
- ): RunWorkspaceScriptResult;
134
- runScriptAcrossWorkspaces(
135
- options: RunScriptAcrossWorkspacesOptions,
136
- ): RunScriptAcrossWorkspacesResult;
137
- }
138
- /** An implementation of {@link Project} that is created from a root directory in the file system. */
139
- export type FileSystemProject = Simplify<_FileSystemProject>;
140
- /**
141
- * Create a {@link Project} based on a given root directory.
142
- * Automatically finds workspaces based on the root package.json "workspaces" field
143
- * and detects and utilizes any provided configuration.
144
- */
145
- export declare const createFileSystemProject: (
146
- options?: CreateFileSystemProjectOptions,
147
- ) => FileSystemProject;
148
- export {};
@@ -1,41 +0,0 @@
1
- import type { Simplify } from "../../internal/core";
2
- import { type Workspace } from "../../workspaces";
3
- import type { Project } from "../project";
4
- import { ProjectBase } from "./projectBase";
5
- /** Arguments for {@link createMemoryProject} */
6
- export type CreateMemoryProjectOptions = {
7
- /** The list of workspaces in the project */
8
- workspaces: Workspace[];
9
- /** The name of the project */
10
- name?: string;
11
- /** The root directory of the project (not used in any actual file system interactions in a {@link MemoryProject}) */
12
- rootDirectory?: string;
13
- /** The root workspace */
14
- rootWorkspace?: Workspace;
15
- /** Whether to include the root workspace as a normal workspace. */
16
- includeRootWorkspace?: boolean;
17
- };
18
- declare class _MemoryProject extends ProjectBase implements Project {
19
- readonly rootDirectory: string;
20
- readonly workspaces: Workspace[];
21
- readonly name: string;
22
- readonly sourceType = "memory";
23
- readonly config: {
24
- root: import("../..").ResolvedRootConfig;
25
- workspaces: {};
26
- };
27
- readonly rootWorkspace: Workspace;
28
- constructor(options: CreateMemoryProjectOptions);
29
- }
30
- /**
31
- * An implementation of {@link Project} that is created from a list of workspaces in memory.
32
- *
33
- * Mainly used for testing without needing a real file system project. */
34
- export type MemoryProject = Simplify<InstanceType<typeof _MemoryProject>>;
35
- /** Create a {@link Project} from a provided list of workspace objects.
36
- *
37
- * Mainly used for testing without needing a real file system project. */
38
- export declare const createMemoryProject: (
39
- options: CreateMemoryProjectOptions,
40
- ) => MemoryProject;
41
- export {};
@@ -1,37 +0,0 @@
1
- import { type Workspace } from "../../workspaces";
2
- import type {
3
- CreateProjectScriptCommandOptions,
4
- CreateProjectScriptCommandResult,
5
- Project,
6
- ProjectConfig,
7
- WorkspaceScriptMetadata,
8
- } from "../project";
9
- export declare const resolveWorkspacePath: (
10
- project: Project,
11
- workspace: Workspace,
12
- ) => string;
13
- export declare const ROOT_WORKSPACE_SELECTOR = "@root";
14
- export declare const resolveRootWorkspaceSelector: (
15
- workspacePattern: string,
16
- project: Project,
17
- ) => Workspace | null;
18
- export declare abstract class ProjectBase implements Project {
19
- abstract readonly name: string;
20
- abstract readonly rootDirectory: string;
21
- abstract readonly rootWorkspace: Workspace;
22
- abstract readonly workspaces: Workspace[];
23
- abstract readonly sourceType: "fileSystem" | "memory";
24
- abstract readonly config: ProjectConfig;
25
- constructor(_ignoreBunVersion?: boolean);
26
- listWorkspacesWithScript(scriptName: string): Workspace[];
27
- mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
28
- mapTagsToWorkspaces(): Record<string, Workspace[]>;
29
- findWorkspaceByName(workspaceName: string): Workspace | null;
30
- findWorkspaceByAlias(alias: string): Workspace | null;
31
- findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
32
- listWorkspacesWithTag(tag: string): Workspace[];
33
- findWorkspacesByPattern(...workspacePatterns: string[]): Workspace[];
34
- createScriptCommand(
35
- options: CreateProjectScriptCommandOptions,
36
- ): CreateProjectScriptCommandResult;
37
- }
@@ -1,5 +0,0 @@
1
- export * from "./errors";
2
- export type * from "./project";
3
- export * from "./implementations/projectBase";
4
- export * from "./implementations/fileSystemProject";
5
- export * from "./implementations/memoryProject";
@@ -1,79 +0,0 @@
1
- import type { ResolvedRootConfig, ResolvedWorkspaceConfig } from "../config";
2
- import type { ScriptCommand, WorkspaceScriptCommandMethod } from "../runScript";
3
- import type { Workspace } from "../workspaces";
4
- /** Metadata about a {@link Project}'s script, including the workspaces that have it in their package.json */
5
- export type WorkspaceScriptMetadata = {
6
- name: string;
7
- workspaces: Workspace[];
8
- };
9
- /** Arguments for {@link Project.createScriptCommand} */
10
- export type CreateProjectScriptCommandOptions = {
11
- /** The workspace to run the script in */
12
- workspaceNameOrAlias: string;
13
- /** The name of the script to run */
14
- scriptName: string;
15
- /**
16
- * The method to use to run the script.
17
- * Either run in the workspace directory or use bun's --filter option.
18
- * Defaults to "cd".
19
- */
20
- method?: WorkspaceScriptCommandMethod;
21
- /** The arguments to append to the command */
22
- args?: string;
23
- };
24
- /** Result of {@link Project.createScriptCommand}. Includes a command string that will run a workspace's script. */
25
- export type CreateProjectScriptCommandResult = {
26
- /** Data including a command string using the `bun`
27
- * CLI that will run a workspace's script and the
28
- * directory to run it in. */
29
- commandDetails: ScriptCommand;
30
- /** The name of the script to run */
31
- scriptName: string;
32
- /** The workspace that the script belongs to */
33
- workspace: Workspace;
34
- };
35
- /** The config for a project and its workspaces */
36
- export type ProjectConfig = {
37
- root: ResolvedRootConfig;
38
- /** A map of workspace names to their resolved config */
39
- workspaces: Record<string, ResolvedWorkspaceConfig>;
40
- };
41
- /**
42
- * A project contains a collection of workspaces and is the core of `bun-workspaces`'s functionality.
43
- *
44
- * Typically based on a root package.json file's `"workspaces"` field and any matching nested package.json files that are found.
45
- */
46
- export interface Project {
47
- /** The name of the project. This is typically the name of the root package.json unless otherwise provided. */
48
- name: string;
49
- /** The root directory of the project */
50
- rootDirectory: string;
51
- /** The root workspace of the project */
52
- rootWorkspace: Workspace;
53
- /** The list of all workspaces in the project */
54
- workspaces: Workspace[];
55
- /** The config for the project and its workspaces */
56
- config: ProjectConfig;
57
- /** The means by which the project was created */
58
- sourceType: "fileSystem" | "memory";
59
- /** Find a workspace by its package.json name */
60
- findWorkspaceByName(workspaceName: string): Workspace | null;
61
- /** Find a workspace by a workspace alias */
62
- findWorkspaceByAlias(alias: string): Workspace | null;
63
- /** Find a workspace that matches a workspace's name or an alias if no name matches. */
64
- findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
65
- /** Find a list of workspaces that have a given tag in their configuration */
66
- listWorkspacesWithTag(tag: string): Workspace[];
67
- /** Accepts a wildcard pattern for finding a list of workspaces by their name*/
68
- findWorkspacesByPattern(workspacePattern: string): Workspace[];
69
- /** Get an array of all workspaces that have a given script in their package.json */
70
- listWorkspacesWithScript(scriptName: string): Workspace[];
71
- /** Get a mapping of all scripts to the workspaces that have them in their package.json */
72
- mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
73
- /** Get a mapping of all tags to the workspaces that have them in their config */
74
- mapTagsToWorkspaces(): Record<string, Workspace[]>;
75
- /** Create metadata that can be used to run a workspace's script */
76
- createScriptCommand(
77
- options: CreateProjectScriptCommandOptions,
78
- ): CreateProjectScriptCommandResult;
79
- }
@@ -1,7 +0,0 @@
1
- export * from "./runScript";
2
- export * from "./runScripts";
3
- export * from "./scriptCommand";
4
- export * from "./output";
5
- export * from "./parallel";
6
- export * from "./scriptRuntimeMetadata";
7
- export * from "./scriptShellOption";
@@ -1,3 +0,0 @@
1
- export type * from "./outputStream";
2
- export * from "./multiProcessOutput";
3
- export * from "./processOutput";
@@ -1,14 +0,0 @@
1
- import {
2
- type ProcessOutput,
3
- type BytesOutput,
4
- type TextOutput,
5
- } from "./processOutput";
6
- export interface MultiProcessOutput<Metadata extends object = object> {
7
- bytes(): BytesOutput<Metadata>;
8
- text(): TextOutput<Metadata>;
9
- }
10
- export declare const createMultiProcessOutput: <
11
- Metadata extends object = object,
12
- >(
13
- processes: ProcessOutput<Metadata>[],
14
- ) => MultiProcessOutput<Metadata>;
@@ -1 +0,0 @@
1
- export type OutputStreamName = "stdout" | "stderr";
@@ -1,33 +0,0 @@
1
- import { type SimpleAsyncIterable } from "../../internal/core";
2
- export type ByteStream = SimpleAsyncIterable<Uint8Array<ArrayBufferLike>>;
3
- export type ProcessOutputChunk<
4
- Chunk = unknown,
5
- Metadata extends object = object,
6
- > = {
7
- /** The metadata for the script that produced the output chunk */
8
- metadata: Metadata;
9
- /** The output chunk */
10
- chunk: Chunk;
11
- };
12
- export type ByteChunk<Metadata extends object = object> = ProcessOutputChunk<
13
- Uint8Array<ArrayBufferLike>,
14
- Metadata
15
- >;
16
- export type TextChunk<Metadata extends object = object> = ProcessOutputChunk<
17
- string,
18
- Metadata
19
- >;
20
- export type BytesOutput<Metadata extends object = object> = SimpleAsyncIterable<
21
- ByteChunk<Metadata>
22
- >;
23
- export type TextOutput<Metadata extends object = object> = SimpleAsyncIterable<
24
- TextChunk<Metadata>
25
- >;
26
- export interface ProcessOutput<Metadata extends object = object> {
27
- bytes(): BytesOutput<Metadata>;
28
- text(): TextOutput<Metadata>;
29
- }
30
- export declare const createProcessOutput: <Metadata extends object = object>(
31
- stream: ByteStream,
32
- metadata: Metadata,
33
- ) => ProcessOutput<Metadata>;
@@ -1,24 +0,0 @@
1
- export declare const PARALLEL_MAX_VALUES: readonly [
2
- "auto",
3
- "unbounded",
4
- "default",
5
- ];
6
- export type PercentageValue = `${number}%`;
7
- /**
8
- * The maximum number of scripts that can run in parallel.
9
- *
10
- * - `number`: The exact number of scripts that can run in parallel.
11
- * - `"auto"`: The number of available logical CPU threads.
12
- * - `"unbounded"`: No limit.
13
- * - `"default"`: The default value, either "auto" or the value of the root config's "parallelMax" option.
14
- * - `"${number}%"`: A percentage of the available logical CPU threads (e.g. "50%").
15
- */
16
- export type ParallelMaxValue =
17
- | number
18
- | (typeof PARALLEL_MAX_VALUES)[number]
19
- | PercentageValue;
20
- /** Should always return at least 1 */
21
- export declare const determineParallelMax: (
22
- value: ParallelMaxValue,
23
- errorMessageSuffix?: string,
24
- ) => number;
@@ -1,4 +0,0 @@
1
- export declare const checkIsRecursiveScript: (
2
- workspaceName: string,
3
- scriptName: string,
4
- ) => boolean | undefined;
@@ -1,45 +0,0 @@
1
- import { type MultiProcessOutput, type OutputStreamName } from "./output";
2
- import type { ScriptCommand } from "./scriptCommand";
3
- import type { ScriptShellOption } from "./scriptShellOption";
4
- export type RunScriptExit<ScriptMetadata extends object = object> = {
5
- exitCode: number;
6
- signal: NodeJS.Signals | null;
7
- success: boolean;
8
- /** Whether the script was skipped due to a failed dependency */
9
- skipped?: boolean;
10
- startTimeISO: string;
11
- endTimeISO: string;
12
- durationMs: number;
13
- metadata: ScriptMetadata;
14
- };
15
- export type RunScriptResult<ScriptMetadata extends object = object> = {
16
- output: MultiProcessOutput<
17
- ScriptMetadata & {
18
- streamName: OutputStreamName;
19
- }
20
- >;
21
- exit: Promise<RunScriptExit<ScriptMetadata>>;
22
- metadata: ScriptMetadata;
23
- kill: (exit?: number | NodeJS.Signals) => void;
24
- };
25
- export type RunScriptOptions<ScriptMetadata extends object = object> = {
26
- scriptCommand: ScriptCommand;
27
- metadata: ScriptMetadata;
28
- env: Record<string, string>;
29
- /** The shell to use to run the script. Defaults to "system". */
30
- shell?: ScriptShellOption;
31
- /** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
32
- ignoreOutput?: boolean;
33
- };
34
- /**
35
- * Run some script and get an async output stream of
36
- * stdout and stderr chunks and a result object
37
- * containing exit details.
38
- */
39
- export declare const runScript: <ScriptMetadata extends object = object>({
40
- scriptCommand,
41
- metadata,
42
- env,
43
- shell,
44
- ignoreOutput,
45
- }: RunScriptOptions<ScriptMetadata>) => RunScriptResult<ScriptMetadata>;
@@ -1,65 +0,0 @@
1
- import { type MultiProcessOutput, type OutputStreamName } from "./output";
2
- import { type ParallelMaxValue } from "./parallel";
3
- import { type RunScriptExit, type RunScriptResult } from "./runScript";
4
- import { type ScriptCommand } from "./scriptCommand";
5
- import { type ScriptShellOption } from "./scriptShellOption";
6
- export type RunScriptsScript<ScriptMetadata extends object = object> = {
7
- scriptCommand: ScriptCommand;
8
- metadata: ScriptMetadata;
9
- env: Record<string, string>;
10
- /** The shell to use to run the script */
11
- shell?: ScriptShellOption;
12
- /** Indices of other scripts in the array that must complete before this one starts */
13
- dependsOn?: number[];
14
- /** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
15
- ignoreOutput?: boolean;
16
- };
17
- export type RunScriptsScriptResult<ScriptMetadata extends object = object> = {
18
- /** The result of running the script */
19
- result: RunScriptResult<ScriptMetadata>;
20
- };
21
- export type RunScriptsSummary<ScriptMetadata extends object = object> = {
22
- totalCount: number;
23
- successCount: number;
24
- failureCount: number;
25
- allSuccess: boolean;
26
- startTimeISO: string;
27
- endTimeISO: string;
28
- durationMs: number;
29
- scriptResults: RunScriptExit<ScriptMetadata>[];
30
- };
31
- export type ScriptEventName = "start" | "skip" | "exit";
32
- export type RunScriptsResult<ScriptMetadata extends object = object> = {
33
- output: MultiProcessOutput<
34
- ScriptMetadata & {
35
- streamName: OutputStreamName;
36
- }
37
- >;
38
- /** Resolves with a results summary after all scripts have exited */
39
- summary: Promise<RunScriptsSummary<ScriptMetadata>>;
40
- };
41
- export type RunScriptsParallelOptions = {
42
- max: ParallelMaxValue;
43
- };
44
- export type RunScriptsOptions<ScriptMetadata extends object = object> = {
45
- scripts: RunScriptsScript<ScriptMetadata>[];
46
- parallel: boolean | RunScriptsParallelOptions;
47
- /** When true, run scripts even if a dependency failed. Default: false (skip them). */
48
- ignoreDependencyFailure?: boolean;
49
- /** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
50
- ignoreOutput?: boolean;
51
- /** Callback to invoke when a script event occurs */
52
- onScriptEvent?: (
53
- event: ScriptEventName,
54
- scriptIndex: number,
55
- result: RunScriptExit<ScriptMetadata> | null,
56
- ) => void;
57
- };
58
- /** Run a list of scripts */
59
- export declare const runScripts: <ScriptMetadata extends object = object>({
60
- scripts,
61
- parallel,
62
- ignoreDependencyFailure,
63
- ignoreOutput,
64
- onScriptEvent,
65
- }: RunScriptsOptions<ScriptMetadata>) => RunScriptsResult<ScriptMetadata>;
@@ -1,33 +0,0 @@
1
- import type { Workspace } from "../workspaces";
2
- export declare const WORKSPACE_SCRIPT_COMMAND_METHODS: readonly [
3
- "cd",
4
- "filter",
5
- ];
6
- export type WorkspaceScriptCommandMethod =
7
- (typeof WORKSPACE_SCRIPT_COMMAND_METHODS)[number];
8
- /** Basic metadata to run a script, the command string and the directory to run it in */
9
- export interface ScriptCommand {
10
- /** The command string to run */
11
- command: string;
12
- /** The directory to run the command in */
13
- workingDirectory: string;
14
- }
15
- export interface CreateWorkspaceScriptCommandOptions {
16
- /**
17
- * The method to use to run the script.
18
- * Either run in the workspace directory or use bun's --filter option.
19
- * Defaults to "cd".
20
- */
21
- method?: WorkspaceScriptCommandMethod;
22
- /** The name of the script to run */
23
- scriptName: string;
24
- /** The arguments to append to the command */
25
- args: string;
26
- /** The workspace that the script belongs to */
27
- workspace: Workspace;
28
- /** The root directory of the project */
29
- rootDirectory: string;
30
- }
31
- export declare const createWorkspaceScriptCommand: (
32
- options: CreateWorkspaceScriptCommandOptions,
33
- ) => ScriptCommand;
@@ -1,9 +0,0 @@
1
- import { type ScriptShellOption } from "./scriptShellOption";
2
- export type ScriptExecutor = {
3
- argv: string[];
4
- cleanup: () => void;
5
- };
6
- export declare const createScriptExecutor: (
7
- command: string,
8
- shell: ScriptShellOption,
9
- ) => ScriptExecutor;