workspace-utils 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -56
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# 📦
|
|
1
|
+
# 📦 workspace-utils
|
|
2
2
|
|
|
3
|
-
A **
|
|
3
|
+
A **universal CLI tool** for orchestrating scripts across **monorepo workspaces** (Bun, pnpm, npm) with parallel execution, dependency-aware builds, and real-time log streaming.
|
|
4
4
|
|
|
5
5
|
## ✨ Features
|
|
6
6
|
|
|
@@ -11,33 +11,51 @@ A **Bun-powered CLI tool** for orchestrating scripts across **Bun workspaces** w
|
|
|
11
11
|
- ⚡ **Configurable concurrency** limits
|
|
12
12
|
- 🏗️ **Smart build ordering** respecting package dependencies
|
|
13
13
|
- 📺 **Real-time log streaming** with timestamps
|
|
14
|
-
- 🎯 **Zero configuration** - works with any
|
|
15
|
-
-
|
|
14
|
+
- 🎯 **Zero configuration** - works with any workspace setup
|
|
15
|
+
- 🌐 **Universal support** - works with Bun, pnpm, and npm workspaces
|
|
16
16
|
|
|
17
17
|
## 🛠️ Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
# Install
|
|
21
|
-
|
|
20
|
+
# Install as dev dependency with npm
|
|
21
|
+
npm install --save-dev workspace-utils
|
|
22
22
|
|
|
23
|
-
#
|
|
24
|
-
|
|
23
|
+
# Install as dev dependency with pnpm
|
|
24
|
+
pnpm add -D workspace-utils
|
|
25
|
+
|
|
26
|
+
# Install as dev dependency with bun
|
|
27
|
+
bun add -d workspace-utils
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
## 🚀 Quick Start
|
|
28
31
|
|
|
32
|
+
First, add workspace-utils scripts to your root `package.json`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "wsu dev",
|
|
38
|
+
"build": "wsu build",
|
|
39
|
+
"test": "wsu run test",
|
|
40
|
+
"lint": "wsu run lint --filter '@myorg/*'"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Then run them:
|
|
46
|
+
|
|
29
47
|
```bash
|
|
30
48
|
# Run tests across all packages (parallel by default)
|
|
31
|
-
|
|
49
|
+
npm run test
|
|
32
50
|
|
|
33
51
|
# Build packages in dependency order
|
|
34
|
-
|
|
52
|
+
npm run build
|
|
35
53
|
|
|
36
54
|
# Start all dev servers with live logs
|
|
37
|
-
|
|
55
|
+
npm run dev
|
|
38
56
|
|
|
39
57
|
# Run linting on specific packages
|
|
40
|
-
|
|
58
|
+
npm run lint
|
|
41
59
|
```
|
|
42
60
|
|
|
43
61
|
## 📖 Commands
|
|
@@ -47,7 +65,18 @@ bunmono run lint --filter "@myorg/*"
|
|
|
47
65
|
Run a script across multiple packages with support for parallel or sequential execution.
|
|
48
66
|
|
|
49
67
|
```bash
|
|
50
|
-
|
|
68
|
+
wsu run <script> [options]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Add to your `package.json` scripts and run with your package manager:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"scripts": {
|
|
76
|
+
"test": "wsu run test",
|
|
77
|
+
"test:sequential": "wsu run test --sequential"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
51
80
|
```
|
|
52
81
|
|
|
53
82
|
**Options:**
|
|
@@ -60,16 +89,29 @@ bunmono run <script> [options]
|
|
|
60
89
|
|
|
61
90
|
```bash
|
|
62
91
|
# Run tests across all packages (parallel by default)
|
|
63
|
-
|
|
92
|
+
npm run test
|
|
64
93
|
|
|
65
94
|
# Run build sequentially
|
|
66
|
-
|
|
95
|
+
npm run test:sequential
|
|
67
96
|
|
|
68
97
|
# Run dev only for frontend packages (parallel by default)
|
|
69
|
-
|
|
98
|
+
npm run dev:frontend
|
|
70
99
|
|
|
71
100
|
# Run with custom concurrency
|
|
72
|
-
|
|
101
|
+
npm run lint
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Example `package.json` scripts:
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"scripts": {
|
|
109
|
+
"test": "wsu run test",
|
|
110
|
+
"test:sequential": "wsu run test --sequential",
|
|
111
|
+
"dev:frontend": "wsu run dev --filter '@myorg/frontend-*'",
|
|
112
|
+
"lint": "wsu run lint --concurrency 8"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
73
115
|
```
|
|
74
116
|
|
|
75
117
|
### `build`
|
|
@@ -77,7 +119,7 @@ bunmono run lint --concurrency 8
|
|
|
77
119
|
Build packages in dependency order, ensuring dependencies are built before dependents.
|
|
78
120
|
|
|
79
121
|
```bash
|
|
80
|
-
|
|
122
|
+
wsu build [options]
|
|
81
123
|
```
|
|
82
124
|
|
|
83
125
|
**Options:**
|
|
@@ -90,13 +132,25 @@ bunmono build [options]
|
|
|
90
132
|
|
|
91
133
|
```bash
|
|
92
134
|
# Build all packages in dependency order
|
|
93
|
-
|
|
135
|
+
npm run build
|
|
94
136
|
|
|
95
137
|
# Build only specific scope
|
|
96
|
-
|
|
138
|
+
npm run build:backend
|
|
97
139
|
|
|
98
140
|
# Build with higher concurrency per batch
|
|
99
|
-
|
|
141
|
+
npm run build:fast
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Example `package.json` scripts:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"scripts": {
|
|
149
|
+
"build": "wsu build",
|
|
150
|
+
"build:backend": "wsu build --filter '@myorg/backend-*'",
|
|
151
|
+
"build:fast": "wsu build --concurrency 8"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
100
154
|
```
|
|
101
155
|
|
|
102
156
|
### `dev`
|
|
@@ -104,7 +158,7 @@ bunmono build --concurrency 8
|
|
|
104
158
|
Start development servers with live log streaming and graceful shutdown.
|
|
105
159
|
|
|
106
160
|
```bash
|
|
107
|
-
|
|
161
|
+
wsu dev [options]
|
|
108
162
|
```
|
|
109
163
|
|
|
110
164
|
**Options:**
|
|
@@ -116,38 +170,60 @@ bunmono dev [options]
|
|
|
116
170
|
|
|
117
171
|
```bash
|
|
118
172
|
# Start all dev servers
|
|
119
|
-
|
|
173
|
+
npm run dev
|
|
120
174
|
|
|
121
175
|
# Start only frontend dev servers
|
|
122
|
-
|
|
176
|
+
npm run dev:apps
|
|
123
177
|
|
|
124
178
|
# Limit concurrent dev servers
|
|
125
|
-
|
|
179
|
+
npm run dev:limited
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Example `package.json` scripts:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"scripts": {
|
|
187
|
+
"dev": "wsu dev",
|
|
188
|
+
"dev:apps": "wsu dev --filter 'apps/*'",
|
|
189
|
+
"dev:limited": "wsu dev --concurrency 2"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
126
192
|
```
|
|
127
193
|
|
|
128
194
|
## 🔍 Package Filtering
|
|
129
195
|
|
|
130
196
|
Use glob patterns to target specific packages:
|
|
131
197
|
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"scripts": {
|
|
201
|
+
"test:scope": "wsu run test --filter '@myorg/*'",
|
|
202
|
+
"build:backend": "wsu build --filter '@myorg/backend-*'",
|
|
203
|
+
"dev:apps": "wsu dev --filter 'apps/*'",
|
|
204
|
+
"lint:packages": "wsu run lint --filter 'packages/*'",
|
|
205
|
+
"test:utils": "wsu run test --filter '*-utils' --sequential",
|
|
206
|
+
"build:frontend": "wsu run build --filter '*frontend*'"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
136
210
|
|
|
137
|
-
|
|
138
|
-
bunmono run dev --filter "apps/*"
|
|
139
|
-
bunmono run lint --filter "packages/*"
|
|
211
|
+
Then run with:
|
|
140
212
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
213
|
+
```bash
|
|
214
|
+
npm run test:scope # Scope-based filtering
|
|
215
|
+
npm run build:backend # Build backend packages
|
|
216
|
+
npm run dev:apps # Start app dev servers
|
|
217
|
+
npm run lint:packages # Lint package directories
|
|
218
|
+
npm run test:utils # Test utilities sequentially
|
|
219
|
+
npm run build:frontend # Build frontend packages
|
|
144
220
|
```
|
|
145
221
|
|
|
146
222
|
## 📊 Dependency Management
|
|
147
223
|
|
|
148
224
|
The tool automatically:
|
|
149
225
|
|
|
150
|
-
1. **Parses your workspace** from `package.json` workspaces
|
|
226
|
+
1. **Parses your workspace** from `package.json` workspaces or `pnpm-workspace.yaml`
|
|
151
227
|
2. **Builds a dependency graph** from `package.json` files
|
|
152
228
|
3. **Calculates build order** using topological sorting
|
|
153
229
|
4. **Detects circular dependencies** and reports them
|
|
@@ -177,7 +253,7 @@ Build order will be:
|
|
|
177
253
|
Logs are color-coded and prefixed for easy identification:
|
|
178
254
|
|
|
179
255
|
```
|
|
180
|
-
[shared-utils] Building shared utilities
|
|
256
|
+
[shared-utils] Building shared utilities...
|
|
181
257
|
[ui-components] Starting component library build...
|
|
182
258
|
[web-app] Compiling application...
|
|
183
259
|
[shared-utils] ✅ Completed in 1,234ms
|
|
@@ -187,9 +263,9 @@ Logs are color-coded and prefixed for easy identification:
|
|
|
187
263
|
|
|
188
264
|
## 📁 Workspace Requirements
|
|
189
265
|
|
|
190
|
-
Your project must have
|
|
266
|
+
Your project must have one of the following workspace configurations:
|
|
191
267
|
|
|
192
|
-
###
|
|
268
|
+
### npm/Bun workspaces (`package.json`):
|
|
193
269
|
|
|
194
270
|
```json
|
|
195
271
|
{
|
|
@@ -197,21 +273,29 @@ Your project must have a `package.json` with `workspaces` field at the root.
|
|
|
197
273
|
"private": true,
|
|
198
274
|
"workspaces": ["packages/*", "apps/*"],
|
|
199
275
|
"scripts": {
|
|
200
|
-
"build": "
|
|
201
|
-
"dev": "
|
|
202
|
-
"test": "
|
|
276
|
+
"build": "wsu build",
|
|
277
|
+
"dev": "wsu dev",
|
|
278
|
+
"test": "wsu run test"
|
|
203
279
|
}
|
|
204
280
|
}
|
|
205
281
|
```
|
|
206
282
|
|
|
207
|
-
|
|
283
|
+
### pnpm workspaces (`pnpm-workspace.yaml`):
|
|
284
|
+
|
|
285
|
+
```yaml
|
|
286
|
+
packages:
|
|
287
|
+
- 'packages/*'
|
|
288
|
+
- 'apps/*'
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## 🌐 Package Manager Support
|
|
208
292
|
|
|
209
|
-
This tool
|
|
293
|
+
This tool works seamlessly with:
|
|
210
294
|
|
|
211
|
-
- **
|
|
212
|
-
- **
|
|
213
|
-
- **
|
|
214
|
-
- **
|
|
295
|
+
- **npm workspaces** - Uses standard `package.json` workspaces
|
|
296
|
+
- **pnpm workspaces** - Supports `pnpm-workspace.yaml` configuration
|
|
297
|
+
- **Bun workspaces** - Works with Bun's workspace implementation
|
|
298
|
+
- **Auto-detection** - Automatically detects your package manager and workspace setup
|
|
215
299
|
|
|
216
300
|
## ⚡ Performance Tips
|
|
217
301
|
|
|
@@ -226,7 +310,10 @@ This tool is specifically designed for **Bun workspaces** because:
|
|
|
226
310
|
|
|
227
311
|
### "No workspaces configuration found"
|
|
228
312
|
|
|
229
|
-
Ensure your
|
|
313
|
+
Ensure your project has one of the following:
|
|
314
|
+
|
|
315
|
+
- Root `package.json` with a `workspaces` field
|
|
316
|
+
- `pnpm-workspace.yaml` file with package patterns
|
|
230
317
|
|
|
231
318
|
### "Circular dependencies detected"
|
|
232
319
|
|
|
@@ -234,7 +321,7 @@ Check your package dependencies for circular references:
|
|
|
234
321
|
|
|
235
322
|
```bash
|
|
236
323
|
# This will show the circular dependency chain
|
|
237
|
-
|
|
324
|
+
npm run build
|
|
238
325
|
```
|
|
239
326
|
|
|
240
327
|
### "No packages found with script"
|
|
@@ -243,7 +330,7 @@ Verify your packages have the required script in their `package.json`:
|
|
|
243
330
|
|
|
244
331
|
```bash
|
|
245
332
|
# Check which packages have the script
|
|
246
|
-
|
|
333
|
+
npx wsu run nonexistent-script
|
|
247
334
|
```
|
|
248
335
|
|
|
249
336
|
## 🛣️ Roadmap
|
|
@@ -253,7 +340,8 @@ bunmono run nonexistent-script
|
|
|
253
340
|
- [ ] **Interactive mode** - Focus on specific package logs
|
|
254
341
|
- [ ] **Custom log formatters** - Configurable output styles
|
|
255
342
|
- [ ] **Dry run mode** - Preview execution plan
|
|
256
|
-
- [ ] **
|
|
343
|
+
- [ ] **Yarn workspaces support** - Add support for Yarn workspaces
|
|
344
|
+
- [ ] **Lerna integration** - Better compatibility with Lerna projects
|
|
257
345
|
|
|
258
346
|
## 🤝 Contributing
|
|
259
347
|
|
|
@@ -269,10 +357,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
269
357
|
|
|
270
358
|
## 🙏 Acknowledgments
|
|
271
359
|
|
|
272
|
-
- Built
|
|
273
|
-
- Inspired by the need for
|
|
274
|
-
- Thanks to the Bun
|
|
360
|
+
- Built for the modern JavaScript ecosystem
|
|
361
|
+
- Inspired by the need for universal monorepo tooling
|
|
362
|
+
- Thanks to the communities behind npm, pnpm, and Bun for creating excellent package managers
|
|
275
363
|
|
|
276
364
|
---
|
|
277
365
|
|
|
278
|
-
**Made with ❤️ for the
|
|
366
|
+
**Made with ❤️ for the JavaScript monorepo community**
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "workspace-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|