slicejs-cli 1.0.43 → 1.0.45
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/commands/Validations.js
CHANGED
|
@@ -11,7 +11,6 @@ export default class Validations{
|
|
|
11
11
|
const categoryVariations = {
|
|
12
12
|
'Service': ['service', 'servicio', 'serv', 's'],
|
|
13
13
|
'Visual': ['visual', 'vis', 'v'],
|
|
14
|
-
'Provider': ['provider', 'proveedor', 'prov' , 'p'],
|
|
15
14
|
'Structural': ['structural', 'estructural', 'est', 'st']
|
|
16
15
|
};
|
|
17
16
|
|
|
@@ -10,7 +10,6 @@ export default function listComponents() {
|
|
|
10
10
|
|
|
11
11
|
const visualComponents = fs.readdirSync(`${SlicePath}/Visual`);
|
|
12
12
|
const services = fs.readdirSync(`${SlicePath}/Service`);
|
|
13
|
-
const providers = fs.readdirSync(`${SlicePath}/Provider`);
|
|
14
13
|
const structuralComponents = fs.readdirSync(`${SlicePath}/Structural`)
|
|
15
14
|
|
|
16
15
|
|
|
@@ -24,10 +23,6 @@ export default function listComponents() {
|
|
|
24
23
|
componentMap.set(component, "Service");
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
providers.forEach(component => {
|
|
28
|
-
componentMap.set(component, "Provider");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
26
|
structuralComponents.forEach(component => {
|
|
32
27
|
componentMap.set(component, "Structural");
|
|
33
28
|
});
|
package/package.json
CHANGED
package/post.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
1
|
import fs from 'fs';
|
|
3
2
|
import { fileURLToPath } from 'url';
|
|
4
3
|
import path from 'path';
|
|
5
4
|
|
|
6
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
6
|
const __dirname = path.dirname(__filename);
|
|
8
|
-
|
|
7
|
+
const projectName = path.basename(__dirname); // Obtiene el nombre de la carpeta actual
|
|
8
|
+
|
|
9
9
|
const projectPackageJsonPath = path.resolve(__dirname, '../../package.json');
|
|
10
10
|
|
|
11
|
-
//
|
|
12
|
-
fs.promises.
|
|
11
|
+
// Verifica si el archivo package.json existe
|
|
12
|
+
fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
13
|
+
.then(() => {
|
|
14
|
+
// El archivo package.json existe, por lo que lo leemos y agregamos los comandos
|
|
15
|
+
return fs.promises.readFile(projectPackageJsonPath, 'utf8');
|
|
16
|
+
})
|
|
13
17
|
.then(data => {
|
|
14
18
|
// Convierte el contenido del archivo a un objeto JSON
|
|
15
19
|
const projectPackageJson = JSON.parse(data);
|
|
@@ -26,7 +30,35 @@ fs.promises.readFile(projectPackageJsonPath, 'utf8')
|
|
|
26
30
|
return fs.promises.writeFile(projectPackageJsonPath, JSON.stringify(projectPackageJson, null, 2), 'utf8');
|
|
27
31
|
})
|
|
28
32
|
.then(() => {
|
|
29
|
-
console.log('
|
|
33
|
+
console.log('SliceJS CLI commands added to package.json.');
|
|
34
|
+
})
|
|
35
|
+
.catch(err => {
|
|
36
|
+
if (err.code === 'ENOENT') {
|
|
37
|
+
// El archivo package.json no existe, así que creamos uno nuevo con los comandos
|
|
38
|
+
const defaultPackageJson = {
|
|
39
|
+
name: "project-name", // Utiliza el nombre de la carpeta como nombre del proyecto
|
|
40
|
+
version: '1.0.0',
|
|
41
|
+
description: 'Project description',
|
|
42
|
+
main: 'index.js',
|
|
43
|
+
scripts: {
|
|
44
|
+
'slice:init': 'node node_modules/slicejs-cli/client.js init',
|
|
45
|
+
'slice:create': 'node node_modules/slicejs-cli/client.js create',
|
|
46
|
+
'slice:modify': 'node node_modules/slicejs-cli/client.js modify',
|
|
47
|
+
'slice:list': 'node node_modules/slicejs-cli/client.js list',
|
|
48
|
+
'slice:delete': 'node node_modules/slicejs-cli/client.js delete'
|
|
49
|
+
},
|
|
50
|
+
keywords: [],
|
|
51
|
+
author: '',
|
|
52
|
+
license: 'ISC'
|
|
53
|
+
};
|
|
54
|
+
// Guardamos el nuevo package.json
|
|
55
|
+
return fs.promises.writeFile(projectPackageJsonPath, JSON.stringify(defaultPackageJson, null, 2), 'utf8');
|
|
56
|
+
} else {
|
|
57
|
+
console.error('Error:', err);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.then(() => {
|
|
61
|
+
console.log('Created package.json with SliceJS CLI commands.');
|
|
30
62
|
})
|
|
31
63
|
.catch(err => {
|
|
32
64
|
console.error('Error:', err);
|