bun-workspaces 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +13 -4
- package/src/ai/mcp/bwMcpServer.d.ts +4 -0
- package/src/ai/mcp/bwMcpServer.mjs +46 -0
- package/src/ai/mcp/core/index.d.ts +3 -0
- package/src/ai/mcp/core/index.mjs +3 -0
- package/src/ai/mcp/core/server.d.ts +14 -0
- package/src/ai/mcp/core/server.mjs +169 -0
- package/src/ai/mcp/core/transport.d.ts +12 -0
- package/src/ai/mcp/core/transport.mjs +45 -0
- package/src/ai/mcp/core/types.d.ts +104 -0
- package/src/ai/mcp/core/types.mjs +11 -0
- package/src/ai/mcp/index.d.ts +2 -0
- package/src/ai/mcp/index.mjs +2 -0
- package/src/ai/mcp/resources.d.ts +6 -0
- package/src/ai/mcp/resources.mjs +98 -0
- package/src/ai/mcp/tools.d.ts +6 -0
- package/src/ai/mcp/tools.mjs +210 -0
- package/src/cli/commands/commandHandlerUtils.mjs +1 -0
- package/src/cli/commands/commands.mjs +3 -0
- package/src/cli/commands/commandsConfig.d.ts +14 -0
- package/src/cli/commands/commandsConfig.mjs +8 -0
- package/src/cli/commands/handleSimpleCommands.mjs +4 -0
- package/src/cli/commands/index.d.ts +1 -0
- package/src/cli/commands/index.mjs +1 -0
- package/src/cli/commands/mcp.d.ts +3 -0
- package/src/cli/commands/mcp.mjs +13 -0
- package/src/cli/commands/runScript/handleRunScript.mjs +8 -0
- package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +4 -2
- package/src/cli/createCli.mjs +1 -0
- package/src/config/public.d.ts +3 -0
- package/src/config/workspaceConfig/workspaceConfig.d.ts +13 -0
- package/src/config/workspaceConfig/workspaceConfig.mjs +11 -1
- package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +24 -0
- package/src/config/workspaceConfig/workspaceConfigSchema.mjs +24 -0
- package/src/internal/docs/apiQuickstart.d.ts +3 -0
- package/src/internal/docs/apiQuickstart.mjs +132 -0
- package/src/internal/docs/cliQuickstart.d.ts +2 -0
- package/src/internal/docs/cliQuickstart.mjs +86 -0
- package/src/internal/docs/index.d.ts +2 -0
- package/src/internal/docs/index.mjs +2 -0
- package/src/internal/generated/aiDocs/.gitkeep.mjs +0 -0
- package/src/internal/generated/aiDocs/docs.d.ts +10 -0
- package/src/internal/generated/aiDocs/docs.mjs +285 -0
- package/src/internal/generated/ajv/validateWorkspaceConfig.mjs +1 -1
- package/src/runScript/subprocesses.mjs +1 -0
- package/src/workspaces/dependencyGraph/index.d.ts +1 -0
- package/src/workspaces/dependencyGraph/index.mjs +2 -1
- package/src/workspaces/dependencyGraph/validateDependencyRules.d.ts +7 -0
- package/src/workspaces/dependencyGraph/validateDependencyRules.mjs +66 -0
- package/src/workspaces/errors.d.ts +1 -0
- package/src/workspaces/errors.mjs +1 -0
- package/src/workspaces/findWorkspaces.d.ts +1 -1
- package/src/workspaces/findWorkspaces.mjs +8 -2
- package/src/workspaces/workspacePattern.d.ts +1 -0
- package/src/workspaces/workspacePattern.mjs +8 -4
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { getDoctorInfo } from "../../doctor/index.mjs";
|
|
2
|
+
import { BUN_WORKSPACES_VERSION } from "../../internal/version.mjs";
|
|
3
|
+
import { ROOT_WORKSPACE_SELECTOR } from "../../project/implementations/projectBase.mjs"; // CONCATENATED MODULE: external "../../doctor/index.mjs"
|
|
4
|
+
// CONCATENATED MODULE: external "../../internal/version.mjs"
|
|
5
|
+
// CONCATENATED MODULE: external "../../project/implementations/projectBase.mjs"
|
|
6
|
+
// CONCATENATED MODULE: ./src/ai/mcp/tools.ts
|
|
7
|
+
|
|
8
|
+
const textResult = (data) => ({
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
type: "text",
|
|
12
|
+
text: JSON.stringify(data, null, 2),
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
});
|
|
16
|
+
const errorResult = (message) => ({
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: "text",
|
|
20
|
+
text: message,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
isError: true,
|
|
24
|
+
});
|
|
25
|
+
const registerBwTools = (server, project) => {
|
|
26
|
+
server.registerTool(
|
|
27
|
+
{
|
|
28
|
+
name: "version",
|
|
29
|
+
description: "Get the version of bun-workspaces used by this MCP server",
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
() =>
|
|
35
|
+
textResult({
|
|
36
|
+
version: BUN_WORKSPACES_VERSION,
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
server.registerTool(
|
|
40
|
+
{
|
|
41
|
+
name: "list_workspaces",
|
|
42
|
+
description:
|
|
43
|
+
"List workspaces in the project. Optionally filter by workspace patterns (name, alias, path glob, or tag).",
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
patterns: {
|
|
48
|
+
type: "array",
|
|
49
|
+
items: {
|
|
50
|
+
type: "string",
|
|
51
|
+
},
|
|
52
|
+
description:
|
|
53
|
+
'Workspace patterns to match. Examples: "my-workspace", "name:api-*", "alias:my-alias", "path:packages/**/*", "tag:backend", "@root"',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
({ patterns }) => {
|
|
59
|
+
const workspaces =
|
|
60
|
+
patterns && Array.isArray(patterns) && patterns.length > 0
|
|
61
|
+
? project.findWorkspacesByPattern(...patterns)
|
|
62
|
+
: project.workspaces;
|
|
63
|
+
return textResult(workspaces);
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
server.registerTool(
|
|
67
|
+
{
|
|
68
|
+
name: "workspace_info",
|
|
69
|
+
description:
|
|
70
|
+
'Get detailed information about a single workspace by its name or alias. Use "@root" for the root workspace.',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
nameOrAlias: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description:
|
|
77
|
+
'The workspace name, alias, or "@root" for the root workspace',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
required: ["nameOrAlias"],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
({ nameOrAlias }) => {
|
|
84
|
+
const name = nameOrAlias;
|
|
85
|
+
const workspace =
|
|
86
|
+
name === ROOT_WORKSPACE_SELECTOR
|
|
87
|
+
? project.rootWorkspace
|
|
88
|
+
: project.findWorkspaceByNameOrAlias(name);
|
|
89
|
+
if (!workspace) {
|
|
90
|
+
return errorResult(`Workspace not found: "${name}"`);
|
|
91
|
+
}
|
|
92
|
+
return textResult(workspace);
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
server.registerTool(
|
|
96
|
+
{
|
|
97
|
+
name: "root_info",
|
|
98
|
+
description: "Get information about the root workspace",
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: "object",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
() => textResult(project.rootWorkspace),
|
|
104
|
+
);
|
|
105
|
+
server.registerTool(
|
|
106
|
+
{
|
|
107
|
+
name: "list_scripts",
|
|
108
|
+
description:
|
|
109
|
+
"List all scripts available across the project, with the workspaces that have each script.",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
() => {
|
|
115
|
+
const scriptMap = project.mapScriptsToWorkspaces();
|
|
116
|
+
const scripts = Object.values(scriptMap).map(({ name, workspaces }) => ({
|
|
117
|
+
name,
|
|
118
|
+
workspaces: workspaces.map((w) => w.name),
|
|
119
|
+
}));
|
|
120
|
+
return textResult(scripts);
|
|
121
|
+
},
|
|
122
|
+
);
|
|
123
|
+
server.registerTool(
|
|
124
|
+
{
|
|
125
|
+
name: "script_info",
|
|
126
|
+
description:
|
|
127
|
+
"Get information about a specific script, including all workspaces that have it in their package.json.",
|
|
128
|
+
inputSchema: {
|
|
129
|
+
type: "object",
|
|
130
|
+
properties: {
|
|
131
|
+
script: {
|
|
132
|
+
type: "string",
|
|
133
|
+
description: "The script name to look up",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
required: ["script"],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
({ script }) => {
|
|
140
|
+
const scriptMap = project.mapScriptsToWorkspaces();
|
|
141
|
+
const scriptMetadata = scriptMap[script];
|
|
142
|
+
if (!scriptMetadata) {
|
|
143
|
+
return errorResult(`Script not found: "${script}"`);
|
|
144
|
+
}
|
|
145
|
+
return textResult({
|
|
146
|
+
name: scriptMetadata.name,
|
|
147
|
+
workspaces: scriptMetadata.workspaces.map((w) => w.name),
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
);
|
|
151
|
+
server.registerTool(
|
|
152
|
+
{
|
|
153
|
+
name: "list_tags",
|
|
154
|
+
description:
|
|
155
|
+
"List all tags defined across workspaces, with the workspaces that have each tag.",
|
|
156
|
+
inputSchema: {
|
|
157
|
+
type: "object",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
() => {
|
|
161
|
+
const tagMap = project.mapTagsToWorkspaces();
|
|
162
|
+
const tags = Object.entries(tagMap).map(([tag, workspaces]) => ({
|
|
163
|
+
tag,
|
|
164
|
+
workspaces: workspaces.map((w) => w.name),
|
|
165
|
+
}));
|
|
166
|
+
return textResult(tags);
|
|
167
|
+
},
|
|
168
|
+
);
|
|
169
|
+
server.registerTool(
|
|
170
|
+
{
|
|
171
|
+
name: "tag_info",
|
|
172
|
+
description:
|
|
173
|
+
"Get information about a specific tag, including all workspaces that have it.",
|
|
174
|
+
inputSchema: {
|
|
175
|
+
type: "object",
|
|
176
|
+
properties: {
|
|
177
|
+
tag: {
|
|
178
|
+
type: "string",
|
|
179
|
+
description: "The tag name to look up",
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
required: ["tag"],
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
({ tag }) => {
|
|
186
|
+
const tagMap = project.mapTagsToWorkspaces();
|
|
187
|
+
const tagWorkspaces = tagMap[tag];
|
|
188
|
+
if (!tagWorkspaces) {
|
|
189
|
+
return errorResult(`Tag not found: "${tag}"`);
|
|
190
|
+
}
|
|
191
|
+
return textResult({
|
|
192
|
+
name: tag,
|
|
193
|
+
workspaces: tagWorkspaces.map((w) => w.name),
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
);
|
|
197
|
+
server.registerTool(
|
|
198
|
+
{
|
|
199
|
+
name: "doctor",
|
|
200
|
+
description:
|
|
201
|
+
"Get diagnostic information about the bun-workspaces installation: version, Bun version, OS, and environment.",
|
|
202
|
+
inputSchema: {
|
|
203
|
+
type: "object",
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
() => textResult(getDoctorInfo()),
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
export { registerBwTools };
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
tagInfo,
|
|
8
8
|
workspaceInfo,
|
|
9
9
|
} from "./handleSimpleCommands.mjs";
|
|
10
|
+
import { mcpServer } from "./mcp.mjs";
|
|
10
11
|
import { runScript } from "./runScript/index.mjs"; // CONCATENATED MODULE: external "./handleSimpleCommands.mjs"
|
|
12
|
+
// CONCATENATED MODULE: external "./mcp.mjs"
|
|
11
13
|
// CONCATENATED MODULE: external "./runScript/index.mjs"
|
|
12
14
|
// CONCATENATED MODULE: ./src/cli/commands/commands.ts
|
|
13
15
|
|
|
@@ -21,6 +23,7 @@ const defineProjectCommands = (context) => {
|
|
|
21
23
|
scriptInfo(context);
|
|
22
24
|
listTags(context);
|
|
23
25
|
tagInfo(context);
|
|
26
|
+
mcpServer(context);
|
|
24
27
|
runScript(context);
|
|
25
28
|
};
|
|
26
29
|
|
|
@@ -159,6 +159,13 @@ export declare const CLI_COMMANDS_CONFIG: {
|
|
|
159
159
|
};
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
|
+
readonly mcpServer: {
|
|
163
|
+
readonly command: "mcp-server";
|
|
164
|
+
readonly isGlobal: false;
|
|
165
|
+
readonly aliases: [];
|
|
166
|
+
readonly description: "Start the bun-workspaces MCP (Model Context Protocol) server over stdio";
|
|
167
|
+
readonly options: {};
|
|
168
|
+
};
|
|
162
169
|
readonly runScript: {
|
|
163
170
|
readonly command: "run-script [script] [workspacePatterns...]";
|
|
164
171
|
readonly isGlobal: false;
|
|
@@ -356,6 +363,13 @@ export declare const getCliCommandConfig: (commandName: CliCommandName) =>
|
|
|
356
363
|
};
|
|
357
364
|
};
|
|
358
365
|
}
|
|
366
|
+
| {
|
|
367
|
+
readonly command: "mcp-server";
|
|
368
|
+
readonly isGlobal: false;
|
|
369
|
+
readonly aliases: [];
|
|
370
|
+
readonly description: "Start the bun-workspaces MCP (Model Context Protocol) server over stdio";
|
|
371
|
+
readonly options: {};
|
|
372
|
+
}
|
|
359
373
|
| {
|
|
360
374
|
readonly command: "run-script [script] [workspacePatterns...]";
|
|
361
375
|
readonly isGlobal: false;
|
|
@@ -137,6 +137,14 @@ const CLI_COMMANDS_CONFIG = {
|
|
|
137
137
|
},
|
|
138
138
|
},
|
|
139
139
|
},
|
|
140
|
+
mcpServer: {
|
|
141
|
+
command: "mcp-server",
|
|
142
|
+
isGlobal: false,
|
|
143
|
+
aliases: [],
|
|
144
|
+
description:
|
|
145
|
+
"Start the bun-workspaces MCP (Model Context Protocol) server over stdio",
|
|
146
|
+
options: {},
|
|
147
|
+
},
|
|
140
148
|
runScript: {
|
|
141
149
|
command: "run-script [script] [workspacePatterns...]",
|
|
142
150
|
isGlobal: false,
|
|
@@ -53,6 +53,7 @@ const listWorkspaces = handleProjectCommand(
|
|
|
53
53
|
"CLI syntax error: Cannot use both inline workspace patterns and --workspace-patterns|-W option",
|
|
54
54
|
);
|
|
55
55
|
process.exit(1);
|
|
56
|
+
return;
|
|
56
57
|
}
|
|
57
58
|
const patterns = positionalWorkspacePatterns?.length
|
|
58
59
|
? positionalWorkspacePatterns
|
|
@@ -133,6 +134,7 @@ const workspaceInfo = handleProjectCommand(
|
|
|
133
134
|
if (!workspace) {
|
|
134
135
|
logger.error(`Workspace ${JSON.stringify(workspaceName)} not found`);
|
|
135
136
|
process.exit(1);
|
|
137
|
+
return;
|
|
136
138
|
}
|
|
137
139
|
commandOutputLogger.info(
|
|
138
140
|
(options.json
|
|
@@ -151,6 +153,7 @@ const scriptInfo = handleProjectCommand(
|
|
|
151
153
|
if (!scriptMetadata) {
|
|
152
154
|
logger.error(`Script not found: ${JSON.stringify(script)}`);
|
|
153
155
|
process.exit(1);
|
|
156
|
+
return;
|
|
154
157
|
}
|
|
155
158
|
commandOutputLogger.info(
|
|
156
159
|
(options.json
|
|
@@ -211,6 +214,7 @@ const handleSimpleCommands_tagInfo = handleProjectCommand(
|
|
|
211
214
|
if (!tagMetadata) {
|
|
212
215
|
logger.error(`Tag not found: ${JSON.stringify(tag)}`);
|
|
213
216
|
process.exit(1);
|
|
217
|
+
return;
|
|
214
218
|
}
|
|
215
219
|
const tagInfo = {
|
|
216
220
|
name: tag,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { startBwMcpServer } from "../../ai/mcp/index.mjs";
|
|
2
|
+
import { logger } from "../../internal/logger/index.mjs";
|
|
3
|
+
import { handleProjectCommand } from "./commandHandlerUtils.mjs"; // CONCATENATED MODULE: external "../../ai/mcp/index.mjs"
|
|
4
|
+
// CONCATENATED MODULE: external "../../internal/logger/index.mjs"
|
|
5
|
+
// CONCATENATED MODULE: external "./commandHandlerUtils.mjs"
|
|
6
|
+
// CONCATENATED MODULE: ./src/cli/commands/mcp.ts
|
|
7
|
+
|
|
8
|
+
const mcpServer = handleProjectCommand("mcpServer", async ({ project }) => {
|
|
9
|
+
logger.printLevel = "silent";
|
|
10
|
+
await startBwMcpServer(project);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { mcpServer };
|
|
@@ -56,6 +56,7 @@ const runScript = handleProjectCommand(
|
|
|
56
56
|
"CLI syntax error: Cannot use both --args and inline script args after --",
|
|
57
57
|
);
|
|
58
58
|
process.exit(1);
|
|
59
|
+
return;
|
|
59
60
|
}
|
|
60
61
|
const scriptArgs = postTerminatorArgs.length
|
|
61
62
|
? postTerminatorArgs
|
|
@@ -65,6 +66,7 @@ const runScript = handleProjectCommand(
|
|
|
65
66
|
"CLI syntax error: Cannot use both inline workspace patterns and --workspace-patterns|-W option",
|
|
66
67
|
);
|
|
67
68
|
process.exit(1);
|
|
69
|
+
return;
|
|
68
70
|
}
|
|
69
71
|
const workspacePatterns = positionalWorkspacePatterns?.length
|
|
70
72
|
? positionalWorkspacePatterns
|
|
@@ -137,6 +139,7 @@ const runScript = handleProjectCommand(
|
|
|
137
139
|
`Invalid max grouped lines value: ${options.groupedLines}. Must be a positive number or "all".`,
|
|
138
140
|
);
|
|
139
141
|
process.exit(1);
|
|
142
|
+
return;
|
|
140
143
|
}
|
|
141
144
|
groupedLines = parsedGroupedLines;
|
|
142
145
|
}
|
|
@@ -225,12 +228,14 @@ const runScript = handleProjectCommand(
|
|
|
225
228
|
`Failed to create JSON output file directory "${jsonOutputDir}": ${error}`,
|
|
226
229
|
);
|
|
227
230
|
process.exit(1);
|
|
231
|
+
return;
|
|
228
232
|
}
|
|
229
233
|
} else if (fs.statSync(jsonOutputDir).isFile()) {
|
|
230
234
|
logger.error(
|
|
231
235
|
`Given JSON output file directory "${jsonOutputDir}" is an existing file`,
|
|
232
236
|
);
|
|
233
237
|
process.exit(1);
|
|
238
|
+
return;
|
|
234
239
|
}
|
|
235
240
|
// Check if can make file
|
|
236
241
|
if (
|
|
@@ -241,6 +246,7 @@ const runScript = handleProjectCommand(
|
|
|
241
246
|
`Given JSON output file path "${fullOutputPath}" is an existing directory`,
|
|
242
247
|
);
|
|
243
248
|
process.exit(1);
|
|
249
|
+
return;
|
|
244
250
|
}
|
|
245
251
|
try {
|
|
246
252
|
logger.debug(`Writing JSON output file "${fullOutputPath}"`);
|
|
@@ -250,11 +256,13 @@ const runScript = handleProjectCommand(
|
|
|
250
256
|
`Failed to write JSON output file "${fullOutputPath}": ${error}`,
|
|
251
257
|
);
|
|
252
258
|
process.exit(1);
|
|
259
|
+
return;
|
|
253
260
|
}
|
|
254
261
|
logger.info(`JSON output written to ${fullOutputPath}`);
|
|
255
262
|
}
|
|
256
263
|
if (exitResults.failureCount) {
|
|
257
264
|
process.exit(1);
|
|
265
|
+
return;
|
|
258
266
|
}
|
|
259
267
|
},
|
|
260
268
|
);
|
|
@@ -288,8 +288,10 @@ const renderGroupedOutput = async (
|
|
|
288
288
|
});
|
|
289
289
|
process.on("SIGWINCH", render);
|
|
290
290
|
process.stdin.on("data", (data) => {
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
// Send to the entire process group (pid=0) so child processes also receive
|
|
292
|
+
// the signal — raw mode prevents the terminal from doing this automatically.
|
|
293
|
+
if (data[0] === 0x03) process.kill(0, "SIGINT");
|
|
294
|
+
if (data[0] === 0x1c) process.kill(0, "SIGQUIT");
|
|
293
295
|
});
|
|
294
296
|
runOnExit((reason) => {
|
|
295
297
|
try {
|
package/src/cli/createCli.mjs
CHANGED
|
@@ -90,6 +90,7 @@ const createCli = ({ defaultCwd = process.cwd(), defaultMiddleware } = {}) => {
|
|
|
90
90
|
if (bunVersionError) {
|
|
91
91
|
fatalErrorLogger.error(bunVersionError.message);
|
|
92
92
|
process.exit(1);
|
|
93
|
+
return;
|
|
93
94
|
}
|
|
94
95
|
const { project, projectError } = initializeWithGlobalOptions(
|
|
95
96
|
program,
|
package/src/config/public.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export type { RootConfig, ResolvedRootConfig } from "./rootConfig";
|
|
|
2
2
|
export type {
|
|
3
3
|
WorkspaceConfig,
|
|
4
4
|
ResolvedWorkspaceConfig,
|
|
5
|
+
WorkspaceDependenciesRule,
|
|
6
|
+
WorkspaceRules,
|
|
7
|
+
ScriptConfig,
|
|
5
8
|
} from "./workspaceConfig";
|
|
6
9
|
export { defineRootConfig } from "./rootConfig/defineRootConfig";
|
|
7
10
|
export { defineWorkspaceConfig } from "./workspaceConfig/defineWorkspaceConfig";
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export type WorkspaceDependenciesRule = {
|
|
2
|
+
allowPatterns?: string[];
|
|
3
|
+
denyPatterns?: string[];
|
|
4
|
+
};
|
|
5
|
+
export type WorkspaceRules = {
|
|
6
|
+
/** Allowed or denied workspace dependencies */
|
|
7
|
+
workspaceDependencies?: WorkspaceDependenciesRule;
|
|
8
|
+
};
|
|
1
9
|
/** Configuration that applies to a specific package.json script */
|
|
2
10
|
export type ScriptConfig = {
|
|
3
11
|
/**
|
|
@@ -30,11 +38,16 @@ export type WorkspaceConfig = {
|
|
|
30
38
|
* Configuration that maps to a script name in the workspace's package.json.
|
|
31
39
|
*/
|
|
32
40
|
scripts?: Record<string, ScriptConfig>;
|
|
41
|
+
/**
|
|
42
|
+
* Rules that validate the workspace.
|
|
43
|
+
*/
|
|
44
|
+
rules?: WorkspaceRules;
|
|
33
45
|
};
|
|
34
46
|
export type ResolvedWorkspaceConfig = {
|
|
35
47
|
aliases: string[];
|
|
36
48
|
tags: string[];
|
|
37
49
|
scripts: Record<string, ScriptConfig>;
|
|
50
|
+
rules: WorkspaceRules;
|
|
38
51
|
};
|
|
39
52
|
export declare const validateWorkspaceConfig: (config: WorkspaceConfig) => void;
|
|
40
53
|
export declare const resolveWorkspaceConfig: (
|
|
@@ -8,7 +8,7 @@ import { WORKSPACE_CONFIG_ERRORS } from "./errors.mjs"; // CONCATENATED MODULE:
|
|
|
8
8
|
// CONCATENATED MODULE: ./src/config/workspaceConfig/workspaceConfig.ts
|
|
9
9
|
|
|
10
10
|
const validate = validateWorkspaceConfig;
|
|
11
|
-
const workspaceConfig_validateWorkspaceConfig = (config) =>
|
|
11
|
+
const workspaceConfig_validateWorkspaceConfig = (config) => {
|
|
12
12
|
executeValidator(
|
|
13
13
|
validate,
|
|
14
14
|
"WorkspaceConfig",
|
|
@@ -17,6 +17,15 @@ const workspaceConfig_validateWorkspaceConfig = (config) =>
|
|
|
17
17
|
},
|
|
18
18
|
WORKSPACE_CONFIG_ERRORS.InvalidWorkspaceConfig,
|
|
19
19
|
);
|
|
20
|
+
if (
|
|
21
|
+
config.rules?.workspaceDependencies?.allowPatterns &&
|
|
22
|
+
config.rules?.workspaceDependencies?.denyPatterns
|
|
23
|
+
) {
|
|
24
|
+
throw new WORKSPACE_CONFIG_ERRORS.InvalidWorkspaceConfig(
|
|
25
|
+
"Cannot use both allowPatterns and denyPatterns in workspaceDependencies rule",
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
20
29
|
const resolveWorkspaceConfig = (config) => {
|
|
21
30
|
if (Array.isArray(config.aliases)) {
|
|
22
31
|
const { aliases, ...rest } = config;
|
|
@@ -34,6 +43,7 @@ const resolveWorkspaceConfig = (config) => {
|
|
|
34
43
|
aliases: resolveOptionalArray(config.alias ?? []),
|
|
35
44
|
tags: config.tags ?? [],
|
|
36
45
|
scripts: config.scripts ?? {},
|
|
46
|
+
rules: config.rules ?? {},
|
|
37
47
|
};
|
|
38
48
|
};
|
|
39
49
|
const createDefaultWorkspaceConfig = () => resolveWorkspaceConfig({});
|
|
@@ -28,5 +28,29 @@ export declare const WORKSPACE_CONFIG_JSON_SCHEMA: {
|
|
|
28
28
|
readonly additionalProperties: false;
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
+
readonly rules: {
|
|
32
|
+
readonly type: "object";
|
|
33
|
+
readonly additionalProperties: false;
|
|
34
|
+
readonly properties: {
|
|
35
|
+
readonly workspaceDependencies: {
|
|
36
|
+
readonly type: "object";
|
|
37
|
+
readonly properties: {
|
|
38
|
+
readonly allowPatterns: {
|
|
39
|
+
readonly type: "array";
|
|
40
|
+
readonly items: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
readonly denyPatterns: {
|
|
45
|
+
readonly type: "array";
|
|
46
|
+
readonly items: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly additionalProperties: false;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
31
55
|
};
|
|
32
56
|
};
|
|
@@ -29,6 +29,30 @@ const WORKSPACE_CONFIG_JSON_SCHEMA = {
|
|
|
29
29
|
additionalProperties: false,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
|
+
rules: {
|
|
33
|
+
type: "object",
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
properties: {
|
|
36
|
+
workspaceDependencies: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
allowPatterns: {
|
|
40
|
+
type: "array",
|
|
41
|
+
items: {
|
|
42
|
+
type: "string",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
denyPatterns: {
|
|
46
|
+
type: "array",
|
|
47
|
+
items: {
|
|
48
|
+
type: "string",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
32
56
|
},
|
|
33
57
|
};
|
|
34
58
|
let _validateSchemaType;
|