slicejs-cli 3.3.0 β 3.4.1
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/AGENTS.md +247 -0
- package/LICENSE +21 -21
- package/client.js +663 -626
- package/commands/Print.js +163 -167
- package/commands/Validations.js +92 -103
- package/commands/build/build.js +40 -40
- package/commands/buildProduction/buildProduction.js +576 -579
- package/commands/bundle/bundle.js +234 -235
- package/commands/createComponent/VisualComponentTemplate.js +55 -55
- package/commands/createComponent/createComponent.js +124 -126
- package/commands/deleteComponent/deleteComponent.js +77 -77
- package/commands/doctor/doctor.js +366 -369
- package/commands/getComponent/getComponent.js +684 -747
- package/commands/init/init.js +269 -261
- package/commands/listComponents/listComponents.js +172 -175
- package/commands/startServer/startServer.js +261 -264
- package/commands/startServer/watchServer.js +79 -79
- package/commands/types/types.js +69 -27
- package/commands/utils/LocalCliDelegation.js +53 -53
- package/commands/utils/PathHelper.js +75 -68
- package/commands/utils/VersionChecker.js +167 -167
- package/commands/utils/bundling/BundleGenerator.js +2292 -2292
- package/commands/utils/bundling/DependencyAnalyzer.js +925 -933
- package/commands/utils/loadConfig.js +31 -0
- package/commands/utils/updateManager.js +452 -453
- package/docs/superpowers/specs/2026-05-10-pwa-generate-design.md +105 -105
- package/package.json +58 -46
- package/post.js +66 -65
- package/tests/bundle-generator.test.js +691 -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/component-registry-parse.test.js +34 -0
- package/tests/dependency-analyzer.test.js +24 -24
- package/tests/fixtures/components.js +8 -0
- package/tests/fixtures/sliceConfig.json +74 -0
- package/tests/getcomponent.test.js +407 -0
- package/tests/helpers/setup.js +97 -0
- package/tests/init-command-contract.test.js +46 -0
- package/tests/local-cli-delegation.test.js +81 -79
- package/tests/path-helper.test.js +206 -0
- package/tests/types-breakage.test.js +491 -0
- package/tests/types-generator-errors.test.js +361 -0
- package/tests/types-generator.test.js +172 -184
- package/tests/update-manager-notifications.test.js +88 -88
- package/.github/workflows/docs-render-cicd.yml +0 -65
|
@@ -1,369 +1,366 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
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
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
{ name: '
|
|
272
|
-
{ name: '
|
|
273
|
-
{ name: '
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
console.log(chalk.
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
Print.separator();
|
|
369
|
-
}
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createServer } from 'net';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import Table from 'cli-table3';
|
|
6
|
+
import Print from '../Print.js';
|
|
7
|
+
import inquirer from 'inquirer';
|
|
8
|
+
import { exec } from 'child_process';
|
|
9
|
+
import { promisify } from 'util';
|
|
10
|
+
import { getProjectRoot, getSrcPath, getApiPath, getConfigPath, getPath } from '../utils/PathHelper.js';
|
|
11
|
+
import updateManager from '../utils/updateManager.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Checks the Node.js version
|
|
15
|
+
*/
|
|
16
|
+
async function checkNodeVersion() {
|
|
17
|
+
const currentVersion = process.version;
|
|
18
|
+
const majorVersion = parseInt(currentVersion.slice(1).split('.')[0]);
|
|
19
|
+
const required = 20;
|
|
20
|
+
|
|
21
|
+
if (majorVersion >= required) {
|
|
22
|
+
return {
|
|
23
|
+
pass: true,
|
|
24
|
+
message: `Node.js version: ${currentVersion} (required: >= v${required})`
|
|
25
|
+
};
|
|
26
|
+
} else {
|
|
27
|
+
return {
|
|
28
|
+
pass: false,
|
|
29
|
+
message: `Node.js version: ${currentVersion} (required: >= v${required})`,
|
|
30
|
+
suggestion: `Update Node.js to v${required} or higher`
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks the directory structure
|
|
37
|
+
*/
|
|
38
|
+
async function checkDirectoryStructure() {
|
|
39
|
+
const srcPath = getSrcPath(import.meta.url);
|
|
40
|
+
const apiPath = getApiPath(import.meta.url);
|
|
41
|
+
|
|
42
|
+
const srcExists = await fs.pathExists(srcPath);
|
|
43
|
+
const apiExists = await fs.pathExists(apiPath);
|
|
44
|
+
|
|
45
|
+
if (srcExists && apiExists) {
|
|
46
|
+
return {
|
|
47
|
+
pass: true,
|
|
48
|
+
message: 'Project structure (src/ and api/) exists'
|
|
49
|
+
};
|
|
50
|
+
} else {
|
|
51
|
+
const missing = [];
|
|
52
|
+
if (!srcExists) missing.push('src/');
|
|
53
|
+
if (!apiExists) missing.push('api/');
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
pass: false,
|
|
57
|
+
message: `Missing directories: ${missing.join(', ')}`,
|
|
58
|
+
suggestion: 'Run "slice init" to initialize your project'
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Checks sliceConfig.json
|
|
65
|
+
*/
|
|
66
|
+
async function checkConfig() {
|
|
67
|
+
const configPath = getConfigPath(import.meta.url);
|
|
68
|
+
|
|
69
|
+
if (!await fs.pathExists(configPath)) {
|
|
70
|
+
return {
|
|
71
|
+
pass: false,
|
|
72
|
+
message: 'sliceConfig.json not found',
|
|
73
|
+
suggestion: 'Run "slice init" to create configuration'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
const config = await fs.readJson(configPath);
|
|
79
|
+
|
|
80
|
+
if (!config.paths || !config.paths.components) {
|
|
81
|
+
return {
|
|
82
|
+
pass: false,
|
|
83
|
+
message: 'sliceConfig.json is invalid (missing paths.components)',
|
|
84
|
+
suggestion: 'Check your configuration file'
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
pass: true,
|
|
90
|
+
message: 'sliceConfig.json is valid'
|
|
91
|
+
};
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return {
|
|
94
|
+
pass: false,
|
|
95
|
+
message: `sliceConfig.json is invalid JSON: ${error.message}`,
|
|
96
|
+
suggestion: 'Fix JSON syntax errors in sliceConfig.json'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Checks port availability
|
|
103
|
+
*/
|
|
104
|
+
async function checkPort() {
|
|
105
|
+
const configPath = getConfigPath(import.meta.url);
|
|
106
|
+
let port = 3000;
|
|
107
|
+
|
|
108
|
+
try {
|
|
109
|
+
if (await fs.pathExists(configPath)) {
|
|
110
|
+
const config = await fs.readJson(configPath);
|
|
111
|
+
port = config.server?.port || 3000;
|
|
112
|
+
}
|
|
113
|
+
} catch { /* config missing or unreadable β use default port */ }
|
|
114
|
+
|
|
115
|
+
return new Promise((resolve) => {
|
|
116
|
+
const server = createServer();
|
|
117
|
+
|
|
118
|
+
server.once('error', (err) => {
|
|
119
|
+
if (err.code === 'EADDRINUSE') {
|
|
120
|
+
resolve({
|
|
121
|
+
warn: true,
|
|
122
|
+
message: `Port ${port} is already in use`,
|
|
123
|
+
suggestion: `Stop the process using port ${port} or use: slice dev -p <other-port>`
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
resolve({
|
|
127
|
+
pass: true,
|
|
128
|
+
message: `Port ${port} is available`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
server.once('listening', () => {
|
|
134
|
+
server.close();
|
|
135
|
+
resolve({
|
|
136
|
+
pass: true,
|
|
137
|
+
message: `Port ${port} is available`
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
server.listen(port);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Checks dependencies in package.json
|
|
147
|
+
*/
|
|
148
|
+
async function checkDependencies() {
|
|
149
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
150
|
+
const packagePath = getPath(import.meta.url, 'package.json');
|
|
151
|
+
|
|
152
|
+
if (!await fs.pathExists(packagePath)) {
|
|
153
|
+
return {
|
|
154
|
+
warn: true,
|
|
155
|
+
message: 'package.json not found',
|
|
156
|
+
suggestion: 'Run "npm init" to create package.json'
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
const pkg = await fs.readJson(packagePath);
|
|
162
|
+
const hasFrameworkDep = pkg.dependencies?.['slicejs-web-framework'] || pkg.devDependencies?.['slicejs-web-framework'];
|
|
163
|
+
const frameworkNodePath = getPath(import.meta.url, 'node_modules', 'slicejs-web-framework', 'package.json');
|
|
164
|
+
const hasFrameworkNode = await fs.pathExists(frameworkNodePath);
|
|
165
|
+
const hasFramework = !!(hasFrameworkDep || hasFrameworkNode);
|
|
166
|
+
|
|
167
|
+
if (hasFramework) {
|
|
168
|
+
return {
|
|
169
|
+
pass: true,
|
|
170
|
+
message: 'Required framework dependency is installed'
|
|
171
|
+
};
|
|
172
|
+
} else {
|
|
173
|
+
const missing = ['slicejs-web-framework'];
|
|
174
|
+
|
|
175
|
+
return {
|
|
176
|
+
warn: true,
|
|
177
|
+
message: `Missing dependencies: ${missing.join(', ')}`,
|
|
178
|
+
suggestion: missing.includes('slicejs-web-framework')
|
|
179
|
+
? 'Run "npm install slicejs-web-framework@latest" in your project'
|
|
180
|
+
: 'Run "npm install -D slicejs-cli@latest" in your project',
|
|
181
|
+
missing
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
} catch (error) {
|
|
185
|
+
return {
|
|
186
|
+
pass: false,
|
|
187
|
+
message: `package.json is invalid: ${error.message}`,
|
|
188
|
+
suggestion: 'Fix JSON syntax errors in package.json'
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Checks component integrity
|
|
195
|
+
*/
|
|
196
|
+
async function checkComponents() {
|
|
197
|
+
const configPath = getConfigPath(import.meta.url);
|
|
198
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
199
|
+
|
|
200
|
+
if (!await fs.pathExists(configPath)) {
|
|
201
|
+
return {
|
|
202
|
+
warn: true,
|
|
203
|
+
message: 'Cannot check components (no config)',
|
|
204
|
+
suggestion: 'Run "slice init" first'
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
const config = await fs.readJson(configPath);
|
|
210
|
+
const componentPaths = config.paths?.components || {};
|
|
211
|
+
|
|
212
|
+
let totalComponents = 0;
|
|
213
|
+
let componentIssues = 0;
|
|
214
|
+
|
|
215
|
+
for (const [category, { path: compPath }] of Object.entries(componentPaths)) {
|
|
216
|
+
const fullPath = getSrcPath(import.meta.url, compPath);
|
|
217
|
+
|
|
218
|
+
if (await fs.pathExists(fullPath)) {
|
|
219
|
+
const items = await fs.readdir(fullPath);
|
|
220
|
+
|
|
221
|
+
for (const item of items) {
|
|
222
|
+
const itemPath = path.join(fullPath, item);
|
|
223
|
+
const stat = await fs.stat(itemPath);
|
|
224
|
+
|
|
225
|
+
if (stat.isDirectory()) {
|
|
226
|
+
totalComponents++;
|
|
227
|
+
|
|
228
|
+
// Check JS files
|
|
229
|
+
const jsFile = path.join(itemPath, `${item}.js`);
|
|
230
|
+
if (!await fs.pathExists(jsFile)) {
|
|
231
|
+
componentIssues++;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (componentIssues === 0) {
|
|
239
|
+
return {
|
|
240
|
+
pass: true,
|
|
241
|
+
message: `${totalComponents} components checked, all OK`
|
|
242
|
+
};
|
|
243
|
+
} else {
|
|
244
|
+
return {
|
|
245
|
+
warn: true,
|
|
246
|
+
message: `${componentIssues} component(s) have missing files`,
|
|
247
|
+
suggestion: 'Check your component directories'
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
} catch (error) {
|
|
251
|
+
return {
|
|
252
|
+
warn: true,
|
|
253
|
+
message: `Cannot check components: ${error.message}`,
|
|
254
|
+
suggestion: 'Verify your project structure'
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Main diagnostic command
|
|
261
|
+
*/
|
|
262
|
+
export default async function runDiagnostics() {
|
|
263
|
+
Print.newLine();
|
|
264
|
+
Print.title('π Running Slice.js Diagnostics...');
|
|
265
|
+
Print.newLine();
|
|
266
|
+
|
|
267
|
+
const checks = [
|
|
268
|
+
{ name: 'Node.js Version', fn: checkNodeVersion },
|
|
269
|
+
{ name: 'Project Structure', fn: checkDirectoryStructure },
|
|
270
|
+
{ name: 'Configuration', fn: checkConfig },
|
|
271
|
+
{ name: 'Port Availability', fn: checkPort },
|
|
272
|
+
{ name: 'Dependencies', fn: checkDependencies },
|
|
273
|
+
{ name: 'Components', fn: checkComponents }
|
|
274
|
+
];
|
|
275
|
+
|
|
276
|
+
const results = [];
|
|
277
|
+
|
|
278
|
+
for (const check of checks) {
|
|
279
|
+
const result = await check.fn();
|
|
280
|
+
results.push({ ...result, name: check.name });
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Crear tabla de resultados
|
|
284
|
+
const table = new Table({
|
|
285
|
+
head: [chalk.cyan.bold('Check'), chalk.cyan.bold('Status'), chalk.cyan.bold('Details')],
|
|
286
|
+
colWidths: [25, 10, 55],
|
|
287
|
+
style: {
|
|
288
|
+
head: [],
|
|
289
|
+
border: ['gray']
|
|
290
|
+
},
|
|
291
|
+
wordWrap: true
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
results.forEach(result => {
|
|
295
|
+
let status;
|
|
296
|
+
if (result.pass) {
|
|
297
|
+
status = chalk.green('β
PASS');
|
|
298
|
+
} else if (result.warn) {
|
|
299
|
+
status = chalk.yellow('β οΈ WARN');
|
|
300
|
+
} else {
|
|
301
|
+
status = chalk.red('β FAIL');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
const details = result.suggestion
|
|
305
|
+
? `${result.message}\n${chalk.gray('β ' + result.suggestion)}`
|
|
306
|
+
: result.message;
|
|
307
|
+
|
|
308
|
+
table.push([result.name, status, details]);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
console.log(table.toString());
|
|
312
|
+
|
|
313
|
+
// Resumen
|
|
314
|
+
const issues = results.filter(r => !r.pass && !r.warn).length;
|
|
315
|
+
const warnings = results.filter(r => r.warn).length;
|
|
316
|
+
const passed = results.filter(r => r.pass).length;
|
|
317
|
+
|
|
318
|
+
Print.newLine();
|
|
319
|
+
Print.separator();
|
|
320
|
+
|
|
321
|
+
const depsResult = results.find(r => r.name === 'Dependencies');
|
|
322
|
+
if (depsResult && depsResult.warn && Array.isArray(depsResult.missing) && depsResult.missing.length > 0) {
|
|
323
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
324
|
+
const execAsync = promisify(exec);
|
|
325
|
+
const { confirmInstall } = await inquirer.prompt([
|
|
326
|
+
{
|
|
327
|
+
type: 'confirm',
|
|
328
|
+
name: 'confirmInstall',
|
|
329
|
+
message: `Install missing dependencies in this project now? (${depsResult.missing.join(', ')})`,
|
|
330
|
+
default: true
|
|
331
|
+
}
|
|
332
|
+
]);
|
|
333
|
+
if (confirmInstall) {
|
|
334
|
+
for (const pkg of depsResult.missing) {
|
|
335
|
+
try {
|
|
336
|
+
const cmd = 'npm install slicejs-web-framework@latest';
|
|
337
|
+
Print.info(`Installing ${pkg}...`);
|
|
338
|
+
await execAsync(cmd, { cwd: projectRoot });
|
|
339
|
+
Print.success(`${pkg} installed`);
|
|
340
|
+
} catch (e) {
|
|
341
|
+
Print.error(`Installing ${pkg}: ${e.message}`);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (issues === 0 && warnings === 0) {
|
|
348
|
+
Print.success('All checks passed! π');
|
|
349
|
+
Print.info('Your Slice.js project is correctly configured');
|
|
350
|
+
} else {
|
|
351
|
+
console.log(chalk.bold('π Summary:'));
|
|
352
|
+
console.log(chalk.green(` β
Passed: ${passed}`));
|
|
353
|
+
if (warnings > 0) console.log(chalk.yellow(` β οΈ Warnings: ${warnings}`));
|
|
354
|
+
if (issues > 0) console.log(chalk.red(` β Issues: ${issues}`));
|
|
355
|
+
|
|
356
|
+
Print.newLine();
|
|
357
|
+
|
|
358
|
+
if (issues > 0) {
|
|
359
|
+
Print.warning('Fix the issues above to ensure proper functionality');
|
|
360
|
+
} else {
|
|
361
|
+
Print.info('Warnings are non-critical but should be addressed');
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
Print.separator();
|
|
366
|
+
}
|