bun-workspaces 1.0.0-alpha.8 → 1.0.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 (233) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +212 -19
  3. package/bin/cli.js +1 -1
  4. package/package.json +25 -9
  5. package/src/cli/commands/commandHandlerUtils.d.ts +45 -0
  6. package/src/cli/commands/commandHandlerUtils.mjs +81 -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 +71 -0
  24. package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +307 -0
  25. package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +22 -0
  26. package/src/cli/commands/runScript/output/renderPlainOutput.mjs +43 -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 +14 -8
  30. package/src/cli/createCli.mjs +94 -39
  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 +38 -2
  34. package/src/cli/globalOptions/globalOptions.mjs +96 -47
  35. package/src/cli/globalOptions/globalOptionsConfig.d.ts +37 -31
  36. package/src/cli/globalOptions/globalOptionsConfig.mjs +32 -30
  37. package/src/cli/globalOptions/index.mjs +1 -1
  38. package/src/cli/index.d.ts +3 -1
  39. package/src/cli/index.mjs +3 -2
  40. package/src/config/index.d.ts +3 -2
  41. package/src/config/index.mjs +3 -3
  42. package/src/config/rootConfig/errors.d.ts +1 -0
  43. package/src/config/rootConfig/errors.mjs +6 -0
  44. package/src/config/rootConfig/index.d.ts +5 -0
  45. package/src/config/rootConfig/index.mjs +5 -0
  46. package/src/config/rootConfig/loadRootConfig.d.ts +3 -0
  47. package/src/config/rootConfig/loadRootConfig.mjs +22 -0
  48. package/src/config/rootConfig/rootConfig.d.ts +17 -0
  49. package/src/config/rootConfig/rootConfig.mjs +43 -0
  50. package/src/config/rootConfig/rootConfigLocation.d.ts +2 -0
  51. package/src/config/rootConfig/rootConfigLocation.mjs +5 -0
  52. package/src/config/rootConfig/rootConfigSchema.d.ts +21 -0
  53. package/src/config/rootConfig/rootConfigSchema.mjs +24 -0
  54. package/src/config/userEnvVars/index.d.ts +1 -0
  55. package/src/config/userEnvVars/index.mjs +1 -0
  56. package/src/config/userEnvVars/userEnvVars.d.ts +13 -0
  57. package/src/config/userEnvVars/userEnvVars.mjs +10 -0
  58. package/src/config/util/ajvTypes.d.ts +10 -0
  59. package/src/config/util/ajvTypes.mjs +2 -0
  60. package/src/config/util/configLocation.d.ts +12 -0
  61. package/src/config/util/configLocation.mjs +11 -0
  62. package/src/config/util/index.d.ts +4 -0
  63. package/src/config/util/index.mjs +3 -0
  64. package/src/config/util/loadConfig.d.ts +16 -0
  65. package/src/config/util/loadConfig.mjs +118 -0
  66. package/src/config/util/validateConfig.d.ts +8 -0
  67. package/src/config/util/validateConfig.mjs +17 -0
  68. package/src/config/workspaceConfig/errors.d.ts +1 -0
  69. package/src/config/workspaceConfig/errors.mjs +6 -0
  70. package/src/config/workspaceConfig/index.d.ts +5 -0
  71. package/src/config/workspaceConfig/index.mjs +5 -0
  72. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +3 -0
  73. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +25 -0
  74. package/src/config/workspaceConfig/workspaceConfig.d.ts +22 -0
  75. package/src/config/workspaceConfig/workspaceConfig.mjs +31 -0
  76. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +2 -0
  77. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +5 -0
  78. package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +25 -0
  79. package/src/config/workspaceConfig/workspaceConfigSchema.mjs +28 -0
  80. package/src/doctor/doctor.d.ts +35 -0
  81. package/src/doctor/doctor.mjs +52 -0
  82. package/src/doctor/index.d.ts +1 -0
  83. package/src/doctor/index.mjs +1 -0
  84. package/src/index.d.ts +37 -3
  85. package/src/index.mjs +16 -3
  86. package/src/internal/bun/bunLock.d.ts +20 -0
  87. package/src/internal/bun/bunLock.mjs +70 -0
  88. package/src/internal/bun/bunVersion.d.ts +21 -0
  89. package/src/internal/bun/bunVersion.mjs +43 -0
  90. package/src/internal/bun/index.d.ts +2 -0
  91. package/src/internal/bun/index.mjs +2 -0
  92. package/src/internal/core/error/error.d.ts +13 -0
  93. package/src/internal/core/error/error.mjs +36 -0
  94. package/src/internal/core/error/index.d.ts +1 -0
  95. package/src/internal/core/error/index.mjs +1 -0
  96. package/src/internal/core/index.d.ts +4 -0
  97. package/src/internal/core/index.mjs +4 -0
  98. package/src/internal/core/json/index.d.ts +2 -0
  99. package/src/internal/core/json/index.mjs +2 -0
  100. package/src/internal/core/json/json.d.ts +49 -0
  101. package/src/internal/core/json/json.mjs +12 -0
  102. package/src/internal/core/json/jsonc.d.ts +9 -0
  103. package/src/internal/core/json/jsonc.mjs +117 -0
  104. package/src/internal/core/language/array/index.d.ts +1 -0
  105. package/src/internal/core/language/array/index.mjs +1 -0
  106. package/src/internal/core/language/array/optionalArray.d.ts +15 -0
  107. package/src/internal/core/language/array/optionalArray.mjs +8 -0
  108. package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +16 -0
  109. package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +81 -0
  110. package/src/internal/core/language/asyncIterable/index.d.ts +2 -0
  111. package/src/internal/core/language/asyncIterable/index.mjs +2 -0
  112. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +5 -0
  113. package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +27 -0
  114. package/src/internal/core/language/events/typedEventTarget.d.ts +50 -0
  115. package/src/internal/core/language/events/typedEventTarget.mjs +14 -0
  116. package/src/internal/core/language/index.d.ts +5 -0
  117. package/src/internal/core/language/index.mjs +5 -0
  118. package/src/internal/core/language/regex/index.d.ts +1 -0
  119. package/src/internal/core/language/regex/index.mjs +1 -0
  120. package/src/internal/{regex.d.ts → core/language/regex/regex.d.ts} +1 -0
  121. package/src/internal/core/language/regex/regex.mjs +10 -0
  122. package/src/internal/core/language/string/id.d.ts +1 -0
  123. package/src/internal/core/language/string/id.mjs +10 -0
  124. package/src/internal/core/language/string/index.d.ts +1 -0
  125. package/src/internal/core/language/string/index.mjs +1 -0
  126. package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +16 -0
  127. package/src/internal/core/language/string/utf/eastAsianWidth.mjs +326 -0
  128. package/src/internal/core/language/string/utf/visibleLength.d.ts +5 -0
  129. package/src/internal/core/language/string/utf/visibleLength.mjs +29 -0
  130. package/src/internal/core/language/types/index.d.ts +2 -0
  131. package/src/internal/core/language/types/index.mjs +1 -0
  132. package/src/internal/core/language/types/typeof.d.ts +102 -0
  133. package/src/internal/core/language/types/typeof.mjs +123 -0
  134. package/src/internal/core/language/types/types.d.ts +14 -0
  135. package/src/internal/core/language/types/types.mjs +2 -0
  136. package/src/internal/{env.d.ts → core/runtime/env.d.ts} +1 -0
  137. package/src/internal/core/runtime/env.mjs +36 -0
  138. package/src/internal/core/runtime/index.d.ts +5 -0
  139. package/src/internal/core/runtime/index.mjs +5 -0
  140. package/src/internal/core/runtime/onExit.d.ts +4 -0
  141. package/src/internal/core/runtime/onExit.mjs +54 -0
  142. package/src/internal/core/runtime/os.d.ts +4 -0
  143. package/src/internal/core/runtime/os.mjs +7 -0
  144. package/src/internal/core/runtime/tempFile.d.ts +20 -0
  145. package/src/internal/core/runtime/tempFile.mjs +87 -0
  146. package/src/internal/core/runtime/terminal.d.ts +1 -0
  147. package/src/internal/core/runtime/terminal.mjs +4 -0
  148. package/src/internal/generated/ajv/validateRootConfig.mjs +1 -0
  149. package/src/internal/generated/ajv/validateWorkspaceConfig.mjs +1 -0
  150. package/src/internal/logger/index.d.ts +1 -0
  151. package/src/internal/logger/index.mjs +1 -0
  152. package/src/internal/logger/logger.d.ts +39 -0
  153. package/src/internal/logger/logger.mjs +116 -0
  154. package/src/internal/version.d.ts +1 -0
  155. package/src/internal/version.mjs +6 -0
  156. package/src/project/errors.d.ts +5 -1
  157. package/src/project/errors.mjs +10 -3
  158. package/src/project/implementations/fileSystemProject.d.ts +148 -0
  159. package/src/project/implementations/fileSystemProject.mjs +455 -0
  160. package/src/project/implementations/memoryProject.d.ts +41 -0
  161. package/src/project/implementations/memoryProject.mjs +148 -0
  162. package/src/project/implementations/projectBase.d.ts +35 -0
  163. package/src/project/implementations/projectBase.mjs +197 -0
  164. package/src/project/index.d.ts +5 -1
  165. package/src/project/index.mjs +4 -2
  166. package/src/project/project.d.ts +72 -28
  167. package/src/project/project.mjs +6 -72
  168. package/src/runScript/index.d.ts +7 -0
  169. package/src/runScript/index.mjs +7 -0
  170. package/src/runScript/output/index.d.ts +3 -0
  171. package/src/runScript/output/index.mjs +2 -0
  172. package/src/runScript/output/multiProcessOutput.d.ts +14 -0
  173. package/src/runScript/output/multiProcessOutput.mjs +21 -0
  174. package/src/runScript/output/outputStream.d.ts +1 -0
  175. package/src/runScript/output/outputStream.mjs +1 -0
  176. package/src/runScript/output/processOutput.d.ts +33 -0
  177. package/src/runScript/output/processOutput.mjs +124 -0
  178. package/src/runScript/parallel.d.ts +15 -0
  179. package/src/runScript/parallel.mjs +56 -0
  180. package/src/runScript/recursion.d.ts +4 -0
  181. package/src/runScript/recursion.mjs +17 -0
  182. package/src/runScript/runScript.d.ts +45 -0
  183. package/src/runScript/runScript.mjs +89 -0
  184. package/src/runScript/runScripts.d.ts +65 -0
  185. package/src/runScript/runScripts.mjs +263 -0
  186. package/src/runScript/scriptCommand.d.ts +33 -0
  187. package/src/runScript/scriptCommand.mjs +19 -0
  188. package/src/runScript/scriptExecution.d.ts +9 -0
  189. package/src/runScript/scriptExecution.mjs +50 -0
  190. package/src/runScript/scriptRuntimeMetadata.d.ts +73 -0
  191. package/src/runScript/scriptRuntimeMetadata.mjs +61 -0
  192. package/src/runScript/scriptShellOption.d.ts +8 -0
  193. package/src/runScript/scriptShellOption.mjs +39 -0
  194. package/src/runScript/subprocesses.d.ts +11 -0
  195. package/src/runScript/subprocesses.mjs +34 -0
  196. package/src/workspaces/dependencyGraph/cycles.d.ts +9 -0
  197. package/src/workspaces/dependencyGraph/cycles.mjs +91 -0
  198. package/src/workspaces/dependencyGraph/index.d.ts +2 -0
  199. package/src/workspaces/dependencyGraph/index.mjs +2 -0
  200. package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +18 -0
  201. package/src/workspaces/dependencyGraph/resolveDependencies.mjs +52 -0
  202. package/src/workspaces/errors.d.ts +13 -1
  203. package/src/workspaces/errors.mjs +18 -3
  204. package/src/workspaces/findWorkspaces.d.ts +20 -13
  205. package/src/workspaces/findWorkspaces.mjs +208 -57
  206. package/src/workspaces/index.d.ts +4 -3
  207. package/src/workspaces/index.mjs +3 -2
  208. package/src/workspaces/packageJson.d.ts +28 -5
  209. package/src/workspaces/packageJson.mjs +177 -54
  210. package/src/workspaces/workspace.d.ts +19 -13
  211. package/src/workspaces/workspace.mjs +2 -0
  212. package/src/workspaces/workspacePattern.d.ts +21 -0
  213. package/src/workspaces/workspacePattern.mjs +104 -0
  214. package/src/cli/projectCommands/index.d.ts +0 -2
  215. package/src/cli/projectCommands/index.mjs +0 -2
  216. package/src/cli/projectCommands/projectCommandHandlers.d.ts +0 -8
  217. package/src/cli/projectCommands/projectCommandHandlers.mjs +0 -180
  218. package/src/cli/projectCommands/projectCommandsConfig.d.ts +0 -191
  219. package/src/cli/projectCommands/projectCommandsConfig.mjs +0 -100
  220. package/src/config/bunWorkspacesConfig.d.ts +0 -13
  221. package/src/config/bunWorkspacesConfig.mjs +0 -18
  222. package/src/config/configFile.d.ts +0 -3
  223. package/src/config/configFile.mjs +0 -21
  224. package/src/internal/bunVersion.d.ts +0 -14
  225. package/src/internal/bunVersion.mjs +0 -8
  226. package/src/internal/env.mjs +0 -15
  227. package/src/internal/error.d.ts +0 -7
  228. package/src/internal/error.mjs +0 -26
  229. package/src/internal/logger.d.ts +0 -21
  230. package/src/internal/logger.mjs +0 -85
  231. package/src/internal/regex.mjs +0 -3
  232. package/src/project/scriptCommand.d.ts +0 -15
  233. package/src/project/scriptCommand.mjs +0 -18
