slicejs-cli 1.0.46 → 1.0.49
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
|
@@ -23,6 +23,7 @@ sliceClient
|
|
|
23
23
|
.description('Create a new component')
|
|
24
24
|
.option('-category <category>', 'Specify the category of the component')
|
|
25
25
|
.option('-properties <properties>', 'Specify properties for the component (comma-separated)')
|
|
26
|
+
.option('-methods <methods>', 'Specify methods for the component (comma-separated)')
|
|
26
27
|
.action((componentName, options) => {
|
|
27
28
|
const { Category, Properties } = options;
|
|
28
29
|
const propertiesList = Properties ? Properties.split(',') : [];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export default
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default class componentTemplates{
|
|
2
|
+
|
|
3
|
+
static visual(componentName, props){
|
|
4
|
+
const propGettersSetters = props.map(prop => `
|
|
4
5
|
get ${prop}() {
|
|
5
6
|
return this._${prop};
|
|
6
7
|
}
|
|
@@ -26,5 +27,25 @@ export default function componentTemplate(componentName, props) {
|
|
|
26
27
|
|
|
27
28
|
customElements.define("slice-${componentName.toLowerCase()}", ${componentName});
|
|
28
29
|
`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static service(componentName, methods) {
|
|
33
|
+
const methodDefinitions = methods.map(method => `
|
|
34
|
+
${method}() {}
|
|
35
|
+
`).join('\n');
|
|
36
|
+
|
|
37
|
+
return `export default class ${componentName} {
|
|
38
|
+
constructor(props) {
|
|
39
|
+
// Constructor
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
init() {
|
|
43
|
+
// Método init
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
${methodDefinitions}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
}
|
|
29
50
|
}
|
|
30
51
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import
|
|
2
|
+
import componentTemplates from './VisualComponentTemplate.js';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
@@ -31,7 +31,15 @@ function createComponent(componentName, category, properties) {
|
|
|
31
31
|
// Crear el nombre de la clase y del archivo
|
|
32
32
|
const className = componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
33
33
|
const fileName = `${className}.js`;
|
|
34
|
-
|
|
34
|
+
let template;
|
|
35
|
+
|
|
36
|
+
if(category==='Visual'){
|
|
37
|
+
template = componentTemplates.visual(className, properties);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if(category==='Service'){
|
|
41
|
+
template = componentTemplates.service(className, properties);
|
|
42
|
+
}
|
|
35
43
|
|
|
36
44
|
//RUTA PARA CUANDO SE COLOQUE DE USUARIO
|
|
37
45
|
// ../../../../src/Components
|
|
@@ -7,8 +7,8 @@ import Print from '../Print.js';
|
|
|
7
7
|
export default function listComponents() {
|
|
8
8
|
|
|
9
9
|
const SlicePath = path.join(__dirname, '../../../../Slice/Components');
|
|
10
|
-
const userVisualComponents = fs.readdirSync('../../../../src/Components/Visual');
|
|
11
|
-
const userServices = fs.readdirSync('../../../../src/Components/Service');
|
|
10
|
+
const userVisualComponents = fs.readdirSync(__dirname,'../../../../src/Components/Visual');
|
|
11
|
+
const userServices = fs.readdirSync(__dirname,'../../../../src/Components/Service');
|
|
12
12
|
|
|
13
13
|
const visualComponents = fs.readdirSync(`${SlicePath}/Visual`);
|
|
14
14
|
const services = fs.readdirSync(`${SlicePath}/Service`);
|