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.
- package/LICENSE.md +1 -1
- package/README.md +212 -19
- package/bin/cli.js +1 -1
- package/package.json +25 -9
- package/src/cli/commands/commandHandlerUtils.d.ts +45 -0
- package/src/cli/commands/commandHandlerUtils.mjs +81 -0
- package/src/cli/commands/commands.d.ts +10 -0
- package/src/cli/commands/commands.mjs +23 -0
- package/src/cli/commands/commandsConfig.d.ts +351 -0
- package/src/cli/commands/commandsConfig.mjs +183 -0
- package/src/cli/commands/handleSimpleCommands.d.ts +15 -0
- package/src/cli/commands/handleSimpleCommands.mjs +174 -0
- package/src/cli/commands/index.d.ts +3 -0
- package/src/cli/commands/index.mjs +3 -0
- package/src/cli/commands/runScript/handleRunScript.d.ts +3 -0
- package/src/cli/commands/runScript/handleRunScript.mjs +250 -0
- package/src/cli/commands/runScript/index.d.ts +2 -0
- package/src/cli/commands/runScript/index.mjs +2 -0
- package/src/cli/commands/runScript/output/index.d.ts +1 -0
- package/src/cli/commands/runScript/output/index.mjs +1 -0
- package/src/cli/commands/runScript/output/outputStyle.d.ts +8 -0
- package/src/cli/commands/runScript/output/outputStyle.mjs +17 -0
- package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +71 -0
- package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +307 -0
- package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +22 -0
- package/src/cli/commands/runScript/output/renderPlainOutput.mjs +43 -0
- package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +4 -0
- package/src/cli/commands/runScript/output/sanitizeChunk.mjs +101 -0
- package/src/cli/createCli.d.ts +14 -8
- package/src/cli/createCli.mjs +94 -39
- package/src/cli/fatalErrorLogger.d.ts +1 -0
- package/src/cli/fatalErrorLogger.mjs +7 -0
- package/src/cli/globalOptions/globalOptions.d.ts +38 -2
- package/src/cli/globalOptions/globalOptions.mjs +96 -47
- package/src/cli/globalOptions/globalOptionsConfig.d.ts +37 -31
- package/src/cli/globalOptions/globalOptionsConfig.mjs +32 -30
- package/src/cli/globalOptions/index.mjs +1 -1
- package/src/cli/index.d.ts +3 -1
- package/src/cli/index.mjs +3 -2
- package/src/config/index.d.ts +3 -2
- package/src/config/index.mjs +3 -3
- package/src/config/rootConfig/errors.d.ts +1 -0
- package/src/config/rootConfig/errors.mjs +6 -0
- package/src/config/rootConfig/index.d.ts +5 -0
- package/src/config/rootConfig/index.mjs +5 -0
- package/src/config/rootConfig/loadRootConfig.d.ts +3 -0
- package/src/config/rootConfig/loadRootConfig.mjs +22 -0
- package/src/config/rootConfig/rootConfig.d.ts +17 -0
- package/src/config/rootConfig/rootConfig.mjs +43 -0
- package/src/config/rootConfig/rootConfigLocation.d.ts +2 -0
- package/src/config/rootConfig/rootConfigLocation.mjs +5 -0
- package/src/config/rootConfig/rootConfigSchema.d.ts +21 -0
- package/src/config/rootConfig/rootConfigSchema.mjs +24 -0
- package/src/config/userEnvVars/index.d.ts +1 -0
- package/src/config/userEnvVars/index.mjs +1 -0
- package/src/config/userEnvVars/userEnvVars.d.ts +13 -0
- package/src/config/userEnvVars/userEnvVars.mjs +10 -0
- package/src/config/util/ajvTypes.d.ts +10 -0
- package/src/config/util/ajvTypes.mjs +2 -0
- package/src/config/util/configLocation.d.ts +12 -0
- package/src/config/util/configLocation.mjs +11 -0
- package/src/config/util/index.d.ts +4 -0
- package/src/config/util/index.mjs +3 -0
- package/src/config/util/loadConfig.d.ts +16 -0
- package/src/config/util/loadConfig.mjs +118 -0
- package/src/config/util/validateConfig.d.ts +8 -0
- package/src/config/util/validateConfig.mjs +17 -0
- package/src/config/workspaceConfig/errors.d.ts +1 -0
- package/src/config/workspaceConfig/errors.mjs +6 -0
- package/src/config/workspaceConfig/index.d.ts +5 -0
- package/src/config/workspaceConfig/index.mjs +5 -0
- package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +3 -0
- package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +25 -0
- package/src/config/workspaceConfig/workspaceConfig.d.ts +22 -0
- package/src/config/workspaceConfig/workspaceConfig.mjs +31 -0
- package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +2 -0
- package/src/config/workspaceConfig/workspaceConfigLocation.mjs +5 -0
- package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +25 -0
- package/src/config/workspaceConfig/workspaceConfigSchema.mjs +28 -0
- package/src/doctor/doctor.d.ts +35 -0
- package/src/doctor/doctor.mjs +52 -0
- package/src/doctor/index.d.ts +1 -0
- package/src/doctor/index.mjs +1 -0
- package/src/index.d.ts +37 -3
- package/src/index.mjs +16 -3
- package/src/internal/bun/bunLock.d.ts +20 -0
- package/src/internal/bun/bunLock.mjs +70 -0
- package/src/internal/bun/bunVersion.d.ts +21 -0
- package/src/internal/bun/bunVersion.mjs +43 -0
- package/src/internal/bun/index.d.ts +2 -0
- package/src/internal/bun/index.mjs +2 -0
- package/src/internal/core/error/error.d.ts +13 -0
- package/src/internal/core/error/error.mjs +36 -0
- package/src/internal/core/error/index.d.ts +1 -0
- package/src/internal/core/error/index.mjs +1 -0
- package/src/internal/core/index.d.ts +4 -0
- package/src/internal/core/index.mjs +4 -0
- package/src/internal/core/json/index.d.ts +2 -0
- package/src/internal/core/json/index.mjs +2 -0
- package/src/internal/core/json/json.d.ts +49 -0
- package/src/internal/core/json/json.mjs +12 -0
- package/src/internal/core/json/jsonc.d.ts +9 -0
- package/src/internal/core/json/jsonc.mjs +117 -0
- package/src/internal/core/language/array/index.d.ts +1 -0
- package/src/internal/core/language/array/index.mjs +1 -0
- package/src/internal/core/language/array/optionalArray.d.ts +15 -0
- package/src/internal/core/language/array/optionalArray.mjs +8 -0
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +16 -0
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +81 -0
- package/src/internal/core/language/asyncIterable/index.d.ts +2 -0
- package/src/internal/core/language/asyncIterable/index.mjs +2 -0
- package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +5 -0
- package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +27 -0
- package/src/internal/core/language/events/typedEventTarget.d.ts +50 -0
- package/src/internal/core/language/events/typedEventTarget.mjs +14 -0
- package/src/internal/core/language/index.d.ts +5 -0
- package/src/internal/core/language/index.mjs +5 -0
- package/src/internal/core/language/regex/index.d.ts +1 -0
- package/src/internal/core/language/regex/index.mjs +1 -0
- package/src/internal/{regex.d.ts → core/language/regex/regex.d.ts} +1 -0
- package/src/internal/core/language/regex/regex.mjs +10 -0
- package/src/internal/core/language/string/id.d.ts +1 -0
- package/src/internal/core/language/string/id.mjs +10 -0
- package/src/internal/core/language/string/index.d.ts +1 -0
- package/src/internal/core/language/string/index.mjs +1 -0
- package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +16 -0
- package/src/internal/core/language/string/utf/eastAsianWidth.mjs +326 -0
- package/src/internal/core/language/string/utf/visibleLength.d.ts +5 -0
- package/src/internal/core/language/string/utf/visibleLength.mjs +29 -0
- package/src/internal/core/language/types/index.d.ts +2 -0
- package/src/internal/core/language/types/index.mjs +1 -0
- package/src/internal/core/language/types/typeof.d.ts +102 -0
- package/src/internal/core/language/types/typeof.mjs +123 -0
- package/src/internal/core/language/types/types.d.ts +14 -0
- package/src/internal/core/language/types/types.mjs +2 -0
- package/src/internal/{env.d.ts → core/runtime/env.d.ts} +1 -0
- package/src/internal/core/runtime/env.mjs +36 -0
- package/src/internal/core/runtime/index.d.ts +5 -0
- package/src/internal/core/runtime/index.mjs +5 -0
- package/src/internal/core/runtime/onExit.d.ts +4 -0
- package/src/internal/core/runtime/onExit.mjs +54 -0
- package/src/internal/core/runtime/os.d.ts +4 -0
- package/src/internal/core/runtime/os.mjs +7 -0
- package/src/internal/core/runtime/tempFile.d.ts +20 -0
- package/src/internal/core/runtime/tempFile.mjs +87 -0
- package/src/internal/core/runtime/terminal.d.ts +1 -0
- package/src/internal/core/runtime/terminal.mjs +4 -0
- package/src/internal/generated/ajv/validateRootConfig.mjs +1 -0
- package/src/internal/generated/ajv/validateWorkspaceConfig.mjs +1 -0
- package/src/internal/logger/index.d.ts +1 -0
- package/src/internal/logger/index.mjs +1 -0
- package/src/internal/logger/logger.d.ts +39 -0
- package/src/internal/logger/logger.mjs +116 -0
- package/src/internal/version.d.ts +1 -0
- package/src/internal/version.mjs +6 -0
- package/src/project/errors.d.ts +5 -1
- package/src/project/errors.mjs +10 -3
- package/src/project/implementations/fileSystemProject.d.ts +148 -0
- package/src/project/implementations/fileSystemProject.mjs +455 -0
- package/src/project/implementations/memoryProject.d.ts +41 -0
- package/src/project/implementations/memoryProject.mjs +148 -0
- package/src/project/implementations/projectBase.d.ts +35 -0
- package/src/project/implementations/projectBase.mjs +197 -0
- package/src/project/index.d.ts +5 -1
- package/src/project/index.mjs +4 -2
- package/src/project/project.d.ts +72 -28
- package/src/project/project.mjs +6 -72
- package/src/runScript/index.d.ts +7 -0
- package/src/runScript/index.mjs +7 -0
- package/src/runScript/output/index.d.ts +3 -0
- package/src/runScript/output/index.mjs +2 -0
- package/src/runScript/output/multiProcessOutput.d.ts +14 -0
- package/src/runScript/output/multiProcessOutput.mjs +21 -0
- package/src/runScript/output/outputStream.d.ts +1 -0
- package/src/runScript/output/outputStream.mjs +1 -0
- package/src/runScript/output/processOutput.d.ts +33 -0
- package/src/runScript/output/processOutput.mjs +124 -0
- package/src/runScript/parallel.d.ts +15 -0
- package/src/runScript/parallel.mjs +56 -0
- package/src/runScript/recursion.d.ts +4 -0
- package/src/runScript/recursion.mjs +17 -0
- package/src/runScript/runScript.d.ts +45 -0
- package/src/runScript/runScript.mjs +89 -0
- package/src/runScript/runScripts.d.ts +65 -0
- package/src/runScript/runScripts.mjs +263 -0
- package/src/runScript/scriptCommand.d.ts +33 -0
- package/src/runScript/scriptCommand.mjs +19 -0
- package/src/runScript/scriptExecution.d.ts +9 -0
- package/src/runScript/scriptExecution.mjs +50 -0
- package/src/runScript/scriptRuntimeMetadata.d.ts +73 -0
- package/src/runScript/scriptRuntimeMetadata.mjs +61 -0
- package/src/runScript/scriptShellOption.d.ts +8 -0
- package/src/runScript/scriptShellOption.mjs +39 -0
- package/src/runScript/subprocesses.d.ts +11 -0
- package/src/runScript/subprocesses.mjs +34 -0
- package/src/workspaces/dependencyGraph/cycles.d.ts +9 -0
- package/src/workspaces/dependencyGraph/cycles.mjs +91 -0
- package/src/workspaces/dependencyGraph/index.d.ts +2 -0
- package/src/workspaces/dependencyGraph/index.mjs +2 -0
- package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +18 -0
- package/src/workspaces/dependencyGraph/resolveDependencies.mjs +52 -0
- package/src/workspaces/errors.d.ts +13 -1
- package/src/workspaces/errors.mjs +18 -3
- package/src/workspaces/findWorkspaces.d.ts +20 -13
- package/src/workspaces/findWorkspaces.mjs +208 -57
- package/src/workspaces/index.d.ts +4 -3
- package/src/workspaces/index.mjs +3 -2
- package/src/workspaces/packageJson.d.ts +28 -5
- package/src/workspaces/packageJson.mjs +177 -54
- package/src/workspaces/workspace.d.ts +19 -13
- package/src/workspaces/workspace.mjs +2 -0
- package/src/workspaces/workspacePattern.d.ts +21 -0
- package/src/workspaces/workspacePattern.mjs +104 -0
- package/src/cli/projectCommands/index.d.ts +0 -2
- package/src/cli/projectCommands/index.mjs +0 -2
- package/src/cli/projectCommands/projectCommandHandlers.d.ts +0 -8
- package/src/cli/projectCommands/projectCommandHandlers.mjs +0 -180
- package/src/cli/projectCommands/projectCommandsConfig.d.ts +0 -191
- package/src/cli/projectCommands/projectCommandsConfig.mjs +0 -100
- package/src/config/bunWorkspacesConfig.d.ts +0 -13
- package/src/config/bunWorkspacesConfig.mjs +0 -18
- package/src/config/configFile.d.ts +0 -3
- package/src/config/configFile.mjs +0 -21
- package/src/internal/bunVersion.d.ts +0 -14
- package/src/internal/bunVersion.mjs +0 -8
- package/src/internal/env.mjs +0 -15
- package/src/internal/error.d.ts +0 -7
- package/src/internal/error.mjs +0 -26
- package/src/internal/logger.d.ts +0 -21
- package/src/internal/logger.mjs +0 -85
- package/src/internal/regex.mjs +0 -3
- package/src/project/scriptCommand.d.ts +0 -15
- package/src/project/scriptCommand.mjs +0 -18
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
import { type Command } from "commander";
|
|
2
|
-
export declare const initializeWithGlobalOptions: (
|
|
3
|
-
|
|
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 {
|
|
4
|
-
import { logger } from "../../internal/logger.mjs";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
45
|
+
const getWorkingDirectoryFromArgs = (program, args, defaultCwd) => {
|
|
46
|
+
addGlobalOption(program, "cwd", defaultCwd);
|
|
47
|
+
program.parseOptions(args);
|
|
48
|
+
return program.opts().cwd;
|
|
16
49
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
project,
|
|
90
|
+
projectError: error,
|
|
91
|
+
};
|
|
44
92
|
};
|
|
45
|
-
const initializeWithGlobalOptions = (program, args, defaultCwd)=>{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
logLevel: LogLevelSetting;
|
|
4
|
+
cwd: string;
|
|
5
|
+
includeRoot: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface CliGlobalOptionConfig {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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: (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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)=>
|
|
32
|
-
|
|
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
|
package/src/cli/index.d.ts
CHANGED
package/src/cli/index.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export * from "./createCli.mjs";
|
|
2
|
+
export * from "./commands/index.mjs";
|
|
3
|
+
export * from "./globalOptions/index.mjs"; // CONCATENATED MODULE: ./src/cli/index.ts
|
package/src/config/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export * from "./workspaceConfig";
|
|
2
|
+
export * from "./rootConfig";
|
|
3
|
+
export * from "./util";
|
package/src/config/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
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,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,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,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 };
|