slicejs-cli 2.1.9 → 2.1.11
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.
|
@@ -109,8 +109,7 @@ class ComponentRegistry {
|
|
|
109
109
|
updatableComponents.push({
|
|
110
110
|
name,
|
|
111
111
|
category,
|
|
112
|
-
path: componentPath
|
|
113
|
-
description: this.getComponentDescription(name, category)
|
|
112
|
+
path: componentPath
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
115
|
}
|
|
@@ -125,13 +124,25 @@ class ComponentRegistry {
|
|
|
125
124
|
const components = {};
|
|
126
125
|
Object.entries(this.componentsRegistry).forEach(([name, componentCategory]) => {
|
|
127
126
|
if (!category || componentCategory === category) {
|
|
127
|
+
// ✅ CORREGIDO: Componentes especiales que no necesitan todos los archivos
|
|
128
|
+
let files;
|
|
129
|
+
if (componentCategory === 'Visual') {
|
|
130
|
+
// Componentes de routing lógico solo necesitan JS
|
|
131
|
+
if (['Route', 'MultiRoute', 'NotFound'].includes(name)) {
|
|
132
|
+
files = [`${name}.js`];
|
|
133
|
+
} else {
|
|
134
|
+
// Componentes visuales normales necesitan JS, HTML, CSS
|
|
135
|
+
files = [`${name}.js`, `${name}.html`, `${name}.css`];
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
// Service components solo necesitan JS
|
|
139
|
+
files = [`${name}.js`];
|
|
140
|
+
}
|
|
141
|
+
|
|
128
142
|
components[name] = {
|
|
129
143
|
name,
|
|
130
144
|
category: componentCategory,
|
|
131
|
-
files:
|
|
132
|
-
[`${name}.js`, `${name}.html`, `${name}.css`] :
|
|
133
|
-
[`${name}.js`],
|
|
134
|
-
description: this.getComponentDescription(name, componentCategory)
|
|
145
|
+
files: files
|
|
135
146
|
};
|
|
136
147
|
}
|
|
137
148
|
});
|
|
@@ -139,37 +150,42 @@ class ComponentRegistry {
|
|
|
139
150
|
return components;
|
|
140
151
|
}
|
|
141
152
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
'
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
153
|
+
displayAvailableComponents() {
|
|
154
|
+
if (!this.componentsRegistry) {
|
|
155
|
+
Print.error('❌ No se pudo cargar el registro de componentes');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
console.log('\n📚 Componentes disponibles en el repositorio oficial de Slice.js:\n');
|
|
160
|
+
|
|
161
|
+
const visualComponents = this.getAvailableComponents('Visual');
|
|
162
|
+
const serviceComponents = this.getAvailableComponents('Service');
|
|
163
|
+
|
|
164
|
+
// ✅ SIMPLIFICADO: Solo mostrar nombres sin descripciones
|
|
165
|
+
Print.info('🎨 Visual Components (UI):');
|
|
166
|
+
Object.keys(visualComponents).forEach(name => {
|
|
167
|
+
const files = visualComponents[name].files;
|
|
168
|
+
const fileIcons = files.map(file => {
|
|
169
|
+
if (file.endsWith('.js')) return '📜';
|
|
170
|
+
if (file.endsWith('.html')) return '🌐';
|
|
171
|
+
if (file.endsWith('.css')) return '🎨';
|
|
172
|
+
return '📄';
|
|
173
|
+
}).join(' ');
|
|
174
|
+
console.log(` • ${name} ${fileIcons}`);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
Print.info('\n⚙️ Service Components (Logic):');
|
|
178
|
+
Object.keys(serviceComponents).forEach(name => {
|
|
179
|
+
console.log(` • ${name} 📜`);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
Print.newLine();
|
|
183
|
+
Print.info(`Total: ${Object.keys(visualComponents).length} Visual + ${Object.keys(serviceComponents).length} Service components`);
|
|
184
|
+
|
|
185
|
+
console.log(`\n💡 Ejemplos de uso:`);
|
|
186
|
+
console.log(`slice get Button Card Input # Obtener componentes Visual`);
|
|
187
|
+
console.log(`slice get FetchManager --service # Obtener componente Service`);
|
|
188
|
+
console.log(`slice sync # Sincronizar componentes Visual`);
|
|
173
189
|
}
|
|
174
190
|
|
|
175
191
|
async downloadComponentFiles(componentName, category, targetPath) {
|
|
@@ -180,6 +196,7 @@ class ComponentRegistry {
|
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
const downloadedFiles = [];
|
|
199
|
+
const failedFiles = [];
|
|
183
200
|
Print.info(`Downloading ${componentName} from official repository...`);
|
|
184
201
|
|
|
185
202
|
for (const fileName of component.files) {
|
|
@@ -190,7 +207,9 @@ class ComponentRegistry {
|
|
|
190
207
|
const response = await fetch(githubUrl);
|
|
191
208
|
|
|
192
209
|
if (!response.ok) {
|
|
193
|
-
|
|
210
|
+
Print.downloadError(fileName, `HTTP ${response.status}: ${response.statusText}`);
|
|
211
|
+
failedFiles.push(fileName);
|
|
212
|
+
continue; // ✅ CONTINUAR en lugar de lanzar error
|
|
194
213
|
}
|
|
195
214
|
|
|
196
215
|
const content = await response.text();
|
|
@@ -200,10 +219,24 @@ class ComponentRegistry {
|
|
|
200
219
|
Print.downloadSuccess(fileName);
|
|
201
220
|
} catch (error) {
|
|
202
221
|
Print.downloadError(fileName, error.message);
|
|
203
|
-
|
|
222
|
+
failedFiles.push(fileName);
|
|
223
|
+
continue; // ✅ CONTINUAR en lugar de lanzar error
|
|
204
224
|
}
|
|
205
225
|
}
|
|
206
226
|
|
|
227
|
+
// ✅ NUEVO: Solo lanzar error si NO se descargó el archivo principal (.js)
|
|
228
|
+
const mainFileDownloaded = downloadedFiles.some(file => file.endsWith('.js'));
|
|
229
|
+
|
|
230
|
+
if (!mainFileDownloaded) {
|
|
231
|
+
throw new Error(`Failed to download main component file (${componentName}.js)`);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// ✅ ADVERTENCIA: Informar sobre archivos que fallaron (pero no detener el proceso)
|
|
235
|
+
if (failedFiles.length > 0) {
|
|
236
|
+
Print.warning(`Some files couldn't be downloaded: ${failedFiles.join(', ')}`);
|
|
237
|
+
Print.info('Component installed with available files');
|
|
238
|
+
}
|
|
239
|
+
|
|
207
240
|
return downloadedFiles;
|
|
208
241
|
}
|
|
209
242
|
|
|
@@ -274,7 +307,7 @@ class ComponentRegistry {
|
|
|
274
307
|
{
|
|
275
308
|
type: 'confirm',
|
|
276
309
|
name: 'overwrite',
|
|
277
|
-
message: `
|
|
310
|
+
message: `El componente '${componentName}' ya existe localmente. ¿Deseas sobrescribirlo con la versión del repositorio?`,
|
|
278
311
|
default: false
|
|
279
312
|
}
|
|
280
313
|
]);
|
|
@@ -295,18 +328,27 @@ class ComponentRegistry {
|
|
|
295
328
|
// Update components registry
|
|
296
329
|
await this.updateLocalRegistry(componentName, category);
|
|
297
330
|
|
|
298
|
-
Print.success(`${componentName}
|
|
331
|
+
Print.success(`${componentName} installed successfully from official repository!`);
|
|
299
332
|
console.log(`📁 Location: ${folderSuffix}/${categoryPath}/${componentName}/`);
|
|
300
333
|
console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
|
|
301
334
|
|
|
302
335
|
return true;
|
|
303
336
|
|
|
304
337
|
} catch (error) {
|
|
305
|
-
Print.error(`Error
|
|
306
|
-
|
|
307
|
-
|
|
338
|
+
Print.error(`Error installing ${componentName}: ${error.message}`);
|
|
339
|
+
|
|
340
|
+
// ✅ MEJORADO: Solo borrar si el archivo principal (.js) no existe
|
|
341
|
+
const mainFilePath = path.join(targetPath, `${componentName}.js`);
|
|
342
|
+
const mainFileExists = await fs.pathExists(mainFilePath);
|
|
343
|
+
|
|
344
|
+
if (!mainFileExists && await fs.pathExists(targetPath)) {
|
|
345
|
+
// Solo limpiar si no se instaló el archivo principal
|
|
308
346
|
await fs.remove(targetPath);
|
|
347
|
+
Print.info('Cleaned up failed installation');
|
|
348
|
+
} else if (mainFileExists) {
|
|
349
|
+
Print.warning('Component partially installed - main file exists');
|
|
309
350
|
}
|
|
351
|
+
|
|
310
352
|
throw error;
|
|
311
353
|
}
|
|
312
354
|
}
|
|
@@ -336,22 +378,30 @@ class ComponentRegistry {
|
|
|
336
378
|
}
|
|
337
379
|
|
|
338
380
|
async updateAllComponents(force = false) {
|
|
339
|
-
Print.info('Looking for updatable components...');
|
|
381
|
+
Print.info('Looking for updatable Visual components...');
|
|
382
|
+
|
|
383
|
+
const allUpdatableComponents = await this.findUpdatableComponents();
|
|
340
384
|
|
|
341
|
-
|
|
385
|
+
// ✅ NUEVO: Filtrar solo componentes Visual
|
|
386
|
+
const updatableComponents = allUpdatableComponents.filter(comp => comp.category === 'Visual');
|
|
342
387
|
|
|
343
388
|
if (updatableComponents.length === 0) {
|
|
344
|
-
Print.info('No local components found that match the official repository');
|
|
345
|
-
Print.info('Use "
|
|
389
|
+
Print.info('No local Visual components found that match the official repository');
|
|
390
|
+
Print.info('Use "slice browse" to see available components');
|
|
346
391
|
return true;
|
|
347
392
|
}
|
|
348
393
|
|
|
394
|
+
// Mostrar estadísticas si hay componentes Service que no se sincronizarán
|
|
395
|
+
const serviceComponents = allUpdatableComponents.filter(comp => comp.category === 'Service');
|
|
396
|
+
if (serviceComponents.length > 0) {
|
|
397
|
+
Print.info(`Found ${serviceComponents.length} Service components (skipped - sync only affects Visual components)`);
|
|
398
|
+
}
|
|
399
|
+
|
|
349
400
|
Print.newLine();
|
|
350
|
-
Print.subtitle(`Found ${updatableComponents.length} updatable components:`);
|
|
401
|
+
Print.subtitle(`Found ${updatableComponents.length} updatable Visual components:`);
|
|
351
402
|
Print.newLine();
|
|
352
403
|
updatableComponents.forEach(comp => {
|
|
353
|
-
|
|
354
|
-
console.log(`${icon} ${comp.name} (${comp.category})`);
|
|
404
|
+
console.log(`🎨 ${comp.name} (${comp.category})`);
|
|
355
405
|
});
|
|
356
406
|
|
|
357
407
|
if (!force) {
|
|
@@ -359,7 +409,7 @@ class ComponentRegistry {
|
|
|
359
409
|
{
|
|
360
410
|
type: 'confirm',
|
|
361
411
|
name: 'confirmUpdate',
|
|
362
|
-
message: `Do you want to update
|
|
412
|
+
message: `Do you want to update these Visual components to the repository versions?`,
|
|
363
413
|
default: true
|
|
364
414
|
}
|
|
365
415
|
]);
|
|
@@ -370,38 +420,32 @@ class ComponentRegistry {
|
|
|
370
420
|
}
|
|
371
421
|
}
|
|
372
422
|
|
|
373
|
-
//
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
// Update Visual components
|
|
380
|
-
if (visualComponents.length > 0) {
|
|
381
|
-
Print.info(`Updating ${visualComponents.length} Visual components...`);
|
|
382
|
-
const visualResults = await this.installMultipleComponents(visualComponents, 'Visual', true);
|
|
383
|
-
allResults = allResults.concat(visualResults);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
// Update Service components
|
|
387
|
-
if (serviceComponents.length > 0) {
|
|
388
|
-
Print.info(`Updating ${serviceComponents.length} Service components...`);
|
|
389
|
-
const serviceResults = await this.installMultipleComponents(serviceComponents, 'Service', true);
|
|
390
|
-
allResults = allResults.concat(serviceResults);
|
|
391
|
-
}
|
|
423
|
+
// ✅ SIMPLIFICADO: Solo actualizar componentes Visual
|
|
424
|
+
const visualComponentNames = updatableComponents.map(c => c.name);
|
|
425
|
+
|
|
426
|
+
Print.info(`Updating ${visualComponentNames.length} Visual components...`);
|
|
427
|
+
const results = await this.installMultipleComponents(visualComponentNames, 'Visual', true);
|
|
392
428
|
|
|
393
429
|
// Final summary
|
|
394
|
-
const totalSuccessful =
|
|
395
|
-
const totalFailed =
|
|
430
|
+
const totalSuccessful = results.filter(r => r.success).length;
|
|
431
|
+
const totalFailed = results.filter(r => !r.success).length;
|
|
396
432
|
|
|
397
433
|
Print.newLine();
|
|
398
|
-
Print.title('
|
|
399
|
-
Print.success(`
|
|
434
|
+
Print.title('Visual Components Sync Summary');
|
|
435
|
+
Print.success(`Visual components updated: ${totalSuccessful}`);
|
|
400
436
|
|
|
401
437
|
if (totalFailed > 0) {
|
|
402
|
-
Print.error(`
|
|
438
|
+
Print.error(`Visual components failed: ${totalFailed}`);
|
|
403
439
|
} else {
|
|
404
|
-
Print.success('All your components are now updated to the latest official versions!');
|
|
440
|
+
Print.success('All your Visual components are now updated to the latest official versions!');
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Información adicional sobre Service components
|
|
444
|
+
if (serviceComponents.length > 0) {
|
|
445
|
+
Print.newLine();
|
|
446
|
+
Print.info(`Note: ${serviceComponents.length} Service components were found but not updated`);
|
|
447
|
+
Print.info('Service components maintain manual versioning - update them individually if needed');
|
|
448
|
+
Print.commandExample('Update Service component manually', 'slice get FetchManager --service --force');
|
|
405
449
|
}
|
|
406
450
|
|
|
407
451
|
return totalFailed === 0;
|
|
@@ -418,20 +462,31 @@ class ComponentRegistry {
|
|
|
418
462
|
const visualComponents = this.getAvailableComponents('Visual');
|
|
419
463
|
const serviceComponents = this.getAvailableComponents('Service');
|
|
420
464
|
|
|
465
|
+
// ✅ SIMPLIFICADO: Solo mostrar nombres sin descripciones
|
|
421
466
|
Print.info('🎨 Visual Components (UI):');
|
|
422
|
-
Object.
|
|
423
|
-
|
|
467
|
+
Object.keys(visualComponents).forEach(name => {
|
|
468
|
+
const files = visualComponents[name].files;
|
|
469
|
+
const fileIcons = files.map(file => {
|
|
470
|
+
if (file.endsWith('.js')) return '📜';
|
|
471
|
+
if (file.endsWith('.html')) return '🌐';
|
|
472
|
+
if (file.endsWith('.css')) return '🎨';
|
|
473
|
+
return '📄';
|
|
474
|
+
}).join(' ');
|
|
475
|
+
console.log(` • ${name} ${fileIcons}`);
|
|
424
476
|
});
|
|
425
477
|
|
|
426
478
|
Print.info('\n⚙️ Service Components (Logic):');
|
|
427
|
-
Object.
|
|
428
|
-
console.log(` • ${name}
|
|
479
|
+
Object.keys(serviceComponents).forEach(name => {
|
|
480
|
+
console.log(` • ${name} 📜`);
|
|
429
481
|
});
|
|
430
482
|
|
|
483
|
+
Print.newLine();
|
|
484
|
+
Print.info(`Total: ${Object.keys(visualComponents).length} Visual + ${Object.keys(serviceComponents).length} Service components`);
|
|
485
|
+
|
|
431
486
|
console.log(`\n💡 Ejemplos de uso:`);
|
|
432
|
-
console.log(`
|
|
433
|
-
console.log(`
|
|
434
|
-
console.log(`
|
|
487
|
+
console.log(`slice get Button Card Input # Obtener componentes Visual`);
|
|
488
|
+
console.log(`slice get FetchManager --service # Obtener componente Service`);
|
|
489
|
+
console.log(`slice sync # Sincronizar componentes Visual`);
|
|
435
490
|
}
|
|
436
491
|
|
|
437
492
|
async interactiveInstall() {
|
|
@@ -448,8 +503,8 @@ class ComponentRegistry {
|
|
|
448
503
|
]);
|
|
449
504
|
|
|
450
505
|
const availableComponents = this.getAvailableComponents(componentType);
|
|
451
|
-
const componentChoices = Object.
|
|
452
|
-
name:
|
|
506
|
+
const componentChoices = Object.keys(availableComponents).map(name => ({
|
|
507
|
+
name: name,
|
|
453
508
|
value: name
|
|
454
509
|
}));
|
|
455
510
|
|
|
@@ -552,7 +607,7 @@ async function getComponents(componentNames = [], options = {}) {
|
|
|
552
607
|
|
|
553
608
|
if (!componentInfo) {
|
|
554
609
|
Print.error(`Component '${componentNames[0]}' not found in official repository`);
|
|
555
|
-
Print.commandExample('View available components', '
|
|
610
|
+
Print.commandExample('View available components', 'slice browse');
|
|
556
611
|
return false;
|
|
557
612
|
}
|
|
558
613
|
|