slicejs-cli 2.1.7 → 2.1.9

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,29 @@ 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
+ // ✅ CORREGIDO: Usar 4 niveles como en listComponents para compatibilidad con node_modules
23
+ const configPath = path.join(__dirname, '../../../../src/sliceConfig.json');
24
+ if (!fs.existsSync(configPath)) {
25
+ throw new Error('sliceConfig.json not found in src folder');
26
+ }
27
+ const rawData = fs.readFileSync(configPath, 'utf-8');
28
+ return JSON.parse(rawData);
29
+ } catch (error) {
30
+ console.error(`Error loading configuration: ${error.message}`);
31
+ return null;
32
+ }
33
+ };
16
34
 
17
35
  class ComponentRegistry {
18
36
  constructor() {
19
37
  this.componentsRegistry = null;
38
+ this.config = loadConfig();
20
39
  }
21
40
 
22
41
  async loadRegistry() {
@@ -49,7 +68,8 @@ class ComponentRegistry {
49
68
 
50
69
  async getLocalComponents() {
51
70
  try {
52
- const componentsPath = path.join(__dirname, '../../../src/Components/components.js');
71
+ // CORREGIDO: Usar 4 niveles como en listComponents para compatibilidad con node_modules
72
+ const componentsPath = path.join(__dirname, '../../../../src/Components/components.js');
53
73
 
54
74
  if (!await fs.pathExists(componentsPath)) {
55
75
  return {};
@@ -76,9 +96,14 @@ class ComponentRegistry {
76
96
  Object.entries(localComponents).forEach(([name, category]) => {
77
97
  // Check if component exists in remote registry
78
98
  if (this.componentsRegistry[name] && this.componentsRegistry[name] === category) {
79
- // Check if local component directory exists
99
+ // Check if local component directory exists using dynamic paths
80
100
  const categoryPath = validations.getCategoryPath(category);
81
- const componentPath = path.join(__dirname, '../../../src', categoryPath, name);
101
+
102
+ // ✅ CORREGIDO: Usar 4 niveles para compatibilidad con node_modules
103
+ const isProduction = this.config?.production?.enabled === true;
104
+ const folderSuffix = isProduction ? 'dist' : 'src';
105
+
106
+ const componentPath = path.join(__dirname, `../../../../${folderSuffix}`, categoryPath, name);
82
107
 
83
108
  if (fs.pathExistsSync(componentPath)) {
84
109
  updatableComponents.push({
@@ -183,7 +208,8 @@ class ComponentRegistry {
183
208
  }
184
209
 
185
210
  async updateLocalRegistry(componentName, category) {
186
- const componentsPath = path.join(__dirname, '../../../src/Components/components.js');
211
+ // CORREGIDO: Usar 4 niveles para compatibilidad con node_modules
212
+ const componentsPath = path.join(__dirname, '../../../../src/Components/components.js');
187
213
 
188
214
  try {
189
215
  let content = await fs.readFile(componentsPath, 'utf8');
@@ -235,7 +261,12 @@ class ComponentRegistry {
235
261
  }
236
262
 
237
263
  const categoryPath = validations.getCategoryPath(category);
238
- const targetPath = path.join(__dirname, '../../../src', categoryPath, componentName);
264
+
265
+ // ✅ CORREGIDO: Usar 4 niveles para compatibilidad con node_modules
266
+ const isProduction = this.config?.production?.enabled === true;
267
+ const folderSuffix = isProduction ? 'dist' : 'src';
268
+
269
+ const targetPath = path.join(__dirname, `../../../../${folderSuffix}`, categoryPath, componentName);
239
270
 
240
271
  // Check if component already exists
241
272
  if (await fs.pathExists(targetPath) && !force) {
@@ -243,7 +274,7 @@ class ComponentRegistry {
243
274
  {
244
275
  type: 'confirm',
245
276
  name: 'overwrite',
246
- message: `El componente '${componentName}' ya existe localmente. ¿Deseas sobrescribirlo con la versión del repositorio?`,
277
+ message: `The component '${componentName}' already exists locally. Do you really want to overwrite your own version for the repository version?`,
247
278
  default: false
248
279
  }
249
280
  ]);
@@ -265,7 +296,7 @@ class ComponentRegistry {
265
296
  await this.updateLocalRegistry(componentName, category);
266
297
 
267
298
  Print.success(`${componentName} updated successfully from official repository!`);
268
- console.log(`📁 Location: src/${categoryPath}/${componentName}/`);
299
+ console.log(`📁 Location: ${folderSuffix}/${categoryPath}/${componentName}/`);
269
300
  console.log(`📄 Files: ${downloadedFiles.join(', ')}`);
270
301
 
271
302
  return true;
@@ -566,7 +597,7 @@ async function listComponents() {
566
597
  }
567
598
  }
568
599
 
569
- // Sync components function - NEW
600
+ // Sync components function
570
601
  async function syncComponents(options = {}) {
571
602
  const registry = new ComponentRegistry();
572
603
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "2.1.7",
3
+ "version": "2.1.9",
4
4
  "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "scripts": {