bun-workspaces 1.0.0-alpha.2 → 1.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +124 -79
  3. package/bin/cli.js +1 -2
  4. package/package.json +13 -27
  5. package/src/cli/createCli.d.ts +19 -0
  6. package/src/cli/createCli.mjs +99 -0
  7. package/src/cli/fatalErrorLogger.d.ts +1 -0
  8. package/src/cli/fatalErrorLogger.mjs +7 -0
  9. package/src/cli/globalOptions/globalOptions.d.ts +38 -0
  10. package/src/cli/globalOptions/globalOptions.mjs +120 -0
  11. package/src/cli/globalOptions/globalOptionsConfig.d.ts +43 -0
  12. package/src/cli/globalOptions/globalOptionsConfig.mjs +34 -0
  13. package/src/cli/globalOptions/index.d.ts +2 -0
  14. package/src/cli/globalOptions/index.mjs +2 -0
  15. package/src/cli/index.d.ts +3 -0
  16. package/src/cli/index.mjs +3 -0
  17. package/src/cli/projectCommands/commandHandlerUtils.d.ts +31 -0
  18. package/src/cli/projectCommands/commandHandlerUtils.mjs +52 -0
  19. package/src/cli/projectCommands/handleRunScript.d.ts +5 -0
  20. package/src/cli/projectCommands/handleRunScript.mjs +153 -0
  21. package/src/cli/projectCommands/handleSimpleCommands.d.ts +20 -0
  22. package/src/cli/projectCommands/handleSimpleCommands.mjs +131 -0
  23. package/src/cli/projectCommands/index.d.ts +2 -0
  24. package/src/cli/projectCommands/index.mjs +2 -0
  25. package/src/cli/projectCommands/projectCommands.d.ts +4 -0
  26. package/src/cli/projectCommands/projectCommands.mjs +19 -0
  27. package/src/cli/projectCommands/projectCommandsConfig.d.ts +218 -0
  28. package/src/cli/projectCommands/projectCommandsConfig.mjs +110 -0
  29. package/src/config/bunWorkspacesConfig.d.ts +17 -0
  30. package/src/config/bunWorkspacesConfig.mjs +50 -0
  31. package/src/config/configFile.d.ts +8 -0
  32. package/src/config/configFile.mjs +43 -0
  33. package/src/config/errors.d.ts +3 -0
  34. package/src/config/errors.mjs +10 -0
  35. package/src/config/{index.ts → index.d.ts} +1 -0
  36. package/src/config/index.mjs +11 -0
  37. package/src/config/workspaceConfig/errors.d.ts +3 -0
  38. package/src/config/workspaceConfig/errors.mjs +9 -0
  39. package/src/config/workspaceConfig/index.d.ts +4 -0
  40. package/src/config/workspaceConfig/index.mjs +4 -0
  41. package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +5 -0
  42. package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +82 -0
  43. package/src/config/workspaceConfig/workspaceConfig.d.ts +14 -0
  44. package/src/config/workspaceConfig/workspaceConfig.mjs +48 -0
  45. package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +2 -0
  46. package/src/config/workspaceConfig/workspaceConfigLocation.mjs +5 -0
  47. package/src/index.d.ts +23 -0
  48. package/src/index.mjs +9 -0
  49. package/src/internal/asyncIterableQueue.d.ts +15 -0
  50. package/src/internal/asyncIterableQueue.mjs +73 -0
  51. package/src/internal/bunVersion.d.ts +17 -0
  52. package/src/internal/bunVersion.mjs +28 -0
  53. package/src/internal/env.d.ts +5 -0
  54. package/src/internal/env.mjs +29 -0
  55. package/src/internal/error.d.ts +9 -0
  56. package/src/internal/{error.ts → error.mjs} +7 -16
  57. package/src/internal/json.d.ts +9 -0
  58. package/src/internal/json.mjs +6 -0
  59. package/src/internal/logger.d.ts +44 -0
  60. package/src/internal/logger.mjs +110 -0
  61. package/src/internal/mergeAsyncIterables.d.ts +5 -0
  62. package/src/internal/mergeAsyncIterables.mjs +27 -0
  63. package/src/internal/optionalArray.d.ts +15 -0
  64. package/src/internal/optionalArray.mjs +8 -0
  65. package/src/internal/os.d.ts +4 -0
  66. package/src/internal/os.mjs +7 -0
  67. package/src/internal/regex.d.ts +3 -0
  68. package/src/internal/regex.mjs +10 -0
  69. package/src/internal/types.d.ts +6 -0
  70. package/src/internal/types.mjs +3 -0
  71. package/src/project/errors.d.ts +3 -0
  72. package/src/project/errors.mjs +9 -0
  73. package/src/project/implementations/fileSystemProject.d.ts +88 -0
  74. package/src/project/implementations/fileSystemProject.mjs +152 -0
  75. package/src/project/implementations/memoryProject.d.ts +32 -0
  76. package/src/project/implementations/memoryProject.mjs +46 -0
  77. package/src/project/implementations/projectBase.d.ts +27 -0
  78. package/src/project/implementations/projectBase.mjs +97 -0
  79. package/src/project/index.d.ts +6 -0
  80. package/src/project/index.mjs +5 -0
  81. package/src/project/project.d.ts +64 -0
  82. package/src/project/project.mjs +6 -0
  83. package/src/project/runScript/index.d.ts +3 -0
  84. package/src/project/runScript/index.mjs +3 -0
  85. package/src/project/runScript/runScript.d.ts +41 -0
  86. package/src/project/runScript/runScript.mjs +63 -0
  87. package/src/project/runScript/runScripts.d.ts +47 -0
  88. package/src/project/runScript/runScripts.mjs +95 -0
  89. package/src/project/runScript/scriptCommand.d.ts +33 -0
  90. package/src/project/runScript/scriptCommand.mjs +19 -0
  91. package/src/project/runScript/scriptRuntimeMetadata.d.ts +73 -0
  92. package/src/project/runScript/scriptRuntimeMetadata.mjs +56 -0
  93. package/src/workspaces/errors.d.ts +12 -0
  94. package/src/workspaces/{errors.ts → errors.mjs} +5 -2
  95. package/src/workspaces/findWorkspaces.d.ts +20 -0
  96. package/src/workspaces/findWorkspaces.mjs +147 -0
  97. package/src/workspaces/index.d.ts +4 -0
  98. package/src/workspaces/index.mjs +3 -0
  99. package/src/workspaces/packageJson.d.ts +15 -0
  100. package/src/workspaces/packageJson.mjs +134 -0
  101. package/src/workspaces/{workspace.ts → workspace.d.ts} +5 -6
  102. package/src/workspaces/workspace.mjs +2 -0
  103. package/bun.lock +0 -576
  104. package/src/cli/cli.ts +0 -87
  105. package/src/cli/globalOptions.ts +0 -122
  106. package/src/cli/index.ts +0 -1
  107. package/src/cli/projectCommands.ts +0 -390
  108. package/src/config/bunWorkspacesConfig.ts +0 -62
  109. package/src/config/configFile.ts +0 -33
  110. package/src/index.ts +0 -3
  111. package/src/internal/bunVersion.ts +0 -26
  112. package/src/internal/env.ts +0 -25
  113. package/src/internal/logger.ts +0 -187
  114. package/src/internal/regex.ts +0 -5
  115. package/src/project/errors.ts +0 -6
  116. package/src/project/index.ts +0 -6
  117. package/src/project/project.ts +0 -155
  118. package/src/project/scriptCommand.ts +0 -40
  119. package/src/workspaces/findWorkspaces.ts +0 -137
  120. package/src/workspaces/index.ts +0 -7
  121. package/src/workspaces/packageJson.ts +0 -166
  122. package/tsconfig.json +0 -28
