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
package/src/index.d.ts CHANGED
@@ -1,38 +1,458 @@
1
- export {
2
- createFileSystemProject,
3
- createMemoryProject,
4
- type Project,
5
- type FileSystemProject,
6
- type MemoryProject,
7
- type CreateFileSystemProjectOptions,
8
- type CreateMemoryProjectOptions,
9
- type CreateProjectScriptCommandOptions,
10
- type CreateProjectScriptCommandResult,
11
- type WorkspaceScriptMetadata,
12
- type RunWorkspaceScriptMetadata,
13
- type RunWorkspaceScriptOptions,
14
- type RunWorkspaceScriptExit,
15
- type RunWorkspaceScriptResult,
16
- type InlineScriptOptions,
17
- type RunScriptAcrossWorkspacesOptions,
18
- type RunScriptAcrossWorkspacesOutput,
19
- type RunScriptAcrossWorkspacesSummary,
20
- type RunScriptAcrossWorkspacesOutput as RunScriptAcrossWorkspacesProcessOutput,
21
- type RunScriptAcrossWorkspacesResult,
22
- type ParallelOption,
23
- type ShellOption,
24
- type ScriptEventMetadata,
25
- type OnScriptEventCallback,
26
- } from "./project";
27
- export * from "./config/public";
28
- export {
29
- type ScriptEventName,
30
- type OutputStreamName,
31
- type PercentageValue,
32
- type ParallelMaxValue,
33
- type WorkspaceScriptCommandMethod,
34
- type RunScriptsParallelOptions,
35
- } from "./runScript";
36
- export { type Workspace } from "./workspaces";
37
- export { type SimpleAsyncIterable, BunWorkspacesError } from "./internal/core";
38
- export { setLogLevel, type LogLevelSetting } from "./internal/logger";
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
+ export declare class BunWorkspacesError extends Error {
10
+ name: string;
11
+ }
12
+ declare const SCRIPT_SHELL_OPTIONS: readonly ["bun", "system"];
13
+ export type ScriptShellOption = (typeof SCRIPT_SHELL_OPTIONS)[number];
14
+ export type ShellOption = ScriptShellOption | "default";
15
+ declare const PARALLEL_MAX_VALUES: readonly ["auto", "unbounded", "default"];
16
+ export type PercentageValue = `${number}%`;
17
+ /**
18
+ * The maximum number of scripts that can run in parallel.
19
+ *
20
+ * - `number`: The exact number of scripts that can run in parallel.
21
+ * - `"auto"`: The number of available logical CPU threads.
22
+ * - `"unbounded"`: No limit.
23
+ * - `"default"`: The default value, either "auto" or the value of the root config's "parallelMax" option.
24
+ * - `"${number}%"`: A percentage of the available logical CPU threads (e.g. "50%").
25
+ */
26
+ export type ParallelMaxValue =
27
+ | number
28
+ | (typeof PARALLEL_MAX_VALUES)[number]
29
+ | PercentageValue;
30
+ export type WorkspaceDependenciesRule = {
31
+ allowPatterns?: string[];
32
+ denyPatterns?: string[];
33
+ };
34
+ export type WorkspaceRules = {
35
+ workspaceDependencies?: WorkspaceDependenciesRule;
36
+ };
37
+ /** Configuration that applies to a specific package.json script */
38
+ export type ScriptConfig = {
39
+ /**
40
+ * The order in which the script should be executed.
41
+ *
42
+ * Scripts with no `order` set will be executed in alphanumerical order
43
+ * of their relative path from the project root.
44
+ */
45
+ order?: number;
46
+ };
47
+ /** Configuration that applies to a specific workspace */
48
+ export type WorkspaceConfig = {
49
+ /**
50
+ * An alias or list of aliases for the workspace.
51
+ *
52
+ * These must be unique to other workspaces' aliases
53
+ * and package.json names.
54
+ */
55
+ alias?: string | string[];
56
+ /**
57
+ * Tags for the workspace.
58
+ *
59
+ * These can be used to group workspaces by a common tag.
60
+ */
61
+ tags?: string[];
62
+ /**
63
+ * Configuration that maps to a script name in the workspace's package.json.
64
+ */
65
+ scripts?: Record<string, ScriptConfig>;
66
+ /**
67
+ * Rules that validate the workspace.
68
+ */
69
+ rules?: WorkspaceRules;
70
+ };
71
+ export type ResolvedWorkspaceConfig = {
72
+ aliases: string[];
73
+ tags: string[];
74
+ scripts: Record<string, ScriptConfig>;
75
+ rules: WorkspaceRules;
76
+ };
77
+ export type RootConfig = {
78
+ defaults?: {
79
+ /** The maximum number of scripts that can run in parallel. (default: "auto") */
80
+ parallelMax?: ParallelMaxValue;
81
+ /** The shell to use for inline scripts. (default: "bun") */
82
+ shell?: ShellOption;
83
+ /** Whether to include the root workspace in the workspaces list by default. (default: false) */
84
+ includeRootWorkspace?: boolean;
85
+ };
86
+ };
87
+ export type ResolvedRootConfig = {
88
+ defaults: {
89
+ parallelMax: number;
90
+ shell: ScriptShellOption;
91
+ /** `undefined` means the value was not set in the input config */
92
+ includeRootWorkspace: boolean | undefined;
93
+ };
94
+ };
95
+ export type OutputStreamName = "stdout" | "stderr";
96
+ export type ProcessOutputChunk<
97
+ Chunk = unknown,
98
+ Metadata extends object = object,
99
+ > = {
100
+ /** The metadata for the script that produced the output chunk */
101
+ metadata: Metadata;
102
+ /** The output chunk */
103
+ chunk: Chunk;
104
+ };
105
+ export type ByteChunk<Metadata extends object = object> = ProcessOutputChunk<
106
+ Uint8Array<ArrayBufferLike>,
107
+ Metadata
108
+ >;
109
+ export type TextChunk<Metadata extends object = object> = ProcessOutputChunk<
110
+ string,
111
+ Metadata
112
+ >;
113
+ export type BytesOutput<Metadata extends object = object> = SimpleAsyncIterable<
114
+ ByteChunk<Metadata>
115
+ >;
116
+ export type TextOutput<Metadata extends object = object> = SimpleAsyncIterable<
117
+ TextChunk<Metadata>
118
+ >;
119
+ export interface MultiProcessOutput<Metadata extends object = object> {
120
+ bytes(): BytesOutput<Metadata>;
121
+ text(): TextOutput<Metadata>;
122
+ }
123
+ /** Metadata about a nested package within a Bun monorepo */
124
+ export type Workspace = {
125
+ /** The name of the workspace from its `package.json` */
126
+ name: string;
127
+ /** Whether the workspace is the root workspace */
128
+ isRoot: boolean;
129
+ /** The relative path to the workspace from the root `package.json` */
130
+ path: string;
131
+ /** The pattern from `"workspaces"` in the root `package.json`that this workspace was matched from*/
132
+ matchPattern: string;
133
+ /** The scripts available in package.json */
134
+ scripts: string[];
135
+ /** Aliases assigned via the `"alias"` field in the workspace's config */
136
+ aliases: string[];
137
+ /** Tags assigned via the `"tags"` field in the workspace's config */
138
+ tags: string[];
139
+ /** Names of workspaces that this workspace depends on */
140
+ dependencies: string[];
141
+ /** Names of workspaces that depend on this workspace */
142
+ dependents: string[];
143
+ };
144
+ declare const WORKSPACE_SCRIPT_COMMAND_METHODS: readonly ["cd", "filter"];
145
+ export type WorkspaceScriptCommandMethod =
146
+ (typeof WORKSPACE_SCRIPT_COMMAND_METHODS)[number];
147
+ /** Basic metadata to run a script, the command string and the directory to run it in */
148
+ export interface ScriptCommand {
149
+ /** The command string to run */
150
+ command: string;
151
+ /** The directory to run the command in */
152
+ workingDirectory: string;
153
+ }
154
+ export type RunScriptExit<ScriptMetadata extends object = object> = {
155
+ exitCode: number;
156
+ signal: NodeJS.Signals | null;
157
+ success: boolean;
158
+ /** Whether the script was skipped due to a failed dependency */
159
+ skipped?: boolean;
160
+ startTimeISO: string;
161
+ endTimeISO: string;
162
+ durationMs: number;
163
+ metadata: ScriptMetadata;
164
+ };
165
+ export type RunScriptsSummary<ScriptMetadata extends object = object> = {
166
+ totalCount: number;
167
+ successCount: number;
168
+ failureCount: number;
169
+ allSuccess: boolean;
170
+ startTimeISO: string;
171
+ endTimeISO: string;
172
+ durationMs: number;
173
+ scriptResults: RunScriptExit<ScriptMetadata>[];
174
+ };
175
+ export type ScriptEventName = "start" | "skip" | "exit";
176
+ export type RunScriptsParallelOptions = {
177
+ max: ParallelMaxValue;
178
+ };
179
+ /** Metadata about a {@link Project}'s script, including the workspaces that have it in their package.json */
180
+ export type WorkspaceScriptMetadata = {
181
+ name: string;
182
+ workspaces: Workspace[];
183
+ };
184
+ /** Arguments for {@link Project.createScriptCommand} */
185
+ export type CreateProjectScriptCommandOptions = {
186
+ /** The workspace to run the script in */
187
+ workspaceNameOrAlias: string;
188
+ /** The name of the script to run */
189
+ scriptName: string;
190
+ /**
191
+ * The method to use to run the script.
192
+ * Either run in the workspace directory or use bun's --filter option.
193
+ * Defaults to "cd".
194
+ */
195
+ method?: WorkspaceScriptCommandMethod;
196
+ /** The arguments to append to the command */
197
+ args?: string;
198
+ };
199
+ /** Result of {@link Project.createScriptCommand}. Includes a command string that will run a workspace's script. */
200
+ export type CreateProjectScriptCommandResult = {
201
+ /** Data including a command string using the `bun`
202
+ * CLI that will run a workspace's script and the
203
+ * directory to run it in. */
204
+ commandDetails: ScriptCommand;
205
+ /** The name of the script to run */
206
+ scriptName: string;
207
+ /** The workspace that the script belongs to */
208
+ workspace: Workspace;
209
+ };
210
+ /** The config for a project and its workspaces */
211
+ export type ProjectConfig = {
212
+ root: ResolvedRootConfig;
213
+ /** A map of workspace names to their resolved config */
214
+ workspaces: Record<string, ResolvedWorkspaceConfig>;
215
+ };
216
+ /**
217
+ * A project contains a collection of workspaces and is the core of `bun-workspaces`'s functionality.
218
+ *
219
+ * Typically based on a root package.json file's `"workspaces"` field and any matching nested package.json files that are found.
220
+ */
221
+ export interface Project {
222
+ /** The name of the project. This is typically the name of the root package.json unless otherwise provided. */
223
+ name: string;
224
+ /** The root directory of the project */
225
+ rootDirectory: string;
226
+ /** The root workspace of the project */
227
+ rootWorkspace: Workspace;
228
+ /** The list of all workspaces in the project */
229
+ workspaces: Workspace[];
230
+ /** The config for the project and its workspaces */
231
+ config: ProjectConfig;
232
+ /** The means by which the project was created */
233
+ sourceType: "fileSystem" | "memory";
234
+ /** Find a workspace by its package.json name */
235
+ findWorkspaceByName(workspaceName: string): Workspace | null;
236
+ /** Find a workspace by a workspace alias */
237
+ findWorkspaceByAlias(alias: string): Workspace | null;
238
+ /** Find a workspace that matches a workspace's name or an alias if no name matches. */
239
+ findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
240
+ /** Find a list of workspaces that have a given tag in their configuration */
241
+ listWorkspacesWithTag(tag: string): Workspace[];
242
+ /** Accepts a wildcard pattern for finding a list of workspaces by their name*/
243
+ findWorkspacesByPattern(workspacePattern: string): Workspace[];
244
+ /** Get an array of all workspaces that have a given script in their package.json */
245
+ listWorkspacesWithScript(scriptName: string): Workspace[];
246
+ /** Get a mapping of all scripts to the workspaces that have them in their package.json */
247
+ mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
248
+ /** Get a mapping of all tags to the workspaces that have them in their config */
249
+ mapTagsToWorkspaces(): Record<string, Workspace[]>;
250
+ /** Create metadata that can be used to run a workspace's script */
251
+ createScriptCommand(
252
+ options: CreateProjectScriptCommandOptions,
253
+ ): CreateProjectScriptCommandResult;
254
+ }
255
+ declare abstract class ProjectBase implements Project {
256
+ abstract readonly name: string;
257
+ abstract readonly rootDirectory: string;
258
+ abstract readonly rootWorkspace: Workspace;
259
+ abstract readonly workspaces: Workspace[];
260
+ abstract readonly sourceType: "fileSystem" | "memory";
261
+ abstract readonly config: ProjectConfig;
262
+ constructor(_ignoreBunVersion?: boolean);
263
+ listWorkspacesWithScript(scriptName: string): Workspace[];
264
+ mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
265
+ mapTagsToWorkspaces(): Record<string, Workspace[]>;
266
+ findWorkspaceByName(workspaceName: string): Workspace | null;
267
+ findWorkspaceByAlias(alias: string): Workspace | null;
268
+ findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
269
+ listWorkspacesWithTag(tag: string): Workspace[];
270
+ findWorkspacesByPattern(...workspacePatterns: string[]): Workspace[];
271
+ createScriptCommand(
272
+ options: CreateProjectScriptCommandOptions,
273
+ ): CreateProjectScriptCommandResult;
274
+ }
275
+ /** Arguments for {@link createFileSystemProject} */
276
+ export type CreateFileSystemProjectOptions = {
277
+ /** The directory containing the root package.json. Often the same root as a git repository. Relative to process.cwd(). The default is process.cwd(). */
278
+ rootDirectory?: string;
279
+ /**
280
+ * The name of the project.
281
+ *
282
+ * By default will use the root package.json name
283
+ */
284
+ name?: string;
285
+ /** Whether to include the root workspace as a normal workspace. This overrides any config or env var settings. */
286
+ includeRootWorkspace?: boolean;
287
+ };
288
+ export type InlineScriptOptions = {
289
+ /** A name to act as a label for the inline script */
290
+ scriptName?: string;
291
+ /** Whether to run the script as an inline command */
292
+ shell?: ShellOption;
293
+ };
294
+ /** Arguments for `FileSystemProject.runWorkspaceScript` */
295
+ export type RunWorkspaceScriptOptions = {
296
+ /** The name of the workspace to run the script in */
297
+ workspaceNameOrAlias: string;
298
+ /** The name of the script to run, or an inline command when `inline` is true */
299
+ script: string;
300
+ /** Whether to run the script as an inline command */
301
+ inline?: boolean | InlineScriptOptions;
302
+ /** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
303
+ args?: string | string[];
304
+ /** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
305
+ ignoreOutput?: boolean;
306
+ };
307
+ /** Metadata associated with a workspace script */
308
+ export type RunWorkspaceScriptMetadata = {
309
+ /** The workspace that the script was run in */
310
+ workspace: Workspace;
311
+ };
312
+ export type RunWorkspaceScriptExit = Simplify<
313
+ RunScriptExit<RunWorkspaceScriptMetadata>
314
+ >;
315
+ export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
316
+ RunWorkspaceScriptMetadata & {
317
+ streamName: OutputStreamName;
318
+ }
319
+ >;
320
+ /** Result of `FileSystemProject.runWorkspaceScript` */
321
+ export type RunWorkspaceScriptResult = {
322
+ /** Use to get the output of the script */
323
+ output: RunWorkspaceScriptProcessOutput;
324
+ /** The exit result of the script */
325
+ exit: Promise<RunWorkspaceScriptExit>;
326
+ };
327
+ export type ParallelOption = boolean | RunScriptsParallelOptions;
328
+ export type ScriptEventMetadata = {
329
+ /** The workspace that the script event occurred in */
330
+ workspace: Workspace;
331
+ /** The exit result of the script */
332
+ exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
333
+ };
334
+ export type OnScriptEventCallback = (
335
+ /** The event that occurred */
336
+ event: ScriptEventName,
337
+ /** The metadata for the script event */
338
+ metadata: ScriptEventMetadata,
339
+ ) => unknown;
340
+ /** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
341
+ export type RunScriptAcrossWorkspacesOptions = {
342
+ /**
343
+ * Workspace names, aliases, or patterns including a wildcard.
344
+ *
345
+ * When not provided, all workspaces that the script can be ran in will be used.
346
+ */
347
+ workspacePatterns?: string[];
348
+ /** The name of the script to run, or an inline command when `inline` is true */
349
+ script: string;
350
+ /** Whether to run the script as an inline command */
351
+ inline?: boolean | InlineScriptOptions;
352
+ /** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
353
+ args?: string | string[];
354
+ /** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
355
+ parallel?: ParallelOption;
356
+ /** When `true`, run scripts so that dependent workspaces run only after their dependencies */
357
+ dependencyOrder?: boolean;
358
+ /** When `true`, continue running scripts even if a dependency fails (Only relevant when `dependencyOrder` is `true`) */
359
+ ignoreDependencyFailure?: boolean;
360
+ /** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
361
+ ignoreOutput?: boolean;
362
+ /** Callback to invoke when a script event occurs (start, skip, exit) */
363
+ onScriptEvent?: OnScriptEventCallback;
364
+ };
365
+ export type RunScriptAcrossWorkspacesSummary = Simplify<
366
+ RunScriptsSummary<RunWorkspaceScriptMetadata>
367
+ >;
368
+ export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
369
+ RunWorkspaceScriptMetadata & {
370
+ streamName: OutputStreamName;
371
+ }
372
+ >;
373
+ /** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
374
+ export type RunScriptAcrossWorkspacesResult = {
375
+ /** Use to get the output of the scripts */
376
+ output: RunScriptAcrossWorkspacesOutput;
377
+ /** The summary of the script run with exit details for each workspace */
378
+ summary: Promise<RunScriptAcrossWorkspacesSummary>;
379
+ /** The workspaces targeted */
380
+ workspaces: Workspace[];
381
+ };
382
+ declare class _FileSystemProject extends ProjectBase implements Project {
383
+ #private;
384
+ readonly rootDirectory: string;
385
+ readonly workspaces: Workspace[];
386
+ readonly name: string;
387
+ readonly sourceType = "fileSystem";
388
+ readonly config: ProjectConfig;
389
+ readonly rootWorkspace: Workspace;
390
+ constructor(options: CreateFileSystemProjectOptions);
391
+ runWorkspaceScript(
392
+ options: RunWorkspaceScriptOptions,
393
+ ): RunWorkspaceScriptResult;
394
+ runScriptAcrossWorkspaces(
395
+ options: RunScriptAcrossWorkspacesOptions,
396
+ ): RunScriptAcrossWorkspacesResult;
397
+ }
398
+ /** An implementation of {@link Project} that is created from a root directory in the file system. */
399
+ export type FileSystemProject = Simplify<_FileSystemProject>;
400
+ /**
401
+ * Create a {@link Project} based on a given root directory.
402
+ * Automatically finds workspaces based on the root package.json "workspaces" field
403
+ * and detects and utilizes any provided configuration.
404
+ */
405
+ export declare const createFileSystemProject: (
406
+ options?: CreateFileSystemProjectOptions,
407
+ ) => FileSystemProject;
408
+ /** Arguments for {@link createMemoryProject} */
409
+ export type CreateMemoryProjectOptions = {
410
+ /** The list of workspaces in the project */
411
+ workspaces: Workspace[];
412
+ /** The name of the project */
413
+ name?: string;
414
+ /** The root directory of the project (not used in any actual file system interactions in a {@link MemoryProject}) */
415
+ rootDirectory?: string;
416
+ /** The root workspace */
417
+ rootWorkspace?: Workspace;
418
+ /** Whether to include the root workspace as a normal workspace. */
419
+ includeRootWorkspace?: boolean;
420
+ };
421
+ declare class _MemoryProject extends ProjectBase implements Project {
422
+ readonly rootDirectory: string;
423
+ readonly workspaces: Workspace[];
424
+ readonly name: string;
425
+ readonly sourceType = "memory";
426
+ readonly config: {
427
+ root: ResolvedRootConfig;
428
+ workspaces: {};
429
+ };
430
+ readonly rootWorkspace: Workspace;
431
+ constructor(options: CreateMemoryProjectOptions);
432
+ }
433
+ /**
434
+ * An implementation of {@link Project} that is created from a list of workspaces in memory.
435
+ *
436
+ * Mainly used for testing without needing a real file system project. */
437
+ export type MemoryProject = Simplify<InstanceType<typeof _MemoryProject>>;
438
+ /** Create a {@link Project} from a provided list of workspace objects.
439
+ *
440
+ * Mainly used for testing without needing a real file system project. */
441
+ export declare const createMemoryProject: (
442
+ options: CreateMemoryProjectOptions,
443
+ ) => MemoryProject;
444
+ export declare const defineRootConfig: (
445
+ config: RootConfig,
446
+ ) => ResolvedRootConfig;
447
+ export declare const defineWorkspaceConfig: (
448
+ config: WorkspaceConfig,
449
+ ) => ResolvedWorkspaceConfig;
450
+ declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
451
+ export type LogLevel = (typeof LOG_LEVELS)[number];
452
+ export type LogLevelSetting = LogLevel | "silent";
453
+ /** Set the global logging level. Defaults to "info" or "error" when `NODE_ENV` is "test" */
454
+ export declare const setLogLevel: (level: LogLevelSetting) => void;
455
+
456
+ export { RunScriptAcrossWorkspacesOutput as RunScriptAcrossWorkspacesProcessOutput };
457
+
458
+ export {};
package/src/index.mjs CHANGED
@@ -1,17 +1,8 @@
1
- import {
2
- createFileSystemProject,
3
- createMemoryProject,
4
- } from "./project/index.mjs";
5
- import { BunWorkspacesError } from "./internal/core/index.mjs";
6
- import { setLogLevel } from "./internal/logger/index.mjs";
7
- export * from "./config/public.mjs"; // CONCATENATED MODULE: external "./project/index.mjs"
8
- // CONCATENATED MODULE: external "./internal/core/index.mjs"
9
- // CONCATENATED MODULE: external "./internal/logger/index.mjs"
10
- // CONCATENATED MODULE: ./src/index.ts
1
+ export * from "./config/public.mjs";
11
2
 
