slicejs-web-framework 3.4.4 → 3.5.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.
Files changed (110) hide show
  1. package/Slice/Components/Structural/Controller/Controller.js +135 -0
  2. package/Slice/Components/Structural/EventManager/EventManager.js +289 -4
  3. package/Slice/Components/Structural/EventManager/EventManagerDebugger.js +368 -30
  4. package/Slice/Components/Structural/LeakInspector/LeakInspector.js +296 -0
  5. package/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +56 -0
  6. package/Slice/Slice.js +14 -1
  7. package/Slice/tests/event-emitters.test.js +79 -0
  8. package/Slice/tests/event-registry.test.js +141 -0
  9. package/Slice/tests/leak-orphans.test.js +131 -0
  10. package/api/{middleware → framework}/securityMiddleware.js +18 -74
  11. package/api/framework/server.js +333 -0
  12. package/api/index.js +5 -279
  13. package/api/tests/public-env-resolver.test.js +1 -1
  14. package/package.json +4 -2
  15. package/sliceConfig.schema.json +10 -1
  16. package/src/App/index.html +31 -1
  17. package/src/manifest.json +15 -0
  18. package/src/robots.txt +4 -0
  19. package/src/sitemap.xml +8 -0
  20. package/src/sliceConfig.json +5 -1
  21. package/types/index.d.ts +12 -0
  22. package/slicejs-cli/.github/workflows/ci.yml +0 -43
  23. package/slicejs-cli/LICENSE +0 -21
  24. package/slicejs-cli/assets/Slice.js-logo.png +0 -0
  25. package/slicejs-cli/client.js +0 -740
  26. package/slicejs-cli/commands/Print.js +0 -164
  27. package/slicejs-cli/commands/Validations.js +0 -92
  28. package/slicejs-cli/commands/build/build.js +0 -40
  29. package/slicejs-cli/commands/buildProduction/buildProduction.js +0 -577
  30. package/slicejs-cli/commands/bundle/bundle.js +0 -236
  31. package/slicejs-cli/commands/createComponent/VisualComponentTemplate.js +0 -55
  32. package/slicejs-cli/commands/createComponent/createComponent.js +0 -128
  33. package/slicejs-cli/commands/deleteComponent/deleteComponent.js +0 -81
  34. package/slicejs-cli/commands/doctor/doctor.js +0 -516
  35. package/slicejs-cli/commands/getComponent/getComponent.js +0 -695
  36. package/slicejs-cli/commands/init/init.js +0 -473
  37. package/slicejs-cli/commands/listComponents/listComponents.js +0 -172
  38. package/slicejs-cli/commands/startServer/startServer.js +0 -240
  39. package/slicejs-cli/commands/startServer/watchServer.js +0 -66
  40. package/slicejs-cli/commands/types/types.js +0 -583
  41. package/slicejs-cli/commands/utils/LocalCliDelegation.js +0 -53
  42. package/slicejs-cli/commands/utils/PackageManager.js +0 -148
  43. package/slicejs-cli/commands/utils/PathHelper.js +0 -75
  44. package/slicejs-cli/commands/utils/VersionChecker.js +0 -169
  45. package/slicejs-cli/commands/utils/bundling/BundleGenerator.js +0 -2525
  46. package/slicejs-cli/commands/utils/bundling/DependencyAnalyzer.js +0 -933
  47. package/slicejs-cli/commands/utils/loadConfig.js +0 -31
  48. package/slicejs-cli/commands/utils/sliceScripts.js +0 -48
  49. package/slicejs-cli/commands/utils/updateManager.js +0 -471
  50. package/slicejs-cli/package.json +0 -71
  51. package/slicejs-cli/playwright.config.js +0 -51
  52. package/slicejs-cli/pnpm-lock.yaml +0 -1629
  53. package/slicejs-cli/tests/build-command-integration.test.js +0 -87
  54. package/slicejs-cli/tests/build-mangling-e2e.test.js +0 -290
  55. package/slicejs-cli/tests/build-production-e2e.test.js +0 -140
  56. package/slicejs-cli/tests/builder-edge-cases.test.js +0 -322
  57. package/slicejs-cli/tests/bundle-generate-e2e.test.js +0 -115
  58. package/slicejs-cli/tests/bundle-generator.test.js +0 -691
  59. package/slicejs-cli/tests/bundle-v2-register-output.test.js +0 -470
  60. package/slicejs-cli/tests/bundling-dependency-edges.test.js +0 -127
  61. package/slicejs-cli/tests/bundling-imports-unit.test.js +0 -267
  62. package/slicejs-cli/tests/client-launcher-contract.test.js +0 -211
  63. package/slicejs-cli/tests/commands-component-crud.test.js +0 -128
  64. package/slicejs-cli/tests/commands-doctor.test.js +0 -152
  65. package/slicejs-cli/tests/commands-version-checker.test.js +0 -37
  66. package/slicejs-cli/tests/component-registry-parse.test.js +0 -34
  67. package/slicejs-cli/tests/dependency-analyzer.test.js +0 -24
  68. package/slicejs-cli/tests/e2e/bundles.spec.js +0 -91
  69. package/slicejs-cli/tests/e2e/dependency-scenarios.spec.js +0 -56
  70. package/slicejs-cli/tests/e2e/fixtures/components/Service/FetchManager/FetchManager.js +0 -136
  71. package/slicejs-cli/tests/e2e/fixtures/components/Service/IndexedDbManager/IndexedDbManager.js +0 -149
  72. package/slicejs-cli/tests/e2e/fixtures/components/Service/LocalStorageManager/LocalStorageManager.js +0 -45
  73. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Button/Button.css +0 -106
  74. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Button/Button.html +0 -5
  75. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Button/Button.js +0 -158
  76. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Link/Link.js +0 -33
  77. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Loading/Loading.css +0 -56
  78. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Loading/Loading.html +0 -83
  79. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Loading/Loading.js +0 -164
  80. package/slicejs-cli/tests/e2e/fixtures/components/Visual/MultiRoute/MultiRoute.js +0 -167
  81. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Navbar/Navbar.css +0 -116
  82. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Navbar/Navbar.html +0 -44
  83. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Navbar/Navbar.js +0 -180
  84. package/slicejs-cli/tests/e2e/fixtures/components/Visual/NotFound/NotFound.js +0 -20
  85. package/slicejs-cli/tests/e2e/fixtures/components/Visual/Route/Route.js +0 -181
  86. package/slicejs-cli/tests/e2e/fixtures/components/registry.json +0 -12
  87. package/slicejs-cli/tests/e2e/fixtures/vendor-components.mjs +0 -65
  88. package/slicejs-cli/tests/e2e/navigation.spec.js +0 -44
  89. package/slicejs-cli/tests/e2e/render.spec.js +0 -34
  90. package/slicejs-cli/tests/e2e/serve.mjs +0 -264
  91. package/slicejs-cli/tests/e2e/shared-deps.spec.js +0 -61
  92. package/slicejs-cli/tests/e2e/unminified.spec.js +0 -33
  93. package/slicejs-cli/tests/e2e-serve.test.js +0 -148
  94. package/slicejs-cli/tests/fixtures/components.js +0 -8
  95. package/slicejs-cli/tests/fixtures/sliceConfig.json +0 -74
  96. package/slicejs-cli/tests/getcomponent.test.js +0 -435
  97. package/slicejs-cli/tests/helpers/setup.js +0 -102
  98. package/slicejs-cli/tests/init-command-contract.test.js +0 -101
  99. package/slicejs-cli/tests/init-e2e.test.js +0 -82
  100. package/slicejs-cli/tests/init-project-isolation.test.js +0 -98
  101. package/slicejs-cli/tests/local-cli-delegation.test.js +0 -81
  102. package/slicejs-cli/tests/package-manager.test.js +0 -127
  103. package/slicejs-cli/tests/path-helper.test.js +0 -206
  104. package/slicejs-cli/tests/perf-budget.test.js +0 -84
  105. package/slicejs-cli/tests/postinstall-command.test.js +0 -103
  106. package/slicejs-cli/tests/property-mangling-regression.test.js +0 -182
  107. package/slicejs-cli/tests/types-breakage.test.js +0 -491
  108. package/slicejs-cli/tests/types-generator-errors.test.js +0 -361
  109. package/slicejs-cli/tests/types-generator.test.js +0 -348
  110. /package/api/{utils → framework}/publicEnvResolver.js +0 -0
