workspace-manager-cli 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.
Files changed (50) hide show
  1. package/README.md +339 -0
  2. package/dist/build.d.ts +19 -0
  3. package/dist/build.d.ts.map +1 -0
  4. package/dist/build.js +384 -0
  5. package/dist/build.js.map +1 -0
  6. package/dist/bundler/build-bundler.d.ts +9 -0
  7. package/dist/bundler/build-bundler.d.ts.map +1 -0
  8. package/dist/bundler/build-bundler.js +218 -0
  9. package/dist/bundler/build-bundler.js.map +1 -0
  10. package/dist/bundler/package-merger.d.ts +21 -0
  11. package/dist/bundler/package-merger.d.ts.map +1 -0
  12. package/dist/bundler/package-merger.js +192 -0
  13. package/dist/bundler/package-merger.js.map +1 -0
  14. package/dist/bundler/vite-generator.d.ts +14 -0
  15. package/dist/bundler/vite-generator.d.ts.map +1 -0
  16. package/dist/bundler/vite-generator.js +186 -0
  17. package/dist/bundler/vite-generator.js.map +1 -0
  18. package/dist/config.d.ts +250 -0
  19. package/dist/config.d.ts.map +1 -0
  20. package/dist/config.js +268 -0
  21. package/dist/config.js.map +1 -0
  22. package/dist/copy.d.ts +9 -0
  23. package/dist/copy.d.ts.map +1 -0
  24. package/dist/copy.js +56 -0
  25. package/dist/copy.js.map +1 -0
  26. package/dist/git.d.ts +76 -0
  27. package/dist/git.d.ts.map +1 -0
  28. package/dist/git.js +377 -0
  29. package/dist/git.js.map +1 -0
  30. package/dist/index-update-base.d.ts +2 -0
  31. package/dist/index-update-base.d.ts.map +1 -0
  32. package/dist/index-update-base.js +76 -0
  33. package/dist/index-update-base.js.map +1 -0
  34. package/dist/index.d.ts +3 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +626 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/lock.d.ts +39 -0
  39. package/dist/lock.d.ts.map +1 -0
  40. package/dist/lock.js +91 -0
  41. package/dist/lock.js.map +1 -0
  42. package/dist/logger.d.ts +42 -0
  43. package/dist/logger.d.ts.map +1 -0
  44. package/dist/logger.js +90 -0
  45. package/dist/logger.js.map +1 -0
  46. package/dist/status.d.ts +23 -0
  47. package/dist/status.d.ts.map +1 -0
  48. package/dist/status.js +158 -0
  49. package/dist/status.js.map +1 -0
  50. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,339 @@