12
3
  export {
13
- BunWorkspacesError,
14
4
  createFileSystemProject,
15
5
  createMemoryProject,
16
- setLogLevel,
17
- };
6
+ } from "./project/index.mjs";
7
+ export { BunWorkspacesError } from "./internal/core/index.mjs";
8
+ export { setLogLevel } from "./internal/logger/index.mjs";
@@ -1,9 +1,7 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { defineErrors, isJSONObject, parseJSONC } from "../core/index.mjs"; // CONCATENATED MODULE: external "fs"
4
- // CONCATENATED MODULE: external "path"
5
- // CONCATENATED MODULE: external "../core/index.mjs"
6
- // CONCATENATED MODULE: ./src/internal/bun/bunLock.ts
3
+ import { defineErrors, parseJSONC } from "../core/index.mjs";
4
+ import { isJSONObject } from "../../8257.mjs";
7
5
 
8
6
  const BUN_LOCK_ERRORS = defineErrors(
9
7
  "BunLockNotFound",
@@ -1,7 +1,5 @@
1
1
  import package_0 from "../../../package.json";
2
- import { defineErrors } from "../core/error/index.mjs"; // CONCATENATED MODULE: external "../../../package.json"
3
- // CONCATENATED MODULE: external "../core/error/index.mjs"
4
- // CONCATENATED MODULE: ./src/internal/bun/bunVersion.ts
2
+ import { defineErrors } from "../core/error/index.mjs";
5
3
 
6
4
  const LIBRARY_CONSUMER_BUN_VERSION =
7
5
  package_0._bwInternal.bunVersion.libraryConsumer;
@@ -1,2 +1,4 @@
1
1
  export * from "./bunVersion.mjs";
2
- export * from "./bunLock.mjs"; // CONCATENATED MODULE: ./src/internal/bun/index.ts
2
+ export * from "./bunLock.mjs";
3
+
4
+ export {};