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
package/docs/src/commands/run.md
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
# run Command
|
|
2
|
-
|
|
3
|
-
The `run` command executes scripts across multiple packages in your workspace, with parallel execution by default.
|
|
4
|
-
|
|
5
|
-
## Recommended Usage
|
|
6
|
-
|
|
7
|
-
Add to your `package.json` scripts:
|
|
8
|
-
|
|
9
|
-
```json
|
|
10
|
-
{
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "wsu run test",
|
|
13
|
-
"lint": "wsu run lint",
|
|
14
|
-
"typecheck": "wsu run typecheck"
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Then run:
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm run test # Run tests across packages
|
|
23
|
-
npm run lint # Run linting across packages
|
|
24
|
-
npm run typecheck # Run type checking across packages
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Direct Usage (if needed)
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
wsu run <script> [options]
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Arguments
|
|
34
|
-
|
|
35
|
-
- `<script>` - The npm script name to execute (e.g., `test`, `lint`, `build`)
|
|
36
|
-
|
|
37
|
-
## Options
|
|
38
|
-
|
|
39
|
-
| Option | Description | Default |
|
|
40
|
-
| ------------------------ | ------------------------------------ | ------------ |
|
|
41
|
-
| `--filter <pattern>` | Filter packages by glob pattern | All packages |
|
|
42
|
-
| `--concurrency <number>` | Max concurrent processes | `4` |
|
|
43
|
-
| `--sequential` | Run sequentially instead of parallel | `false` |
|
|
44
|
-
|
|
45
|
-
## Examples
|
|
46
|
-
|
|
47
|
-
### Basic Usage
|
|
48
|
-
|
|
49
|
-
Add scripts to your `package.json`:
|
|
50
|
-
|
|
51
|
-
```json
|
|
52
|
-
{
|
|
53
|
-
"scripts": {
|
|
54
|
-
"test": "wsu run test",
|
|
55
|
-
"test:sequential": "wsu run test --sequential",
|
|
56
|
-
"lint": "wsu run lint --concurrency 8"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Then run:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
npm run test # Run tests in parallel (default)
|
|
65
|
-
npm run test:sequential # Run tests sequentially
|
|
66
|
-
npm run lint # Run linting with custom concurrency
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Package Filtering
|
|
70
|
-
|
|
71
|
-
Add filtered scripts to your `package.json`:
|
|
72
|
-
|
|
73
|
-
```json
|
|
74
|
-
{
|
|
75
|
-
"scripts": {
|
|
76
|
-
"test:company": "wsu run test --filter '@company/*'",
|
|
77
|
-
"dev:apps": "wsu run dev --filter 'apps/*'",
|
|
78
|
-
"build:backend": "wsu run build --filter '*backend*'"
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
Then run:
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
npm run test:company # Run tests for scoped packages
|
|
87
|
-
npm run dev:apps # Run dev scripts for apps only
|
|
88
|
-
npm run build:backend # Run builds for backend packages
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Example Output
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
🚀 Running script "test" across packages...
|
|
95
|
-
|
|
96
|
-
📦 Found 3 packages
|
|
97
|
-
✅ Running "test" in 3 packages:
|
|
98
|
-
• @company/utils
|
|
99
|
-
• @company/ui-components
|
|
100
|
-
• apps/web-app
|
|
101
|
-
|
|
102
|
-
🔧 Package manager: pnpm
|
|
103
|
-
⚡ Execution mode: parallel (concurrency: 4)
|
|
104
|
-
|
|
105
|
-
[@company/utils] Starting: pnpm run test
|
|
106
|
-
[@company/ui-components] Starting: pnpm run test
|
|
107
|
-
[apps/web-app] Starting: pnpm run test
|
|
108
|
-
[@company/utils] ✅ Completed in 1,234ms
|
|
109
|
-
[@company/ui-components] ✅ Completed in 2,456ms
|
|
110
|
-
[apps/web-app] ✅ Completed in 3,789ms
|
|
111
|
-
|
|
112
|
-
📊 Execution Summary:
|
|
113
|
-
✅ Successful: 3
|
|
114
|
-
⏱️ Total duration: 3,789ms
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Execution Modes
|
|
118
|
-
|
|
119
|
-
### Parallel (Default)
|
|
120
|
-
|
|
121
|
-
- Runs all packages simultaneously
|
|
122
|
-
- Faster for I/O bound tasks like tests and linting
|
|
123
|
-
- Other packages continue if one fails
|
|
124
|
-
|
|
125
|
-
### Sequential
|
|
126
|
-
|
|
127
|
-
- Runs packages one at a time
|
|
128
|
-
- Stops on first failure
|
|
129
|
-
- Better for resource-intensive tasks
|
|
130
|
-
|
|
131
|
-
## When to Use
|
|
132
|
-
|
|
133
|
-
- **Tests** - Parallel execution for fast feedback
|
|
134
|
-
- **Linting** - High concurrency for quick checks
|
|
135
|
-
- **Type checking** - Parallel across packages
|
|
136
|
-
- **Custom scripts** - Any script that exists in package.json
|
|
137
|
-
|
|
138
|
-
## Package.json Integration
|
|
139
|
-
|
|
140
|
-
Add common patterns to your root `package.json`:
|
|
141
|
-
|
|
142
|
-
```json
|
|
143
|
-
{
|
|
144
|
-
"scripts": {
|
|
145
|
-
"test": "wsu run test",
|
|
146
|
-
"test:watch": "wsu run test:watch",
|
|
147
|
-
"lint": "wsu run lint --concurrency 8",
|
|
148
|
-
"lint:fix": "wsu run lint:fix",
|
|
149
|
-
"typecheck": "wsu run typecheck",
|
|
150
|
-
"clean": "wsu run clean --sequential"
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
# Configuration
|
|
2
|
-
|
|
3
|
-
workspace-utils is designed to work with **zero configuration** by default. It automatically detects your workspace setup and package manager, then runs with sensible defaults. However, you can customize behavior through command-line options.
|
|
4
|
-
|
|
5
|
-
## No Configuration Files
|
|
6
|
-
|
|
7
|
-
Unlike many other tools, workspace-utils **does not use configuration files**. All behavior is controlled through:
|
|
8
|
-
|
|
9
|
-
1. **Command-line flags** (primary method)
|
|
10
|
-
2. **Workspace structure** (automatic detection)
|
|
11
|
-
3. **Package manager detection** (automatic)
|
|
12
|
-
|
|
13
|
-
This approach keeps things simple and ensures your commands are explicit and reproducible.
|
|
14
|
-
|
|
15
|
-
## Command-Line Configuration
|
|
16
|
-
|
|
17
|
-
All configuration is done through command-line options. Here are the most commonly used options:
|
|
18
|
-
|
|
19
|
-
### Global Options
|
|
20
|
-
|
|
21
|
-
Available for all commands:
|
|
22
|
-
|
|
23
|
-
| Option | Description | Default | Example |
|
|
24
|
-
| ------------------------ | ------------------------------- | ------------ | --------------------- |
|
|
25
|
-
| `--filter <pattern>` | Filter packages by glob pattern | All packages | `--filter "@scope/*"` |
|
|
26
|
-
| `--concurrency <number>` | Max concurrent processes | `4` | `--concurrency 8` |
|
|
27
|
-
| `--help` | Show command help | - | `--help` |
|
|
28
|
-
|
|
29
|
-
### Command-Specific Options
|
|
30
|
-
|
|
31
|
-
#### run command
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
workspace-utils run <script> [options]
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
| Option | Description | Default |
|
|
38
|
-
| -------------- | ------------------------------------ | ------- |
|
|
39
|
-
| `--sequential` | Run sequentially instead of parallel | `false` |
|
|
40
|
-
|
|
41
|
-
#### build command
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
workspace-utils build [options]
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
| Option | Description | Default |
|
|
48
|
-
| ------------------ | -------------------------------- | ------- |
|
|
49
|
-
| `--skip-unchanged` | Skip unchanged packages (future) | `false` |
|
|
50
|
-
|
|
51
|
-
#### dev command
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
workspace-utils dev [options]
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
No additional options - uses global options only.
|
|
58
|
-
|
|
59
|
-
## Environment Variables
|
|
60
|
-
|
|
61
|
-
workspace-utils respects these environment variables:
|
|
62
|
-
|
|
63
|
-
| Variable | Description | Default |
|
|
64
|
-
| ------------- | -------------------- | ------------- |
|
|
65
|
-
| `NODE_ENV` | Node environment | `development` |
|
|
66
|
-
| `FORCE_COLOR` | Force colored output | `1` (enabled) |
|
|
67
|
-
|
|
68
|
-
## Package Manager Detection
|
|
69
|
-
|
|
70
|
-
workspace-utils automatically detects your package manager based on lock files and configuration:
|
|
71
|
-
|
|
72
|
-
### Detection Priority
|
|
73
|
-
|
|
74
|
-
1. **Bun** - if `bun.lockb` exists or bun-specific fields in `package.json`
|
|
75
|
-
2. **pnpm** - if `pnpm-lock.yaml` or `pnpm-workspace.yaml` exists
|
|
76
|
-
3. **npm** - if `package-lock.json` exists
|
|
77
|
-
|
|
78
|
-
### Workspace Configuration
|
|
79
|
-
|
|
80
|
-
The tool reads workspace configuration from:
|
|
81
|
-
|
|
82
|
-
| Package Manager | Configuration Source |
|
|
83
|
-
| --------------- | ---------------------------------------- |
|
|
84
|
-
| **Bun** | `package.json` → `workspaces` field |
|
|
85
|
-
| **pnpm** | `pnpm-workspace.yaml` → `packages` field |
|
|
86
|
-
| **npm** | `package.json` → `workspaces` field |
|
|
87
|
-
|
|
88
|
-
## Workspace Structure Requirements
|
|
89
|
-
|
|
90
|
-
### Supported Workspace Formats
|
|
91
|
-
|
|
92
|
-
#### Bun Workspaces
|
|
93
|
-
|
|
94
|
-
```json
|
|
95
|
-
{
|
|
96
|
-
"name": "my-monorepo",
|
|
97
|
-
"workspaces": ["packages/*", "apps/*"]
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
#### pnpm Workspaces
|
|
102
|
-
|
|
103
|
-
```yaml
|
|
104
|
-
# pnpm-workspace.yaml
|
|
105
|
-
packages:
|
|
106
|
-
- 'packages/*'
|
|
107
|
-
- 'apps/*'
|
|
108
|
-
- '!**/test/**'
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
#### npm Workspaces
|
|
112
|
-
|
|
113
|
-
```json
|
|
114
|
-
{
|
|
115
|
-
"name": "my-monorepo",
|
|
116
|
-
"workspaces": {
|
|
117
|
-
"packages": ["packages/*", "apps/*"]
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Common Configuration Patterns
|
|
123
|
-
|
|
124
|
-
### Package.json Scripts
|
|
125
|
-
|
|
126
|
-
Add workspace-utils commands to your root `package.json`:
|
|
127
|
-
|
|
128
|
-
```json
|
|
129
|
-
{
|
|
130
|
-
"scripts": {
|
|
131
|
-
"test": "workspace-utils run test",
|
|
132
|
-
"test:sequential": "workspace-utils run test --sequential",
|
|
133
|
-
"build": "workspace-utils build",
|
|
134
|
-
"build:apps": "workspace-utils build --filter 'apps/*'",
|
|
135
|
-
"dev": "workspace-utils dev",
|
|
136
|
-
"lint": "workspace-utils run lint --concurrency 8",
|
|
137
|
-
"typecheck": "workspace-utils run typecheck --parallel"
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### CI/CD Configuration
|
|
143
|
-
|
|
144
|
-
Optimize for continuous integration:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
# Lower concurrency for CI resources
|
|
148
|
-
workspace-utils run test --concurrency 2
|
|
149
|
-
|
|
150
|
-
# Sequential builds for predictable resource usage
|
|
151
|
-
workspace-utils build --concurrency 1
|
|
152
|
-
|
|
153
|
-
# Parallel linting for speed
|
|
154
|
-
workspace-utils run lint --concurrency 4
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Development Workflow
|
|
158
|
-
|
|
159
|
-
Optimize for local development:
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
# Start all dev servers
|
|
163
|
-
workspace-utils dev
|
|
164
|
-
|
|
165
|
-
# Run tests with higher concurrency on powerful dev machines
|
|
166
|
-
workspace-utils run test --concurrency 8
|
|
167
|
-
|
|
168
|
-
# Filter to work on specific features
|
|
169
|
-
workspace-utils dev --filter "*frontend*"
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## Performance Tuning
|
|
173
|
-
|
|
174
|
-
### Concurrency Guidelines
|
|
175
|
-
|
|
176
|
-
| Task Type | Recommended Concurrency | Reasoning |
|
|
177
|
-
| --------------- | ----------------------- | -------------------------------- |
|
|
178
|
-
| **Tests** | 4-8 | Usually I/O bound, can run many |
|
|
179
|
-
| **Builds** | 2-4 | CPU intensive, fewer parallel |
|
|
180
|
-
| **Linting** | 6-12 | Fast, lightweight processes |
|
|
181
|
-
| **Dev servers** | 2-6 | Resource intensive, long-running |
|
|
182
|
-
|
|
183
|
-
### System Resources
|
|
184
|
-
|
|
185
|
-
Consider your system when setting concurrency:
|
|
186
|
-
|
|
187
|
-
```bash
|
|
188
|
-
# For 4-core machines
|
|
189
|
-
workspace-utils run build --concurrency 2
|
|
190
|
-
|
|
191
|
-
# For 8+ core machines
|
|
192
|
-
workspace-utils run test --concurrency 8
|
|
193
|
-
|
|
194
|
-
# For CI with limited resources
|
|
195
|
-
workspace-utils run lint --concurrency 2
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Filtering Patterns
|
|
199
|
-
|
|
200
|
-
### Glob Patterns
|
|
201
|
-
|
|
202
|
-
workspace-utils supports standard glob patterns:
|
|
203
|
-
|
|
204
|
-
| Pattern | Matches | Example |
|
|
205
|
-
| ------------ | ------------------------------ | ----------------------------------- |
|
|
206
|
-
| `@scope/*` | All packages in scope | `@company/utils`, `@company/ui` |
|
|
207
|
-
| `apps/*` | All packages in apps directory | `apps/web`, `apps/mobile` |
|
|
208
|
-
| `*-utils` | Packages ending with -utils | `date-utils`, `string-utils` |
|
|
209
|
-
| `*frontend*` | Packages containing frontend | `my-frontend-app`, `frontend-utils` |
|
|
210
|
-
|
|
211
|
-
### Multiple Filters
|
|
212
|
-
|
|
213
|
-
Use multiple invocations for complex filtering:
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
# Run tests on backend packages only
|
|
217
|
-
workspace-utils run test --filter "@company/backend-*"
|
|
218
|
-
|
|
219
|
-
# Build all apps and shared libraries
|
|
220
|
-
workspace-utils build --filter "apps/*"
|
|
221
|
-
workspace-utils build --filter "@company/shared-*"
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## Error Handling Configuration
|
|
225
|
-
|
|
226
|
-
### Exit Behavior
|
|
227
|
-
|
|
228
|
-
workspace-utils has different exit behaviors by command:
|
|
229
|
-
|
|
230
|
-
| Command | Failure Behavior |
|
|
231
|
-
| ------------------ | --------------------------------------------- |
|
|
232
|
-
| `run` (parallel) | Continue other packages, exit 1 if any failed |
|
|
233
|
-
| `run` (sequential) | Stop on first failure, exit with that code |
|
|
234
|
-
| `build` | Stop current batch on failure, skip remaining |
|
|
235
|
-
| `dev` | Stop all servers on any failure |
|
|
236
|
-
|
|
237
|
-
### Error Codes
|
|
238
|
-
|
|
239
|
-
| Exit Code | Meaning |
|
|
240
|
-
| --------- | ------------------------------------------ |
|
|
241
|
-
| `0` | All operations successful |
|
|
242
|
-
| `1` | One or more package operations failed |
|
|
243
|
-
| `2` | Configuration or workspace detection error |
|
|
244
|
-
|
|
245
|
-
## Next Steps
|
|
246
|
-
|
|
247
|
-
- Learn about [Workspace Detection](./concepts/workspace-detection.md)
|
|
248
|
-
- Explore [Package Manager Support](./concepts/package-managers.md)
|
|
249
|
-
- See [Performance Tuning](./advanced/performance.md) for optimization tips
|