slicejs-cli 1.0.35 → 1.0.37

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
@@ -27,9 +27,7 @@ sliceClient
27
27
  .action((componentName, options) => {
28
28
  const { Category, Properties } = options;
29
29
  const propertiesList = Properties ? Properties.split(',') : [];
30
- createComponent(componentName, Category, propertiesList);
31
- listComponents();
32
-
30
+ if( createComponent(componentName, Category, propertiesList)) listComponents();
33
31
  });
34
32
 
35
33
  // Comando para modificar un componente
@@ -43,7 +41,7 @@ sliceClient
43
41
  const { Add, Remove,Category } = options;
44
42
  const addProperties = Add ? Add.split(',') : [];
45
43
  const removeProperties = Remove ? Remove.split(',') : [];
46
- modifyComponent(componentName,Category, addProperties, removeProperties);
44
+ modifyComponent(componentName,Category, addProperties, removeProperties)
47
45
  });
48
46
 
49
47
  sliceClient.command('delete <componentName>')
@@ -51,8 +49,7 @@ sliceClient
51
49
  .option('-category <category>', 'Component category')
52
50
  .action((componentName, options) => {
53
51
  const { Category } = options;
54
- deleteComponent(componentName, Category);
55
- listComponents();
52
+ if(deleteComponent(componentName, Category)) listComponents();
56
53
  });
57
54
 
58
55
  // Comando para listar todos los componentes
@@ -4,18 +4,18 @@ import fs from 'fs-extra';
4
4
  import path from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import Validations from '../Validations.js';
7
-
7
+ import Print from '../Print.js';
8
8
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
9
9
 
