bun-workspaces 1.0.1-alpha → 1.0.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 (238) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +189 -70
  3. package/bin/cli.js +1 -2
  4. package/package.json +27 -30
  5. package/src/cli/commands/commandHandlerUtils.d.ts +50 -0
  6. package/src/cli/commands/commandHandlerUtils.mjs +91 -0
  7. package/src/cli/commands/commands.d.ts +10 -0
  8. package/src/cli/commands/commands.mjs +23 -0
  9. package/src/cli/commands/commandsConfig.d.ts +351 -0
  10. package/src/cli/commands/commandsConfig.mjs +183 -0
  11. package/src/cli/commands/handleSimpleCommands.d.ts +15 -0
  12. package/src/cli/commands/handleSimpleCommands.mjs +174 -0
  13. package/src/cli/commands/index.d.ts +3 -0
  14. package/src/cli/commands/index.mjs +3 -0
  15. package/src/cli/commands/runScript/handleRunScript.d.ts +3 -0
  16. package/src/cli/commands/runScript/handleRunScript.mjs +250 -0
  17. package/src/cli/commands/runScript/index.d.ts +2 -0
  18. package/src/cli/commands/runScript/index.mjs +2 -0
  19. package/src/cli/commands/runScript/output/index.d.ts +1 -0
  20. package/src/cli/commands/runScript/output/index.mjs +1 -0
  21. package/src/cli/commands/runScript/output/outputStyle.d.ts +8 -0
  22. package/src/cli/commands/runScript/output/outputStyle.mjs +17 -0
  23. package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +74 -0
  24. package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +331 -0
  25. package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +24 -0
  26. package/src/cli/commands/runScript/output/renderPlainOutput.mjs +44 -0
  27. package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +4 -0
  28. package/src/cli/commands/runScript/output/sanitizeChunk.mjs +101 -0
  29. package/src/cli/createCli.d.ts +25 -0
  30. package/src/cli/createCli.mjs +157 -0
  31. package/src/cli/fatalErrorLogger.d.ts +1 -0
  32. package/src/cli/fatalErrorLogger.mjs +7 -0
  33. package/src/cli/globalOptions/globalOptions.d.ts +42 -0
  34. package/src/cli/globalOptions/globalOptions.mjs +113 -0
  35. package/src/cli/globalOptions/globalOptionsConfig.d.ts +43 -0
  36. package/src/cli/globalOptions/globalOptionsConfig.mjs +34 -0
  37. package/src/cli/globalOptions/index.d.ts +2 -0
  38. package/src/cli/globalOptions/index.mjs +2 -0
  39. package/src/cli/index.d.ts +3 -0
  40. package/src/cli/index.mjs +3 -0
  41. package/src/cli/middleware.d.ts +83 -0
  42. package/src/cli/middleware.mjs +39 -0
  43. package/src/config/index.d.ts +3 -0
  44. package/src/config/index.mjs +3 -0
  45. package/src/config/rootConfig/errors.d.ts +1 -0
  46. package/src/config/rootConfig/errors.mjs +6 -0
  47. package/src/config/rootConfig/index.d.ts +5 -0
  48. package/src/config/rootConfig/index.mjs +5 -0
  49. package/src/config/rootConfig/loadRootConfig.d.ts +3 -0
  50. package/src/config/rootConfig/loadRootConfig.mjs +22 -0
  51. package/src/config/rootConfig/rootConfig.d.ts +17 -0
  52. package/src/config/rootConfig/rootConfig.mjs +43 -0
  53. package/src/config/rootConfig/rootConfigLocation.d.ts +2 -0
  54. package/src/config/rootConfig/rootConfigLocation.mjs +5 -0
  55. package/src/config/rootConfig/rootConfigSchema.d.ts +21 -0
  56. package/src/config/rootConfig/rootConfigSchema.mjs +24 -0
  57. package/src/config/userEnvVars/index.d.ts +1 -0
  58. package/src/config/userEnvVars/index.mjs +1 -0
  59. package/src/config/userEnvVars/userEnvVars.d.ts +13 -0
  60. package/src/config/userEnvVars/userEnvVars.mjs +10 -0
  61. package/src/config/util/ajvTypes.d.ts +10 -0
  62. package/src/config/util/ajvTypes.mjs +2 -0
  63. package/src/config/util/configLocation.d.ts +12 -0
  64. package/src/config/util/configLocation.mjs +11 -0
  65. package/src/config/util/index.d.ts +4 -0
  66. package/src/config/util/index.mjs +3 -0
  67. package/src/config/util/loadConfig.d.ts +16 -0
  68. package/src/config/util/loadConfig.mjs +118 -0
  69. package/src/config/util/validateConfig.d.ts +8 -0
  70. package/src/config/util/validateConfig.mjs +17 -0
  71. package/src/config/workspaceConfig/errors.d.ts +1 -0
  72. package/src/config/workspaceConfig/errors.mjs +6 -0
  73. package/src/config/workspaceConfig/index.d.ts +5 -0
  74. package/src/config/workspaceConfig/index.mjs +5 -0
  75. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +3 -0
  76. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +25 -0
  77. package/src/config/workspaceConfig/workspaceConfig.d.ts +22 -0
  78. package/src/config/workspaceConfig/workspaceConfig.mjs +31 -0
  79. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +2 -0
  80. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +5 -0
  81. package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +25 -0
  82. package/src/config/workspaceConfig/workspaceConfigSchema.mjs +28 -0
  83. package/src/doctor/doctor.d.ts +35 -0
  84. package/src/doctor/doctor.mjs +52 -0
  85. package/src/doctor/index.d.ts +1 -0
  86. package/src/doctor/index.mjs +1 -0
  87. package/src/index.d.ts +37 -0
  88. package/src/index.mjs +16 -0
  89. package/src/internal/bun/bunLock.d.ts +20 -0
  90. package/src/internal/bun/bunLock.mjs +70 -0
  91. package/src/internal/bun/bunVersion.d.ts +21 -0
  92. package/src/internal/bun/bunVersion.mjs +43 -0
  93. package/src/internal/bun/index.d.ts +2 -0
  94. package/src/internal/bun/index.mjs +2 -0
  95. package/src/internal/core/error/error.d.ts +13 -0
  96. package/src/internal/{error.ts → core/error/error.mjs} +16 -18
  97. package/src/internal/core/error/index.d.ts +1 -0
  98. package/src/internal/core/error/index.mjs +1 -0
  99. package/src/internal/core/index.d.ts +4 -0
  100. package/src/internal/core/index.mjs +4 -0
  101. package/src/internal/core/json/index.d.ts +2 -0
  102. package/src/internal/core/json/index.mjs +2 -0
  103. package/src/internal/core/json/json.d.ts +49 -0
  104. package/src/internal/core/json/json.mjs +12 -0
  105. package/src/internal/core/json/jsonc.d.ts +9 -0
  106. package/src/internal/core/json/jsonc.mjs +117 -0
  107. package/src/internal/core/language/array/index.d.ts +1 -0
  108. package/src/internal/core/language/array/index.mjs +1 -0
  109. package/src/internal/core/language/array/optionalArray.d.ts +15 -0
  110. package/src/internal/core/language/array/optionalArray.mjs +8 -0
  111. package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +16 -0
  112. package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +81 -0
  113. package/src/internal/core/language/asyncIterable/index.d.ts +2 -0
  114. package/src/internal/core/language/asyncIterable/index.mjs +2 -0
  115. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +5 -0
  116. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +27 -0
  117. package/src/internal/core/language/events/typedEventTarget.d.ts +50 -0
  118. package/src/internal/core/language/events/typedEventTarget.mjs +14 -0
  119. package/src/internal/core/language/index.d.ts +5 -0
  120. package/src/internal/core/language/index.mjs +5 -0
  121. package/src/internal/core/language/regex/index.d.ts +1 -0
  122. package/src/internal/core/language/regex/index.mjs +1 -0
  123. package/src/internal/core/language/regex/regex.d.ts +3 -0
  124. package/src/internal/core/language/regex/regex.mjs +10 -0
  125. package/src/internal/core/language/string/id.d.ts +1 -0
  126. package/src/internal/core/language/string/id.mjs +10 -0
  127. package/src/internal/core/language/string/index.d.ts +1 -0
  128. package/src/internal/core/language/string/index.mjs +1 -0
  129. package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +16 -0
  130. package/src/internal/core/language/string/utf/eastAsianWidth.mjs +326 -0
  131. package/src/internal/core/language/string/utf/visibleLength.d.ts +5 -0
  132. package/src/internal/core/language/string/utf/visibleLength.mjs +29 -0
  133. package/src/internal/core/language/types/index.d.ts +2 -0
  134. package/src/internal/core/language/types/index.mjs +1 -0
  135. package/src/internal/core/language/types/typeof.d.ts +102 -0
  136. package/src/internal/core/language/types/typeof.mjs +123 -0
  137. package/src/internal/core/language/types/types.d.ts +14 -0
  138. package/src/internal/core/language/types/types.mjs +2 -0
  139. package/src/internal/core/runtime/env.d.ts +6 -0
  140. package/src/internal/core/runtime/env.mjs +36 -0
  141. package/src/internal/core/runtime/index.d.ts +5 -0
  142. package/src/internal/core/runtime/index.mjs +5 -0
  143. package/src/internal/core/runtime/onExit.d.ts +4 -0
  144. package/src/internal/core/runtime/onExit.mjs +54 -0
  145. package/src/internal/core/runtime/os.d.ts +4 -0
  146. package/src/internal/core/runtime/os.mjs +7 -0
  147. package/src/internal/core/runtime/tempFile.d.ts +20 -0
  148. package/src/internal/core/runtime/tempFile.mjs +87 -0
  149. package/src/internal/core/runtime/terminal.d.ts +1 -0
  150. package/src/internal/core/runtime/terminal.mjs +4 -0
  151. package/src/internal/generated/ajv/validateRootConfig.mjs +1 -0
  152. package/src/internal/generated/ajv/validateWorkspaceConfig.mjs +1 -0
  153. package/src/internal/logger/index.d.ts +1 -0
  154. package/src/internal/logger/index.mjs +1 -0
  155. package/src/internal/logger/logger.d.ts +45 -0
  156. package/src/internal/logger/logger.mjs +133 -0
  157. package/src/internal/version.d.ts +1 -0
  158. package/src/internal/version.mjs +6 -0
  159. package/src/project/errors.d.ts +5 -0
  160. package/src/project/errors.mjs +10 -0
  161. package/src/project/implementations/fileSystemProject.d.ts +148 -0
  162. package/src/project/implementations/fileSystemProject.mjs +455 -0
  163. package/src/project/implementations/memoryProject.d.ts +41 -0
  164. package/src/project/implementations/memoryProject.mjs +148 -0
  165. package/src/project/implementations/projectBase.d.ts +35 -0
  166. package/src/project/implementations/projectBase.mjs +197 -0
  167. package/src/project/index.d.ts +5 -0
  168. package/src/project/index.mjs +4 -0
  169. package/src/project/project.d.ts +75 -0
  170. package/src/project/project.mjs +6 -0
  171. package/src/runScript/index.d.ts +7 -0
  172. package/src/runScript/index.mjs +7 -0
  173. package/src/runScript/output/index.d.ts +3 -0
  174. package/src/runScript/output/index.mjs +2 -0
  175. package/src/runScript/output/multiProcessOutput.d.ts +14 -0
  176. package/src/runScript/output/multiProcessOutput.mjs +21 -0
  177. package/src/runScript/output/outputStream.d.ts +1 -0
  178. package/src/runScript/output/outputStream.mjs +1 -0
  179. package/src/runScript/output/processOutput.d.ts +33 -0
  180. package/src/runScript/output/processOutput.mjs +124 -0
  181. package/src/runScript/parallel.d.ts +15 -0
  182. package/src/runScript/parallel.mjs +56 -0
  183. package/src/runScript/recursion.d.ts +4 -0
  184. package/src/runScript/recursion.mjs +17 -0
  185. package/src/runScript/runScript.d.ts +45 -0
  186. package/src/runScript/runScript.mjs +89 -0
  187. package/src/runScript/runScripts.d.ts +65 -0
  188. package/src/runScript/runScripts.mjs +263 -0
  189. package/src/runScript/scriptCommand.d.ts +33 -0
  190. package/src/runScript/scriptCommand.mjs +19 -0
  191. package/src/runScript/scriptExecution.d.ts +9 -0
  192. package/src/runScript/scriptExecution.mjs +50 -0
  193. package/src/runScript/scriptRuntimeMetadata.d.ts +73 -0
  194. package/src/runScript/scriptRuntimeMetadata.mjs +61 -0
  195. package/src/runScript/scriptShellOption.d.ts +8 -0
  196. package/src/runScript/scriptShellOption.mjs +39 -0
  197. package/src/runScript/subprocesses.d.ts +11 -0
  198. package/src/runScript/subprocesses.mjs +34 -0
  199. package/src/workspaces/dependencyGraph/cycles.d.ts +9 -0
  200. package/src/workspaces/dependencyGraph/cycles.mjs +91 -0
  201. package/src/workspaces/dependencyGraph/index.d.ts +2 -0
  202. package/src/workspaces/dependencyGraph/index.mjs +2 -0
  203. package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +18 -0
  204. package/src/workspaces/dependencyGraph/resolveDependencies.mjs +52 -0
  205. package/src/workspaces/errors.d.ts +13 -0
  206. package/src/workspaces/errors.mjs +18 -0
  207. package/src/workspaces/findWorkspaces.d.ts +24 -0
  208. package/src/workspaces/findWorkspaces.mjs +217 -0
  209. package/src/workspaces/index.d.ts +4 -0
  210. package/src/workspaces/index.mjs +3 -0
  211. package/src/workspaces/packageJson.d.ts +31 -0
  212. package/src/workspaces/packageJson.mjs +188 -0
  213. package/src/workspaces/{workspace.ts → workspace.d.ts} +11 -6
  214. package/src/workspaces/workspace.mjs +2 -0
  215. package/src/workspaces/workspacePattern.d.ts +21 -0
  216. package/src/workspaces/workspacePattern.mjs +104 -0
  217. package/bun.lock +0 -576
  218. package/src/cli/cli.ts +0 -87
  219. package/src/cli/globalOptions.ts +0 -122
  220. package/src/cli/index.ts +0 -1
  221. package/src/cli/projectCommands.ts +0 -396
  222. package/src/config/bunWorkspacesConfig.ts +0 -62
  223. package/src/config/configFile.ts +0 -33
  224. package/src/config/index.ts +0 -7
  225. package/src/index.ts +0 -3
  226. package/src/internal/bunVersion.ts +0 -26
  227. package/src/internal/env.ts +0 -25
  228. package/src/internal/logger.ts +0 -145
  229. package/src/internal/regex.ts +0 -5
  230. package/src/project/errors.ts +0 -6
  231. package/src/project/index.ts +0 -6
  232. package/src/project/project.ts +0 -155
  233. package/src/project/scriptCommand.ts +0 -40
  234. package/src/workspaces/errors.ts +0 -14
  235. package/src/workspaces/findWorkspaces.ts +0 -137
  236. package/src/workspaces/index.ts +0 -7
  237. package/src/workspaces/packageJson.ts +0 -166
  238. package/tsconfig.json +0 -28
