slicejs-cli 2.3.3 → 2.5.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/README.md +280 -0
- package/client.js +28 -12
- package/commands/Print.js +81 -30
- package/commands/doctor/doctor.js +333 -0
- package/commands/init/init.js +38 -34
- package/commands/listComponents/listComponents.js +79 -17
- package/commands/startServer/startServer.js +130 -23
- package/commands/startServer/watchServer.js +67 -0
- package/package.json +13 -2
- package/post.js +81 -64
package/README.md
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Slice.js CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for developing web applications with the Slice.js framework.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Local Installation (Recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install slicejs-cli --save-dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Global Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g slicejs-cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
After installation, you can use the `slice` command directly:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
slice [command] [options]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or with npx (no installation required):
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx slicejs-cli [command]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Commands
|
|
34
|
+
|
|
35
|
+
### Project Initialization
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
slice init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Initializes a new Slice.js project with the complete framework structure.
|
|
42
|
+
|
|
43
|
+
### Development Server
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Start development server on default port (3000)
|
|
47
|
+
slice dev
|
|
48
|
+
|
|
49
|
+
# Start on custom port
|
|
50
|
+
slice dev -p 8080
|
|
51
|
+
|
|
52
|
+
# Alternative command (same as dev)
|
|
53
|
+
slice start
|
|
54
|
+
slice start -p 8080
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Component Management (Local)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Create a new component (interactive)
|
|
61
|
+
slice component create
|
|
62
|
+
|
|
63
|
+
# List all local components
|
|
64
|
+
slice component list
|
|
65
|
+
|
|
66
|
+
# Delete a component (interactive)
|
|
67
|
+
slice component delete
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Shortcuts:**
|
|
71
|
+
```bash
|
|
72
|
+
slice component create → slice comp create
|
|
73
|
+
slice component list → slice comp ls
|
|
74
|
+
slice component delete → slice comp remove
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Component Registry (Official Repository)
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Install components from official repository
|
|
81
|
+
slice get Button Card Input
|
|
82
|
+
|
|
83
|
+
# Install service component
|
|
84
|
+
slice get FetchManager --service
|
|
85
|
+
|
|
86
|
+
# Force overwrite existing components
|
|
87
|
+
slice get Button --force
|
|
88
|
+
|
|
89
|
+
# Browse available components
|
|
90
|
+
slice browse
|
|
91
|
+
|
|
92
|
+
# Update all local components to latest versions
|
|
93
|
+
slice sync
|
|
94
|
+
|
|
95
|
+
# Force update without confirmation
|
|
96
|
+
slice sync --force
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Shortcuts:**
|
|
100
|
+
```bash
|
|
101
|
+
slice registry get Button → slice get Button
|
|
102
|
+
slice registry list → slice browse
|
|
103
|
+
slice registry sync → slice sync
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Utilities
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Show version information
|
|
110
|
+
slice version
|
|
111
|
+
slice -v
|
|
112
|
+
|
|
113
|
+
# Check for available updates
|
|
114
|
+
slice update
|
|
115
|
+
|
|
116
|
+
# Show help
|
|
117
|
+
slice --help
|
|
118
|
+
slice [command] --help
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## NPM Scripts
|
|
122
|
+
|
|
123
|
+
When you install `slicejs-cli`, the following scripts are automatically added to your project's `package.json`:
|
|
124
|
+
|
|
125
|
+
### Recommended (New)
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"scripts": {
|
|
130
|
+
"dev": "slice dev",
|
|
131
|
+
"start": "slice start",
|
|
132
|
+
"get": "slice get",
|
|
133
|
+
"browse": "slice browse",
|
|
134
|
+
"sync": "slice sync",
|
|
135
|
+
"component:create": "slice component create",
|
|
136
|
+
"component:list": "slice component list",
|
|
137
|
+
"component:delete": "slice component delete"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Usage:
|
|
143
|
+
```bash
|
|
144
|
+
npm run dev
|
|
145
|
+
npm run get
|
|
146
|
+
npm run browse
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Legacy (Still Supported)
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"scripts": {
|
|
154
|
+
"slice:dev": "slice dev",
|
|
155
|
+
"slice:start": "slice start",
|
|
156
|
+
"slice:get": "slice get"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Quick Start
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# 1. Create a new project directory
|
|
165
|
+
mkdir my-slice-project
|
|
166
|
+
cd my-slice-project
|
|
167
|
+
|
|
168
|
+
# 2. Initialize npm and install Slice CLI
|
|
169
|
+
npm init -y
|
|
170
|
+
npm install slicejs-cli --save-dev
|
|
171
|
+
|
|
172
|
+
# 3. Initialize Slice.js project
|
|
173
|
+
slice init
|
|
174
|
+
|
|
175
|
+
# 4. Start development server
|
|
176
|
+
slice dev
|
|
177
|
+
|
|
178
|
+
# 5. Open browser at http://localhost:3000
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Common Workflows
|
|
182
|
+
|
|
183
|
+
### Starting a New Project
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
slice init
|
|
187
|
+
slice dev
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Adding Components
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Browse available components
|
|
194
|
+
slice browse
|
|
195
|
+
|
|
196
|
+
# Install specific components
|
|
197
|
+
slice get Button Card Input
|
|
198
|
+
|
|
199
|
+
# Create custom component
|
|
200
|
+
slice component create
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Keeping Components Updated
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Check what needs updating
|
|
207
|
+
slice browse
|
|
208
|
+
|
|
209
|
+
# Update all components
|
|
210
|
+
slice sync
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Development Mode
|
|
214
|
+
|
|
215
|
+
The development server (`slice dev` or `slice start`) provides:
|
|
216
|
+
|
|
217
|
+
- ✅ Hot reload for instant changes
|
|
218
|
+
- ✅ Serves files directly from `/src`
|
|
219
|
+
- ✅ No build step required
|
|
220
|
+
- ✅ Port validation
|
|
221
|
+
- ✅ Clear error messages
|
|
222
|
+
|
|
223
|
+
## Requirements
|
|
224
|
+
|
|
225
|
+
- Node.js >= 20.0.0
|
|
226
|
+
- npm or yarn
|
|
227
|
+
|
|
228
|
+
## Configuration
|
|
229
|
+
|
|
230
|
+
Project configuration is stored in `src/sliceConfig.json`, created automatically during `slice init`.
|
|
231
|
+
|
|
232
|
+
## Features
|
|
233
|
+
|
|
234
|
+
- 🚀 Fast development server with hot reload
|
|
235
|
+
- 📦 Component registry for sharing components
|
|
236
|
+
- 🎨 Visual and Service component types
|
|
237
|
+
- ✨ Interactive component creation
|
|
238
|
+
- 🔄 Automatic component synchronization
|
|
239
|
+
- 🛠️ Built-in validation and error handling
|
|
240
|
+
- 📝 Clear, actionable error messages
|
|
241
|
+
|
|
242
|
+
## Troubleshooting
|
|
243
|
+
|
|
244
|
+
### Port Already in Use
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Use a different port
|
|
248
|
+
slice dev -p 8080
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Project Not Initialized
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Make sure to run init first
|
|
255
|
+
slice init
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Command Not Found
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Use npx if not installed globally
|
|
262
|
+
npx slicejs-cli dev
|
|
263
|
+
|
|
264
|
+
# Or install globally
|
|
265
|
+
npm install -g slicejs-cli
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Links
|
|
269
|
+
|
|
270
|
+
- 📘 Documentation: https://slice-js-docs.vercel.app/
|
|
271
|
+
- 🐙 GitHub: https://github.com/VKneider/slice-cli
|
|
272
|
+
- 📦 npm: https://www.npmjs.com/package/slicejs-cli
|
|
273
|
+
|
|
274
|
+
## License
|
|
275
|
+
|
|
276
|
+
ISC
|
|
277
|
+
|
|
278
|
+
## Author
|
|
279
|
+
|
|
280
|
+
vkneider
|
package/client.js
CHANGED
|
@@ -7,6 +7,7 @@ import listComponents from "./commands/listComponents/listComponents.js";
|
|
|
7
7
|
import deleteComponent from "./commands/deleteComponent/deleteComponent.js";
|
|
8
8
|
import getComponent, { listComponents as listRemoteComponents, syncComponents } from "./commands/getComponent/getComponent.js";
|
|
9
9
|
import startServer from "./commands/startServer/startServer.js";
|
|
10
|
+
import runDiagnostics from "./commands/doctor/doctor.js";
|
|
10
11
|
import versionChecker from "./commands/utils/versionChecker.js";
|
|
11
12
|
import fs from "fs";
|
|
12
13
|
import path from "path";
|
|
@@ -37,12 +38,12 @@ async function runWithVersionCheck(commandFunction, ...args) {
|
|
|
37
38
|
try {
|
|
38
39
|
// Run the command first
|
|
39
40
|
const result = await commandFunction(...args);
|
|
40
|
-
|
|
41
|
+
|
|
41
42
|
// Then check for updates (non-blocking)
|
|
42
43
|
setTimeout(() => {
|
|
43
44
|
versionChecker.checkForUpdates(false);
|
|
44
45
|
}, 100);
|
|
45
|
-
|
|
46
|
+
|
|
46
47
|
return result;
|
|
47
48
|
} catch (error) {
|
|
48
49
|
Print.error(`Command execution: ${error.message}`);
|
|
@@ -52,7 +53,7 @@ async function runWithVersionCheck(commandFunction, ...args) {
|
|
|
52
53
|
|
|
53
54
|
const sliceClient = program;
|
|
54
55
|
|
|
55
|
-
sliceClient.version("2.
|
|
56
|
+
sliceClient.version("2.5.0").description("CLI for managing Slice.js framework components");
|
|
56
57
|
|
|
57
58
|
// INIT COMMAND
|
|
58
59
|
sliceClient
|
|
@@ -79,11 +80,13 @@ sliceClient
|
|
|
79
80
|
.command("dev")
|
|
80
81
|
.description("Start development server")
|
|
81
82
|
.option("-p, --port <port>", "Port for development server", 3000)
|
|
83
|
+
.option("-w, --watch", "Enable watch mode for file changes")
|
|
82
84
|
.action(async (options) => {
|
|
83
85
|
await runWithVersionCheck(async () => {
|
|
84
86
|
await startServer({
|
|
85
87
|
mode: 'development',
|
|
86
|
-
port: parseInt(options.port)
|
|
88
|
+
port: parseInt(options.port),
|
|
89
|
+
watch: options.watch
|
|
87
90
|
});
|
|
88
91
|
});
|
|
89
92
|
});
|
|
@@ -93,12 +96,13 @@ sliceClient
|
|
|
93
96
|
.command("start")
|
|
94
97
|
.description("Start development server (alias for dev)")
|
|
95
98
|
.option("-p, --port <port>", "Port for server", 3000)
|
|
99
|
+
.option("-w, --watch", "Enable watch mode for file changes")
|
|
96
100
|
.action(async (options) => {
|
|
97
101
|
await runWithVersionCheck(async () => {
|
|
98
|
-
Print.info("Starting development server...");
|
|
99
102
|
await startServer({
|
|
100
103
|
mode: 'development',
|
|
101
|
-
port: parseInt(options.port)
|
|
104
|
+
port: parseInt(options.port),
|
|
105
|
+
watch: options.watch
|
|
102
106
|
});
|
|
103
107
|
});
|
|
104
108
|
});
|
|
@@ -141,7 +145,7 @@ componentCommand
|
|
|
141
145
|
choices: categories,
|
|
142
146
|
}
|
|
143
147
|
]);
|
|
144
|
-
|
|
148
|
+
|
|
145
149
|
const result = createComponent(answers.componentName, answers.category);
|
|
146
150
|
if (result) {
|
|
147
151
|
Print.success(`Component '${answers.componentName}' created successfully in category '${answers.category}'`);
|
|
@@ -197,7 +201,7 @@ componentCommand
|
|
|
197
201
|
|
|
198
202
|
const categoryPath = config.paths.components[categoryAnswer.category].path;
|
|
199
203
|
const fullPath = path.join(__dirname, "../../src", categoryPath);
|
|
200
|
-
|
|
204
|
+
|
|
201
205
|
if (!fs.existsSync(fullPath)) {
|
|
202
206
|
Print.error(`Category path does not exist: ${categoryPath}`);
|
|
203
207
|
return;
|
|
@@ -303,7 +307,7 @@ sliceClient
|
|
|
303
307
|
Print.commandExample("Browse components", "slice browse");
|
|
304
308
|
return;
|
|
305
309
|
}
|
|
306
|
-
|
|
310
|
+
|
|
307
311
|
await getComponent(components, {
|
|
308
312
|
force: options.force,
|
|
309
313
|
service: options.service
|
|
@@ -339,10 +343,10 @@ sliceClient
|
|
|
339
343
|
.description("Check for and show available updates for CLI and framework")
|
|
340
344
|
.action(async () => {
|
|
341
345
|
Print.info("Checking for updates...");
|
|
342
|
-
|
|
346
|
+
|
|
343
347
|
try {
|
|
344
348
|
const updateInfo = await versionChecker.checkForUpdates(false);
|
|
345
|
-
|
|
349
|
+
|
|
346
350
|
if (updateInfo) {
|
|
347
351
|
if (updateInfo.cli.status === 'current' && updateInfo.framework.status === 'current') {
|
|
348
352
|
Print.success("All components are up to date!");
|
|
@@ -357,6 +361,17 @@ sliceClient
|
|
|
357
361
|
}
|
|
358
362
|
});
|
|
359
363
|
|
|
364
|
+
// DOCTOR COMMAND - Diagnose project issues
|
|
365
|
+
sliceClient
|
|
366
|
+
.command("doctor")
|
|
367
|
+
.alias("diagnose")
|
|
368
|
+
.description("Run diagnostics to check project health")
|
|
369
|
+
.action(async () => {
|
|
370
|
+
await runWithVersionCheck(async () => {
|
|
371
|
+
await runDiagnostics();
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
|
|
360
375
|
// Enhanced help
|
|
361
376
|
sliceClient
|
|
362
377
|
.option("--no-version-check", "Skip version check for this command")
|
|
@@ -376,13 +391,14 @@ Common Usage Examples:
|
|
|
376
391
|
slice browse - Browse all available components
|
|
377
392
|
slice sync - Update local components to latest versions
|
|
378
393
|
slice component create - Create new local component
|
|
394
|
+
slice doctor - Run project diagnostics
|
|
379
395
|
|
|
380
396
|
Command Categories:
|
|
381
397
|
• init, dev, start - Project lifecycle (development only)
|
|
382
398
|
• get, browse, sync - Quick registry shortcuts
|
|
383
399
|
• component <cmd> - Local component management
|
|
384
400
|
• registry <cmd> - Official repository operations
|
|
385
|
-
• version, update
|
|
401
|
+
• version, update, doctor - Maintenance commands
|
|
386
402
|
|
|
387
403
|
Development Workflow:
|
|
388
404
|
• slice init - Initialize project
|
package/commands/Print.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
1
3
|
export default class Print {
|
|
2
|
-
constructor() {}
|
|
4
|
+
constructor() { }
|
|
3
5
|
|
|
4
6
|
static error(message) {
|
|
5
|
-
console.error(
|
|
7
|
+
console.error(chalk.red(`❌ Error: ${message}`));
|
|
6
8
|
}
|
|
7
|
-
|
|
9
|
+
|
|
8
10
|
static success(message) {
|
|
9
|
-
console.log(
|
|
11
|
+
console.log(chalk.green(`✅ Success: ${message}`));
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
static warning(message) {
|
|
13
|
-
console.log(
|
|
15
|
+
console.log(chalk.yellow(`⚠️ Warning: ${message}`));
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
static info(message) {
|
|
17
|
-
console.log(
|
|
19
|
+
console.log(chalk.cyan(`ℹ️ Info: ${message}`));
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
static title(message) {
|
|
21
|
-
console.log(
|
|
23
|
+
console.log(chalk.magenta.bold(`🎯 ${message}`));
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
static subtitle(message) {
|
|
25
|
-
console.log(
|
|
27
|
+
console.log(chalk.blue(`📋 ${message}`));
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
static step(stepNumber, message) {
|
|
29
|
-
console.log(
|
|
31
|
+
console.log(chalk.cyan(`${stepNumber}. ${message}`));
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
static highlight(message) {
|
|
33
|
-
console.log(
|
|
35
|
+
console.log(chalk.bgYellow.black(` ${message} `));
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
static newLine() {
|
|
@@ -38,50 +40,50 @@ export default class Print {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
static separator() {
|
|
41
|
-
console.log('
|
|
43
|
+
console.log(chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
// Métodos para el contexto específico del CLI
|
|
45
47
|
static componentSuccess(componentName, action = 'processed') {
|
|
46
|
-
console.log(
|
|
48
|
+
console.log(chalk.green(`✅ ${componentName} ${action} successfully!`));
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
static componentError(componentName, action = 'processing', error) {
|
|
50
|
-
console.error(
|
|
52
|
+
console.error(chalk.red(`❌ Error ${action} ${componentName}: ${error}`));
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
static downloadProgress(fileName) {
|
|
54
|
-
console.log(
|
|
56
|
+
console.log(chalk.cyan(` 📥 Downloading ${fileName}...`));
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
static downloadSuccess(fileName) {
|
|
58
|
-
console.log(
|
|
60
|
+
console.log(chalk.green(` ✅ ${fileName}`));
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
static downloadError(fileName, error) {
|
|
62
|
-
console.error(
|
|
64
|
+
console.error(chalk.red(` ❌ Error downloading ${fileName}: ${error}`));
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
static registryUpdate(message) {
|
|
66
|
-
console.log(
|
|
68
|
+
console.log(chalk.magenta(`📝 Registry: ${message}`));
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
static versionInfo(component, currentVersion, latestVersion = null) {
|
|
70
72
|
if (latestVersion && currentVersion !== latestVersion) {
|
|
71
|
-
console.log(
|
|
73
|
+
console.log(chalk.yellow(`🔄 ${component}: v${currentVersion} → v${latestVersion}`));
|
|
72
74
|
} else {
|
|
73
|
-
console.log(
|
|
75
|
+
console.log(chalk.green(`✅ ${component}: v${currentVersion}`));
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
static commandExample(description, command) {
|
|
78
|
-
console.log(
|
|
79
|
-
console.log(
|
|
80
|
+
console.log(chalk.gray(`💡 ${description}:`));
|
|
81
|
+
console.log(chalk.white(` ${command}`));
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
static summary(successful, failed, total) {
|
|
83
85
|
Print.separator();
|
|
84
|
-
console.log('
|
|
86
|
+
console.log(chalk.bold('📊 Summary:'));
|
|
85
87
|
if (successful > 0) {
|
|
86
88
|
Print.success(`Successful: ${successful}/${total}`);
|
|
87
89
|
}
|
|
@@ -95,23 +97,72 @@ export default class Print {
|
|
|
95
97
|
static minificationResult(filename, originalSize, minifiedSize, savingsPercent) {
|
|
96
98
|
const originalKB = (originalSize / 1024).toFixed(1);
|
|
97
99
|
const minifiedKB = (minifiedSize / 1024).toFixed(1);
|
|
98
|
-
|
|
99
|
-
console.log(
|
|
100
|
-
console.log(
|
|
100
|
+
|
|
101
|
+
console.log(chalk.green(` ✅ ${filename}`));
|
|
102
|
+
console.log(chalk.gray(` ${originalKB}KB → ${minifiedKB}KB (${savingsPercent}% saved)`));
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
// Método para mostrar progreso de build
|
|
104
106
|
static buildProgress(message) {
|
|
105
|
-
console.log(
|
|
107
|
+
console.log(chalk.cyan(`🔄 ${message}`));
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
// Método para mostrar estadísticas de servidor
|
|
109
111
|
static serverStats(mode, port, directory) {
|
|
110
112
|
Print.newLine();
|
|
111
|
-
console.log(
|
|
112
|
-
console.log(
|
|
113
|
-
console.log(
|
|
114
|
-
console.log(
|
|
113
|
+
console.log(chalk.magenta(`🌐 Server Configuration:`));
|
|
114
|
+
console.log(chalk.gray(` Mode: ${mode}`));
|
|
115
|
+
console.log(chalk.gray(` Port: ${port}`));
|
|
116
|
+
console.log(chalk.gray(` Serving: /${directory}`));
|
|
117
|
+
Print.newLine();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Método para mostrar que el servidor está listo con URL destacada
|
|
121
|
+
static serverReady(port) {
|
|
122
|
+
Print.newLine();
|
|
123
|
+
console.log(chalk.bgGreen.black.bold(' ✓ SERVER READY '));
|
|
124
|
+
Print.newLine();
|
|
125
|
+
console.log(chalk.cyan.bold(` → Local: http://localhost:${port}`));
|
|
126
|
+
console.log(chalk.gray(` → Network: http://127.0.0.1:${port}`));
|
|
115
127
|
Print.newLine();
|
|
128
|
+
console.log(chalk.yellow(` Press Ctrl+C to stop the server`));
|
|
129
|
+
Print.newLine();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Método para mostrar el estado del servidor durante inicio
|
|
133
|
+
static serverStatus(status, message = '') {
|
|
134
|
+
const icons = {
|
|
135
|
+
checking: '🔍',
|
|
136
|
+
starting: '🚀',
|
|
137
|
+
ready: '✅',
|
|
138
|
+
error: '❌'
|
|
139
|
+
};
|
|
140
|
+
const colors = {
|
|
141
|
+
checking: chalk.cyan,
|
|
142
|
+
starting: chalk.magenta,
|
|
143
|
+
ready: chalk.green,
|
|
144
|
+
error: chalk.red
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const icon = icons[status] || 'ℹ️';
|
|
148
|
+
const color = colors[status] || chalk.white;
|
|
149
|
+
const displayMessage = message || status;
|
|
150
|
+
|
|
151
|
+
console.log(color(`${icon} ${displayMessage}`));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Método para mostrar que se está verificando el puerto
|
|
155
|
+
static checkingPort(port) {
|
|
156
|
+
console.log(chalk.cyan(`🔍 Checking port ${port}...`));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Nuevo: Método para debug
|
|
160
|
+
static debug(message) {
|
|
161
|
+
console.log(chalk.gray(`🐛 DEBUG: ${message}`));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Nuevo: Método para logs verbosos
|
|
165
|
+
static verbose(message) {
|
|
166
|
+
console.log(chalk.gray(`📝 ${message}`));
|
|
116
167
|
}
|
|
117
168
|
}
|