slicejs-cli 2.3.0 → 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.
@@ -39,32 +39,62 @@ class ComponentRegistry {
39
39
  }
40
40
 
41
41
  async loadRegistry() {
42
- Print.info('Loading component registry from official repository...');
42
+ Print.info('Loading component registry from official repository...');
43
+
44
+ try {
45
+ const response = await fetch(COMPONENTS_REGISTRY_URL);
43
46
 
44
- try {
45
- const response = await fetch(COMPONENTS_REGISTRY_URL);
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
- 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
- }
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
- this.componentsRegistry = eval('(' + match[1] + ')');
60
- Print.success('Component registry loaded successfully');
61
-
62
- } catch (error) {
63
- Print.error(`Loading component registry: ${error.message}`);
64
- Print.info('Check your internet connection and repository accessibility');
65
- throw error;
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
- const availableComponents = this.getAvailableComponents(category);
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
- if (!availableComponents[componentName]) {
293
- throw new Error(`Componente '${componentName}' no encontrado en la categoría '${category}' del repositorio oficial`);
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "scripts": {