@@ -0,0 +1,34 @@
1
+ import { LOG_LEVELS } from "../../internal/logger.mjs"; // CONCATENATED MODULE: external "../../internal/logger.mjs"
2
+ // CONCATENATED MODULE: ./src/cli/globalOptions/globalOptionsConfig.ts
3
+
4
+ const CLI_GLOBAL_OPTIONS_CONFIG = {
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
+ configFile: {
22
+ mainOption: "--config-file",
23
+ shortOption: "-c",
24
+ description: "(DEPRECATED) Config file",
25
+ defaultValue: "",
26
+ values: null,
27
+ param: "path",
28
+ },
29
+ };
30
+ const getCliGlobalOptionConfig = (optionName) =>
31
+ CLI_GLOBAL_OPTIONS_CONFIG[optionName];
32
+ const getCliGlobalOptionNames = () => Object.keys(CLI_GLOBAL_OPTIONS_CONFIG);
33
+
34
+ export { getCliGlobalOptionConfig, getCliGlobalOptionNames };
@@ -0,0 +1,2 @@
1
+ export * from "./globalOptionsConfig";
2
+ export * from "./globalOptions";
@@ -0,0 +1,2 @@
1
+ export * from "./globalOptionsConfig.mjs";
2
+ export * from "./globalOptions.mjs"; // CONCATENATED MODULE: ./src/cli/globalOptions/index.ts
@@ -0,0 +1,3 @@
1
+ export * from "./createCli";
2
+ export * from "./projectCommands";
3
+ export * from "./globalOptions";
@@ -0,0 +1,3 @@
1
+ export * from "./createCli.mjs";
2
+ export * from "./projectCommands/index.mjs";
3
+ export * from "./globalOptions/index.mjs"; // CONCATENATED MODULE: ./src/cli/index.ts
@@ -0,0 +1,31 @@
1
+ import { type Command } from "commander";
2
+ import type { FileSystemProject } from "../../project/implementations/fileSystemProject";
3
+ import type { Workspace } from "../../workspaces";
4
+ import { type CliProjectCommandName } from "./projectCommandsConfig";
5
+ /** @todo DRY use of output text in cases such as having no workspaces/scripts */
6
+ export interface ProjectCommandContext {
7
+ project: FileSystemProject;
8
+ projectError: Error | null;
9
+ program: Command;
10
+ }
11
+ export declare const createWorkspaceInfoLines: (
12
+ workspace: Workspace,
13
+ ) => string[];
14
+ export declare const createScriptInfoLines: (
15
+ script: string,
16
+ workspaces: Workspace[],
17
+ ) => string[];
18
+ export declare const createJsonLines: (
19
+ data: unknown,
20
+ options: {
21
+ pretty: boolean;
22
+ },
23
+ ) => string[];
24
+ export declare const commandOutputLogger: import("../../internal/logger").Logger;
25
+ export declare const handleCommand: <T extends unknown[]>(
26
+ commandName: CliProjectCommandName,
27
+ handler: (
28
+ context: Omit<ProjectCommandContext, "projectError">,
29
+ ...actionArgs: T
30
+ ) => void,
31
+ ) => ({ program, project, projectError }: ProjectCommandContext) => Command;
@@ -0,0 +1,52 @@
1
+ import { createLogger } from "../../internal/logger.mjs";
2
+ import { getProjectCommandConfig } from "./projectCommandsConfig.mjs"; // CONCATENATED MODULE: external "../../internal/logger.mjs"
3
+ // CONCATENATED MODULE: external "./projectCommandsConfig.mjs"
4
+ // CONCATENATED MODULE: ./src/cli/projectCommands/commandHandlerUtils.ts
5
+
6
+ const createWorkspaceInfoLines = (workspace) => [
7
+ `Workspace: ${workspace.name}`,
8
+ ` - Aliases: ${workspace.aliases.join(", ")}`,
9
+ ` - Path: ${workspace.path}`,
10
+ ` - Glob Match: ${workspace.matchPattern}`,
11
+ ` - Scripts: ${workspace.scripts.join(", ")}`,
12
+ ];
13
+ const createScriptInfoLines = (script, workspaces) => [
14
+ `Script: ${script}`,
15
+ ...workspaces.map((workspace) => ` - ${workspace.name}`),
16
+ ];
17
+ const createJsonLines = (data, options) =>
18
+ JSON.stringify(data, null, options.pretty ? 2 : undefined).split("\n");
19
+ const commandOutputLogger = createLogger("");
20
+ commandOutputLogger.printLevel = "info";
21
+ const handleCommand = (commandName, handler) => {
22
+ const config = getProjectCommandConfig(commandName);
23
+ return ({ program, project, projectError }) => {
24
+ program = program
25
+ .command(config.command)
26
+ .aliases(config.aliases)
27
+ .description(config.description);
28
+ for (const option of Object.values(config.options)) {
29
+ program.option(option.flags, option.description);
30
+ }
31
+ if (!projectError) {
32
+ program = program.action((...actionArgs) =>
33
+ handler(
34
+ {
35
+ program,
36
+ project,
37
+ },
38
+ ...actionArgs,
39
+ ),
40
+ );
41
+ }
42
+ return program;
43
+ };
44
+ };
45
+
46
+ export {
47
+ commandOutputLogger,
48
+ createJsonLines,
49
+ createScriptInfoLines,
50
+ createWorkspaceInfoLines,
51
+ handleCommand,
52
+ };
@@ -0,0 +1,5 @@
1
+ export declare const runScript: ({
2
+ program,
3
+ project,
4
+ projectError,
5
+ }: import("./commandHandlerUtils").ProjectCommandContext) => import("commander").Command;
@@ -0,0 +1,153 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { logger } from "../../internal/logger.mjs";
4
+ import { commandOutputLogger, handleCommand } from "./commandHandlerUtils.mjs"; // CONCATENATED MODULE: external "fs"
5
+ // CONCATENATED MODULE: external "path"
6
+ // CONCATENATED MODULE: external "../../internal/logger.mjs"
7
+ // CONCATENATED MODULE: external "./commandHandlerUtils.mjs"
8
+ // CONCATENATED MODULE: ./src/cli/projectCommands/handleRunScript.ts
9
+
10
+ const runScript = handleCommand(
11
+ "runScript",
12
+ async ({ project }, script, _workspaces, options) => {
13
+ logger.debug(
14
+ `Command: Run script ${JSON.stringify(script)} for ${_workspaces.length ? "workspaces " + _workspaces.join(", ") : "all workspaces"} (parallel: ${!!options.parallel}, args: ${JSON.stringify(options.args)})`,
15
+ );
16
+ const workspaces = _workspaces.length
17
+ ? _workspaces
18
+ .flatMap((workspacePattern) => {
19
+ if (workspacePattern.includes("*")) {
20
+ return project
21
+ .findWorkspacesByPattern(workspacePattern)
22
+ .filter(
23
+ (workspace) =>
24
+ options.inline || workspace.scripts.includes(script),
25
+ )
26
+ .map(({ name }) => name);
27
+ }
28
+ return [workspacePattern];
29
+ })
30
+ .map((workspaceName) => {
31
+ const workspace = project.findWorkspaceByNameOrAlias(workspaceName);
32
+ if (!workspace) {
33
+ logger.error(
34
+ `Workspace name or alias not found: ${JSON.stringify(workspaceName)}`,
35
+ );
36
+ process.exit(1);
37
+ }
38
+ return workspace;
39
+ })
40
+ .filter(Boolean)
41
+ : options.inline
42
+ ? project.workspaces
43
+ : project.listWorkspacesWithScript(script);
44
+ if (!workspaces.length) {
45
+ if (_workspaces.length === 1 && !_workspaces[0].includes("*")) {
46
+ logger.error(`Workspace not found: ${JSON.stringify(_workspaces[0])}`);
47
+ } else {
48
+ logger.error(
49
+ `No ${_workspaces.length ? "matching " : ""}workspaces found${options.inline ? " in the project" : " with script " + JSON.stringify(script)}`,
50
+ );
51
+ }
52
+ process.exit(1);
53
+ }
54
+ if (
55
+ !options.inline &&
56
+ !workspaces.some((workspace) => workspace.scripts.includes(script))
57
+ ) {
58
+ logger.error(
59
+ `Script not found in target workspace${workspaces.length === 1 ? "" : "s"}: ${JSON.stringify(script)}`,
60
+ );
61
+ process.exit(1);
62
+ }
63
+ workspaces.sort((a, b) => a.path.localeCompare(b.path));
64
+ const { output, summary } = project.runScriptAcrossWorkspaces({
65
+ workspacePatterns: workspaces.map(({ name }) => name),
66
+ script,
67
+ inline: options.inline,
68
+ args: options.args,
69
+ parallel: !!options.parallel,
70
+ });
71
+ const scriptName = options.inline ? "(inline)" : script;
72
+ const handleOutput = async () => {
73
+ if (logger.printLevel === "silent") return;
74
+ for await (const { outputChunk, scriptMetadata } of output) {
75
+ commandOutputLogger.logOutput(
76
+ outputChunk.text,
77
+ "info",
78
+ process[outputChunk.streamName],
79
+ options.prefix
80
+ ? `[${scriptMetadata.workspace.name}:${scriptName}] `
81
+ : "",
82
+ );
83
+ }
84
+ };
85
+ handleOutput();
86
+ const exitResults = await summary;
87
+ exitResults.scriptResults.forEach(
88
+ ({ success, metadata: { workspace }, exitCode }) => {
89
+ logger.info(
90
+ `${success ? "✅" : "❌"} ${workspace.name}: ${scriptName}${exitCode ? ` (exited with code ${exitCode})` : ""}`,
91
+ );
92
+ },
93
+ );
94
+ const s = exitResults.scriptResults.length === 1 ? "" : "s";
95
+ if (exitResults.failureCount) {
96
+ const message = `${exitResults.failureCount} of ${exitResults.scriptResults.length} script${s} failed`;
97
+ logger.info(message);
98
+ } else {
99
+ logger.info(
100
+ `${exitResults.scriptResults.length} script${s} ran successfully`,
101
+ );
102
+ }
103
+ if (options.jsonOutfile) {
104
+ const fullOutputPath = path.resolve(
105
+ project.rootDirectory,
106
+ options.jsonOutfile,
107
+ );
108
+ // Check if can make directory
109
+ const jsonOutputDir = path.dirname(fullOutputPath);
110
+ if (!fs.existsSync(jsonOutputDir)) {
111
+ try {
112
+ fs.mkdirSync(jsonOutputDir, {
113
+ recursive: true,
114
+ });
115
+ } catch (error) {
116
+ logger.error(
117
+ `Failed to create JSON output file directory "${jsonOutputDir}": ${error}`,
118
+ );
119
+ process.exit(1);
120
+ }
121
+ } else if (fs.statSync(jsonOutputDir).isFile()) {
122
+ logger.error(
123
+ `Given JSON output file directory "${jsonOutputDir}" is an existing file`,
124
+ );
125
+ process.exit(1);
126
+ }
127
+ // Check if can make file
128
+ if (
129
+ fs.existsSync(fullOutputPath) &&
130
+ fs.statSync(fullOutputPath).isDirectory()
131
+ ) {
132
+ logger.error(
133
+ `Given JSON output file path "${fullOutputPath}" is an existing directory`,
134
+ );
135
+ process.exit(1);
136
+ }
137
+ try {
138
+ fs.writeFileSync(fullOutputPath, JSON.stringify(exitResults, null, 2));
139
+ } catch (error) {
140
+ logger.error(
141
+ `Failed to write JSON output file "${fullOutputPath}": ${error}`,
142
+ );
143
+ process.exit(1);
144
+ }
145
+ logger.info(`JSON output written to ${fullOutputPath}`);
146
+ }
147
+ if (exitResults.failureCount) {
148
+ process.exit(1);
149
+ }
150
+ },
151
+ );
152
+
153
+ export { runScript };
@@ -0,0 +1,20 @@
1
+ export declare const listWorkspaces: ({
2
+ program,
3
+ project,
4
+ projectError,
5
+ }: import("./commandHandlerUtils").ProjectCommandContext) => import("commander").Command;
6
+ export declare const listScripts: ({
7
+ program,
8
+ project,
9
+ projectError,
10
+ }: import("./commandHandlerUtils").ProjectCommandContext) => import("commander").Command;
11
+ export declare const workspaceInfo: ({
12
+ program,
13
+ project,
14
+ projectError,
15
+ }: import("./commandHandlerUtils").ProjectCommandContext) => import("commander").Command;
16
+ export declare const scriptInfo: ({
17
+ program,
18
+ project,
19
+ projectError,
20
+ }: import("./commandHandlerUtils").ProjectCommandContext) => import("commander").Command;
@@ -0,0 +1,131 @@
1
+ import { logger } from "../../internal/logger.mjs";
2
+ import {
3
+ commandOutputLogger,
4
+ createJsonLines,
5
+ createScriptInfoLines,
6
+ createWorkspaceInfoLines,
7
+ handleCommand,
8
+ } from "./commandHandlerUtils.mjs"; // CONCATENATED MODULE: external "../../internal/logger.mjs"
9
+ // CONCATENATED MODULE: external "./commandHandlerUtils.mjs"
10
+ // CONCATENATED MODULE: ./src/cli/projectCommands/handleSimpleCommands.ts
11
+
12
+ const listWorkspaces = handleCommand(
13
+ "listWorkspaces",
14
+ ({ project }, pattern, options) => {
15
+ logger.debug(
16
+ `Command: List workspaces (options: ${JSON.stringify(options)})`,
17
+ );
18
+ const lines = [];
19
+ const workspaces = pattern
20
+ ? project.findWorkspacesByPattern(pattern)
21
+ : project.workspaces;
22
+ if (options.json) {
23
+ lines.push(
24
+ ...createJsonLines(
25
+ options.nameOnly ? workspaces.map(({ name }) => name) : workspaces,
26
+ options,
27
+ ),
28
+ );
29
+ } else {
30
+ workspaces.forEach((workspace) => {
31
+ if (options.nameOnly) {
32
+ lines.push(workspace.name);
33
+ } else {
34
+ lines.push(...createWorkspaceInfoLines(workspace));
35
+ }
36
+ });
37
+ }
38
+ if (!lines.length && !options.nameOnly) {
39
+ logger.info("No workspaces found");
40
+ }
41
+ if (lines.length) commandOutputLogger.info(lines.join("\n"));
42
+ },
43
+ );
44
+ const listScripts = handleCommand("listScripts", ({ project }, options) => {
45
+ logger.debug(`Command: List scripts (options: ${JSON.stringify(options)})`);
46
+ const scripts = project.mapScriptsToWorkspaces();
47
+ const lines = [];
48
+ if (!project.workspaces.length && !options.nameOnly) {
49
+ logger.info("No workspaces found");
50
+ return;
51
+ }
52
+ if (!Object.keys(scripts).length && !options.nameOnly) {
53
+ logger.info("No scripts found");
54
+ return;
55
+ }
56
+ if (options.json) {
57
+ lines.push(
58
+ ...createJsonLines(
59
+ options.nameOnly
60
+ ? Object.keys(scripts)
61
+ : Object.values(scripts).map(({ workspaces, ...rest }) => ({
62
+ ...rest,
63
+ workspaces: workspaces.map(({ name }) => name),
64
+ })),
65
+ options,
66
+ ),
67
+ );
68
+ } else {
69
+ Object.values(scripts)
70
+ .sort(({ name: nameA }, { name: nameB }) => nameA.localeCompare(nameB))
71
+ .forEach(({ name, workspaces }) => {
72
+ if (options.nameOnly) {
73
+ lines.push(name);
74
+ } else {
75
+ lines.push(...createScriptInfoLines(name, workspaces));
76
+ }
77
+ });
78
+ }
79
+ if (lines.length) commandOutputLogger.info(lines.join("\n"));
80
+ });
81
+ const workspaceInfo = handleCommand(
82
+ "workspaceInfo",
83
+ ({ project }, workspaceName, options) => {
84
+ logger.debug(
85
+ `Command: Workspace info for ${workspaceName} (options: ${JSON.stringify(options)})`,
86
+ );
87
+ const workspace = project.findWorkspaceByNameOrAlias(workspaceName);
88
+ if (!workspace) {
89
+ logger.error(`Workspace ${JSON.stringify(workspaceName)} not found`);
90
+ process.exit(1);
91
+ }
92
+ commandOutputLogger.info(
93
+ (options.json
94
+ ? createJsonLines(workspace, options)
95
+ : createWorkspaceInfoLines(workspace)
96
+ ).join("\n"),
97
+ );
98
+ },
99
+ );
100
+ const scriptInfo = handleCommand(
101
+ "scriptInfo",
102
+ ({ project }, script, options) => {
103
+ logger.debug(
104
+ `Command: Script info for ${script} (options: ${JSON.stringify(options)})`,
105
+ );
106
+ const scripts = project.mapScriptsToWorkspaces();
107
+ const scriptMetadata = scripts[script];
108
+ if (!scriptMetadata) {
109
+ logger.error(`Script not found: ${JSON.stringify(script)}`);
110
+ process.exit(1);
111
+ }
112
+ commandOutputLogger.info(
113
+ (options.json
114
+ ? createJsonLines(
115
+ options.workspacesOnly
116
+ ? scriptMetadata.workspaces.map(({ name }) => name)
117
+ : {
118
+ name: scriptMetadata.name,
119
+ workspaces: scriptMetadata.workspaces.map(({ name }) => name),
120
+ },
121
+ options,
122
+ )
123
+ : options.workspacesOnly
124
+ ? scriptMetadata.workspaces.map(({ name }) => name)
125
+ : createScriptInfoLines(script, scriptMetadata.workspaces)
126
+ ).join("\n"),
127
+ );
128
+ },
129
+ );
130
+
131
+ export { listScripts, listWorkspaces, scriptInfo, workspaceInfo };
@@ -0,0 +1,2 @@
1
+ export * from "./projectCommands";
2
+ export * from "./projectCommandsConfig";
@@ -0,0 +1,2 @@
1
+ export * from "./projectCommands.mjs";
2
+ export * from "./projectCommandsConfig.mjs"; // CONCATENATED MODULE: ./src/cli/projectCommands/index.ts
@@ -0,0 +1,4 @@
1
+ import type { ProjectCommandContext } from "./commandHandlerUtils";
2
+ export declare const defineProjectCommands: (
3
+ context: ProjectCommandContext,
4
+ ) => void;
@@ -0,0 +1,19 @@
1
+ import { runScript } from "./handleRunScript.mjs";
2
+ import {
3
+ listScripts,
4
+ listWorkspaces,
5
+ scriptInfo,
6
+ workspaceInfo,
7
+ } from "./handleSimpleCommands.mjs"; // CONCATENATED MODULE: external "./handleRunScript.mjs"
8
+ // CONCATENATED MODULE: external "./handleSimpleCommands.mjs"
9
+ // CONCATENATED MODULE: ./src/cli/projectCommands/projectCommands.ts
10
+
11
+ const defineProjectCommands = (context) => {
12
+ listWorkspaces(context);
13
+ listScripts(context);
14
+ workspaceInfo(context);
15
+ scriptInfo(context);
16
+ runScript(context);
17
+ };
18
+
19
+ export { defineProjectCommands };