@@ -1,516 +0,0 @@
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 { getProjectRoot, getSrcPath, getApiPath, getConfigPath, getPath, getComponentsJsPath } from '../utils/PathHelper.js';
8
- import { resolvePackageManager, installCommand } from '../utils/PackageManager.js';
9
- import updateManager from '../utils/updateManager.js';
10
- import { parseComponentsRegistry, extractStaticPropsFromSource } from '../types/types.js';
11
-
12
- /**
13
- * Checks the Node.js version
14
- */
15
- async function checkNodeVersion() {
16
- const currentVersion = process.version;
17
- const majorVersion = parseInt(currentVersion.slice(1).split('.')[0]);
18
- const required = 20;
19
-
20
- if (majorVersion >= required) {
21
- return {
22
- pass: true,
23
- message: `Node.js version: ${currentVersion} (required: >= v${required})`
24
- };
25
- } else {
26
- return {
27
- pass: false,
28
- message: `Node.js version: ${currentVersion} (required: >= v${required})`,
29
- suggestion: `Update Node.js to v${required} or higher`
30
- };
31
- }
32
- }
33
-
34
- /**
35
- * Checks the directory structure
36
- */
37
- async function checkDirectoryStructure() {
38
- const srcPath = getSrcPath(import.meta.url);
39
- const apiPath = getApiPath(import.meta.url);
40
-
41
- const srcExists = await fs.pathExists(srcPath);
42
- const apiExists = await fs.pathExists(apiPath);
43
-
44
- if (srcExists && apiExists) {
45
- return {
46
- pass: true,
47
- message: 'Project structure (src/ and api/) exists'
48
- };
49
- } else {
50
- const missing = [];
51
- if (!srcExists) missing.push('src/');
52
- if (!apiExists) missing.push('api/');
53
-
54
- return {
55
- pass: false,
56
- message: `Missing directories: ${missing.join(', ')}`,
57
- suggestion: 'Run "slice init" to initialize your project'
58
- };
59
- }
60
- }
61
-
62
- /**
63
- * Checks sliceConfig.json
64
- */
65
- async function checkConfig() {
66
- const configPath = getConfigPath(import.meta.url);
67
-
68
- if (!await fs.pathExists(configPath)) {
69
- return {
70
- pass: false,
71
- message: 'sliceConfig.json not found',
72
- suggestion: 'Run "slice init" to create configuration'
73
- };
74
- }
75
-
76
- try {
77
- const config = await fs.readJson(configPath);
78
-
79
- if (!config.paths || !config.paths.components) {
80
- return {
81
- pass: false,
82
- message: 'sliceConfig.json is invalid (missing paths.components)',
83
- suggestion: 'Check your configuration file'
84
- };
85
- }
86
-
87
- return {
88
- pass: true,
89
- message: 'sliceConfig.json is valid'
90
- };
91
- } catch (error) {
92
- return {
93
- pass: false,
94
- message: `sliceConfig.json is invalid JSON: ${error.message}`,
95
- suggestion: 'Fix JSON syntax errors in sliceConfig.json'
96
- };
97
- }
98
- }
99
-
100
- /**
101
- * Checks port availability
102
- */
103
- async function checkPort() {
104
- const configPath = getConfigPath(import.meta.url);
105
- let port = 3000;
106
-
107
- try {
108
- if (await fs.pathExists(configPath)) {
109
- const config = await fs.readJson(configPath);
110
- port = config.server?.port || 3000;
111
- }
112
- } catch { /* config missing or unreadable — use default port */ }
113
-
114
- return new Promise((resolve) => {
115
- const server = createServer();
116
-
117
- server.once('error', (err) => {
118
- if (err.code === 'EADDRINUSE') {
119
- resolve({
120
- warn: true,
121
- message: `Port ${port} is already in use`,
122
- suggestion: `Stop the process using port ${port} or use: slice dev -p <other-port>`
123
- });
124
- } else {
125
- resolve({
126
- pass: true,
127
- message: `Port ${port} is available`
128
- });
129
- }
130
- });
131
-
132
- server.once('listening', () => {
133
- server.close();
134
- resolve({
135
- pass: true,
136
- message: `Port ${port} is available`
137
- });
138
- });
139
-
140
- server.listen(port);
141
- });
142
- }
143
-
144
- /**
145
- * Checks the package manager setup: mixed lockfiles, packageManager field
146
- * consistency, and a project-local CLI install (required for local delegation).
147
- * Exported for tests.
148
- */
149
- export async function checkPackageManagerSetup(projectRoot = getProjectRoot(import.meta.url)) {
150
- const issues = [];
151
- const suggestions = [];
152
-
153
- const LOCKFILE_PM = {
154
- 'package-lock.json': 'npm',
155
- 'pnpm-lock.yaml': 'pnpm'
156
- };
157
- const lockfiles = [];
158
- for (const lockfile of Object.keys(LOCKFILE_PM)) {
159
- if (await fs.pathExists(path.join(projectRoot, lockfile))) {
160
- lockfiles.push(lockfile);
161
- }
162
- }
163
-
164
- let pkg = null;
165
- const pkgPath = path.join(projectRoot, 'package.json');
166
- if (await fs.pathExists(pkgPath)) {
167
- try { pkg = await fs.readJson(pkgPath); } catch { /* reported by Dependencies check */ }
168
- }
169
- const pmField = typeof pkg?.packageManager === 'string' ? pkg.packageManager.split('@')[0] : null;
170
- const pm = resolvePackageManager(projectRoot).name;
171
-
172
- if (lockfiles.length > 1) {
173
- issues.push(`Mixed lockfiles found: ${lockfiles.join(', ')}`);
174
- const keep = pmField || pm;
175
- const keepLockfile = Object.entries(LOCKFILE_PM).find(([, name]) => name === keep)?.[0];
176
- suggestions.push(`Keep only ${keepLockfile ?? 'the lockfile of your package manager'} and delete the rest`);
177
- }
178
-
179
- if (pkg && !pmField) {
180
- issues.push('No "packageManager" field in package.json');
181
- suggestions.push(`Pin it (e.g. "packageManager": "${pm}@<version>") so every tool resolves the same package manager`);
182
- } else if (pmField && lockfiles.length === 1 && LOCKFILE_PM[lockfiles[0]] !== pmField) {
183
- issues.push(`packageManager is "${pmField}" but the lockfile is ${lockfiles[0]}`);
184
- suggestions.push(`Reinstall with ${pmField} (or update the packageManager field) so they agree`);
185
- }
186
-
187
- const localCliPath = path.join(projectRoot, 'node_modules', 'slicejs-cli', 'package.json');
188
- if (pkg && !(await fs.pathExists(localCliPath))) {
189
- issues.push('slicejs-cli is not installed locally');
190
- suggestions.push(`Run "${installCommand(pm, 'slicejs-cli', { dev: true })}" so the launcher delegates to a version pinned per project`);
191
- }
192
-
193
- if (issues.length === 0) {
194
- return {
195
- pass: true,
196
- message: `Package manager setup is consistent (${pmField || pm})`
197
- };
198
- }
199
- return {
200
- warn: true,
201
- message: issues.join(' | '),
202
- suggestion: suggestions.join(' | ')
203
- };
204
- }
205
-
206
- /**
207
- * Checks dependencies in package.json
208
- */
209
- async function checkDependencies() {
210
- const projectRoot = getProjectRoot(import.meta.url);
211
- const packagePath = getPath(import.meta.url, 'package.json');
212
-
213
- if (!await fs.pathExists(packagePath)) {
214
- return {
215
- warn: true,
216
- message: 'package.json not found',
217
- suggestion: 'Run "npm init" to create package.json'
218
- };
219
- }
220
-
221
- try {
222
- const pkg = await fs.readJson(packagePath);
223
- const hasFrameworkDep = pkg.dependencies?.['slicejs-web-framework'] || pkg.devDependencies?.['slicejs-web-framework'];
224
- const frameworkNodePath = getPath(import.meta.url, 'node_modules', 'slicejs-web-framework', 'package.json');
225
- const hasFrameworkNode = await fs.pathExists(frameworkNodePath);
226
- const hasFramework = !!(hasFrameworkDep || hasFrameworkNode);
227
-
228
- if (hasFramework) {
229
- return {
230
- pass: true,
231
- message: 'Required framework dependency is installed'
232
- };
233
- } else {
234
- const missing = ['slicejs-web-framework'];
235
-
236
- return {
237
- warn: true,
238
- message: `Missing dependencies: ${missing.join(', ')}`,
239
- suggestion: missing.includes('slicejs-web-framework')
240
- ? `Run "${installCommand(resolvePackageManager(getProjectRoot(import.meta.url)).name, 'slicejs-web-framework@latest')}" in your project`
241
- : `Run "${installCommand(resolvePackageManager(getProjectRoot(import.meta.url)).name, 'slicejs-cli@latest', { dev: true })}" in your project`,
242
- missing
243
- };
244
- }
245
- } catch (error) {
246
- return {
247
- pass: false,
248
- message: `package.json is invalid: ${error.message}`,
249
- suggestion: 'Fix JSON syntax errors in package.json'
250
- };
251
- }
252
- }
253
-
254
- /**
255
- * Checks component integrity
256
- */
257
- async function checkComponents() {
258
- const configPath = getConfigPath(import.meta.url);
259
- const projectRoot = getProjectRoot(import.meta.url);
260
-
261
- if (!await fs.pathExists(configPath)) {
262
- return {
263
- warn: true,
264
- message: 'Cannot check components (no config)',
265
- suggestion: 'Run "slice init" first'
266
- };
267
- }
268
-
269
- try {
270
- const config = await fs.readJson(configPath);
271
- const componentPaths = config.paths?.components || {};
272
-
273
- let totalComponents = 0;
274
- let componentIssues = 0;
275
-
276
- for (const [category, { path: compPath }] of Object.entries(componentPaths)) {
277
- const fullPath = getSrcPath(import.meta.url, compPath);
278
-
279
- if (await fs.pathExists(fullPath)) {
280
- const items = await fs.readdir(fullPath);
281
-
282
- for (const item of items) {
283
- const itemPath = path.join(fullPath, item);
284
- const stat = await fs.stat(itemPath);
285
-
286
- if (stat.isDirectory()) {
287
- totalComponents++;
288
-
289
- // Check JS files
290
- const jsFile = path.join(itemPath, `${item}.js`);
291
- if (!await fs.pathExists(jsFile)) {
292
- componentIssues++;
293
- }
294
- }
295
- }
296
- }
297
- }
298
-
299
- if (componentIssues === 0) {
300
- return {
301
- pass: true,
302
- message: `${totalComponents} components checked, all OK`
303
- };
304
- } else {
305
- return {
306
- warn: true,
307
- message: `${componentIssues} component(s) have missing files`,
308
- suggestion: 'Check your component directories'
309
- };
310
- }
311
- } catch (error) {
312
- return {
313
- warn: true,
314
- message: `Cannot check components: ${error.message}`,
315
- suggestion: 'Verify your project structure'
316
- };
317
- }
318
- }
319
-
320
- /**
321
- * Lints component static props for common issues.
322
- * Uses the same Babel parsing as slice types generate.
323
- */
324
- async function checkComponentProps() {
325
- const issues = [];
326
- const registryPath = getComponentsJsPath(import.meta.url);
327
- const configPath = getConfigPath(import.meta.url);
328
-
329
- if (!await fs.pathExists(registryPath)) {
330
- return { pass: true, message: 'No components to check' };
331
- }
332
-
333
- try {
334
- const content = await fs.readFile(registryPath, 'utf-8');
335
- const registryMap = parseComponentsRegistry(content, registryPath);
336
- const entries = Object.entries(registryMap);
337
-
338
- if (entries.length === 0) {
339
- return { pass: true, message: 'No components registered' };
340
- }
341
-
342
- // Build a category-to-path map from sliceConfig.json
343
- const categoryPathCache = new Map();
344
- if (await fs.pathExists(configPath)) {
345
- try {
346
- const config = await fs.readJson(configPath);
347
- if (config.paths?.components) {
348
- for (const [cat, catMeta] of Object.entries(config.paths.components)) {
349
- categoryPathCache.set(cat, catMeta.path?.replace(/^[/\\]+/, '') || '');
350
- }
351
- }
352
- } catch {}
353
- }
354
-
355
- const VALID_TYPES = new Set(['string', 'number', 'boolean', 'object', 'array', 'function', 'any']);
356
- const checked = [];
357
-
358
- for (const [compName, meta] of entries) {
359
- const category = typeof meta === 'string' ? meta : (meta.category || '');
360
- const relPath = categoryPathCache.get(category);
361
- if (!relPath) continue;
362
- const jsPath = getSrcPath(import.meta.url, relPath, compName, `${compName}.js`);
363
-
364
- if (!await fs.pathExists(jsPath)) {
365
- continue;
366
- }
367
-
368
- const source = await fs.readFile(jsPath, 'utf-8');
369
- const props = extractStaticPropsFromSource(source, jsPath);
370
- if (!props) continue;
371
-
372
- checked.push(compName);
373
-
374
- for (const [propName, propMeta] of Object.entries(props)) {
375
- if (propMeta.type === 'any') {
376
- issues.push({ component: compName, prop: propName, message: `"${propName}" uses type "any" — specify a concrete type` });
377
- }
378
- if (propMeta.required && propMeta.type !== 'boolean') {
379
- issues.push({ component: compName, prop: propName, message: `"${propName}" is required but has no default value` });
380
- }
381
- if (propMeta.schema && propMeta.type !== 'object') {
382
- issues.push({ component: compName, prop: propName, message: `"${propName}" has "schema" but type is "${propMeta.type}" (should be "object")` });
383
- }
384
- if (propMeta.items && propMeta.type !== 'array') {
385
- issues.push({ component: compName, prop: propName, message: `"${propName}" has "items" but type is "${propMeta.type}" (should be "array")` });
386
- }
387
- if (!VALID_TYPES.has(propMeta.type)) {
388
- issues.push({ component: compName, prop: propName, message: `"${propName}" has unknown type "${propMeta.type}"` });
389
- }
390
- if (Array.isArray(propMeta.allowedValues) && propMeta.allowedValues.length > 0) {
391
- const typeMismatch = propMeta.allowedValues.some(v => typeof v !== propMeta.type);
392
- if (typeMismatch && propMeta.type !== 'any') {
393
- issues.push({ component: compName, prop: propName, message: `"${propName}" allowedValues type mismatch (expected ${propMeta.type})` });
394
- }
395
- }
396
- }
397
- }
398
-
399
- if (issues.length === 0) {
400
- return { pass: true, message: `${checked.length} components checked, props look good` };
401
- }
402
-
403
- return {
404
- warn: true,
405
- message: `${issues.length} prop issue(s) across ${new Set(issues.map(i => i.component)).size} component(s)`,
406
- suggestion: issues.map(i => ` ${i.component}.${i.prop}: ${i.message}`).join('\n'),
407
- issues
408
- };
409
- } catch (error) {
410
- return { warn: true, message: `Cannot check props: ${error.message}` };
411
- }
412
- }
413
-
414
- /**
415
- * Main diagnostic command
416
- */
417
- export {
418
- checkNodeVersion,
419
- checkDirectoryStructure,
420
- checkConfig,
421
- checkPort,
422
- checkDependencies,
423
- checkComponents,
424
- checkComponentProps
425
- };
426
-
427
- export default async function runDiagnostics() {
428
- Print.newLine();
429
- Print.title('🔍 Running Slice.js Diagnostics...');
430
- Print.newLine();
431
-
432
- const checks = [
433
- { name: 'Node.js Version', fn: checkNodeVersion },
434
- { name: 'Project Structure', fn: checkDirectoryStructure },
435
- { name: 'Configuration', fn: checkConfig },
436
- { name: 'Port Availability', fn: checkPort },
437
- { name: 'Package Manager', fn: checkPackageManagerSetup },
438
- { name: 'Dependencies', fn: checkDependencies },
439
- { name: 'Components', fn: checkComponents },
440
- { name: 'Component Props', fn: checkComponentProps }
441
- ];
442
-
443
- const results = [];
444
-
445
- for (const check of checks) {
446
- const result = await check.fn();
447
- results.push({ ...result, name: check.name });
448
- }
449
-
450
- // Crear tabla de resultados
451
- const table = new Table({
452
- head: [chalk.cyan.bold('Check'), chalk.cyan.bold('Status'), chalk.cyan.bold('Details')],
453
- colWidths: [25, 10, 55],
454
- style: {
455
- head: [],
456
- border: ['gray']
457
- },
458
- wordWrap: true
459
- });
460
-
461
- results.forEach(result => {
462
- let status;
463
- if (result.pass) {
464
- status = chalk.green('✅ PASS');
465
- } else if (result.warn) {
466
- status = chalk.yellow('⚠️ WARN');
467
- } else {
468
- status = chalk.red('❌ FAIL');
469
- }
470
-
471
- const details = result.suggestion
472
- ? `${result.message}\n${chalk.gray('→ ' + result.suggestion)}`
473
- : result.message;
474
-
475
- table.push([result.name, status, details]);
476
- });
477
-
478
- console.log(table.toString());
479
-
480
- // Resumen
481
- const issues = results.filter(r => !r.pass && !r.warn).length;
482
- const warnings = results.filter(r => r.warn).length;
483
- const passed = results.filter(r => r.pass).length;
484
-
485
- Print.newLine();
486
- Print.separator();
487
-
488
- const depsResult = results.find(r => r.name === 'Dependencies');
489
- if (depsResult && depsResult.warn && Array.isArray(depsResult.missing) && depsResult.missing.length > 0) {
490
- const projectRoot = getProjectRoot(import.meta.url);
491
- const pm = resolvePackageManager(projectRoot).name;
492
- for (const pkg of depsResult.missing) {
493
- Print.info(`Missing: ${pkg}. Install with: ${installCommand(pm, `${pkg}@latest`)}`);
494
- }
495
- }
496
-
497
- if (issues === 0 && warnings === 0) {
498
- Print.success('All checks passed! 🎉');
499
- Print.info('Your Slice.js project is correctly configured');
500
- } else {
501
- console.log(chalk.bold('📊 Summary:'));
502
- console.log(chalk.green(` ✅ Passed: ${passed}`));
503
- if (warnings > 0) console.log(chalk.yellow(` ⚠️ Warnings: ${warnings}`));
504
- if (issues > 0) console.log(chalk.red(` ❌ Issues: ${issues}`));
505
-
506
- Print.newLine();
507
-
508
- if (issues > 0) {
509
- Print.warning('Fix the issues above to ensure proper functionality');
510
- } else {
511
- Print.info('Warnings are non-critical but should be addressed');
512
- }
513
- }
514
-
515
- Print.separator();
516
- }