slicejs-cli 3.2.0 → 3.4.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/ISSUE_TEMPLATE/bug_report.md +29 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +25 -0
- package/.github/pull_request_template.md +22 -0
- package/CODE_OF_CONDUCT.md +126 -0
- package/ECOSYSTEM.md +9 -0
- package/LICENSE +21 -0
- package/README.md +171 -375
- package/client.js +664 -563
- package/commands/Print.js +167 -167
- package/commands/Validations.js +103 -103
- package/commands/build/build.js +40 -40
- package/commands/buildProduction/buildProduction.js +579 -579
- package/commands/bundle/bundle.js +235 -235
- package/commands/createComponent/VisualComponentTemplate.js +55 -55
- package/commands/createComponent/createComponent.js +126 -126
- package/commands/deleteComponent/deleteComponent.js +77 -77
- package/commands/doctor/doctor.js +369 -369
- package/commands/getComponent/getComponent.js +747 -747
- package/commands/init/init.js +265 -261
- package/commands/listComponents/listComponents.js +175 -175
- package/commands/startServer/startServer.js +264 -264
- package/commands/startServer/watchServer.js +79 -79
- package/commands/types/types.js +16 -9
- package/commands/utils/LocalCliDelegation.js +53 -53
- package/commands/utils/PathHelper.js +68 -68
- package/commands/utils/VersionChecker.js +167 -167
- package/commands/utils/bundling/BundleGenerator.js +2292 -2292
- package/commands/utils/bundling/DependencyAnalyzer.js +933 -933
- package/commands/utils/updateManager.js +453 -453
- package/package.json +46 -46
- package/post.js +66 -25
- package/tests/bundle-generator.test.js +708 -708
- package/tests/bundle-v2-register-output.test.js +470 -470
- package/tests/client-launcher-contract.test.js +211 -211
- package/tests/client-update-flow-contract.test.js +272 -272
- package/tests/dependency-analyzer.test.js +24 -24
- package/tests/local-cli-delegation.test.js +79 -79
- package/tests/postinstall-command.test.js +72 -0
- package/tests/update-manager-notifications.test.js +88 -88
- package/refactor.md +0 -271
package/README.md
CHANGED
|
@@ -1,375 +1,171 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
<
|
|
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
|
-
</
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
##
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
##
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
slice
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
#
|
|
143
|
-
slice
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
slice
|
|
170
|
-
|
|
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
|
+
<img src="./assets/Slice.js-logo.png" alt="Slice.js logo" width="150" />
|
|
3
|
+
<h1>Slice.js CLI</h1>
|
|
4
|
+
<p>Command-line client for building web applications with the Slice.js framework</p>
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://slice-js-docs.vercel.app/Documentation/CLI"><strong>Explore the docs »</strong></a>
|
|
7
|
+
<br />
|
|
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
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## About this repository
|
|
15
|
+
|
|
16
|
+
This repository contains the Slice.js CLI (`slicejs-cli`), the command-line tool for developing applications with the Slice.js framework. It includes a development server, build system, component management, and more.
|
|
17
|
+
|
|
18
|
+
## Prerequisites
|
|
19
|
+
|
|
20
|
+
- Node.js >= 20
|
|
21
|
+
- npm or pnpm
|
|
22
|
+
|
|
23
|
+
## Local development
|
|
24
|
+
|
|
25
|
+
1. **Clone the repository**
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/VKneider/slicejs-cli.git
|
|
28
|
+
cd slicejs-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
2. **Install dependencies**
|
|
32
|
+
```bash
|
|
33
|
+
npm install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. **Test changes locally**
|
|
37
|
+
```bash
|
|
38
|
+
node client.js --help
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
To bypass delegation to a global installation:
|
|
42
|
+
```bash
|
|
43
|
+
SLICE_NO_LOCAL_DELEGATION=1 node client.js --help
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
4. **Run tests**
|
|
47
|
+
```bash
|
|
48
|
+
npm test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Installation (for users)
|
|
52
|
+
|
|
53
|
+
### Local (Recommended)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install slicejs-cli --save-dev
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Global (Not recommended)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install -g slicejs-cli
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Main commands
|
|
66
|
+
|
|
67
|
+
| Command | Description |
|
|
68
|
+
|---------|-------------|
|
|
69
|
+
| `slice init` | Initialize a Slice.js project |
|
|
70
|
+
| `slice dev` | Development server with hot reload |
|
|
71
|
+
| `slice build` | Build for production |
|
|
72
|
+
| `slice start` | Serve production build |
|
|
73
|
+
| `slice get <component>` | Install components from the official registry |
|
|
74
|
+
| `slice browse` | Browse available components |
|
|
75
|
+
| `slice component create` | Create a local component |
|
|
76
|
+
| `slice doctor` | Run project diagnostics |
|
|
77
|
+
| `slice postinstall` | Configure npm scripts (alternative to postinstall) |
|
|
78
|
+
|
|
79
|
+
## Postinstall Scripts
|
|
80
|
+
|
|
81
|
+
When you install `slicejs-cli`, the `postinstall` script automatically configures `slice:*` npm scripts in your `package.json`:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"scripts": {
|
|
86
|
+
"slice:dev": "slice dev",
|
|
87
|
+
"slice:start": "slice start",
|
|
88
|
+
"slice:create": "slice component create",
|
|
89
|
+
"slice:list": "slice component list",
|
|
90
|
+
"slice:delete": "slice component delete",
|
|
91
|
+
"slice:init": "slice init",
|
|
92
|
+
"slice:get": "slice get",
|
|
93
|
+
"slice:browse": "slice browse",
|
|
94
|
+
"slice:sync": "slice sync",
|
|
95
|
+
"slice:version": "slice version",
|
|
96
|
+
"slice:update": "slice update"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
If you installed with `--ignore-scripts`, run manually:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx slicejs-cli postinstall
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Quick start
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 1. Create project
|
|
111
|
+
mkdir my-project && cd my-project
|
|
112
|
+
npm init -y
|
|
113
|
+
|
|
114
|
+
# 2. Install CLI
|
|
115
|
+
npm install slicejs-cli --save-dev
|
|
116
|
+
|
|
117
|
+
# 3. Initialize
|
|
118
|
+
npx slicejs-cli init
|
|
119
|
+
|
|
120
|
+
# 4. Development
|
|
121
|
+
npx slicejs-cli dev
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Tests
|
|
125
|
+
|
|
126
|
+
The CLI uses Node.js native test runner:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# All tests
|
|
130
|
+
node --test
|
|
131
|
+
|
|
132
|
+
# Specific tests
|
|
133
|
+
node --test tests/postinstall-command.test.js
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Project structure
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
slicejs-cli/
|
|
140
|
+
├── client.js # CLI entry point
|
|
141
|
+
├── commands/ # Command implementations
|
|
142
|
+
│ ├── init/ # slice init
|
|
143
|
+
│ ├── build/ # slice build
|
|
144
|
+
│ ├── startServer/ # slice dev / slice start
|
|
145
|
+
│ ├── createComponent/ # slice component create
|
|
146
|
+
│ └── utils/ # PathHelper, VersionChecker, etc.
|
|
147
|
+
├── tests/ # Tests
|
|
148
|
+
└── post.js # Postinstall hook
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Local delegation
|
|
152
|
+
|
|
153
|
+
When the `slice` command is globally available, it automatically delegates to the project-local CLI (`node_modules/slicejs-cli`). To disable:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
SLICE_NO_LOCAL_DELEGATION=1 slice version
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Contributing
|
|
160
|
+
|
|
161
|
+
We welcome contributions. Please review the guidelines in [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before submitting changes.
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
Distributed under the ISC License. See `LICENSE` for more information.
|
|
166
|
+
|
|
167
|
+
## Links
|
|
168
|
+
|
|
169
|
+
- 📘 Documentation: https://slice-js-docs.vercel.app/Documentation/CLI
|
|
170
|
+
- 🐙 GitHub: https://github.com/VKneider/slicejs-cli
|
|
171
|
+
- 📦 npm: https://www.npmjs.com/package/slicejs-cli
|