slicejs-cli 2.1.10 → 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
|
|
|
@@ -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
|
}
|
|
@@ -420,20 +462,31 @@ class ComponentRegistry {
|
|
|
420
462
|
const visualComponents = this.getAvailableComponents('Visual');
|
|
421
463
|
const serviceComponents = this.getAvailableComponents('Service');
|
|
422
464
|
|
|
465
|
+
// ✅ SIMPLIFICADO: Solo mostrar nombres sin descripciones
|
|
423
466
|
Print.info('🎨 Visual Components (UI):');
|
|
424
|
-
Object.
|
|
425
|
-
|
|
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}`);
|
|
426
476
|
});
|
|
427
477
|
|
|
428
478
|
Print.info('\n⚙️ Service Components (Logic):');
|
|
429
|
-
Object.
|
|
430
|
-
console.log(` • ${name}
|
|
479
|
+
Object.keys(serviceComponents).forEach(name => {
|
|
480
|
+
console.log(` • ${name} 📜`);
|
|
431
481
|
});
|
|
432
482
|
|
|
483
|
+
Print.newLine();
|
|
484
|
+
Print.info(`Total: ${Object.keys(visualComponents).length} Visual + ${Object.keys(serviceComponents).length} Service components`);
|
|
485
|
+
|
|
433
486
|
console.log(`\n💡 Ejemplos de uso:`);
|
|
434
|
-
console.log(`
|
|
435
|
-
console.log(`
|
|
436
|
-
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`);
|
|
437
490
|
}
|
|
438
491
|
|
|
439
492
|
async interactiveInstall() {
|
|
@@ -450,8 +503,8 @@ class ComponentRegistry {
|
|
|
450
503
|
]);
|
|
451
504
|
|
|
452
505
|
const availableComponents = this.getAvailableComponents(componentType);
|
|
453
|
-
const componentChoices = Object.
|
|
454
|
-
name:
|
|
506
|
+
const componentChoices = Object.keys(availableComponents).map(name => ({
|
|
507
|
+
name: name,
|
|
455
508
|
value: name
|
|
456
509
|
}));
|
|
457
510
|
|
|
@@ -554,7 +607,7 @@ async function getComponents(componentNames = [], options = {}) {
|
|
|
554
607
|
|
|
555
608
|
if (!componentInfo) {
|
|
556
609
|
Print.error(`Component '${componentNames[0]}' not found in official repository`);
|
|
557
|
-
Print.commandExample('View available components', '
|
|
610
|
+
Print.commandExample('View available components', 'slice browse');
|
|
558
611
|
return false;
|
|
559
612
|
}
|
|
560
613
|
|