@@ -0,0 +1,16 @@
1
+ import { type AnyFunction } from "../../internal/core";
2
+ import { type ConfigLocation } from "./configLocation";
3
+ export declare const InvalidJSONError: typeof import("../..").BunWorkspacesError;
4
+ export declare const getConfigLocation: (
5
+ name: string,
6
+ directory: string,
7
+ fileName: string,
8
+ packageJsonKey: string,
9
+ ) => ConfigLocation | null;
10
+ export declare const loadConfig: <ProcessContent extends AnyFunction>(
11
+ name: string,
12
+ directory: string,
13
+ fileName: string,
14
+ packageJsonKey: string,
15
+ processContent: ProcessContent,
16
+ ) => ReturnType<ProcessContent> | null;
@@ -0,0 +1,118 @@
1
+ import fs from "fs";
2
+ import path_0 from "path";
3
+ import { defineErrors, parseJSONC } from "../../internal/core/index.mjs";
4
+ import { logger } from "../../internal/logger/index.mjs";
5
+ import {
6
+ CONFIG_LOCATION_TYPES,
7
+ createConfigLocationPath,
8
+ } from "./configLocation.mjs"; // CONCATENATED MODULE: external "fs"
9
+ // CONCATENATED MODULE: external "path"
10
+ // CONCATENATED MODULE: external "../../internal/core/index.mjs"
11
+ // CONCATENATED MODULE: external "../../internal/logger/index.mjs"
12
+ // CONCATENATED MODULE: external "./configLocation.mjs"
13
+ // CONCATENATED MODULE: ./src/config/util/loadConfig.ts
14
+
15
+ const InvalidJSONError = defineErrors("InvalidJSON").InvalidJSON;
16
+ const parseJSON = (jsonString, path) => {
17
+ try {
18
+ return parseJSONC(jsonString);
19
+ } catch (error) {
20
+ throw new InvalidJSONError(`Invalid JSON at ${path}: ${error.message}`);
21
+ }
22
+ };
23
+ const LOCATION_FINDERS = {
24
+ jsoncFile: (directory, fileName) => {
25
+ const configFilePath = path_0.join(
26
+ directory,
27
+ createConfigLocationPath("jsoncFile", fileName, ""),
28
+ );
29
+ if (fs.existsSync(configFilePath)) {
30
+ return {
31
+ type: "jsoncFile",
32
+ content: parseJSON(
33
+ fs.readFileSync(configFilePath, "utf8"),
34
+ configFilePath,
35
+ ),
36
+ path: path_0.relative(process.cwd(), configFilePath),
37
+ };
38
+ }
39
+ return null;
40
+ },
41
+ jsonFile: (directory, fileName) => {
42
+ const configFilePath = path_0.join(
43
+ directory,
44
+ createConfigLocationPath("jsonFile", fileName, ""),
45
+ );
46
+ if (fs.existsSync(configFilePath)) {
47
+ return {
48
+ type: "jsonFile",
49
+ content: parseJSON(
50
+ fs.readFileSync(configFilePath, "utf8"),
51
+ configFilePath,
52
+ ),
53
+ path: path_0.relative(process.cwd(), configFilePath),
54
+ };
55
+ }
56
+ return null;
57
+ },
58
+ packageJson: (directory, _fileName, packageJsonKey) => {
59
+ const packageJsonPath = path_0.join(directory, "package.json");
60
+ if (fs.existsSync(packageJsonPath)) {
61
+ const packageJson = parseJSON(
62
+ fs.readFileSync(packageJsonPath, "utf8"),
63
+ packageJsonPath,
64
+ );
65
+ if (packageJson[packageJsonKey]) {
66
+ return {
67
+ type: "packageJson",
68
+ path: path_0.relative(
69
+ process.cwd(),
70
+ path_0.join(
71
+ directory,
72
+ createConfigLocationPath("packageJson", "", packageJsonKey),
73
+ ),
74
+ ),
75
+ content: packageJson[packageJsonKey],
76
+ };
77
+ }
78
+ }
79
+ return null;
80
+ },
81
+ };
82
+ const getConfigLocation = (name, directory, fileName, packageJsonKey) => {
83
+ const locations = [];
84
+ for (const locationType of CONFIG_LOCATION_TYPES) {
85
+ const location = LOCATION_FINDERS[locationType](
86
+ directory,
87
+ fileName,
88
+ packageJsonKey,
89
+ );
90
+ if (location) {
91
+ locations.push(location);
92
+ }
93
+ }
94
+ if (locations.length > 1) {
95
+ logger.warn(
96
+ `Found multiple ${name} configs:\n${locations.map((location) => " " + location.path).join("\n")}\n Using config at ${locations[0]?.path}`,
97
+ );
98
+ }
99
+ return locations[0] ?? null;
100
+ };
101
+ const loadConfig = (
102
+ name,
103
+ directory,
104
+ fileName,
105
+ packageJsonKey,
106
+ processContent,
107
+ ) => {
108
+ const location = getConfigLocation(name, directory, fileName, packageJsonKey);
109
+ if (!location) {
110
+ return null;
111
+ }
112
+ logger.debug(
113
+ `Config loaded for ${name} at ${location.type === "packageJson" ? `${path_0.join(directory, "package.json")}["${packageJsonKey}"]` : location.path}`,
114
+ );
115
+ return processContent(location.content);
116
+ };
117
+
118
+ export { InvalidJSONError, getConfigLocation, loadConfig };
@@ -0,0 +1,8 @@
1
+ import type { BunWorkspacesError } from "../../internal/core";
2
+ import type { AjvSchemaValidator } from "./ajvTypes";
3
+ export declare const executeValidator: <Config extends object>(
4
+ validator: AjvSchemaValidator<Config>,
5
+ name: string,
6
+ config: Config,
7
+ ErrorType: typeof BunWorkspacesError,
8
+ ) => void;
@@ -0,0 +1,17 @@
1
+ // CONCATENATED MODULE: ./src/config/util/validateConfig.ts
2
+ const suffixAdditionalPropertyName = (error) => {
3
+ return error.params?.additionalProperty
4
+ ? ` (found "${error.params.additionalProperty}")`
5
+ : "";
6
+ };
7
+ const executeValidator = (validator, name, config, ErrorType) => {
8
+ const isValid = validator(config);
9
+ if (!isValid) {
10
+ const multipleErrors = (validator.errors?.length ?? 0) > 1;
11
+ throw new ErrorType(
12
+ `Root config is invalid:${multipleErrors ? "\n" : ""}${validator.errors?.map((error) => `${multipleErrors ? " " : " "}${`config${error.instancePath?.replace(/[/|\\](\d+)/g, "[$1]").replaceAll(/[/|\\]/g, ".") ?? ""}`.replace(/^config[^.]/, "config.")} ${error.message?.replace(/NOT/g, "not")}${suffixAdditionalPropertyName(error)}`).join("\n")}`,
13
+ );
14
+ }
15
+ };
16
+
17
+ export { executeValidator };
@@ -0,0 +1 @@
1
+ export declare const WORKSPACE_CONFIG_ERRORS: import("../../internal/core").DefinedErrors<"InvalidWorkspaceConfig">;
@@ -0,0 +1,6 @@
1
+ import { defineErrors } from "../../internal/core/index.mjs"; // CONCATENATED MODULE: external "../../internal/core/index.mjs"
2
+ // CONCATENATED MODULE: ./src/config/workspaceConfig/errors.ts
3
+
4
+ const WORKSPACE_CONFIG_ERRORS = defineErrors("InvalidWorkspaceConfig");
5
+
6
+ export { WORKSPACE_CONFIG_ERRORS };
@@ -0,0 +1,5 @@
1
+ export * from "./workspaceConfigSchema";
2
+ export * from "./workspaceConfig";
3
+ export * from "./loadWorkspaceConfig";
4
+ export * from "./errors";
5
+ export * from "./workspaceConfigLocation";
@@ -0,0 +1,5 @@
1
+ export * from "./workspaceConfigSchema.mjs";
2
+ export * from "./workspaceConfig.mjs";
3
+ export * from "./loadWorkspaceConfig.mjs";
4
+ export * from "./errors.mjs";
5
+ export * from "./workspaceConfigLocation.mjs"; // CONCATENATED MODULE: ./src/config/workspaceConfig/index.ts
@@ -0,0 +1,3 @@
1
+ export declare const loadWorkspaceConfig: (
2
+ workspacePath: string,
3
+ ) => import("./workspaceConfig").ResolvedWorkspaceConfig;
@@ -0,0 +1,25 @@
1
+ import { loadConfig } from "../util/loadConfig.mjs";
2
+ import {
3
+ createDefaultWorkspaceConfig,
4
+ resolveWorkspaceConfig,
5
+ } from "./workspaceConfig.mjs";
6
+ import {
7
+ WORKSPACE_CONFIG_FILE_NAME,
8
+ WORKSPACE_CONFIG_PACKAGE_JSON_KEY,
9
+ } from "./workspaceConfigLocation.mjs"; // CONCATENATED MODULE: external "../util/loadConfig.mjs"
10
+ // CONCATENATED MODULE: external "./workspaceConfig.mjs"
11
+ // CONCATENATED MODULE: external "./workspaceConfigLocation.mjs"
12
+ // CONCATENATED MODULE: ./src/config/workspaceConfig/loadWorkspaceConfig.ts
13
+
14
+ const loadWorkspaceConfig = (workspacePath) => {
15
+ const config = loadConfig(
16
+ "workspace",
17
+ workspacePath,
18
+ WORKSPACE_CONFIG_FILE_NAME,
19
+ WORKSPACE_CONFIG_PACKAGE_JSON_KEY,
20
+ (content) => resolveWorkspaceConfig(content),
21
+ );
22
+ return config ?? createDefaultWorkspaceConfig();
23
+ };
24
+
25
+ export { loadWorkspaceConfig };
@@ -0,0 +1,22 @@
1
+ import { type FromSchema } from "json-schema-to-ts";
2
+ import type { WORKSPACE_CONFIG_JSON_SCHEMA } from "./workspaceConfigSchema";
3
+ /**
4
+ * @todo json-schema-to-ts doesn't support the union type for alias as it is,
5
+ * but AJV error messaging for oneOf is not good
6
+ */
7
+ export type WorkspaceConfig = Omit<
8
+ FromSchema<typeof WORKSPACE_CONFIG_JSON_SCHEMA>,
9
+ "alias"
10
+ > & {
11
+ alias?: string | string[];
12
+ };
13
+ export type ResolvedWorkspaceConfig = {
14
+ aliases: string[];
15
+ scripts: Record<string, ScriptConfig>;
16
+ };
17
+ export type ScriptConfig = NonNullable<WorkspaceConfig["scripts"]>[string];
18
+ export declare const validateWorkspaceConfig: (config: WorkspaceConfig) => void;
19
+ export declare const resolveWorkspaceConfig: (
20
+ config: WorkspaceConfig,
21
+ ) => ResolvedWorkspaceConfig;
22
+ export declare const createDefaultWorkspaceConfig: () => ResolvedWorkspaceConfig;
@@ -0,0 +1,31 @@
1
+ import { resolveOptionalArray } from "../../internal/core/index.mjs";
2
+ import validateWorkspaceConfig from "../../internal/generated/ajv/validateWorkspaceConfig.mjs";
3
+ import { executeValidator } from "../util/validateConfig.mjs";
4
+ import { WORKSPACE_CONFIG_ERRORS } from "./errors.mjs"; // CONCATENATED MODULE: external "../../internal/core/index.mjs"
5
+ // CONCATENATED MODULE: external "../../internal/generated/ajv/validateWorkspaceConfig.mjs"
6
+ // CONCATENATED MODULE: external "../util/validateConfig.mjs"
7
+ // CONCATENATED MODULE: external "./errors.mjs"
8
+ // CONCATENATED MODULE: ./src/config/workspaceConfig/workspaceConfig.ts
9
+
10
+ const validate = validateWorkspaceConfig;
11
+ const workspaceConfig_validateWorkspaceConfig = (config) =>
12
+ executeValidator(
13
+ validate,
14
+ "WorkspaceConfig",
15
+ config,
16
+ WORKSPACE_CONFIG_ERRORS.InvalidWorkspaceConfig,
17
+ );
18
+ const resolveWorkspaceConfig = (config) => {
19
+ workspaceConfig_validateWorkspaceConfig(config);
20
+ return {
21
+ aliases: resolveOptionalArray(config.alias ?? []),
22
+ scripts: config.scripts ?? {},
23
+ };
24
+ };
25
+ const createDefaultWorkspaceConfig = () => resolveWorkspaceConfig({});
26
+
27
+ export {
28
+ createDefaultWorkspaceConfig,
29
+ resolveWorkspaceConfig,
30
+ workspaceConfig_validateWorkspaceConfig as validateWorkspaceConfig,
31
+ };
@@ -0,0 +1,2 @@
1
+ export declare const WORKSPACE_CONFIG_FILE_NAME = "bw.workspace";
2
+ export declare const WORKSPACE_CONFIG_PACKAGE_JSON_KEY = "bw";
@@ -0,0 +1,5 @@
1
+ // CONCATENATED MODULE: ./src/config/workspaceConfig/workspaceConfigLocation.ts
2
+ const WORKSPACE_CONFIG_FILE_NAME = "bw.workspace";
3
+ const WORKSPACE_CONFIG_PACKAGE_JSON_KEY = "bw";
4
+
5
+ export { WORKSPACE_CONFIG_FILE_NAME, WORKSPACE_CONFIG_PACKAGE_JSON_KEY };
@@ -0,0 +1,25 @@
1
+ export declare const WORKSPACE_CONFIG_JSON_SCHEMA: {
2
+ type: "object";
3
+ additionalProperties: false;
4
+ properties: {
5
+ alias: {
6
+ type: ("string" | "array")[];
7
+ items: {
8
+ type: "string";
9
+ };
10
+ uniqueItems: true;
11
+ };
12
+ scripts: {
13
+ type: "object";
14
+ additionalProperties: {
15
+ type: "object";
16
+ properties: {
17
+ order: {
18
+ type: "number";
19
+ };
20
+ };
21
+ additionalProperties: false;
22
+ };
23
+ };
24
+ };
25
+ };
@@ -0,0 +1,28 @@
1
+ // CONCATENATED MODULE: ./src/config/workspaceConfig/workspaceConfigSchema.ts
2
+ const WORKSPACE_CONFIG_JSON_SCHEMA = {
3
+ type: "object",
4
+ additionalProperties: false,
5
+ properties: {
6
+ alias: {
7
+ type: ["string", "array"],
8
+ items: {
9
+ type: "string",
10
+ },
11
+ uniqueItems: true,
12
+ },
13
+ scripts: {
14
+ type: "object",
15
+ additionalProperties: {
16
+ type: "object",
17
+ properties: {
18
+ order: {
19
+ type: "number",
20
+ },
21
+ },
22
+ additionalProperties: false,
23
+ },
24
+ },
25
+ },
26
+ };
27
+
28
+ export { WORKSPACE_CONFIG_JSON_SCHEMA };
@@ -0,0 +1,35 @@
1
+ import type { Simplify } from "../internal/core";
2
+ declare const getBinaryInfo: () => {
3
+ binary: {
4
+ exec: string;
5
+ path: string | null;
6
+ };
7
+ };
8
+ declare const getShellInfo: () => {
9
+ shell: {
10
+ binary: string | null;
11
+ terminal: string | null;
12
+ };
13
+ };
14
+ declare const getSystemInfo: () => {
15
+ os: {
16
+ type: string;
17
+ platform: NodeJS.Platform;
18
+ arch: NodeJS.Architecture;
19
+ release: string;
20
+ version: string;
21
+ cpuCount: number;
22
+ };
23
+ };
24
+ declare const getVersionInfo: () => {
25
+ version: string;
26
+ bunVersion: string;
27
+ };
28
+ export type DoctorInfo = Simplify<
29
+ ReturnType<typeof getVersionInfo> &
30
+ ReturnType<typeof getBinaryInfo> &
31
+ ReturnType<typeof getSystemInfo> &
32
+ ReturnType<typeof getShellInfo>
33
+ >;
34
+ export declare const getDoctorInfo: () => DoctorInfo;
35
+ export {};
@@ -0,0 +1,52 @@
1
+ import fs from "fs";
2
+ import os from "os";
3
+ import path from "path";
4
+ import package_0 from "../../package.json"; // CONCATENATED MODULE: external "fs"
5
+ // CONCATENATED MODULE: external "os"
6
+ // CONCATENATED MODULE: external "path"
7
+ // CONCATENATED MODULE: external "../../package.json"
8
+ // CONCATENATED MODULE: ./src/doctor/doctor.ts
9
+
10
+ const getBinaryInfo = () => {
11
+ const argv = process.argv.slice(0);
12
+ let binaryPath = argv[1] ?? null;
13
+ try {
14
+ binaryPath = path.relative(process.cwd(), fs.realpathSync(binaryPath));
15
+ } catch {
16
+ binaryPath = null;
17
+ }
18
+ return {
19
+ binary: {
20
+ exec: process.execPath,
21
+ path: binaryPath,
22
+ },
23
+ };
24
+ };
25
+ const getShellInfo = () => ({
26
+ shell: {
27
+ binary: process.env.SHELL ?? null,
28
+ terminal: process.env.TERM ?? null,
29
+ },
30
+ });
31
+ const getSystemInfo = () => ({
32
+ os: {
33
+ type: os.type(),
34
+ platform: process.platform,
35
+ arch: process.arch,
36
+ release: os.release(),
37
+ version: os.version(),
38
+ cpuCount: os.cpus().length,
39
+ },
40
+ });
41
+ const getVersionInfo = () => ({
42
+ version: package_0.version,
43
+ bunVersion: Bun.version_with_sha,
44
+ });
45
+ const getDoctorInfo = () => ({
46
+ ...getVersionInfo(),
47
+ ...getBinaryInfo(),
48
+ ...getSystemInfo(),
49
+ ...getShellInfo(),
50
+ });
51
+
52
+ export { getDoctorInfo };
@@ -0,0 +1 @@
1
+ export * from "./doctor";
@@ -0,0 +1 @@
1
+ export * from "./doctor.mjs"; // CONCATENATED MODULE: ./src/doctor/index.ts
package/src/index.d.ts ADDED
@@ -0,0 +1,37 @@
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 {
28
+ type ScriptEventName,
29
+ type OutputStreamName,
30
+ type PercentageValue,
31
+ type ParallelMaxValue,
32
+ type WorkspaceScriptCommandMethod,
33
+ type RunScriptsParallelOptions,
34
+ } from "./runScript";
35
+ export { type Workspace } from "./workspaces";
36
+ export { type SimpleAsyncIterable, BunWorkspacesError } from "./internal/core";
37
+ export { setLogLevel, type LogLevelSetting } from "./internal/logger";
package/src/index.mjs ADDED
@@ -0,0 +1,16 @@
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"; // CONCATENATED MODULE: external "./project/index.mjs"
7
+ // CONCATENATED MODULE: external "./internal/core/index.mjs"
8
+ // CONCATENATED MODULE: external "./internal/logger/index.mjs"
9
+ // CONCATENATED MODULE: ./src/index.ts
10
+
11
+ export {
12
+ BunWorkspacesError,
13
+ createFileSystemProject,
14
+ createMemoryProject,
15
+ setLogLevel,
16
+ };
@@ -0,0 +1,20 @@
1
+ import { type BunWorkspacesError } from "../core";
2
+ export declare const BUN_LOCK_ERRORS: import("../core").DefinedErrors<
3
+ "BunLockNotFound" | "MalformedBunLock" | "UnsupportedBunLockVersion"
4
+ >;
5
+ export type RelevantBunLockWorkspace = {
6
+ name: string;
7
+ };
8
+ export type RelevantBunLock = {
9
+ lockfileVersion: number;
10
+ workspaces: Record<string, RelevantBunLockWorkspace>;
11
+ };
12
+ export declare const SUPPORTED_BUN_LOCK_VERSIONS: readonly [1];
13
+ export declare const parseBunLock: (
14
+ jsonString: string,
15
+ /** Only for error message */
16
+ bunLockPath?: string,
17
+ ) => RelevantBunLock | BunWorkspacesError;
18
+ export declare const readBunLockfile: (
19
+ directory: string,
20
+ ) => RelevantBunLock | BunWorkspacesError;
@@ -0,0 +1,70 @@
1
+ import fs from "fs";
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
7
+
8
+ const BUN_LOCK_ERRORS = defineErrors(
9
+ "BunLockNotFound",
10
+ "MalformedBunLock",
11
+ "UnsupportedBunLockVersion",
12
+ );
13
+ const SUPPORTED_BUN_LOCK_VERSIONS = [1];
14
+ const parseBunLock = (
15
+ jsonString,
16
+ /** Only for error message */ bunLockPath,
17
+ ) => {
18
+ let bunLockJson = null;
19
+ try {
20
+ bunLockJson = parseJSONC(jsonString);
21
+ } catch (error) {
22
+ return new BUN_LOCK_ERRORS.MalformedBunLock(
23
+ `Failed to parse bun lockfile ${bunLockPath ? `at "${bunLockPath}"` : ""}: ${error.message}`,
24
+ );
25
+ }
26
+ if (!isJSONObject(bunLockJson)) {
27
+ return new BUN_LOCK_ERRORS.MalformedBunLock(
28
+ `Bun lockfile ${bunLockPath ? `at "${bunLockPath}"` : ""} is not a valid JSON object`,
29
+ );
30
+ }
31
+ if (bunLockJson.lockfileVersion !== SUPPORTED_BUN_LOCK_VERSIONS[0]) {
32
+ return new BUN_LOCK_ERRORS.UnsupportedBunLockVersion(
33
+ `Unsupported bun lockfile version ${bunLockPath ? `at "${bunLockPath}"` : ""}: ${bunLockJson.lockfileVersion ?? "(could not find property lockfileVersion)"} (Supported: ${SUPPORTED_BUN_LOCK_VERSIONS.join(", ")})`,
34
+ );
35
+ }
36
+ if (typeof bunLockJson.lockfileVersion !== "number") {
37
+ return new BUN_LOCK_ERRORS.MalformedBunLock(
38
+ `Bun lockfile ${bunLockPath ? `at "${bunLockPath}"` : ""} has an invalid lockfileVersion field of type ${typeof bunLockJson.lockfileVersion}: ${bunLockJson.lockfileVersion}`,
39
+ );
40
+ }
41
+ if (bunLockJson.workspaces && typeof bunLockJson.workspaces !== "object") {
42
+ return new BUN_LOCK_ERRORS.MalformedBunLock(
43
+ `Bun lockfile ${bunLockPath ? `at "${bunLockPath}"` : ""} has an invalid workspaces field of type ${typeof bunLockJson.workspaces}: ${bunLockJson.workspaces}`,
44
+ );
45
+ }
46
+ return {
47
+ lockfileVersion: bunLockJson.lockfileVersion,
48
+ workspaces: bunLockJson.workspaces ?? {},
49
+ };
50
+ };
51
+ const readBunLockfile = (directory) => {
52
+ const bunLockPath = path.join(
53
+ directory.replace(/(\/*)?bun.lock$/, ""),
54
+ "bun.lock",
55
+ );
56
+ if (!fs.existsSync(bunLockPath)) {
57
+ return new BUN_LOCK_ERRORS.BunLockNotFound(
58
+ `Did not find bun lockfile at "${bunLockPath}"`,
59
+ );
60
+ }
61
+ const jsonString = fs.readFileSync(bunLockPath, "utf8");
62
+ return parseBunLock(jsonString, bunLockPath);
63
+ };
64
+
65
+ export {
66
+ BUN_LOCK_ERRORS,
67
+ SUPPORTED_BUN_LOCK_VERSIONS,
68
+ parseBunLock,
69
+ readBunLockfile,
70
+ };
@@ -0,0 +1,21 @@
1
+ export declare const LIBRARY_CONSUMER_BUN_VERSION: string;
2
+ export declare const BUILD_BUN_VERSION: string;
3
+ export declare const BUN_VERSION_ERRORS: import("../core").DefinedErrors<
4
+ "InvalidBunVersion" | "NotBunRuntime"
5
+ >;
6
+ export declare const getRequiredBunVersion: (isBuild?: boolean) => string;
7
+ /**
8
+ * Validates that the provided version satisfies the required Bun version
9
+ * specified in the root `package.json`.
10
+ */
11
+ export declare const validateBunVersion: (
12
+ version: string,
13
+ isBuild?: boolean,
14
+ ) => import("../core").BunWorkspacesError | null;
15
+ /**
16
+ * Validates that the Bun version of the current script satisfies the
17
+ * required Bun version specified in the root `package.json`.
18
+ */
19
+ export declare const validateCurrentBunVersion: (
20
+ build?: boolean,
21
+ ) => import("../core").BunWorkspacesError | null;
@@ -0,0 +1,43 @@
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
5
+
6
+ const LIBRARY_CONSUMER_BUN_VERSION =
7
+ package_0._bwInternal.bunVersion.libraryConsumer;
8
+ const BUILD_BUN_VERSION = package_0._bwInternal.bunVersion.build;
9
+ const BUN_VERSION_ERRORS = defineErrors("InvalidBunVersion", "NotBunRuntime");
10
+ const getRequiredBunVersion = (isBuild) =>
11
+ isBuild
12
+ ? BUILD_BUN_VERSION.replace(/\.\d+$/, ".x")
13
+ : LIBRARY_CONSUMER_BUN_VERSION;
14
+ const _Bun = typeof Bun === "undefined" ? null : Bun;
15
+ /**
16
+ * Validates that the provided version satisfies the required Bun version
17
+ * specified in the root `package.json`.
18
+ */ const validateBunVersion = (version, isBuild) =>
19
+ _Bun
20
+ ? _Bun.semver.satisfies(version, getRequiredBunVersion(isBuild))
21
+ ? null
22
+ : new BUN_VERSION_ERRORS.InvalidBunVersion(
23
+ isBuild
24
+ ? `Expected Bun version ${getRequiredBunVersion(isBuild)} for build`
25
+ : `Bun version ${version} is not supported by bun-workspaces. Supported: ${getRequiredBunVersion(isBuild)}`,
26
+ )
27
+ : new BUN_VERSION_ERRORS.NotBunRuntime(
28
+ `bun-workspaces is not running in a Bun runtime. Expected Bun version ${getRequiredBunVersion(isBuild)}`,
29
+ );
30
+ /**
31
+ * Validates that the Bun version of the current script satisfies the
32
+ * required Bun version specified in the root `package.json`.
33
+ */ const validateCurrentBunVersion = (build) =>
34
+ validateBunVersion(_Bun?.version ?? "(Error: not Bun runtime)", build);
35
+
36
+ export {
37
+ BUILD_BUN_VERSION,
38
+ BUN_VERSION_ERRORS,
39
+ LIBRARY_CONSUMER_BUN_VERSION,
40
+ getRequiredBunVersion,
41
+ validateBunVersion,
42
+ validateCurrentBunVersion,
43
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./bunVersion";
2
+ export * from "./bunLock";
@@ -0,0 +1,2 @@
1
+ export * from "./bunVersion.mjs";
2
+ export * from "./bunLock.mjs"; // CONCATENATED MODULE: ./src/internal/bun/index.ts