@mckit/schematics 0.0.9 → 0.0.11
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/package.json +1 -1
- package/src/add-table/files/__class__.component.html.template +14 -0
- package/src/add-table/files/__class__.component.scss.template +0 -0
- package/src/add-table/files/__class__.component.ts.template +39 -0
- package/src/add-table/index.d.ts +7 -0
- package/src/add-table/index.js +52 -0
- package/src/add-table/index.js.map +1 -0
- package/src/add-table/schema.json +26 -0
- package/src/collection.json +5 -0
- package/src/core/create-file-with-template.d.ts +4 -0
- package/src/core/create-file-with-template.js +21 -0
- package/src/core/create-file-with-template.js.map +1 -0
- package/src/core/get-properties-by-class.d.ts +6 -0
- package/src/core/get-properties-by-class.js +30 -0
- package/src/core/get-properties-by-class.js.map +1 -0
- package/src/install-layout-fuse/files/app.component.ts.template +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<mc-odata-page
|
|
2
|
+
[breadcrumb]="breadcrumb"
|
|
3
|
+
[title]="'Title page'"
|
|
4
|
+
[subtitle]="'Description of page'"
|
|
5
|
+
[key]="'{{className}}'"
|
|
6
|
+
[httpService]="httpService"
|
|
7
|
+
[columns]="columns"
|
|
8
|
+
[searchFieldsKey]="searchFieldsKey" >
|
|
9
|
+
|
|
10
|
+
<ng-template mcTdTemplate="actions" let-row>
|
|
11
|
+
<mc-actions-column [item]="row" (onEdit)="onClickEdit($event)" (onRemove)="onClickRemove($event)"></mc-actions-column>
|
|
12
|
+
</ng-template>
|
|
13
|
+
|
|
14
|
+
</mc-odata-page>
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { Component, inject, OnInit, viewChild } from '@angular/core';
|
|
3
|
+
import { MCOdataPage } from '@mckit/odata';
|
|
4
|
+
import { MenuItem } from 'primeng/api';
|
|
5
|
+
import { Observable, of } from 'rxjs';
|
|
6
|
+
import { ButtonModule } from 'primeng/button';
|
|
7
|
+
import { MCActionsColumn, MCTdTemplateDirective, MCThTemplateDirective } from '@mckit/table';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'app-{{className}}',
|
|
11
|
+
imports: [CommonModule, MCOdataPage, ButtonModule, MCThTemplateDirective, MCTdTemplateDirective, MCActionsColumn],
|
|
12
|
+
templateUrl: './{{className}}.component.html',
|
|
13
|
+
styleUrl: './{{className}}.component.scss'
|
|
14
|
+
})
|
|
15
|
+
export class {{classNameCamel}} implements OnInit {
|
|
16
|
+
|
|
17
|
+
odataPage = viewChild(MCOdataPage);
|
|
18
|
+
|
|
19
|
+
breadcrumb: MenuItem[] = [
|
|
20
|
+
{ label: 'Home', routerLink: '/' },
|
|
21
|
+
{ label: '{{classNameCamel}}' }
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
httpService = inject(TestService);
|
|
25
|
+
|
|
26
|
+
columns = [
|
|
27
|
+
{{columns}}
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
searchFieldsKey = ['title'];
|
|
31
|
+
|
|
32
|
+
onClickEdit(item: any) {
|
|
33
|
+
// this.router.navigate(['edit', item.id], { relativeTo: this.route });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onClickRemove(item: any) {
|
|
37
|
+
this.odataPage()?.onClickRemove(item);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addTable = addTable;
|
|
4
|
+
const run_command_1 = require("../core/run-command");
|
|
5
|
+
const create_file_with_template_1 = require("../core/create-file-with-template");
|
|
6
|
+
const get_properties_by_class_1 = require("../core/get-properties-by-class");
|
|
7
|
+
function addTable(_options) {
|
|
8
|
+
return (tree, _context) => {
|
|
9
|
+
if (!_options.name) {
|
|
10
|
+
throw new Error('El parámetro "name" es obligatorio.');
|
|
11
|
+
}
|
|
12
|
+
if (!_options.component) {
|
|
13
|
+
throw new Error('El parámetro "component" es obligatorio.');
|
|
14
|
+
}
|
|
15
|
+
// Install the required dependencies
|
|
16
|
+
(0, run_command_1.runCommand)('npm install --save @mckit/table @mckit/odata @mckit/filter @mckit/layout-core', _context);
|
|
17
|
+
// Obtener path y nombre del component
|
|
18
|
+
let pathComponent = _options.component.split('/');
|
|
19
|
+
let nameComponent = pathComponent.pop();
|
|
20
|
+
let path = pathComponent.join('/');
|
|
21
|
+
// Convertir nombre de la clase CamelCase a PascalCase
|
|
22
|
+
let classNameCamel = nameComponent;
|
|
23
|
+
// Convertir nombre de la clase CamelCase a kebab-case
|
|
24
|
+
let classNameKebab = classNameCamel.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
25
|
+
// Convertir nombre de la clase CamelCase a snake_case
|
|
26
|
+
//let classNameSnake = classNameCamel.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1_$2').toLowerCase();
|
|
27
|
+
// Get properties by class
|
|
28
|
+
let classProperty = (0, get_properties_by_class_1.getPropertiesByClass)(tree, _options.name);
|
|
29
|
+
// Create HTML file
|
|
30
|
+
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}.component.html`, '__class__.component.html.template', {
|
|
31
|
+
'className': classNameKebab
|
|
32
|
+
});
|
|
33
|
+
// Create SCSS file
|
|
34
|
+
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}.component.scss`, '__class__.component.scss.template', {
|
|
35
|
+
'className': classNameKebab
|
|
36
|
+
});
|
|
37
|
+
// Generate content for columns variable
|
|
38
|
+
let columns = '';
|
|
39
|
+
classProperty.properties.forEach((property) => {
|
|
40
|
+
columns += `{ field: '${property}', title: '${property}' },`;
|
|
41
|
+
});
|
|
42
|
+
columns += "{ field: 'actions', title: 'Actions' }";
|
|
43
|
+
// Create TS file
|
|
44
|
+
(0, create_file_with_template_1.createFileWithTemplate)(tree, __dirname, `${path}/${classNameKebab}.component.ts`, '__class__.component.ts.template', {
|
|
45
|
+
'className': classNameKebab,
|
|
46
|
+
'classNameCamel': classNameCamel,
|
|
47
|
+
'columns': columns
|
|
48
|
+
});
|
|
49
|
+
return tree;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAUA,4BAuDC;AAhED,qDAAiD;AACjD,iFAA2E;AAC3E,6EAAkF;AAOlF,SAAgB,QAAQ,CAAC,QAAuB;IAC9C,OAAO,CAAC,IAAU,EAAE,QAA0B,EAAE,EAAE;QAEhD,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;QAED,oCAAoC;QACpC,IAAA,wBAAU,EAAC,+EAA+E,EAAE,QAAQ,CAAC,CAAC;QAEtG,sCAAsC;QACtC,IAAI,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,aAAa,GAAG,aAAa,CAAC,GAAG,EAAE,CAAC;QACxC,IAAI,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEnC,sDAAsD;QACtD,IAAI,cAAc,GAAG,aAAc,CAAC;QACpC,sDAAsD;QACtD,IAAI,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QACnG,sDAAsD;QACtD,qGAAqG;QAErG,0BAA0B;QAC1B,IAAI,aAAa,GAAc,IAAA,8CAAoB,EAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEzE,mBAAmB;QACnB,IAAA,kDAAsB,EAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,cAAc,iBAAiB,EAAE,mCAAmC,EAAE;YACvH,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAC;QAEH,mBAAmB;QACnB,IAAA,kDAAsB,EAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,cAAc,iBAAiB,EAAE,mCAAmC,EAAE;YACvH,WAAW,EAAE,cAAc;SAC5B,CAAC,CAAC;QAEH,wCAAwC;QACxC,IAAI,OAAO,GAAG,EAAE,CAAC;QACjB,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC5C,OAAO,IAAI,aAAa,QAAQ,cAAc,QAAQ,MAAM,CAAC;QAC/D,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,wCAAwC,CAAC;QAEpD,iBAAiB;QACjB,IAAA,kDAAsB,EAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,IAAI,cAAc,eAAe,EAAE,iCAAiC,EAAE;YACnH,WAAW,EAAE,cAAc;YAC3B,gBAAgB,EAAE,cAAc;YAChC,SAAS,EAAE,OAAO;SACnB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "addTable",
|
|
4
|
+
"title": "Add Table",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Nombre de la entidad",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"component": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Ruta donde se creara el component",
|
|
18
|
+
"$default": {
|
|
19
|
+
"$source": "argv",
|
|
20
|
+
"index": 1
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": ["name", "component"]
|
|
25
|
+
}
|
|
26
|
+
|
package/src/collection.json
CHANGED
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"install-layout-fuse": {
|
|
17
17
|
"description": "Install layout fuse",
|
|
18
18
|
"factory": "./install-layout-fuse/index#install"
|
|
19
|
+
},
|
|
20
|
+
"addTable": {
|
|
21
|
+
"description": "Add Table",
|
|
22
|
+
"factory": "./add-table/index#addTable",
|
|
23
|
+
"schema": "./add-table/schema.json"
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFileWithTemplate = createFileWithTemplate;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function createFileWithTemplate(tree, dirname, fileName, template, vars) {
|
|
7
|
+
// Verify if exist the file
|
|
8
|
+
if (tree.exists(fileName)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const filePath = path.join(dirname, 'files/' + template);
|
|
12
|
+
if (fs.existsSync(filePath)) {
|
|
13
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
14
|
+
// Replace vars
|
|
15
|
+
Object.keys(vars).forEach(key => {
|
|
16
|
+
content = content.replace(new RegExp(`{{${key}}}`, 'g'), vars[key]);
|
|
17
|
+
});
|
|
18
|
+
tree.create(fileName, content);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=create-file-with-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-file-with-template.js","sourceRoot":"","sources":["create-file-with-template.ts"],"names":[],"mappings":";;AAIA,wDAgBC;AAnBD,yBAAyB;AACzB,6BAA6B;AAE7B,SAAgB,sBAAsB,CAAC,IAAU,EAAE,OAAe,EAAE,QAAgB,EAAE,QAAgB,EAAE,IAA+B;IACrI,2BAA2B;IAC3B,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;IACzD,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAChD,eAAe;QACf,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPropertiesByClass = getPropertiesByClass;
|
|
4
|
+
const ts = require("typescript");
|
|
5
|
+
function getPropertiesByClass(tree, filePath) {
|
|
6
|
+
const file = tree.read(filePath);
|
|
7
|
+
if (!file) {
|
|
8
|
+
throw new Error(`El archivo ${filePath} no existe.`);
|
|
9
|
+
}
|
|
10
|
+
const fileContent = file.toString('utf-8');
|
|
11
|
+
const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);
|
|
12
|
+
let firstClass = null;
|
|
13
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
14
|
+
if (!firstClass && ts.isClassDeclaration(node) && node.name) {
|
|
15
|
+
const className = node.name.text;
|
|
16
|
+
const properties = [];
|
|
17
|
+
node.members.forEach((member) => {
|
|
18
|
+
if (ts.isPropertyDeclaration(member) && member.name) {
|
|
19
|
+
properties.push(member.name.getText());
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
firstClass = { name: className, properties };
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (firstClass == undefined || firstClass == null) {
|
|
26
|
+
throw new Error(`No se encontró ninguna clase en el archivo ${filePath}`);
|
|
27
|
+
}
|
|
28
|
+
return firstClass;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=get-properties-by-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-properties-by-class.js","sourceRoot":"","sources":["get-properties-by-class.ts"],"names":[],"mappings":";;AAQA,oDAiCC;AAxCD,iCAAiC;AAOjC,SAAgB,oBAAoB,CAAC,IAAU,EAAE,QAAgB;IAE7D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,cAAc,QAAQ,aAAa,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE5F,IAAI,UAAU,GAAqB,IAAI,CAAC;IAExC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE;QACjC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACjC,MAAM,UAAU,GAAa,EAAE,CAAC;YAEhC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;gBAC5B,IAAI,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;oBAClD,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC3C,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,UAAU,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;QACjD,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAG,UAAU,IAAI,SAAS,IAAE,UAAU,IAAI,IAAI,EAAC,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,8CAA8C,QAAQ,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { MCIconToggleSidebarButton } from '@mckit/layout';
|
|
|
5
5
|
import { MCImage, MCMenu, MCSubtitle } from '@mckit/core';
|
|
6
6
|
import { FooterComponent } from './layout/footer/footer.component';
|
|
7
7
|
import { MCAvatarWithMenu } from '@mckit/auth';
|
|
8
|
+
import { MenuItem } from 'primeng/api';
|
|
8
9
|
|
|
9
10
|
@Component({
|
|
10
11
|
selector: 'app-root',
|