bun-workspaces 1.5.1 → 1.5.2
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/bin/cli.js +0 -0
- package/package.json +1 -5
- package/src/1108.mjs +30 -0
- package/src/{cli/commands/commandsConfig.mjs → 2392.mjs} +52 -11
- package/src/4427.mjs +9 -0
- package/src/5166.mjs +8 -0
- package/src/8126.mjs +4 -0
- package/src/8257.mjs +4 -0
- package/src/{config/util/configLocation.mjs → 8529.mjs} +11 -2
- package/src/ai/mcp/bwMcpServer.mjs +213 -9
- package/src/ai/mcp/core/index.mjs +3 -1
- package/src/ai/mcp/core/server.mjs +1 -3
- package/src/ai/mcp/core/transport.mjs +1 -2
- package/src/ai/mcp/core/types.mjs +0 -1
- package/src/ai/mcp/index.mjs +3 -1
- package/src/ai/mcp/resources.mjs +1 -2
- package/src/ai/mcp/tools.mjs +1 -5
- package/src/cli/commands/commandHandlerUtils.mjs +2 -6
- package/src/cli/commands/commands.mjs +1 -4
- package/src/cli/commands/handleSimpleCommands.mjs +4 -10
- package/src/cli/commands/index.mjs +11 -2
- package/src/cli/commands/mcp.mjs +1 -4
- package/src/cli/commands/runScript/handleRunScript.mjs +1 -9
- package/src/cli/commands/runScript/index.mjs +3 -1
- package/src/cli/commands/runScript/output/index.mjs +3 -1
- package/src/cli/commands/runScript/output/outputStyle.mjs +1 -3
- package/src/cli/commands/runScript/output/renderGroupedOutput.mjs +1 -6
- package/src/cli/commands/runScript/output/renderPlainOutput.mjs +1 -2
- package/src/cli/commands/runScript/output/sanitizeChunk.mjs +0 -1
- package/src/cli/createCli.mjs +2 -12
- package/src/cli/fatalErrorLogger.mjs +1 -2
- package/src/cli/globalOptions/globalOptions.mjs +2 -9
- package/src/cli/globalOptions/index.mjs +3 -2
- package/src/cli/index.d.ts +1025 -3
- package/src/cli/index.mjs +3 -1
- package/src/cli/middleware.mjs +1 -3
- package/src/config/index.mjs +3 -1
- package/src/config/public.d.ts +93 -10
- package/src/config/public.mjs +2 -6
- package/src/config/rootConfig/defineRootConfig.mjs +1 -2
- package/src/config/rootConfig/errors.mjs +1 -2
- package/src/config/rootConfig/index.mjs +2 -1
- package/src/config/rootConfig/loadRootConfig.mjs +1 -4
- package/src/config/rootConfig/rootConfig.mjs +1 -6
- package/src/config/rootConfig/rootConfigSchema.mjs +0 -1
- package/src/config/userEnvVars/index.mjs +3 -1
- package/src/config/userEnvVars/userEnvVars.mjs +3 -8
- package/src/config/util/ajvTypes.mjs +2 -1
- package/src/config/util/index.mjs +2 -1
- package/src/config/util/loadConfig.mjs +1 -6
- package/src/config/util/validateConfig.mjs +0 -1
- package/src/config/workspaceConfig/defineWorkspaceConfig.mjs +1 -2
- package/src/config/workspaceConfig/errors.mjs +1 -2
- package/src/config/workspaceConfig/index.mjs +2 -1
- package/src/config/workspaceConfig/loadWorkspaceConfig.mjs +2 -8
- package/src/config/workspaceConfig/workspaceConfig.mjs +1 -5
- package/src/config/workspaceConfig/workspaceConfigSchema.mjs +0 -1
- package/src/doctor/doctor.mjs +1 -5
- package/src/doctor/index.mjs +3 -1
- package/src/index.d.ts +458 -38
- package/src/index.mjs +4 -13
- package/src/internal/bun/bunLock.mjs +2 -4
- package/src/internal/bun/bunVersion.mjs +1 -3
- package/src/internal/bun/index.mjs +3 -1
- package/src/internal/bundledDeps/commander.mjs +3843 -0
- package/src/internal/bundledDeps/shellQuote.mjs +291 -0
- package/src/internal/core/error/error.mjs +0 -1
- package/src/internal/core/error/index.mjs +3 -1
- package/src/internal/core/index.mjs +3 -1
- package/src/internal/core/json/index.mjs +3 -1
- package/src/internal/core/json/json.mjs +3 -5
- package/src/internal/core/json/jsonc.mjs +0 -1
- package/src/internal/core/language/array/index.mjs +3 -1
- package/src/internal/core/language/array/optionalArray.mjs +0 -1
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.mjs +0 -1
- package/src/internal/core/language/asyncIterable/index.mjs +3 -1
- package/src/internal/core/language/asyncIterable/mergeAsyncIterables.mjs +0 -1
- package/src/internal/core/language/events/typedEventTarget.mjs +0 -1
- package/src/internal/core/language/index.mjs +3 -1
- package/src/internal/core/language/regex/index.mjs +3 -1
- package/src/internal/core/language/regex/regex.mjs +0 -1
- package/src/internal/core/language/string/id.mjs +0 -1
- package/src/internal/core/language/string/index.mjs +3 -1
- package/src/internal/core/language/string/utf/eastAsianWidth.mjs +0 -1
- package/src/internal/core/language/string/utf/visibleLength.mjs +1 -2
- package/src/internal/core/language/types/index.mjs +3 -1
- package/src/internal/core/language/types/typeof.mjs +1 -3
- package/src/internal/core/language/types/types.mjs +3 -2
- package/src/internal/core/runtime/env.mjs +0 -1
- package/src/internal/core/runtime/index.mjs +3 -1
- package/src/internal/core/runtime/onExit.mjs +1 -2
- package/src/internal/core/runtime/os.mjs +1 -3
- package/src/internal/core/runtime/tempFile.mjs +1 -9
- package/src/internal/core/runtime/terminal.mjs +0 -1
- package/src/internal/generated/aiDocs/.gitkeep.mjs +1 -0
- package/src/internal/generated/aiDocs/docs.mjs +0 -1
- package/src/internal/logger/index.mjs +3 -1
- package/src/internal/logger/logger.mjs +4 -14
- package/src/internal/version.mjs +1 -2
- package/src/project/errors.mjs +1 -2
- package/src/project/implementations/fileSystemProject.mjs +3 -18
- package/src/project/implementations/memoryProject.mjs +1 -5
- package/src/project/implementations/projectBase.mjs +10 -19
- package/src/project/index.mjs +3 -1
- package/src/project/project.mjs +2 -1
- package/src/rslib-runtime.mjs +62 -0
- package/src/runScript/index.mjs +3 -1
- package/src/runScript/output/index.mjs +3 -1
- package/src/runScript/output/multiProcessOutput.mjs +1 -2
- package/src/runScript/output/outputStream.mjs +1 -1
- package/src/runScript/output/processOutput.mjs +1 -2
- package/src/runScript/parallel.mjs +4 -10
- package/src/runScript/recursion.mjs +1 -2
- package/src/runScript/runScript.mjs +1 -4
- package/src/runScript/runScripts.mjs +1 -6
- package/src/runScript/scriptCommand.mjs +1 -2
- package/src/runScript/scriptExecution.mjs +1 -3
- package/src/runScript/scriptRuntimeMetadata.mjs +38 -56
- package/src/runScript/scriptShellOption.mjs +5 -14
- package/src/runScript/subprocesses.mjs +1 -3
- package/src/workspaces/dependencyGraph/cycles.mjs +0 -1
- package/src/workspaces/dependencyGraph/index.mjs +3 -1
- package/src/workspaces/dependencyGraph/resolveDependencies.mjs +1 -2
- package/src/workspaces/dependencyGraph/validateDependencyRules.mjs +1 -3
- package/src/workspaces/errors.mjs +1 -2
- package/src/workspaces/findWorkspaces.mjs +1 -11
- package/src/workspaces/index.mjs +3 -1
- package/src/workspaces/packageJson.mjs +2 -7
- package/src/workspaces/workspace.mjs +2 -1
- package/src/workspaces/workspacePattern.mjs +4 -4
- package/src/ai/mcp/bwMcpServer.d.ts +0 -4
- package/src/ai/mcp/core/index.d.ts +0 -3
- package/src/ai/mcp/core/server.d.ts +0 -14
- package/src/ai/mcp/core/transport.d.ts +0 -12
- package/src/ai/mcp/core/types.d.ts +0 -104
- package/src/ai/mcp/index.d.ts +0 -2
- package/src/ai/mcp/resources.d.ts +0 -6
- package/src/ai/mcp/tools.d.ts +0 -6
- package/src/cli/commands/commandHandlerUtils.d.ts +0 -51
- package/src/cli/commands/commands.d.ts +0 -10
- package/src/cli/commands/commandsConfig.d.ts +0 -436
- package/src/cli/commands/handleSimpleCommands.d.ts +0 -21
- package/src/cli/commands/index.d.ts +0 -4
- package/src/cli/commands/mcp.d.ts +0 -3
- package/src/cli/commands/runScript/handleRunScript.d.ts +0 -3
- package/src/cli/commands/runScript/index.d.ts +0 -2
- package/src/cli/commands/runScript/output/index.d.ts +0 -1
- package/src/cli/commands/runScript/output/outputStyle.d.ts +0 -9
- package/src/cli/commands/runScript/output/renderGroupedOutput.d.ts +0 -75
- package/src/cli/commands/runScript/output/renderPlainOutput.d.ts +0 -24
- package/src/cli/commands/runScript/output/sanitizeChunk.d.ts +0 -4
- package/src/cli/createCli.d.ts +0 -26
- package/src/cli/fatalErrorLogger.d.ts +0 -1
- package/src/cli/globalOptions/globalOptions.d.ts +0 -43
- package/src/cli/globalOptions/globalOptionsConfig.d.ts +0 -52
- package/src/cli/globalOptions/globalOptionsConfig.mjs +0 -43
- package/src/cli/globalOptions/index.d.ts +0 -2
- package/src/cli/middleware.d.ts +0 -83
- package/src/config/index.d.ts +0 -3
- package/src/config/rootConfig/defineRootConfig.d.ts +0 -4
- package/src/config/rootConfig/errors.d.ts +0 -1
- package/src/config/rootConfig/index.d.ts +0 -5
- package/src/config/rootConfig/loadRootConfig.d.ts +0 -3
- package/src/config/rootConfig/rootConfig.d.ts +0 -25
- package/src/config/rootConfig/rootConfigLocation.d.ts +0 -2
- package/src/config/rootConfig/rootConfigLocation.mjs +0 -5
- package/src/config/rootConfig/rootConfigSchema.d.ts +0 -21
- package/src/config/userEnvVars/index.d.ts +0 -1
- package/src/config/userEnvVars/userEnvVars.d.ts +0 -13
- package/src/config/util/ajvTypes.d.ts +0 -10
- package/src/config/util/configLocation.d.ts +0 -18
- package/src/config/util/index.d.ts +0 -4
- package/src/config/util/loadConfig.d.ts +0 -18
- package/src/config/util/validateConfig.d.ts +0 -8
- package/src/config/workspaceConfig/defineWorkspaceConfig.d.ts +0 -7
- package/src/config/workspaceConfig/errors.d.ts +0 -1
- package/src/config/workspaceConfig/index.d.ts +0 -5
- package/src/config/workspaceConfig/loadWorkspaceConfig.d.ts +0 -3
- package/src/config/workspaceConfig/workspaceConfig.d.ts +0 -56
- package/src/config/workspaceConfig/workspaceConfigLocation.d.ts +0 -2
- package/src/config/workspaceConfig/workspaceConfigLocation.mjs +0 -5
- package/src/config/workspaceConfig/workspaceConfigSchema.d.ts +0 -56
- package/src/doctor/doctor.d.ts +0 -35
- package/src/doctor/index.d.ts +0 -1
- package/src/internal/bun/bunLock.d.ts +0 -20
- package/src/internal/bun/bunVersion.d.ts +0 -21
- package/src/internal/bun/index.d.ts +0 -2
- package/src/internal/core/error/error.d.ts +0 -13
- package/src/internal/core/error/index.d.ts +0 -1
- package/src/internal/core/index.d.ts +0 -4
- package/src/internal/core/json/index.d.ts +0 -2
- package/src/internal/core/json/json.d.ts +0 -49
- package/src/internal/core/json/jsonc.d.ts +0 -9
- package/src/internal/core/language/array/index.d.ts +0 -1
- package/src/internal/core/language/array/optionalArray.d.ts +0 -15
- package/src/internal/core/language/asyncIterable/asyncIterableQueue.d.ts +0 -16
- package/src/internal/core/language/asyncIterable/index.d.ts +0 -2
- package/src/internal/core/language/asyncIterable/mergeAsyncIterables.d.ts +0 -5
- package/src/internal/core/language/events/typedEventTarget.d.ts +0 -50
- package/src/internal/core/language/index.d.ts +0 -5
- package/src/internal/core/language/regex/index.d.ts +0 -1
- package/src/internal/core/language/regex/regex.d.ts +0 -3
- package/src/internal/core/language/string/id.d.ts +0 -1
- package/src/internal/core/language/string/index.d.ts +0 -1
- package/src/internal/core/language/string/utf/eastAsianWidth.d.ts +0 -16
- package/src/internal/core/language/string/utf/visibleLength.d.ts +0 -5
- package/src/internal/core/language/types/index.d.ts +0 -2
- package/src/internal/core/language/types/typeof.d.ts +0 -102
- package/src/internal/core/language/types/types.d.ts +0 -19
- package/src/internal/core/runtime/env.d.ts +0 -6
- package/src/internal/core/runtime/index.d.ts +0 -5
- package/src/internal/core/runtime/onExit.d.ts +0 -4
- package/src/internal/core/runtime/os.d.ts +0 -6
- package/src/internal/core/runtime/tempFile.d.ts +0 -20
- package/src/internal/core/runtime/terminal.d.ts +0 -1
- package/src/internal/docs/apiQuickstart.d.ts +0 -3
- package/src/internal/docs/apiQuickstart.mjs +0 -132
- package/src/internal/docs/cliQuickstart.d.ts +0 -2
- package/src/internal/docs/cliQuickstart.mjs +0 -86
- package/src/internal/docs/index.d.ts +0 -2
- package/src/internal/docs/index.mjs +0 -2
- package/src/internal/generated/aiDocs/docs.d.ts +0 -10
- package/src/internal/logger/index.d.ts +0 -1
- package/src/internal/logger/logger.d.ts +0 -45
- package/src/internal/version.d.ts +0 -1
- package/src/project/errors.d.ts +0 -5
- package/src/project/implementations/fileSystemProject.d.ts +0 -148
- package/src/project/implementations/memoryProject.d.ts +0 -41
- package/src/project/implementations/projectBase.d.ts +0 -37
- package/src/project/index.d.ts +0 -5
- package/src/project/project.d.ts +0 -79
- package/src/runScript/index.d.ts +0 -7
- package/src/runScript/output/index.d.ts +0 -3
- package/src/runScript/output/multiProcessOutput.d.ts +0 -14
- package/src/runScript/output/outputStream.d.ts +0 -1
- package/src/runScript/output/processOutput.d.ts +0 -33
- package/src/runScript/parallel.d.ts +0 -24
- package/src/runScript/recursion.d.ts +0 -4
- package/src/runScript/runScript.d.ts +0 -45
- package/src/runScript/runScripts.d.ts +0 -65
- package/src/runScript/scriptCommand.d.ts +0 -33
- package/src/runScript/scriptExecution.d.ts +0 -9
- package/src/runScript/scriptRuntimeMetadata.d.ts +0 -73
- package/src/runScript/scriptShellOption.d.ts +0 -8
- package/src/runScript/subprocesses.d.ts +0 -11
- package/src/workspaces/dependencyGraph/cycles.d.ts +0 -9
- package/src/workspaces/dependencyGraph/index.d.ts +0 -3
- package/src/workspaces/dependencyGraph/resolveDependencies.d.ts +0 -18
- package/src/workspaces/dependencyGraph/validateDependencyRules.d.ts +0 -7
- package/src/workspaces/errors.d.ts +0 -14
- package/src/workspaces/findWorkspaces.d.ts +0 -24
- package/src/workspaces/index.d.ts +0 -4
- package/src/workspaces/packageJson.d.ts +0 -31
- package/src/workspaces/workspace.d.ts +0 -21
- package/src/workspaces/workspacePattern.d.ts +0 -22
|
@@ -1,10 +0,0 @@
|
|
|
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```';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./logger";
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
2
|
-
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
3
|
-
export type LogLevelSetting = LogLevel | "silent";
|
|
4
|
-
export declare const LOGGER_ERRORS: import("../core").DefinedErrors<"InvalidLogLevel">;
|
|
5
|
-
export declare const validateLogLevel: (level: LogLevelSetting) => void;
|
|
6
|
-
export type LogMetadata = Record<string, unknown>;
|
|
7
|
-
export interface Log<
|
|
8
|
-
Message extends string | Error = string,
|
|
9
|
-
Metadata extends LogMetadata = LogMetadata,
|
|
10
|
-
> {
|
|
11
|
-
message: Message;
|
|
12
|
-
level: LogLevel;
|
|
13
|
-
metadata: Metadata;
|
|
14
|
-
time: Date;
|
|
15
|
-
}
|
|
16
|
-
export type Logger = {
|
|
17
|
-
name: string;
|
|
18
|
-
log<
|
|
19
|
-
Message extends string | Error = string,
|
|
20
|
-
Metadata extends LogMetadata = LogMetadata,
|
|
21
|
-
>(
|
|
22
|
-
message: Message,
|
|
23
|
-
level: LogLevel,
|
|
24
|
-
metadata?: Metadata,
|
|
25
|
-
): Log<Message, Metadata>;
|
|
26
|
-
printLevel: LogLevelSetting;
|
|
27
|
-
setPrintStdout: (
|
|
28
|
-
stdout: (...args: Parameters<typeof process.stdout.write>) => void,
|
|
29
|
-
) => void;
|
|
30
|
-
setPrintStderr: (
|
|
31
|
-
stderr: (...args: Parameters<typeof process.stderr.write>) => void,
|
|
32
|
-
) => void;
|
|
33
|
-
} & {
|
|
34
|
-
[Level in LogLevel]: <
|
|
35
|
-
Message extends string | Error = string,
|
|
36
|
-
Metadata extends LogMetadata = LogMetadata,
|
|
37
|
-
>(
|
|
38
|
-
message: Message,
|
|
39
|
-
metadata?: Metadata,
|
|
40
|
-
) => Log<Message, Metadata>;
|
|
41
|
-
};
|
|
42
|
-
export declare const createLogger: (name: string) => Logger;
|
|
43
|
-
export declare const logger: Logger;
|
|
44
|
-
/** Set the global logging level. Defaults to "info" or "error" when `NODE_ENV` is "test" */
|
|
45
|
-
export declare const setLogLevel: (level: LogLevelSetting) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const BUN_WORKSPACES_VERSION: string;
|
package/src/project/errors.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import type { Simplify } from "../../internal/core";
|
|
2
|
-
import {
|
|
3
|
-
type RunScriptsParallelOptions,
|
|
4
|
-
type RunScriptsSummary,
|
|
5
|
-
type RunScriptExit,
|
|
6
|
-
type OutputStreamName,
|
|
7
|
-
type ScriptEventName,
|
|
8
|
-
} from "../../runScript";
|
|
9
|
-
import type { MultiProcessOutput } from "../../runScript/output/multiProcessOutput";
|
|
10
|
-
import { type ScriptShellOption } from "../../runScript/scriptShellOption";
|
|
11
|
-
import { type Workspace } from "../../workspaces";
|
|
12
|
-
import type { Project, ProjectConfig } from "../project";
|
|
13
|
-
import { ProjectBase } from "./projectBase";
|
|
14
|
-
/** Arguments for {@link createFileSystemProject} */
|
|
15
|
-
export type CreateFileSystemProjectOptions = {
|
|
16
|
-
/** The directory containing the root package.json. Often the same root as a git repository. Relative to process.cwd(). The default is process.cwd(). */
|
|
17
|
-
rootDirectory?: string;
|
|
18
|
-
/**
|
|
19
|
-
* The name of the project.
|
|
20
|
-
*
|
|
21
|
-
* By default will use the root package.json name
|
|
22
|
-
*/
|
|
23
|
-
name?: string;
|
|
24
|
-
/** Whether to include the root workspace as a normal workspace. This overrides any config or env var settings. */
|
|
25
|
-
includeRootWorkspace?: boolean;
|
|
26
|
-
};
|
|
27
|
-
export type ShellOption = ScriptShellOption | "default";
|
|
28
|
-
export type InlineScriptOptions = {
|
|
29
|
-
/** A name to act as a label for the inline script */
|
|
30
|
-
scriptName?: string;
|
|
31
|
-
/** Whether to run the script as an inline command */
|
|
32
|
-
shell?: ShellOption;
|
|
33
|
-
};
|
|
34
|
-
/** Arguments for `FileSystemProject.runWorkspaceScript` */
|
|
35
|
-
export type RunWorkspaceScriptOptions = {
|
|
36
|
-
/** The name of the workspace to run the script in */
|
|
37
|
-
workspaceNameOrAlias: string;
|
|
38
|
-
/** The name of the script to run, or an inline command when `inline` is true */
|
|
39
|
-
script: string;
|
|
40
|
-
/** Whether to run the script as an inline command */
|
|
41
|
-
inline?: boolean | InlineScriptOptions;
|
|
42
|
-
/** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
|
|
43
|
-
args?: string | string[];
|
|
44
|
-
/** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
|
|
45
|
-
ignoreOutput?: boolean;
|
|
46
|
-
};
|
|
47
|
-
/** Metadata associated with a workspace script */
|
|
48
|
-
export type RunWorkspaceScriptMetadata = {
|
|
49
|
-
/** The workspace that the script was run in */
|
|
50
|
-
workspace: Workspace;
|
|
51
|
-
};
|
|
52
|
-
export type RunWorkspaceScriptExit = Simplify<
|
|
53
|
-
RunScriptExit<RunWorkspaceScriptMetadata>
|
|
54
|
-
>;
|
|
55
|
-
export type RunWorkspaceScriptProcessOutput = MultiProcessOutput<
|
|
56
|
-
RunWorkspaceScriptMetadata & {
|
|
57
|
-
streamName: OutputStreamName;
|
|
58
|
-
}
|
|
59
|
-
>;
|
|
60
|
-
/** Result of `FileSystemProject.runWorkspaceScript` */
|
|
61
|
-
export type RunWorkspaceScriptResult = {
|
|
62
|
-
/** Use to get the output of the script */
|
|
63
|
-
output: RunWorkspaceScriptProcessOutput;
|
|
64
|
-
/** The exit result of the script */
|
|
65
|
-
exit: Promise<RunWorkspaceScriptExit>;
|
|
66
|
-
};
|
|
67
|
-
export type ParallelOption = boolean | RunScriptsParallelOptions;
|
|
68
|
-
export type ScriptEventMetadata = {
|
|
69
|
-
/** The workspace that the script event occurred in */
|
|
70
|
-
workspace: Workspace;
|
|
71
|
-
/** The exit result of the script */
|
|
72
|
-
exitResult: RunScriptExit<RunWorkspaceScriptMetadata> | null;
|
|
73
|
-
};
|
|
74
|
-
export type OnScriptEventCallback = (
|
|
75
|
-
/** The event that occurred */
|
|
76
|
-
event: ScriptEventName,
|
|
77
|
-
/** The metadata for the script event */
|
|
78
|
-
metadata: ScriptEventMetadata,
|
|
79
|
-
) => unknown;
|
|
80
|
-
/** Arguments for `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
81
|
-
export type RunScriptAcrossWorkspacesOptions = {
|
|
82
|
-
/**
|
|
83
|
-
* Workspace names, aliases, or patterns including a wildcard.
|
|
84
|
-
*
|
|
85
|
-
* When not provided, all workspaces that the script can be ran in will be used.
|
|
86
|
-
*/
|
|
87
|
-
workspacePatterns?: string[];
|
|
88
|
-
/** The name of the script to run, or an inline command when `inline` is true */
|
|
89
|
-
script: string;
|
|
90
|
-
/** Whether to run the script as an inline command */
|
|
91
|
-
inline?: boolean | InlineScriptOptions;
|
|
92
|
-
/** The arguments to append to the script command. If passed as a string, the argv will be parsed POSIX-style */
|
|
93
|
-
args?: string | string[];
|
|
94
|
-
/** Whether to run the scripts in parallel (default: `true`). Pass `false` to run in series. */
|
|
95
|
-
parallel?: ParallelOption;
|
|
96
|
-
/** When `true`, run scripts so that dependent workspaces run only after their dependencies */
|
|
97
|
-
dependencyOrder?: boolean;
|
|
98
|
-
/** When `true`, continue running scripts even if a dependency fails (Only relevant when `dependencyOrder` is `true`) */
|
|
99
|
-
ignoreDependencyFailure?: boolean;
|
|
100
|
-
/** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
|
|
101
|
-
ignoreOutput?: boolean;
|
|
102
|
-
/** Callback to invoke when a script event occurs (start, skip, exit) */
|
|
103
|
-
onScriptEvent?: OnScriptEventCallback;
|
|
104
|
-
};
|
|
105
|
-
export type RunScriptAcrossWorkspacesSummary = Simplify<
|
|
106
|
-
RunScriptsSummary<RunWorkspaceScriptMetadata>
|
|
107
|
-
>;
|
|
108
|
-
export type RunScriptAcrossWorkspacesOutput = MultiProcessOutput<
|
|
109
|
-
RunWorkspaceScriptMetadata & {
|
|
110
|
-
streamName: OutputStreamName;
|
|
111
|
-
}
|
|
112
|
-
>;
|
|
113
|
-
/** Result of `FileSystemProject.runScriptAcrossWorkspaces` */
|
|
114
|
-
export type RunScriptAcrossWorkspacesResult = {
|
|
115
|
-
/** Use to get the output of the scripts */
|
|
116
|
-
output: RunScriptAcrossWorkspacesOutput;
|
|
117
|
-
/** The summary of the script run with exit details for each workspace */
|
|
118
|
-
summary: Promise<RunScriptAcrossWorkspacesSummary>;
|
|
119
|
-
/** The workspaces targeted */
|
|
120
|
-
workspaces: Workspace[];
|
|
121
|
-
};
|
|
122
|
-
declare class _FileSystemProject extends ProjectBase implements Project {
|
|
123
|
-
#private;
|
|
124
|
-
readonly rootDirectory: string;
|
|
125
|
-
readonly workspaces: Workspace[];
|
|
126
|
-
readonly name: string;
|
|
127
|
-
readonly sourceType = "fileSystem";
|
|
128
|
-
readonly config: ProjectConfig;
|
|
129
|
-
readonly rootWorkspace: Workspace;
|
|
130
|
-
constructor(options: CreateFileSystemProjectOptions);
|
|
131
|
-
runWorkspaceScript(
|
|
132
|
-
options: RunWorkspaceScriptOptions,
|
|
133
|
-
): RunWorkspaceScriptResult;
|
|
134
|
-
runScriptAcrossWorkspaces(
|
|
135
|
-
options: RunScriptAcrossWorkspacesOptions,
|
|
136
|
-
): RunScriptAcrossWorkspacesResult;
|
|
137
|
-
}
|
|
138
|
-
/** An implementation of {@link Project} that is created from a root directory in the file system. */
|
|
139
|
-
export type FileSystemProject = Simplify<_FileSystemProject>;
|
|
140
|
-
/**
|
|
141
|
-
* Create a {@link Project} based on a given root directory.
|
|
142
|
-
* Automatically finds workspaces based on the root package.json "workspaces" field
|
|
143
|
-
* and detects and utilizes any provided configuration.
|
|
144
|
-
*/
|
|
145
|
-
export declare const createFileSystemProject: (
|
|
146
|
-
options?: CreateFileSystemProjectOptions,
|
|
147
|
-
) => FileSystemProject;
|
|
148
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Simplify } from "../../internal/core";
|
|
2
|
-
import { type Workspace } from "../../workspaces";
|
|
3
|
-
import type { Project } from "../project";
|
|
4
|
-
import { ProjectBase } from "./projectBase";
|
|
5
|
-
/** Arguments for {@link createMemoryProject} */
|
|
6
|
-
export type CreateMemoryProjectOptions = {
|
|
7
|
-
/** The list of workspaces in the project */
|
|
8
|
-
workspaces: Workspace[];
|
|
9
|
-
/** The name of the project */
|
|
10
|
-
name?: string;
|
|
11
|
-
/** The root directory of the project (not used in any actual file system interactions in a {@link MemoryProject}) */
|
|
12
|
-
rootDirectory?: string;
|
|
13
|
-
/** The root workspace */
|
|
14
|
-
rootWorkspace?: Workspace;
|
|
15
|
-
/** Whether to include the root workspace as a normal workspace. */
|
|
16
|
-
includeRootWorkspace?: boolean;
|
|
17
|
-
};
|
|
18
|
-
declare class _MemoryProject extends ProjectBase implements Project {
|
|
19
|
-
readonly rootDirectory: string;
|
|
20
|
-
readonly workspaces: Workspace[];
|
|
21
|
-
readonly name: string;
|
|
22
|
-
readonly sourceType = "memory";
|
|
23
|
-
readonly config: {
|
|
24
|
-
root: import("../..").ResolvedRootConfig;
|
|
25
|
-
workspaces: {};
|
|
26
|
-
};
|
|
27
|
-
readonly rootWorkspace: Workspace;
|
|
28
|
-
constructor(options: CreateMemoryProjectOptions);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* An implementation of {@link Project} that is created from a list of workspaces in memory.
|
|
32
|
-
*
|
|
33
|
-
* Mainly used for testing without needing a real file system project. */
|
|
34
|
-
export type MemoryProject = Simplify<InstanceType<typeof _MemoryProject>>;
|
|
35
|
-
/** Create a {@link Project} from a provided list of workspace objects.
|
|
36
|
-
*
|
|
37
|
-
* Mainly used for testing without needing a real file system project. */
|
|
38
|
-
export declare const createMemoryProject: (
|
|
39
|
-
options: CreateMemoryProjectOptions,
|
|
40
|
-
) => MemoryProject;
|
|
41
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type Workspace } from "../../workspaces";
|
|
2
|
-
import type {
|
|
3
|
-
CreateProjectScriptCommandOptions,
|
|
4
|
-
CreateProjectScriptCommandResult,
|
|
5
|
-
Project,
|
|
6
|
-
ProjectConfig,
|
|
7
|
-
WorkspaceScriptMetadata,
|
|
8
|
-
} from "../project";
|
|
9
|
-
export declare const resolveWorkspacePath: (
|
|
10
|
-
project: Project,
|
|
11
|
-
workspace: Workspace,
|
|
12
|
-
) => string;
|
|
13
|
-
export declare const ROOT_WORKSPACE_SELECTOR = "@root";
|
|
14
|
-
export declare const resolveRootWorkspaceSelector: (
|
|
15
|
-
workspacePattern: string,
|
|
16
|
-
project: Project,
|
|
17
|
-
) => Workspace | null;
|
|
18
|
-
export declare abstract class ProjectBase implements Project {
|
|
19
|
-
abstract readonly name: string;
|
|
20
|
-
abstract readonly rootDirectory: string;
|
|
21
|
-
abstract readonly rootWorkspace: Workspace;
|
|
22
|
-
abstract readonly workspaces: Workspace[];
|
|
23
|
-
abstract readonly sourceType: "fileSystem" | "memory";
|
|
24
|
-
abstract readonly config: ProjectConfig;
|
|
25
|
-
constructor(_ignoreBunVersion?: boolean);
|
|
26
|
-
listWorkspacesWithScript(scriptName: string): Workspace[];
|
|
27
|
-
mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
|
|
28
|
-
mapTagsToWorkspaces(): Record<string, Workspace[]>;
|
|
29
|
-
findWorkspaceByName(workspaceName: string): Workspace | null;
|
|
30
|
-
findWorkspaceByAlias(alias: string): Workspace | null;
|
|
31
|
-
findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
|
|
32
|
-
listWorkspacesWithTag(tag: string): Workspace[];
|
|
33
|
-
findWorkspacesByPattern(...workspacePatterns: string[]): Workspace[];
|
|
34
|
-
createScriptCommand(
|
|
35
|
-
options: CreateProjectScriptCommandOptions,
|
|
36
|
-
): CreateProjectScriptCommandResult;
|
|
37
|
-
}
|
package/src/project/index.d.ts
DELETED
package/src/project/project.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { ResolvedRootConfig, ResolvedWorkspaceConfig } from "../config";
|
|
2
|
-
import type { ScriptCommand, WorkspaceScriptCommandMethod } from "../runScript";
|
|
3
|
-
import type { Workspace } from "../workspaces";
|
|
4
|
-
/** Metadata about a {@link Project}'s script, including the workspaces that have it in their package.json */
|
|
5
|
-
export type WorkspaceScriptMetadata = {
|
|
6
|
-
name: string;
|
|
7
|
-
workspaces: Workspace[];
|
|
8
|
-
};
|
|
9
|
-
/** Arguments for {@link Project.createScriptCommand} */
|
|
10
|
-
export type CreateProjectScriptCommandOptions = {
|
|
11
|
-
/** The workspace to run the script in */
|
|
12
|
-
workspaceNameOrAlias: string;
|
|
13
|
-
/** The name of the script to run */
|
|
14
|
-
scriptName: string;
|
|
15
|
-
/**
|
|
16
|
-
* The method to use to run the script.
|
|
17
|
-
* Either run in the workspace directory or use bun's --filter option.
|
|
18
|
-
* Defaults to "cd".
|
|
19
|
-
*/
|
|
20
|
-
method?: WorkspaceScriptCommandMethod;
|
|
21
|
-
/** The arguments to append to the command */
|
|
22
|
-
args?: string;
|
|
23
|
-
};
|
|
24
|
-
/** Result of {@link Project.createScriptCommand}. Includes a command string that will run a workspace's script. */
|
|
25
|
-
export type CreateProjectScriptCommandResult = {
|
|
26
|
-
/** Data including a command string using the `bun`
|
|
27
|
-
* CLI that will run a workspace's script and the
|
|
28
|
-
* directory to run it in. */
|
|
29
|
-
commandDetails: ScriptCommand;
|
|
30
|
-
/** The name of the script to run */
|
|
31
|
-
scriptName: string;
|
|
32
|
-
/** The workspace that the script belongs to */
|
|
33
|
-
workspace: Workspace;
|
|
34
|
-
};
|
|
35
|
-
/** The config for a project and its workspaces */
|
|
36
|
-
export type ProjectConfig = {
|
|
37
|
-
root: ResolvedRootConfig;
|
|
38
|
-
/** A map of workspace names to their resolved config */
|
|
39
|
-
workspaces: Record<string, ResolvedWorkspaceConfig>;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* A project contains a collection of workspaces and is the core of `bun-workspaces`'s functionality.
|
|
43
|
-
*
|
|
44
|
-
* Typically based on a root package.json file's `"workspaces"` field and any matching nested package.json files that are found.
|
|
45
|
-
*/
|
|
46
|
-
export interface Project {
|
|
47
|
-
/** The name of the project. This is typically the name of the root package.json unless otherwise provided. */
|
|
48
|
-
name: string;
|
|
49
|
-
/** The root directory of the project */
|
|
50
|
-
rootDirectory: string;
|
|
51
|
-
/** The root workspace of the project */
|
|
52
|
-
rootWorkspace: Workspace;
|
|
53
|
-
/** The list of all workspaces in the project */
|
|
54
|
-
workspaces: Workspace[];
|
|
55
|
-
/** The config for the project and its workspaces */
|
|
56
|
-
config: ProjectConfig;
|
|
57
|
-
/** The means by which the project was created */
|
|
58
|
-
sourceType: "fileSystem" | "memory";
|
|
59
|
-
/** Find a workspace by its package.json name */
|
|
60
|
-
findWorkspaceByName(workspaceName: string): Workspace | null;
|
|
61
|
-
/** Find a workspace by a workspace alias */
|
|
62
|
-
findWorkspaceByAlias(alias: string): Workspace | null;
|
|
63
|
-
/** Find a workspace that matches a workspace's name or an alias if no name matches. */
|
|
64
|
-
findWorkspaceByNameOrAlias(nameOrAlias: string): Workspace | null;
|
|
65
|
-
/** Find a list of workspaces that have a given tag in their configuration */
|
|
66
|
-
listWorkspacesWithTag(tag: string): Workspace[];
|
|
67
|
-
/** Accepts a wildcard pattern for finding a list of workspaces by their name*/
|
|
68
|
-
findWorkspacesByPattern(workspacePattern: string): Workspace[];
|
|
69
|
-
/** Get an array of all workspaces that have a given script in their package.json */
|
|
70
|
-
listWorkspacesWithScript(scriptName: string): Workspace[];
|
|
71
|
-
/** Get a mapping of all scripts to the workspaces that have them in their package.json */
|
|
72
|
-
mapScriptsToWorkspaces(): Record<string, WorkspaceScriptMetadata>;
|
|
73
|
-
/** Get a mapping of all tags to the workspaces that have them in their config */
|
|
74
|
-
mapTagsToWorkspaces(): Record<string, Workspace[]>;
|
|
75
|
-
/** Create metadata that can be used to run a workspace's script */
|
|
76
|
-
createScriptCommand(
|
|
77
|
-
options: CreateProjectScriptCommandOptions,
|
|
78
|
-
): CreateProjectScriptCommandResult;
|
|
79
|
-
}
|
package/src/runScript/index.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ProcessOutput,
|
|
3
|
-
type BytesOutput,
|
|
4
|
-
type TextOutput,
|
|
5
|
-
} from "./processOutput";
|
|
6
|
-
export interface MultiProcessOutput<Metadata extends object = object> {
|
|
7
|
-
bytes(): BytesOutput<Metadata>;
|
|
8
|
-
text(): TextOutput<Metadata>;
|
|
9
|
-
}
|
|
10
|
-
export declare const createMultiProcessOutput: <
|
|
11
|
-
Metadata extends object = object,
|
|
12
|
-
>(
|
|
13
|
-
processes: ProcessOutput<Metadata>[],
|
|
14
|
-
) => MultiProcessOutput<Metadata>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type OutputStreamName = "stdout" | "stderr";
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type SimpleAsyncIterable } from "../../internal/core";
|
|
2
|
-
export type ByteStream = SimpleAsyncIterable<Uint8Array<ArrayBufferLike>>;
|
|
3
|
-
export type ProcessOutputChunk<
|
|
4
|
-
Chunk = unknown,
|
|
5
|
-
Metadata extends object = object,
|
|
6
|
-
> = {
|
|
7
|
-
/** The metadata for the script that produced the output chunk */
|
|
8
|
-
metadata: Metadata;
|
|
9
|
-
/** The output chunk */
|
|
10
|
-
chunk: Chunk;
|
|
11
|
-
};
|
|
12
|
-
export type ByteChunk<Metadata extends object = object> = ProcessOutputChunk<
|
|
13
|
-
Uint8Array<ArrayBufferLike>,
|
|
14
|
-
Metadata
|
|
15
|
-
>;
|
|
16
|
-
export type TextChunk<Metadata extends object = object> = ProcessOutputChunk<
|
|
17
|
-
string,
|
|
18
|
-
Metadata
|
|
19
|
-
>;
|
|
20
|
-
export type BytesOutput<Metadata extends object = object> = SimpleAsyncIterable<
|
|
21
|
-
ByteChunk<Metadata>
|
|
22
|
-
>;
|
|
23
|
-
export type TextOutput<Metadata extends object = object> = SimpleAsyncIterable<
|
|
24
|
-
TextChunk<Metadata>
|
|
25
|
-
>;
|
|
26
|
-
export interface ProcessOutput<Metadata extends object = object> {
|
|
27
|
-
bytes(): BytesOutput<Metadata>;
|
|
28
|
-
text(): TextOutput<Metadata>;
|
|
29
|
-
}
|
|
30
|
-
export declare const createProcessOutput: <Metadata extends object = object>(
|
|
31
|
-
stream: ByteStream,
|
|
32
|
-
metadata: Metadata,
|
|
33
|
-
) => ProcessOutput<Metadata>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const PARALLEL_MAX_VALUES: readonly [
|
|
2
|
-
"auto",
|
|
3
|
-
"unbounded",
|
|
4
|
-
"default",
|
|
5
|
-
];
|
|
6
|
-
export type PercentageValue = `${number}%`;
|
|
7
|
-
/**
|
|
8
|
-
* The maximum number of scripts that can run in parallel.
|
|
9
|
-
*
|
|
10
|
-
* - `number`: The exact number of scripts that can run in parallel.
|
|
11
|
-
* - `"auto"`: The number of available logical CPU threads.
|
|
12
|
-
* - `"unbounded"`: No limit.
|
|
13
|
-
* - `"default"`: The default value, either "auto" or the value of the root config's "parallelMax" option.
|
|
14
|
-
* - `"${number}%"`: A percentage of the available logical CPU threads (e.g. "50%").
|
|
15
|
-
*/
|
|
16
|
-
export type ParallelMaxValue =
|
|
17
|
-
| number
|
|
18
|
-
| (typeof PARALLEL_MAX_VALUES)[number]
|
|
19
|
-
| PercentageValue;
|
|
20
|
-
/** Should always return at least 1 */
|
|
21
|
-
export declare const determineParallelMax: (
|
|
22
|
-
value: ParallelMaxValue,
|
|
23
|
-
errorMessageSuffix?: string,
|
|
24
|
-
) => number;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type MultiProcessOutput, type OutputStreamName } from "./output";
|
|
2
|
-
import type { ScriptCommand } from "./scriptCommand";
|
|
3
|
-
import type { ScriptShellOption } from "./scriptShellOption";
|
|
4
|
-
export type RunScriptExit<ScriptMetadata extends object = object> = {
|
|
5
|
-
exitCode: number;
|
|
6
|
-
signal: NodeJS.Signals | null;
|
|
7
|
-
success: boolean;
|
|
8
|
-
/** Whether the script was skipped due to a failed dependency */
|
|
9
|
-
skipped?: boolean;
|
|
10
|
-
startTimeISO: string;
|
|
11
|
-
endTimeISO: string;
|
|
12
|
-
durationMs: number;
|
|
13
|
-
metadata: ScriptMetadata;
|
|
14
|
-
};
|
|
15
|
-
export type RunScriptResult<ScriptMetadata extends object = object> = {
|
|
16
|
-
output: MultiProcessOutput<
|
|
17
|
-
ScriptMetadata & {
|
|
18
|
-
streamName: OutputStreamName;
|
|
19
|
-
}
|
|
20
|
-
>;
|
|
21
|
-
exit: Promise<RunScriptExit<ScriptMetadata>>;
|
|
22
|
-
metadata: ScriptMetadata;
|
|
23
|
-
kill: (exit?: number | NodeJS.Signals) => void;
|
|
24
|
-
};
|
|
25
|
-
export type RunScriptOptions<ScriptMetadata extends object = object> = {
|
|
26
|
-
scriptCommand: ScriptCommand;
|
|
27
|
-
metadata: ScriptMetadata;
|
|
28
|
-
env: Record<string, string>;
|
|
29
|
-
/** The shell to use to run the script. Defaults to "system". */
|
|
30
|
-
shell?: ScriptShellOption;
|
|
31
|
-
/** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
|
|
32
|
-
ignoreOutput?: boolean;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Run some script and get an async output stream of
|
|
36
|
-
* stdout and stderr chunks and a result object
|
|
37
|
-
* containing exit details.
|
|
38
|
-
*/
|
|
39
|
-
export declare const runScript: <ScriptMetadata extends object = object>({
|
|
40
|
-
scriptCommand,
|
|
41
|
-
metadata,
|
|
42
|
-
env,
|
|
43
|
-
shell,
|
|
44
|
-
ignoreOutput,
|
|
45
|
-
}: RunScriptOptions<ScriptMetadata>) => RunScriptResult<ScriptMetadata>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { type MultiProcessOutput, type OutputStreamName } from "./output";
|
|
2
|
-
import { type ParallelMaxValue } from "./parallel";
|
|
3
|
-
import { type RunScriptExit, type RunScriptResult } from "./runScript";
|
|
4
|
-
import { type ScriptCommand } from "./scriptCommand";
|
|
5
|
-
import { type ScriptShellOption } from "./scriptShellOption";
|
|
6
|
-
export type RunScriptsScript<ScriptMetadata extends object = object> = {
|
|
7
|
-
scriptCommand: ScriptCommand;
|
|
8
|
-
metadata: ScriptMetadata;
|
|
9
|
-
env: Record<string, string>;
|
|
10
|
-
/** The shell to use to run the script */
|
|
11
|
-
shell?: ScriptShellOption;
|
|
12
|
-
/** Indices of other scripts in the array that must complete before this one starts */
|
|
13
|
-
dependsOn?: number[];
|
|
14
|
-
/** Set to `true` to ignore all output from the script. This saves memory when you don't need script output. */
|
|
15
|
-
ignoreOutput?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export type RunScriptsScriptResult<ScriptMetadata extends object = object> = {
|
|
18
|
-
/** The result of running the script */
|
|
19
|
-
result: RunScriptResult<ScriptMetadata>;
|
|
20
|
-
};
|
|
21
|
-
export type RunScriptsSummary<ScriptMetadata extends object = object> = {
|
|
22
|
-
totalCount: number;
|
|
23
|
-
successCount: number;
|
|
24
|
-
failureCount: number;
|
|
25
|
-
allSuccess: boolean;
|
|
26
|
-
startTimeISO: string;
|
|
27
|
-
endTimeISO: string;
|
|
28
|
-
durationMs: number;
|
|
29
|
-
scriptResults: RunScriptExit<ScriptMetadata>[];
|
|
30
|
-
};
|
|
31
|
-
export type ScriptEventName = "start" | "skip" | "exit";
|
|
32
|
-
export type RunScriptsResult<ScriptMetadata extends object = object> = {
|
|
33
|
-
output: MultiProcessOutput<
|
|
34
|
-
ScriptMetadata & {
|
|
35
|
-
streamName: OutputStreamName;
|
|
36
|
-
}
|
|
37
|
-
>;
|
|
38
|
-
/** Resolves with a results summary after all scripts have exited */
|
|
39
|
-
summary: Promise<RunScriptsSummary<ScriptMetadata>>;
|
|
40
|
-
};
|
|
41
|
-
export type RunScriptsParallelOptions = {
|
|
42
|
-
max: ParallelMaxValue;
|
|
43
|
-
};
|
|
44
|
-
export type RunScriptsOptions<ScriptMetadata extends object = object> = {
|
|
45
|
-
scripts: RunScriptsScript<ScriptMetadata>[];
|
|
46
|
-
parallel: boolean | RunScriptsParallelOptions;
|
|
47
|
-
/** When true, run scripts even if a dependency failed. Default: false (skip them). */
|
|
48
|
-
ignoreDependencyFailure?: boolean;
|
|
49
|
-
/** Set to `true` to ignore all output from the scripts. This saves memory when you don't need script output. */
|
|
50
|
-
ignoreOutput?: boolean;
|
|
51
|
-
/** Callback to invoke when a script event occurs */
|
|
52
|
-
onScriptEvent?: (
|
|
53
|
-
event: ScriptEventName,
|
|
54
|
-
scriptIndex: number,
|
|
55
|
-
result: RunScriptExit<ScriptMetadata> | null,
|
|
56
|
-
) => void;
|
|
57
|
-
};
|
|
58
|
-
/** Run a list of scripts */
|
|
59
|
-
export declare const runScripts: <ScriptMetadata extends object = object>({
|
|
60
|
-
scripts,
|
|
61
|
-
parallel,
|
|
62
|
-
ignoreDependencyFailure,
|
|
63
|
-
ignoreOutput,
|
|
64
|
-
onScriptEvent,
|
|
65
|
-
}: RunScriptsOptions<ScriptMetadata>) => RunScriptsResult<ScriptMetadata>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Workspace } from "../workspaces";
|
|
2
|
-
export declare const WORKSPACE_SCRIPT_COMMAND_METHODS: readonly [
|
|
3
|
-
"cd",
|
|
4
|
-
"filter",
|
|
5
|
-
];
|
|
6
|
-
export type WorkspaceScriptCommandMethod =
|
|
7
|
-
(typeof WORKSPACE_SCRIPT_COMMAND_METHODS)[number];
|
|
8
|
-
/** Basic metadata to run a script, the command string and the directory to run it in */
|
|
9
|
-
export interface ScriptCommand {
|
|
10
|
-
/** The command string to run */
|
|
11
|
-
command: string;
|
|
12
|
-
/** The directory to run the command in */
|
|
13
|
-
workingDirectory: string;
|
|
14
|
-
}
|
|
15
|
-
export interface CreateWorkspaceScriptCommandOptions {
|
|
16
|
-
/**
|
|
17
|
-
* The method to use to run the script.
|
|
18
|
-
* Either run in the workspace directory or use bun's --filter option.
|
|
19
|
-
* Defaults to "cd".
|
|
20
|
-
*/
|
|
21
|
-
method?: WorkspaceScriptCommandMethod;
|
|
22
|
-
/** The name of the script to run */
|
|
23
|
-
scriptName: string;
|
|
24
|
-
/** The arguments to append to the command */
|
|
25
|
-
args: string;
|
|
26
|
-
/** The workspace that the script belongs to */
|
|
27
|
-
workspace: Workspace;
|
|
28
|
-
/** The root directory of the project */
|
|
29
|
-
rootDirectory: string;
|
|
30
|
-
}
|
|
31
|
-
export declare const createWorkspaceScriptCommand: (
|
|
32
|
-
options: CreateWorkspaceScriptCommandOptions,
|
|
33
|
-
) => ScriptCommand;
|