ngx-essentials-schematics 0.0.7 → 0.0.9
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/ngrx/store/index.js +32 -14
- package/src/ngrx/store/schema.d.ts +1 -1
- package/src/ngrx/store/schema.json +12 -1
package/package.json
CHANGED
package/src/ngrx/store/index.js
CHANGED
|
@@ -53,25 +53,44 @@ function mergeFilesSmart(urlPath, destPath, options) {
|
|
|
53
53
|
}),
|
|
54
54
|
]));
|
|
55
55
|
}
|
|
56
|
-
let treeRef;
|
|
56
|
+
let treeRef;
|
|
57
57
|
function signalStore(options) {
|
|
58
58
|
return (tree) => {
|
|
59
59
|
treeRef = tree;
|
|
60
|
-
const
|
|
61
|
-
const movePath = (0, core_1.normalize)(options.path || defaultPath);
|
|
62
|
-
// 1. Manejo del Index Principal (Export)
|
|
60
|
+
const movePath = (0, core_1.normalize)(options.path);
|
|
63
61
|
const indexPath = (0, core_1.join)(movePath, "index.ts");
|
|
64
|
-
const
|
|
62
|
+
const nameDash = core_1.strings.dasherize(options.name);
|
|
63
|
+
const entityName = core_1.strings.classify(options.name);
|
|
64
|
+
const entityHeader = `/** ${entityName.toUpperCase()} **/`;
|
|
65
|
+
const exportBlock = [
|
|
66
|
+
entityHeader,
|
|
67
|
+
`export * from './${nameDash}/${nameDash}.model';`,
|
|
68
|
+
`export * from './${nameDash}/${nameDash}.service';`,
|
|
69
|
+
`export * from './${nameDash}/${nameDash}.store';`,
|
|
70
|
+
"",
|
|
71
|
+
].join("\n");
|
|
72
|
+
let content = "";
|
|
65
73
|
if (tree.exists(indexPath)) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
content = tree.read(indexPath).toString();
|
|
75
|
+
}
|
|
76
|
+
if (content.includes(entityHeader)) {
|
|
77
|
+
const lines = exportBlock.split("\n");
|
|
78
|
+
lines.forEach((line) => {
|
|
79
|
+
if (line.trim() !== "" && !content.includes(line)) {
|
|
80
|
+
content += line + "\n";
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
content =
|
|
86
|
+
content.trim() + (content.length > 0 ? "\n\n" : "") + exportBlock;
|
|
87
|
+
}
|
|
88
|
+
if (tree.exists(indexPath)) {
|
|
89
|
+
tree.overwrite(indexPath, content);
|
|
70
90
|
}
|
|
71
91
|
else {
|
|
72
|
-
tree.create(indexPath,
|
|
92
|
+
tree.create(indexPath, content);
|
|
73
93
|
}
|
|
74
|
-
// 2. Archivos de la Store (Estos se crean siempre en carpeta nueva)
|
|
75
94
|
const templateStoreSource = (0, schematics_1.apply)((0, schematics_1.url)("./files/store"), [
|
|
76
95
|
(0, schematics_1.applyTemplates)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { pluralize: (word) => {
|
|
77
96
|
switch (options.language) {
|
|
@@ -83,9 +102,8 @@ function signalStore(options) {
|
|
|
83
102
|
} })),
|
|
84
103
|
(0, schematics_1.move)((0, core_1.join)(movePath, core_1.strings.dasherize(options.name))),
|
|
85
104
|
]);
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const commonFormRule = mergeFilesSmart("./files/form", (0, core_1.join)((0, core_1.normalize)(defaultPath), "common/form"), options);
|
|
105
|
+
const commonEntityRule = mergeFilesSmart("./files/entity", (0, core_1.join)(movePath, "common/entity"), options);
|
|
106
|
+
const commonFormRule = mergeFilesSmart("./files/form", (0, core_1.join)(movePath, "common/form"), options);
|
|
89
107
|
return (0, schematics_1.chain)([
|
|
90
108
|
(0, schematics_1.mergeWith)(templateStoreSource),
|
|
91
109
|
commonEntityRule,
|
|
@@ -13,7 +13,18 @@
|
|
|
13
13
|
"path": {
|
|
14
14
|
"type": "string",
|
|
15
15
|
"description": "Ruta de destino.",
|
|
16
|
-
"default": "src/app/
|
|
16
|
+
"default": "src/app/core"
|
|
17
|
+
},
|
|
18
|
+
"generateExtras": {
|
|
19
|
+
"type": "boolean",
|
|
20
|
+
"description": "¿Generar archivos adicionales para formularios y entidades?",
|
|
21
|
+
"default": false
|
|
22
|
+
},
|
|
23
|
+
"language": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Idioma para la pluralización ('en' para inglés, 'es' para español).",
|
|
26
|
+
"enum": ["en", "es"],
|
|
27
|
+
"default": "en"
|
|
17
28
|
}
|
|
18
29
|
},
|
|
19
30
|
"required": ["name"]
|