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,61 +1,43 @@
1
- import { IS_WINDOWS } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
2
- // CONCATENATED MODULE: ./src/runScript/scriptRuntimeMetadata.ts
1
+ import { IS_WINDOWS } from "../internal/core/index.mjs";
2
+ import { getScriptRuntimeMetadataConfig } from "../1108.mjs";
3
3
 
4
- const SCRIPT_RUNTIME_METADATA_CONFIG = {
5
- projectPath: {
6
- inlineName: "<projectPath>",
7
- envVarName: "BW_PROJECT_PATH",
8
- },
9
- projectName: {
10
- inlineName: "<projectName>",
11
- envVarName: "BW_PROJECT_NAME",
12
- },
13
- workspacePath: {
14
- inlineName: "<workspacePath>",
15
- envVarName: "BW_WORKSPACE_PATH",
16
- },
17
- workspaceRelativePath: {
18
- inlineName: "<workspaceRelativePath>",
19
- envVarName: "BW_WORKSPACE_RELATIVE_PATH",
20
- },
21
- scriptName: {
22
- inlineName: "<scriptName>",
23
- envVarName: "BW_SCRIPT_NAME",
24
- },
25
- workspaceName: {
26
- inlineName: "<workspaceName>",
27
- envVarName: "BW_WORKSPACE_NAME",
28
- },
29
- };
30
- const getScriptRuntimeMetadataConfig = (key) =>
31
- SCRIPT_RUNTIME_METADATA_CONFIG[key];
32
- const createScriptRuntimeEnvVars = (metadata) =>
33
- Object.entries(SCRIPT_RUNTIME_METADATA_CONFIG).reduce((acc, [key, value]) => {
34
- acc[value.envVarName] = metadata[key];
4
+ const createScriptRuntimeEnvVars = (metadata) => {
5
+ const keys = [
6
+ "projectPath",
7
+ "projectName",
8
+ "workspacePath",
9
+ "workspaceRelativePath",
10
+ "scriptName",
11
+ "workspaceName",
12
+ ];
13
+ return keys.reduce((acc, key) => {
14
+ const { envVarName } = getScriptRuntimeMetadataConfig(key);
15
+ acc[envVarName] = metadata[key];
35
16
  return acc;
36
17
  }, {});
37
- const interpolateScriptRuntimeMetadata = (text, metadata, shell) =>
38
- text.replace(
39
- new RegExp(
40
- Object.values(SCRIPT_RUNTIME_METADATA_CONFIG)
41
- .flatMap((value) => value.inlineName)
42
- .join("|"),
43
- "g",
44
- ),
45
- (match) => {
46
- const key = Object.entries(SCRIPT_RUNTIME_METADATA_CONFIG).find(
47
- ([_, value]) => value.inlineName === match,
48
- )?.[0];
49
- const value = metadata[key];
50
- if (IS_WINDOWS && shell === "bun") {
51
- return value.replace(/\\/g, "\\\\");
52
- }
53
- return value;
54
- },
18
+ };
19
+ const interpolateScriptRuntimeMetadata = (text, metadata, shell) => {
20
+ const keys = [
21
+ "projectPath",
22
+ "projectName",
23
+ "workspacePath",
24
+ "workspaceRelativePath",
25
+ "scriptName",
26
+ "workspaceName",
27
+ ];
28
+ const inlineNames = keys.map(
29
+ (key) => getScriptRuntimeMetadataConfig(key).inlineName,
55
30
  );
56
-
57
- export {
58
- createScriptRuntimeEnvVars,
59
- getScriptRuntimeMetadataConfig,
60
- interpolateScriptRuntimeMetadata,
31
+ return text.replace(new RegExp(inlineNames.join("|"), "g"), (match) => {
32
+ const key = keys.find(
33
+ (k) => getScriptRuntimeMetadataConfig(k).inlineName === match,
34
+ );
35
+ const value = metadata[key];
36
+ if (IS_WINDOWS && shell === "bun") {
37
+ return value.replace(/\\/g, "\\\\");
38
+ }
39
+ return value;
40
+ });
61
41
  };
42
+
43
+ export { createScriptRuntimeEnvVars, interpolateScriptRuntimeMetadata };
@@ -1,12 +1,8 @@
1
- import {
2
- getUserEnvVar,
3
- getUserEnvVarName,
4
- } from "../config/userEnvVars/index.mjs";
5
- import { BunWorkspacesError } from "../internal/core/error/index.mjs"; // CONCATENATED MODULE: external "../config/userEnvVars/index.mjs"
6
- // CONCATENATED MODULE: external "../internal/core/error/index.mjs"
7
- // CONCATENATED MODULE: ./src/runScript/scriptShellOption.ts
1
+ import { getUserEnvVar } from "../config/userEnvVars/index.mjs";
2
+ import { BunWorkspacesError } from "../internal/core/error/index.mjs";
3
+ import { SCRIPT_SHELL_OPTIONS } from "../4427.mjs";
4
+ import { getUserEnvVarName } from "../5166.mjs";
8
5
 
9
- const SCRIPT_SHELL_OPTIONS = ["bun", "system"];
10
6
  const validateScriptShellOption = (shell, fromEnvVar = false) => {
11
7
  if (!SCRIPT_SHELL_OPTIONS.includes(shell)) {
12
8
  throw new BunWorkspacesError(
@@ -31,9 +27,4 @@ const resolveScriptShell = (shell) => {
31
27
  return validateScriptShellOption(shell);
32
28
  };
33
29
 
34
- export {
35
- SCRIPT_SHELL_OPTIONS,
36
- getScriptShellDefault,
37
- resolveScriptShell,
38
- validateScriptShellOption,
39
- };
30
+ export { getScriptShellDefault, resolveScriptShell, validateScriptShellOption };
@@ -1,7 +1,5 @@
1
1
  import { IS_WINDOWS, runOnExit } from "../internal/core/index.mjs";
2
- import { logger } from "../internal/logger/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
3
- // CONCATENATED MODULE: external "../internal/logger/index.mjs"
4
- // CONCATENATED MODULE: ./src/runScript/subprocesses.ts
2
+ import { logger } from "../internal/logger/index.mjs";
5
3
 
6
4
  const SUBPROCESS_REGISTRY = {};
7
5
  runOnExit((codeOrSignal) => {
@@ -0,0 +1,58 @@
1
+ import {
2
+ mergeWorkspaceConfig,
3
+ resolveWorkspaceConfig,
4
+ } from "../config/index.mjs";
5
+ import { matchWorkspacesByPatterns } from "./workspacePattern.mjs";
6
+
7
+ const resolvedToWorkspaceConfig = ({ aliases, tags, scripts, rules }) => ({
8
+ alias: aliases,
9
+ tags,
10
+ scripts,
11
+ rules,
12
+ });
13
+ const makeContext = (workspace) => ({
14
+ name: workspace.name,
15
+ isRoot: workspace.isRoot,
16
+ path: workspace.path,
17
+ matchPattern: workspace.matchPattern,
18
+ scripts: workspace.scripts,
19
+ dependencies: workspace.dependencies,
20
+ dependents: workspace.dependents,
21
+ });
22
+ const applyWorkspacePatternConfigs = (
23
+ workspaces,
24
+ workspaceMap,
25
+ workspaceAliases,
26
+ patternConfigs,
27
+ ) => {
28
+ for (const entry of patternConfigs) {
29
+ const matched = matchWorkspacesByPatterns(entry.patterns, workspaces);
30
+ for (const workspace of matched) {
31
+ const mapEntry = workspaceMap[workspace.name];
32
+ const prevConfig = mapEntry.config;
33
+ const configToMerge =
34
+ typeof entry.config === "function"
35
+ ? entry.config(makeContext(workspace), prevConfig)
36
+ : entry.config;
37
+ const resolved = resolveWorkspaceConfig(
38
+ mergeWorkspaceConfig(
39
+ resolvedToWorkspaceConfig(prevConfig),
40
+ configToMerge,
41
+ ),
42
+ );
43
+ // Register any new aliases for validation
44
+ const previousAliases = new Set(workspace.aliases);
45
+ for (const alias of resolved.aliases) {
46
+ if (!previousAliases.has(alias)) {
47
+ workspaceAliases[alias] = workspace.name;
48
+ }
49
+ }
50
+ // Update workspace object so subsequent pattern entries see accumulated aliases/tags
51
+ workspace.aliases = resolved.aliases;
52
+ workspace.tags = resolved.tags;
53
+ mapEntry.config = resolved;
54
+ }
55
+ }
56
+ };
57
+
58
+ export { applyWorkspacePatternConfigs };
@@ -1,4 +1,3 @@
1
- // CONCATENATED MODULE: ./src/workspaces/dependencyGraph/cycles.ts
2
1
  const preventDependencyCycles = (workspaces) => {
3
2
  const byName = new Map(workspaces.map((n) => [n.name, n]));
4
3
  // memo: name -> chains that end at `name`
@@ -1,3 +1,5 @@
1
1
  export * from "./cycles.mjs";
2
2
  export * from "./resolveDependencies.mjs";
3
- export * from "./validateDependencyRules.mjs"; // CONCATENATED MODULE: ./src/workspaces/dependencyGraph/index.ts
3
+ export * from "./validateDependencyRules.mjs";
4
+
5
+ export {};
@@ -1,5 +1,4 @@
1
- import { resolveCatalogDependencyVersion } from "../packageJson.mjs"; // CONCATENATED MODULE: external "../packageJson.mjs"
2
- // CONCATENATED MODULE: ./src/workspaces/dependencyGraph/resolveDependencies.ts
1
+ import { resolveCatalogDependencyVersion } from "../packageJson.mjs";
3
2
 
4
3
  const resolveWorkspaceDependencies = (
5
4
  workspaceMap,
@@ -1,7 +1,5 @@
1
1
  import { WORKSPACE_ERRORS } from "../errors.mjs";
2
- import { matchWorkspacesByPatterns } from "../workspacePattern.mjs"; // CONCATENATED MODULE: external "../errors.mjs"
3
- // CONCATENATED MODULE: external "../workspacePattern.mjs"
4
- // CONCATENATED MODULE: ./src/workspaces/dependencyGraph/validateDependencyRules.ts
2
+ import { matchWorkspacesByPatterns } from "../workspacePattern.mjs";
5
3
 
6
4
  const getTransitiveDeps = (workspaceName, workspaceMap, chain, visited) => {
7
5
  const entry = workspaceMap[workspaceName];
@@ -34,16 +32,6 @@ const validateWorkspaceDependencyRules = ({ workspaceMap }) => {
34
32
  const depWorkspace = workspaceMap[depName]?.workspace;
35
33
  if (!depWorkspace) continue;
36
34
  const chainStr = chain.join(" -> ");
37
- if (rule.denyPatterns) {
38
- const isDenied =
39
- matchWorkspacesByPatterns(rule.denyPatterns, [depWorkspace]).length >
40
- 0;
41
- if (isDenied) {
42
- violations.push(
43
- `"${workspaceName}" violates workspaceDependencies rule: workspace "${depName}" is denied by denyPatterns (dependency chain: ${chainStr})`,
44
- );
45
- }
46
- }
47
35
  if (rule.allowPatterns) {
48
36
  const isAllowed =
49
37
  matchWorkspacesByPatterns(rule.allowPatterns, [depWorkspace]).length >
@@ -52,6 +40,17 @@ const validateWorkspaceDependencyRules = ({ workspaceMap }) => {
52
40
  violations.push(
53
41
  `"${workspaceName}" violates workspaceDependencies rule: workspace "${depName}" is not permitted by allowPatterns (dependency chain: ${chainStr})`,
54
42
  );
43
+ continue;
44
+ }
45
+ }
46
+ if (rule.denyPatterns) {
47
+ const isDenied =
48
+ matchWorkspacesByPatterns(rule.denyPatterns, [depWorkspace]).length >
49
+ 0;
50
+ if (isDenied) {
51
+ violations.push(
52
+ `"${workspaceName}" violates workspaceDependencies rule: workspace "${depName}" is denied by denyPatterns (dependency chain: ${chainStr})`,
53
+ );
55
54
  }
56
55
  }
57
56
  }
@@ -1,5 +1,4 @@
1
- import { defineErrors } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
2
- // CONCATENATED MODULE: ./src/workspaces/errors.ts
1
+ import { defineErrors } from "../internal/core/index.mjs";
3
2
 
4
3
  const WORKSPACE_ERRORS = defineErrors(
5
4
  "PackageNotFound",
@@ -8,6 +8,7 @@ import {
8
8
  import { BUN_LOCK_ERRORS, readBunLockfile } from "../internal/bun/index.mjs";
9
9
  import { BunWorkspacesError } from "../internal/core/index.mjs";
10
10
  import { logger } from "../internal/logger/logger.mjs";
11
+ import { applyWorkspacePatternConfigs } from "./applyWorkspacePatternConfigs.mjs";
11
12
  import {
12
13
  resolveWorkspaceDependencies,
13
14
  validateWorkspaceDependencyRules,
@@ -16,17 +17,7 @@ import { WORKSPACE_ERRORS } from "./errors.mjs";
16
17
  import {
17
18
  resolvePackageJsonContent,
18
19
  resolvePackageJsonPath,
19
- } from "./packageJson.mjs"; // CONCATENATED MODULE: external "fs"
20
- // CONCATENATED MODULE: external "path"
21
- // CONCATENATED MODULE: external "bun"
22
- // CONCATENATED MODULE: external "../config/index.mjs"
23
- // CONCATENATED MODULE: external "../internal/bun/index.mjs"
24
- // CONCATENATED MODULE: external "../internal/core/index.mjs"
25
- // CONCATENATED MODULE: external "../internal/logger/logger.mjs"
26
- // CONCATENATED MODULE: external "./dependencyGraph/index.mjs"
27
- // CONCATENATED MODULE: external "./errors.mjs"
28
- // CONCATENATED MODULE: external "./packageJson.mjs"
29
- // CONCATENATED MODULE: ./src/workspaces/findWorkspaces.ts
20
+ } from "./packageJson.mjs";
30
21
 
31
22
  const sortWorkspaces = (workspaces) =>
32
23
  [...workspaces]
@@ -75,6 +66,7 @@ const findWorkspaces = ({
75
66
  rootDirectory,
76
67
  workspaceGlobs: _workspaceGlobs,
77
68
  includeRootWorkspace = false,
69
+ workspacePatternConfigs,
78
70
  }) => {
79
71
  rootDirectory = path.resolve(rootDirectory);
80
72
  logger.debug(`Finding workspaces in ${rootDirectory}`);
@@ -179,6 +171,14 @@ const findWorkspaces = ({
179
171
  bunCatalogs,
180
172
  ),
181
173
  );
174
+ if (workspacePatternConfigs?.length) {
175
+ applyWorkspacePatternConfigs(
176
+ workspaces,
177
+ workspaceMap,
178
+ workspaceAliases,
179
+ workspacePatternConfigs,
180
+ );
181
+ }
182
182
  validateWorkspaceDependencyRules({
183
183
  workspaceMap,
184
184
  });
@@ -1,3 +1,5 @@
1
1
  export * from "./findWorkspaces.mjs";
2
2
  export * from "./packageJson.mjs";
3
- export * from "./errors.mjs"; // CONCATENATED MODULE: ./src/workspaces/index.ts
3
+ export * from "./errors.mjs";
4
+
5
+ export {};
@@ -1,13 +1,8 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { isJSONObject } from "../internal/core/index.mjs";
4
3
  import { logger } from "../internal/logger/index.mjs";
5
- import { WORKSPACE_ERRORS } from "./errors.mjs"; // CONCATENATED MODULE: external "fs"
6
- // CONCATENATED MODULE: external "path"
7
- // CONCATENATED MODULE: external "../internal/core/index.mjs"
8
- // CONCATENATED MODULE: external "../internal/logger/index.mjs"
9
- // CONCATENATED MODULE: external "./errors.mjs"
10
- // CONCATENATED MODULE: ./src/workspaces/packageJson.ts
4
+ import { WORKSPACE_ERRORS } from "./errors.mjs";
5
+ import { isJSONObject } from "../8257.mjs";
11
6
 
12
7
  const resolvePackageJsonPath = (directoryItem) => {
13
8
  if (path.basename(directoryItem) === "package.json") {
@@ -1,2 +1,3 @@
1
- // CONCATENATED MODULE: ./src/workspaces/workspace.ts
2
1
  /** Metadata about a nested package within a Bun monorepo */
2
+
3
+ export {};
@@ -1,9 +1,9 @@
1
1
  import bun from "bun";
2
- import { createWildcardRegex, defineErrors } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "bun"
3
- // CONCATENATED MODULE: external "../internal/core/index.mjs"
4
- // CONCATENATED MODULE: ./src/workspaces/workspacePattern.ts
2
+ import { createWildcardRegex, defineErrors } from "../internal/core/index.mjs";
5
3
 
6
- const TARGETS = ["path", "alias", "name", "tag"];
4
+ const WORKSPACE_PATTERN_TARGETS = ["path", "alias", "name", "tag"];
5
+
6
+ const TARGETS = WORKSPACE_PATTERN_TARGETS;
7
7
  const WORKSPACE_PATTERN_ERRORS = defineErrors("InvalidWorkspacePattern");
8
8
  const WORKSPACE_PATTERN_NEGATION_PREFIX = "not:";
9
9
  const WORKSPACE_PATTERN_SEPARATOR = ":";
@@ -1,4 +0,0 @@
1
- import type { FileSystemProject } from "../../project/implementations/fileSystemProject";
2
- export declare const startBwMcpServer: (
3
- project: FileSystemProject,
4
- ) => Promise<void>;
@@ -1,3 +0,0 @@
1
- export * from "./types";
2
- export * from "./transport";
3
- export * from "./server";
@@ -1,14 +0,0 @@
1
- import { type McpTransport } from "./transport";
2
- import {
3
- type McpServerInfo,
4
- type Resource,
5
- type ResourceHandler,
6
- type Tool,
7
- type ToolHandler,
8
- } from "./types";
9
- export type McpServer = {
10
- registerTool: (tool: Tool, handler: ToolHandler) => void;
11
- registerResource: (resource: Resource, handler: ResourceHandler) => void;
12
- start: (transport?: McpTransport) => Promise<void>;
13
- };
14
- export declare const createMcpServer: (info: McpServerInfo) => McpServer;
@@ -1,12 +0,0 @@
1
- export type RawMessage = Record<string, unknown>;
2
- export type McpTransport = {
3
- receive: () => AsyncGenerator<RawMessage>;
4
- send: (message: RawMessage) => void;
5
- };
6
- export type MemoryTransport = McpTransport & {
7
- sent: RawMessage[];
8
- };
9
- export declare const createMemoryTransport: (
10
- messages: RawMessage[],
11
- ) => MemoryTransport;
12
- export declare const createStdioTransport: () => McpTransport;
@@ -1,104 +0,0 @@
1
- export type JsonRpcId = string | number;
2
- export type JsonRpcSuccessResponse = {
3
- jsonrpc: "2.0";
4
- id: JsonRpcId;
5
- result: unknown;
6
- };
7
- export type JsonRpcErrorResponse = {
8
- jsonrpc: "2.0";
9
- id: JsonRpcId;
10
- error: {
11
- code: number;
12
- message: string;
13
- data?: unknown;
14
- };
15
- };
16
- export declare const JSON_RPC_ERROR_CODES: {
17
- readonly parseError: -32700;
18
- readonly invalidRequest: -32600;
19
- readonly methodNotFound: -32601;
20
- readonly invalidParams: -32602;
21
- readonly internalError: -32603;
22
- };
23
- export declare const MCP_PROTOCOL_VERSION = "2024-11-05";
24
- export type ServerCapabilities = {
25
- tools?: Record<string, never>;
26
- resources?: Record<string, never>;
27
- };
28
- export type McpServerInfo = {
29
- name: string;
30
- version: string;
31
- instructions?: string;
32
- };
33
- export type InitializeResult = {
34
- protocolVersion: string;
35
- capabilities: ServerCapabilities;
36
- serverInfo: {
37
- name: string;
38
- version: string;
39
- };
40
- instructions?: string;
41
- };
42
- export type JsonSchemaProperty =
43
- | {
44
- type: "string";
45
- description?: string;
46
- enum?: string[];
47
- }
48
- | {
49
- type: "number";
50
- description?: string;
51
- }
52
- | {
53
- type: "boolean";
54
- description?: string;
55
- }
56
- | {
57
- type: "array";
58
- items: JsonSchemaProperty;
59
- description?: string;
60
- }
61
- | {
62
- type: "object";
63
- properties?: Record<string, JsonSchemaProperty>;
64
- required?: string[];
65
- description?: string;
66
- };
67
- export type ToolInputSchema = {
68
- type: "object";
69
- properties?: Record<string, JsonSchemaProperty>;
70
- required?: string[];
71
- };
72
- export type Tool = {
73
- name: string;
74
- description: string;
75
- inputSchema: ToolInputSchema;
76
- };
77
- export type TextContent = {
78
- type: "text";
79
- text: string;
80
- };
81
- export type CallToolResult = {
82
- content: TextContent[];
83
- isError?: boolean;
84
- };
85
- export type Resource = {
86
- uri: string;
87
- name: string;
88
- description?: string;
89
- mimeType?: string;
90
- };
91
- export type ResourceContent = {
92
- uri: string;
93
- mimeType: string;
94
- text: string;
95
- };
96
- export type ReadResourceResult = {
97
- contents: ResourceContent[];
98
- };
99
- export type ToolHandler = (
100
- args: Record<string, unknown>,
101
- ) => Promise<CallToolResult> | CallToolResult;
102
- export type ResourceHandler = (
103
- uri: string,
104
- ) => Promise<ReadResourceResult> | ReadResourceResult;
@@ -1,2 +0,0 @@
1
- export * from "./core";
2
- export * from "./bwMcpServer";
@@ -1,6 +0,0 @@
1
- import type { FileSystemProject } from "../../project/implementations/fileSystemProject";
2
- import type { McpServer } from "./core";
3
- export declare const registerBwResources: (
4
- server: McpServer,
5
- project: FileSystemProject,
6
- ) => void;
@@ -1,6 +0,0 @@
1
- import type { FileSystemProject } from "../../project/implementations/fileSystemProject";
2
- import type { McpServer } from "./core";
3
- export declare const registerBwTools: (
4
- server: McpServer,
5
- project: FileSystemProject,
6
- ) => void;
@@ -1,51 +0,0 @@
1
- import { type Command } from "commander";
2
- import type { FileSystemProject } from "../../project/implementations/fileSystemProject";
3
- import type { Workspace } from "../../workspaces";
4
- import type { WriteOutputOptions } from "../createCli";
5
- import type { CliMiddleware } from "../middleware";
6
- import {
7
- type CliGlobalCommandName,
8
- type CliProjectCommandName,
9
- } from "./commandsConfig";
10
- /** @todo DRY use of output text in cases such as having no workspaces/scripts */
11
- export type GlobalCommandContext = {
12
- program: Command;
13
- postTerminatorArgs: string[];
14
- middleware: CliMiddleware;
15
- outputWriters: Required<WriteOutputOptions>;
16
- terminalWidth: number;
17
- terminalHeight: number;
18
- };
19
- export type ProjectCommandContext = GlobalCommandContext & {
20
- project: FileSystemProject;
21
- projectError: Error | null;
22
- };
23
- /** Splits workspace patterns by whitespace, but allows escaping spaces via backslash */
24
- export declare const splitWorkspacePatterns: (
25
- workspacePatterns: string,
26
- ) => string[];
27
- export declare const createWorkspaceInfoLines: (
28
- workspace: Workspace,
29
- ) => string[];
30
- export declare const createScriptInfoLines: (
31
- script: string,
32
- workspaces: Workspace[],
33
- ) => string[];
34
- export declare const createJsonLines: (
35
- data: unknown,
36
- options: {
37
- pretty: boolean;
38
- },
39
- ) => string[];
40
- export declare const commandOutputLogger: import("../../internal/logger").Logger;
41
- export declare const handleGlobalCommand: <ActionArgs extends unknown[]>(
42
- commandName: CliGlobalCommandName,
43
- handler: (context: GlobalCommandContext, ...actionArgs: ActionArgs) => void,
44
- ) => (context: GlobalCommandContext) => Command;
45
- export declare const handleProjectCommand: <ActionArgs extends unknown[]>(
46
- commandName: CliProjectCommandName,
47
- handler: (
48
- context: Omit<ProjectCommandContext, "projectError">,
49
- ...actionArgs: ActionArgs
50
- ) => void,
51
- ) => (context: ProjectCommandContext) => Command;
@@ -1,10 +0,0 @@
1
- import type {
2
- GlobalCommandContext,
3
- ProjectCommandContext,
4
- } from "./commandHandlerUtils";
5
- export declare const defineGlobalCommands: (
6
- context: GlobalCommandContext,
7
- ) => void;
8
- export declare const defineProjectCommands: (
9
- context: ProjectCommandContext,
10
- ) => void;