workspace-utils 1.0.0 → 1.0.1
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/dist/index.js +15460 -0
- package/dist/package.json +57 -0
- package/package.json +4 -1
- package/.github/workflows/mdbook.yml +0 -64
- package/.prettierignore +0 -22
- package/.prettierrc +0 -13
- package/docs/book.toml +0 -10
- package/docs/src/SUMMARY.md +0 -24
- package/docs/src/commands/build.md +0 -110
- package/docs/src/commands/dev.md +0 -118
- package/docs/src/commands/overview.md +0 -239
- package/docs/src/commands/run.md +0 -153
- package/docs/src/configuration.md +0 -249
- package/docs/src/examples.md +0 -567
- package/docs/src/installation.md +0 -148
- package/docs/src/introduction.md +0 -117
- package/docs/src/quick-start.md +0 -278
- package/docs/src/troubleshooting.md +0 -533
- package/index.ts +0 -84
- package/src/commands/build.ts +0 -158
- package/src/commands/dev.ts +0 -192
- package/src/commands/run.test.ts +0 -329
- package/src/commands/run.ts +0 -118
- package/src/core/dependency-graph.ts +0 -262
- package/src/core/process-runner.ts +0 -355
- package/src/core/workspace.test.ts +0 -404
- package/src/core/workspace.ts +0 -228
- package/src/package-managers/bun.test.ts +0 -209
- package/src/package-managers/bun.ts +0 -79
- package/src/package-managers/detector.test.ts +0 -199
- package/src/package-managers/detector.ts +0 -111
- package/src/package-managers/index.ts +0 -10
- package/src/package-managers/npm.ts +0 -79
- package/src/package-managers/pnpm.ts +0 -101
- package/src/package-managers/types.ts +0 -42
- package/src/utils/output.ts +0 -301
- package/src/utils/package-utils.ts +0 -243
- package/tests/bun-workspace/apps/web-app/package.json +0 -18
- package/tests/bun-workspace/bun.lockb +0 -0
- package/tests/bun-workspace/package.json +0 -18
- package/tests/bun-workspace/packages/shared-utils/package.json +0 -15
- package/tests/bun-workspace/packages/ui-components/package.json +0 -17
- package/tests/npm-workspace/package-lock.json +0 -0
- package/tests/npm-workspace/package.json +0 -18
- package/tests/npm-workspace/packages/core/package.json +0 -15
- package/tests/pnpm-workspace/package.json +0 -14
- package/tests/pnpm-workspace/packages/utils/package.json +0 -15
- package/tests/pnpm-workspace/pnpm-workspace.yaml +0 -3
- package/tsconfig.json +0 -29
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "workspace-utils",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A CLI tool to orchestrate scripts across monorepo workspaces (Bun, pnpm, npm) with parallel execution and dependency-aware builds.",
|
|
5
|
+
"module": "index.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"workspace-utils": "./dist/index.js",
|
|
12
|
+
"wsu": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "bun build index.ts --outdir dist --target node && cp package.json dist/",
|
|
16
|
+
"dev": "bun run index.ts",
|
|
17
|
+
"prepublishOnly": "bun run build",
|
|
18
|
+
"format": "prettier --write .",
|
|
19
|
+
"format:check": "prettier --check .",
|
|
20
|
+
"test": "bun test",
|
|
21
|
+
"test:watch": "bun test --watch",
|
|
22
|
+
"docs:build": "cd docs && mdbook build",
|
|
23
|
+
"docs:serve": "cd docs && mdbook serve",
|
|
24
|
+
"docs:watch": "cd docs && mdbook serve --open"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"monorepo",
|
|
28
|
+
"workspaces",
|
|
29
|
+
"bun",
|
|
30
|
+
"pnpm",
|
|
31
|
+
"npm",
|
|
32
|
+
"cli",
|
|
33
|
+
"parallel",
|
|
34
|
+
"dependency-graph",
|
|
35
|
+
"build-orchestration"
|
|
36
|
+
],
|
|
37
|
+
"author": "",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"commander": "^11.1.0",
|
|
41
|
+
"fast-glob": "^3.3.2",
|
|
42
|
+
"picocolors": "^1.0.0",
|
|
43
|
+
"yaml": "^2.8.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/bun": "^1.2.20",
|
|
47
|
+
"@types/node": "^20.10.0",
|
|
48
|
+
"prettier": "^3.6.2"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"typescript": "^5"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18",
|
|
55
|
+
"bun": ">=1.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A CLI tool to orchestrate scripts across monorepo workspaces (Bun, pnpm, npm) with parallel execution and dependency-aware builds.",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/"
|
|
9
|
+
],
|
|
7
10
|
"bin": {
|
|
8
11
|
"workspace-utils": "./dist/index.js",
|
|
9
12
|
"wsu": "./dist/index.js"
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Sample workflow for building and deploying a mdBook site to GitHub Pages
|
|
2
|
-
#
|
|
3
|
-
# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html
|
|
4
|
-
#
|
|
5
|
-
name: Deploy mdBook site to Pages
|
|
6
|
-
|
|
7
|
-
defaults:
|
|
8
|
-
run:
|
|
9
|
-
working-directory: docs
|
|
10
|
-
|
|
11
|
-
on:
|
|
12
|
-
# Runs on pushes targeting the default branch
|
|
13
|
-
push:
|
|
14
|
-
branches: ['main']
|
|
15
|
-
|
|
16
|
-
# Allows you to run this workflow manually from the Actions tab
|
|
17
|
-
workflow_dispatch:
|
|
18
|
-
|
|
19
|
-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
20
|
-
permissions:
|
|
21
|
-
contents: read
|
|
22
|
-
pages: write
|
|
23
|
-
id-token: write
|
|
24
|
-
|
|
25
|
-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
26
|
-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
27
|
-
concurrency:
|
|
28
|
-
group: 'pages'
|
|
29
|
-
cancel-in-progress: false
|
|
30
|
-
|
|
31
|
-
jobs:
|
|
32
|
-
# Build job
|
|
33
|
-
build:
|
|
34
|
-
runs-on: ubuntu-latest
|
|
35
|
-
env:
|
|
36
|
-
MDBOOK_VERSION: 0.4.52
|
|
37
|
-
steps:
|
|
38
|
-
- uses: actions/checkout@v4
|
|
39
|
-
- name: Install mdBook
|
|
40
|
-
run: |
|
|
41
|
-
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
|
|
42
|
-
rustup update
|
|
43
|
-
cargo install --version ${MDBOOK_VERSION} mdbook
|
|
44
|
-
- name: Setup Pages
|
|
45
|
-
id: pages
|
|
46
|
-
uses: actions/configure-pages@v5
|
|
47
|
-
- name: Build with mdBook
|
|
48
|
-
run: mdbook build
|
|
49
|
-
- name: Upload artifact
|
|
50
|
-
uses: actions/upload-pages-artifact@v3
|
|
51
|
-
with:
|
|
52
|
-
path: ./docs/book
|
|
53
|
-
|
|
54
|
-
# Deployment job
|
|
55
|
-
deploy:
|
|
56
|
-
environment:
|
|
57
|
-
name: github-pages
|
|
58
|
-
url: ${{ steps.deployment.outputs.page_url }}
|
|
59
|
-
runs-on: ubuntu-latest
|
|
60
|
-
needs: build
|
|
61
|
-
steps:
|
|
62
|
-
- name: Deploy to GitHub Pages
|
|
63
|
-
id: deployment
|
|
64
|
-
uses: actions/deploy-pages@v4
|
package/.prettierignore
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Dependencies
|
|
2
|
-
node_modules/
|
|
3
|
-
dist/
|
|
4
|
-
|
|
5
|
-
# Build outputs
|
|
6
|
-
*.js
|
|
7
|
-
*.d.ts
|
|
8
|
-
|
|
9
|
-
# Lock files
|
|
10
|
-
pnpm-lock.yaml
|
|
11
|
-
yarn.lock
|
|
12
|
-
package-lock.json
|
|
13
|
-
|
|
14
|
-
# Test workspaces and temporary test directories
|
|
15
|
-
tests/
|
|
16
|
-
test-temp*/
|
|
17
|
-
|
|
18
|
-
# Documentation
|
|
19
|
-
CHANGELOG.md
|
|
20
|
-
|
|
21
|
-
# Git
|
|
22
|
-
.git/
|
package/.prettierrc
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"useTabs": true,
|
|
3
|
-
"tabWidth": 2,
|
|
4
|
-
"semi": true,
|
|
5
|
-
"singleQuote": true,
|
|
6
|
-
"quoteProps": "as-needed",
|
|
7
|
-
"trailingComma": "es5",
|
|
8
|
-
"bracketSpacing": true,
|
|
9
|
-
"bracketSameLine": false,
|
|
10
|
-
"arrowParens": "avoid",
|
|
11
|
-
"printWidth": 100,
|
|
12
|
-
"endOfLine": "lf"
|
|
13
|
-
}
|
package/docs/book.toml
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
[book]
|
|
2
|
-
authors = ["Torsten Dittmann"]
|
|
3
|
-
language = "en"
|
|
4
|
-
src = "src"
|
|
5
|
-
title = "workspace-utils"
|
|
6
|
-
description = "A CLI tool to orchestrate scripts across monorepo workspaces with parallel execution and dependency-aware builds"
|
|
7
|
-
|
|
8
|
-
[output.html]
|
|
9
|
-
git-repository-url = "https://github.com/torstendittmann/workspace-utils"
|
|
10
|
-
edit-url-template = "https://github.com/torstendittmann/workspace-utils/edit/main/docs/{path}"
|
package/docs/src/SUMMARY.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Summary
|
|
2
|
-
|
|
3
|
-
[Introduction](./introduction.md)
|
|
4
|
-
|
|
5
|
-
# Getting Started
|
|
6
|
-
|
|
7
|
-
- [Installation](./installation.md)
|
|
8
|
-
- [Quick Start](./quick-start.md)
|
|
9
|
-
- [Configuration](./configuration.md)
|
|
10
|
-
|
|
11
|
-
# Commands
|
|
12
|
-
|
|
13
|
-
- [Overview](./commands/overview.md)
|
|
14
|
-
- [run](./commands/run.md)
|
|
15
|
-
- [build](./commands/build.md)
|
|
16
|
-
- [dev](./commands/dev.md)
|
|
17
|
-
|
|
18
|
-
# Usage Examples
|
|
19
|
-
|
|
20
|
-
- [Examples](./examples.md)
|
|
21
|
-
|
|
22
|
-
# Help
|
|
23
|
-
|
|
24
|
-
- [Troubleshooting](./troubleshooting.md)
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# build Command
|
|
2
|
-
|
|
3
|
-
The `build` command builds packages in dependency order, ensuring that dependencies are built before their dependents.
|
|
4
|
-
|
|
5
|
-
## Recommended Usage
|
|
6
|
-
|
|
7
|
-
Add to your `package.json` scripts:
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
{
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "wsu build",
|
|
13
|
-
"build:apps": "wsu build --filter 'apps/*'",
|
|
14
|
-
"build:slow": "wsu build --concurrency 2"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Then run:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm run build # Build all packages in dependency order
|
|
23
|
-
npm run build:apps # Build only apps
|
|
24
|
-
npm run build:slow # Build with limited concurrency
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Direct Usage (if needed)
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
wsu build [options]
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## How it Works
|
|
34
|
-
|
|
35
|
-
1. **Analyzes dependencies** - Reads `package.json` files to understand package relationships
|
|
36
|
-
2. **Creates build batches** - Groups packages that can be built in parallel
|
|
37
|
-
3. **Executes in order** - Runs builds batch by batch, respecting dependencies
|
|
38
|
-
|
|
39
|
-
## Options
|
|
40
|
-
|
|
41
|
-
| Option | Description | Default |
|
|
42
|
-
| ------------------------ | ------------------------------- | ------------ |
|
|
43
|
-
| `--filter <pattern>` | Filter packages by glob pattern | All packages |
|
|
44
|
-
| `--concurrency <number>` | Max concurrent builds per batch | `4` |
|
|
45
|
-
|
|
46
|
-
## Examples
|
|
47
|
-
|
|
48
|
-
### Basic Usage
|
|
49
|
-
|
|
50
|
-
Add scripts to your `package.json`:
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"scripts": {
|
|
55
|
-
"build": "wsu build",
|
|
56
|
-
"build:apps": "wsu build --filter 'apps/*'",
|
|
57
|
-
"build:limited": "wsu build --concurrency 2"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Then run:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npm run build # Build all packages in dependency order
|
|
66
|
-
npm run build:apps # Build only apps
|
|
67
|
-
npm run build:limited # Build with limited concurrency
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### Example Output
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
🏗️ Building packages in dependency order...
|
|
74
|
-
|
|
75
|
-
📊 Building dependency graph...
|
|
76
|
-
✅ Build order determined: 3 batches
|
|
77
|
-
|
|
78
|
-
📋 Build Plan:
|
|
79
|
-
Batch 1: @company/utils
|
|
80
|
-
Batch 2: @company/ui-components, @company/api-client
|
|
81
|
-
Batch 3: apps/web-app
|
|
82
|
-
|
|
83
|
-
🔧 Package manager: pnpm
|
|
84
|
-
⚡ Batch concurrency: 4
|
|
85
|
-
|
|
86
|
-
🔄 Running batch 1/3 (1 packages)
|
|
87
|
-
[@company/utils] ✅ Completed in 2,000ms
|
|
88
|
-
|
|
89
|
-
🔄 Running batch 2/3 (2 packages)
|
|
90
|
-
[@company/ui-components] ✅ Completed in 3,000ms
|
|
91
|
-
[@company/api-client] ✅ Completed in 2,500ms
|
|
92
|
-
|
|
93
|
-
🔄 Running batch 3/3 (1 packages)
|
|
94
|
-
[apps/web-app] ✅ Completed in 4,000ms
|
|
95
|
-
|
|
96
|
-
🎉 All packages built successfully!
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## When to Use
|
|
100
|
-
|
|
101
|
-
- **Production builds** - When dependency order matters
|
|
102
|
-
- **CI/CD pipelines** - Reliable, predictable builds
|
|
103
|
-
- **Publishing** - Ensure dependencies are built first
|
|
104
|
-
- **Clean builds** - Start from scratch with proper ordering
|
|
105
|
-
|
|
106
|
-
## Error Handling
|
|
107
|
-
|
|
108
|
-
- If a package fails, the current batch stops
|
|
109
|
-
- Subsequent batches are skipped
|
|
110
|
-
- Exit code is non-zero if any builds fail
|
package/docs/src/commands/dev.md
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# dev Command
|
|
2
|
-
|
|
3
|
-
The `dev` command starts development servers across multiple packages with live log streaming and graceful shutdown.
|
|
4
|
-
|
|
5
|
-
## Recommended Usage
|
|
6
|
-
|
|
7
|
-
Add to your `package.json` scripts:
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
{
|
|
11
|
-
"scripts": {
|
|
12
|
-
"dev": "wsu dev",
|
|
13
|
-
"dev:apps": "wsu dev --filter 'apps/*'",
|
|
14
|
-
"dev:limited": "wsu dev --concurrency 2"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Then run:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm run dev # Start all dev servers
|
|
23
|
-
npm run dev:apps # Start only frontend packages
|
|
24
|
-
npm run dev:limited # Limit concurrent servers
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Direct Usage (if needed)
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
wsu dev [options]
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## How it Works
|
|
34
|
-
|
|
35
|
-
1. **Finds packages** with `dev` scripts
|
|
36
|
-
2. **Starts servers** in parallel with live log streaming
|
|
37
|
-
3. **Color-codes output** for easy identification
|
|
38
|
-
4. **Handles shutdown** gracefully when you press Ctrl+C
|
|
39
|
-
|
|
40
|
-
## Options
|
|
41
|
-
|
|
42
|
-
| Option | Description | Default |
|
|
43
|
-
| ------------------------ | ------------------------------- | ------------ |
|
|
44
|
-
| `--filter <pattern>` | Filter packages by glob pattern | All packages |
|
|
45
|
-
| `--concurrency <number>` | Max concurrent dev servers | `4` |
|
|
46
|
-
|
|
47
|
-
## Examples
|
|
48
|
-
|
|
49
|
-
### Basic Usage
|
|
50
|
-
|
|
51
|
-
Add scripts to your `package.json`:
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"scripts": {
|
|
56
|
-
"dev": "wsu dev",
|
|
57
|
-
"dev:frontend": "wsu dev --filter 'apps/*'",
|
|
58
|
-
"dev:limited": "wsu dev --concurrency 2"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Then run:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npm run dev # Start all dev servers
|
|
67
|
-
npm run dev:frontend # Start only frontend packages
|
|
68
|
-
npm run dev:limited # Limit concurrent servers
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Example Output
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
🚀 Starting development servers with live log streaming...
|
|
75
|
-
|
|
76
|
-
✅ Starting dev servers for 3 packages:
|
|
77
|
-
• @company/ui-components
|
|
78
|
-
• apps/web-app
|
|
79
|
-
• apps/mobile-app
|
|
80
|
-
|
|
81
|
-
🔧 Package manager: npm
|
|
82
|
-
⚡ Running 3 dev servers simultaneously
|
|
83
|
-
💡 Tip: Use Ctrl+C to stop all development servers
|
|
84
|
-
|
|
85
|
-
🎬 Starting development servers...
|
|
86
|
-
|
|
87
|
-
────────────────────────────────────────────────────────
|
|
88
|
-
[@company/ui-components] Starting: npm run dev
|
|
89
|
-
[apps/web-app] Starting: npm run dev
|
|
90
|
-
[apps/mobile-app] Starting: npm run dev
|
|
91
|
-
[@company/ui-components] Server running on http://localhost:6006
|
|
92
|
-
[apps/web-app] Server running on http://localhost:3000
|
|
93
|
-
[apps/mobile-app] Expo running on http://localhost:19000
|
|
94
|
-
[@company/ui-components] Hot reload enabled
|
|
95
|
-
[apps/web-app] Hot reload enabled
|
|
96
|
-
...
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Features
|
|
100
|
-
|
|
101
|
-
- **Live log streaming** - See real-time output from all servers
|
|
102
|
-
- **Color-coded prefixes** - Each package has its own color
|
|
103
|
-
- **Graceful shutdown** - Ctrl+C stops all servers cleanly
|
|
104
|
-
- **No timestamps** - Clean output focused on development
|
|
105
|
-
|
|
106
|
-
## When to Use
|
|
107
|
-
|
|
108
|
-
- **Local development** - Start all services at once
|
|
109
|
-
- **Full-stack development** - Frontend, backend, and services together
|
|
110
|
-
- **Debugging** - See logs from multiple packages simultaneously
|
|
111
|
-
- **Team development** - Consistent development environment
|
|
112
|
-
|
|
113
|
-
## Tips
|
|
114
|
-
|
|
115
|
-
- Use filtering to start only the packages you're working on
|
|
116
|
-
- Keep concurrency reasonable to avoid overwhelming your system
|
|
117
|
-
- Each package gets a unique color for easy log identification
|
|
118
|
-
- Press Ctrl+C once to gracefully stop all servers
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
# Commands Overview
|
|
2
|
-
|
|
3
|
-
workspace-utils provides three main commands designed to handle different aspects of monorepo workflow management. Each command is optimized for specific use cases while sharing common functionality like package filtering and concurrency control.
|
|
4
|
-
|
|
5
|
-
## Command Summary
|
|
6
|
-
|
|
7
|
-
| Command | Purpose | Default Mode | Use Case |
|
|
8
|
-
| --------------------- | -------------------------------------- | -------------------- | ------------------------------ |
|
|
9
|
-
| [`run`](./run.md) | Execute scripts across packages | **Parallel** | Tests, linting, custom scripts |
|
|
10
|
-
| [`build`](./build.md) | Build packages respecting dependencies | **Dependency order** | Production builds, CI/CD |
|
|
11
|
-
| [`dev`](./dev.md) | Start development servers | **Parallel** | Local development |
|
|
12
|
-
|
|
13
|
-
## Quick Reference
|
|
14
|
-
|
|
15
|
-
### wsu run
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
wsu run <script> [options]
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Execute any script across multiple packages in parallel (by default) or sequentially.
|
|
22
|
-
|
|
23
|
-
**Package.json setup:**
|
|
24
|
-
|
|
25
|
-
```json
|
|
26
|
-
{
|
|
27
|
-
"scripts": {
|
|
28
|
-
"test": "wsu run test",
|
|
29
|
-
"lint": "wsu run lint --sequential",
|
|
30
|
-
"typecheck": "wsu run typecheck --concurrency 8"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**Usage:**
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npm run test # Run tests in parallel
|
|
39
|
-
npm run lint # Run linting sequentially
|
|
40
|
-
npm run typecheck # Custom concurrency
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### wsu build
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
wsu build [options]
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Build packages in dependency order using topological sorting. Packages are built in batches where each batch can run in parallel.
|
|
50
|
-
|
|
51
|
-
**Package.json setup:**
|
|
52
|
-
|
|
53
|
-
```json
|
|
54
|
-
{
|
|
55
|
-
"scripts": {
|
|
56
|
-
"build": "wsu build",
|
|
57
|
-
"build:apps": "wsu build --filter 'apps/*'",
|
|
58
|
-
"build:slow": "wsu build --concurrency 2"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Usage:**
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
npm run build # Build all packages
|
|
67
|
-
npm run build:apps # Build only apps
|
|
68
|
-
npm run build:slow # Limit batch concurrency
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### wsu dev
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
wsu dev [options]
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Start development servers with live log streaming. Designed for long-running processes with real-time output.
|
|
78
|
-
|
|
79
|
-
**Package.json setup:**
|
|
80
|
-
|
|
81
|
-
```json
|
|
82
|
-
{
|
|
83
|
-
"scripts": {
|
|
84
|
-
"dev": "wsu dev",
|
|
85
|
-
"dev:scope": "wsu dev --filter '@scope/*'",
|
|
86
|
-
"dev:limited": "wsu dev --concurrency 3"
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
**Usage:**
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
npm run dev # Start all dev servers
|
|
95
|
-
npm run dev:scope # Start scoped packages
|
|
96
|
-
npm run dev:limited # Limit concurrent servers
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Global Options
|
|
100
|
-
|
|
101
|
-
All commands support these common options:
|
|
102
|
-
|
|
103
|
-
### Filtering
|
|
104
|
-
|
|
105
|
-
- `--filter <pattern>` - Filter packages using glob patterns
|
|
106
|
-
- Examples: `"@scope/*"`, `"apps/*"`, `"*-utils"`, `"*frontend*"`
|
|
107
|
-
|
|
108
|
-
### Concurrency
|
|
109
|
-
|
|
110
|
-
- `--concurrency <number>` - Maximum concurrent processes (default: 4)
|
|
111
|
-
- Applies to parallel execution and batch processing
|
|
112
|
-
|
|
113
|
-
### Help
|
|
114
|
-
|
|
115
|
-
- `--help` - Show command-specific help and options
|
|
116
|
-
|
|
117
|
-
## Execution Modes
|
|
118
|
-
|
|
119
|
-
### Parallel Execution
|
|
120
|
-
|
|
121
|
-
**Used by:** `run` (default), `dev`
|
|
122
|
-
**Behavior:** All matching packages execute simultaneously
|
|
123
|
-
**Best for:** Tests, linting, development servers
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
npm run test # with "test": "wsu run test" in package.json
|
|
127
|
-
# ✅ Runs tests in all packages at the same time
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
### Sequential Execution
|
|
131
|
-
|
|
132
|
-
**Used by:** `run` (with --sequential flag)
|
|
133
|
-
**Behavior:** Packages execute one after another
|
|
134
|
-
**Best for:** Resource-intensive tasks, ordered operations
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
npm run build:sequential # with "build:sequential": "wsu run build --sequential"
|
|
138
|
-
# ✅ Runs builds one package at a time
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### Dependency-Aware Execution
|
|
142
|
-
|
|
143
|
-
**Used by:** `build`
|
|
144
|
-
**Behavior:** Packages are grouped into batches based on dependencies
|
|
145
|
-
**Best for:** Building, publishing, dependency-critical operations
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
npm run build # with "build": "wsu build" in package.json
|
|
149
|
-
# ✅ Builds dependencies first, then dependents
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## Package Manager Detection
|
|
153
|
-
|
|
154
|
-
workspace-utils automatically detects your package manager:
|
|
155
|
-
|
|
156
|
-
| Package Manager | Detection Criteria |
|
|
157
|
-
| --------------- | ----------------------------------------------------------------- |
|
|
158
|
-
| **Bun** | `bun.lockb`, `bunfig.toml`, or bun-specific `package.json` fields |
|
|
159
|
-
| **pnpm** | `pnpm-lock.yaml`, `pnpm-workspace.yaml` |
|
|
160
|
-
| **npm** | `package-lock.json`, `.npmrc` |
|
|
161
|
-
|
|
162
|
-
The detected package manager is used for all script execution (e.g., `bun run test`, `pnpm run test`, `npm run test`).
|
|
163
|
-
|
|
164
|
-
## Error Handling
|
|
165
|
-
|
|
166
|
-
### Exit Behavior
|
|
167
|
-
|
|
168
|
-
- **Single failure in parallel mode:** Other packages continue running
|
|
169
|
-
- **Single failure in sequential mode:** Execution stops immediately
|
|
170
|
-
- **Single failure in build mode:** Current batch fails, subsequent batches are skipped
|
|
171
|
-
|
|
172
|
-
### Exit Codes
|
|
173
|
-
|
|
174
|
-
- `0` - All packages executed successfully
|
|
175
|
-
- `1` - One or more packages failed
|
|
176
|
-
- `2` - Configuration or setup error
|
|
177
|
-
|
|
178
|
-
## Output Format
|
|
179
|
-
|
|
180
|
-
All commands provide consistent, color-coded output:
|
|
181
|
-
|
|
182
|
-
```
|
|
183
|
-
🚀 Starting operation...
|
|
184
|
-
📁 Workspace root: /path/to/workspace
|
|
185
|
-
📦 Found X packages
|
|
186
|
-
✅ Running "script" in Y packages
|
|
187
|
-
🔧 Package manager: detected-pm
|
|
188
|
-
⚡ Execution mode: parallel/sequential/dependency-order
|
|
189
|
-
|
|
190
|
-
[package-1] Starting: pm run script
|
|
191
|
-
[package-2] Starting: pm run script
|
|
192
|
-
[package-1] ✅ Completed in 1,234ms
|
|
193
|
-
[package-2] ❌ Failed with exit code 1
|
|
194
|
-
|
|
195
|
-
📊 Execution Summary:
|
|
196
|
-
✅ Successful: 1
|
|
197
|
-
❌ Failed: 1
|
|
198
|
-
⏱️ Total duration: 2,345ms
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
## Best Practices
|
|
202
|
-
|
|
203
|
-
### Choose the Right Command
|
|
204
|
-
|
|
205
|
-
- **`run`** for most script execution (tests, linting, utilities)
|
|
206
|
-
- **`build`** when package dependencies matter
|
|
207
|
-
- **`dev`** for long-running development processes
|
|
208
|
-
|
|
209
|
-
### Use Filtering Effectively
|
|
210
|
-
|
|
211
|
-
```json
|
|
212
|
-
{
|
|
213
|
-
"scripts": {
|
|
214
|
-
"test:packages": "wsu run test --filter 'packages/*'",
|
|
215
|
-
"dev:apps": "wsu dev --filter 'apps/*'",
|
|
216
|
-
"build:company": "wsu build --filter '@company/*'"
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
### Optimize Concurrency
|
|
222
|
-
|
|
223
|
-
```json
|
|
224
|
-
{
|
|
225
|
-
"scripts": {
|
|
226
|
-
"build:slow": "wsu run build --concurrency 2",
|
|
227
|
-
"test:fast": "wsu run test --concurrency 8",
|
|
228
|
-
"dev": "wsu dev --concurrency 4"
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## Next Steps
|
|
234
|
-
|
|
235
|
-
Dive deeper into each command:
|
|
236
|
-
|
|
237
|
-
- [**run command**](./run.md) - Detailed script execution options
|
|
238
|
-
- [**build command**](./build.md) - Dependency-aware building
|
|
239
|
-
- [**dev command**](./dev.md) - Development server management
|