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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ScriptShellOption } from "./scriptShellOption";
|
|
2
|
+
export interface ScriptRuntimeMetadata {
|
|
3
|
+
projectPath: string;
|
|
4
|
+
projectName: string;
|
|
5
|
+
workspacePath: string;
|
|
6
|
+
workspaceRelativePath: string;
|
|
7
|
+
workspaceName: string;
|
|
8
|
+
scriptName: string;
|
|
9
|
+
}
|
|
10
|
+
declare const SCRIPT_RUNTIME_METADATA_CONFIG: {
|
|
11
|
+
readonly projectPath: {
|
|
12
|
+
readonly inlineName: "<projectPath>";
|
|
13
|
+
readonly envVarName: "BW_PROJECT_PATH";
|
|
14
|
+
};
|
|
15
|
+
readonly projectName: {
|
|
16
|
+
readonly inlineName: "<projectName>";
|
|
17
|
+
readonly envVarName: "BW_PROJECT_NAME";
|
|
18
|
+
};
|
|
19
|
+
readonly workspacePath: {
|
|
20
|
+
readonly inlineName: "<workspacePath>";
|
|
21
|
+
readonly envVarName: "BW_WORKSPACE_PATH";
|
|
22
|
+
};
|
|
23
|
+
readonly workspaceRelativePath: {
|
|
24
|
+
readonly inlineName: "<workspaceRelativePath>";
|
|
25
|
+
readonly envVarName: "BW_WORKSPACE_RELATIVE_PATH";
|
|
26
|
+
};
|
|
27
|
+
readonly scriptName: {
|
|
28
|
+
readonly inlineName: "<scriptName>";
|
|
29
|
+
readonly envVarName: "BW_SCRIPT_NAME";
|
|
30
|
+
};
|
|
31
|
+
readonly workspaceName: {
|
|
32
|
+
readonly inlineName: "<workspaceName>";
|
|
33
|
+
readonly envVarName: "BW_WORKSPACE_NAME";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type ScriptRuntimeMetadataKey =
|
|
37
|
+
keyof typeof SCRIPT_RUNTIME_METADATA_CONFIG;
|
|
38
|
+
export declare const getScriptRuntimeMetadataConfig: (
|
|
39
|
+
key: ScriptRuntimeMetadataKey,
|
|
40
|
+
) =>
|
|
41
|
+
| {
|
|
42
|
+
readonly inlineName: "<projectPath>";
|
|
43
|
+
readonly envVarName: "BW_PROJECT_PATH";
|
|
44
|
+
}
|
|
45
|
+
| {
|
|
46
|
+
readonly inlineName: "<projectName>";
|
|
47
|
+
readonly envVarName: "BW_PROJECT_NAME";
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
readonly inlineName: "<workspacePath>";
|
|
51
|
+
readonly envVarName: "BW_WORKSPACE_PATH";
|
|
52
|
+
}
|
|
53
|
+
| {
|
|
54
|
+
readonly inlineName: "<workspaceRelativePath>";
|
|
55
|
+
readonly envVarName: "BW_WORKSPACE_RELATIVE_PATH";
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
readonly inlineName: "<scriptName>";
|
|
59
|
+
readonly envVarName: "BW_SCRIPT_NAME";
|
|
60
|
+
}
|
|
61
|
+
| {
|
|
62
|
+
readonly inlineName: "<workspaceName>";
|
|
63
|
+
readonly envVarName: "BW_WORKSPACE_NAME";
|
|
64
|
+
};
|
|
65
|
+
export declare const createScriptRuntimeEnvVars: (
|
|
66
|
+
metadata: ScriptRuntimeMetadata,
|
|
67
|
+
) => Record<string, string>;
|
|
68
|
+
export declare const interpolateScriptRuntimeMetadata: (
|
|
69
|
+
text: string,
|
|
70
|
+
metadata: ScriptRuntimeMetadata,
|
|
71
|
+
shell: ScriptShellOption,
|
|
72
|
+
) => string;
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { IS_WINDOWS } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
|
|
2
|
+
// CONCATENATED MODULE: ./src/runScript/scriptRuntimeMetadata.ts
|
|
3
|
+
|
|
4
|
+
const SCRIPT_RUNTIME_METADATA_CONFIG = {
|
|
5
|
+
projectPath: {
|
|
6
|
+
inlineName: "<projectPath>",
|
|
7
|
+
envVarName: "BW_PROJECT_PATH",
|
|
8
|
+
},
|
|
9
|
+
projectName: {
|
|
10
|
+
inlineName: "<projectName>",
|
|
11
|
+
envVarName: "BW_PROJECT_NAME",
|
|
12
|
+
},
|
|
13
|
+
workspacePath: {
|
|
14
|
+
inlineName: "<workspacePath>",
|
|
15
|
+
envVarName: "BW_WORKSPACE_PATH",
|
|
16
|
+
},
|
|
17
|
+
workspaceRelativePath: {
|
|
18
|
+
inlineName: "<workspaceRelativePath>",
|
|
19
|
+
envVarName: "BW_WORKSPACE_RELATIVE_PATH",
|
|
20
|
+
},
|
|
21
|
+
scriptName: {
|
|
22
|
+
inlineName: "<scriptName>",
|
|
23
|
+
envVarName: "BW_SCRIPT_NAME",
|
|
24
|
+
},
|
|
25
|
+
workspaceName: {
|
|
26
|
+
inlineName: "<workspaceName>",
|
|
27
|
+
envVarName: "BW_WORKSPACE_NAME",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const getScriptRuntimeMetadataConfig = (key) =>
|
|
31
|
+
SCRIPT_RUNTIME_METADATA_CONFIG[key];
|
|
32
|
+
const createScriptRuntimeEnvVars = (metadata) =>
|
|
33
|
+
Object.entries(SCRIPT_RUNTIME_METADATA_CONFIG).reduce((acc, [key, value]) => {
|
|
34
|
+
acc[value.envVarName] = metadata[key];
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
37
|
+
const interpolateScriptRuntimeMetadata = (text, metadata, shell) =>
|
|
38
|
+
text.replace(
|
|
39
|
+
new RegExp(
|
|
40
|
+
Object.values(SCRIPT_RUNTIME_METADATA_CONFIG)
|
|
41
|
+
.flatMap((value) => value.inlineName)
|
|
42
|
+
.join("|"),
|
|
43
|
+
"g",
|
|
44
|
+
),
|
|
45
|
+
(match) => {
|
|
46
|
+
const key = Object.entries(SCRIPT_RUNTIME_METADATA_CONFIG).find(
|
|
47
|
+
([_, value]) => value.inlineName === match,
|
|
48
|
+
)?.[0];
|
|
49
|
+
const value = metadata[key];
|
|
50
|
+
if (IS_WINDOWS && shell === "bun") {
|
|
51
|
+
return value.replace(/\\/g, "\\\\");
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
createScriptRuntimeEnvVars,
|
|
59
|
+
getScriptRuntimeMetadataConfig,
|
|
60
|
+
interpolateScriptRuntimeMetadata,
|
|
61
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const SCRIPT_SHELL_OPTIONS: readonly ["bun", "system"];
|
|
2
|
+
export type ScriptShellOption = (typeof SCRIPT_SHELL_OPTIONS)[number];
|
|
3
|
+
export declare const validateScriptShellOption: (
|
|
4
|
+
shell: string,
|
|
5
|
+
fromEnvVar?: boolean,
|
|
6
|
+
) => ScriptShellOption;
|
|
7
|
+
export declare const getScriptShellDefault: () => "bun" | "system";
|
|
8
|
+
export declare const resolveScriptShell: (shell?: string) => ScriptShellOption;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getUserEnvVar,
|
|
3
|
+
getUserEnvVarName,
|
|
4
|
+
} from "../config/userEnvVars/index.mjs";
|
|
5
|
+
import { BunWorkspacesError } from "../internal/core/error/index.mjs"; // CONCATENATED MODULE: external "../config/userEnvVars/index.mjs"
|
|
6
|
+
// CONCATENATED MODULE: external "../internal/core/error/index.mjs"
|
|
7
|
+
// CONCATENATED MODULE: ./src/runScript/scriptShellOption.ts
|
|
8
|
+
|
|
9
|
+
const SCRIPT_SHELL_OPTIONS = ["bun", "system"];
|
|
10
|
+
const validateScriptShellOption = (shell, fromEnvVar = false) => {
|
|
11
|
+
if (!SCRIPT_SHELL_OPTIONS.includes(shell)) {
|
|
12
|
+
throw new BunWorkspacesError(
|
|
13
|
+
`Invalid shell option: ${shell} (accepted values: ${SCRIPT_SHELL_OPTIONS.join(", ")})${fromEnvVar ? ` (set by env var ${getUserEnvVarName("scriptShellDefault")})` : ""}`,
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return shell;
|
|
17
|
+
};
|
|
18
|
+
const getScriptShellDefault = () => {
|
|
19
|
+
const shell = getUserEnvVar("scriptShellDefault");
|
|
20
|
+
return shell ? validateScriptShellOption(shell, true) : "bun";
|
|
21
|
+
};
|
|
22
|
+
const resolveScriptShell = (shell) => {
|
|
23
|
+
if (
|
|
24
|
+
!shell ||
|
|
25
|
+
shell === "default" ||
|
|
26
|
+
shell === "undefined" ||
|
|
27
|
+
shell === "null"
|
|
28
|
+
) {
|
|
29
|
+
return getScriptShellDefault();
|
|
30
|
+
}
|
|
31
|
+
return validateScriptShellOption(shell);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
SCRIPT_SHELL_OPTIONS,
|
|
36
|
+
getScriptShellDefault,
|
|
37
|
+
resolveScriptShell,
|
|
38
|
+
validateScriptShellOption,
|
|
39
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**Essentially a wrapper around `Bun.spawn` that ensures all
|
|
2
|
+
* the subprocess is killed when the main process exits for any
|
|
3
|
+
* handle-able exit code or signal. */
|
|
4
|
+
export declare const createSubprocess: <
|
|
5
|
+
In extends Bun.SpawnOptions.Writable,
|
|
6
|
+
Out extends Bun.SpawnOptions.Readable,
|
|
7
|
+
Err extends Bun.SpawnOptions.Readable,
|
|
8
|
+
>(
|
|
9
|
+
argv: string[],
|
|
10
|
+
options: Bun.Spawn.SpawnOptions<In, Out, Err>,
|
|
11
|
+
) => Bun.Subprocess<In, Out, Err>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IS_WINDOWS, runOnExit } from "../internal/core/index.mjs";
|
|
2
|
+
import { logger } from "../internal/logger/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
|
|
3
|
+
// CONCATENATED MODULE: external "../internal/logger/index.mjs"
|
|
4
|
+
// CONCATENATED MODULE: ./src/runScript/subprocesses.ts
|
|
5
|
+
|
|
6
|
+
const SUBPROCESS_REGISTRY = {};
|
|
7
|
+
runOnExit((codeOrSignal) => {
|
|
8
|
+
Object.values(SUBPROCESS_REGISTRY).forEach((subprocess) => {
|
|
9
|
+
/**
|
|
10
|
+
* @todo Windows support for killing subprocesses is needed.
|
|
11
|
+
* subprocess.kill() will throw with not-implemented error
|
|
12
|
+
*/ if (!subprocess.killed && subprocess.exitCode === null && !IS_WINDOWS) {
|
|
13
|
+
logger.debug(
|
|
14
|
+
`Killing subprocess ${subprocess.pid} with signal ${codeOrSignal}`,
|
|
15
|
+
);
|
|
16
|
+
subprocess.kill(codeOrSignal);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
/**Essentially a wrapper around `Bun.spawn` that ensures all
|
|
21
|
+
* the subprocess is killed when the main process exits for any
|
|
22
|
+
* handle-able exit code or signal. */ const createSubprocess = (
|
|
23
|
+
argv,
|
|
24
|
+
options,
|
|
25
|
+
) => {
|
|
26
|
+
const subprocess = Bun.spawn(argv, options);
|
|
27
|
+
SUBPROCESS_REGISTRY[subprocess.pid] = subprocess;
|
|
28
|
+
subprocess.exited.finally(() => {
|
|
29
|
+
delete SUBPROCESS_REGISTRY[subprocess.pid];
|
|
30
|
+
});
|
|
31
|
+
return subprocess;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { createSubprocess };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Workspace } from "../workspace";
|
|
2
|
+
export type DependencyCycleEdge = {
|
|
3
|
+
dependency: string;
|
|
4
|
+
dependent: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const preventDependencyCycles: (workspaces: Workspace[]) => {
|
|
7
|
+
workspaces: Workspace[];
|
|
8
|
+
cycles: DependencyCycleEdge[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// CONCATENATED MODULE: ./src/workspaces/dependencyGraph/cycles.ts
|
|
2
|
+
const preventDependencyCycles = (workspaces) => {
|
|
3
|
+
const byName = new Map(workspaces.map((n) => [n.name, n]));
|
|
4
|
+
// memo: name -> chains that end at `name`
|
|
5
|
+
const memo = new Map();
|
|
6
|
+
// recursion stack in order (root -> ... -> current)
|
|
7
|
+
const stack = [];
|
|
8
|
+
const inStack = new Set();
|
|
9
|
+
// dedupe cycle edges
|
|
10
|
+
const cyclesKeyed = new Map();
|
|
11
|
+
// all nodes that participate in at least one cycle
|
|
12
|
+
const cycleNodeSet = new Set();
|
|
13
|
+
const recordCycleEdge = (dependency, dependent) => {
|
|
14
|
+
const key = `${dependency}\u0000${dependent}`;
|
|
15
|
+
if (!cyclesKeyed.has(key))
|
|
16
|
+
cyclesKeyed.set(key, {
|
|
17
|
+
dependency,
|
|
18
|
+
dependent,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const chainsTo = (name) => {
|
|
22
|
+
const cached = memo.get(name);
|
|
23
|
+
if (cached) return cached;
|
|
24
|
+
stack.push(name);
|
|
25
|
+
inStack.add(name);
|
|
26
|
+
const node = byName.get(name);
|
|
27
|
+
const deps = node?.dependencies ?? [];
|
|
28
|
+
const result = [];
|
|
29
|
+
if (deps.length === 0) {
|
|
30
|
+
memo.set(name, result);
|
|
31
|
+
inStack.delete(name);
|
|
32
|
+
stack.pop();
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
for (const dep of deps) {
|
|
36
|
+
// Cycle edge: current `name` depends on `dep`, and `dep` is already in the active stack
|
|
37
|
+
if (inStack.has(dep)) {
|
|
38
|
+
recordCycleEdge(dep, name);
|
|
39
|
+
// Mark every node between `dep` and `name` (inclusive) as a cycle participant.
|
|
40
|
+
// `name` is already at stack[stack.length - 1] since it was pushed above.
|
|
41
|
+
const depIndex = stack.indexOf(dep);
|
|
42
|
+
for (let i = depIndex; i < stack.length; i++)
|
|
43
|
+
cycleNodeSet.add(stack[i]);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// Missing dependency name: treat as a leaf chain [dep, name]
|
|
47
|
+
if (!byName.has(dep)) {
|
|
48
|
+
result.push([dep, name]);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const depChains = chainsTo(dep);
|
|
52
|
+
if (depChains.length === 0) {
|
|
53
|
+
// dep is a leaf => base chain
|
|
54
|
+
result.push([dep, name]);
|
|
55
|
+
} else {
|
|
56
|
+
// extend each dep chain with current dependent
|
|
57
|
+
for (const c of depChains) result.push([...c, name]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
memo.set(name, result);
|
|
61
|
+
inStack.delete(name);
|
|
62
|
+
stack.pop();
|
|
63
|
+
return result;
|
|
64
|
+
};
|
|
65
|
+
workspaces.forEach((workspace) => {
|
|
66
|
+
chainsTo(workspace.name);
|
|
67
|
+
});
|
|
68
|
+
workspaces = workspaces.map((workspace) => ({
|
|
69
|
+
...workspace,
|
|
70
|
+
}));
|
|
71
|
+
const cycles = [...cyclesKeyed.values()];
|
|
72
|
+
// Remove all dependency/dependent edges between workspaces that share a cycle.
|
|
73
|
+
// This leaves no opinionated "winner": if two workspaces are in the same cycle,
|
|
74
|
+
// all edges between them are stripped.
|
|
75
|
+
for (const workspace of workspaces) {
|
|
76
|
+
if (cycleNodeSet.has(workspace.name)) {
|
|
77
|
+
workspace.dependencies = workspace.dependencies.filter(
|
|
78
|
+
(d) => !cycleNodeSet.has(d),
|
|
79
|
+
);
|
|
80
|
+
workspace.dependents = workspace.dependents.filter(
|
|
81
|
+
(d) => !cycleNodeSet.has(d),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
workspaces,
|
|
87
|
+
cycles,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export { preventDependencyCycles };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ResolvedWorkspaceConfig } from "../../config";
|
|
2
|
+
import {
|
|
3
|
+
type BunCatalogSet,
|
|
4
|
+
type ResolvedPackageJsonContent,
|
|
5
|
+
} from "../packageJson";
|
|
6
|
+
import type { Workspace } from "../workspace";
|
|
7
|
+
export type WorkspaceMap = {
|
|
8
|
+
[workspaceName: string]: {
|
|
9
|
+
workspace: Workspace;
|
|
10
|
+
config: ResolvedWorkspaceConfig;
|
|
11
|
+
packageJson: ResolvedPackageJsonContent;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const resolveWorkspaceDependencies: (
|
|
15
|
+
workspaceMap: WorkspaceMap,
|
|
16
|
+
includeRootWorkspace: boolean,
|
|
17
|
+
catalogs?: BunCatalogSet,
|
|
18
|
+
) => Workspace[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolveCatalogDependencyVersion } from "../packageJson.mjs"; // CONCATENATED MODULE: external "../packageJson.mjs"
|
|
2
|
+
// CONCATENATED MODULE: ./src/workspaces/dependencyGraph/resolveDependencies.ts
|
|
3
|
+
|
|
4
|
+
const resolveWorkspaceDependencies = (
|
|
5
|
+
workspaceMap,
|
|
6
|
+
includeRootWorkspace,
|
|
7
|
+
catalogs,
|
|
8
|
+
) => {
|
|
9
|
+
const workspacePackages = Object.values(workspaceMap).filter(
|
|
10
|
+
({ workspace }) => includeRootWorkspace || !workspace.isRoot,
|
|
11
|
+
);
|
|
12
|
+
const workspacesWithDependencies = workspacePackages.map(
|
|
13
|
+
({ workspace, packageJson }) => {
|
|
14
|
+
for (const dependencyMap of [
|
|
15
|
+
packageJson.dependencies,
|
|
16
|
+
packageJson.devDependencies,
|
|
17
|
+
packageJson.peerDependencies,
|
|
18
|
+
packageJson.optionalDependencies,
|
|
19
|
+
]) {
|
|
20
|
+
for (const [dependencyName, dependencyVersion] of Object.entries(
|
|
21
|
+
dependencyMap,
|
|
22
|
+
)) {
|
|
23
|
+
const resolvedVersion =
|
|
24
|
+
catalogs && dependencyVersion.startsWith("catalog:")
|
|
25
|
+
? (resolveCatalogDependencyVersion(
|
|
26
|
+
dependencyName,
|
|
27
|
+
dependencyVersion,
|
|
28
|
+
catalogs,
|
|
29
|
+
) ?? dependencyVersion)
|
|
30
|
+
: dependencyVersion;
|
|
31
|
+
if (
|
|
32
|
+
resolvedVersion.startsWith("workspace:") &&
|
|
33
|
+
workspaceMap[dependencyName]
|
|
34
|
+
) {
|
|
35
|
+
workspace.dependencies.push(dependencyName);
|
|
36
|
+
workspaceMap[dependencyName].workspace.dependents.push(
|
|
37
|
+
workspace.name,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return workspace;
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
return workspacesWithDependencies.map((workspace) => {
|
|
46
|
+
workspace.dependencies = [...new Set(workspace.dependencies)].sort();
|
|
47
|
+
workspace.dependents = [...new Set(workspace.dependents)].sort();
|
|
48
|
+
return workspace;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { resolveWorkspaceDependencies };
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const WORKSPACE_ERRORS: import("../internal/core").DefinedErrors<
|
|
2
|
+
| "PackageNotFound"
|
|
3
|
+
| "InvalidPackageJson"
|
|
4
|
+
| "DuplicateWorkspaceName"
|
|
5
|
+
| "InvalidWorkspaceName"
|
|
6
|
+
| "NoWorkspaceName"
|
|
7
|
+
| "InvalidScripts"
|
|
8
|
+
| "InvalidWorkspaces"
|
|
9
|
+
| "InvalidWorkspacePattern"
|
|
10
|
+
| "AliasConflict"
|
|
11
|
+
| "AliasedWorkspaceNotFound"
|
|
12
|
+
| "RootWorkspaceNotFound"
|
|
13
|
+
>;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
import { defineErrors } from "../internal/
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { defineErrors } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
|
|
2
|
+
// CONCATENATED MODULE: ./src/workspaces/errors.ts
|
|
3
|
+
|
|
4
|
+
const WORKSPACE_ERRORS = defineErrors(
|
|
5
|
+
"PackageNotFound",
|
|
6
|
+
"InvalidPackageJson",
|
|
7
|
+
"DuplicateWorkspaceName",
|
|
8
|
+
"InvalidWorkspaceName",
|
|
9
|
+
"NoWorkspaceName",
|
|
10
|
+
"InvalidScripts",
|
|
11
|
+
"InvalidWorkspaces",
|
|
12
|
+
"InvalidWorkspacePattern",
|
|
13
|
+
"AliasConflict",
|
|
14
|
+
"AliasedWorkspaceNotFound",
|
|
15
|
+
"RootWorkspaceNotFound",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export { WORKSPACE_ERRORS };
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type WorkspaceMap } from "./dependencyGraph/resolveDependencies";
|
|
2
2
|
import type { Workspace } from "./workspace";
|
|
3
3
|
export interface FindWorkspacesOptions {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
rootDirectory: string;
|
|
5
|
+
/** If provided, will override the workspaces found in the package.json. Mainly for testing purposes */
|
|
6
|
+
workspaceGlobs?: string[];
|
|
7
|
+
/** Whether to include the root workspace as a normal workspace.*/
|
|
8
|
+
includeRootWorkspace?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
export declare const sortWorkspaces: (workspaces: Workspace[]) => Workspace[];
|
|
11
|
+
export declare const findWorkspaces: ({
|
|
12
|
+
rootDirectory,
|
|
13
|
+
workspaceGlobs: _workspaceGlobs,
|
|
14
|
+
includeRootWorkspace,
|
|
15
|
+
}: FindWorkspacesOptions) => {
|
|
16
|
+
workspaces: Workspace[];
|
|
17
|
+
workspaceMap: WorkspaceMap;
|
|
18
|
+
rootWorkspace: Workspace;
|
|
17
19
|
};
|
|
20
|
+
export declare const validateWorkspaceAliases: (
|
|
21
|
+
workspaces: Workspace[],
|
|
22
|
+
workspaceAliases: Record<string, string>,
|
|
23
|
+
rootWorkspaceName: string,
|
|
24
|
+
) => void;
|