@@ -1,4 +1,40 @@
1
1
  import { type Command } from "commander";
2
- export declare const initializeWithGlobalOptions: (program: Command, args: string[], defaultCwd: string) => {
3
- project: import("../..").Project;
2
+ export declare const initializeWithGlobalOptions: (
3
+ program: Command,
4
+ args: string[],
5
+ defaultCwd: string,
6
+ ) => {
7
+ project: import("../../internal/core").Simplify<{
8
+ readonly rootDirectory: string;
9
+ readonly workspaces: import("../..").Workspace[];
10
+ readonly name: string;
11
+ readonly sourceType: "fileSystem";
12
+ readonly config: import("../../project").ProjectConfig;
13
+ readonly rootWorkspace: import("../..").Workspace;
14
+ runWorkspaceScript(
15
+ options: import("../..").RunWorkspaceScriptOptions,
16
+ ): import("../..").RunWorkspaceScriptResult;
17
+ runScriptAcrossWorkspaces(
18
+ options: import("../..").RunScriptAcrossWorkspacesOptions,
19
+ ): import("../..").RunScriptAcrossWorkspacesResult;
20
+ listWorkspacesWithScript(scriptName: string): import("../..").Workspace[];
21
+ mapScriptsToWorkspaces(): Record<
22
+ string,
23
+ import("../..").WorkspaceScriptMetadata
24
+ >;
25
+ findWorkspaceByName(
26
+ workspaceName: string,
27
+ ): import("../..").Workspace | null;
28
+ findWorkspaceByAlias(alias: string): import("../..").Workspace | null;
29
+ findWorkspaceByNameOrAlias(
30
+ nameOrAlias: string,
31
+ ): import("../..").Workspace | null;
32
+ findWorkspacesByPattern(
33
+ ...workspacePatterns: string[]
34
+ ): import("../..").Workspace[];
35
+ createScriptCommand(
36
+ options: import("../..").CreateProjectScriptCommandOptions,
37
+ ): import("../..").CreateProjectScriptCommandResult;
38
+ }>;
39
+ projectError: Error | null;
4
40
  };
@@ -1,56 +1,105 @@
1
+ import fs from "fs";
1
2
  import path from "path";
2
3
  import { Option } from "commander";
3
- import { loadConfigFile } from "../../config/index.mjs";
4
- import { logger } from "../../internal/logger.mjs";
5
- import { createProject } from "../../project/index.mjs";
6
- import { getCliGlobalOptionConfig } from "./globalOptionsConfig.mjs";
7
- const addGlobalOption = (program, optionName, defaultOverride)=>{
8
- const { mainOption, shortOption, description, param, values, defaultValue } = getCliGlobalOptionConfig(optionName);
9
- const option = new Option(`${shortOption} ${mainOption}${param ? ` <${param}>` : ""}`, description).default(defaultOverride ?? defaultValue);
10
- program.addOption(values?.length ? option.choices(values) : option);
4
+ import { defineErrors } from "../../internal/core/index.mjs";
5
+ import { logger } from "../../internal/logger/index.mjs";
6
+ import {
7
+ createFileSystemProject,
8
+ createMemoryProject,
9
+ } from "../../project/index.mjs";
10
+ import { getCliGlobalOptionConfig } from "./globalOptionsConfig.mjs"; // CONCATENATED MODULE: external "fs"
11
+ // CONCATENATED MODULE: external "path"
12
+ // CONCATENATED MODULE: external "commander"
13
+ // CONCATENATED MODULE: external "../../internal/core/index.mjs"
14
+ // CONCATENATED MODULE: external "../../internal/logger/index.mjs"
15
+ // CONCATENATED MODULE: external "../../project/index.mjs"
16
+ // CONCATENATED MODULE: external "./globalOptionsConfig.mjs"
17
+ // CONCATENATED MODULE: ./src/cli/globalOptions/globalOptions.ts
18
+
19
+ const ERRORS = defineErrors(
20
+ "WorkingDirectoryNotFound",
21
+ "WorkingDirectoryNotADirectory",
22
+ );
23
+ const addGlobalOption = (program, optionName, defaultOverride) => {
24
+ const { mainOption, shortOption, description, param, values, defaultValue } =
25
+ getCliGlobalOptionConfig(optionName);
26
+ let option = new Option(
27
+ `${shortOption} ${mainOption}${param ? ` <${param}>` : ""}`,
28
+ description,
29
+ );
30
+ const effectiveDefaultValue = defaultOverride ?? defaultValue;
31
+ if (effectiveDefaultValue) {
32
+ option = option.default(effectiveDefaultValue);
33
+ }
34
+ if (values?.length) {
35
+ option = option.choices(values);
36
+ }
37
+ program.addOption(option);
38
+ if (!param) {
39
+ program.option(
40
+ mainOption.replace(/^--/, "--no-"),
41
+ `Set ${mainOption} as false`,
42
+ );
43
+ }
11
44
  };
12
- const getWorkingDirectory = (program, args, defaultCwd)=>{
13
- addGlobalOption(program, "cwd", defaultCwd);
14
- program.parseOptions(args);
15
- return program.opts().cwd;
45
+ const getWorkingDirectoryFromArgs = (program, args, defaultCwd) => {
46
+ addGlobalOption(program, "cwd", defaultCwd);
47
+ program.parseOptions(args);
48
+ return program.opts().cwd;
16
49
  };
17
- const getConfig = (program, args)=>{
18
- addGlobalOption(program, "configFile");
19
- program.parseOptions(args);
20
- return program.opts().configFile;
50
+ const defineGlobalOptions = (program, args, defaultCwd) => {
51
+ const cwd = getWorkingDirectoryFromArgs(program, args, defaultCwd);
52
+ if (!fs.existsSync(cwd)) {
53
+ throw new ERRORS.WorkingDirectoryNotFound(
54
+ `Working directory not found at path "${cwd}"`,
55
+ );
56
+ }
57
+ if (!fs.statSync(cwd).isDirectory()) {
58
+ throw new ERRORS.WorkingDirectoryNotADirectory(
59
+ `Working directory is not a directory at path "${cwd}"`,
60
+ );
61
+ }
62
+ addGlobalOption(program, "logLevel");
63
+ addGlobalOption(program, "includeRoot");
64
+ return {
65
+ cwd,
66
+ };
21
67
  };
22
- const defineGlobalOptions = (program, args, defaultCwd)=>{
23
- const cwd = getWorkingDirectory(program, args, defaultCwd);
24
- const configFilePath = getConfig(program, args);
25
- const config = loadConfigFile(configFilePath, cwd);
26
- addGlobalOption(program, "logLevel");
27
- return {
28
- cwd,
29
- config
30
- };
31
- };
32
- const applyGlobalOptions = (options, config)=>{
33
- logger.printLevel = options.logLevel;
34
- logger.debug("Log level: " + options.logLevel);
35
- const project = createProject({
36
- rootDir: options.cwd,
37
- workspaceAliases: config?.project?.workspaceAliases ?? {}
68
+ const applyGlobalOptions = (options) => {
69
+ logger.printLevel = options.logLevel;
70
+ logger.debug("Log level: " + options.logLevel);
71
+ let project;
72
+ let error = null;
73
+ try {
74
+ project = createFileSystemProject({
75
+ rootDirectory: options.cwd,
76
+ includeRootWorkspace: options.includeRoot,
77
+ });
78
+ logger.debug(
79
+ `Project: ${JSON.stringify(project.name)} (${project.workspaces.length} workspace${project.workspaces.length === 1 ? "" : "s"})`,
80
+ );
81
+ logger.debug("Project root: " + path.resolve(project.rootDirectory));
82
+ } catch (_error) {
83
+ error = _error;
84
+ project = createMemoryProject({
85
+ workspaces: [],
38
86
  });
39
- logger.debug(`Project: ${JSON.stringify(project.name)} (${project.workspaces.length} workspace${1 === project.workspaces.length ? "" : "s"})`);
40
- logger.debug("Project root: " + path.resolve(project.rootDir));
41
- return {
42
- project
43
- };
87
+ }
88
+ return {
89
+ project,
90
+ projectError: error,
91
+ };
44
92
  };
45
- const initializeWithGlobalOptions = (program, args, defaultCwd)=>{
46
- program.allowUnknownOption(true);
47
- const { cwd, config } = defineGlobalOptions(program, args, defaultCwd);
48
- program.parseOptions(args);
49
- program.allowUnknownOption(false);
50
- const options = program.opts();
51
- return applyGlobalOptions({
52
- ...options,
53
- cwd
54
- }, config);
93
+ const initializeWithGlobalOptions = (program, args, defaultCwd) => {
94
+ program.allowUnknownOption(true);
95
+ const { cwd } = defineGlobalOptions(program, args, defaultCwd);
96
+ program.parseOptions(args);
97
+ program.allowUnknownOption(false);
98
+ const options = program.opts();
99
+ return applyGlobalOptions({
100
+ ...options,
101
+ cwd,
102
+ });
55
103
  };
104
+
56
105
  export { initializeWithGlobalOptions };
@@ -1,37 +1,43 @@
1
1
  import { type LogLevelSetting } from "../../internal/logger";
2
2
  export interface CliGlobalOptions {
3
- logLevel: LogLevelSetting;
4
- cwd: string;
5
- configFile?: string;
3
+ logLevel: LogLevelSetting;
4
+ cwd: string;
5
+ includeRoot: boolean;
6
6
  }
7
7
  export interface CliGlobalOptionConfig {
8
- mainOption: string;
9
- shortOption: string;
10
- description: string;
11
- defaultValue: string;
12
- values: LogLevelSetting[] | null;
13
- param: string;
8
+ mainOption: string;
9
+ shortOption: string;
10
+ description: string;
11
+ defaultValue: string;
12
+ values: string[] | null;
13
+ param: string;
14
14
  }
15
15
  export type CliGlobalOptionName = keyof CliGlobalOptions;
16
- export declare const getCliGlobalOptionConfig: (optionName: CliGlobalOptionName) => {
17
- readonly mainOption: "--logLevel";
18
- readonly shortOption: "-l";
19
- readonly description: "Log levels";
20
- readonly defaultValue: "info";
21
- readonly values: ["debug", "info", "warn", "error", "silent"];
22
- readonly param: "level";
23
- } | {
24
- readonly mainOption: "--cwd";
25
- readonly shortOption: "-d";
26
- readonly description: "Working directory";
27
- readonly defaultValue: ".";
28
- readonly values: null;
29
- readonly param: "path";
30
- } | {
31
- readonly mainOption: "--configFile";
32
- readonly shortOption: "-c";
33
- readonly description: "Config file";
34
- readonly defaultValue: "";
35
- readonly values: null;
36
- readonly param: "path";
37
- };
16
+ export declare const getCliGlobalOptionConfig: (
17
+ optionName: CliGlobalOptionName,
18
+ ) =>
19
+ | {
20
+ readonly mainOption: "--log-level";
21
+ readonly shortOption: "-l";
22
+ readonly description: "Log levels";
23
+ readonly defaultValue: "info";
24
+ readonly values: ("debug" | "info" | "warn" | "error" | "silent")[];
25
+ readonly param: "level";
26
+ }
27
+ | {
28
+ readonly mainOption: "--cwd";
29
+ readonly shortOption: "-d";
30
+ readonly description: "Working directory";
31
+ readonly defaultValue: ".";
32
+ readonly values: null;
33
+ readonly param: "path";
34
+ }
35
+ | {
36
+ readonly mainOption: "--include-root";
37
+ readonly shortOption: "-r";
38
+ readonly description: "Include the root workspace as a normal workspace";
39
+ readonly defaultValue: "";
40
+ readonly values: null;
41
+ readonly param: "";
42
+ };
43
+ export declare const getCliGlobalOptionNames: () => CliGlobalOptionName[];
@@ -1,32 +1,34 @@
1
- import { LOG_LEVELS } from "../../internal/logger.mjs";
1
+ import { LOG_LEVELS } from "../../internal/logger/index.mjs"; // CONCATENATED MODULE: external "../../internal/logger/index.mjs"
2
+ // CONCATENATED MODULE: ./src/cli/globalOptions/globalOptionsConfig.ts
3
+
2
4
  const CLI_GLOBAL_OPTIONS_CONFIG = {
3
- logLevel: {
4
- mainOption: "--logLevel",
5
- shortOption: "-l",
6
- description: "Log levels",
7
- defaultValue: "info",
8
- values: [
9
- ...LOG_LEVELS,
10
- "silent"
11
- ],
12
- param: "level"
13
- },
14
- cwd: {
15
- mainOption: "--cwd",
16
- shortOption: "-d",
17
- description: "Working directory",
18
- defaultValue: ".",
19
- values: null,
20
- param: "path"
21
- },
22
- configFile: {
23
- mainOption: "--configFile",
24
- shortOption: "-c",
25
- description: "Config file",
26
- defaultValue: "",
27
- values: null,
28
- param: "path"
29
- }
5
+ logLevel: {
6
+ mainOption: "--log-level",
7
+ shortOption: "-l",
8
+ description: "Log levels",
9
+ defaultValue: "info",
10
+ values: [...LOG_LEVELS, "silent"],
11
+ param: "level",
12
+ },
13
+ cwd: {
14
+ mainOption: "--cwd",
15
+ shortOption: "-d",
16
+ description: "Working directory",
17
+ defaultValue: ".",
18
+ values: null,
19
+ param: "path",
20
+ },
21
+ includeRoot: {
22
+ mainOption: "--include-root",
23
+ shortOption: "-r",
24
+ description: "Include the root workspace as a normal workspace",
25
+ defaultValue: "",
26
+ values: null,
27
+ param: "",
28
+ },
30
29
  };
31
- const getCliGlobalOptionConfig = (optionName)=>CLI_GLOBAL_OPTIONS_CONFIG[optionName];
32
- export { getCliGlobalOptionConfig };
30
+ const getCliGlobalOptionConfig = (optionName) =>
31
+ CLI_GLOBAL_OPTIONS_CONFIG[optionName];
32
+ const getCliGlobalOptionNames = () => Object.keys(CLI_GLOBAL_OPTIONS_CONFIG);
33
+
34
+ export { getCliGlobalOptionConfig, getCliGlobalOptionNames };
@@ -1,2 +1,2 @@
1
1
  export * from "./globalOptionsConfig.mjs";
2
- export * from "./globalOptions.mjs";
2
+ export * from "./globalOptions.mjs"; // CONCATENATED MODULE: ./src/cli/globalOptions/index.ts
@@ -1 +1,3 @@
1
- export { createCli } from "./createCli";
1
+ export * from "./createCli";
2
+ export * from "./commands";
3
+ export * from "./globalOptions";
package/src/cli/index.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import { createCli } from "./createCli.mjs";
2
- export { createCli };
1
+ export * from "./createCli.mjs";
2
+ export * from "./commands/index.mjs";
3
+ export * from "./globalOptions/index.mjs"; // CONCATENATED MODULE: ./src/cli/index.ts
@@ -1,2 +1,3 @@
1
- export { validateBunWorkspacesConfig, type BunWorkspacesConfig, type CliConfig, type ProjectConfig, } from "./bunWorkspacesConfig";
2
- export { loadConfigFile, DEFAULT_CONFIG_FILE_PATH } from "./configFile";
1
+ export * from "./workspaceConfig";
2
+ export * from "./rootConfig";
3
+ export * from "./util";
@@ -1,3 +1,3 @@
1
- import { validateBunWorkspacesConfig } from "./bunWorkspacesConfig.mjs";
2
- import { DEFAULT_CONFIG_FILE_PATH, loadConfigFile } from "./configFile.mjs";
3
- export { DEFAULT_CONFIG_FILE_PATH, loadConfigFile, validateBunWorkspacesConfig };
1
+ export * from "./workspaceConfig/index.mjs";
2
+ export * from "./rootConfig/index.mjs";
3
+ export * from "./util/index.mjs"; // CONCATENATED MODULE: ./src/config/index.ts
@@ -0,0 +1 @@
1
+ export declare const ROOT_CONFIG_ERRORS: import("../../internal/core").DefinedErrors<"InvalidRootConfig">;
@@ -0,0 +1,6 @@
1
+ import { defineErrors } from "../../internal/core/index.mjs"; // CONCATENATED MODULE: external "../../internal/core/index.mjs"
2
+ // CONCATENATED MODULE: ./src/config/rootConfig/errors.ts
3
+
4
+ const ROOT_CONFIG_ERRORS = defineErrors("InvalidRootConfig");
5
+
6
+ export { ROOT_CONFIG_ERRORS };
@@ -0,0 +1,5 @@
1
+ export * from "./rootConfigSchema";
2
+ export * from "./rootConfig";
3
+ export * from "./loadRootConfig";
4
+ export * from "./errors";
5
+ export * from "./rootConfigLocation";
@@ -0,0 +1,5 @@
1
+ export * from "./rootConfigSchema.mjs";
2
+ export * from "./rootConfig.mjs";
3
+ export * from "./loadRootConfig.mjs";
4
+ export * from "./errors.mjs";
5
+ export * from "./rootConfigLocation.mjs"; // CONCATENATED MODULE: ./src/config/rootConfig/index.ts
@@ -0,0 +1,3 @@
1
+ export declare const loadRootConfig: (
2
+ rootDirectory: string,
3
+ ) => import("./rootConfig").ResolvedRootConfig;
@@ -0,0 +1,22 @@
1
+ import { loadConfig } from "../util/loadConfig.mjs";
2
+ import { createDefaultRootConfig, resolveRootConfig } from "./rootConfig.mjs";
3
+ import {
4
+ ROOT_CONFIG_FILE_NAME,
5
+ ROOT_CONFIG_PACKAGE_JSON_KEY,
6
+ } from "./rootConfigLocation.mjs"; // CONCATENATED MODULE: external "../util/loadConfig.mjs"
7
+ // CONCATENATED MODULE: external "./rootConfig.mjs"
8
+ // CONCATENATED MODULE: external "./rootConfigLocation.mjs"
9
+ // CONCATENATED MODULE: ./src/config/rootConfig/loadRootConfig.ts
10
+
11
+ const loadRootConfig = (rootDirectory) => {
12
+ const config = loadConfig(
13
+ "root",
14
+ rootDirectory,
15
+ ROOT_CONFIG_FILE_NAME,
16
+ ROOT_CONFIG_PACKAGE_JSON_KEY,
17
+ (content) => resolveRootConfig(content),
18
+ );
19
+ return config ?? createDefaultRootConfig();
20
+ };
21
+
22
+ export { loadRootConfig };
@@ -0,0 +1,17 @@
1
+ import { type FromSchema } from "json-schema-to-ts";
2
+ import { type ScriptShellOption } from "../../runScript";
3
+ import type { ROOT_CONFIG_JSON_SCHEMA } from "./rootConfigSchema";
4
+ export type RootConfig = FromSchema<typeof ROOT_CONFIG_JSON_SCHEMA>;
5
+ export type ResolvedRootConfig = {
6
+ defaults: {
7
+ parallelMax: number;
8
+ shell: ScriptShellOption;
9
+ /** `undefined` means the value was not set in the input config */
10
+ includeRootWorkspace: boolean | undefined;
11
+ };
12
+ };
13
+ export declare const validateRootConfig: (config: RootConfig) => void;
14
+ export declare const createDefaultRootConfig: () => ResolvedRootConfig;
15
+ export declare const resolveRootConfig: (
16
+ config: RootConfig,
17
+ ) => ResolvedRootConfig;
@@ -0,0 +1,43 @@
1
+ import validateRootConfig from "../../internal/generated/ajv/validateRootConfig.mjs";
2
+ import {
3
+ determineParallelMax,
4
+ resolveScriptShell,
5
+ } from "../../runScript/index.mjs";
6
+ import { getUserEnvVar } from "../userEnvVars/index.mjs";
7
+ import { executeValidator } from "../util/validateConfig.mjs";
8
+ import { ROOT_CONFIG_ERRORS } from "./errors.mjs"; // CONCATENATED MODULE: external "../../internal/generated/ajv/validateRootConfig.mjs"
9
+ // CONCATENATED MODULE: external "../../runScript/index.mjs"
10
+ // CONCATENATED MODULE: external "../userEnvVars/index.mjs"
11
+ // CONCATENATED MODULE: external "../util/validateConfig.mjs"
12
+ // CONCATENATED MODULE: external "./errors.mjs"
13
+ // CONCATENATED MODULE: ./src/config/rootConfig/rootConfig.ts
14
+
15
+ const rootConfig_validateRootConfig = (config) =>
16
+ executeValidator(
17
+ validateRootConfig,
18
+ "RootConfig",
19
+ config,
20
+ ROOT_CONFIG_ERRORS.InvalidRootConfig,
21
+ );
22
+ const createDefaultRootConfig = () => resolveRootConfig({});
23
+ const resolveRootConfig = (config) => {
24
+ rootConfig_validateRootConfig(config);
25
+ return {
26
+ defaults: {
27
+ parallelMax: determineParallelMax(
28
+ config.defaults?.parallelMax ?? "default",
29
+ " (set by root config)",
30
+ ),
31
+ shell: resolveScriptShell(config.defaults?.shell),
32
+ includeRootWorkspace:
33
+ config.defaults?.includeRootWorkspace ??
34
+ getUserEnvVar("includeRootWorkspaceDefault") === "true",
35
+ },
36
+ };
37
+ };
38
+
39
+ export {
40
+ createDefaultRootConfig,
41
+ resolveRootConfig,
42
+ rootConfig_validateRootConfig as validateRootConfig,
43
+ };
@@ -0,0 +1,2 @@
1
+ export declare const ROOT_CONFIG_FILE_NAME = "bw.root";
2
+ export declare const ROOT_CONFIG_PACKAGE_JSON_KEY = "bw-root";
@@ -0,0 +1,5 @@
1
+ // CONCATENATED MODULE: ./src/config/rootConfig/rootConfigLocation.ts
2
+ const ROOT_CONFIG_FILE_NAME = "bw.root";
3
+ const ROOT_CONFIG_PACKAGE_JSON_KEY = "bw-root";
4
+
5
+ export { ROOT_CONFIG_FILE_NAME, ROOT_CONFIG_PACKAGE_JSON_KEY };
@@ -0,0 +1,21 @@
1
+ export declare const ROOT_CONFIG_JSON_SCHEMA: {
2
+ readonly type: "object";
3
+ readonly additionalProperties: false;
4
+ readonly properties: {
5
+ readonly defaults: {
6
+ readonly type: "object";
7
+ readonly additionalProperties: false;
8
+ readonly properties: {
9
+ readonly parallelMax: {
10
+ readonly type: readonly ["number", "string"];
11
+ };
12
+ readonly shell: {
13
+ readonly type: "string";
14
+ };
15
+ readonly includeRootWorkspace: {
16
+ readonly type: "boolean";
17
+ };
18
+ };
19
+ };
20
+ };
21
+ };
@@ -0,0 +1,24 @@
1
+ // CONCATENATED MODULE: ./src/config/rootConfig/rootConfigSchema.ts
2
+ const ROOT_CONFIG_JSON_SCHEMA = {
3
+ type: "object",
4
+ additionalProperties: false,
5
+ properties: {
6
+ defaults: {
7
+ type: "object",
8
+ additionalProperties: false,
9
+ properties: {
10
+ parallelMax: {
11
+ type: ["number", "string"],
12
+ },
13
+ shell: {
14
+ type: "string",
15
+ },
16
+ includeRootWorkspace: {
17
+ type: "boolean",
18
+ },
19
+ },
20
+ },
21
+ },
22
+ };
23
+
24
+ export { ROOT_CONFIG_JSON_SCHEMA };
@@ -0,0 +1 @@
1
+ export * from "./userEnvVars";
@@ -0,0 +1 @@
1
+ export * from "./userEnvVars.mjs"; // CONCATENATED MODULE: ./src/config/userEnvVars/index.ts
@@ -0,0 +1,13 @@
1
+ export declare const USER_ENV_VARS: {
2
+ readonly parallelMaxDefault: "BW_PARALLEL_MAX_DEFAULT";
3
+ readonly scriptShellDefault: "BW_SHELL_DEFAULT";
4
+ readonly includeRootWorkspaceDefault: "BW_INCLUDE_ROOT_WORKSPACE_DEFAULT";
5
+ };
6
+ export type UserEnvVarName = keyof typeof USER_ENV_VARS;
7
+ export declare const getUserEnvVar: (key: UserEnvVarName) => string | undefined;
8
+ export declare const getUserEnvVarName: (
9
+ key: UserEnvVarName,
10
+ ) =>
11
+ | "BW_PARALLEL_MAX_DEFAULT"
12
+ | "BW_SHELL_DEFAULT"
13
+ | "BW_INCLUDE_ROOT_WORKSPACE_DEFAULT";
@@ -0,0 +1,10 @@
1
+ // CONCATENATED MODULE: ./src/config/userEnvVars/userEnvVars.ts
2
+ const USER_ENV_VARS = {
3
+ parallelMaxDefault: "BW_PARALLEL_MAX_DEFAULT",
4
+ scriptShellDefault: "BW_SHELL_DEFAULT",
5
+ includeRootWorkspaceDefault: "BW_INCLUDE_ROOT_WORKSPACE_DEFAULT",
6
+ };
7
+ const getUserEnvVar = (key) => process.env[USER_ENV_VARS[key]];
8
+ const getUserEnvVarName = (key) => USER_ENV_VARS[key];
9
+
10
+ export { USER_ENV_VARS, getUserEnvVar, getUserEnvVarName };
@@ -0,0 +1,10 @@
1
+ export type AjvJsonSchemaErrorObject = {
2
+ instancePath?: string;
3
+ schemaPath?: string;
4
+ keyword?: string;
5
+ params?: Record<string, unknown>;
6
+ message?: string;
7
+ };
8
+ export type AjvSchemaValidator<T = unknown> = ((data: unknown) => data is T) & {
9
+ errors?: AjvJsonSchemaErrorObject[] | null;
10
+ };
@@ -0,0 +1,2 @@
1
+ // CONCATENATED MODULE: ./src/config/util/ajvTypes.ts
2
+ // Types for AJV-generated JSON schema validators
@@ -0,0 +1,12 @@
1
+ export declare const CONFIG_LOCATION_TYPES: string[];
2
+ export type ConfigLocationType = (typeof CONFIG_LOCATION_TYPES)[number];
3
+ export type ConfigLocation = {
4
+ type: ConfigLocationType;
5
+ content: unknown;
6
+ path: string;
7
+ };
8
+ export declare const createConfigLocationPath: (
9
+ locationType: ConfigLocationType,
10
+ name: string,
11
+ packageJsonKey: string,
12
+ ) => string;
@@ -0,0 +1,11 @@
1
+ // CONCATENATED MODULE: ./src/config/util/configLocation.ts
2
+ const CONFIG_LOCATION_TYPES = ["jsoncFile", "jsonFile", "packageJson"];
3
+ const CONFIG_LOCATION_PATHS = {
4
+ jsoncFile: (name) => `${name}.jsonc`,
5
+ jsonFile: (name) => `${name}.json`,
6
+ packageJson: (_, packageJsonKey) => `package.json["${packageJsonKey}"]`,
7
+ };
8
+ const createConfigLocationPath = (locationType, name, packageJsonKey) =>
9
+ CONFIG_LOCATION_PATHS[locationType](name, packageJsonKey);
10
+
11
+ export { CONFIG_LOCATION_TYPES, createConfigLocationPath };
@@ -0,0 +1,4 @@
1
+ export type * from "./ajvTypes";
2
+ export * from "./loadConfig";
3
+ export * from "./validateConfig";
4
+ export * from "./configLocation";
@@ -0,0 +1,3 @@
1
+ export * from "./loadConfig.mjs";
2
+ export * from "./validateConfig.mjs";
3
+ export * from "./configLocation.mjs"; // CONCATENATED MODULE: ./src/config/util/index.ts