1
+ # workspace-manager-cli
2
+
3
+ A cross-platform Node/TypeScript CLI that assembles a project workspace from a shared core boilerplate plus a project's custom folder.
4
+
5
+ ## Features
6
+
7
+ - **Smart caching**: Clones core repositories to local cache (`.wmc-cache/`)
8
+ - **Update notifications**: Shows when new commits are available with `wmc status`
9
+ - **Overlay system**: Layer your custom code on top of core boilerplate
10
+ - **Cross-platform**: Pure Node.js APIs, no shell dependencies
11
+ - **Automation-friendly**: `--json` flag for machine-readable output
12
+
13
+ ## Quick Start
14
+
15
+ ```bash
16
+ # Initialize cache and build workspace
17
+ wmc init --build
18
+
19
+ # Skip npm install after build
20
+ wmc init --build --no-install
21
+ # If not installed globally, use: npx workspace-manager-cli init --build
22
+ ```
23
+
24
+ ## Installation
25
+
26
+ ### Global Installation
27
+
28
+ ```bash
29
+ npm install -g workspace-manager-cli
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ Run `wmc init` (or `wmc init -i` or `wmc init --interactive`) in a folder without a config and the CLI will **generate `workspace.config.json` for you**, prompting for project type plus core/base URLs. It also writes a minimal `.gitignore` covering the generated workspace and cache.
35
+
36
+ Example of a generated `workspace.config.json` (base-core-custom):
37
+
38
+ ```json
39
+ {
40
+ "projectType": "base-core-custom",
41
+ "base": {
42
+ "name": "base",
43
+ "url": "https://github.com/example/base.git",
44
+ "ref": "main"
45
+ },
46
+ "core": {
47
+ "name": "core",
48
+ "url": "https://github.com/example/core.git",
49
+ "ref": "main"
50
+ },
51
+ "custom": {
52
+ "path": "custom"
53
+ },
54
+ "install": {
55
+ "command": "npm install"
56
+ }
57
+ }
58
+ ```
59
+
60
+ ### Configuration Options
61
+
62
+ | Field | Type | Default | Description |
63
+ | ----------------- | -------- | --------------- | ---------------------------------------------------------------------------------------------------------------- |
64
+ | `projectType` | enum | _required_ | One of `core-custom`, `base-core`, `base-core-custom`; determines which repos are required and how they overlay. |
65
+ | `base.name` | string | \_required\* | Base repo name (cache dir). Required when the project type includes base. |
66
+ | `base.url` | string | \_required\* | Git URL of base repo. |
67
+ | `base.ref` | string | `"main"` | Branch/tag/commit for base. |
68
+ | `core.name` | string | _required_ | Core repo name (cache dir). |
69
+ | `core.url` | string | \_required\*\* | Git URL of core repo (required for `core-custom` and `base-core-custom`; omit for `base-core`). |
70
+ | `core.path` | string | `"core"` | Local path to core folder (only for `base-core` type). |
71
+ | `core.ref` | string | `"main"` | Branch/tag/commit for core (only used when `core.url` is set). |
72
+ | (fixed) workspace | string | `"workspace"` | The workspace directory is fixed to `./workspace` and is not configurable |
73
+ | `custom.path` | string | `"custom"` | Path to your custom code directory |
74
+ | `install.command` | string | `"npm install"` | Command to run inside `workspace` after copying (skipped with `--no-install`) |
75
+ | `excludes` | string[] | `[]` | Additional glob patterns to exclude when copying |
76
+
77
+ \* Required when the selected `projectType` includes a base repository.
78
+ \*\* Required for `core-custom` and `base-core-custom`; omit for `base-core` (use `core.path` instead).
79
+
80
+ **Excludes & dry-run visibility** 🛑
81
+
82
+ - Use `excludes` to skip copying files or directories into the assembled `workspace` folder (`./workspace`).
83
+ - Examples: `excludes: ["**/*.log", "dist/**", "node_modules/**", "**/*.tmp"]` will prevent matching files from being copied.
84
+ - Use `--dry-run` (or `--dry-run` option) to preview actions — the build will add an action `Excludes: <patterns>` and log `Effective excludes: ...` so you can verify which globs will be applied before any copying occurs.
85
+
86
+ ### Project Types
87
+
88
+ - `core-custom`: Remote core + local custom overlay (no base). Core is cached in `.wmc-cache/<core>` and copied to `workspace`; custom overlays into `workspace/src/core/custom`.
89
+ - `base-core`: Remote base + local core folder. Base comes from cache; core is taken from a local path; custom is optional.
90
+ - `base-core-custom`: Remote base + remote core + local custom. Both base and core are cached; core replaces base's core area; custom overlays on top.
91
+
92
+ ## Commands
93
+
94
+ ### `init`
95
+
96
+ Initialize repositories (core/base) by cloning to local cache, optionally build.
97
+
98
+ ```bash
99
+ wmc init [options]
100
+ ```
101
+
102
+ **Options:**
103
+
104
+ - `--ref <ref>`: Override core ref (branch/tag/commit)
105
+ - `--base-ref <ref>`: Override base ref
106
+ - `--core-latest`: Checkout latest commit on core branch
107
+ - `--base-latest`: Checkout latest commit on base branch
108
+ - `--interactive`: Pick refs interactively (non-JSON mode)
109
+ - `--build`: Build workspace after initialization
110
+ - `--no-install`: Skip running `npm install` inside `workspace` (only applies when `--build` is used)
111
+
112
+ **What it does:**
113
+
114
+ - Clones configured repos to `.wmc-cache/<name>` (behavior depends on project type):
115
+ - `core-custom`: Clones core only
116
+ - `base-core`: Clones base only (core is local)
117
+ - `base-core-custom`: Clones both base and core
118
+ - Checks out the chosen refs
119
+ - Persists the resolved hashes/refs to `workspace.config.json`
120
+ - (Optional) Builds the workspace when `--build` is provided
121
+
122
+ ### `build` (alias: `sync`)
123
+
124
+ Build the workspace by assembling repositories and overlaying custom code based on project type.
125
+
126
+ ```bash
127
+ wmc build [options]
128
+ ```
129
+
130
+ **Options:**
131
+
132
+ - `--no-install`: Skip running `npm install` inside `workspace`
133
+ - `--dry-run`: Preview what will happen **without actually making any changes**. Useful for testing your config before committing to the build.
134
+
135
+ **Example:**
136
+
137
+ ```bash
138
+ wmc build --dry-run
139
+ ```
140
+
141
+ **What happens:**
142
+ - Reads your config and checks what files will be copied/excluded
143
+ - Logs each action it _would_ perform (copy, overlay, install, etc.)
144
+ - **Does NOT create or modify any files**
145
+ - Exits without touching `workspace/` or running `npm install`
146
+
147
+ **Real-world scenario:**
148
+ You just updated your `excludes` list and want to verify the right files will be copied before actually running the build. Run `wmc build --dry-run` first to see the preview, then if it looks good, run `wmc build` to execute it.
149
+
150
+ **What it does (varies by project type):**
151
+
152
+ - `core-custom`:
153
+ 1. Copy core from `.wmc-cache/<core>` to `workspace`
154
+ 2. Overlay `custom/` into `workspace/src/core/custom`
155
+ 3. Run `install.command` in `workspace`
156
+
157
+ - `base-core`:
158
+ 1. Copy base from `.wmc-cache/<base>` to `workspace`
159
+ 2. Copy local core from `config.core.path` to `workspace/src/core`
160
+ 3. Run `install.command` in `workspace`
161
+
162
+ - `base-core-custom`:
163
+ 1. Copy base from `.wmc-cache/<base>` to `workspace`
164
+ 2. Copy core from `.wmc-cache/<core>` to `workspace/src/core` (replacing base's core)
165
+ 3. Overlay `custom/` into `workspace/src/core/custom`
166
+ 4. Run `install.command` in `workspace`
167
+
168
+ ### `status`
169
+
170
+ Print current status of repositories and directories based on project type.
171
+
172
+ ```bash
173
+ wmc status
174
+ ```
175
+
176
+ **Shows (varies by project type):**
177
+
178
+ - `core-custom`:
179
+ - Core repo cache status (cloned, commit, branch)
180
+ - Core updates available (if any)
181
+ - Custom directory uncommitted changes
182
+
183
+ - `base-core`:
184
+ - Base repo cache status (cloned, commit, branch)
185
+ - Base updates available (if any)
186
+ - Local core directory location
187
+ - Custom directory uncommitted changes (if applicable)
188
+
189
+ - `base-core-custom`:
190
+ - Base repo cache status (cloned, commit, branch)
191
+ - Base updates available (if any)
192
+ - Core repo cache status (cloned, commit, branch)
193
+ - Core updates available (if any)
194
+ - Custom directory uncommitted changes
195
+
196
+ ## Global Options
197
+
198
+ | Option | Description |
199
+ | ----------- | ---------------------------------------------------- |
200
+ | `--json` | Output machine-readable JSON (useful for automation) |
201
+ | `--version` | Show version number |
202
+ | `--help` | Show help |
203
+
204
+ ## What to Commit
205
+
206
+ ✅ **Commit these:**
207
+
208
+ - `workspace.config.json`
209
+ - `custom/` directory (your custom code)
210
+
211
+ ❌ **Don't commit:**
212
+
213
+ - `workspace/` (generated)
214
+ - `.wmc-cache/` (local cache)
215
+ - `workspace/node_modules/` (dependencies)
216
+
217
+ ## How It Works
218
+
219
+ Core repository is cloned to a local cache directory and reused across builds:
220
+
221
+ - **Cache location**: `.wmc-cache/<name>` (in project root)
222
+ - **Fast builds**: Reuses cached repositories, only fetches when needed
223
+ - **Update notifications**: `wmc status` shows when new commits are available
224
+
225
+ **Project Structure:**
226
+
227
+ ```
228
+ ┌─────────────────────────────────────────────────────────────────┐
229
+ │ Your Project │
230
+ ├─────────────────────────────────────────────────────────────────┤
231
+ │ workspace.config.json │
232
+ │ custom/ │
233
+ │ .wmc-cache/ ← Git repos cloned here │
234
+ │ └── CORE-EKCFastag/ │
235
+ │ ├── .git/ │
236
+ │ └── src/ │
237
+ │ workspace/ (generated) ← Files copied here │
238
+ └─────────────────────────────────────────────────────────────────┘
239
+ ```
240
+
241
+ **Workflow:**
242
+
243
+ ```bash
244
+ # Developer A initializes and builds
245
+ wmc init --build # Clones to local .wmc-cache and builds workspace
246
+
247
+ # Developer A commits their work
248
+ git add custom/ workspace.config.json
249
+ git commit -m "Add feature X"
250
+ git push
251
+
252
+ # Developer B pulls and builds
253
+ git pull
254
+ wmc init --build # Populates their own .wmc-cache and rebuilds workspace
255
+ # Note: .wmc-cache is local per developer, not shared
256
+
257
+ # Check for updates
258
+ wmc status # Shows if new commits are available
259
+ wmc init --core-latest --build # Fetch latest core, then rebuild
260
+ ```
261
+
262
+ **Note on sharing:**
263
+
264
+ - Each developer has their own `.wmc-cache/` (not committed to git)
265
+ - Developers share: `workspace.config.json`, `custom/` folder, and `core/` folder (if local)
266
+ - After `git pull`, run `wmc init --build` to populate your local cache and rebuild workspace
267
+
268
+ ## Automation (not tested)
269
+
270
+ ### CI/CD Pipeline Example
271
+
272
+ ```yaml
273
+ # GitHub Actions example
274
+ jobs:
275
+ build:
276
+ runs-on: ubuntu-latest
277
+ steps:
278
+ - uses: actions/checkout@v4
279
+
280
+ - name: Setup Node.js
281
+ uses: actions/setup-node@v4
282
+ with:
283
+ node-version: "20"
284
+
285
+ - name: Initialize core
286
+ run: wmc init --json
287
+
288
+ - name: Build workspace
289
+ run: wmc build --json
290
+
291
+ - name: Build project
292
+ run: cd workspace && npm run build
293
+ ```
294
+
295
+ ### JSON Output
296
+
297
+ Use `--json` for machine-readable output:
298
+
299
+ ```bash
300
+ wmc status --json # or: npx workspace-manager-cli status --json
301
+ ```
302
+
303
+ ```json
304
+ {
305
+ "command": "status",
306
+ "config": { ... },
307
+ "status": {
308
+ "coreInitialized": true,
309
+ "coreCommit": "abc123...",
310
+ "customHasChanges": false
311
+ }
312
+ }
313
+ ```
314
+
315
+ ## Troubleshooting
316
+
317
+ ### "Could not find workspace.config.json"
318
+
319
+ Make sure you're running the CLI from a directory that has `workspace.config.json` or one of its parent directories.
320
+
321
+ ### "Core repository not found"
322
+
323
+ Run `wmc init` (or `npx workspace-manager-cli init` if not installed globally).
324
+
325
+ ### "Failed to checkout ref"
326
+
327
+ Ensure the ref (branch/tag/commit) exists in the core repository. Try:
328
+
329
+ ```bash
330
+ wmc init --ref main --build # or: npx workspace-manager-cli init --ref main --build
331
+ ```
332
+
333
+ ### Build fails with permission errors
334
+
335
+ On Windows, ensure no processes are using files in the workspace directory.
336
+
337
+ ## License
338
+
339
+ MIT
@@ -0,0 +1,19 @@
1
+ import type { ResolvedConfig } from "./config.js";
2
+ import { Logger } from "./logger.js";
3
+ export interface BuildOptions {
4
+ noInstall?: boolean;
5
+ dryRun?: boolean;
6
+ }
7
+ export interface BuildResult {
8
+ success: boolean;
9
+ baseFilesCopied: number;
10
+ coreFilesCopied: number;
11
+ customFilesCopied: number;
12
+ installRan: boolean;
13
+ actions: string[];
14
+ }
15
+ /**
16
+ * Build the workspace by copying layers based on project type
17
+ */
18
+ export declare function buildWorkspace(config: ResolvedConfig, logger: Logger, options?: BuildOptions): Promise<BuildResult>;
19
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAuGD;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC,CA8ItB"}