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,132 @@
|
|
|
1
|
+
// CONCATENATED MODULE: ./src/internal/docs/apiQuickstart.ts
|
|
2
|
+
const RUN_WORKSPACE_SCRIPT_EXAMPLE = `
|
|
3
|
+
const { output, exit } = project.runWorkspaceScript({
|
|
4
|
+
workspaceNameOrAlias: "my-workspace",
|
|
5
|
+
script: "my-script",
|
|
6
|
+
|
|
7
|
+
// Optional. Arguments to add to the command
|
|
8
|
+
// Can be a string or an array of strings
|
|
9
|
+
// If string, the argv will be parsed POSIX-style
|
|
10
|
+
args: ["--my", "--appended", "--args"],
|
|
11
|
+
|
|
12
|
+
// Optional. Whether to ignore all output from the script.
|
|
13
|
+
// This saves memory when you don't need script output.
|
|
14
|
+
ignoreOutput: false,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// Get a stream of the script subprocess's output
|
|
18
|
+
for await (const { chunk, metadata } of output.text()) {
|
|
19
|
+
// console.log(chunk); // The output chunk's content (string)
|
|
20
|
+
// console.log(metadata.streamName); // The output stream, "stdout" or "stderr"
|
|
21
|
+
// console.log(metadata.workspace); // The target Workspace
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Get data about the script execution after it exits
|
|
25
|
+
const exitResult = await exit;
|
|
26
|
+
|
|
27
|
+
// exitResult.exitCode // The exit code (number)
|
|
28
|
+
// exitResult.signal // The exit signal (string), or null
|
|
29
|
+
// exitResult.success // true if exit code was 0
|
|
30
|
+
// exitResult.startTimeISO // Start time (string)
|
|
31
|
+
// exitResult.endTimeISO // End time (string)
|
|
32
|
+
// exitResult.durationMs // Duration in milliseconds (number)
|
|
33
|
+
// exitResult.metadata.workspace // The target workspace (Workspace)
|
|
34
|
+
|
|
35
|
+
`.trim();
|
|
36
|
+
const RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE = `
|
|
37
|
+
|
|
38
|
+
const { output, summary } = project.runScriptAcrossWorkspaces({
|
|
39
|
+
// Optional. This will run in all matching workspaces that have my-script
|
|
40
|
+
// Accepts same values as the CLI run-script command's workspace patterns
|
|
41
|
+
// When not provided, all workspaces that have the script will be used.
|
|
42
|
+
workspacePatterns: ["my-workspace", "my-name-pattern-*"],
|
|
43
|
+
|
|
44
|
+
// Required. The package.json "scripts" field name to run
|
|
45
|
+
script: "my-script",
|
|
46
|
+
|
|
47
|
+
// Optional. Arguments to add to the command (same as for runWorkspaceScript)
|
|
48
|
+
args: ["--my", "--appended", "--args"],
|
|
49
|
+
|
|
50
|
+
// Optional. Whether to run the scripts in parallel (default: true)
|
|
51
|
+
parallel: true,
|
|
52
|
+
|
|
53
|
+
// Optional. When true, a workspace's script will wait
|
|
54
|
+
// until any workspaces it depends on have completed
|
|
55
|
+
dependencyOrder: false,
|
|
56
|
+
|
|
57
|
+
// Optional. When true and dependencyOrder is true,
|
|
58
|
+
// continue running scripts even if a dependency fails
|
|
59
|
+
ignoreDependencyFailure: false,
|
|
60
|
+
|
|
61
|
+
// Optional. Whether to ignore all output from the scripts.
|
|
62
|
+
// This saves memory when you don't need script output.
|
|
63
|
+
ignoreOutput: false,
|
|
64
|
+
|
|
65
|
+
// Optional, callback when script starts, skips, or exits
|
|
66
|
+
onScriptEvent: (event, { workspace, exitResult }) => {
|
|
67
|
+
// event: "start", "skip", "exit"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Get a stream of script output
|
|
72
|
+
for await (const { chunk, metadata } of output.text()) {
|
|
73
|
+
// console.log(chunk); // the output chunk's content (string)
|
|
74
|
+
// console.log(metadata.streamName); // "stdout" or "stderr"
|
|
75
|
+
// console.log(metadata.workspace); // the Workspace that the output came from
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Get final summary data and script exit details after all scripts have completed
|
|
79
|
+
const summaryResult = await summary;
|
|
80
|
+
|
|
81
|
+
// summaryResult.totalCount // Total number of scripts
|
|
82
|
+
// summaryResult.allSuccess // true if all scripts succeeded
|
|
83
|
+
// summaryResult.successCount // Number of scripts that succeeded
|
|
84
|
+
// summaryResult.failureCount // Number of scripts that failed
|
|
85
|
+
// summaryResult.startTimeISO // Start time (string)
|
|
86
|
+
// summaryResult.endTimeISO // End time (string)
|
|
87
|
+
// summaryResult.durationMs // Total duration in milliseconds (number)
|
|
88
|
+
|
|
89
|
+
// The exit details of each workspace script
|
|
90
|
+
for (const exitResult of summaryResult.scriptResults) {
|
|
91
|
+
// exitResult.exitCode // The exit code (number)
|
|
92
|
+
// exitResult.signal // The exit signal (string), or null
|
|
93
|
+
// exitResult.success // true if exit code was 0
|
|
94
|
+
// exitResult.startTimeISO // Start time (ISO string)
|
|
95
|
+
// exitResult.endTimeISO // End time (ISO string)
|
|
96
|
+
// exitResult.durationMs // Duration in milliseconds (number)
|
|
97
|
+
// exitResult.metadata.workspace // The target workspace (Workspace)
|
|
98
|
+
}
|
|
99
|
+
`.trim();
|
|
100
|
+
const API_QUICKSTART = `
|
|
101
|
+
import { createFileSystemProject } from "bun-workspaces";
|
|
102
|
+
|
|
103
|
+
// A Project contains the core functionality of bun-workspaces.
|
|
104
|
+
// Below defaults to process.cwd() for the project root directory
|
|
105
|
+
// Pass { rootDirectory: "path/to/your/project" } to use a different root directory
|
|
106
|
+
const project = createFileSystemProject();
|
|
107
|
+
|
|
108
|
+
// A Workspace that matches the name or alias "my-workspace"
|
|
109
|
+
const myWorkspace = project.findWorkspaceByNameOrAlias("my-workspace");
|
|
110
|
+
|
|
111
|
+
// Array of workspaces whose names match the wildcard pattern
|
|
112
|
+
const wildcardWorkspaces = project.findWorkspacesByPattern("my-workspace-*");
|
|
113
|
+
|
|
114
|
+
// Array of workspaces that have "my-script" in their package.json "scripts"
|
|
115
|
+
const workspacesWithScript = project.listWorkspacesWithScript("my-script");
|
|
116
|
+
|
|
117
|
+
// Run a script in a workspace
|
|
118
|
+
const runSingleScript = async () => {
|
|
119
|
+
${RUN_WORKSPACE_SCRIPT_EXAMPLE.split("\n").join("\n ")}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Run a script in all workspaces that have it in their package.json "scripts" field
|
|
123
|
+
const runManyScripts = async () => {
|
|
124
|
+
${RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE.split("\n").join("\n ")}
|
|
125
|
+
}
|
|
126
|
+
`.trim();
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
API_QUICKSTART,
|
|
130
|
+
RUN_SCRIPT_ACROSS_WORKSPACES_EXAMPLE,
|
|
131
|
+
RUN_WORKSPACE_SCRIPT_EXAMPLE,
|
|
132
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// CONCATENATED MODULE: ./src/internal/docs/cliQuickstart.ts
|
|
2
|
+
const CLI_QUICKSTART = `
|
|
3
|
+
# You can add this to .bashrc, .zshrc, or similar.
|
|
4
|
+
# You can also invoke "bw" in your root package.json scripts.
|
|
5
|
+
alias bw="bunx bun-workspaces"
|
|
6
|
+
|
|
7
|
+
# List all workspaces in your project
|
|
8
|
+
bw list-workspaces
|
|
9
|
+
|
|
10
|
+
# ls is an alias for list-workspaces
|
|
11
|
+
bw ls --json --pretty # Output as formatted JSON
|
|
12
|
+
|
|
13
|
+
# Get info about a workspace
|
|
14
|
+
bw workspace-info my-workspace
|
|
15
|
+
bw info my-workspace --json --pretty # info is alias for workspace-info
|
|
16
|
+
|
|
17
|
+
# Get info about a script, such as the workspaces that have it
|
|
18
|
+
bw script-info my-script
|
|
19
|
+
|
|
20
|
+
# Run the lint script for all workspaces
|
|
21
|
+
# that have it in their package.json "scripts" field
|
|
22
|
+
bw run-script lint
|
|
23
|
+
|
|
24
|
+
# run is an alias for run-script
|
|
25
|
+
bw run lint my-workspace # Run for a single workspace
|
|
26
|
+
bw run lint my-workspace-a my-workspace-b # Run for multiple workspaces
|
|
27
|
+
bw run lint my-alias-a my-alias-b # Run by alias (set by optional config)
|
|
28
|
+
|
|
29
|
+
# A workspace's script will wait until any workspaces it depends on have completed
|
|
30
|
+
# Similar to Bun's --filter behavior
|
|
31
|
+
bw run lint --dep-order
|
|
32
|
+
|
|
33
|
+
# Continue running scripts even if a dependency fails
|
|
34
|
+
bw run lint --dep-order --ignore-dep-failure
|
|
35
|
+
|
|
36
|
+
bw run lint "my-workspace-*" # Run for matching workspace names
|
|
37
|
+
bw run lint "alias:my-alias-*" "path:my-glob/**/*" "tag:my-tag" # Use matching specifiers
|
|
38
|
+
bw run lint "*" "not:path:my-path/*" # Run for all workspaces not in my-path/
|
|
39
|
+
|
|
40
|
+
bw run lint --args="--my-appended-args" # Add args to each script call
|
|
41
|
+
bw run lint --args="--my-arg=<workspaceName>" # Use the workspace name in args
|
|
42
|
+
|
|
43
|
+
bw run "bun build" --inline # Run an inline command via the Bun shell
|
|
44
|
+
|
|
45
|
+
# Scripts run in parallel by default
|
|
46
|
+
bw run lint --parallel=false # Run in series
|
|
47
|
+
bw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts
|
|
48
|
+
bw run lint --parallel=auto # Default, based on number of available logical CPUs
|
|
49
|
+
bw run lint --parallel=50% # Run in parallel with a max of 50% of the "auto" limit
|
|
50
|
+
|
|
51
|
+
# Use the grouped output style (default when on a TTY)
|
|
52
|
+
bw run my-script --output-style=grouped
|
|
53
|
+
|
|
54
|
+
# Set the max preview lines for script output in grouped output style
|
|
55
|
+
bw run my-script --output-style=grouped --grouped-lines=auto
|
|
56
|
+
bw run my-script --output-style=grouped --grouped-lines=10
|
|
57
|
+
|
|
58
|
+
# Use simple script output with workspace prefixes (default when not on a TTY)
|
|
59
|
+
bw run my-script --output-style=prefixed
|
|
60
|
+
|
|
61
|
+
# Use the plain output style (no workspace prefixes)
|
|
62
|
+
bw run my-script --output-style=plain
|
|
63
|
+
|
|
64
|
+
# Silence all output of the run command
|
|
65
|
+
bw --log-level=silent run my-script --output-style=none
|
|
66
|
+
|
|
67
|
+
# Show usage (you can pass --help to any command)
|
|
68
|
+
bw help
|
|
69
|
+
bw --help
|
|
70
|
+
|
|
71
|
+
# Show version
|
|
72
|
+
bw --version
|
|
73
|
+
|
|
74
|
+
# Pass --cwd to any command
|
|
75
|
+
bw --cwd=/path/to/your/project ls
|
|
76
|
+
bw --cwd=/path/to/your/project run my-script
|
|
77
|
+
|
|
78
|
+
# Pass --log-level to any command (debug, info, warn, error, or silent)
|
|
79
|
+
bw --log-level=debug ls
|
|
80
|
+
`.trim();
|
|
81
|
+
const INLINE_SCRIPT_EXAMPLE = `
|
|
82
|
+
# Run an inline command from the workspace directory
|
|
83
|
+
bw run "bun run build" --inline
|
|
84
|
+
`.trim();
|
|
85
|
+
|
|
86
|
+
export { CLI_QUICKSTART, INLINE_SCRIPT_EXAMPLE };
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const DOC_OVERVIEW =
|
|
2
|
+
'## Project Overview\n\nbun-workspaces is a CLI and TypeScript API to help manage Bun monorepos. It reads `bun.lock` to find all workspaces in the project. It is referred to as "bw" for short, which is also the recommended CLI alias. The overall goal is a monorepo tool that is more lightweight than others, with still powerful comparable features, requiring no special config to get started, only a standard Bun repo using workspaces.\n\nThree main domain terms to know:\n\n- Project: generally represents a monorepo and is defined by the root `package.json` file\n- Workspace: a nested package within a project. The root package.json can count as a workspace as well, but by default, only nested packages are considered workspaces.\n- Script: an entry in the `scripts` field of a workspace\'s `package.json` file. bw can also run one-off commands known as "inline scripts," which can use the Bun shell or system shell (`sh -c` or `cmd /d /s /c` for windows).';
|
|
3
|
+
export declare const DOC_CONCEPTS =
|
|
4
|
+
'## Concepts\n\n### Workspace patterns\n\nMany features accept a list of workspace patterns to match a subset of workspaces.\n\nBy default, a pattern matches the workspace name or alias: `my-workspace-name` or `my-alias-name`. Aliases are defined in config explained below.\n\nPatterns can include a wildcard to match only by workspace name: `my-workspace-*`.\n\n- Alias pattern specifier: `alias:my-alias-*`.\n- Path pattern specifier (supports glob): `path:packages/**/*`.\n- Name pattern specifier: `name:my-workspace-*`.\n- Tag pattern specifier: `tag:my-tag`.\n- Special root workspace selector: `@root`.\n- Any pattern can start with `not:` to negate the pattern. (e.g. "not:my-workspace-name", "not:tag:my-tag-\\*") This excludes workspaces that match any other present patterns from a result.\n\n### Script runtime metadata\n\nScripts ran via bw can access metadata via env vars. This same metadata can be interpolated into inline scripts and appended args.\n\n```typescript\n// in a script\nconst projectPath = process.env.BW_PROJECT_PATH;\nconst workspaceName = process.env.BW_WORKSPACE_NAME;\nconst workspacePath = process.env.BW_WORKSPACE_PATH;\nconst workspaceRelativePath = process.env.BW_WORKSPACE_RELATIVE_PATH;\nconst scriptName = process.env.BW_SCRIPT_NAME;\n```\n\n```bash\n# interpolated\nbw run "bun <projectPath>/my-script.ts" --inline \\\n --inline-name="my-script-name" \\\n --args="<workspaceName> <workspacePath>"\n```';
|
|
5
|
+
export declare const DOC_CLI =
|
|
6
|
+
'### CLI examples:\n\n```bash\nalias bw="bunx bun-workspaces"\n\nbw list-workspaces # human-readable output\nbw ls --json --pretty # ls is alias for list-workspaces\nbw ls "name:my-workspace-*" "alias:my-alias-*" "path:packages/**/*" # accepts workspace patterns\n\n# info includes the name, aliases, path, etc.\nbw workspace-info my-workspace\nbw info my-workspace --json --pretty # info is alias for workspace-info\n\n# info includes the script name and workspaces that have it in their package.json "scripts" field\nbw script-info my-script --json --pretty\n\n# run the package.json "lint" script for all workspaces that have it\nbw run-script lint\n\n# run is alias for run-script\n# run the package.json "lint" script for workspaces using matching specifiers\nbw run lint my-workspace-name "alias:my-alias-pattern-*" "path:my-glob/**/*" # accepts workspace patterns\n\n# A workspace\'s script will wait until any workspaces it depends on have completed\n# Similar to Bun\'s --filter behavior\nbw run lint --dep-order\n\n# Continue running scripts even if a dependency fails\nbw run lint --dep-order --ignore-dep-failure\n\n# special root workspace selector (works even if root workspace is not included)\nbw run lint @root\n\n# Scripts run in parallel by default\nbw run lint --parallel=false # Run in series\n\n# Default can be overridden by config or env var BW_PARALLEL_MAX_DEFAULT\nbw run lint --parallel # default "auto", os.availableParallelism()\nbw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts\nbw run lint --parallel=50% # 50% of os.availableParallelism()\nbw run lint --parallel=unbounded # run all in one batch\n\n# add args to the script command\nbw run lint --args="--my-arg=value"\nbw run lint --args="--my-arg=<workspaceName>" # use the workspace name in args\n\n# run the script as an inline command from the workspace directory\nbw run "bun build" --inline\nbw run "bun build" --inline --inline-name="my-script"\nbw run "bun build" --inline --shell=system # use the system shell\n\n# Use the grouped output style (default when on a TTY)\nbw run my-script --output-style=grouped\n\n# Set the max preview lines for script output in grouped output style\nbw run my-script --output-style=grouped --grouped-lines=auto\nbw run my-script --output-style=grouped --grouped-lines=10\n\n# Use simple script output with workspace prefixes (default when not on a TTY)\nbw run my-script --output-style=prefixed\n\n# Use the plain output style (no workspace prefixes)\nbw run my-script --output-style=plain\n\n### Global Options ###\n# Root directory of project:\nbw --cwd=/path/to/project ls\nbw -d /path/to/project ls\n\n# Include root workspace as a normal workspace (default false):\nbw --include-root ls\nbw -r ls\nbw --no-include-root ls # override config/env var setting\n\n# Log level (debug|info|warn|error|silent, default info)\nbw --log-level=silent ls\nbw -l silent ls\n```';
|
|
7
|
+
export declare const DOC_API =
|
|
8
|
+
'### API examples:\n\nThe API is held in close parity with the CLI. It is developed first so that the CLI is a thin wrapper around the API.\n\n```typescript\nimport { createFileSystemProject } from "bun-workspaces";\n\nconst project = createFileSystemProject({\n // the options object itself and its properties are optional\n rootDirectory: "path/to/your/project",\n includeRootWorkspace: false,\n});\nproject.workspaces; // array of all workspaces in the project\nproject.rootWorkspace; // the root workspace (available even when not included in the workspaces array)\nproject.findWorkspaceByName("my-workspace"); // find a workspace by name\nproject.findWorkspaceByAlias("my-alias"); // find a workspace by alias\nproject.findWorkspaceByNameOrAlias("my-workspace-or-alias"); // find a workspace by name or alias\nproject.findWorkspacesByPattern(\n "my-workspace-name",\n "my-workspace-alias",\n "my-name-pattern-*",\n "alias:my-alias-*",\n "path:my-glob/**/*",\n); // find workspaces by pattern like the CLI\nproject.runWorkspaceScript({\n workspaceNameOrAlias: "my-workspace",\n script: "lint",\n inline: true,\n // args can be a string or an array of strings\n // if string, the argv will be parsed POSIX-style\n args: "--my-arg=value",\n});\nproject.runScriptAcrossWorkspaces({\n script: "lint",\n workspacePatterns: [\n "alias:my-alias-pattern-*",\n "path:my-glob/**/*",\n "workspace-name-a",\n "workspace-alias-b",\n ],\n parallel: true, // also could be { max: 2 }, max taking same options as seen in CLI examples above (e.g. "50%", "auto", etc.)\n dependencyOrder: true,\n ignoreDependencyFailure: true,\n // same as for runWorkspaceScript\n args: ["--my", "--appended", "--args"],\n // Optional, callback when script starts, skips, or exits\n onScriptEvent: (event, { workspace, exitResult }) => {\n // event: "start", "skip", "exit"\n },\n});\n```\n\n## The Workspace object\n\n```jsonc\n{\n // The name of the workspace from its package.json\n "name": "my-workspace",\n // Whether the workspace is the root workspace\n "isRoot": false,\n // The relative path to the workspace from the project root\n "path": "my/workspace/path",\n // The glob pattern from the root package.json "workspaces" field\n // that this workspace was matched from\n "matchPattern": "my/workspace/pattern/*",\n // The scripts available in the workspace\'s package.json\n "scripts": ["my-script"],\n // Aliases defined in workspace configuration (bw.workspace.jsonc/bw.workspace.json)\n "aliases": ["my-alias"],\n // Names of other workspaces that this workspace depends on\n "dependencies": ["my-dependency"],\n // Names of other workspaces that depend on this workspace\n "dependents": ["my-dependent"],\n}\n```';
|
|
9
|
+
export declare const DOC_CONFIG =
|
|
10
|
+
'## Root config\n\nOptional project config can be placed in `bw.root.jsonc`/`bw.root.json` in the root directory.\n\nConfig defaults here take precedence over environment variables that can set defaults.\nExplicit arguments to the CLI or API take precedence over all other settings.\n\n```jsonc\n{\n "defaults": {\n "parallelMax": 5, // same options as seen in CLI examples above\n "shell": "system", // "bun" or "system" (default "bun")\n "includeRootWorkspace": true, // treat root package.json as a normal workspace\n },\n}\n```\n\n## Workspace config\n\nOptional config can be placed in `bw.workspace.jsonc`/`bw.workspace.json` in a workspace directory.\n\nAliases must be unique to each workspace and to not clash with other workspaces\' `package.json` names.\n\nTags are strings to group workspaces together that therefore don\'t need to be unique to each workspace.\n\n```jsonc\n{\n "alias": "my-alias", // can be array\n "tags": ["my-tag"],\n "scripts": {\n "lint": {\n // set optional sorting order for scripts\n "order": 1,\n },\n },\n "rules": {\n "workspaceDependencies": {\n // use workspace patterns to allow or deny other workspaces as dependencies\n "allowPatterns": ["my-allow-pattern-*"],\n // or\n // "denyPatterns": ["my-deny-pattern-*"],\n },\n },\n}\n```\n\n### Workspace Dependency Rules\n\nUsing the `rules.workspaceDependencies` field, you can define rules for which workspaces are allowed to be dependencies,\nusing either `allowPatterns` or `denyPatterns`.\n\nWorkspace Patterns are used to match workspaces.\n\nYou can\'t use both `allowPatterns` and `denyPatterns` at the same time, but you can use\n\n## TypeScript/JSON Config Files\n\nYou can use TypeScript/JSON config files to define your workspace configuration.\n\n### TypeScript\n\n`bw.workspace.ts`\n\n```ts\nimport { defineWorkspaceConfig } from "bun-workspaces/config";\n\nexport default defineWorkspaceConfig({\n alias: "my-alias",\n tags: ["my-tag"],\n});\n```\n\n`bw.root.ts`\n\n```ts\nimport { defineRootConfig } from "bun-workspaces/config";\n\nexport default defineRootConfig({\n defaults: {\n parallelMax: 5,\n },\n});\n```';
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// CONCATENATED MODULE: ./src/internal/generated/aiDocs/docs.ts
|
|
2
|
+
// This file is generated by scripts/generateMcpDocs.ts. Do not edit manually.
|
|
3
|
+
const DOC_OVERVIEW = `## Project Overview
|
|
4
|
+
|
|
5
|
+
bun-workspaces is a CLI and TypeScript API to help manage Bun monorepos. It reads \`bun.lock\` to find all workspaces in the project. It is referred to as "bw" for short, which is also the recommended CLI alias. The overall goal is a monorepo tool that is more lightweight than others, with still powerful comparable features, requiring no special config to get started, only a standard Bun repo using workspaces.
|
|
6
|
+
|
|
7
|
+
Three main domain terms to know:
|
|
8
|
+
|
|
9
|
+
- Project: generally represents a monorepo and is defined by the root \`package.json\` file
|
|
10
|
+
- Workspace: a nested package within a project. The root package.json can count as a workspace as well, but by default, only nested packages are considered workspaces.
|
|
11
|
+
- Script: an entry in the \`scripts\` field of a workspace's \`package.json\` file. bw can also run one-off commands known as "inline scripts," which can use the Bun shell or system shell (\`sh -c\` or \`cmd /d /s /c\` for windows).`;
|
|
12
|
+
const DOC_CONCEPTS = `## Concepts
|
|
13
|
+
|
|
14
|
+
### Workspace patterns
|
|
15
|
+
|
|
16
|
+
Many features accept a list of workspace patterns to match a subset of workspaces.
|
|
17
|
+
|
|
18
|
+
By default, a pattern matches the workspace name or alias: \`my-workspace-name\` or \`my-alias-name\`. Aliases are defined in config explained below.
|
|
19
|
+
|
|
20
|
+
Patterns can include a wildcard to match only by workspace name: \`my-workspace-*\`.
|
|
21
|
+
|
|
22
|
+
- Alias pattern specifier: \`alias:my-alias-*\`.
|
|
23
|
+
- Path pattern specifier (supports glob): \`path:packages/**/*\`.
|
|
24
|
+
- Name pattern specifier: \`name:my-workspace-*\`.
|
|
25
|
+
- Tag pattern specifier: \`tag:my-tag\`.
|
|
26
|
+
- Special root workspace selector: \`@root\`.
|
|
27
|
+
- Any pattern can start with \`not:\` to negate the pattern. (e.g. "not:my-workspace-name", "not:tag:my-tag-\\*") This excludes workspaces that match any other present patterns from a result.
|
|
28
|
+
|
|
29
|
+
### Script runtime metadata
|
|
30
|
+
|
|
31
|
+
Scripts ran via bw can access metadata via env vars. This same metadata can be interpolated into inline scripts and appended args.
|
|
32
|
+
|
|
33
|
+
\`\`\`typescript
|
|
34
|
+
// in a script
|
|
35
|
+
const projectPath = process.env.BW_PROJECT_PATH;
|
|
36
|
+
const workspaceName = process.env.BW_WORKSPACE_NAME;
|
|
37
|
+
const workspacePath = process.env.BW_WORKSPACE_PATH;
|
|
38
|
+
const workspaceRelativePath = process.env.BW_WORKSPACE_RELATIVE_PATH;
|
|
39
|
+
const scriptName = process.env.BW_SCRIPT_NAME;
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
\`\`\`bash
|
|
43
|
+
# interpolated
|
|
44
|
+
bw run "bun <projectPath>/my-script.ts" --inline \\
|
|
45
|
+
--inline-name="my-script-name" \\
|
|
46
|
+
--args="<workspaceName> <workspacePath>"
|
|
47
|
+
\`\`\``;
|
|
48
|
+
const DOC_CLI = `### CLI examples:
|
|
49
|
+
|
|
50
|
+
\`\`\`bash
|
|
51
|
+
alias bw="bunx bun-workspaces"
|
|
52
|
+
|
|
53
|
+
bw list-workspaces # human-readable output
|
|
54
|
+
bw ls --json --pretty # ls is alias for list-workspaces
|
|
55
|
+
bw ls "name:my-workspace-*" "alias:my-alias-*" "path:packages/**/*" # accepts workspace patterns
|
|
56
|
+
|
|
57
|
+
# info includes the name, aliases, path, etc.
|
|
58
|
+
bw workspace-info my-workspace
|
|
59
|
+
bw info my-workspace --json --pretty # info is alias for workspace-info
|
|
60
|
+
|
|
61
|
+
# info includes the script name and workspaces that have it in their package.json "scripts" field
|
|
62
|
+
bw script-info my-script --json --pretty
|
|
63
|
+
|
|
64
|
+
# run the package.json "lint" script for all workspaces that have it
|
|
65
|
+
bw run-script lint
|
|
66
|
+
|
|
67
|
+
# run is alias for run-script
|
|
68
|
+
# run the package.json "lint" script for workspaces using matching specifiers
|
|
69
|
+
bw run lint my-workspace-name "alias:my-alias-pattern-*" "path:my-glob/**/*" # accepts workspace patterns
|
|
70
|
+
|
|
71
|
+
# A workspace's script will wait until any workspaces it depends on have completed
|
|
72
|
+
# Similar to Bun's --filter behavior
|
|
73
|
+
bw run lint --dep-order
|
|
74
|
+
|
|
75
|
+
# Continue running scripts even if a dependency fails
|
|
76
|
+
bw run lint --dep-order --ignore-dep-failure
|
|
77
|
+
|
|
78
|
+
# special root workspace selector (works even if root workspace is not included)
|
|
79
|
+
bw run lint @root
|
|
80
|
+
|
|
81
|
+
# Scripts run in parallel by default
|
|
82
|
+
bw run lint --parallel=false # Run in series
|
|
83
|
+
|
|
84
|
+
# Default can be overridden by config or env var BW_PARALLEL_MAX_DEFAULT
|
|
85
|
+
bw run lint --parallel # default "auto", os.availableParallelism()
|
|
86
|
+
bw run lint --parallel=2 # Run in parallel with a max of 2 concurrent scripts
|
|
87
|
+
bw run lint --parallel=50% # 50% of os.availableParallelism()
|
|
88
|
+
bw run lint --parallel=unbounded # run all in one batch
|
|
89
|
+
|
|
90
|
+
# add args to the script command
|
|
91
|
+
bw run lint --args="--my-arg=value"
|
|
92
|
+
bw run lint --args="--my-arg=<workspaceName>" # use the workspace name in args
|
|
93
|
+
|
|
94
|
+
# run the script as an inline command from the workspace directory
|
|
95
|
+
bw run "bun build" --inline
|
|
96
|
+
bw run "bun build" --inline --inline-name="my-script"
|
|
97
|
+
bw run "bun build" --inline --shell=system # use the system shell
|
|
98
|
+
|
|
99
|
+
# Use the grouped output style (default when on a TTY)
|
|
100
|
+
bw run my-script --output-style=grouped
|
|
101
|
+
|
|
102
|
+
# Set the max preview lines for script output in grouped output style
|
|
103
|
+
bw run my-script --output-style=grouped --grouped-lines=auto
|
|
104
|
+
bw run my-script --output-style=grouped --grouped-lines=10
|
|
105
|
+
|
|
106
|
+
# Use simple script output with workspace prefixes (default when not on a TTY)
|
|
107
|
+
bw run my-script --output-style=prefixed
|
|
108
|
+
|
|
109
|
+
# Use the plain output style (no workspace prefixes)
|
|
110
|
+
bw run my-script --output-style=plain
|
|
111
|
+
|
|
112
|
+
### Global Options ###
|
|
113
|
+
# Root directory of project:
|
|
114
|
+
bw --cwd=/path/to/project ls
|
|
115
|
+
bw -d /path/to/project ls
|
|
116
|
+
|
|
117
|
+
# Include root workspace as a normal workspace (default false):
|
|
118
|
+
bw --include-root ls
|
|
119
|
+
bw -r ls
|
|
120
|
+
bw --no-include-root ls # override config/env var setting
|
|
121
|
+
|
|
122
|
+
# Log level (debug|info|warn|error|silent, default info)
|
|
123
|
+
bw --log-level=silent ls
|
|
124
|
+
bw -l silent ls
|
|
125
|
+
\`\`\``;
|
|
126
|
+
const DOC_API = `### API examples:
|
|
127
|
+
|
|
128
|
+
The API is held in close parity with the CLI. It is developed first so that the CLI is a thin wrapper around the API.
|
|
129
|
+
|
|
130
|
+
\`\`\`typescript
|
|
131
|
+
import { createFileSystemProject } from "bun-workspaces";
|
|
132
|
+
|
|
133
|
+
const project = createFileSystemProject({
|
|
134
|
+
// the options object itself and its properties are optional
|
|
135
|
+
rootDirectory: "path/to/your/project",
|
|
136
|
+
includeRootWorkspace: false,
|
|
137
|
+
});
|
|
138
|
+
project.workspaces; // array of all workspaces in the project
|
|
139
|
+
project.rootWorkspace; // the root workspace (available even when not included in the workspaces array)
|
|
140
|
+
project.findWorkspaceByName("my-workspace"); // find a workspace by name
|
|
141
|
+
project.findWorkspaceByAlias("my-alias"); // find a workspace by alias
|
|
142
|
+
project.findWorkspaceByNameOrAlias("my-workspace-or-alias"); // find a workspace by name or alias
|
|
143
|
+
project.findWorkspacesByPattern(
|
|
144
|
+
"my-workspace-name",
|
|
145
|
+
"my-workspace-alias",
|
|
146
|
+
"my-name-pattern-*",
|
|
147
|
+
"alias:my-alias-*",
|
|
148
|
+
"path:my-glob/**/*",
|
|
149
|
+
); // find workspaces by pattern like the CLI
|
|
150
|
+
project.runWorkspaceScript({
|
|
151
|
+
workspaceNameOrAlias: "my-workspace",
|
|
152
|
+
script: "lint",
|
|
153
|
+
inline: true,
|
|
154
|
+
// args can be a string or an array of strings
|
|
155
|
+
// if string, the argv will be parsed POSIX-style
|
|
156
|
+
args: "--my-arg=value",
|
|
157
|
+
});
|
|
158
|
+
project.runScriptAcrossWorkspaces({
|
|
159
|
+
script: "lint",
|
|
160
|
+
workspacePatterns: [
|
|
161
|
+
"alias:my-alias-pattern-*",
|
|
162
|
+
"path:my-glob/**/*",
|
|
163
|
+
"workspace-name-a",
|
|
164
|
+
"workspace-alias-b",
|
|
165
|
+
],
|
|
166
|
+
parallel: true, // also could be { max: 2 }, max taking same options as seen in CLI examples above (e.g. "50%", "auto", etc.)
|
|
167
|
+
dependencyOrder: true,
|
|
168
|
+
ignoreDependencyFailure: true,
|
|
169
|
+
// same as for runWorkspaceScript
|
|
170
|
+
args: ["--my", "--appended", "--args"],
|
|
171
|
+
// Optional, callback when script starts, skips, or exits
|
|
172
|
+
onScriptEvent: (event, { workspace, exitResult }) => {
|
|
173
|
+
// event: "start", "skip", "exit"
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
\`\`\`
|
|
177
|
+
|
|
178
|
+
## The Workspace object
|
|
179
|
+
|
|
180
|
+
\`\`\`jsonc
|
|
181
|
+
{
|
|
182
|
+
// The name of the workspace from its package.json
|
|
183
|
+
"name": "my-workspace",
|
|
184
|
+
// Whether the workspace is the root workspace
|
|
185
|
+
"isRoot": false,
|
|
186
|
+
// The relative path to the workspace from the project root
|
|
187
|
+
"path": "my/workspace/path",
|
|
188
|
+
// The glob pattern from the root package.json "workspaces" field
|
|
189
|
+
// that this workspace was matched from
|
|
190
|
+
"matchPattern": "my/workspace/pattern/*",
|
|
191
|
+
// The scripts available in the workspace's package.json
|
|
192
|
+
"scripts": ["my-script"],
|
|
193
|
+
// Aliases defined in workspace configuration (bw.workspace.jsonc/bw.workspace.json)
|
|
194
|
+
"aliases": ["my-alias"],
|
|
195
|
+
// Names of other workspaces that this workspace depends on
|
|
196
|
+
"dependencies": ["my-dependency"],
|
|
197
|
+
// Names of other workspaces that depend on this workspace
|
|
198
|
+
"dependents": ["my-dependent"],
|
|
199
|
+
}
|
|
200
|
+
\`\`\``;
|
|
201
|
+
const DOC_CONFIG = `## Root config
|
|
202
|
+
|
|
203
|
+
Optional project config can be placed in \`bw.root.jsonc\`/\`bw.root.json\` in the root directory.
|
|
204
|
+
|
|
205
|
+
Config defaults here take precedence over environment variables that can set defaults.
|
|
206
|
+
Explicit arguments to the CLI or API take precedence over all other settings.
|
|
207
|
+
|
|
208
|
+
\`\`\`jsonc
|
|
209
|
+
{
|
|
210
|
+
"defaults": {
|
|
211
|
+
"parallelMax": 5, // same options as seen in CLI examples above
|
|
212
|
+
"shell": "system", // "bun" or "system" (default "bun")
|
|
213
|
+
"includeRootWorkspace": true, // treat root package.json as a normal workspace
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
\`\`\`
|
|
217
|
+
|
|
218
|
+
## Workspace config
|
|
219
|
+
|
|
220
|
+
Optional config can be placed in \`bw.workspace.jsonc\`/\`bw.workspace.json\` in a workspace directory.
|
|
221
|
+
|
|
222
|
+
Aliases must be unique to each workspace and to not clash with other workspaces' \`package.json\` names.
|
|
223
|
+
|
|
224
|
+
Tags are strings to group workspaces together that therefore don't need to be unique to each workspace.
|
|
225
|
+
|
|
226
|
+
\`\`\`jsonc
|
|
227
|
+
{
|
|
228
|
+
"alias": "my-alias", // can be array
|
|
229
|
+
"tags": ["my-tag"],
|
|
230
|
+
"scripts": {
|
|
231
|
+
"lint": {
|
|
232
|
+
// set optional sorting order for scripts
|
|
233
|
+
"order": 1,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
"rules": {
|
|
237
|
+
"workspaceDependencies": {
|
|
238
|
+
// use workspace patterns to allow or deny other workspaces as dependencies
|
|
239
|
+
"allowPatterns": ["my-allow-pattern-*"],
|
|
240
|
+
// or
|
|
241
|
+
// "denyPatterns": ["my-deny-pattern-*"],
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
}
|
|
245
|
+
\`\`\`
|
|
246
|
+
|
|
247
|
+
### Workspace Dependency Rules
|
|
248
|
+
|
|
249
|
+
Using the \`rules.workspaceDependencies\` field, you can define rules for which workspaces are allowed to be dependencies,
|
|
250
|
+
using either \`allowPatterns\` or \`denyPatterns\`.
|
|
251
|
+
|
|
252
|
+
Workspace Patterns are used to match workspaces.
|
|
253
|
+
|
|
254
|
+
You can't use both \`allowPatterns\` and \`denyPatterns\` at the same time, but you can use
|
|
255
|
+
|
|
256
|
+
## TypeScript/JSON Config Files
|
|
257
|
+
|
|
258
|
+
You can use TypeScript/JSON config files to define your workspace configuration.
|
|
259
|
+
|
|
260
|
+
### TypeScript
|
|
261
|
+
|
|
262
|
+
\`bw.workspace.ts\`
|
|
263
|
+
|
|
264
|
+
\`\`\`ts
|
|
265
|
+
import { defineWorkspaceConfig } from "bun-workspaces/config";
|
|
266
|
+
|
|
267
|
+
export default defineWorkspaceConfig({
|
|
268
|
+
alias: "my-alias",
|
|
269
|
+
tags: ["my-tag"],
|
|
270
|
+
});
|
|
271
|
+
\`\`\`
|
|
272
|
+
|
|
273
|
+
\`bw.root.ts\`
|
|
274
|
+
|
|
275
|
+
\`\`\`ts
|
|
276
|
+
import { defineRootConfig } from "bun-workspaces/config";
|
|
277
|
+
|
|
278
|
+
export default defineRootConfig({
|
|
279
|
+
defaults: {
|
|
280
|
+
parallelMax: 5,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
\`\`\``;
|
|
284
|
+
|
|
285
|
+
export { DOC_API, DOC_CLI, DOC_CONCEPTS, DOC_CONFIG, DOC_OVERVIEW };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";module.exports = validate10;module.exports.default = validate10;const schema11 = {"type":"object","additionalProperties":false,"properties":{"alias":{"type":["string","array"],"items":{"type":"string"},"uniqueItems":true},"tags":{"type":"array","items":{"type":"string"},"uniqueItems":true},"scripts":{"type":"object","additionalProperties":{"type":"object","properties":{"order":{"type":"number"}},"additionalProperties":false}}}};function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){const _errs1 = errors;for(const key0 in data){if(!(((key0 === "alias") || (key0 === "tags")) || (key0 === "scripts"))){validate10.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}];return false;break;}}if(_errs1 === errors){if(data.alias !== undefined){let data0 = data.alias;const _errs2 = errors;if((typeof data0 !== "string") && (!(Array.isArray(data0)))){validate10.errors = [{instancePath:instancePath+"/alias",schemaPath:"#/properties/alias/type",keyword:"type",params:{type: schema11.properties.alias.type},message:"must be string,array"}];return false;}if(errors === _errs2){if(Array.isArray(data0)){var valid1 = true;const len0 = data0.length;for(let i0=0; i0<len0; i0++){const _errs4 = errors;if(typeof data0[i0] !== "string"){validate10.errors = [{instancePath:instancePath+"/alias/" + i0,schemaPath:"#/properties/alias/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs4 === errors;if(!valid1){break;}}if(valid1){let i1 = data0.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data0[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate10.errors = [{instancePath:instancePath+"/alias",schemaPath:"#/properties/alias/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}}var valid0 = _errs2 === errors;}else {var valid0 = true;}if(valid0){if(data.tags !== undefined){let data2 = data.tags;const _errs6 = errors;if(errors === _errs6){if(Array.isArray(data2)){var valid3 = true;const len1 = data2.length;for(let i2=0; i2<len1; i2++){const _errs8 = errors;if(typeof data2[i2] !== "string"){validate10.errors = [{instancePath:instancePath+"/tags/" + i2,schemaPath:"#/properties/tags/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid3 = _errs8 === errors;if(!valid3){break;}}if(valid3){let i3 = data2.length;let j1;if(i3 > 1){const indices1 = {};for(;i3--;){let item1 = data2[i3];if(typeof item1 !== "string"){continue;}if(typeof indices1[item1] == "number"){j1 = indices1[item1];validate10.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices1[item1] = i3;}}}}else {validate10.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs6 === errors;}else {var valid0 = true;}if(valid0){if(data.scripts !== undefined){let data4 = data.scripts;const _errs10 = errors;if(errors === _errs10){if(data4 && typeof data4 == "object" && !Array.isArray(data4)){for(const key1 in data4){let data5 = data4[key1];const _errs13 = errors;if(errors === _errs13){if(data5 && typeof data5 == "object" && !Array.isArray(data5)){const _errs15 = errors;for(const key2 in data5){if(!(key2 === "order")){validate10.errors = [{instancePath:instancePath+"/scripts/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/scripts/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"}];return false;break;}}if(_errs15 === errors){if(data5.order !== undefined){let data6 = data5.order;if(!((typeof data6 == "number") && (isFinite(data6)))){validate10.errors = [{instancePath:instancePath+"/scripts/" + key1.replace(/~/g, "~0").replace(/\//g, "~1")+"/order",schemaPath:"#/properties/scripts/additionalProperties/properties/order/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}}}else {validate10.errors = [{instancePath:instancePath+"/scripts/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/scripts/additionalProperties/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid5 = _errs13 === errors;if(!valid5){break;}}}else {validate10.errors = [{instancePath:instancePath+"/scripts",schemaPath:"#/properties/scripts/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs10 === errors;}else {var valid0 = true;}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}
|
|
1
|
+
"use strict";module.exports = validate10;module.exports.default = validate10;const schema11 = {"type":"object","additionalProperties":false,"properties":{"alias":{"type":["string","array"],"items":{"type":"string"},"uniqueItems":true},"tags":{"type":"array","items":{"type":"string"},"uniqueItems":true},"scripts":{"type":"object","additionalProperties":{"type":"object","properties":{"order":{"type":"number"}},"additionalProperties":false}},"rules":{"type":"object","additionalProperties":false,"properties":{"workspaceDependencies":{"type":"object","properties":{"allowPatterns":{"type":"array","items":{"type":"string"}},"denyPatterns":{"type":"array","items":{"type":"string"}}},"additionalProperties":false}}}}};function validate10(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){const _errs1 = errors;for(const key0 in data){if(!((((key0 === "alias") || (key0 === "tags")) || (key0 === "scripts")) || (key0 === "rules"))){validate10.errors = [{instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"}];return false;break;}}if(_errs1 === errors){if(data.alias !== undefined){let data0 = data.alias;const _errs2 = errors;if((typeof data0 !== "string") && (!(Array.isArray(data0)))){validate10.errors = [{instancePath:instancePath+"/alias",schemaPath:"#/properties/alias/type",keyword:"type",params:{type: schema11.properties.alias.type},message:"must be string,array"}];return false;}if(errors === _errs2){if(Array.isArray(data0)){var valid1 = true;const len0 = data0.length;for(let i0=0; i0<len0; i0++){const _errs4 = errors;if(typeof data0[i0] !== "string"){validate10.errors = [{instancePath:instancePath+"/alias/" + i0,schemaPath:"#/properties/alias/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs4 === errors;if(!valid1){break;}}if(valid1){let i1 = data0.length;let j0;if(i1 > 1){const indices0 = {};for(;i1--;){let item0 = data0[i1];if(typeof item0 !== "string"){continue;}if(typeof indices0[item0] == "number"){j0 = indices0[item0];validate10.errors = [{instancePath:instancePath+"/alias",schemaPath:"#/properties/alias/uniqueItems",keyword:"uniqueItems",params:{i: i1, j: j0},message:"must NOT have duplicate items (items ## "+j0+" and "+i1+" are identical)"}];return false;break;}indices0[item0] = i1;}}}}}var valid0 = _errs2 === errors;}else {var valid0 = true;}if(valid0){if(data.tags !== undefined){let data2 = data.tags;const _errs6 = errors;if(errors === _errs6){if(Array.isArray(data2)){var valid3 = true;const len1 = data2.length;for(let i2=0; i2<len1; i2++){const _errs8 = errors;if(typeof data2[i2] !== "string"){validate10.errors = [{instancePath:instancePath+"/tags/" + i2,schemaPath:"#/properties/tags/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid3 = _errs8 === errors;if(!valid3){break;}}if(valid3){let i3 = data2.length;let j1;if(i3 > 1){const indices1 = {};for(;i3--;){let item1 = data2[i3];if(typeof item1 !== "string"){continue;}if(typeof indices1[item1] == "number"){j1 = indices1[item1];validate10.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/uniqueItems",keyword:"uniqueItems",params:{i: i3, j: j1},message:"must NOT have duplicate items (items ## "+j1+" and "+i3+" are identical)"}];return false;break;}indices1[item1] = i3;}}}}else {validate10.errors = [{instancePath:instancePath+"/tags",schemaPath:"#/properties/tags/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid0 = _errs6 === errors;}else {var valid0 = true;}if(valid0){if(data.scripts !== undefined){let data4 = data.scripts;const _errs10 = errors;if(errors === _errs10){if(data4 && typeof data4 == "object" && !Array.isArray(data4)){for(const key1 in data4){let data5 = data4[key1];const _errs13 = errors;if(errors === _errs13){if(data5 && typeof data5 == "object" && !Array.isArray(data5)){const _errs15 = errors;for(const key2 in data5){if(!(key2 === "order")){validate10.errors = [{instancePath:instancePath+"/scripts/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/scripts/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key2},message:"must NOT have additional properties"}];return false;break;}}if(_errs15 === errors){if(data5.order !== undefined){let data6 = data5.order;if(!((typeof data6 == "number") && (isFinite(data6)))){validate10.errors = [{instancePath:instancePath+"/scripts/" + key1.replace(/~/g, "~0").replace(/\//g, "~1")+"/order",schemaPath:"#/properties/scripts/additionalProperties/properties/order/type",keyword:"type",params:{type: "number"},message:"must be number"}];return false;}}}}else {validate10.errors = [{instancePath:instancePath+"/scripts/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"),schemaPath:"#/properties/scripts/additionalProperties/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid5 = _errs13 === errors;if(!valid5){break;}}}else {validate10.errors = [{instancePath:instancePath+"/scripts",schemaPath:"#/properties/scripts/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs10 === errors;}else {var valid0 = true;}if(valid0){if(data.rules !== undefined){let data7 = data.rules;const _errs18 = errors;if(errors === _errs18){if(data7 && typeof data7 == "object" && !Array.isArray(data7)){const _errs20 = errors;for(const key3 in data7){if(!(key3 === "workspaceDependencies")){validate10.errors = [{instancePath:instancePath+"/rules",schemaPath:"#/properties/rules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key3},message:"must NOT have additional properties"}];return false;break;}}if(_errs20 === errors){if(data7.workspaceDependencies !== undefined){let data8 = data7.workspaceDependencies;const _errs21 = errors;if(errors === _errs21){if(data8 && typeof data8 == "object" && !Array.isArray(data8)){const _errs23 = errors;for(const key4 in data8){if(!((key4 === "allowPatterns") || (key4 === "denyPatterns"))){validate10.errors = [{instancePath:instancePath+"/rules/workspaceDependencies",schemaPath:"#/properties/rules/properties/workspaceDependencies/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key4},message:"must NOT have additional properties"}];return false;break;}}if(_errs23 === errors){if(data8.allowPatterns !== undefined){let data9 = data8.allowPatterns;const _errs24 = errors;if(errors === _errs24){if(Array.isArray(data9)){var valid9 = true;const len2 = data9.length;for(let i4=0; i4<len2; i4++){const _errs26 = errors;if(typeof data9[i4] !== "string"){validate10.errors = [{instancePath:instancePath+"/rules/workspaceDependencies/allowPatterns/" + i4,schemaPath:"#/properties/rules/properties/workspaceDependencies/properties/allowPatterns/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid9 = _errs26 === errors;if(!valid9){break;}}}else {validate10.errors = [{instancePath:instancePath+"/rules/workspaceDependencies/allowPatterns",schemaPath:"#/properties/rules/properties/workspaceDependencies/properties/allowPatterns/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid8 = _errs24 === errors;}else {var valid8 = true;}if(valid8){if(data8.denyPatterns !== undefined){let data11 = data8.denyPatterns;const _errs28 = errors;if(errors === _errs28){if(Array.isArray(data11)){var valid10 = true;const len3 = data11.length;for(let i5=0; i5<len3; i5++){const _errs30 = errors;if(typeof data11[i5] !== "string"){validate10.errors = [{instancePath:instancePath+"/rules/workspaceDependencies/denyPatterns/" + i5,schemaPath:"#/properties/rules/properties/workspaceDependencies/properties/denyPatterns/items/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid10 = _errs30 === errors;if(!valid10){break;}}}else {validate10.errors = [{instancePath:instancePath+"/rules/workspaceDependencies/denyPatterns",schemaPath:"#/properties/rules/properties/workspaceDependencies/properties/denyPatterns/type",keyword:"type",params:{type: "array"},message:"must be array"}];return false;}}var valid8 = _errs28 === errors;}else {var valid8 = true;}}}}else {validate10.errors = [{instancePath:instancePath+"/rules/workspaceDependencies",schemaPath:"#/properties/rules/properties/workspaceDependencies/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}}}}else {validate10.errors = [{instancePath:instancePath+"/rules",schemaPath:"#/properties/rules/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs18 === errors;}else {var valid0 = true;}}}}}}else {validate10.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate10.errors = vErrors;return errors === 0;}
|
|
@@ -24,6 +24,7 @@ runOnExit((codeOrSignal) => {
|
|
|
24
24
|
options,
|
|
25
25
|
) => {
|
|
26
26
|
const subprocess = Bun.spawn(argv, options);
|
|
27
|
+
logger.debug(`Subprocess spawned with pid ${subprocess.pid}`);
|
|
27
28
|
SUBPROCESS_REGISTRY[subprocess.pid] = subprocess;
|
|
28
29
|
subprocess.exited.finally(() => {
|
|
29
30
|
delete SUBPROCESS_REGISTRY[subprocess.pid];
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export * from "./cycles.mjs";
|
|
2
|
-
export * from "./resolveDependencies.mjs";
|
|
2
|
+
export * from "./resolveDependencies.mjs";
|
|
3
|
+
export * from "./validateDependencyRules.mjs"; // CONCATENATED MODULE: ./src/workspaces/dependencyGraph/index.ts
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WorkspaceMap } from "./resolveDependencies";
|
|
2
|
+
export type ValidateWorkspaceDependencyRulesOptions = {
|
|
3
|
+
workspaceMap: WorkspaceMap;
|
|
4
|
+
};
|
|
5
|
+
export declare const validateWorkspaceDependencyRules: ({
|
|
6
|
+
workspaceMap,
|
|
7
|
+
}: ValidateWorkspaceDependencyRulesOptions) => void;
|