slicejs-cli 3.1.0 → 3.2.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 (35) hide show
  1. package/README.md +375 -375
  2. package/client.js +579 -555
  3. package/commands/Print.js +167 -167
  4. package/commands/Validations.js +103 -103
  5. package/commands/build/build.js +40 -40
  6. package/commands/buildProduction/buildProduction.js +579 -579
  7. package/commands/bundle/bundle.js +235 -235
  8. package/commands/createComponent/VisualComponentTemplate.js +55 -55
  9. package/commands/createComponent/createComponent.js +126 -126
  10. package/commands/deleteComponent/deleteComponent.js +77 -77
  11. package/commands/doctor/doctor.js +369 -369
  12. package/commands/getComponent/getComponent.js +747 -747
  13. package/commands/init/init.js +261 -261
  14. package/commands/listComponents/listComponents.js +175 -175
  15. package/commands/startServer/startServer.js +264 -264
  16. package/commands/startServer/watchServer.js +79 -79
  17. package/commands/types/types.js +538 -0
  18. package/commands/utils/LocalCliDelegation.js +53 -53
  19. package/commands/utils/PathHelper.js +68 -68
  20. package/commands/utils/VersionChecker.js +167 -167
  21. package/commands/utils/bundling/BundleGenerator.js +2292 -2292
  22. package/commands/utils/bundling/DependencyAnalyzer.js +933 -933
  23. package/commands/utils/updateManager.js +453 -453
  24. package/docs/superpowers/specs/2026-05-10-pwa-generate-design.md +182 -0
  25. package/package.json +46 -46
  26. package/post.js +25 -25
  27. package/refactor.md +271 -271
  28. package/tests/bundle-generator.test.js +708 -708
  29. package/tests/bundle-v2-register-output.test.js +470 -470
  30. package/tests/client-launcher-contract.test.js +211 -211
  31. package/tests/client-update-flow-contract.test.js +272 -272
  32. package/tests/dependency-analyzer.test.js +24 -24
  33. package/tests/local-cli-delegation.test.js +79 -79
  34. package/tests/types-generator.test.js +356 -0
  35. package/tests/update-manager-notifications.test.js +88 -88
