slicejs-cli 2.0.12 → 2.0.14
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 +10 -0
- package/commands/Validations.js +2 -1
- package/package.json +1 -1
- package/post.js +7 -4
package/client.js
CHANGED
|
@@ -13,6 +13,8 @@ import validations from "./commands/Validations.js";
|
|
|
13
13
|
|
|
14
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
15
|
|
|
16
|
+
|
|
17
|
+
|
|
16
18
|
const loadConfig = () => {
|
|
17
19
|
try {
|
|
18
20
|
const configPath = path.join(__dirname, "../../src/sliceConfig.json");
|
|
@@ -36,6 +38,14 @@ sliceClient.version("1.0.0").description("CLI for managing framework components"
|
|
|
36
38
|
// COMPONENT COMMAND GROUP
|
|
37
39
|
const componentCommand = sliceClient.command("component").description("Manage components");
|
|
38
40
|
|
|
41
|
+
//create init command
|
|
42
|
+
sliceClient
|
|
43
|
+
.command("init")
|
|
44
|
+
.description("Initialize a new SliceJS project")
|
|
45
|
+
.action(() => {
|
|
46
|
+
initializeProject();
|
|
47
|
+
});
|
|
48
|
+
|
|
39
49
|
// CREATE COMPONENT
|
|
40
50
|
componentCommand
|
|
41
51
|
.command("create")
|
package/commands/Validations.js
CHANGED
|
@@ -65,8 +65,9 @@ class Validations {
|
|
|
65
65
|
|
|
66
66
|
const fileContent = fs.readFileSync(componentFilePath, 'utf-8');
|
|
67
67
|
const components = eval(fileContent.replace('export default', '')); // Evalúa el contenido como objeto
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
return components.hasOwnProperty(componentName);
|
|
70
|
+
|
|
70
71
|
} catch (error) {
|
|
71
72
|
console.error('❌ Error al verificar el componente:', error);
|
|
72
73
|
return false;
|
package/package.json
CHANGED
package/post.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
|
|
4
|
+
import Print from './commands/Print.js';
|
|
5
5
|
import initializeProject from './commands/init/init.js';
|
|
6
6
|
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -25,6 +25,7 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
25
25
|
projectPackageJson.scripts['slice:create'] = 'node node_modules/slicejs-cli/client.js component create';
|
|
26
26
|
projectPackageJson.scripts['slice:list'] = 'node node_modules/slicejs-cli/client.js component list';
|
|
27
27
|
projectPackageJson.scripts['slice:delete'] = 'node node_modules/slicejs-cli/client.js component delete';
|
|
28
|
+
projectPackageJson.scripts['slice:init'] = 'node node_modules/slicejs-cli/client.js init';
|
|
28
29
|
projectPackageJson.scripts['run'] = 'node api/index.js';
|
|
29
30
|
projectPackageJson.scripts['slice:start'] = 'node api/index.js';
|
|
30
31
|
projectPackageJson.scripts['development'] = 'node api/index.js';
|
|
@@ -37,7 +38,7 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
37
38
|
|
|
38
39
|
// Escribe el nuevo contenido en el package.json del proyecto
|
|
39
40
|
fs.promises.writeFile(projectPackageJsonPath, JSON.stringify(projectPackageJson, null, 2), 'utf8');
|
|
40
|
-
return
|
|
41
|
+
return Print.success("Run 'npm run slice:init' to initialize your project");
|
|
41
42
|
})
|
|
42
43
|
.then(() => {
|
|
43
44
|
console.log('SliceJS CLI commands added to package.json.');
|
|
@@ -55,7 +56,8 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
55
56
|
'slice:list': 'node node_modules/slicejs-cli/client.js component list',
|
|
56
57
|
'slice:delete': 'node node_modules/slicejs-cli/client.js component delete',
|
|
57
58
|
"run": "node api/index.js",
|
|
58
|
-
"slice:start": "node api/index.js"
|
|
59
|
+
"slice:start": "node api/index.js",
|
|
60
|
+
"slice:init": "node node_modules/slicejs-cli/client.js init"
|
|
59
61
|
},
|
|
60
62
|
keywords: [],
|
|
61
63
|
author: '',
|
|
@@ -67,7 +69,7 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
67
69
|
};
|
|
68
70
|
// Guardamos el nuevo package.json
|
|
69
71
|
fs.promises.writeFile(projectPackageJsonPath, JSON.stringify(defaultPackageJson, null, 2), 'utf8');
|
|
70
|
-
return
|
|
72
|
+
return Print.success("Run 'npm run slice:init' to initialize your project");
|
|
71
73
|
} else {
|
|
72
74
|
console.error('Error:', err);
|
|
73
75
|
}
|
|
@@ -79,3 +81,4 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
79
81
|
console.error('Error:', err);
|
|
80
82
|
})
|
|
81
83
|
|
|
84
|
+
|