slicejs-cli 2.1.7 → 2.1.8

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 CHANGED
@@ -317,4 +317,10 @@ program.on('command:*', () => {
317
317
  process.exit(1);
318
318
  });
319
319
 
320
+ //CREATE HELP Command
321
+ const helpCommand = sliceClient.command("help").description("Display help information for Slice.js CLI").action(() => {
322
+ sliceClient.outputHelp();
323
+ }
324
+ );
325
+
320
326
  program.parse();
@@ -13,10 +13,28 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
13
  const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/master/src/Components';
14
14
  const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/master/src/Components/components.js';
15
15
 
16
+ /**
17
+ * Carga la configuración desde sliceConfig.json
18
+ * @returns {object} - Objeto de configuración
19
+ */
20
+ const loadConfig = () => {
21
+ try {
22
+ const configPath = path.join(__dirname, '../../../src/sliceConfig.json');
23
+ if (!fs.existsSync(configPath)) {
24
+ throw new Error('sliceConfig.json not found in src folder');
25
+ }
26
+ const rawData = fs.readFileSync(configPath, 'utf-8');
27
+ return JSON.parse(rawData);
28
+ } catch (error) {
29
+ console.error(`Error loading configuration: ${error.message}`);
30
+ return null;
31
+ }
32
+ };
16
33
 
17
34
  class ComponentRegistry {
18
35
  constructor() {
19
36
  this.componentsRegistry = null;
37
+ this.config = loadConfig();
20
38
  }
21
39
 
22
40
  async loadRegistry() {
@@ -49,6 +67,7 @@ class ComponentRegistry {
49
67
 
50
68
  async getLocalComponents() {
51
69
  try {
70
+ // ✅ CAMBIO: Usar ruta dinámica basada en sliceConfig.json
52
71
  const componentsPath = path.join(__dirname, '../../../src/Components/components.js');
53
72
 
54
73
  if (!await fs.pathExists(componentsPath)) {
@@ -76,9 +95,14 @@ class ComponentRegistry {
76
95
  Object.entries(localComponents).forEach(([name, category]) => {
77
96
  // Check if component exists in remote registry
78
97
  if (this.componentsRegistry[name] && this.componentsRegistry[name] === category) {
79
- // Check if local component directory exists
98
+ // Check if local component directory exists using dynamic paths
80
99
  const categoryPath = validations.getCategoryPath(category);
81
- const componentPath = path.join(__dirname, '../../../src', categoryPath, name);
100
+
101
+ // ✅ CAMBIO: Determinar si estamos en modo producción
102
+ const isProduction = this.config?.production?.enabled === true;
103
+ const folderSuffix = isProduction ? 'dist' : 'src';
104
+
105
+ const componentPath = path.join(__dirname, `../../../${folderSuffix}`, categoryPath, name);
82
106
 
83
107
  if (fs.pathExistsSync(componentPath)) {
84
108
  updatableComponents.push({
@@ -183,6 +207,7 @@ class ComponentRegistry {
183
207
  }
184
208
 
185
209
  async updateLocalRegistry(componentName, category) {
210
+ // ✅ CAMBIO PRINCIPAL: Usar ruta dinámica basada en sliceConfig.json
186
211
  const componentsPath = path.join(__dirname, '../../../src/Components/components.js');
187
212
 
188
213
  try {
@@ -235,7 +260,12 @@ class ComponentRegistry {
235
260
  }
236
261
 
237
262
  const categoryPath = validations.getCategoryPath(category);
238
- const targetPath = path.join(__dirname, '../../../src', categoryPath, componentName);
263
+
264
+ // ✅ CAMBIO: Usar configuración dinámica para determinar la ruta base
265
+ const isProduction = this.config?.production?.enabled === true;
266
+ const folderSuffix = isProduction ? 'dist' : 'src';
267
+
268
+ const targetPath = path.join(__dirname, `../../../${folderSuffix}`, categoryPath, componentName);
239
269
 
240
270
  // Check if component already exists
241
271
  if (await fs.pathExists(targetPath) && !force) {
@@ -265,7 +295,7 @@ class ComponentRegistry {
265
295
  await this.updateLocalRegistry(componentName, category);
266
296
 
267
297
  Print.success(`${componentName} updated successfully from official repository!`);
268
- console.log(`📁 Location: src/${categoryPath}/${componentName}/`);
298
+ console.log(`📁 Location: ${folderSuffix}/${categoryPath}/${componentName}/`);
269
299
  console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
270
300
 
271
301
  return true;
@@ -566,7 +596,7 @@ async function listComponents() {
566
596
  }
567
597
  }
568
598
 
569
- // Sync components function - NEW
599
+ // Sync components function
570
600
  async function syncComponents(options = {}) {
571
601
  const registry = new ComponentRegistry();
572
602
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "scripts": {