bun-workspaces 1.0.0-alpha.40 → 1.0.0-alpha.42
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 +4 -2
- package/package.json +1 -1
- package/src/cli/commands/commandsConfig.d.ts +2 -2
- package/src/cli/commands/commandsConfig.mjs +1 -1
- package/src/cli/commands/runScript/handleRunScript.mjs +5 -7
- package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +2 -2
- package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +3 -3
- package/src/cli/createCli.mjs +1 -22
- package/src/cli/globalOptions/globalOptions.mjs +8 -31
- package/src/cli/globalOptions/globalOptionsConfig.d.ts +0 -9
- package/src/cli/globalOptions/globalOptionsConfig.mjs +0 -8
- package/src/config/index.d.ts +0 -7
- package/src/config/index.mjs +1 -11
- package/src/index.d.ts +1 -3
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +1 -0
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +8 -0
- package/src/project/implementations/fileSystemProject.d.ts +18 -28
- package/src/project/implementations/fileSystemProject.mjs +5 -33
- package/src/runScript/index.d.ts +1 -1
- package/src/runScript/index.mjs +1 -1
- package/src/runScript/output/index.d.ts +3 -0
- package/src/runScript/output/index.mjs +2 -0
- package/src/runScript/output/outputStream.d.ts +1 -0
- package/src/runScript/output/outputStream.mjs +1 -0
- package/src/runScript/runScript.d.ts +2 -6
- package/src/runScript/runScript.mjs +6 -13
- package/src/runScript/runScripts.d.ts +2 -15
- package/src/runScript/runScripts.mjs +30 -46
- package/src/runScript/scriptRuntimeMetadata.d.ts +12 -14
- package/src/runScript/scriptRuntimeMetadata.mjs +7 -8
- package/src/workspaces/findWorkspaces.d.ts +1 -5
- package/src/workspaces/findWorkspaces.mjs +1 -1
- package/src/config/bunWorkspacesConfig.d.ts +0 -17
- package/src/config/bunWorkspacesConfig.mjs +0 -50
- package/src/config/configFile.d.ts +0 -8
- package/src/config/configFile.mjs +0 -43
- package/src/config/errors.d.ts +0 -3
- package/src/config/errors.mjs +0 -10
- package/src/runScript/outputChunk.d.ts +0 -24
- package/src/runScript/outputChunk.mjs +0 -30
package/README.md
CHANGED
|
@@ -79,8 +79,10 @@ bw run lint --args="--my-arg=<workspaceName>" # Use the workspace name in args
|
|
|
79
79
|
|
|
80
80
|
bw run "bun build" --inline # Run an inline command via the Bun shell
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
# Scripts run in parallel by default
|
|
83
|
+
bw run lint --parallel=false # Run in series
|
|
83
84
|
bw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts
|
|
85
|
+
bw run lint --parallel=auto # Default, based on number of available logical CPUs
|
|
84
86
|
|
|
85
87
|
# Use the grouped output style (default when on a TTY)
|
|
86
88
|
bw run my-script --output-style=grouped
|
|
@@ -172,7 +174,7 @@ const runManyScripts = async () => {
|
|
|
172
174
|
// Optional. Arguments to add to the command
|
|
173
175
|
args: "--my --appended --args",
|
|
174
176
|
|
|
175
|
-
// Optional. Whether to run the scripts in parallel
|
|
177
|
+
// Optional. Whether to run the scripts in parallel (default: true)
|
|
176
178
|
parallel: true,
|
|
177
179
|
|
|
178
180
|
// Optional. When true, a workspace's script will wait
|
package/package.json
CHANGED
|
@@ -140,7 +140,7 @@ export declare const CLI_COMMANDS_CONFIG: {
|
|
|
140
140
|
};
|
|
141
141
|
readonly parallel: {
|
|
142
142
|
readonly flags: ["-P", "--parallel [max]"];
|
|
143
|
-
readonly description:
|
|
143
|
+
readonly description: 'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"';
|
|
144
144
|
};
|
|
145
145
|
readonly args: {
|
|
146
146
|
readonly flags: ["-a", "--args <args>"];
|
|
@@ -301,7 +301,7 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
|
|
|
301
301
|
};
|
|
302
302
|
readonly parallel: {
|
|
303
303
|
readonly flags: ["-P", "--parallel [max]"];
|
|
304
|
-
readonly description:
|
|
304
|
+
readonly description: 'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"';
|
|
305
305
|
};
|
|
306
306
|
readonly args: {
|
|
307
307
|
readonly flags: ["-a", "--args <args>"];
|
|
@@ -120,7 +120,7 @@ const CLI_COMMANDS_CONFIG = {
|
|
|
120
120
|
parallel: {
|
|
121
121
|
flags: ["-P", "--parallel [max]"],
|
|
122
122
|
description:
|
|
123
|
-
|
|
123
|
+
'Run the scripts in parallel. Pass "false" for series, or a concurrency limit as a number, percentage ("50%"), "auto", "default", or"unbounded"',
|
|
124
124
|
},
|
|
125
125
|
args: {
|
|
126
126
|
flags: ["-a", "--args <args>"],
|
|
@@ -67,13 +67,8 @@ const runScript = handleProjectCommand(
|
|
|
67
67
|
`Command: Run ${options.inline ? "inline " : ""}script ${JSON.stringify(script)} for ${workspacePatterns.length ? "workspaces " + workspacePatterns.join(", ") : "all workspaces"}`,
|
|
68
68
|
);
|
|
69
69
|
logger.debug(`Options: ${JSON.stringify(options)}`);
|
|
70
|
-
const workspaces = workspacePatterns.length
|
|
71
|
-
? project.findWorkspacesByPattern(...workspacePatterns)
|
|
72
|
-
: options.inline
|
|
73
|
-
? project.workspaces
|
|
74
|
-
: project.listWorkspacesWithScript(script);
|
|
75
70
|
const scriptEventTarget = createScriptEventTarget();
|
|
76
|
-
const { output, summary } = project.runScriptAcrossWorkspaces({
|
|
71
|
+
const { output, summary, workspaces } = project.runScriptAcrossWorkspaces({
|
|
77
72
|
workspacePatterns: workspacePatterns.length
|
|
78
73
|
? workspacePatterns
|
|
79
74
|
: undefined,
|
|
@@ -104,7 +99,7 @@ const runScript = handleProjectCommand(
|
|
|
104
99
|
parallel:
|
|
105
100
|
typeof options.parallel === "boolean" ||
|
|
106
101
|
typeof options.parallel === "undefined"
|
|
107
|
-
?
|
|
102
|
+
? undefined
|
|
108
103
|
: options.parallel === "true"
|
|
109
104
|
? true
|
|
110
105
|
: options.parallel === "false"
|
|
@@ -139,6 +134,9 @@ const runScript = handleProjectCommand(
|
|
|
139
134
|
logger.warn(
|
|
140
135
|
"--no-prefix is deprecated and will be removed in a future version. Use --output-style=plain instead.",
|
|
141
136
|
);
|
|
137
|
+
if (!options.outputStyle) {
|
|
138
|
+
options.outputStyle = "plain";
|
|
139
|
+
}
|
|
142
140
|
}
|
|
143
141
|
const outputStyleHandlers = {
|
|
144
142
|
grouped: () =>
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TypedEventTarget,
|
|
4
4
|
} from "../../../../internal/core/language/events/typedEventTarget";
|
|
5
5
|
import type {
|
|
6
|
-
|
|
6
|
+
RunScriptAcrossWorkspacesOutput,
|
|
7
7
|
RunWorkspaceScriptMetadata,
|
|
8
8
|
} from "../../../../project";
|
|
9
9
|
import type {
|
|
@@ -63,7 +63,7 @@ export declare const createScriptEvent: {
|
|
|
63
63
|
};
|
|
64
64
|
export declare const renderGroupedOutput: (
|
|
65
65
|
workspaces: Workspace[],
|
|
66
|
-
output:
|
|
66
|
+
output: RunScriptAcrossWorkspacesOutput,
|
|
67
67
|
summary: Promise<RunScriptsSummary<RunWorkspaceScriptMetadata>>,
|
|
68
68
|
scriptEventTarget: ScriptEventTarget,
|
|
69
69
|
activeScriptLines: number | "all",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RunScriptAcrossWorkspacesOutput } from "../../../../project";
|
|
2
2
|
export type RenderPlainOutputOptions = {
|
|
3
3
|
stripDisruptiveControls?: boolean;
|
|
4
4
|
prefix?: boolean;
|
|
5
5
|
};
|
|
6
6
|
export declare function generatePlainOutputLines(
|
|
7
|
-
output:
|
|
7
|
+
output: RunScriptAcrossWorkspacesOutput,
|
|
8
8
|
{ stripDisruptiveControls, prefix }: RenderPlainOutputOptions,
|
|
9
9
|
): AsyncGenerator<
|
|
10
10
|
{
|
|
@@ -17,6 +17,6 @@ export declare function generatePlainOutputLines(
|
|
|
17
17
|
unknown
|
|
18
18
|
>;
|
|
19
19
|
export declare const renderPlainOutput: (
|
|
20
|
-
output:
|
|
20
|
+
output: RunScriptAcrossWorkspacesOutput,
|
|
21
21
|
{ stripDisruptiveControls, prefix }: RenderPlainOutputOptions,
|
|
22
22
|
) => Promise<void>;
|
package/src/cli/createCli.mjs
CHANGED
|
@@ -38,9 +38,7 @@ const createCli = ({
|
|
|
38
38
|
.version(package_0.version)
|
|
39
39
|
.showHelpAfterError(true);
|
|
40
40
|
postInit?.(program);
|
|
41
|
-
const rawArgs =
|
|
42
|
-
typeof argv === "string" ? argv.split(/s+/) : argv,
|
|
43
|
-
);
|
|
41
|
+
const rawArgs = typeof argv === "string" ? argv.split(/s+/) : argv;
|
|
44
42
|
const { args, postTerminatorArgs } = (() => {
|
|
45
43
|
const terminatorIndex = rawArgs.findIndex((arg) => arg === "--");
|
|
46
44
|
return {
|
|
@@ -96,24 +94,5 @@ const createCli = ({
|
|
|
96
94
|
run,
|
|
97
95
|
};
|
|
98
96
|
};
|
|
99
|
-
/**
|
|
100
|
-
* @todo
|
|
101
|
-
* ! Temp backwards support for deprecated camel case options
|
|
102
|
-
* ! Added October 2025, drop support in some reasonable future release
|
|
103
|
-
*/ const tempOptions = {
|
|
104
|
-
"--nameOnly": "--name-only",
|
|
105
|
-
"--noPrefix": "--no-prefix",
|
|
106
|
-
"--configFile": "--config-file",
|
|
107
|
-
"--logLevel": "--log-level",
|
|
108
|
-
};
|
|
109
|
-
const tempFixCamelCaseOptions = (args) =>
|
|
110
|
-
args.map((arg) => {
|
|
111
|
-
for (const [camel, kebab] of Object.entries(tempOptions)) {
|
|
112
|
-
if (arg.startsWith(camel)) {
|
|
113
|
-
return arg.replace(camel, kebab);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return arg;
|
|
117
|
-
});
|
|
118
97
|
|
|
119
98
|
export { createCli };
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Option } from "commander";
|
|
4
|
-
import {
|
|
5
|
-
DEFAULT_CONFIG_FILE_PATH,
|
|
6
|
-
loadConfigFile,
|
|
7
|
-
} from "../../config/index.mjs";
|
|
8
4
|
import { defineErrors } from "../../internal/core/index.mjs";
|
|
9
5
|
import { logger } from "../../internal/logger/index.mjs";
|
|
10
6
|
import {
|
|
11
|
-
|
|
7
|
+
createFileSystemProject,
|
|
12
8
|
createMemoryProject,
|
|
13
9
|
} from "../../project/index.mjs";
|
|
14
10
|
import { getCliGlobalOptionConfig } from "./globalOptionsConfig.mjs"; // CONCATENATED MODULE: external "fs"
|
|
15
11
|
// CONCATENATED MODULE: external "path"
|
|
16
12
|
// CONCATENATED MODULE: external "commander"
|
|
17
|
-
// CONCATENATED MODULE: external "../../config/index.mjs"
|
|
18
13
|
// CONCATENATED MODULE: external "../../internal/core/index.mjs"
|
|
19
14
|
// CONCATENATED MODULE: external "../../internal/logger/index.mjs"
|
|
20
15
|
// CONCATENATED MODULE: external "../../project/index.mjs"
|
|
@@ -52,11 +47,6 @@ const getWorkingDirectoryFromArgs = (program, args, defaultCwd) => {
|
|
|
52
47
|
program.parseOptions(args);
|
|
53
48
|
return program.opts().cwd;
|
|
54
49
|
};
|
|
55
|
-
const getConfigFileFromArgs = (program, args) => {
|
|
56
|
-
addGlobalOption(program, "configFile");
|
|
57
|
-
program.parseOptions(args);
|
|
58
|
-
return program.opts().configFile;
|
|
59
|
-
};
|
|
60
50
|
const defineGlobalOptions = (program, args, defaultCwd) => {
|
|
61
51
|
const cwd = getWorkingDirectoryFromArgs(program, args, defaultCwd);
|
|
62
52
|
if (!fs.existsSync(cwd)) {
|
|
@@ -69,30 +59,20 @@ const defineGlobalOptions = (program, args, defaultCwd) => {
|
|
|
69
59
|
`Working directory is not a directory at path "${cwd}"`,
|
|
70
60
|
);
|
|
71
61
|
}
|
|
72
|
-
const configFilePath = getConfigFileFromArgs(program, args);
|
|
73
|
-
const config = loadConfigFile(configFilePath, cwd);
|
|
74
|
-
if (config) {
|
|
75
|
-
logger.warn(
|
|
76
|
-
// TODO link to docs
|
|
77
|
-
`Using the config file at ${configFilePath || DEFAULT_CONFIG_FILE_PATH} is deprecated. Migrate to the new workspace config file.`,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
62
|
addGlobalOption(program, "logLevel");
|
|
81
63
|
addGlobalOption(program, "includeRoot");
|
|
82
64
|
return {
|
|
83
65
|
cwd,
|
|
84
|
-
config,
|
|
85
66
|
};
|
|
86
67
|
};
|
|
87
|
-
const applyGlobalOptions = (options
|
|
68
|
+
const applyGlobalOptions = (options) => {
|
|
88
69
|
logger.printLevel = options.logLevel;
|
|
89
70
|
logger.debug("Log level: " + options.logLevel);
|
|
90
71
|
let project;
|
|
91
72
|
let error = null;
|
|
92
73
|
try {
|
|
93
|
-
project =
|
|
74
|
+
project = createFileSystemProject({
|
|
94
75
|
rootDirectory: options.cwd,
|
|
95
|
-
workspaceAliases: config?.project?.workspaceAliases ?? {},
|
|
96
76
|
includeRootWorkspace: options.includeRoot,
|
|
97
77
|
});
|
|
98
78
|
logger.debug(
|
|
@@ -112,17 +92,14 @@ const applyGlobalOptions = (options, config) => {
|
|
|
112
92
|
};
|
|
113
93
|
const initializeWithGlobalOptions = (program, args, defaultCwd) => {
|
|
114
94
|
program.allowUnknownOption(true);
|
|
115
|
-
const { cwd
|
|
95
|
+
const { cwd } = defineGlobalOptions(program, args, defaultCwd);
|
|
116
96
|
program.parseOptions(args);
|
|
117
97
|
program.allowUnknownOption(false);
|
|
118
98
|
const options = program.opts();
|
|
119
|
-
return applyGlobalOptions(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
},
|
|
124
|
-
config,
|
|
125
|
-
);
|
|
99
|
+
return applyGlobalOptions({
|
|
100
|
+
...options,
|
|
101
|
+
cwd,
|
|
102
|
+
});
|
|
126
103
|
};
|
|
127
104
|
|
|
128
105
|
export { initializeWithGlobalOptions };
|
|
@@ -3,7 +3,6 @@ export interface CliGlobalOptions {
|
|
|
3
3
|
logLevel: LogLevelSetting;
|
|
4
4
|
cwd: string;
|
|
5
5
|
includeRoot: boolean;
|
|
6
|
-
configFile?: string;
|
|
7
6
|
}
|
|
8
7
|
export interface CliGlobalOptionConfig {
|
|
9
8
|
mainOption: string;
|
|
@@ -40,13 +39,5 @@ export declare const getCliGlobalOptionConfig: (
|
|
|
40
39
|
readonly defaultValue: "";
|
|
41
40
|
readonly values: null;
|
|
42
41
|
readonly param: "";
|
|
43
|
-
}
|
|
44
|
-
| {
|
|
45
|
-
readonly mainOption: "--config-file";
|
|
46
|
-
readonly shortOption: "-c";
|
|
47
|
-
readonly description: "(DEPRECATED) Config file";
|
|
48
|
-
readonly defaultValue: "";
|
|
49
|
-
readonly values: null;
|
|
50
|
-
readonly param: "path";
|
|
51
42
|
};
|
|
52
43
|
export declare const getCliGlobalOptionNames: () => CliGlobalOptionName[];
|
|
@@ -26,14 +26,6 @@ const CLI_GLOBAL_OPTIONS_CONFIG = {
|
|
|
26
26
|
values: null,
|
|
27
27
|
param: "",
|
|
28
28
|
},
|
|
29
|
-
configFile: {
|
|
30
|
-
mainOption: "--config-file",
|
|
31
|
-
shortOption: "-c",
|
|
32
|
-
description: "(DEPRECATED) Config file",
|
|
33
|
-
defaultValue: "",
|
|
34
|
-
values: null,
|
|
35
|
-
param: "path",
|
|
36
|
-
},
|
|
37
29
|
};
|
|
38
30
|
const getCliGlobalOptionConfig = (optionName) =>
|
|
39
31
|
CLI_GLOBAL_OPTIONS_CONFIG[optionName];
|
package/src/config/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
validateBunWorkspacesConfig,
|
|
3
|
-
type BunWorkspacesConfig,
|
|
4
|
-
type CliConfig,
|
|
5
|
-
type ProjectConfig,
|
|
6
|
-
} from "./bunWorkspacesConfig";
|
|
7
|
-
export { loadConfigFile, DEFAULT_CONFIG_FILE_PATH } from "./configFile";
|
|
8
1
|
export * from "./workspaceConfig";
|
|
9
2
|
export * from "./rootConfig";
|
|
10
3
|
export * from "./util";
|
package/src/config/index.mjs
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import { validateBunWorkspacesConfig } from "./bunWorkspacesConfig.mjs";
|
|
2
|
-
import { DEFAULT_CONFIG_FILE_PATH, loadConfigFile } from "./configFile.mjs";
|
|
3
1
|
export * from "./workspaceConfig/index.mjs";
|
|
4
2
|
export * from "./rootConfig/index.mjs";
|
|
5
|
-
export * from "./util/index.mjs"; // CONCATENATED MODULE:
|
|
6
|
-
// CONCATENATED MODULE: external "./configFile.mjs"
|
|
7
|
-
// CONCATENATED MODULE: ./src/config/index.ts
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
DEFAULT_CONFIG_FILE_PATH,
|
|
11
|
-
loadConfigFile,
|
|
12
|
-
validateBunWorkspacesConfig,
|
|
13
|
-
};
|
|
3
|
+
export * from "./util/index.mjs"; // CONCATENATED MODULE: ./src/config/index.ts
|
package/src/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export {
|
|
|
17
17
|
type RunScriptAcrossWorkspacesOptions,
|
|
18
18
|
type RunScriptAcrossWorkspacesOutput,
|
|
19
19
|
type RunScriptAcrossWorkspacesSummary,
|
|
20
|
-
type RunScriptAcrossWorkspacesProcessOutput,
|
|
20
|
+
type RunScriptAcrossWorkspacesOutput as RunScriptAcrossWorkspacesProcessOutput,
|
|
21
21
|
type RunScriptAcrossWorkspacesResult,
|
|
22
22
|
type ParallelOption,
|
|
23
23
|
type ShellOption,
|
|
@@ -26,9 +26,7 @@ export {
|
|
|
26
26
|
} from "./project";
|
|
27
27
|
export {
|
|
28
28
|
type ScriptEventName,
|
|
29
|
-
type OutputChunk,
|
|
30
29
|
type OutputStreamName,
|
|
31
|
-
type DecodeOptions,
|
|
32
30
|
type PercentageValue,
|
|
33
31
|
type ParallelMaxValue,
|
|
34
32
|
type WorkspaceScriptCommandMethod,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// CONCATENATED MODULE: ./src/internal/core/language/asyncIterable/asyncIterableQueue.ts
|
|
2
2
|
const createAsyncIterableQueue = () => {
|
|
3
|
+
let resolveClose = () => {
|
|
4
|
+
void 0;
|
|
5
|
+
};
|
|
6
|
+
const closePromise = new Promise((resolve) => {
|
|
7
|
+
resolveClose = resolve;
|
|
8
|
+
});
|
|
3
9
|
let pendingResolveIdle = null;
|
|
4
10
|
const items = [];
|
|
5
11
|
let isDone = false;
|
|
@@ -34,6 +40,7 @@ const createAsyncIterableQueue = () => {
|
|
|
34
40
|
type: "done",
|
|
35
41
|
});
|
|
36
42
|
}
|
|
43
|
+
resolveClose();
|
|
37
44
|
};
|
|
38
45
|
const asyncIterator = {
|
|
39
46
|
next: () => {
|
|
@@ -66,6 +73,7 @@ const createAsyncIterableQueue = () => {
|
|
|
66
73
|
[Symbol.asyncIterator]: () => asyncIterator,
|
|
67
74
|
push,
|
|
68
75
|
close,
|
|
76
|
+
closed: closePromise,
|
|
69
77
|
};
|
|
70
78
|
return iterator;
|
|
71
79
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Simplify } from "../../internal/core";
|
|
2
2
|
import {
|
|
3
3
|
type RunScriptsParallelOptions,
|
|
4
4
|
type RunScriptsSummary,
|
|
5
|
-
type RunScriptsOutput,
|
|
6
5
|
type RunScriptExit,
|
|
7
|
-
type OutputChunk,
|
|
8
6
|
type OutputStreamName,
|
|
9
7
|
type ScriptEventName,
|
|
10
8
|
} from "../../runScript";
|
|
@@ -48,6 +46,7 @@ export type RunWorkspaceScriptOptions = {
|
|
|
48
46
|
};
|
|
49
47
|
/** Metadata associated with a workspace script */
|
|
50
48
|
export type RunWorkspaceScriptMetadata = {
|
|
49
|
+
/** The workspace that the script was run in */
|
|
51
50
|
workspace: Workspace;
|
|
52
51
|
};
|
|
53
52
|
export type RunWorkspaceScriptExit = Simplify<
|
|
@@ -57,21 +56,25 @@ export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
|
|
|
57
56
|
RunWorkspaceScriptMetadata & {
|
|
58
57
|
streamName: OutputStreamName;
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
/** @deprecated */
|
|
62
|
-
SimpleAsyncIterable<OutputChunk>;
|
|
59
|
+
>;
|
|
63
60
|
/** Result of `FileSystemProject.runWorkspaceScript` */
|
|
64
61
|
export type RunWorkspaceScriptResult = {
|
|
62
|
+
/** Use to get the output of the script */
|
|
65
63
|
output: RunWorkspaceScriptProcessOutput;
|
|
64
|
+
/** The exit result of the script */
|
|
66
65
|
exit: Promise<RunWorkspaceScriptExit>;
|
|
67
66
|
};
|
|
68
67
|
export type ParallelOption = boolean | RunScriptsParallelOptions;
|
|
69
68
|
export type ScriptEventMetadata = {
|
|
69
|
+
/** The workspace that the script event occurred in */
|
|
70
70
|
workspace: Workspace;
|
|
71
|
+
/** The exit result of the script */
|
|
71
72
|
exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
|
|
72
73
|
};
|
|
73
74
|
export type OnScriptEventCallback = (
|
|
75
|
+
/** The event that occurred */
|
|
74
76
|
event: ScriptEventName,
|
|
77
|
+
/** The metadata for the script event */
|
|
75
78
|
metadata: ScriptEventMetadata,
|
|
76
79
|
) => unknown;
|
|
77
80
|
/** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
@@ -88,7 +91,7 @@ export type RunScriptAcrossWorkspacesOptions = {
|
|
|
88
91
|
inline?: boolean | InlineScriptOptions;
|
|
89
92
|
/** The arguments to append to the script command. `<workspaceName>` will be replaced with the workspace name */
|
|
90
93
|
args?: string;
|
|
91
|
-
/** Whether to run the scripts in parallel (
|
|
94
|
+
/** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
|
|
92
95
|
parallel?: ParallelOption;
|
|
93
96
|
/** When `true`, run scripts so that dependent workspaces run only after their dependencies */
|
|
94
97
|
dependencyOrder?: boolean;
|
|
@@ -99,23 +102,22 @@ export type RunScriptAcrossWorkspacesOptions = {
|
|
|
99
102
|
/** Callback to invoke when a script event occurs (start, skip, exit) */
|
|
100
103
|
onScriptEvent?: OnScriptEventCallback;
|
|
101
104
|
};
|
|
102
|
-
export type RunScriptAcrossWorkspacesOutput = Simplify<
|
|
103
|
-
RunScriptsOutput<RunWorkspaceScriptMetadata>
|
|
104
|
-
>;
|
|
105
105
|
export type RunScriptAcrossWorkspacesSummary = Simplify<
|
|
106
106
|
RunScriptsSummary<RunWorkspaceScriptMetadata>
|
|
107
107
|
>;
|
|
108
|
-
export type
|
|
108
|
+
export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
|
|
109
109
|
RunWorkspaceScriptMetadata & {
|
|
110
110
|
streamName: OutputStreamName;
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
/** @deprecated */
|
|
114
|
-
SimpleAsyncIterable<RunScriptAcrossWorkspacesOutput>;
|
|
112
|
+
>;
|
|
115
113
|
/** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
116
114
|
export type RunScriptAcrossWorkspacesResult = {
|
|
117
|
-
output
|
|
115
|
+
/** Use to get the output of the scripts */
|
|
116
|
+
output: RunScriptAcrossWorkspacesOutput;
|
|
117
|
+
/** The summary of the script run with exit details for each workspace */
|
|
118
118
|
summary: Promise<RunScriptAcrossWorkspacesSummary>;
|
|
119
|
+
/** The workspaces targeted */
|
|
120
|
+
workspaces: Workspace[];
|
|
119
121
|
};
|
|
120
122
|
declare class _FileSystemProject extends ProjectBase implements Project {
|
|
121
123
|
#private;
|
|
@@ -125,12 +127,7 @@ declare class _FileSystemProject extends ProjectBase implements Project {
|
|
|
125
127
|
readonly sourceType = "fileSystem";
|
|
126
128
|
readonly config: ProjectConfig;
|
|
127
129
|
readonly rootWorkspace: Workspace;
|
|
128
|
-
constructor(
|
|
129
|
-
options: CreateFileSystemProjectOptions & {
|
|
130
|
-
/** @deprecated */
|
|
131
|
-
workspaceAliases?: Record<string, string>;
|
|
132
|
-
},
|
|
133
|
-
);
|
|
130
|
+
constructor(options: CreateFileSystemProjectOptions);
|
|
134
131
|
runWorkspaceScript(
|
|
135
132
|
options: RunWorkspaceScriptOptions,
|
|
136
133
|
): RunWorkspaceScriptResult;
|
|
@@ -148,11 +145,4 @@ export type FileSystemProject = Simplify<_FileSystemProject>;
|
|
|
148
145
|
export declare const createFileSystemProject: (
|
|
149
146
|
options?: CreateFileSystemProjectOptions,
|
|
150
147
|
) => FileSystemProject;
|
|
151
|
-
/** @deprecated temporarily supports workspaceAliases from deprecated config file */
|
|
152
|
-
export declare const _internalCreateFileSystemProject: (
|
|
153
|
-
options: CreateFileSystemProjectOptions & {
|
|
154
|
-
/** @deprecated */
|
|
155
|
-
workspaceAliases?: Record<string, string>;
|
|
156
|
-
},
|
|
157
|
-
) => FileSystemProject;
|
|
158
148
|
export {};
|
|
@@ -81,7 +81,6 @@ class _FileSystemProject extends ProjectBase {
|
|
|
81
81
|
const rootConfig = loadRootConfig(this.rootDirectory);
|
|
82
82
|
const { workspaces, workspaceMap, rootWorkspace } = findWorkspaces({
|
|
83
83
|
rootDirectory: this.rootDirectory,
|
|
84
|
-
workspaceAliases: options.workspaceAliases,
|
|
85
84
|
includeRootWorkspace:
|
|
86
85
|
options.includeRootWorkspace ??
|
|
87
86
|
rootConfig.defaults.includeRootWorkspace ??
|
|
@@ -221,21 +220,7 @@ class _FileSystemProject extends ProjectBase {
|
|
|
221
220
|
shell,
|
|
222
221
|
ignoreOutput: options.ignoreOutput ?? false,
|
|
223
222
|
});
|
|
224
|
-
|
|
225
|
-
output[Symbol.asyncIterator] = async function* () {
|
|
226
|
-
logger.warn(
|
|
227
|
-
new Error(
|
|
228
|
-
"Iterating directly over runWorkspaceScript output is deprecated: Use output.bytes() or output.text() instead",
|
|
229
|
-
),
|
|
230
|
-
);
|
|
231
|
-
for await (const chunk of result.output) {
|
|
232
|
-
yield chunk;
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
return {
|
|
236
|
-
exit: result.exit,
|
|
237
|
-
output,
|
|
238
|
-
};
|
|
223
|
+
return result;
|
|
239
224
|
}
|
|
240
225
|
runScriptAcrossWorkspaces(options) {
|
|
241
226
|
validateJSTypes(
|
|
@@ -445,7 +430,7 @@ class _FileSystemProject extends ProjectBase {
|
|
|
445
430
|
? {
|
|
446
431
|
max: this.config.root.defaults.parallelMax,
|
|
447
432
|
}
|
|
448
|
-
: (options.parallel ??
|
|
433
|
+
: (options.parallel ?? true),
|
|
449
434
|
ignoreOutput: options.ignoreOutput ?? false,
|
|
450
435
|
onScriptEvent: (event, index, exitResult) =>
|
|
451
436
|
options.onScriptEvent?.(event, {
|
|
@@ -453,20 +438,9 @@ class _FileSystemProject extends ProjectBase {
|
|
|
453
438
|
exitResult,
|
|
454
439
|
}),
|
|
455
440
|
});
|
|
456
|
-
const output = result.processOutput;
|
|
457
|
-
output[Symbol.asyncIterator] = async function* () {
|
|
458
|
-
logger.warn(
|
|
459
|
-
new Error(
|
|
460
|
-
"Iterating directly over runScriptAcrossWorkspaces output is deprecated: Use output.bytes() or output.text() instead",
|
|
461
|
-
),
|
|
462
|
-
);
|
|
463
|
-
for await (const chunk of result.output) {
|
|
464
|
-
yield chunk;
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
441
|
return {
|
|
468
|
-
|
|
469
|
-
|
|
442
|
+
...result,
|
|
443
|
+
workspaces,
|
|
470
444
|
};
|
|
471
445
|
}
|
|
472
446
|
static #initialized = false;
|
|
@@ -477,7 +451,5 @@ class _FileSystemProject extends ProjectBase {
|
|
|
477
451
|
* and detects and utilizes any provided configuration.
|
|
478
452
|
*/ const createFileSystemProject = (options = {}) =>
|
|
479
453
|
new _FileSystemProject(options);
|
|
480
|
-
/** @deprecated temporarily supports workspaceAliases from deprecated config file */ const _internalCreateFileSystemProject =
|
|
481
|
-
(options) => new _FileSystemProject(options);
|
|
482
454
|
|
|
483
|
-
export {
|
|
455
|
+
export { createFileSystemProject };
|
package/src/runScript/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./runScript";
|
|
2
2
|
export * from "./runScripts";
|
|
3
3
|
export * from "./scriptCommand";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./output";
|
|
5
5
|
export * from "./parallel";
|
|
6
6
|
export * from "./scriptRuntimeMetadata";
|
|
7
7
|
export * from "./scriptShellOption";
|
package/src/runScript/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./runScript.mjs";
|
|
2
2
|
export * from "./runScripts.mjs";
|
|
3
3
|
export * from "./scriptCommand.mjs";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./output/index.mjs";
|
|
5
5
|
export * from "./parallel.mjs";
|
|
6
6
|
export * from "./scriptRuntimeMetadata.mjs";
|
|
7
7
|
export * from "./scriptShellOption.mjs"; // CONCATENATED MODULE: ./src/runScript/index.ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type OutputStreamName = "stdout" | "stderr";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// CONCATENATED MODULE: ./src/runScript/output/outputStream.ts
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type MultiProcessOutput } from "./output/multiProcessOutput";
|
|
3
|
-
import { type OutputChunk, type OutputStreamName } from "./outputChunk";
|
|
1
|
+
import { type MultiProcessOutput, type OutputStreamName } from "./output";
|
|
4
2
|
import type { ScriptCommand } from "./scriptCommand";
|
|
5
3
|
import type { ScriptShellOption } from "./scriptShellOption";
|
|
6
4
|
export type RunScriptExit<ScriptMetadata extends object = object> = {
|
|
@@ -15,9 +13,7 @@ export type RunScriptExit<ScriptMetadata extends object = object> = {
|
|
|
15
13
|
metadata: ScriptMetadata;
|
|
16
14
|
};
|
|
17
15
|
export type RunScriptResult<ScriptMetadata extends object = object> = {
|
|
18
|
-
|
|
19
|
-
output: SimpleAsyncIterable<OutputChunk>;
|
|
20
|
-
processOutput: MultiProcessOutput<
|
|
16
|
+
output: MultiProcessOutput<
|
|
21
17
|
ScriptMetadata & {
|
|
22
18
|
streamName: OutputStreamName;
|
|
23
19
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
createMultiProcessOutput,
|
|
3
|
+
createProcessOutput,
|
|
4
|
+
} from "./output/index.mjs";
|
|
4
5
|
import { createScriptExecutor } from "./scriptExecution.mjs";
|
|
5
|
-
import { createSubprocess } from "./subprocesses.mjs"; // CONCATENATED MODULE: external "./output/
|
|
6
|
-
// CONCATENATED MODULE: external "./output/processOutput.mjs"
|
|
7
|
-
// CONCATENATED MODULE: external "./outputChunk.mjs"
|
|
6
|
+
import { createSubprocess } from "./subprocesses.mjs"; // CONCATENATED MODULE: external "./output/index.mjs"
|
|
8
7
|
// CONCATENATED MODULE: external "./scriptExecution.mjs"
|
|
9
8
|
// CONCATENATED MODULE: external "./subprocesses.mjs"
|
|
10
9
|
// CONCATENATED MODULE: ./src/runScript/runScript.ts
|
|
@@ -67,11 +66,6 @@ const SIGNAL_MAP = {
|
|
|
67
66
|
},
|
|
68
67
|
),
|
|
69
68
|
]);
|
|
70
|
-
const deprecatedOutput = async function* () {
|
|
71
|
-
for await (const chunk of processOutput.bytes()) {
|
|
72
|
-
yield createOutputChunk(chunk.metadata.streamName, chunk.chunk);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
69
|
const exit = proc.exited.then((exitCode) => {
|
|
76
70
|
const endTime = new Date();
|
|
77
71
|
return {
|
|
@@ -85,8 +79,7 @@ const SIGNAL_MAP = {
|
|
|
85
79
|
};
|
|
86
80
|
});
|
|
87
81
|
return {
|
|
88
|
-
output:
|
|
89
|
-
processOutput,
|
|
82
|
+
output: processOutput,
|
|
90
83
|
exit,
|
|
91
84
|
metadata,
|
|
92
85
|
kill: (exit) => proc.kill(exit),
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type MultiProcessOutput } from "./output/multiProcessOutput";
|
|
3
|
-
import { type OutputChunk, type OutputStreamName } from "./outputChunk";
|
|
1
|
+
import { type MultiProcessOutput, type OutputStreamName } from "./output";
|
|
4
2
|
import { type ParallelMaxValue } from "./parallel";
|
|
5
3
|
import { type RunScriptExit, type RunScriptResult } from "./runScript";
|
|
6
4
|
import { type ScriptCommand } from "./scriptCommand";
|
|
@@ -30,20 +28,9 @@ export type RunScriptsSummary<ScriptMetadata extends object = object> = {
|
|
|
30
28
|
durationMs: number;
|
|
31
29
|
scriptResults: RunScriptExit<ScriptMetadata>[];
|
|
32
30
|
};
|
|
33
|
-
/** @deprecated */
|
|
34
|
-
export type RunScriptsOutput<ScriptMetadata extends object = object> = {
|
|
35
|
-
/** The output chunk from a script execution */
|
|
36
|
-
outputChunk: OutputChunk;
|
|
37
|
-
/** The metadata for the script that produced the output chunk */
|
|
38
|
-
scriptMetadata: ScriptMetadata & {
|
|
39
|
-
streamName: OutputStreamName;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
31
|
export type ScriptEventName = "start" | "skip" | "exit";
|
|
43
32
|
export type RunScriptsResult<ScriptMetadata extends object = object> = {
|
|
44
|
-
|
|
45
|
-
output: SimpleAsyncIterable<RunScriptsOutput<ScriptMetadata>>;
|
|
46
|
-
processOutput: MultiProcessOutput<
|
|
33
|
+
output: MultiProcessOutput<
|
|
47
34
|
ScriptMetadata & {
|
|
48
35
|
streamName: OutputStreamName;
|
|
49
36
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createAsyncIterableQueue } from "../internal/core/index.mjs";
|
|
2
2
|
import { logger } from "../internal/logger/index.mjs";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
createMultiProcessOutput,
|
|
5
|
+
createProcessOutput,
|
|
6
|
+
} from "./output/index.mjs";
|
|
6
7
|
import { determineParallelMax } from "./parallel.mjs";
|
|
7
8
|
import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
|
|
8
9
|
// CONCATENATED MODULE: external "../internal/logger/index.mjs"
|
|
9
|
-
// CONCATENATED MODULE: external "./output/
|
|
10
|
-
// CONCATENATED MODULE: external "./output/processOutput.mjs"
|
|
11
|
-
// CONCATENATED MODULE: external "./outputChunk.mjs"
|
|
10
|
+
// CONCATENATED MODULE: external "./output/index.mjs"
|
|
12
11
|
// CONCATENATED MODULE: external "./parallel.mjs"
|
|
13
12
|
// CONCATENATED MODULE: external "./runScript.mjs"
|
|
14
13
|
// CONCATENATED MODULE: ./src/runScript/runScripts.ts
|
|
@@ -84,7 +83,6 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
84
83
|
};
|
|
85
84
|
return result;
|
|
86
85
|
});
|
|
87
|
-
/** @deprecated */ const outputQueue = createAsyncIterableQueue();
|
|
88
86
|
const scriptResults = scripts.map(() => null);
|
|
89
87
|
const parallelMax =
|
|
90
88
|
parallel === false
|
|
@@ -126,10 +124,7 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
126
124
|
exitResults[index] = skippedExit;
|
|
127
125
|
return {
|
|
128
126
|
result: {
|
|
129
|
-
output: (
|
|
130
|
-
/* empty */
|
|
131
|
-
})(),
|
|
132
|
-
processOutput: createMultiProcessOutput([]),
|
|
127
|
+
output: createMultiProcessOutput([]),
|
|
133
128
|
exit: Promise.resolve(skippedExit),
|
|
134
129
|
metadata: scripts[index].metadata,
|
|
135
130
|
kill: () => {
|
|
@@ -150,6 +145,10 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
150
145
|
if (!deps) return true;
|
|
151
146
|
return deps.every((dep) => completedScripts.has(dep));
|
|
152
147
|
};
|
|
148
|
+
const scriptOutputQueues = scripts.map(() => ({
|
|
149
|
+
stdout: createAsyncIterableQueue(),
|
|
150
|
+
stderr: createAsyncIterableQueue(),
|
|
151
|
+
}));
|
|
153
152
|
const scheduleReadyScripts = () => {
|
|
154
153
|
let changed = true;
|
|
155
154
|
while (changed) {
|
|
@@ -164,6 +163,8 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
164
163
|
scriptProcessBytes[index] = (async function* () {
|
|
165
164
|
/* empty */
|
|
166
165
|
})();
|
|
166
|
+
scriptOutputQueues[index].stdout.close();
|
|
167
|
+
scriptOutputQueues[index].stderr.close();
|
|
167
168
|
onScriptEvent?.("skip", index, null);
|
|
168
169
|
scriptTriggers[index].trigger();
|
|
169
170
|
changed = true;
|
|
@@ -183,7 +184,15 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
183
184
|
}),
|
|
184
185
|
};
|
|
185
186
|
scriptResults[index] = scriptResult;
|
|
186
|
-
|
|
187
|
+
const bytesOutput = scriptResult.result.output.bytes();
|
|
188
|
+
scriptProcessBytes[index] = bytesOutput;
|
|
189
|
+
(async () => {
|
|
190
|
+
for await (const { chunk, metadata } of bytesOutput) {
|
|
191
|
+
scriptOutputQueues[index][metadata.streamName].push(chunk);
|
|
192
|
+
}
|
|
193
|
+
scriptOutputQueues[index].stdout.close();
|
|
194
|
+
scriptOutputQueues[index].stderr.close();
|
|
195
|
+
})();
|
|
187
196
|
onScriptEvent?.("start", index, null);
|
|
188
197
|
scriptTriggers[index].trigger();
|
|
189
198
|
scriptResult.result.exit.then((exit) => {
|
|
@@ -196,11 +205,8 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
196
205
|
}
|
|
197
206
|
}
|
|
198
207
|
};
|
|
199
|
-
const scriptOutputQueues = scripts.map(() =>
|
|
200
|
-
["stdout", "stderr"].map(() => createAsyncIterableQueue()),
|
|
201
|
-
);
|
|
202
208
|
const multiProcessOutput = createMultiProcessOutput(
|
|
203
|
-
scriptOutputQueues.flatMap((
|
|
209
|
+
scriptOutputQueues.flatMap(({ stdout, stderr }, index) => [
|
|
204
210
|
createProcessOutput(stdout, {
|
|
205
211
|
...scripts[index].metadata,
|
|
206
212
|
streamName: "stdout",
|
|
@@ -212,8 +218,6 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
212
218
|
]),
|
|
213
219
|
);
|
|
214
220
|
const handleScriptProcesses = async () => {
|
|
215
|
-
/** @deprecated */ const outputReaders = [];
|
|
216
|
-
const scriptExits = [];
|
|
217
221
|
let pendingScriptCount = scripts.length;
|
|
218
222
|
while (pendingScriptCount > 0) {
|
|
219
223
|
const { index } = await Promise.race(
|
|
@@ -223,33 +227,14 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
223
227
|
scriptTriggers[index].promise = new Promise(() => {
|
|
224
228
|
void 0;
|
|
225
229
|
});
|
|
226
|
-
outputReaders.push(
|
|
227
|
-
(async () => {
|
|
228
|
-
for await (const chunk of scriptProcessBytes[index]) {
|
|
229
|
-
outputQueue.push({
|
|
230
|
-
outputChunk: createOutputChunk(
|
|
231
|
-
chunk.metadata.streamName,
|
|
232
|
-
chunk.chunk,
|
|
233
|
-
),
|
|
234
|
-
scriptMetadata: {
|
|
235
|
-
...scripts[index].metadata,
|
|
236
|
-
streamName: chunk.metadata.streamName,
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
scriptOutputQueues[index][
|
|
240
|
-
chunk.metadata.streamName === "stdout" ? 0 : 1
|
|
241
|
-
].push(chunk.chunk);
|
|
242
|
-
}
|
|
243
|
-
})(),
|
|
244
|
-
);
|
|
245
230
|
}
|
|
246
|
-
await Promise.all(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
});
|
|
231
|
+
await Promise.all(
|
|
232
|
+
scriptOutputQueues.flatMap(({ stdout, stderr }) => [
|
|
233
|
+
stdout.closed,
|
|
234
|
+
stderr.closed,
|
|
235
|
+
]),
|
|
236
|
+
);
|
|
237
|
+
await Promise.all(scriptResults.map(({ result }) => result.exit));
|
|
253
238
|
};
|
|
254
239
|
const awaitSummary = async () => {
|
|
255
240
|
scheduleReadyScripts();
|
|
@@ -270,8 +255,7 @@ import { runScript } from "./runScript.mjs"; // CONCATENATED MODULE: external ".
|
|
|
270
255
|
};
|
|
271
256
|
};
|
|
272
257
|
return {
|
|
273
|
-
output:
|
|
274
|
-
processOutput: multiProcessOutput,
|
|
258
|
+
output: multiProcessOutput,
|
|
275
259
|
summary: awaitSummary(),
|
|
276
260
|
};
|
|
277
261
|
};
|
|
@@ -9,28 +9,27 @@ export interface ScriptRuntimeMetadata {
|
|
|
9
9
|
}
|
|
10
10
|
declare const SCRIPT_RUNTIME_METADATA_CONFIG: {
|
|
11
11
|
readonly projectPath: {
|
|
12
|
-
readonly inlineName:
|
|
12
|
+
readonly inlineName: "<projectPath>";
|
|
13
13
|
readonly envVarName: "BW_PROJECT_PATH";
|
|
14
14
|
};
|
|
15
15
|
readonly projectName: {
|
|
16
|
-
readonly inlineName:
|
|
16
|
+
readonly inlineName: "<projectName>";
|
|
17
17
|
readonly envVarName: "BW_PROJECT_NAME";
|
|
18
18
|
};
|
|
19
19
|
readonly workspacePath: {
|
|
20
|
-
readonly inlineName:
|
|
20
|
+
readonly inlineName: "<workspacePath>";
|
|
21
21
|
readonly envVarName: "BW_WORKSPACE_PATH";
|
|
22
22
|
};
|
|
23
23
|
readonly workspaceRelativePath: {
|
|
24
|
-
readonly inlineName:
|
|
24
|
+
readonly inlineName: "<workspaceRelativePath>";
|
|
25
25
|
readonly envVarName: "BW_WORKSPACE_RELATIVE_PATH";
|
|
26
26
|
};
|
|
27
27
|
readonly scriptName: {
|
|
28
|
-
readonly inlineName:
|
|
28
|
+
readonly inlineName: "<scriptName>";
|
|
29
29
|
readonly envVarName: "BW_SCRIPT_NAME";
|
|
30
30
|
};
|
|
31
31
|
readonly workspaceName: {
|
|
32
|
-
|
|
33
|
-
readonly inlineName: readonly ["<workspaceName>", "<workspace>"];
|
|
32
|
+
readonly inlineName: "<workspaceName>";
|
|
34
33
|
readonly envVarName: "BW_WORKSPACE_NAME";
|
|
35
34
|
};
|
|
36
35
|
};
|
|
@@ -40,28 +39,27 @@ export declare const getScriptRuntimeMetadataConfig: (
|
|
|
40
39
|
key: ScriptRuntimeMetadataKey,
|
|
41
40
|
) =>
|
|
42
41
|
| {
|
|
43
|
-
readonly inlineName:
|
|
42
|
+
readonly inlineName: "<projectPath>";
|
|
44
43
|
readonly envVarName: "BW_PROJECT_PATH";
|
|
45
44
|
}
|
|
46
45
|
| {
|
|
47
|
-
readonly inlineName:
|
|
46
|
+
readonly inlineName: "<projectName>";
|
|
48
47
|
readonly envVarName: "BW_PROJECT_NAME";
|
|
49
48
|
}
|
|
50
49
|
| {
|
|
51
|
-
readonly inlineName:
|
|
50
|
+
readonly inlineName: "<workspacePath>";
|
|
52
51
|
readonly envVarName: "BW_WORKSPACE_PATH";
|
|
53
52
|
}
|
|
54
53
|
| {
|
|
55
|
-
readonly inlineName:
|
|
54
|
+
readonly inlineName: "<workspaceRelativePath>";
|
|
56
55
|
readonly envVarName: "BW_WORKSPACE_RELATIVE_PATH";
|
|
57
56
|
}
|
|
58
57
|
| {
|
|
59
|
-
readonly inlineName:
|
|
58
|
+
readonly inlineName: "<scriptName>";
|
|
60
59
|
readonly envVarName: "BW_SCRIPT_NAME";
|
|
61
60
|
}
|
|
62
61
|
| {
|
|
63
|
-
|
|
64
|
-
readonly inlineName: readonly ["<workspaceName>", "<workspace>"];
|
|
62
|
+
readonly inlineName: "<workspaceName>";
|
|
65
63
|
readonly envVarName: "BW_WORKSPACE_NAME";
|
|
66
64
|
};
|
|
67
65
|
export declare const createScriptRuntimeEnvVars: (
|
|
@@ -3,28 +3,27 @@ import { IS_WINDOWS } from "../internal/core/index.mjs"; // CONCATENATED MODULE:
|
|
|
3
3
|
|
|
4
4
|
const SCRIPT_RUNTIME_METADATA_CONFIG = {
|
|
5
5
|
projectPath: {
|
|
6
|
-
inlineName:
|
|
6
|
+
inlineName: "<projectPath>",
|
|
7
7
|
envVarName: "BW_PROJECT_PATH",
|
|
8
8
|
},
|
|
9
9
|
projectName: {
|
|
10
|
-
inlineName:
|
|
10
|
+
inlineName: "<projectName>",
|
|
11
11
|
envVarName: "BW_PROJECT_NAME",
|
|
12
12
|
},
|
|
13
13
|
workspacePath: {
|
|
14
|
-
inlineName:
|
|
14
|
+
inlineName: "<workspacePath>",
|
|
15
15
|
envVarName: "BW_WORKSPACE_PATH",
|
|
16
16
|
},
|
|
17
17
|
workspaceRelativePath: {
|
|
18
|
-
inlineName:
|
|
18
|
+
inlineName: "<workspaceRelativePath>",
|
|
19
19
|
envVarName: "BW_WORKSPACE_RELATIVE_PATH",
|
|
20
20
|
},
|
|
21
21
|
scriptName: {
|
|
22
|
-
inlineName:
|
|
22
|
+
inlineName: "<scriptName>",
|
|
23
23
|
envVarName: "BW_SCRIPT_NAME",
|
|
24
24
|
},
|
|
25
25
|
workspaceName: {
|
|
26
|
-
|
|
27
|
-
["<workspaceName>", "<workspace>"],
|
|
26
|
+
inlineName: "<workspaceName>",
|
|
28
27
|
envVarName: "BW_WORKSPACE_NAME",
|
|
29
28
|
},
|
|
30
29
|
};
|
|
@@ -45,7 +44,7 @@ const interpolateScriptRuntimeMetadata = (text, metadata, shell) =>
|
|
|
45
44
|
),
|
|
46
45
|
(match) => {
|
|
47
46
|
const key = Object.entries(SCRIPT_RUNTIME_METADATA_CONFIG).find(
|
|
48
|
-
([_, value]) => value.inlineName
|
|
47
|
+
([_, value]) => value.inlineName === match,
|
|
49
48
|
)?.[0];
|
|
50
49
|
const value = metadata[key];
|
|
51
50
|
if (IS_WINDOWS && shell === "bun") {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { type ProjectConfig } from "../config";
|
|
2
1
|
import { type WorkspaceMap } from "./dependencyGraph/resolveDependencies";
|
|
3
2
|
import type { Workspace } from "./workspace";
|
|
4
3
|
export interface FindWorkspacesOptions {
|
|
5
4
|
rootDirectory: string;
|
|
6
5
|
/** If provided, will override the workspaces found in the package.json. Mainly for testing purposes */
|
|
7
6
|
workspaceGlobs?: string[];
|
|
8
|
-
/** @deprecated due to config file changes */
|
|
9
|
-
workspaceAliases?: ProjectConfig["workspaceAliases"];
|
|
10
7
|
/** Whether to include the root workspace as a normal workspace.*/
|
|
11
8
|
includeRootWorkspace?: boolean;
|
|
12
9
|
}
|
|
@@ -14,7 +11,6 @@ export declare const sortWorkspaces: (workspaces: Workspace[]) => Workspace[];
|
|
|
14
11
|
export declare const findWorkspaces: ({
|
|
15
12
|
rootDirectory,
|
|
16
13
|
workspaceGlobs: _workspaceGlobs,
|
|
17
|
-
workspaceAliases,
|
|
18
14
|
includeRootWorkspace,
|
|
19
15
|
}: FindWorkspacesOptions) => {
|
|
20
16
|
workspaces: Workspace[];
|
|
@@ -23,6 +19,6 @@ export declare const findWorkspaces: ({
|
|
|
23
19
|
};
|
|
24
20
|
export declare const validateWorkspaceAliases: (
|
|
25
21
|
workspaces: Workspace[],
|
|
26
|
-
workspaceAliases:
|
|
22
|
+
workspaceAliases: Record<string, string>,
|
|
27
23
|
rootWorkspaceName: string,
|
|
28
24
|
) => void;
|
|
@@ -71,7 +71,6 @@ const validateWorkspace = (workspace, workspaces) => {
|
|
|
71
71
|
const findWorkspaces = ({
|
|
72
72
|
rootDirectory,
|
|
73
73
|
workspaceGlobs: _workspaceGlobs,
|
|
74
|
-
workspaceAliases = {},
|
|
75
74
|
includeRootWorkspace = false,
|
|
76
75
|
}) => {
|
|
77
76
|
rootDirectory = path.resolve(rootDirectory);
|
|
@@ -102,6 +101,7 @@ const findWorkspaces = ({
|
|
|
102
101
|
namedCatalogs: catalogs,
|
|
103
102
|
};
|
|
104
103
|
let rootWorkspace;
|
|
104
|
+
const workspaceAliases = {};
|
|
105
105
|
for (const workspacePath of Object.keys(bunLock.workspaces).map((p) =>
|
|
106
106
|
path.join(rootDirectory, p),
|
|
107
107
|
)) {
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type LogLevelSetting } from "../internal/logger";
|
|
2
|
-
export interface CliConfig {
|
|
3
|
-
logLevel?: LogLevelSetting;
|
|
4
|
-
}
|
|
5
|
-
export interface ProjectConfig {
|
|
6
|
-
/** @deprecated A map of aliases to a workspace name */
|
|
7
|
-
workspaceAliases?: Record<string, string>;
|
|
8
|
-
}
|
|
9
|
-
/** @deprecated */
|
|
10
|
-
export interface BunWorkspacesConfig {
|
|
11
|
-
cli?: CliConfig;
|
|
12
|
-
project?: ProjectConfig;
|
|
13
|
-
}
|
|
14
|
-
/** @deprecated */
|
|
15
|
-
export declare const validateBunWorkspacesConfig: (
|
|
16
|
-
config: BunWorkspacesConfig,
|
|
17
|
-
) => void;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { validateLogLevel } from "../internal/logger/index.mjs";
|
|
2
|
-
import { ERRORS } from "./errors.mjs"; // CONCATENATED MODULE: external "../internal/logger/index.mjs"
|
|
3
|
-
// CONCATENATED MODULE: external "./errors.mjs"
|
|
4
|
-
// CONCATENATED MODULE: ./src/config/bunWorkspacesConfig.ts
|
|
5
|
-
|
|
6
|
-
const isJsonObject = (value) => {
|
|
7
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
|
-
};
|
|
9
|
-
const validateCliConfig = (cliConfig) => {
|
|
10
|
-
if (!isJsonObject(cliConfig)) {
|
|
11
|
-
throw new ERRORS.InvalidConfigFile(`Config file: "cli" must be an object`);
|
|
12
|
-
}
|
|
13
|
-
if (cliConfig?.logLevel) {
|
|
14
|
-
validateLogLevel(cliConfig.logLevel);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const validateProjectConfig = (projectConfig) => {
|
|
18
|
-
if (!isJsonObject(projectConfig)) {
|
|
19
|
-
throw new ERRORS.InvalidConfigFile(
|
|
20
|
-
`Config file: "project" must be an object`,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
if (projectConfig?.workspaceAliases !== undefined) {
|
|
24
|
-
if (!isJsonObject(projectConfig.workspaceAliases)) {
|
|
25
|
-
throw new ERRORS.InvalidConfigFile(
|
|
26
|
-
`Config file: project.workspaceAliases must be an object`,
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
for (const alias of Object.values(projectConfig.workspaceAliases)) {
|
|
30
|
-
if (typeof alias !== "string") {
|
|
31
|
-
throw new ERRORS.InvalidConfigFile(
|
|
32
|
-
`Config file: project.workspaceAliases must be an object with string keys and values`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
/** @deprecated */ const validateBunWorkspacesConfig = (config) => {
|
|
39
|
-
if (!isJsonObject(config)) {
|
|
40
|
-
throw new ERRORS.InvalidConfigFile(`Config file: must be an object`);
|
|
41
|
-
}
|
|
42
|
-
if (typeof config.cli !== "undefined") {
|
|
43
|
-
validateCliConfig(config.cli);
|
|
44
|
-
}
|
|
45
|
-
if (typeof config.project !== "undefined") {
|
|
46
|
-
validateProjectConfig(config.project);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export { validateBunWorkspacesConfig };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type BunWorkspacesConfig } from "./bunWorkspacesConfig";
|
|
2
|
-
/** @deprecated The default path for the config file */
|
|
3
|
-
export declare const DEFAULT_CONFIG_FILE_PATH = "bw.json";
|
|
4
|
-
/** @deprecated */
|
|
5
|
-
export declare const loadConfigFile: (
|
|
6
|
-
filePath?: string,
|
|
7
|
-
rootDirectory?: string,
|
|
8
|
-
) => BunWorkspacesConfig | null;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { validateBunWorkspacesConfig } from "./bunWorkspacesConfig.mjs";
|
|
4
|
-
import { ERRORS } from "./errors.mjs"; // CONCATENATED MODULE: external "fs"
|
|
5
|
-
// CONCATENATED MODULE: external "path"
|
|
6
|
-
// CONCATENATED MODULE: external "./bunWorkspacesConfig.mjs"
|
|
7
|
-
// CONCATENATED MODULE: external "./errors.mjs"
|
|
8
|
-
// CONCATENATED MODULE: ./src/config/configFile.ts
|
|
9
|
-
|
|
10
|
-
/** @deprecated The default path for the config file */ const DEFAULT_CONFIG_FILE_PATH =
|
|
11
|
-
"bw.json";
|
|
12
|
-
/** @deprecated */ const loadConfigFile = (filePath, rootDirectory = ".") => {
|
|
13
|
-
if (!filePath) {
|
|
14
|
-
const defaultFilePath = path.resolve(
|
|
15
|
-
rootDirectory,
|
|
16
|
-
DEFAULT_CONFIG_FILE_PATH,
|
|
17
|
-
);
|
|
18
|
-
if (fs.existsSync(defaultFilePath)) {
|
|
19
|
-
filePath = defaultFilePath;
|
|
20
|
-
} else {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
filePath = path.resolve(rootDirectory, filePath);
|
|
25
|
-
if (!fs.existsSync(filePath)) {
|
|
26
|
-
throw new ERRORS.ConfigFileNotFound(
|
|
27
|
-
`Config file not found at path "${filePath}"`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
const configFile = fs.readFileSync(filePath, "utf8");
|
|
31
|
-
let json = null;
|
|
32
|
-
try {
|
|
33
|
-
json = JSON.parse(configFile);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
throw new ERRORS.InvalidConfigFileFormat(
|
|
36
|
-
`Failed to parse config file at path "${filePath}": ${error.message}`,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
if (json) validateBunWorkspacesConfig(json);
|
|
40
|
-
return json;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export { DEFAULT_CONFIG_FILE_PATH, loadConfigFile };
|
package/src/config/errors.d.ts
DELETED
package/src/config/errors.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { defineErrors } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
|
|
2
|
-
// CONCATENATED MODULE: ./src/config/errors.ts
|
|
3
|
-
|
|
4
|
-
const ERRORS = defineErrors(
|
|
5
|
-
"ConfigFileNotFound",
|
|
6
|
-
"InvalidConfigFile",
|
|
7
|
-
"InvalidConfigFileFormat",
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
export { ERRORS };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export type OutputStreamName = "stdout" | "stderr";
|
|
2
|
-
/** @deprecated */
|
|
3
|
-
export interface DecodeOptions {
|
|
4
|
-
/** Whether to strip ANSI escape codes */
|
|
5
|
-
stripAnsi?: boolean;
|
|
6
|
-
}
|
|
7
|
-
/** @deprecated Output captured from a script subprocess */
|
|
8
|
-
export interface OutputChunk {
|
|
9
|
-
/** The source of the output, `"stdout"` or `"stderr"` */
|
|
10
|
-
streamName: OutputStreamName;
|
|
11
|
-
/** Raw output text. Pass `true` to strip ANSI escape codes. */
|
|
12
|
-
decode(options?: DecodeOptions): string;
|
|
13
|
-
/** The raw output content */
|
|
14
|
-
raw: Uint8Array<ArrayBufferLike>;
|
|
15
|
-
/** @deprecated Use `decode()` instead */
|
|
16
|
-
text: string;
|
|
17
|
-
/** @deprecated Use `decode({ stripAnsi: true })` instead */
|
|
18
|
-
textNoAnsi: string;
|
|
19
|
-
}
|
|
20
|
-
/** @deprecated */
|
|
21
|
-
export declare const createOutputChunk: (
|
|
22
|
-
streamName: OutputStreamName,
|
|
23
|
-
raw: Uint8Array<ArrayBufferLike>,
|
|
24
|
-
) => OutputChunk;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { sanitizeAnsi } from "../internal/core/index.mjs"; // CONCATENATED MODULE: external "../internal/core/index.mjs"
|
|
2
|
-
// CONCATENATED MODULE: ./src/runScript/outputChunk.ts
|
|
3
|
-
|
|
4
|
-
/** @deprecated */ class _OutputChunk {
|
|
5
|
-
streamName;
|
|
6
|
-
raw;
|
|
7
|
-
constructor(streamName, raw) {
|
|
8
|
-
this.streamName = streamName;
|
|
9
|
-
this.raw = raw;
|
|
10
|
-
}
|
|
11
|
-
decode(options) {
|
|
12
|
-
const { stripAnsi = false } = options ?? {};
|
|
13
|
-
const text = new TextDecoder().decode(this.raw);
|
|
14
|
-
return stripAnsi ? sanitizeAnsi(text) : text;
|
|
15
|
-
}
|
|
16
|
-
/** @deprecated Use `decode()` instead */ get text() {
|
|
17
|
-
// TODO remove in future major release
|
|
18
|
-
return this.decode();
|
|
19
|
-
}
|
|
20
|
-
/** @deprecated Use `decode({ stripAnsi: true })` instead */ get textNoAnsi() {
|
|
21
|
-
// TODO remove in future major release
|
|
22
|
-
return this.decode({
|
|
23
|
-
stripAnsi: true,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/** @deprecated */ const createOutputChunk = (streamName, raw) =>
|
|
28
|
-
new _OutputChunk(streamName, raw);
|
|
29
|
-
|
|
30
|
-
export { createOutputChunk };
|