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.
- package/README.md +96 -2
- package/bin/cli.js +0 -0
- package/package.json +1 -5
- package/src/1108.mjs +30 -0
- package/src/{cli/commands/commandsConfig.mjs → 2392.mjs} +52 -11
- package/src/4427.mjs +9 -0
- package/src/5166.mjs +8 -0
- package/src/8126.mjs +4 -0
- package/src/8257.mjs +4 -0
- package/src/{config/util/configLocation.mjs → 8529.mjs} +11 -2
- package/src/ai/mcp/bwMcpServer.mjs +299 -9
- package/src/ai/mcp/core/index.mjs +3 -1
- package/src/ai/mcp/core/server.mjs +1 -3
- package/src/ai/mcp/core/transport.mjs +1 -2
- package/src/ai/mcp/core/types.mjs +0 -1
- package/src/ai/mcp/index.mjs +3 -1
- package/src/ai/mcp/resources.mjs +1 -2
- package/src/ai/mcp/tools.mjs +1 -5
- package/src/cli/commands/commandHandlerUtils.mjs +2 -6
- package/src/cli/commands/commands.mjs +1 -4
- package/src/cli/commands/handleSimpleCommands.mjs +4 -10
- package/src/cli/commands/index.mjs +11 -2
- package/src/cli/commands/mcp.mjs +1 -4
- package/src/cli/commands/runScript/handleRunScript.mjs +1 -9
- package/src/cli/commands/runScript/index.mjs +3 -1
- package/src/cli/commands/runScript/output/index.mjs +3 -1
- package/src/cli/commands/runScript/output/outputStyle.mjs +1 -3
- package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +1 -6
- package/src/cli/commands/runScript/output/renderPlainOutput.mjs +1 -2
- package/src/cli/commands/runScript/output/sanitizeChunk.mjs +0 -1
- package/src/cli/createCli.mjs +2 -12
- package/src/cli/fatalErrorLogger.mjs +1 -2
- package/src/cli/globalOptions/globalOptions.mjs +2 -9
- package/src/cli/globalOptions/index.mjs +3 -2
- package/src/cli/index.d.ts +1085 -3
- package/src/cli/index.mjs +3 -1
- package/src/cli/middleware.mjs +1 -3
- package/src/config/index.mjs +3 -1
- package/src/config/public.d.ts +151 -10
- package/src/config/public.mjs +4 -6
- package/src/config/rootConfig/defineRootConfig.mjs +1 -2
- package/src/config/rootConfig/errors.mjs +1 -2
- package/src/config/rootConfig/index.mjs +3 -1
- package/src/config/rootConfig/loadRootConfig.mjs +1 -4
- package/src/config/rootConfig/mergeRootConfig.mjs +24 -0
- package/src/config/rootConfig/rootConfig.mjs +8 -6
- package/src/config/rootConfig/rootConfigSchema.mjs +19 -1
- package/src/config/userEnvVars/index.mjs +3 -1
- package/src/config/userEnvVars/userEnvVars.mjs +3 -8
- package/src/config/util/ajvTypes.mjs +2 -1
- package/src/config/util/index.mjs +2 -1
- package/src/config/util/loadConfig.mjs +1 -6
- package/src/config/util/validateConfig.mjs +0 -1
- package/src/config/workspaceConfig/defineWorkspaceConfig.mjs +1 -2
- package/src/config/workspaceConfig/errors.mjs +1 -2
- package/src/config/workspaceConfig/index.mjs +3 -1
- package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +2 -8
- package/src/config/workspaceConfig/mergeWorkspaceConfig.mjs +75 -0
- package/src/config/workspaceConfig/workspaceConfig.mjs +1 -13
- package/src/config/workspaceConfig/workspaceConfigSchema.mjs +0 -1
- package/src/doctor/doctor.mjs +1 -5
- package/src/doctor/index.mjs +3 -1
- package/src/index.d.ts +516 -38
- package/src/index.mjs +4 -13
- package/src/internal/bun/bunLock.mjs +2 -4
- package/src/internal/bun/bunVersion.mjs +1 -3
- package/src/internal/bun/index.mjs +3 -1
- package/src/internal/bundledDeps/commander.mjs +3843 -0
- package/src/internal/bundledDeps/shellQuote.mjs +291 -0
- package/src/internal/core/error/error.mjs +0 -1
- package/src/internal/core/error/index.mjs +3 -1
- package/src/internal/core/index.mjs +3 -1
- package/src/internal/core/json/index.mjs +3 -1
- package/src/internal/core/json/json.mjs +3 -5
- package/src/internal/core/json/jsonc.mjs +0 -1
- package/src/internal/core/language/array/index.mjs +3 -1
- package/src/internal/core/language/array/optionalArray.mjs +0 -1
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +0 -1
- package/src/internal/core/language/asyncIterable/index.mjs +3 -1
- package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +0 -1
- package/src/internal/core/language/events/typedEventTarget.mjs +0 -1
- package/src/internal/core/language/index.mjs +3 -1
- package/src/internal/core/language/regex/index.mjs +3 -1
- package/src/internal/core/language/regex/regex.mjs +0 -1
- package/src/internal/core/language/string/id.mjs +0 -1
- package/src/internal/core/language/string/index.mjs +3 -1
- package/src/internal/core/language/string/utf/eastAsianWidth.mjs +0 -1
- package/src/internal/core/language/string/utf/visibleLength.mjs +1 -2
- package/src/internal/core/language/types/index.mjs +3 -1
- package/src/internal/core/language/types/typeof.mjs +1 -3
- package/src/internal/core/language/types/types.mjs +3 -2
- package/src/internal/core/runtime/env.mjs +0 -1
- package/src/internal/core/runtime/index.mjs +3 -1
- package/src/internal/core/runtime/onExit.mjs +1 -2
- package/src/internal/core/runtime/os.mjs +1 -3
- package/src/internal/core/runtime/tempFile.mjs +1 -9
- package/src/internal/core/runtime/terminal.mjs +0 -1
- package/src/internal/generated/aiDocs/.gitkeep.mjs +1 -0
- package/src/internal/generated/aiDocs/docs.mjs +92 -15
- package/src/internal/generated/ajv/validateRootConfig.mjs +1 -1
- package/src/internal/logger/index.mjs +3 -1
- package/src/internal/logger/logger.mjs +4 -14
- package/src/internal/version.mjs +1 -2
- package/src/project/errors.mjs +1 -2
- package/src/project/implementations/fileSystemProject.mjs +4 -18
- package/src/project/implementations/memoryProject.mjs +1 -5
- package/src/project/implementations/projectBase.mjs +10 -19
- package/src/project/index.mjs +3 -1
- package/src/project/project.mjs +2 -1
- package/src/rslib-runtime.mjs +62 -0
- package/src/runScript/index.mjs +3 -1
- package/src/runScript/output/index.mjs +3 -1
- package/src/runScript/output/multiProcessOutput.mjs +1 -2
- package/src/runScript/output/outputStream.mjs +1 -1
- package/src/runScript/output/processOutput.mjs +1 -2
- package/src/runScript/parallel.mjs +4 -10
- package/src/runScript/recursion.mjs +1 -2
- package/src/runScript/runScript.mjs +1 -4
- package/src/runScript/runScripts.mjs +1 -6
- package/src/runScript/scriptCommand.mjs +1 -2
- package/src/runScript/scriptExecution.mjs +1 -3
- package/src/runScript/scriptRuntimeMetadata.mjs +38 -56
- package/src/runScript/scriptShellOption.mjs +5 -14
- package/src/runScript/subprocesses.mjs +1 -3
- package/src/workspaces/applyWorkspacePatternConfigs.mjs +58 -0
- package/src/workspaces/dependencyGraph/cycles.mjs +0 -1
- package/src/workspaces/dependencyGraph/index.mjs +3 -1
- package/src/workspaces/dependencyGraph/resolveDependencies.mjs +1 -2
- package/src/workspaces/dependencyGraph/validateDependencyRules.mjs +12 -13
- package/src/workspaces/errors.mjs +1 -2
- package/src/workspaces/findWorkspaces.mjs +11 -11
- package/src/workspaces/index.mjs +3 -1
- package/src/workspaces/packageJson.mjs +2 -7
- package/src/workspaces/workspace.mjs +2 -1
- package/src/workspaces/workspacePattern.mjs +4 -4
- package/src/ai/mcp/bwMcpServer.d.ts +0 -4
- package/src/ai/mcp/core/index.d.ts +0 -3
- package/src/ai/mcp/core/server.d.ts +0 -14
- package/src/ai/mcp/core/transport.d.ts +0 -12
- package/src/ai/mcp/core/types.d.ts +0 -104
- package/src/ai/mcp/index.d.ts +0 -2
- package/src/ai/mcp/resources.d.ts +0 -6
- package/src/ai/mcp/tools.d.ts +0 -6
- package/src/cli/commands/commandHandlerUtils.d.ts +0 -51
- package/src/cli/commands/commands.d.ts +0 -10
- package/src/cli/commands/commandsConfig.d.ts +0 -436
- package/src/cli/commands/handleSimpleCommands.d.ts +0 -21
- package/src/cli/commands/index.d.ts +0 -4
- package/src/cli/commands/mcp.d.ts +0 -3
- package/src/cli/commands/runScript/handleRunScript.d.ts +0 -3
- package/src/cli/commands/runScript/index.d.ts +0 -2
- package/src/cli/commands/runScript/output/index.d.ts +0 -1
- package/src/cli/commands/runScript/output/outputStyle.d.ts +0 -9
- package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +0 -75
- package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +0 -24
- package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +0 -4
- package/src/cli/createCli.d.ts +0 -26
- package/src/cli/fatalErrorLogger.d.ts +0 -1
- package/src/cli/globalOptions/globalOptions.d.ts +0 -43
- package/src/cli/globalOptions/globalOptionsConfig.d.ts +0 -52
- package/src/cli/globalOptions/globalOptionsConfig.mjs +0 -43
- package/src/cli/globalOptions/index.d.ts +0 -2
- package/src/cli/middleware.d.ts +0 -83
- package/src/config/index.d.ts +0 -3
- package/src/config/rootConfig/defineRootConfig.d.ts +0 -4
- package/src/config/rootConfig/errors.d.ts +0 -1
- package/src/config/rootConfig/index.d.ts +0 -5
- package/src/config/rootConfig/loadRootConfig.d.ts +0 -3
- package/src/config/rootConfig/rootConfig.d.ts +0 -25
- package/src/config/rootConfig/rootConfigLocation.d.ts +0 -2
- package/src/config/rootConfig/rootConfigLocation.mjs +0 -5
- package/src/config/rootConfig/rootConfigSchema.d.ts +0 -21
- package/src/config/userEnvVars/index.d.ts +0 -1
- package/src/config/userEnvVars/userEnvVars.d.ts +0 -13
- package/src/config/util/ajvTypes.d.ts +0 -10
- package/src/config/util/configLocation.d.ts +0 -18
- package/src/config/util/index.d.ts +0 -4
- package/src/config/util/loadConfig.d.ts +0 -18
- package/src/config/util/validateConfig.d.ts +0 -8
- package/src/config/workspaceConfig/defineWorkspaceConfig.d.ts +0 -7
- package/src/config/workspaceConfig/errors.d.ts +0 -1
- package/src/config/workspaceConfig/index.d.ts +0 -5
- package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +0 -3
- package/src/config/workspaceConfig/workspaceConfig.d.ts +0 -56
- package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +0 -2
- package/src/config/workspaceConfig/workspaceConfigLocation.mjs +0 -5
- package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +0 -56
- package/src/doctor/doctor.d.ts +0 -35
- package/src/doctor/index.d.ts +0 -1
- package/src/internal/bun/bunLock.d.ts +0 -20
- package/src/internal/bun/bunVersion.d.ts +0 -21
- package/src/internal/bun/index.d.ts +0 -2
- package/src/internal/core/error/error.d.ts +0 -13
- package/src/internal/core/error/index.d.ts +0 -1
- package/src/internal/core/index.d.ts +0 -4
- package/src/internal/core/json/index.d.ts +0 -2
- package/src/internal/core/json/json.d.ts +0 -49
- package/src/internal/core/json/jsonc.d.ts +0 -9
- package/src/internal/core/language/array/index.d.ts +0 -1
- package/src/internal/core/language/array/optionalArray.d.ts +0 -15
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +0 -16
- package/src/internal/core/language/asyncIterable/index.d.ts +0 -2
- package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +0 -5
- package/src/internal/core/language/events/typedEventTarget.d.ts +0 -50
- package/src/internal/core/language/index.d.ts +0 -5
- package/src/internal/core/language/regex/index.d.ts +0 -1
- package/src/internal/core/language/regex/regex.d.ts +0 -3
- package/src/internal/core/language/string/id.d.ts +0 -1
- package/src/internal/core/language/string/index.d.ts +0 -1
- package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +0 -16
- package/src/internal/core/language/string/utf/visibleLength.d.ts +0 -5
- package/src/internal/core/language/types/index.d.ts +0 -2
- package/src/internal/core/language/types/typeof.d.ts +0 -102
- package/src/internal/core/language/types/types.d.ts +0 -19
- package/src/internal/core/runtime/env.d.ts +0 -6
- package/src/internal/core/runtime/index.d.ts +0 -5
- package/src/internal/core/runtime/onExit.d.ts +0 -4
- package/src/internal/core/runtime/os.d.ts +0 -6
- package/src/internal/core/runtime/tempFile.d.ts +0 -20
- package/src/internal/core/runtime/terminal.d.ts +0 -1
- package/src/internal/docs/apiQuickstart.d.ts +0 -3
- package/src/internal/docs/apiQuickstart.mjs +0 -132
- package/src/internal/docs/cliQuickstart.d.ts +0 -2
- package/src/internal/docs/cliQuickstart.mjs +0 -86
- package/src/internal/docs/index.d.ts +0 -2
- package/src/internal/docs/index.mjs +0 -2
- package/src/internal/generated/aiDocs/docs.d.ts +0 -10
- package/src/internal/logger/index.d.ts +0 -1
- package/src/internal/logger/logger.d.ts +0 -45
- package/src/internal/version.d.ts +0 -1
- package/src/project/errors.d.ts +0 -5
- package/src/project/implementations/fileSystemProject.d.ts +0 -148
- package/src/project/implementations/memoryProject.d.ts +0 -41
- package/src/project/implementations/projectBase.d.ts +0 -37
- package/src/project/index.d.ts +0 -5
- package/src/project/project.d.ts +0 -79
- package/src/runScript/index.d.ts +0 -7
- package/src/runScript/output/index.d.ts +0 -3
- package/src/runScript/output/multiProcessOutput.d.ts +0 -14
- package/src/runScript/output/outputStream.d.ts +0 -1
- package/src/runScript/output/processOutput.d.ts +0 -33
- package/src/runScript/parallel.d.ts +0 -24
- package/src/runScript/recursion.d.ts +0 -4
- package/src/runScript/runScript.d.ts +0 -45
- package/src/runScript/runScripts.d.ts +0 -65
- package/src/runScript/scriptCommand.d.ts +0 -33
- package/src/runScript/scriptExecution.d.ts +0 -9
- package/src/runScript/scriptRuntimeMetadata.d.ts +0 -73
- package/src/runScript/scriptShellOption.d.ts +0 -8
- package/src/runScript/subprocesses.d.ts +0 -11
- package/src/workspaces/dependencyGraph/cycles.d.ts +0 -9
- package/src/workspaces/dependencyGraph/index.d.ts +0 -3
- package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +0 -18
- package/src/workspaces/dependencyGraph/validateDependencyRules.d.ts +0 -7
- package/src/workspaces/errors.d.ts +0 -14
- package/src/workspaces/findWorkspaces.d.ts +0 -24
- package/src/workspaces/index.d.ts +0 -4
- package/src/workspaces/packageJson.d.ts +0 -31
- package/src/workspaces/workspace.d.ts +0 -21
- package/src/workspaces/workspacePattern.d.ts +0 -22
package/src/cli/index.mjs
CHANGED
package/src/cli/middleware.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { defineErrors } from "../internal/core/index.mjs";
|
|
2
|
-
import { logger } from "../internal/logger/index.mjs";
|
|
3
|
-
// CONCATENATED MODULE: external "../internal/logger/index.mjs"
|
|
4
|
-
// CONCATENATED MODULE: ./src/cli/middleware.ts
|
|
2
|
+
import { logger } from "../internal/logger/index.mjs";
|
|
5
3
|
|
|
6
4
|
const MIDDLEWARE_ERRORS = defineErrors("MiddlewareHandlerFailed");
|
|
7
5
|
const resolveMiddleware = (defaultMiddleware, runMiddleware) =>
|
package/src/config/index.mjs
CHANGED
package/src/config/public.d.ts
CHANGED
|
@@ -1,10 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
declare const SCRIPT_SHELL_OPTIONS: readonly ["bun", "system"];
|
|
4
|
+
export type ScriptShellOption = (typeof SCRIPT_SHELL_OPTIONS)[number];
|
|
5
|
+
export type ShellOption = ScriptShellOption | "default";
|
|
6
|
+
declare const PARALLEL_MAX_VALUES: readonly ["auto", "unbounded", "default"];
|
|
7
|
+
export type PercentageValue = `${number}%`;
|
|
8
|
+
/**
|
|
9
|
+
* The maximum number of scripts that can run in parallel.
|
|
10
|
+
*
|
|
11
|
+
* - `number`: The exact number of scripts that can run in parallel.
|
|
12
|
+
* - `"auto"`: The number of available logical CPU threads.
|
|
13
|
+
* - `"unbounded"`: No limit.
|
|
14
|
+
* - `"default"`: The default value, either "auto" or the value of the root config's "parallelMax" option.
|
|
15
|
+
* - `"${number}%"`: A percentage of the available logical CPU threads (e.g. "50%").
|
|
16
|
+
*/
|
|
17
|
+
export type ParallelMaxValue =
|
|
18
|
+
| number
|
|
19
|
+
| (typeof PARALLEL_MAX_VALUES)[number]
|
|
20
|
+
| PercentageValue;
|
|
21
|
+
export type WorkspaceDependenciesRule = {
|
|
22
|
+
/**
|
|
23
|
+
* Workspace patterns that are permitted as dependencies.
|
|
24
|
+
* Only workspaces matching these patterns are allowed.
|
|
25
|
+
* When combined with `denyPatterns`, the deny list further
|
|
26
|
+
* filters this allowed subset.
|
|
27
|
+
*/
|
|
28
|
+
allowPatterns?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Workspace patterns that are forbidden as dependencies.
|
|
31
|
+
* When combined with `allowPatterns`, this further filters
|
|
32
|
+
* the subset of allowed workspaces.
|
|
33
|
+
*/
|
|
34
|
+
denyPatterns?: string[];
|
|
35
|
+
};
|
|
36
|
+
export type WorkspaceRules = {
|
|
37
|
+
workspaceDependencies?: WorkspaceDependenciesRule;
|
|
38
|
+
};
|
|
39
|
+
/** Configuration that applies to a specific package.json script */
|
|
40
|
+
export type ScriptConfig = {
|
|
41
|
+
/**
|
|
42
|
+
* The order in which the script should be executed.
|
|
43
|
+
*
|
|
44
|
+
* Scripts with no `order` set will be executed in alphanumerical order
|
|
45
|
+
* of their relative path from the project root.
|
|
46
|
+
*/
|
|
47
|
+
order?: number;
|
|
48
|
+
};
|
|
49
|
+
/** Configuration that applies to a specific workspace */
|
|
50
|
+
export type WorkspaceConfig = {
|
|
51
|
+
/**
|
|
52
|
+
* An alias or list of aliases for the workspace.
|
|
53
|
+
*
|
|
54
|
+
* These must be unique to other workspaces' aliases
|
|
55
|
+
* and package.json names.
|
|
56
|
+
*/
|
|
57
|
+
alias?: string | string[];
|
|
58
|
+
/**
|
|
59
|
+
* Tags for the workspace.
|
|
60
|
+
*
|
|
61
|
+
* These can be used to group workspaces by a common tag.
|
|
62
|
+
*/
|
|
63
|
+
tags?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Configuration that maps to a script name in the workspace's package.json.
|
|
66
|
+
*/
|
|
67
|
+
scripts?: Record<string, ScriptConfig>;
|
|
68
|
+
/**
|
|
69
|
+
* Rules that validate the workspace.
|
|
70
|
+
*/
|
|
71
|
+
rules?: WorkspaceRules;
|
|
72
|
+
};
|
|
73
|
+
export type ResolvedWorkspaceConfig = {
|
|
74
|
+
aliases: string[];
|
|
75
|
+
tags: string[];
|
|
76
|
+
scripts: Record<string, ScriptConfig>;
|
|
77
|
+
rules: WorkspaceRules;
|
|
78
|
+
};
|
|
79
|
+
/** Static workspace context passed to a {@link WorkspacePatternConfigFactory}.
|
|
80
|
+
* Contains only the immutable, package.json-derived fields — not config-derived fields like aliases or tags. */
|
|
81
|
+
export type RawWorkspace = {
|
|
82
|
+
name: string;
|
|
83
|
+
isRoot: boolean;
|
|
84
|
+
path: string;
|
|
85
|
+
matchPattern: string;
|
|
86
|
+
scripts: string[];
|
|
87
|
+
dependencies: string[];
|
|
88
|
+
dependents: string[];
|
|
89
|
+
};
|
|
90
|
+
/** A factory that returns a {@link WorkspaceConfig} to merge for a matched workspace.
|
|
91
|
+
* Receives the static workspace context and the workspace's accumulated resolved config at that point. */
|
|
92
|
+
export type WorkspacePatternConfigFactory = (
|
|
93
|
+
workspace: RawWorkspace,
|
|
94
|
+
prevConfig: ResolvedWorkspaceConfig,
|
|
95
|
+
) => WorkspaceConfig;
|
|
96
|
+
/** A single entry in {@link RootConfig.workspacePatternConfigs} */
|
|
97
|
+
export type WorkspacePatternConfigEntry = {
|
|
98
|
+
/** Workspace patterns to match. Supports all workspace pattern specifiers (name, alias, tag, path, not:). */
|
|
99
|
+
patterns: string[];
|
|
100
|
+
/** Config to merge into all matching workspaces. May be a factory receiving the workspace context and accumulated config. */
|
|
101
|
+
config: WorkspaceConfig | WorkspacePatternConfigFactory;
|
|
102
|
+
};
|
|
103
|
+
export type RootConfig = {
|
|
104
|
+
defaults?: {
|
|
105
|
+
/** The maximum number of scripts that can run in parallel. (default: "auto") */
|
|
106
|
+
parallelMax?: ParallelMaxValue;
|
|
107
|
+
/** The shell to use for inline scripts. (default: "bun") */
|
|
108
|
+
shell?: ShellOption;
|
|
109
|
+
/** Whether to include the root workspace in the workspaces list by default. (default: false) */
|
|
110
|
+
includeRootWorkspace?: boolean;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Workspace configs applied by pattern, in order, merging left to right,
|
|
114
|
+
* using any workspaces' local configs as the starting config.
|
|
115
|
+
* Each entry's config is merged into all workspaces matching its patterns.
|
|
116
|
+
* Pattern matching reflects accumulated aliases and tags from previous entries.
|
|
117
|
+
* Factory functions are only supported in TypeScript/JavaScript config files.
|
|
118
|
+
*/
|
|
119
|
+
workspacePatternConfigs?: WorkspacePatternConfigEntry[];
|
|
120
|
+
};
|
|
121
|
+
export type ResolvedRootConfig = {
|
|
122
|
+
defaults: {
|
|
123
|
+
parallelMax: number;
|
|
124
|
+
shell: ScriptShellOption;
|
|
125
|
+
/** `undefined` means the value was not set in the input config */
|
|
126
|
+
includeRootWorkspace: boolean | undefined;
|
|
127
|
+
};
|
|
128
|
+
workspacePatternConfigs: WorkspacePatternConfigEntry[];
|
|
129
|
+
};
|
|
130
|
+
export declare const defineRootConfig: (
|
|
131
|
+
config: RootConfig,
|
|
132
|
+
) => ResolvedRootConfig;
|
|
133
|
+
export type RootConfigFactory = (prev: RootConfig) => RootConfig;
|
|
134
|
+
export type RootConfigInput = RootConfig | RootConfigFactory;
|
|
135
|
+
/** Merge two or more root configs left to right, with each subsequent config taking precedence.
|
|
136
|
+
* Any argument may be a factory function receiving the accumulated config up to that point. */
|
|
137
|
+
export declare const mergeRootConfig: (
|
|
138
|
+
...configs: RootConfigInput[]
|
|
139
|
+
) => RootConfig;
|
|
140
|
+
export declare const defineWorkspaceConfig: (
|
|
141
|
+
config: WorkspaceConfig,
|
|
142
|
+
) => ResolvedWorkspaceConfig;
|
|
143
|
+
export type WorkspaceConfigFactory = (prev: WorkspaceConfig) => WorkspaceConfig;
|
|
144
|
+
export type WorkspaceConfigInput = WorkspaceConfig | WorkspaceConfigFactory;
|
|
145
|
+
/** Merge two or more workspace configs left to right, with each subsequent config taking precedence.
|
|
146
|
+
* Any argument may be a factory function receiving the accumulated config up to that point. */
|
|
147
|
+
export declare const mergeWorkspaceConfig: (
|
|
148
|
+
...configs: WorkspaceConfigInput[]
|
|
149
|
+
) => WorkspaceConfig;
|
|
150
|
+
|
|
151
|
+
export {};
|
package/src/config/public.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { defineRootConfig, defineWorkspaceConfig };
|
|
1
|
+
export { defineRootConfig } from "./rootConfig/defineRootConfig.mjs";
|
|
2
|
+
export { mergeRootConfig } from "./rootConfig/mergeRootConfig.mjs";
|
|
3
|
+
export { defineWorkspaceConfig } from "./workspaceConfig/defineWorkspaceConfig.mjs";
|
|
4
|
+
export { mergeWorkspaceConfig } from "./workspaceConfig/mergeWorkspaceConfig.mjs";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { resolveRootConfig } from "./rootConfig.mjs";
|
|
2
|
-
// CONCATENATED MODULE: ./src/config/rootConfig/defineRootConfig.ts
|
|
1
|
+
import { resolveRootConfig } from "./rootConfig.mjs";
|
|
3
2
|
|
|
4
3
|
const defineRootConfig = (config) => resolveRootConfig(config);
|
|
5
4
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { defineErrors } from "../../internal/core/index.mjs";
|
|
2
|
-
// CONCATENATED MODULE: ./src/config/rootConfig/errors.ts
|
|
1
|
+
import { defineErrors } from "../../internal/core/index.mjs";
|
|
3
2
|
|
|
4
3
|
const ROOT_CONFIG_ERRORS = defineErrors("InvalidRootConfig");
|
|
5
4
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./rootConfigSchema.mjs";
|
|
2
2
|
export * from "./rootConfig.mjs";
|
|
3
3
|
export * from "./loadRootConfig.mjs";
|
|
4
|
+
export * from "./mergeRootConfig.mjs";
|
|
4
5
|
export * from "./errors.mjs";
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
export {};
|
|
@@ -3,10 +3,7 @@ import { createDefaultRootConfig, resolveRootConfig } from "./rootConfig.mjs";
|
|
|
3
3
|
import {
|
|
4
4
|
ROOT_CONFIG_FILE_NAME,
|
|
5
5
|
ROOT_CONFIG_PACKAGE_JSON_KEY,
|
|
6
|
-
} from "
|
|
7
|
-
// CONCATENATED MODULE: external "./rootConfig.mjs"
|
|
8
|
-
// CONCATENATED MODULE: external "./rootConfigLocation.mjs"
|
|
9
|
-
// CONCATENATED MODULE: ./src/config/rootConfig/loadRootConfig.ts
|
|
6
|
+
} from "../../8529.mjs";
|
|
10
7
|
|
|
11
8
|
const loadRootConfig = (rootDirectory) => {
|
|
12
9
|
const config = loadConfig(
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Merge two or more root configs left to right, with each subsequent config taking precedence.
|
|
2
|
+
* Any argument may be a factory function receiving the accumulated config up to that point. */ const mergeRootConfig =
|
|
3
|
+
(...configs) =>
|
|
4
|
+
configs.reduce((acc, configOrFactory) => {
|
|
5
|
+
const config =
|
|
6
|
+
typeof configOrFactory === "function"
|
|
7
|
+
? configOrFactory(acc)
|
|
8
|
+
: configOrFactory;
|
|
9
|
+
const mergedPatternConfigs = [
|
|
10
|
+
...(acc.workspacePatternConfigs ?? []),
|
|
11
|
+
...(config.workspacePatternConfigs ?? []),
|
|
12
|
+
];
|
|
13
|
+
return {
|
|
14
|
+
defaults: {
|
|
15
|
+
...acc.defaults,
|
|
16
|
+
...config.defaults,
|
|
17
|
+
},
|
|
18
|
+
...(mergedPatternConfigs.length > 0 && {
|
|
19
|
+
workspacePatternConfigs: mergedPatternConfigs,
|
|
20
|
+
}),
|
|
21
|
+
};
|
|
22
|
+
}, {});
|
|
23
|
+
|
|
24
|
+
export { mergeRootConfig };
|
|
@@ -5,12 +5,8 @@ import {
|
|
|
5
5
|
} from "../../runScript/index.mjs";
|
|
6
6
|
import { getUserEnvVar } from "../userEnvVars/index.mjs";
|
|
7
7
|
import { executeValidator } from "../util/validateConfig.mjs";
|
|
8
|
-
import {
|
|
9
|
-
|
|
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
|
|
8
|
+
import { validateWorkspaceConfig } from "../workspaceConfig/workspaceConfig.mjs";
|
|
9
|
+
import { ROOT_CONFIG_ERRORS } from "./errors.mjs";
|
|
14
10
|
|
|
15
11
|
const rootConfig_validateRootConfig = (config) =>
|
|
16
12
|
executeValidator(
|
|
@@ -22,6 +18,11 @@ const rootConfig_validateRootConfig = (config) =>
|
|
|
22
18
|
const createDefaultRootConfig = () => resolveRootConfig({});
|
|
23
19
|
const resolveRootConfig = (config) => {
|
|
24
20
|
rootConfig_validateRootConfig(config);
|
|
21
|
+
for (const entry of config.workspacePatternConfigs ?? []) {
|
|
22
|
+
if (typeof entry.config !== "function") {
|
|
23
|
+
validateWorkspaceConfig(entry.config);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
25
26
|
return {
|
|
26
27
|
defaults: {
|
|
27
28
|
parallelMax: determineParallelMax(
|
|
@@ -33,6 +34,7 @@ const resolveRootConfig = (config) => {
|
|
|
33
34
|
config.defaults?.includeRootWorkspace ??
|
|
34
35
|
getUserEnvVar("includeRootWorkspaceDefault") === "true",
|
|
35
36
|
},
|
|
37
|
+
workspacePatternConfigs: config.workspacePatternConfigs ?? [],
|
|
36
38
|
};
|
|
37
39
|
};
|
|
38
40
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// CONCATENATED MODULE: ./src/config/rootConfig/rootConfigSchema.ts
|
|
2
1
|
const ROOT_CONFIG_JSON_SCHEMA = {
|
|
3
2
|
type: "object",
|
|
4
3
|
additionalProperties: false,
|
|
@@ -18,6 +17,25 @@ const ROOT_CONFIG_JSON_SCHEMA = {
|
|
|
18
17
|
},
|
|
19
18
|
},
|
|
20
19
|
},
|
|
20
|
+
workspacePatternConfigs: {
|
|
21
|
+
type: "array",
|
|
22
|
+
items: {
|
|
23
|
+
type: "object",
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
required: ["patterns", "config"],
|
|
26
|
+
properties: {
|
|
27
|
+
patterns: {
|
|
28
|
+
type: "array",
|
|
29
|
+
items: {
|
|
30
|
+
type: "string",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
// config may be a WorkspaceConfig object or a factory function (TS/JS configs only).
|
|
34
|
+
// Object form is validated separately via validateWorkspaceConfig after AJV.
|
|
35
|
+
config: {},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
21
39
|
},
|
|
22
40
|
};
|
|
23
41
|
let _validateSchemaType;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
parallelMaxDefault: "BW_PARALLEL_MAX_DEFAULT",
|
|
4
|
-
scriptShellDefault: "BW_SHELL_DEFAULT",
|
|
5
|
-
includeRootWorkspaceDefault: "BW_INCLUDE_ROOT_WORKSPACE_DEFAULT",
|
|
6
|
-
};
|
|
1
|
+
import { USER_ENV_VARS } from "../../5166.mjs";
|
|
2
|
+
|
|
7
3
|
const getUserEnvVar = (key) => process.env[USER_ENV_VARS[key]];
|
|
8
|
-
const getUserEnvVarName = (key) => USER_ENV_VARS[key];
|
|
9
4
|
|
|
10
|
-
export {
|
|
5
|
+
export { getUserEnvVar };
|
|
@@ -5,12 +5,7 @@ import { logger } from "../../internal/logger/index.mjs";
|
|
|
5
5
|
import {
|
|
6
6
|
CONFIG_LOCATION_TYPES,
|
|
7
7
|
createConfigLocationPath,
|
|
8
|
-
} from "
|
|
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
|
|
8
|
+
} from "../../8529.mjs";
|
|
14
9
|
|
|
15
10
|
const LOAD_CONFIG_ERRORS = defineErrors(
|
|
16
11
|
"InvalidJSON",
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { resolveWorkspaceConfig } from "./workspaceConfig.mjs";
|
|
2
|
-
// CONCATENATED MODULE: ./src/config/workspaceConfig/defineWorkspaceConfig.ts
|
|
1
|
+
import { resolveWorkspaceConfig } from "./workspaceConfig.mjs";
|
|
3
2
|
|
|
4
3
|
const defineWorkspaceConfig = (config) => {
|
|
5
4
|
if (Array.isArray(config.aliases)) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { defineErrors } from "../../internal/core/index.mjs";
|
|
2
|
-
// CONCATENATED MODULE: ./src/config/workspaceConfig/errors.ts
|
|
1
|
+
import { defineErrors } from "../../internal/core/index.mjs";
|
|
3
2
|
|
|
4
3
|
const WORKSPACE_CONFIG_ERRORS = defineErrors("InvalidWorkspaceConfig");
|
|
5
4
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./workspaceConfigSchema.mjs";
|
|
2
2
|
export * from "./workspaceConfig.mjs";
|
|
3
3
|
export * from "./loadWorkspaceConfig.mjs";
|
|
4
|
+
export * from "./mergeWorkspaceConfig.mjs";
|
|
4
5
|
export * from "./errors.mjs";
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
export {};
|
|
@@ -3,20 +3,14 @@ import {
|
|
|
3
3
|
createDefaultWorkspaceConfig,
|
|
4
4
|
resolveWorkspaceConfig,
|
|
5
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
|
|
6
|
+
import { WORKSPACE_CONFIG_FILE_NAME } from "../../8529.mjs";
|
|
13
7
|
|
|
14
8
|
const loadWorkspaceConfig = (workspacePath) => {
|
|
15
9
|
const config = loadConfig(
|
|
16
10
|
"workspace",
|
|
17
11
|
workspacePath,
|
|
18
12
|
WORKSPACE_CONFIG_FILE_NAME,
|
|
19
|
-
WORKSPACE_CONFIG_PACKAGE_JSON_KEY,
|
|
13
|
+
/* inlined export .WORKSPACE_CONFIG_PACKAGE_JSON_KEY */ "bw",
|
|
20
14
|
(content) => resolveWorkspaceConfig(content),
|
|
21
15
|
);
|
|
22
16
|
return config ?? createDefaultWorkspaceConfig();
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { resolveOptionalArray } from "../../internal/core/index.mjs";
|
|
2
|
+
|
|
3
|
+
const uniqueArray = (arr) => [...new Set(arr)];
|
|
4
|
+
const concatPatterns = (a, b) => {
|
|
5
|
+
if (!a?.length && !b?.length) return undefined;
|
|
6
|
+
return uniqueArray([...(a ?? []), ...(b ?? [])]);
|
|
7
|
+
};
|
|
8
|
+
const mergeWorkspaceDependenciesRule = (base, override) => {
|
|
9
|
+
if (!base && !override) return undefined;
|
|
10
|
+
const allowPatterns = concatPatterns(
|
|
11
|
+
base?.allowPatterns,
|
|
12
|
+
override?.allowPatterns,
|
|
13
|
+
);
|
|
14
|
+
const denyPatterns = concatPatterns(
|
|
15
|
+
base?.denyPatterns,
|
|
16
|
+
override?.denyPatterns,
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
...(allowPatterns && {
|
|
20
|
+
allowPatterns,
|
|
21
|
+
}),
|
|
22
|
+
...(denyPatterns && {
|
|
23
|
+
denyPatterns,
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const mergeWorkspaceRules = (base, override) => {
|
|
28
|
+
const workspaceDependencies = mergeWorkspaceDependenciesRule(
|
|
29
|
+
base?.workspaceDependencies,
|
|
30
|
+
override?.workspaceDependencies,
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
...(workspaceDependencies && {
|
|
34
|
+
workspaceDependencies,
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const mergeScripts = (base, override) => {
|
|
39
|
+
if (!base && !override) return {};
|
|
40
|
+
if (!base) return override ?? {};
|
|
41
|
+
if (!override) return base;
|
|
42
|
+
const merged = {
|
|
43
|
+
...base,
|
|
44
|
+
};
|
|
45
|
+
for (const [key, value] of Object.entries(override)) {
|
|
46
|
+
merged[key] = base[key]
|
|
47
|
+
? {
|
|
48
|
+
...base[key],
|
|
49
|
+
...value,
|
|
50
|
+
}
|
|
51
|
+
: value;
|
|
52
|
+
}
|
|
53
|
+
return merged;
|
|
54
|
+
};
|
|
55
|
+
const applyConfig = (acc, config) => ({
|
|
56
|
+
alias: uniqueArray([
|
|
57
|
+
...resolveOptionalArray(acc.alias ?? []),
|
|
58
|
+
...resolveOptionalArray(config.alias ?? []),
|
|
59
|
+
]),
|
|
60
|
+
tags: uniqueArray([...(acc.tags ?? []), ...(config.tags ?? [])]),
|
|
61
|
+
scripts: mergeScripts(acc.scripts, config.scripts),
|
|
62
|
+
rules: mergeWorkspaceRules(acc.rules, config.rules),
|
|
63
|
+
});
|
|
64
|
+
/** Merge two or more workspace configs left to right, with each subsequent config taking precedence.
|
|
65
|
+
* Any argument may be a factory function receiving the accumulated config up to that point. */ const mergeWorkspaceConfig =
|
|
66
|
+
(...configs) =>
|
|
67
|
+
configs.reduce((acc, configOrFactory) => {
|
|
68
|
+
const config =
|
|
69
|
+
typeof configOrFactory === "function"
|
|
70
|
+
? configOrFactory(acc)
|
|
71
|
+
: configOrFactory;
|
|
72
|
+
return applyConfig(acc, config);
|
|
73
|
+
}, {});
|
|
74
|
+
|
|
75
|
+
export { mergeWorkspaceConfig };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { resolveOptionalArray } from "../../internal/core/index.mjs";
|
|
2
2
|
import validateWorkspaceConfig from "../../internal/generated/ajv/validateWorkspaceConfig.mjs";
|
|
3
3
|
import { executeValidator } from "../util/validateConfig.mjs";
|
|
4
|
-
import { WORKSPACE_CONFIG_ERRORS } from "./errors.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
|
|
4
|
+
import { WORKSPACE_CONFIG_ERRORS } from "./errors.mjs";
|
|
9
5
|
|
|
10
6
|
const validate = validateWorkspaceConfig;
|
|
11
7
|
const workspaceConfig_validateWorkspaceConfig = (config) => {
|
|
@@ -17,14 +13,6 @@ const workspaceConfig_validateWorkspaceConfig = (config) => {
|
|
|
17
13
|
},
|
|
18
14
|
WORKSPACE_CONFIG_ERRORS.InvalidWorkspaceConfig,
|
|
19
15
|
);
|
|
20
|
-
if (
|
|
21
|
-
config.rules?.workspaceDependencies?.allowPatterns &&
|
|
22
|
-
config.rules?.workspaceDependencies?.denyPatterns
|
|
23
|
-
) {
|
|
24
|
-
throw new WORKSPACE_CONFIG_ERRORS.InvalidWorkspaceConfig(
|
|
25
|
-
"Cannot use both allowPatterns and denyPatterns in workspaceDependencies rule",
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
16
|
};
|
|
29
17
|
const resolveWorkspaceConfig = (config) => {
|
|
30
18
|
if (Array.isArray(config.aliases)) {
|
package/src/doctor/doctor.mjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import package_0 from "../../package.json";
|
|
5
|
-
// CONCATENATED MODULE: external "os"
|
|
6
|
-
// CONCATENATED MODULE: external "path"
|
|
7
|
-
// CONCATENATED MODULE: external "../../package.json"
|
|
8
|
-
// CONCATENATED MODULE: ./src/doctor/doctor.ts
|
|
4
|
+
import package_0 from "../../package.json";
|
|
9
5
|
|
|
10
6
|
const getBinaryInfo = () => {
|
|
11
7
|
const argv = process.argv.slice(0);
|
package/src/doctor/index.mjs
CHANGED