workspace-utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/mdbook.yml +64 -0
- package/.prettierignore +22 -0
- package/.prettierrc +13 -0
- package/LICENSE +21 -0
- package/README.md +278 -0
- package/docs/book.toml +10 -0
- package/docs/src/SUMMARY.md +24 -0
- package/docs/src/commands/build.md +110 -0
- package/docs/src/commands/dev.md +118 -0
- package/docs/src/commands/overview.md +239 -0
- package/docs/src/commands/run.md +153 -0
- package/docs/src/configuration.md +249 -0
- package/docs/src/examples.md +567 -0
- package/docs/src/installation.md +148 -0
- package/docs/src/introduction.md +117 -0
- package/docs/src/quick-start.md +278 -0
- package/docs/src/troubleshooting.md +533 -0
- package/index.ts +84 -0
- package/package.json +54 -0
- package/src/commands/build.ts +158 -0
- package/src/commands/dev.ts +192 -0
- package/src/commands/run.test.ts +329 -0
- package/src/commands/run.ts +118 -0
- package/src/core/dependency-graph.ts +262 -0
- package/src/core/process-runner.ts +355 -0
- package/src/core/workspace.test.ts +404 -0
- package/src/core/workspace.ts +228 -0
- package/src/package-managers/bun.test.ts +209 -0
- package/src/package-managers/bun.ts +79 -0
- package/src/package-managers/detector.test.ts +199 -0
- package/src/package-managers/detector.ts +111 -0
- package/src/package-managers/index.ts +10 -0
- package/src/package-managers/npm.ts +79 -0
- package/src/package-managers/pnpm.ts +101 -0
- package/src/package-managers/types.ts +42 -0
- package/src/utils/output.ts +301 -0
- package/src/utils/package-utils.ts +243 -0
- package/tests/bun-workspace/apps/web-app/package.json +18 -0
- package/tests/bun-workspace/bun.lockb +0 -0
- package/tests/bun-workspace/package.json +18 -0
- package/tests/bun-workspace/packages/shared-utils/package.json +15 -0
- package/tests/bun-workspace/packages/ui-components/package.json +17 -0
- package/tests/npm-workspace/package-lock.json +0 -0
- package/tests/npm-workspace/package.json +18 -0
- package/tests/npm-workspace/packages/core/package.json +15 -0
- package/tests/pnpm-workspace/package.json +14 -0
- package/tests/pnpm-workspace/packages/utils/package.json +15 -0
- package/tests/pnpm-workspace/pnpm-workspace.yaml +3 -0
- package/tsconfig.json +29 -0
|
@@ -0,0 +1,64 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 pnpmono
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# 📦 bunmono
|
|
2
|
+
|
|
3
|
+
A **Bun-powered CLI tool** for orchestrating scripts across **Bun workspaces** with parallel execution, dependency-aware builds, and real-time log streaming.
|
|
4
|
+
|
|
5
|
+
## ✨ Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Parallel script execution** across multiple packages
|
|
8
|
+
- 📊 **Dependency-aware builds** with topological sorting
|
|
9
|
+
- 🎨 **Color-coded, prefixed logs** for easy identification
|
|
10
|
+
- 🔍 **Package filtering** with glob patterns
|
|
11
|
+
- ⚡ **Configurable concurrency** limits
|
|
12
|
+
- 🏗️ **Smart build ordering** respecting package dependencies
|
|
13
|
+
- 📺 **Real-time log streaming** with timestamps
|
|
14
|
+
- 🎯 **Zero configuration** - works with any Bun workspace
|
|
15
|
+
- 🟡 **Bun native** - designed specifically for Bun workspaces
|
|
16
|
+
|
|
17
|
+
## 🛠️ Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install globally
|
|
21
|
+
bun install -g bunmono
|
|
22
|
+
|
|
23
|
+
# Or use with bunx
|
|
24
|
+
bunx bunmono
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 🚀 Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Run tests across all packages (parallel by default)
|
|
31
|
+
bunmono run test
|
|
32
|
+
|
|
33
|
+
# Build packages in dependency order
|
|
34
|
+
bunmono build
|
|
35
|
+
|
|
36
|
+
# Start all dev servers with live logs
|
|
37
|
+
bunmono dev
|
|
38
|
+
|
|
39
|
+
# Run linting on specific packages
|
|
40
|
+
bunmono run lint --filter "@myorg/*"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 📖 Commands
|
|
44
|
+
|
|
45
|
+
### `run <script>`
|
|
46
|
+
|
|
47
|
+
Run a script across multiple packages with support for parallel or sequential execution.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bunmono run <script> [options]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Options:**
|
|
54
|
+
|
|
55
|
+
- `-c, --concurrency <number>` - Maximum concurrent processes (default: 4)
|
|
56
|
+
- `-f, --filter <pattern>` - Filter packages by glob pattern
|
|
57
|
+
- `--sequential` - Run scripts sequentially (default is parallel)
|
|
58
|
+
|
|
59
|
+
**Examples:**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Run tests across all packages (parallel by default)
|
|
63
|
+
bunmono run test
|
|
64
|
+
|
|
65
|
+
# Run build sequentially
|
|
66
|
+
bunmono run build --sequential
|
|
67
|
+
|
|
68
|
+
# Run dev only for frontend packages (parallel by default)
|
|
69
|
+
bunmono run dev --filter "@myorg/frontend-*"
|
|
70
|
+
|
|
71
|
+
# Run with custom concurrency
|
|
72
|
+
bunmono run lint --concurrency 8
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `build`
|
|
76
|
+
|
|
77
|
+
Build packages in dependency order, ensuring dependencies are built before dependents.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
bunmono build [options]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Options:**
|
|
84
|
+
|
|
85
|
+
- `-f, --filter <pattern>` - Filter packages by pattern
|
|
86
|
+
- `-c, --concurrency <number>` - Max concurrent builds per batch (default: 4)
|
|
87
|
+
- `--skip-unchanged` - Skip unchanged packages (future feature)
|
|
88
|
+
|
|
89
|
+
**Examples:**
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Build all packages in dependency order
|
|
93
|
+
bunmono build
|
|
94
|
+
|
|
95
|
+
# Build only specific scope
|
|
96
|
+
bunmono build --filter "@myorg/backend-*"
|
|
97
|
+
|
|
98
|
+
# Build with higher concurrency per batch
|
|
99
|
+
bunmono build --concurrency 8
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### `dev`
|
|
103
|
+
|
|
104
|
+
Start development servers with live log streaming and graceful shutdown.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
bunmono dev [options]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Options:**
|
|
111
|
+
|
|
112
|
+
- `-f, --filter <pattern>` - Filter packages by pattern
|
|
113
|
+
- `-c, --concurrency <number>` - Max concurrent dev servers (default: 4)
|
|
114
|
+
|
|
115
|
+
**Examples:**
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Start all dev servers
|
|
119
|
+
bunmono dev
|
|
120
|
+
|
|
121
|
+
# Start only frontend dev servers
|
|
122
|
+
bunmono dev --filter "apps/*"
|
|
123
|
+
|
|
124
|
+
# Limit concurrent dev servers
|
|
125
|
+
bunmono dev --concurrency 2
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 🔍 Package Filtering
|
|
129
|
+
|
|
130
|
+
Use glob patterns to target specific packages:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Scope-based filtering (runs in parallel by default)
|
|
134
|
+
bunmono run test --filter "@myorg/*"
|
|
135
|
+
bunmono run build --filter "@myorg/backend-*"
|
|
136
|
+
|
|
137
|
+
# Path-based filtering
|
|
138
|
+
bunmono run dev --filter "apps/*"
|
|
139
|
+
bunmono run lint --filter "packages/*"
|
|
140
|
+
|
|
141
|
+
# Name-based filtering with sequential execution
|
|
142
|
+
bunmono run test --filter "*-utils" --sequential
|
|
143
|
+
bunmono run build --filter "*frontend*"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 📊 Dependency Management
|
|
147
|
+
|
|
148
|
+
The tool automatically:
|
|
149
|
+
|
|
150
|
+
1. **Parses your workspace** from `package.json` workspaces
|
|
151
|
+
2. **Builds a dependency graph** from `package.json` files
|
|
152
|
+
3. **Calculates build order** using topological sorting
|
|
153
|
+
4. **Detects circular dependencies** and reports them
|
|
154
|
+
5. **Executes in batches** where each batch can run in parallel
|
|
155
|
+
|
|
156
|
+
### Example Dependency Resolution
|
|
157
|
+
|
|
158
|
+
Given this structure:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
├── packages/
|
|
162
|
+
│ ├── shared-utils/ (no dependencies)
|
|
163
|
+
│ ├── ui-components/ (depends on shared-utils)
|
|
164
|
+
│ └── api-client/ (depends on shared-utils)
|
|
165
|
+
└── apps/
|
|
166
|
+
└── web-app/ (depends on ui-components, api-client)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Build order will be:
|
|
170
|
+
|
|
171
|
+
1. **Batch 1:** `shared-utils` (parallel with others in batch)
|
|
172
|
+
2. **Batch 2:** `ui-components`, `api-client` (parallel with each other)
|
|
173
|
+
3. **Batch 3:** `web-app`
|
|
174
|
+
|
|
175
|
+
## 🎨 Log Output
|
|
176
|
+
|
|
177
|
+
Logs are color-coded and prefixed for easy identification:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
[shared-utils] Building shared utilities with Bun...
|
|
181
|
+
[ui-components] Starting component library build...
|
|
182
|
+
[web-app] Compiling application...
|
|
183
|
+
[shared-utils] ✅ Completed in 1,234ms
|
|
184
|
+
[ui-components] ✅ Completed in 2,456ms
|
|
185
|
+
[web-app] ✅ Completed in 3,789ms
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 📁 Workspace Requirements
|
|
189
|
+
|
|
190
|
+
Your project must have a `package.json` with `workspaces` field at the root.
|
|
191
|
+
|
|
192
|
+
### Example workspace `package.json`:
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"name": "my-monorepo",
|
|
197
|
+
"private": true,
|
|
198
|
+
"workspaces": ["packages/*", "apps/*"],
|
|
199
|
+
"scripts": {
|
|
200
|
+
"build": "bunmono build",
|
|
201
|
+
"dev": "bunmono dev",
|
|
202
|
+
"test": "bunmono run test"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 🟡 Why Bun?
|
|
208
|
+
|
|
209
|
+
This tool is specifically designed for **Bun workspaces** because:
|
|
210
|
+
|
|
211
|
+
- **Native performance** - Built with Bun for maximum speed
|
|
212
|
+
- **Simple workspace config** - Uses standard `package.json` workspaces
|
|
213
|
+
- **Modern tooling** - Leverages Bun's fast package manager and runtime
|
|
214
|
+
- **Developer experience** - Seamless integration with Bun's ecosystem
|
|
215
|
+
|
|
216
|
+
## ⚡ Performance Tips
|
|
217
|
+
|
|
218
|
+
1. **Use filtering** to target only the packages you need
|
|
219
|
+
2. **Adjust concurrency** based on your system resources (default: 4)
|
|
220
|
+
3. **Parallel by default** - most scripts benefit from parallel execution
|
|
221
|
+
4. **Use --sequential** only when order matters or for resource-intensive tasks
|
|
222
|
+
5. **For builds**, dependency ordering ensures correct execution even in parallel batches
|
|
223
|
+
6. **For dev servers**, use reasonable concurrency limits to avoid resource exhaustion
|
|
224
|
+
|
|
225
|
+
## 🐛 Troubleshooting
|
|
226
|
+
|
|
227
|
+
### "No workspaces configuration found"
|
|
228
|
+
|
|
229
|
+
Ensure your root `package.json` has a `workspaces` field with package patterns.
|
|
230
|
+
|
|
231
|
+
### "Circular dependencies detected"
|
|
232
|
+
|
|
233
|
+
Check your package dependencies for circular references:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# This will show the circular dependency chain
|
|
237
|
+
bunmono build
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### "No packages found with script"
|
|
241
|
+
|
|
242
|
+
Verify your packages have the required script in their `package.json`:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Check which packages have the script
|
|
246
|
+
bunmono run nonexistent-script
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## 🛣️ Roadmap
|
|
250
|
+
|
|
251
|
+
- [ ] **Caching** - Skip builds for unchanged packages
|
|
252
|
+
- [ ] **Watch mode** - Restart processes on file changes
|
|
253
|
+
- [ ] **Interactive mode** - Focus on specific package logs
|
|
254
|
+
- [ ] **Custom log formatters** - Configurable output styles
|
|
255
|
+
- [ ] **Dry run mode** - Preview execution plan
|
|
256
|
+
- [ ] **Bun-specific optimizations** - Leverage Bun features for better performance
|
|
257
|
+
|
|
258
|
+
## 🤝 Contributing
|
|
259
|
+
|
|
260
|
+
1. Fork the repository
|
|
261
|
+
2. Create a feature branch: `git checkout -b feature/amazing-feature`
|
|
262
|
+
3. Commit your changes: `git commit -m 'Add amazing feature'`
|
|
263
|
+
4. Push to the branch: `git push origin feature/amazing-feature`
|
|
264
|
+
5. Open a Pull Request
|
|
265
|
+
|
|
266
|
+
## 📄 License
|
|
267
|
+
|
|
268
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
269
|
+
|
|
270
|
+
## 🙏 Acknowledgments
|
|
271
|
+
|
|
272
|
+
- Built with [Bun](https://bun.sh) for blazing fast performance
|
|
273
|
+
- Inspired by the need for better Bun workspace tooling
|
|
274
|
+
- Thanks to the Bun team for creating an excellent runtime and package manager
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
**Made with ❤️ for the Bun community**
|
package/docs/book.toml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
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}"
|
|
@@ -0,0 +1,24 @@
|
|
|
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)
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
|
@@ -0,0 +1,118 @@
|
|
|
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
|