slicejs-cli 2.1.5 → 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();
@@ -10,12 +10,31 @@ import Print from "../Print.js";
10
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
11
 
12
12
  // Base URL del repositorio de documentación de Slice.js
13
- const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/main/src/Components';
14
- const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/main/src/Components/components.js';
13
+ const DOCS_REPO_BASE_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/master/src/Components';
14
+ const COMPONENTS_REGISTRY_URL = 'https://raw.githubusercontent.com/VKneider/slicejs_docs/master/src/Components/components.js';
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
+ };
15
33
 
16
34
  class ComponentRegistry {
17
35
  constructor() {
18
36
  this.componentsRegistry = null;
37
+ this.config = loadConfig();
19
38
  }
20
39
 
21
40
  async loadRegistry() {
@@ -48,6 +67,7 @@ class ComponentRegistry {
48
67
 
49
68
  async getLocalComponents() {
50
69
  try {
70
+ // ✅ CAMBIO: Usar ruta dinámica basada en sliceConfig.json
51
71
  const componentsPath = path.join(__dirname, '../../../src/Components/components.js');
52
72
 
53
73
  if (!await fs.pathExists(componentsPath)) {
@@ -75,9 +95,14 @@ class ComponentRegistry {
75
95
  Object.entries(localComponents).forEach(([name, category]) => {
76
96
  // Check if component exists in remote registry
77
97
  if (this.componentsRegistry[name] && this.componentsRegistry[name] === category) {
78
- // Check if local component directory exists
98
+ // Check if local component directory exists using dynamic paths
79
99
  const categoryPath = validations.getCategoryPath(category);
80
- 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);
81
106
 
82
107
  if (fs.pathExistsSync(componentPath)) {
83
108
  updatableComponents.push({
@@ -182,6 +207,7 @@ class ComponentRegistry {
182
207
  }
183
208
 
184
209
  async updateLocalRegistry(componentName, category) {
210
+ // ✅ CAMBIO PRINCIPAL: Usar ruta dinámica basada en sliceConfig.json
185
211
  const componentsPath = path.join(__dirname, '../../../src/Components/components.js');
186
212
 
187
213
  try {
@@ -234,7 +260,12 @@ class ComponentRegistry {
234
260
  }
235
261
 
236
262
  const categoryPath = validations.getCategoryPath(category);
237
- 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);
238
269
 
239
270
  // Check if component already exists
240
271
  if (await fs.pathExists(targetPath) && !force) {
@@ -264,7 +295,7 @@ class ComponentRegistry {
264
295
  await this.updateLocalRegistry(componentName, category);
265
296
 
266
297
  Print.success(`${componentName} updated successfully from official repository!`);
267
- console.log(`📁 Location: src/${categoryPath}/${componentName}/`);
298
+ console.log(`📁 Location: ${folderSuffix}/${categoryPath}/${componentName}/`);
268
299
  console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
269
300
 
270
301
  return true;
@@ -565,7 +596,7 @@ async function listComponents() {
565
596
  }
566
597
  }
567
598
 
568
- // Sync components function - NEW
599
+ // Sync components function
569
600
  async function syncComponents(options = {}) {
570
601
  const registry = new ComponentRegistry();
571
602
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "2.1.5",
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": {