slicejs-cli 2.7.0 → 2.7.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 +71 -63
- package/assets/Slice.js-logo.png +0 -0
- package/client.js +10 -4
- package/commands/utils/updateManager.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,29 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
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
|
+
|
|
2
13
|
|
|
3
|
-
|
|
14
|
+
<p>CLI for building web applications with the Slice.js framework</p>
|
|
15
|
+
|
|
16
|
+
</div>
|
|
4
17
|
|
|
5
18
|
## Installation
|
|
6
19
|
|
|
7
|
-
|
|
20
|
+
- Local (recommended):
|
|
8
21
|
|
|
9
22
|
```bash
|
|
10
23
|
npm install slicejs-cli --save-dev
|
|
11
24
|
```
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
- Global:
|
|
14
27
|
|
|
15
28
|
```bash
|
|
16
29
|
npm install -g slicejs-cli
|
|
@@ -24,108 +37,104 @@ After installation, you can use the `slice` command directly:
|
|
|
24
37
|
slice [command] [options]
|
|
25
38
|
```
|
|
26
39
|
|
|
27
|
-
Or with npx (
|
|
40
|
+
Or with npx (without global install):
|
|
28
41
|
|
|
29
42
|
```bash
|
|
30
43
|
npx slicejs-cli [command]
|
|
31
44
|
```
|
|
32
45
|
|
|
33
|
-
## Commands
|
|
46
|
+
## Essential Commands
|
|
34
47
|
|
|
35
|
-
###
|
|
48
|
+
### Initialize a project
|
|
36
49
|
|
|
37
50
|
```bash
|
|
38
51
|
slice init
|
|
39
52
|
```
|
|
40
53
|
|
|
41
|
-
Initializes a
|
|
54
|
+
Initializes a Slice.js project with the full structure (`src/` and `api/`), installs initial Visual components, and configures npm scripts.
|
|
42
55
|
|
|
43
|
-
### Development
|
|
56
|
+
### Development server
|
|
44
57
|
|
|
45
58
|
```bash
|
|
46
|
-
#
|
|
59
|
+
# Default port (3000)
|
|
47
60
|
slice dev
|
|
48
61
|
|
|
49
|
-
#
|
|
62
|
+
# Custom port
|
|
50
63
|
slice dev -p 8080
|
|
51
64
|
|
|
52
|
-
#
|
|
65
|
+
# Alias
|
|
53
66
|
slice start
|
|
54
67
|
slice start -p 8080
|
|
55
68
|
```
|
|
56
69
|
|
|
57
|
-
### Component
|
|
70
|
+
### Component management (local)
|
|
58
71
|
|
|
59
72
|
```bash
|
|
60
|
-
# Create a
|
|
73
|
+
# Create a component (interactive)
|
|
61
74
|
slice component create
|
|
62
75
|
|
|
63
|
-
# List
|
|
76
|
+
# List local components
|
|
64
77
|
slice component list
|
|
65
78
|
|
|
66
79
|
# Delete a component (interactive)
|
|
67
80
|
slice component delete
|
|
68
81
|
```
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
Shortcuts:
|
|
71
84
|
```bash
|
|
72
|
-
slice
|
|
73
|
-
slice
|
|
74
|
-
slice
|
|
85
|
+
slice comp create
|
|
86
|
+
slice comp ls
|
|
87
|
+
slice comp remove
|
|
75
88
|
```
|
|
76
89
|
|
|
77
|
-
###
|
|
90
|
+
### Official component registry
|
|
78
91
|
|
|
79
92
|
```bash
|
|
80
|
-
# Install components
|
|
93
|
+
# Install Visual components
|
|
81
94
|
slice get Button Card Input
|
|
82
95
|
|
|
83
|
-
# Install
|
|
96
|
+
# Install a Service component
|
|
84
97
|
slice get FetchManager --service
|
|
85
98
|
|
|
86
|
-
# Force overwrite
|
|
99
|
+
# Force overwrite
|
|
87
100
|
slice get Button --force
|
|
88
101
|
|
|
89
102
|
# Browse available components
|
|
90
103
|
slice browse
|
|
91
104
|
|
|
92
|
-
# Update all local components
|
|
105
|
+
# Update all local components
|
|
93
106
|
slice sync
|
|
94
|
-
|
|
95
|
-
# Force update without confirmation
|
|
96
107
|
slice sync --force
|
|
97
108
|
```
|
|
98
109
|
|
|
99
|
-
|
|
110
|
+
Shortcuts:
|
|
100
111
|
```bash
|
|
101
|
-
slice
|
|
102
|
-
slice
|
|
103
|
-
slice
|
|
112
|
+
slice get Button
|
|
113
|
+
slice browse
|
|
114
|
+
slice sync
|
|
104
115
|
```
|
|
105
116
|
|
|
106
117
|
### Utilities
|
|
107
118
|
|
|
108
119
|
```bash
|
|
109
|
-
#
|
|
120
|
+
# Version info
|
|
110
121
|
slice version
|
|
111
122
|
slice -v
|
|
112
123
|
|
|
113
|
-
#
|
|
114
|
-
slice update # Check and prompt
|
|
115
|
-
slice update --yes # Update
|
|
116
|
-
slice update --cli #
|
|
117
|
-
slice update --framework #
|
|
124
|
+
# Updates (CLI and Framework)
|
|
125
|
+
slice update # Check and prompt to update
|
|
126
|
+
slice update --yes # Update everything automatically
|
|
127
|
+
slice update --cli # CLI only
|
|
128
|
+
slice update --framework # Framework only
|
|
118
129
|
|
|
119
|
-
#
|
|
130
|
+
# Help
|
|
120
131
|
slice --help
|
|
121
132
|
slice [command] --help
|
|
122
133
|
```
|
|
123
134
|
|
|
124
|
-
##
|
|
125
|
-
|
|
126
|
-
When you install `slicejs-cli`, the following scripts are automatically added to your project's `package.json`:
|
|
135
|
+
## npm Scripts
|
|
127
136
|
|
|
128
|
-
|
|
137
|
+
`slice init` automatically configures the recommended scripts in your `package.json`:
|
|
129
138
|
|
|
130
139
|
```json
|
|
131
140
|
{
|
|
@@ -149,18 +158,6 @@ npm run get
|
|
|
149
158
|
npm run browse
|
|
150
159
|
```
|
|
151
160
|
|
|
152
|
-
### Legacy (Still Supported)
|
|
153
|
-
|
|
154
|
-
```json
|
|
155
|
-
{
|
|
156
|
-
"scripts": {
|
|
157
|
-
"slice:dev": "slice dev",
|
|
158
|
-
"slice:start": "slice start",
|
|
159
|
-
"slice:get": "slice get"
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
```
|
|
163
|
-
|
|
164
161
|
## Quick Start
|
|
165
162
|
|
|
166
163
|
```bash
|
|
@@ -215,11 +212,11 @@ slice sync
|
|
|
215
212
|
|
|
216
213
|
## Development Mode
|
|
217
214
|
|
|
218
|
-
The development server (`slice dev`
|
|
215
|
+
The development server (`slice dev` / `slice start`) provides:
|
|
219
216
|
|
|
220
|
-
- ✅ Hot reload
|
|
221
|
-
- ✅ Serves
|
|
222
|
-
- ✅ No build step
|
|
217
|
+
- ✅ Hot reload
|
|
218
|
+
- ✅ Serves directly from `/src`
|
|
219
|
+
- ✅ No build step
|
|
223
220
|
- ✅ Port validation
|
|
224
221
|
- ✅ Clear error messages
|
|
225
222
|
|
|
@@ -230,35 +227,46 @@ The development server (`slice dev` or `slice start`) provides:
|
|
|
230
227
|
|
|
231
228
|
## Configuration
|
|
232
229
|
|
|
233
|
-
Project configuration is stored in `src/sliceConfig.json
|
|
230
|
+
Project configuration is stored in `src/sliceConfig.json` and is created automatically by `slice init`.
|
|
234
231
|
|
|
235
232
|
## Features
|
|
236
233
|
|
|
237
|
-
- 🚀
|
|
238
|
-
- 📦
|
|
234
|
+
- 🚀 Development server with hot reload
|
|
235
|
+
- 📦 Official component registry
|
|
239
236
|
- 🎨 Visual and Service component types
|
|
240
237
|
- ✨ Interactive component creation
|
|
241
238
|
- 🔄 Automatic component synchronization
|
|
242
239
|
- 🛠️ Built-in validation and error handling
|
|
243
|
-
|
|
240
|
+
|
|
241
|
+
### Smart Updates
|
|
242
|
+
|
|
243
|
+
- Detects whether the CLI in use is global or local
|
|
244
|
+
- Shows an update plan (GLOBAL/PROJECT) before execution
|
|
245
|
+
- Offers to include global CLI update interactively
|
|
246
|
+
- Applies `uninstall` + `install @latest` to ensure latest versions
|
|
247
|
+
|
|
248
|
+
### Cross-platform Paths
|
|
249
|
+
|
|
250
|
+
- Centralized path helper avoids `../../..`
|
|
251
|
+
- Windows/Linux/Mac compatibility using `import.meta.url` and `fileURLToPath`
|
|
244
252
|
|
|
245
253
|
## Troubleshooting
|
|
246
254
|
|
|
247
|
-
### Port
|
|
255
|
+
### Port already in use
|
|
248
256
|
|
|
249
257
|
```bash
|
|
250
258
|
# Use a different port
|
|
251
259
|
slice dev -p 8080
|
|
252
260
|
```
|
|
253
261
|
|
|
254
|
-
### Project
|
|
262
|
+
### Project not initialized
|
|
255
263
|
|
|
256
264
|
```bash
|
|
257
265
|
# Make sure to run init first
|
|
258
266
|
slice init
|
|
259
267
|
```
|
|
260
268
|
|
|
261
|
-
### Command
|
|
269
|
+
### Command not found
|
|
262
270
|
|
|
263
271
|
```bash
|
|
264
272
|
# Use npx if not installed globally
|
|
Binary file
|
package/client.js
CHANGED
|
@@ -24,8 +24,7 @@ const loadConfig = () => {
|
|
|
24
24
|
const configPath = getConfigPath(import.meta.url);
|
|
25
25
|
const rawData = fs.readFileSync(configPath, "utf-8");
|
|
26
26
|
return JSON.parse(rawData);
|
|
27
|
-
} catch
|
|
28
|
-
Print.error(`Loading configuration: ${error.message}`);
|
|
27
|
+
} catch {
|
|
29
28
|
return null;
|
|
30
29
|
}
|
|
31
30
|
};
|
|
@@ -58,7 +57,14 @@ async function runWithVersionCheck(commandFunction, ...args) {
|
|
|
58
57
|
|
|
59
58
|
const sliceClient = program;
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
try {
|
|
61
|
+
const pkgPath = path.join(__dirname, "./package.json");
|
|
62
|
+
const pkgRaw = fs.readFileSync(pkgPath, "utf-8");
|
|
63
|
+
const pkg = JSON.parse(pkgRaw);
|
|
64
|
+
sliceClient.version(pkg.version).description("CLI for managing Slice.js framework components");
|
|
65
|
+
} catch {
|
|
66
|
+
sliceClient.version("0.0.0").description("CLI for managing Slice.js framework components");
|
|
67
|
+
}
|
|
62
68
|
|
|
63
69
|
// INIT COMMAND
|
|
64
70
|
sliceClient
|
|
@@ -416,11 +422,11 @@ More info: https://slice-js-docs.vercel.app/
|
|
|
416
422
|
|
|
417
423
|
// Default action with better messaging
|
|
418
424
|
if (!process.argv.slice(2).length) {
|
|
419
|
-
program.outputHelp();
|
|
420
425
|
Print.newLine();
|
|
421
426
|
Print.info("Start with: slice init");
|
|
422
427
|
Print.commandExample("Development", "slice dev");
|
|
423
428
|
Print.commandExample("View available components", "slice browse");
|
|
429
|
+
Print.info("Use 'slice --help' for full help");
|
|
424
430
|
}
|
|
425
431
|
|
|
426
432
|
// Error handling for unknown commands
|
|
@@ -184,13 +184,15 @@ class UpdateManager {
|
|
|
184
184
|
*/
|
|
185
185
|
async updatePackage(packageName) {
|
|
186
186
|
try {
|
|
187
|
-
let
|
|
187
|
+
let installCmd = `npm install ${packageName}@latest`;
|
|
188
|
+
let uninstallCmd = `npm uninstall ${packageName}`;
|
|
188
189
|
let options = {};
|
|
189
190
|
|
|
190
191
|
if (packageName === 'slicejs-cli') {
|
|
191
192
|
const info = await this.detectCliInstall();
|
|
192
193
|
if (info.type === 'global') {
|
|
193
|
-
|
|
194
|
+
installCmd = `npm install -g slicejs-cli@latest`;
|
|
195
|
+
uninstallCmd = `npm uninstall -g slicejs-cli`;
|
|
194
196
|
} else {
|
|
195
197
|
options.cwd = info.projectRoot || getProjectRoot(import.meta.url);
|
|
196
198
|
}
|
|
@@ -198,7 +200,12 @@ class UpdateManager {
|
|
|
198
200
|
options.cwd = getProjectRoot(import.meta.url);
|
|
199
201
|
}
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
// Try uninstall first (ignore failure)
|
|
204
|
+
try {
|
|
205
|
+
await execAsync(uninstallCmd, options);
|
|
206
|
+
} catch {}
|
|
207
|
+
|
|
208
|
+
const { stdout, stderr } = await execAsync(installCmd, options);
|
|
202
209
|
|
|
203
210
|
return {
|
|
204
211
|
success: true,
|