slicejs-cli 2.2.8 → 2.3.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/client.js +1 -1
- package/commands/getComponent/getComponent.js +81 -31
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -39,32 +39,62 @@ class ComponentRegistry {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async loadRegistry() {
|
|
42
|
-
|
|
42
|
+
Print.info('Loading component registry from official repository...');
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const response = await fetch(COMPONENTS_REGISTRY_URL);
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
49
|
-
}
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
49
|
+
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
const content = await response.text();
|
|
52
|
+
|
|
53
|
+
// Parse the components.js file content
|
|
54
|
+
const match = content.match(/const components = ({[\s\S]*?});/);
|
|
55
|
+
if (!match) {
|
|
56
|
+
throw new Error('Invalid components.js format from repository');
|
|
57
|
+
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
const allComponents = eval('(' + match[1] + ')');
|
|
60
|
+
|
|
61
|
+
// ✅ NUEVO: FILTRAR solo componentes Visual y Service
|
|
62
|
+
this.componentsRegistry = this.filterOfficialComponents(allComponents);
|
|
63
|
+
|
|
64
|
+
Print.success('Component registry loaded successfully');
|
|
65
|
+
|
|
66
|
+
} catch (error) {
|
|
67
|
+
Print.error(`Loading component registry: ${error.message}`);
|
|
68
|
+
Print.info('Check your internet connection and repository accessibility');
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Filtra el registry para incluir SOLO componentes de categorías Visual y Service
|
|
75
|
+
* Excluye AppComponents y cualquier otra categoría
|
|
76
|
+
* @param {object} allComponents - Objeto con todos los componentes del registry
|
|
77
|
+
* @returns {object} - Objeto filtrado solo con Visual y Service
|
|
78
|
+
*/
|
|
79
|
+
filterOfficialComponents(allComponents) {
|
|
80
|
+
const filtered = {};
|
|
81
|
+
let excludedCount = 0;
|
|
82
|
+
|
|
83
|
+
Object.entries(allComponents).forEach(([name, category]) => {
|
|
84
|
+
// Solo incluir componentes de categoría Visual o Service
|
|
85
|
+
if (category === 'Visual' || category === 'Service') {
|
|
86
|
+
filtered[name] = category;
|
|
87
|
+
} else {
|
|
88
|
+
excludedCount++;
|
|
66
89
|
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (excludedCount > 0) {
|
|
93
|
+
Print.info(`Filtered out ${excludedCount} non-Visual/Service components from registry`);
|
|
67
94
|
}
|
|
95
|
+
|
|
96
|
+
return filtered;
|
|
97
|
+
}
|
|
68
98
|
|
|
69
99
|
async getLocalComponents() {
|
|
70
100
|
try {
|
|
@@ -287,19 +317,39 @@ class ComponentRegistry {
|
|
|
287
317
|
}
|
|
288
318
|
|
|
289
319
|
async installComponent(componentName, category, force = false) {
|
|
290
|
-
|
|
320
|
+
const availableComponents = this.getAvailableComponents(category);
|
|
321
|
+
|
|
322
|
+
if (!availableComponents[componentName]) {
|
|
323
|
+
throw new Error(`Componente '${componentName}' no encontrado en la categoría '${category}' del repositorio oficial`);
|
|
324
|
+
}
|
|
291
325
|
|
|
292
|
-
|
|
293
|
-
|
|
326
|
+
// ✅ MEJORADO: Detectar si validations tiene acceso a la configuración
|
|
327
|
+
let categoryPath;
|
|
328
|
+
const hasValidConfig = validations.config &&
|
|
329
|
+
validations.config.paths &&
|
|
330
|
+
validations.config.paths.components &&
|
|
331
|
+
validations.config.paths.components[category];
|
|
332
|
+
|
|
333
|
+
if (hasValidConfig) {
|
|
334
|
+
// Usar validations cuando la config está disponible
|
|
335
|
+
categoryPath = validations.getCategoryPath(category);
|
|
336
|
+
} else {
|
|
337
|
+
// Usar rutas por defecto cuando no hay config (durante init o error)
|
|
338
|
+
if (category === 'Visual') {
|
|
339
|
+
categoryPath = '/Components/Visual';
|
|
340
|
+
} else if (category === 'Service') {
|
|
341
|
+
categoryPath = '/Components/Service';
|
|
342
|
+
} else {
|
|
343
|
+
throw new Error(`Unknown category: ${category}`);
|
|
294
344
|
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const isProduction = this.config?.production?.enabled === true;
|
|
348
|
+
const folderSuffix = isProduction ? 'dist' : 'src';
|
|
349
|
+
|
|
350
|
+
const targetPath = path.join(__dirname, `../../../../${folderSuffix}`, categoryPath, componentName);
|
|
351
|
+
|
|
295
352
|
|
|
296
|
-
const categoryPath = validations.getCategoryPath(category);
|
|
297
|
-
|
|
298
|
-
// ✅ CORREGIDO: Usar 4 niveles para compatibilidad con node_modules
|
|
299
|
-
const isProduction = this.config?.production?.enabled === true;
|
|
300
|
-
const folderSuffix = isProduction ? 'dist' : 'src';
|
|
301
|
-
|
|
302
|
-
const targetPath = path.join(__dirname, `../../../../${folderSuffix}`, categoryPath, componentName);
|
|
303
353
|
|
|
304
354
|
// Check if component already exists
|
|
305
355
|
if (await fs.pathExists(targetPath) && !force) {
|