slicejs-cli 1.0.35 → 1.0.36
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.
|
@@ -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
|
-
|
|
13
|
+
Print.error('Component name is required');
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
if (!Validations.isValidComponentName(componentName)) {
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
+
Print.error(`Component '${componentName}' already exists.`);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ function createComponent(componentName, category, properties) {
|
|
|
55
55
|
fs.writeFileSync(`${componentDir}/${className}.css`, '');
|
|
56
56
|
fs.writeFileSync(`${componentDir}/${className}.html`, '');
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
Print.success(`Component '${componentName}' created successfully.`);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
@@ -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
|
-
|
|
9
|
+
Print.error('Component name is required');
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (!Validations.isValidComponentName(componentName)) {
|
|
14
|
-
|
|
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
|
-
|
|
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,14 @@ function deleteComponent(componentName, category) {
|
|
|
29
29
|
|
|
30
30
|
// Verificar si el directorio del componente existe
|
|
31
31
|
if (!fs.existsSync(componentDir)) {
|
|
32
|
-
|
|
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
|
-
|
|
39
|
+
Print.success(`Component '${componentName}' deleted successfully.`);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export default deleteComponent;
|
package/commands/init/init.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
28
|
+
Print.success('Proyecto inicializado correctamente.');
|
|
29
29
|
} catch (error) {
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59
|
+
Print.success(`Property '${property}' removed from component '${componentName}'.`);
|
|
60
60
|
componentContent = removePropertyIfNeeded(componentContent, property);
|
|
61
61
|
} else {
|
|
62
|
-
|
|
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
|
-
|
|
68
|
+
Print.success(`Component '${componentName}' modified successfully.`);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
|