bun-workspaces 1.5.0 → 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 +2 -3
  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 +4 -4
  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,132 +0,0 @@
1
- // CONCATENATED MODULE: ./src/internal/docs/apiQuickstart.ts
2
- const RUN_WORKSPACE_SCRIPT_EXAMPLE = `
3
- const { output, exit } = project.runWorkspaceScript({
4
- workspaceNameOrAlias: "my-workspace",
5
- script: "my-script",
6
-
7
- // Optional. Arguments to add to the command
8
- // Can be a string or an array of strings
9
- // If string, the argv will be parsed POSIX-style
10
- args: ["--my", "--appended", "--args"],
11
-
12
- // Optional. Whether to ignore all output from the script.
13
- // This saves memory when you don't need script output.
14
- ignoreOutput: false,
15
- });
16
-
17
- // Get a stream of the script subprocess's output
18
- for await (const { chunk, metadata } of output.text()) {
19
- // console.log(chunk); // The output chunk's content (string)
20
- // console.log(metadata.streamName); // The output stream, "stdout" or "stderr"
21
- // console.log(metadata.workspace); // The target Workspace
22
- }
23
-
24
- // Get data about the script execution after it exits
25
- const exitResult = await exit;
26
-
27
- // exitResult.exitCode // The exit code (number)
28
- // exitResult.signal // The exit signal (string), or null
29
- // exitResult.success // true if exit code was 0
30
- // exitResult.startTimeISO // Start time (string)
31
- // exitResult.endTimeISO // End time (string)
32
- // exitResult.durationMs // Duration in milliseconds (number)
33
- // exitResult.metadata.workspace // The target workspace (Workspace)
34
-
35
- `.trim();
36
- const RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE = `
37
-
38
- const { output, summary } = project.runScriptAcrossWorkspaces({
39
- // Optional. This will run in all matching workspaces that have my-script
40
- // Accepts same values as the CLI run-script command's workspace patterns
41
- // When not provided, all workspaces that have the script will be used.
42
- workspacePatterns: ["my-workspace", "my-name-pattern-*"],
43
-
44
- // Required. The package.json "scripts" field name to run
45
- script: "my-script",
46
-
47
- // Optional. Arguments to add to the command (same as for runWorkspaceScript)
48
- args: ["--my", "--appended", "--args"],
49
-
50
- // Optional. Whether to run the scripts in parallel (default: true)
51
- parallel: true,
52
-
53
- // Optional. When true, a workspace's script will wait
54
- // until any workspaces it depends on have completed
55
- dependencyOrder: false,
56
-
57
- // Optional. When true and dependencyOrder is true,
58
- // continue running scripts even if a dependency fails
59
- ignoreDependencyFailure: false,
60
-
61
- // Optional. Whether to ignore all output from the scripts.
62
- // This saves memory when you don't need script output.
63
- ignoreOutput: false,
64
-
65
- // Optional, callback when script starts, skips, or exits
66
- onScriptEvent: (event, { workspace, exitResult }) => {
67
- // event: "start", "skip", "exit"
68
- }
69
- });
70
-
71
- // Get a stream of script output
72
- for await (const { chunk, metadata } of output.text()) {
73
- // console.log(chunk); // the output chunk's content (string)
74
- // console.log(metadata.streamName); // "stdout" or "stderr"
75
- // console.log(metadata.workspace); // the Workspace that the output came from
76
- }
77
-
78
- // Get final summary data and script exit details after all scripts have completed
79
- const summaryResult = await summary;
80
-
81
- // summaryResult.totalCount // Total number of scripts
82
- // summaryResult.allSuccess // true if all scripts succeeded
83
- // summaryResult.successCount // Number of scripts that succeeded
84
- // summaryResult.failureCount // Number of scripts that failed
85
- // summaryResult.startTimeISO // Start time (string)
86
- // summaryResult.endTimeISO // End time (string)
87
- // summaryResult.durationMs // Total duration in milliseconds (number)
88
-
89
- // The exit details of each workspace script
90
- for (const exitResult of summaryResult.scriptResults) {
91
- // exitResult.exitCode // The exit code (number)
92
- // exitResult.signal // The exit signal (string), or null
93
- // exitResult.success // true if exit code was 0
94
- // exitResult.startTimeISO // Start time (ISO string)
95
- // exitResult.endTimeISO // End time (ISO string)
96
- // exitResult.durationMs // Duration in milliseconds (number)
97
- // exitResult.metadata.workspace // The target workspace (Workspace)
98
- }
99
- `.trim();
100
- const API_QUICKSTART = `
101
- import { createFileSystemProject } from "bun-workspaces";
102
-
103
- // A Project contains the core functionality of bun-workspaces.
104
- // Below defaults to process.cwd() for the project root directory
105
- // Pass { rootDirectory: "path/to/your/project" } to use a different root directory
106
- const project = createFileSystemProject();
107
-
108
- // A Workspace that matches the name or alias "my-workspace"
109
- const myWorkspace = project.findWorkspaceByNameOrAlias("my-workspace");
110
-
111
- // Array of workspaces whose names match the wildcard pattern
112
- const wildcardWorkspaces = project.findWorkspacesByPattern("my-workspace-*");
113
-
114
- // Array of workspaces that have "my-script" in their package.json "scripts"
115
- const workspacesWithScript = project.listWorkspacesWithScript("my-script");
116
-
117
- // Run a script in a workspace
118
- const runSingleScript = async () => {
119
- ${RUN_WORKSPACE_SCRIPT_EXAMPLE.split("\n").join("\n ")}
120
- }
121
-
122
- // Run a script in all workspaces that have it in their package.json "scripts" field
123
- const runManyScripts = async () => {
124
- ${RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE.split("\n").join("\n ")}
125
- }
126
- `.trim();
127
-
128
- export {
129
- API_QUICKSTART,
130
- RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE,
131
- RUN_WORKSPACE_SCRIPT_EXAMPLE,
132
- };
@@ -1,2 +0,0 @@
1
- export declare const CLI_QUICKSTART: string;
2
- export declare const INLINE_SCRIPT_EXAMPLE: string;
@@ -1,86 +0,0 @@
1
- // CONCATENATED MODULE: ./src/internal/docs/cliQuickstart.ts
2
- const CLI_QUICKSTART = `
3
- # You can add this to .bashrc, .zshrc, or similar.
4
- # You can also invoke "bw" in your root package.json scripts.
5
- alias bw="bunx bun-workspaces"
6
-
7
- # List all workspaces in your project
8
- bw list-workspaces
9
-
10
- # ls is an alias for list-workspaces
11
- bw ls --json --pretty # Output as formatted JSON
12
-
13
- # Get info about a workspace
14
- bw workspace-info my-workspace
15
- bw info my-workspace --json --pretty # info is alias for workspace-info
16
-
17
- # Get info about a script, such as the workspaces that have it
18
- bw script-info my-script
19
-
20
- # Run the lint script for all workspaces
21
- # that have it in their package.json "scripts" field
22
- bw run-script lint
23
-
24
- # run is an alias for run-script
25
- bw run lint my-workspace # Run for a single workspace
26
- bw run lint my-workspace-a my-workspace-b # Run for multiple workspaces
27
- bw run lint my-alias-a my-alias-b # Run by alias (set by optional config)
28
-
29
- # A workspace's script will wait until any workspaces it depends on have completed
30
- # Similar to Bun's --filter behavior
31
- bw run lint --dep-order
32
-
33
- # Continue running scripts even if a dependency fails
34
- bw run lint --dep-order --ignore-dep-failure
35
-
36
- bw run lint "my-workspace-*" # Run for matching workspace names
37
- bw run lint "alias:my-alias-*" "path:my-glob/**/*" "tag:my-tag" # Use matching specifiers
38
- bw run lint "*" "not:path:my-path/*" # Run for all workspaces not in my-path/
39
-
40
- bw run lint --args="--my-appended-args" # Add args to each script call
41
- bw run lint --args="--my-arg=<workspaceName>" # Use the workspace name in args
42
-
43
- bw run "bun build" --inline # Run an inline command via the Bun shell
44
-
45
- # Scripts run in parallel by default
46
- bw run lint --parallel=false # Run in series
47
- bw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts
48
- bw run lint --parallel=auto # Default, based on number of available logical CPUs
49
- bw run lint --parallel=50% # Run in parallel with a max of 50% of the "auto" limit
50
-
51
- # Use the grouped output style (default when on a TTY)
52
- bw run my-script --output-style=grouped
53
-
54
- # Set the max preview lines for script output in grouped output style
55
- bw run my-script --output-style=grouped --grouped-lines=auto
56
- bw run my-script --output-style=grouped --grouped-lines=10
57
-
58
- # Use simple script output with workspace prefixes (default when not on a TTY)
59
- bw run my-script --output-style=prefixed
60
-
61
- # Use the plain output style (no workspace prefixes)
62
- bw run my-script --output-style=plain
63
-
64
- # Silence all output of the run command
65
- bw --log-level=silent run my-script --output-style=none
66
-
67
- # Show usage (you can pass --help to any command)
68
- bw help
69
- bw --help
70
-
71
- # Show version
72
- bw --version
73
-
74
- # Pass --cwd to any command
75
- bw --cwd=/path/to/your/project ls
76
- bw --cwd=/path/to/your/project run my-script
77
-
78
- # Pass --log-level to any command (debug, info, warn, error, or silent)
79
- bw --log-level=debug ls
80
- `.trim();
81
- const INLINE_SCRIPT_EXAMPLE = `
82
- # Run an inline command from the workspace directory
83
- bw run "bun run build" --inline
84
- `.trim();
85
-
86
- export { CLI_QUICKSTART, INLINE_SCRIPT_EXAMPLE };
@@ -1,2 +0,0 @@
1
- export * from "./cliQuickstart";
2
- export * from "./apiQuickstart";
@@ -1,2 +0,0 @@
1
- export * from "./cliQuickstart.mjs";
2
- export * from "./apiQuickstart.mjs"; // CONCATENATED MODULE: ./src/internal/docs/index.ts
@@ -1,10 +0,0 @@
1
- export declare const DOC_OVERVIEW =
2
- '## Project Overview\n\nbun-workspaces is a CLI and TypeScript API to help manage Bun monorepos. It reads `bun.lock` to find all workspaces in the project. It is referred to as "bw" for short, which is also the recommended CLI alias. The overall goal is a monorepo tool that is more lightweight than others, with still powerful comparable features, requiring no special config to get started, only a standard Bun repo using workspaces.\n\nThree main domain terms to know:\n\n- Project: generally represents a monorepo and is defined by the root `package.json` file\n- Workspace: a nested package within a project. The root package.json can count as a workspace as well, but by default, only nested packages are considered workspaces.\n- Script: an entry in the `scripts` field of a workspace\'s `package.json` file. bw can also run one-off commands known as "inline scripts," which can use the Bun shell or system shell (`sh -c` or `cmd /d /s /c` for windows).';
3
- export declare const DOC_CONCEPTS =
4
- '## Concepts\n\n### Workspace patterns\n\nMany features accept a list of workspace patterns to match a subset of workspaces.\n\nBy default, a pattern matches the workspace name or alias: `my-workspace-name` or `my-alias-name`. Aliases are defined in config explained below.\n\nPatterns can include a wildcard to match only by workspace name: `my-workspace-*`.\n\n- Alias pattern specifier: `alias:my-alias-*`.\n- Path pattern specifier (supports glob): `path:packages/**/*`.\n- Name pattern specifier: `name:my-workspace-*`.\n- Tag pattern specifier: `tag:my-tag`.\n- Special root workspace selector: `@root`.\n- Any pattern can start with `not:` to negate the pattern. (e.g. "not:my-workspace-name", "not:tag:my-tag-\\*") This excludes workspaces that match any other present patterns from a result.\n\n### Script runtime metadata\n\nScripts ran via bw can access metadata via env vars. This same metadata can be interpolated into inline scripts and appended args.\n\n```typescript\n// in a script\nconst projectPath = process.env.BW_PROJECT_PATH;\nconst workspaceName = process.env.BW_WORKSPACE_NAME;\nconst workspacePath = process.env.BW_WORKSPACE_PATH;\nconst workspaceRelativePath = process.env.BW_WORKSPACE_RELATIVE_PATH;\nconst scriptName = process.env.BW_SCRIPT_NAME;\n```\n\n```bash\n# interpolated\nbw run "bun <projectPath>/my-script.ts" --inline \\\n --inline-name="my-script-name" \\\n --args="<workspaceName> <workspacePath>"\n```';
5
- export declare const DOC_CLI =
6
- '### CLI examples:\n\n```bash\nalias bw="bunx bun-workspaces"\n\nbw list-workspaces # human-readable output\nbw ls --json --pretty # ls is alias for list-workspaces\nbw ls "name:my-workspace-*" "alias:my-alias-*" "path:packages/**/*" # accepts workspace patterns\n\n# info includes the name, aliases, path, etc.\nbw workspace-info my-workspace\nbw info my-workspace --json --pretty # info is alias for workspace-info\n\n# info includes the script name and workspaces that have it in their package.json "scripts" field\nbw script-info my-script --json --pretty\n\n# run the package.json "lint" script for all workspaces that have it\nbw run-script lint\n\n# run is alias for run-script\n# run the package.json "lint" script for workspaces using matching specifiers\nbw run lint my-workspace-name "alias:my-alias-pattern-*" "path:my-glob/**/*" # accepts workspace patterns\n\n# A workspace\'s script will wait until any workspaces it depends on have completed\n# Similar to Bun\'s --filter behavior\nbw run lint --dep-order\n\n# Continue running scripts even if a dependency fails\nbw run lint --dep-order --ignore-dep-failure\n\n# special root workspace selector (works even if root workspace is not included)\nbw run lint @root\n\n# Scripts run in parallel by default\nbw run lint --parallel=false # Run in series\n\n# Default can be overridden by config or env var BW_PARALLEL_MAX_DEFAULT\nbw run lint --parallel # default "auto", os.availableParallelism()\nbw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts\nbw run lint --parallel=50% # 50% of os.availableParallelism()\nbw run lint --parallel=unbounded # run all in one batch\n\n# add args to the script command\nbw run lint --args="--my-arg=value"\nbw run lint --args="--my-arg=<workspaceName>" # use the workspace name in args\n\n# run the script as an inline command from the workspace directory\nbw run "bun build" --inline\nbw run "bun build" --inline --inline-name="my-script"\nbw run "bun build" --inline --shell=system # use the system shell\n\n# Use the grouped output style (default when on a TTY)\nbw run my-script --output-style=grouped\n\n# Set the max preview lines for script output in grouped output style\nbw run my-script --output-style=grouped --grouped-lines=auto\nbw run my-script --output-style=grouped --grouped-lines=10\n\n# Use simple script output with workspace prefixes (default when not on a TTY)\nbw run my-script --output-style=prefixed\n\n# Use the plain output style (no workspace prefixes)\nbw run my-script --output-style=plain\n\n### Global Options ###\n# Root directory of project:\nbw --cwd=/path/to/project ls\nbw -d /path/to/project ls\n\n# Include root workspace as a normal workspace (default false):\nbw --include-root ls\nbw -r ls\nbw --no-include-root ls # override config/env var setting\n\n# Log level (debug|info|warn|error|silent, default info)\nbw --log-level=silent ls\nbw -l silent ls\n```';
7
- export declare const DOC_API =
8
- '### API examples:\n\nThe API is held in close parity with the CLI. It is developed first so that the CLI is a thin wrapper around the API.\n\n```typescript\nimport { createFileSystemProject } from "bun-workspaces";\n\nconst project = createFileSystemProject({\n // the options object itself and its properties are optional\n rootDirectory: "path/to/your/project",\n includeRootWorkspace: false,\n});\nproject.workspaces; // array of all workspaces in the project\nproject.rootWorkspace; // the root workspace (available even when not included in the workspaces array)\nproject.findWorkspaceByName("my-workspace"); // find a workspace by name\nproject.findWorkspaceByAlias("my-alias"); // find a workspace by alias\nproject.findWorkspaceByNameOrAlias("my-workspace-or-alias"); // find a workspace by name or alias\nproject.findWorkspacesByPattern(\n "my-workspace-name",\n "my-workspace-alias",\n "my-name-pattern-*",\n "alias:my-alias-*",\n "path:my-glob/**/*",\n); // find workspaces by pattern like the CLI\nproject.runWorkspaceScript({\n workspaceNameOrAlias: "my-workspace",\n script: "lint",\n inline: true,\n // args can be a string or an array of strings\n // if string, the argv will be parsed POSIX-style\n args: "--my-arg=value",\n});\nproject.runScriptAcrossWorkspaces({\n script: "lint",\n workspacePatterns: [\n "alias:my-alias-pattern-*",\n "path:my-glob/**/*",\n "workspace-name-a",\n "workspace-alias-b",\n ],\n parallel: true, // also could be { max: 2 }, max taking same options as seen in CLI examples above (e.g. "50%", "auto", etc.)\n dependencyOrder: true,\n ignoreDependencyFailure: true,\n // same as for runWorkspaceScript\n args: ["--my", "--appended", "--args"],\n // Optional, callback when script starts, skips, or exits\n onScriptEvent: (event, { workspace, exitResult }) => {\n // event: "start", "skip", "exit"\n },\n});\n```\n\n## The Workspace object\n\n```jsonc\n{\n // The name of the workspace from its package.json\n "name": "my-workspace",\n // Whether the workspace is the root workspace\n "isRoot": false,\n // The relative path to the workspace from the project root\n "path": "my/workspace/path",\n // The glob pattern from the root package.json "workspaces" field\n // that this workspace was matched from\n "matchPattern": "my/workspace/pattern/*",\n // The scripts available in the workspace\'s package.json\n "scripts": ["my-script"],\n // Aliases defined in workspace configuration (bw.workspace.jsonc/bw.workspace.json)\n "aliases": ["my-alias"],\n // Names of other workspaces that this workspace depends on\n "dependencies": ["my-dependency"],\n // Names of other workspaces that depend on this workspace\n "dependents": ["my-dependent"],\n}\n```';
9
- export declare const DOC_CONFIG =
10
- '## Root config\n\nOptional project config can be placed in `bw.root.jsonc`/`bw.root.json` in the root directory.\n\nConfig defaults here take precedence over environment variables that can set defaults.\nExplicit arguments to the CLI or API take precedence over all other settings.\n\n```jsonc\n{\n "defaults": {\n "parallelMax": 5, // same options as seen in CLI examples above\n "shell": "system", // "bun" or "system" (default "bun")\n "includeRootWorkspace": true, // treat root package.json as a normal workspace\n },\n}\n```\n\n## Workspace config\n\nOptional config can be placed in `bw.workspace.jsonc`/`bw.workspace.json` in a workspace directory.\n\nAliases must be unique to each workspace and to not clash with other workspaces\' `package.json` names.\n\nTags are strings to group workspaces together that therefore don\'t need to be unique to each workspace.\n\n```jsonc\n{\n "alias": "my-alias", // can be array\n "tags": ["my-tag"],\n "scripts": {\n "lint": {\n // set optional sorting order for scripts\n "order": 1,\n },\n },\n "rules": {\n "workspaceDependencies": {\n // use workspace patterns to allow or deny other workspaces as dependencies\n "allowPatterns": ["my-allow-pattern-*"],\n // or\n // "denyPatterns": ["my-deny-pattern-*"],\n },\n },\n}\n```\n\n### Workspace Dependency Rules\n\nUsing the `rules.workspaceDependencies` field, you can define rules for which workspaces are allowed to be dependencies,\nusing either `allowPatterns` or `denyPatterns`.\n\nWorkspace Patterns are used to match workspaces.\n\nYou can\'t use both `allowPatterns` and `denyPatterns` at the same time, but you can use\n\n## TypeScript/JSON Config Files\n\nYou can use TypeScript/JSON config files to define your workspace configuration.\n\n### TypeScript\n\n`bw.workspace.ts`\n\n```ts\nimport { defineWorkspaceConfig } from "bun-workspaces/config";\n\nexport default defineWorkspaceConfig({\n alias: "my-alias",\n tags: ["my-tag"],\n});\n```\n\n`bw.root.ts`\n\n```ts\nimport { defineRootConfig } from "bun-workspaces/config";\n\nexport default defineRootConfig({\n defaults: {\n parallelMax: 5,\n },\n});\n```';
@@ -1 +0,0 @@
1
- export * from "./logger";
@@ -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";