ngx-essentials-schematics 0.0.4 → 0.0.6
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 -1
- package/src/ngrx/store/schema.d.ts +10 -0
package/package.json
CHANGED
package/src/ngrx/store/index.js
CHANGED
|
@@ -3,6 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.signalStore = signalStore;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
+
const pluralizeEs = (name) => {
|
|
7
|
+
if (!name)
|
|
8
|
+
return name;
|
|
9
|
+
const lastChar = name.slice(-1).toLowerCase();
|
|
10
|
+
const vowels = ["a", "e", "i", "o", "u"];
|
|
11
|
+
if (vowels.includes(lastChar))
|
|
12
|
+
return name + "s";
|
|
13
|
+
if (lastChar === "z")
|
|
14
|
+
return name.slice(0, -1) + "ces";
|
|
15
|
+
return name + "es";
|
|
16
|
+
};
|
|
17
|
+
const pluralizeEn = (name) => {
|
|
18
|
+
if (!name)
|
|
19
|
+
return name;
|
|
20
|
+
const lastChar = name.slice(-1).toLowerCase();
|
|
21
|
+
const vowels = ["a", "e", "i", "o", "u"];
|
|
22
|
+
if (lastChar === "y" && !vowels.includes(name.slice(-2, -1).toLowerCase())) {
|
|
23
|
+
return name.slice(0, -1) + "ies";
|
|
24
|
+
}
|
|
25
|
+
if (["s", "x", "z", "ch", "sh"].some((end) => name.toLowerCase().endsWith(end))) {
|
|
26
|
+
return name + "es";
|
|
27
|
+
}
|
|
28
|
+
return name + "s";
|
|
29
|
+
};
|
|
6
30
|
/**
|
|
7
31
|
* Genera un Signal Store profesional para Angular 20
|
|
8
32
|
* @param {SchemaOptions} options - Opciones del esquema
|
|
@@ -32,7 +56,14 @@ function signalStore(options) {
|
|
|
32
56
|
(0, schematics_1.move)(defaultPath + "/common/form"),
|
|
33
57
|
]);
|
|
34
58
|
const templateStoreSource = (0, schematics_1.apply)((0, schematics_1.url)("./files/store"), [
|
|
35
|
-
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options))
|
|
59
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { pluralize: (word) => {
|
|
60
|
+
switch (options.language) {
|
|
61
|
+
case "es":
|
|
62
|
+
return pluralizeEs(word);
|
|
63
|
+
default:
|
|
64
|
+
return pluralizeEn(word);
|
|
65
|
+
}
|
|
66
|
+
} })),
|
|
36
67
|
(0, schematics_1.move)(movePath + `/${core_1.strings.dasherize(options.name)}`),
|
|
37
68
|
]);
|
|
38
69
|
return (0, schematics_1.chain)([
|
|
@@ -8,4 +8,14 @@ export interface SchemaOptions {
|
|
|
8
8
|
* La ruta donde se generará el archivo.
|
|
9
9
|
*/
|
|
10
10
|
path?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Indica si se deben generar archivos adicionales para formularios y entidades.
|
|
14
|
+
*/
|
|
15
|
+
generateExtras?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* El idioma para la pluralización ('en' para inglés, 'es' para español).
|
|
19
|
+
*/
|
|
20
|
+
language?: "en" | "es";
|
|
11
21
|
}
|