10
10
  function createComponent(componentName, category, properties) {
11
11
 
12
12
  if (!componentName) {
13
- console.error('Component name is required');
13
+ Print.error('Component name is required');
14
14
  return;
15
15
  }
16
16
 
17
17
  if (!Validations.isValidComponentName(componentName)) {
18
- console.error('Invalid component name. Please use only alphanumeric characters and start with a letter.');
18
+ Print.error('Invalid component name. Please use only alphanumeric characters and start with a letter.');
19
19
  return;
20
20
  }
21
21
 
@@ -23,7 +23,7 @@ function createComponent(componentName, category, properties) {
23
23
 
24
24
 
25
25
  if (!flagCategory.isValid) {
26
- console.error('Invalid category. Please use one of the following categories: Service, Visual, Provider, Structural');
26
+ Print.error('Invalid category. Please use one of the following categories: Service, Visual, Provider, Structural');
27
27
  return;
28
28
  }
29
29
  category = flagCategory.category;
@@ -46,7 +46,7 @@ function createComponent(componentName, category, properties) {
46
46
 
47
47
  // Verificar si el archivo ya existe
48
48
  if (fs.existsSync(componentPath)) {
49
- console.error(`Component '${componentName}' already exists.`);
49
+ Print.error(`Component '${componentName}' already exists.`);
50
50
  return;
51
51
  }
52
52
 
@@ -55,7 +55,8 @@ function createComponent(componentName, category, properties) {
55
55
  fs.writeFileSync(`${componentDir}/${className}.css`, '');
56
56
  fs.writeFileSync(`${componentDir}/${className}.html`, '');
57
57
 
58
- console.log(`Component '${componentName}' created successfully.`);
58
+ Print.success(`Component '${componentName}' created successfully.`);
59
+ return true;
59
60
  }
60
61
 
61
62
 
@@ -1,24 +1,24 @@
1
1
  import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import Validations from '../Validations.js';
4
-
4
+ import Print from '../Print.js';
5
5
  const __dirname = path.dirname(new URL(import.meta.url).pathname);
6
6
 
7
7
  function deleteComponent(componentName, category) {
8
8
  if (!componentName) {
9
- console.error('Component name is required');
9
+ Print.error('Component name is required');
10
10
  return;
11
11
  }
12
12
 
13
13
  if (!Validations.isValidComponentName(componentName)) {
14
- console.error('Invalid component name. Please use only alphanumeric characters and start with a letter.');
14
+ Print.error('Invalid component name. Please use only alphanumeric characters and start with a letter.');
15
15
  return;
16
16
  }
17
17
 
18
18
  let flagCategory = Validations.isValidCategory(category);
19
19
 
20
20
  if (!flagCategory.isValid) {
21
- console.error('Invalid category. Please use one of the following categories: Service, Visual, Provider, Structural');
21
+ Print.error('Invalid category. Please use one of the following categories: Service, Visual, Provider, Structural');
22
22
  return;
23
23
  }
24
24
  category = flagCategory.category;
@@ -29,14 +29,15 @@ function deleteComponent(componentName, category) {
29
29
 
30
30
  // Verificar si el directorio del componente existe
31
31
  if (!fs.existsSync(componentDir)) {
32
- console.error(`Component '${componentName}' does not exist.`);
32
+ Print.error(`Component '${componentName}' does not exist.`);
33
33
  return;
34
34
  }
35
35
 
36
36
  // Eliminar el directorio del componente y su contenido
37
37
  fs.removeSync(componentDir);
38
38
 
39
- console.log(`Component '${componentName}' deleted successfully.`);
39
+ Print.success(`Component '${componentName}' deleted successfully.`);
40
+ return true;
40
41
  }
41
42
 
42
43
  export default deleteComponent;
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
-
4
+ import Print from '../Print.js';
5
5
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
6
 
7
7
  export default async function initializeProject(projectType) {
@@ -18,16 +18,16 @@ export default async function initializeProject(projectType) {
18
18
 
19
19
  // Verificar si el directorio de destino ya existe
20
20
  if (fs.existsSync(destinationDir)) {
21
- console.error('El proyecto ya cuenta con un directorio "Slice". No es posible inicializar el proyecto nuevamente');
21
+ Print.error('El proyecto ya cuenta con un directorio "Slice". No es posible inicializar el proyecto nuevamente');
22
22
  return;
23
23
  }
24
24
 
25
25
  // Copiar el contenido del directorio de origen al directorio de destino
26
26
  await fs.copy(sliceDir, destinationDir, { recursive: true });
27
27
 
28
- console.log('Proyecto inicializado correctamente.');
28
+ Print.success('Proyecto inicializado correctamente.');
29
29
  } catch (error) {
30
- console.error('Error al inicializar el proyecto:', error);
30
+ Print.error('Error al inicializar el proyecto:', error);
31
31
  }
32
32
  }
33
33
 
@@ -3,7 +3,7 @@ import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
5
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
-
6
+ import Print from '../Print.js';
7
7
  export default function listComponents() {
8
8
 
9
9
  const SlicePath = path.join(__dirname, '../../../../Slice/Components');
@@ -37,5 +37,5 @@ export default function listComponents() {
37
37
  const mapObject = Object.fromEntries(mapAsArray);
38
38
 
39
39
  fs.writeFileSync(`${SlicePath}/components.js`, `const components = ${JSON.stringify(mapObject, null, 2)}; export default components;`);
40
- console.log('Components list updated');
40
+ Print.success('Components list updated');
41
41
  }
@@ -15,7 +15,7 @@ function modifyComponent(componentName, category, addProperties, removePropertie
15
15
  return;
16
16
  }
17
17
 
18
-
18
+
19
19
 
20
20
 
21
21
  let flagCategory = Validations.isValidCategory(category);
@@ -45,27 +45,27 @@ function modifyComponent(componentName, category, addProperties, removePropertie
45
45
  addProperties.forEach(property => {
46
46
  if (!existingProperties.includes(property)) {
47
47
  existingProperties.push(property);
48
- console.log(`Property '${property}' added to component '${componentName}'.`);
48
+ Print.success(`Property '${property}' added to component '${componentName}'.`);
49
49
  // Verificar si existen getters y setters para la propiedad y agregarlos si es necesario
50
50
  componentContent = addGetterSetterIfNeeded(componentContent, property);
51
51
  } else {
52
- console.log(`Property '${property}' already exists in component '${componentName}'.`);
52
+ Print.error(`Property '${property}' already exists in component '${componentName}'.`);
53
53
  }
54
54
  });
55
55
 
56
56
  removeProperties.forEach(property => {
57
57
  if (existingProperties.includes(property)) {
58
58
  existingProperties = existingProperties.filter(prop => prop !== property);
59
- console.log(`Property '${property}' removed from component '${componentName}'.`);
59
+ Print.success(`Property '${property}' removed from component '${componentName}'.`);
60
60
  componentContent = removePropertyIfNeeded(componentContent, property);
61
61
  } else {
62
- console.log(`Property '${property}' does not exist in component '${componentName}'.`);
62
+ Print.error(`Property '${property}' does not exist in component '${componentName}'.`);
63
63
  }
64
64
  });
65
65
 
66
66
  componentContent = updateComponentProps(componentContent, existingProperties);
67
67
  fs.writeFileSync(componentPath, componentContent);
68
- console.log(`Component '${componentName}' modified successfully.`);
68
+ Print.success(`Component '${componentName}' modified successfully.`);
69
69
  }
70
70
 
71
71
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "slicejs-cli",
3
- "version": "1.0.35",
4
- "description": "Command client for developing web applications with Slice.js",
3
+ "version": "1.0.37",
4
+ "description": "Command client for developing web applications with Slice.js framework",
5
5
  "main": "client.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",