package/README.md CHANGED
@@ -1,375 +1,375 @@
1
- <div align="center">
2
-
3
- # Slice.js CLI
4
- <img src="./assets/Slice.js-logo.png" alt="Slice.js logo" width="200" />
5
- <br/>
6
-
7
- <div style="display: flex; justify-content: center; align-items: center; gap: 10px; align-content: center;">
8
- <a href="https://www.npmjs.com/package/slicejs-cli"><img src="https://img.shields.io/npm/v/slicejs-cli.svg?label=CLI" alt="npm version" /></a>
9
- <img src="https://img.shields.io/badge/Node-%E2%89%A5%2020.0.0-339933?logo=node.js" alt="node requirement" />
10
- <a href="#license"><img src="https://img.shields.io/badge/License-ISC-blue.svg" alt="license" /></a>
11
- </div>
12
-
13
-
14
- <p>CLI for building web applications with the Slice.js framework</p>
15
-
16
- </div>
17
-
18
- ## Installation
19
-
20
- ### Local (Recommended)
21
-
22
- 1. Install as a development dependency:
23
-
24
- ```bash
25
- npm install slicejs-cli --save-dev
26
- ```
27
-
28
- 2. Add to your `package.json` scripts:
29
-
30
- ```json
31
- {
32
- "scripts": {
33
- "dev": "slice dev",
34
- "build": "slice build",
35
- "slice": "slice"
36
- }
37
- }
38
- ```
39
-
40
- 3. usage:
41
-
42
- ```bash
43
- npm run dev
44
- # or pass arguments
45
- npm run slice -- get Button
46
- ```
47
-
48
- 4. Use `slice` directly when the launcher command is available on your system
49
- (commonly after a global install that puts `slice` in your PATH).
50
- The launcher delegates to your nearest project-local `node_modules/slicejs-cli`
51
- so project-pinned behavior is used from the project root and subdirectories.
52
-
53
- ```bash
54
- slice dev
55
- slice build
56
- slice version
57
- ```
58
-
59
- If `slice` is not available in your shell, use:
60
-
61
- ```bash
62
- npx slicejs-cli dev
63
- ```
64
-
65
- You can disable launcher delegation for a command when needed:
66
-
67
- ```bash
68
- SLICE_NO_LOCAL_DELEGATION=1 slice version
69
- ```
70
-
71
- ### Global (Not Recommended)
72
-
73
- Global installations can lead to version mismatches and "works on my machine" issues.
74
-
75
- ```bash
76
- npm install -g slicejs-cli
77
- ```
78
-
79
- ## Usage
80
-
81
- After installation, prefer your project-local CLI. When the `slice` launcher command is
82
- available, it automatically delegates to the nearest local `slicejs-cli` install.
83
-
84
- Use the `slice` command directly:
85
-
86
- ```bash
87
- slice [command] [options]
88
- ```
89
-
90
- Or with npx (without global install):
91
-
92
- ```bash
93
- npx slicejs-cli [command]
94
- ```
95
-
96
- Use `npx slicejs-cli [command]` as a fallback when the `slice` launcher command is unavailable.
97
-
98
- ## Essential Commands
99
-
100
- ### Initialize a project
101
-
102
- ```bash
103
- slice init
104
- ```
105
-
106
- Initializes a Slice.js project with the full structure (`src/` and `api/`), installs initial Visual components, and configures npm scripts.
107
-
108
- ### Development server
109
-
110
- ```bash
111
- # Default port (3000)
112
- slice dev
113
-
114
- # Custom port
115
- slice dev -p 8080
116
- ```
117
-
118
- ### Production build + server
119
-
120
- ```bash
121
- # Build production output (minified + obfuscated by default)
122
- slice build
123
-
124
- # Disable minification or obfuscation
125
- slice build --no-minify
126
- slice build --no-obfuscate
127
-
128
- # Start production server (serves /dist)
129
- slice start
130
- slice start -p 8080
131
- ```
132
-
133
- ### Component management (local)
134
-
135
- ```bash
136
- # Create a component (interactive)
137
- slice component create
138
-
139
- # List local components
140
- slice component list
141
-
142
- # Delete a component (interactive)
143
- slice component delete
144
- ```
145
-
146
- Shortcuts:
147
- ```bash
148
- slice comp create
149
- slice comp ls
150
- slice comp remove
151
- ```
152
-
153
- ### Official component registry
154
-
155
- ```bash
156
- # Install Visual components
157
- slice get Button Card Input
158
-
159
- # Install a Service component
160
- slice get FetchManager --service
161
-
162
- # Force overwrite
163
- slice get Button --force
164
-
165
- # Browse available components
166
- slice browse
167
-
168
- # Update all local components
169
- slice sync
170
- slice sync --force
171
- ```
172
-
173
- Shortcuts:
174
- ```bash
175
- slice get Button
176
- slice browse
177
- slice sync
178
- ```
179
-
180
- ### Utilities
181
-
182
- ```bash
183
- # Version info
184
- slice version
185
- slice v
186
-
187
- # Updates (CLI and Framework)
188
- slice update # Check and prompt to update
189
- slice update --yes # Update everything automatically
190
- slice update --cli # CLI only
191
- slice update --framework # Framework only
192
-
193
- # Help
194
- slice --help
195
- slice [command] --help
196
- ```
197
-
198
- ## npm Scripts
199
-
200
- `slice init` automatically configures the recommended scripts in your `package.json`:
201
-
202
- ```json
203
- {
204
- "scripts": {
205
- "dev": "slice dev",
206
- "start": "slice start",
207
- "get": "slice get",
208
- "browse": "slice browse",
209
- "sync": "slice sync",
210
- "component:create": "slice component create",
211
- "component:list": "slice component list",
212
- "component:delete": "slice component delete"
213
- }
214
- }
215
- ```
216
-
217
- Usage:
218
- ```bash
219
- npm run dev
220
- npm run get
221
- npm run browse
222
- ```
223
-
224
- ## Quick Start
225
-
226
- ```bash
227
- # 1. Create a new project directory
228
- mkdir my-slice-project
229
- cd my-slice-project
230
-
231
- # 2. Initialize npm and install Slice CLI
232
- npm init -y
233
- npm install slicejs-cli --save-dev
234
-
235
- # 3. Initialize Slice.js project
236
- slice init
237
-
238
- # 4. Start development server
239
- slice dev
240
-
241
- # 5. Open browser at http://localhost:3000
242
- ```
243
-
244
- ## Common Workflows
245
-
246
- ### Starting a New Project
247
-
248
- ```bash
249
- slice init
250
- slice dev
251
- ```
252
-
253
- ### Production Build + Start
254
-
255
- ```bash
256
- slice build
257
- slice start
258
- ```
259
-
260
- ### Adding Components
261
-
262
- ```bash
263
- # Browse available components
264
- slice browse
265
-
266
- # Install specific components
267
- slice get Button Card Input
268
-
269
- # Create custom component
270
- slice component create
271
- ```
272
-
273
- ### Keeping Components Updated
274
-
275
- ```bash
276
- # Check what needs updating
277
- slice browse
278
-
279
- # Update all components
280
- slice sync
281
- ```
282
-
283
- ## Development Mode
284
-
285
- The development server (`slice dev`) provides:
286
-
287
- - ✅ Hot reload
288
- - ✅ Serves directly from `/src`
289
- - ✅ No build step
290
- - ✅ Port validation
291
- - ✅ Clear error messages
292
-
293
- ## Production Mode
294
-
295
- The production workflow uses `slice build` + `slice start`:
296
-
297
- - ✅ Builds to `/dist`
298
- - ✅ Generates bundles into `/dist/bundles`
299
- - ✅ Generates a dedicated framework bundle for Structural components (`slice-bundle.framework.js`)
300
- - ✅ Minifies + obfuscates by default
301
- - ✅ Serves production assets only
302
-
303
- ## Requirements
304
-
305
- - Node.js >= 20.0.0
306
- - npm or yarn
307
-
308
- ## Configuration
309
-
310
- Project configuration is stored in `src/sliceConfig.json` and is created automatically by `slice init`.
311
-
312
- In production, `publicFolders` defines **public asset folders** served by the server (defaults to
313
- `/Themes`, `/Styles`, `/assets`). This keeps source-only folders private while exposing the assets
314
- your app needs.
315
-
316
- ## Features
317
-
318
- - 🚀 Development server with hot reload
319
- - 📦 Official component registry
320
- - 🎨 Visual and Service component types
321
- - ✨ Interactive component creation
322
- - 🔄 Automatic component synchronization
323
- - 🛠️ Built-in validation and error handling
324
-
325
- ### Smart Updates
326
-
327
- - Detects whether the CLI in use is global or local
328
- - Shows an update plan (GLOBAL/PROJECT) before execution
329
- - Offers to include global CLI update interactively
330
- - Applies `uninstall` + `install @latest` to ensure latest versions
331
-
332
- ### Cross-platform Paths
333
-
334
- - Centralized path helper avoids `../../..`
335
- - Windows/Linux/Mac compatibility using `import.meta.url` and `fileURLToPath`
336
-
337
- ## Troubleshooting
338
-
339
- ### Port already in use
340
-
341
- ```bash
342
- # Use a different port
343
- slice dev -p 8080
344
- ```
345
-
346
- ### Project not initialized
347
-
348
- ```bash
349
- # Make sure to run init first
350
- slice init
351
- ```
352
-
353
- ### Command not found
354
-
355
- ```bash
356
- # If the launcher command is unavailable, run the local CLI via npx
357
- npx slicejs-cli dev
358
-
359
- # Optional: install globally to expose the slice launcher command
360
- npm install -g slicejs-cli
361
- ```
362
-
363
- ## Links
364
-
365
- - 📘 CLI Documentation: https://slice-js-docs.vercel.app/Documentation/CLI
366
- - 🐙 GitHub: https://github.com/VKneider/slice-cli
367
- - 📦 npm: https://www.npmjs.com/package/slicejs-cli
368
-
369
- ## License
370
-
371
- ISC
372
-
373
- ## Author
374
-
375
- vkneider
1
+ <div align="center">
2
+
3
+ # Slice.js CLI
4
+ <img src="./assets/Slice.js-logo.png" alt="Slice.js logo" width="200" />
5
+ <br/>
6
+
7
+ <div style="display: flex; justify-content: center; align-items: center; gap: 10px; align-content: center;">
8
+ <a href="https://www.npmjs.com/package/slicejs-cli"><img src="https://img.shields.io/npm/v/slicejs-cli.svg?label=CLI" alt="npm version" /></a>
9
+ <img src="https://img.shields.io/badge/Node-%E2%89%A5%2020.0.0-339933?logo=node.js" alt="node requirement" />
10
+ <a href="#license"><img src="https://img.shields.io/badge/License-ISC-blue.svg" alt="license" /></a>
11
+ </div>
12
+
13
+
14
+ <p>CLI for building web applications with the Slice.js framework</p>
15
+
16
+ </div>
17
+
18
+ ## Installation
19
+
20
+ ### Local (Recommended)
21
+
22
+ 1. Install as a development dependency:
23
+
24
+ ```bash
25
+ npm install slicejs-cli --save-dev
26
+ ```
27
+
28
+ 2. Add to your `package.json` scripts:
29
+
30
+ ```json
31
+ {
32
+ "scripts": {
33
+ "dev": "slice dev",
34
+ "build": "slice build",
35
+ "slice": "slice"
36
+ }
37
+ }
38
+ ```
39
+
40
+ 3. usage:
41
+
42
+ ```bash
43
+ npm run dev
44
+ # or pass arguments
45
+ npm run slice -- get Button
46
+ ```
47
+
48
+ 4. Use `slice` directly when the launcher command is available on your system
49
+ (commonly after a global install that puts `slice` in your PATH).
50
+ The launcher delegates to your nearest project-local `node_modules/slicejs-cli`
51
+ so project-pinned behavior is used from the project root and subdirectories.
52
+
53
+ ```bash
54
+ slice dev
55
+ slice build
56
+ slice version
57
+ ```
58
+
59
+ If `slice` is not available in your shell, use:
60
+
61
+ ```bash
62
+ npx slicejs-cli dev
63
+ ```
64
+
65
+ You can disable launcher delegation for a command when needed:
66
+
67
+ ```bash
68
+ SLICE_NO_LOCAL_DELEGATION=1 slice version
69
+ ```
70
+
71
+ ### Global (Not Recommended)
72
+
73
+ Global installations can lead to version mismatches and "works on my machine" issues.
74
+
75
+ ```bash
76
+ npm install -g slicejs-cli
77
+ ```
78
+
79
+ ## Usage
80
+
81
+ After installation, prefer your project-local CLI. When the `slice` launcher command is
82
+ available, it automatically delegates to the nearest local `slicejs-cli` install.
83
+
84
+ Use the `slice` command directly:
85
+
86
+ ```bash
87
+ slice [command] [options]
88
+ ```
89
+
90
+ Or with npx (without global install):
91
+
92
+ ```bash
93
+ npx slicejs-cli [command]
94
+ ```
95
+
96
+ Use `npx slicejs-cli [command]` as a fallback when the `slice` launcher command is unavailable.
97
+
98
+ ## Essential Commands
99
+
100
+ ### Initialize a project
101
+
102
+ ```bash
103
+ slice init
104
+ ```
105
+
106
+ Initializes a Slice.js project with the full structure (`src/` and `api/`), installs initial Visual components, and configures npm scripts.
107
+
108
+ ### Development server
109
+
110
+ ```bash
111
+ # Default port (3000)
112
+ slice dev
113
+
114
+ # Custom port
115
+ slice dev -p 8080
116
+ ```
117
+
118
+ ### Production build + server
119
+
120
+ ```bash
121
+ # Build production output (minified + obfuscated by default)
122
+ slice build
123
+
124
+ # Disable minification or obfuscation
125
+ slice build --no-minify
126
+ slice build --no-obfuscate
127
+
128
+ # Start production server (serves /dist)
129
+ slice start
130
+ slice start -p 8080
131
+ ```
132
+
133
+ ### Component management (local)
134
+
135
+ ```bash
136
+ # Create a component (interactive)
137
+ slice component create
138
+
139
+ # List local components
140
+ slice component list
141
+
142
+ # Delete a component (interactive)
143
+ slice component delete
144
+ ```
145
+
146
+ Shortcuts:
147
+ ```bash
148
+ slice comp create
149
+ slice comp ls
150
+ slice comp remove
151
+ ```
152
+
153
+ ### Official component registry
154
+
155
+ ```bash
156
+ # Install Visual components
157
+ slice get Button Card Input
158
+
159
+ # Install a Service component
160
+ slice get FetchManager --service
161
+
162
+ # Force overwrite
163
+ slice get Button --force
164
+
165
+ # Browse available components
166
+ slice browse
167
+
168
+ # Update all local components
169
+ slice sync
170
+ slice sync --force
171
+ ```
172
+
173
+ Shortcuts:
174
+ ```bash
175
+ slice get Button
176
+ slice browse
177
+ slice sync
178
+ ```
179
+
180
+ ### Utilities
181
+
182
+ ```bash
183
+ # Version info
184
+ slice version
185
+ slice v
186
+
187
+ # Updates (CLI and Framework)
188
+ slice update # Check and prompt to update
189
+ slice update --yes # Update everything automatically
190
+ slice update --cli # CLI only
191
+ slice update --framework # Framework only
192
+
193
+ # Help
194
+ slice --help
195
+ slice [command] --help
196
+ ```
197
+
198
+ ## npm Scripts
199
+
200
+ `slice init` automatically configures the recommended scripts in your `package.json`:
201
+
202
+ ```json
203
+ {
204
+ "scripts": {
205
+ "dev": "slice dev",
206
+ "start": "slice start",
207
+ "get": "slice get",
208
+ "browse": "slice browse",
209
+ "sync": "slice sync",
210
+ "component:create": "slice component create",
211
+ "component:list": "slice component list",
212
+ "component:delete": "slice component delete"
213
+ }
214
+ }
215
+ ```
216
+
217
+ Usage:
218
+ ```bash
219
+ npm run dev
220
+ npm run get
221
+ npm run browse
222
+ ```
223
+
224
+ ## Quick Start
225
+
226
+ ```bash
227
+ # 1. Create a new project directory
228
+ mkdir my-slice-project
229
+ cd my-slice-project
230
+
231
+ # 2. Initialize npm and install Slice CLI
232
+ npm init -y
233
+ npm install slicejs-cli --save-dev
234
+
235
+ # 3. Initialize Slice.js project
236
+ slice init
237
+
238
+ # 4. Start development server
239
+ slice dev
240
+
241
+ # 5. Open browser at http://localhost:3000
242
+ ```
243
+
244
+ ## Common Workflows
245
+
246
+ ### Starting a New Project
247
+
248
+ ```bash
249
+ slice init
250
+ slice dev
251
+ ```
252
+
253
+ ### Production Build + Start
254
+
255
+ ```bash
256
+ slice build
257
+ slice start
258
+ ```
259
+
260
+ ### Adding Components
261
+
262
+ ```bash
263
+ # Browse available components
264
+ slice browse
265
+
266
+ # Install specific components
267
+ slice get Button Card Input
268
+
269
+ # Create custom component
270
+ slice component create
271
+ ```
272
+
273
+ ### Keeping Components Updated
274
+
275
+ ```bash
276
+ # Check what needs updating
277
+ slice browse
278
+
279
+ # Update all components
280
+ slice sync
281
+ ```
282
+
283
+ ## Development Mode
284
+
285
+ The development server (`slice dev`) provides:
286
+
287
+ - ✅ Hot reload
288
+ - ✅ Serves directly from `/src`
289
+ - ✅ No build step
290
+ - ✅ Port validation
291
+ - ✅ Clear error messages
292
+
293
+ ## Production Mode
294
+
295
+ The production workflow uses `slice build` + `slice start`:
296
+
297
+ - ✅ Builds to `/dist`
298
+ - ✅ Generates bundles into `/dist/bundles`
299
+ - ✅ Generates a dedicated framework bundle for Structural components (`slice-bundle.framework.js`)
300
+ - ✅ Minifies + obfuscates by default
301
+ - ✅ Serves production assets only
302
+
303
+ ## Requirements
304
+
305
+ - Node.js >= 20.0.0
306
+ - npm or yarn
307
+
308
+ ## Configuration
309
+
310
+ Project configuration is stored in `src/sliceConfig.json` and is created automatically by `slice init`.
311
+
312
+ In production, `publicFolders` defines **public asset folders** served by the server (defaults to
313
+ `/Themes`, `/Styles`, `/assets`). This keeps source-only folders private while exposing the assets
314
+ your app needs.
315
+
316
+ ## Features
317
+
318
+ - 🚀 Development server with hot reload
319
+ - 📦 Official component registry
320
+ - 🎨 Visual and Service component types
321
+ - ✨ Interactive component creation
322
+ - 🔄 Automatic component synchronization
323
+ - 🛠️ Built-in validation and error handling
324
+
325
+ ### Smart Updates
326
+
327
+ - Detects whether the CLI in use is global or local
328
+ - Shows an update plan (GLOBAL/PROJECT) before execution
329
+ - Offers to include global CLI update interactively
330
+ - Applies `uninstall` + `install @latest` to ensure latest versions
331
+
332
+ ### Cross-platform Paths
333
+
334
+ - Centralized path helper avoids `../../..`
335
+ - Windows/Linux/Mac compatibility using `import.meta.url` and `fileURLToPath`
336
+
337
+ ## Troubleshooting
338
+
339
+ ### Port already in use
340
+
341
+ ```bash
342
+ # Use a different port
343
+ slice dev -p 8080
344
+ ```
345
+
346
+ ### Project not initialized
347
+
348
+ ```bash
349
+ # Make sure to run init first
350
+ slice init
351
+ ```
352
+
353
+ ### Command not found
354
+
355
+ ```bash
356
+ # If the launcher command is unavailable, run the local CLI via npx
357
+ npx slicejs-cli dev
358
+
359
+ # Optional: install globally to expose the slice launcher command
360
+ npm install -g slicejs-cli
361
+ ```
362
+
363
+ ## Links
364
+
365
+ - 📘 CLI Documentation: https://slice-js-docs.vercel.app/Documentation/CLI
366
+ - 🐙 GitHub: https://github.com/VKneider/slice-cli
367
+ - 📦 npm: https://www.npmjs.com/package/slicejs-cli
368
+
369
+ ## License
370
+
371
+ ISC
372
+
373
+ ## Author
374
+
375
+ vkneider