angular-generate 2.2.1
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/README.md +149 -0
- package/explication_conception.md +119 -0
- package/package.json +28 -0
- package/src/api/index.d.ts +2 -0
- package/src/api/index.js +18 -0
- package/src/api/index.js.map +1 -0
- package/src/api/index_spec.d.ts +1 -0
- package/src/api/index_spec.js +23 -0
- package/src/api/index_spec.js.map +1 -0
- package/src/api/schema.json +17 -0
- package/src/collection.json +88 -0
- package/src/component/add/index.d.ts +2 -0
- package/src/component/add/index.js +64 -0
- package/src/component/add/index.js.map +1 -0
- package/src/component/add/index_spec.d.ts +1 -0
- package/src/component/add/index_spec.js +23 -0
- package/src/component/add/index_spec.js.map +1 -0
- package/src/component/deconnexion/index.d.ts +2 -0
- package/src/component/deconnexion/index.js +88 -0
- package/src/component/deconnexion/index.js.map +1 -0
- package/src/component/deconnexion/index_spec.d.ts +1 -0
- package/src/component/deconnexion/index_spec.js +23 -0
- package/src/component/deconnexion/index_spec.js.map +1 -0
- package/src/component/details/index.d.ts +2 -0
- package/src/component/details/index.js +12 -0
- package/src/component/details/index.js.map +1 -0
- package/src/component/details/index_spec.d.ts +1 -0
- package/src/component/details/index_spec.js +23 -0
- package/src/component/details/index_spec.js.map +1 -0
- package/src/component/edit/index.d.ts +2 -0
- package/src/component/edit/index.js +63 -0
- package/src/component/edit/index.js.map +1 -0
- package/src/component/edit/index_spec.d.ts +1 -0
- package/src/component/edit/index_spec.js +23 -0
- package/src/component/edit/index_spec.js.map +1 -0
- package/src/component/header/index.d.ts +2 -0
- package/src/component/header/index.js +311 -0
- package/src/component/header/index.js.map +1 -0
- package/src/component/list/index.d.ts +2 -0
- package/src/component/list/index.js +64 -0
- package/src/component/list/index.js.map +1 -0
- package/src/component/list/index_spec.d.ts +1 -0
- package/src/component/list/index_spec.js +23 -0
- package/src/component/list/index_spec.js.map +1 -0
- package/src/component/login/index.d.ts +2 -0
- package/src/component/login/index.js +314 -0
- package/src/component/login/index.js.map +1 -0
- package/src/component/login/index_spec.d.ts +1 -0
- package/src/component/login/index_spec.js +23 -0
- package/src/component/login/index_spec.js.map +1 -0
- package/src/component/not-found/index.d.ts +2 -0
- package/src/component/not-found/index.js +68 -0
- package/src/component/not-found/index.js.map +1 -0
- package/src/component/not-found/index_spec.d.ts +1 -0
- package/src/component/not-found/index_spec.js +23 -0
- package/src/component/not-found/index_spec.js.map +1 -0
- package/src/component/sidebar/index.d.ts +2 -0
- package/src/component/sidebar/index.js +247 -0
- package/src/component/sidebar/index.js.map +1 -0
- package/src/component/test/index.d.ts +2 -0
- package/src/component/test/index.js +20 -0
- package/src/component/test/index.js.map +1 -0
- package/src/component/test/index_spec.d.ts +1 -0
- package/src/component/test/index_spec.js +23 -0
- package/src/component/test/index_spec.js.map +1 -0
- package/src/component/type/index.d.ts +2 -0
- package/src/component/type/index.js +45 -0
- package/src/component/type/index.js.map +1 -0
- package/src/component/type/index_spec.d.ts +1 -0
- package/src/component/type/index_spec.js +23 -0
- package/src/component/type/index_spec.js.map +1 -0
- package/src/component/wrapper/index.d.ts +2 -0
- package/src/component/wrapper/index.js +175 -0
- package/src/component/wrapper/index.js.map +1 -0
- package/src/component/wrapper/index_spec.d.ts +1 -0
- package/src/component/wrapper/index_spec.js +23 -0
- package/src/component/wrapper/index_spec.js.map +1 -0
- package/src/config/index.d.ts +2 -0
- package/src/config/index.js +166 -0
- package/src/config/index.js.map +1 -0
- package/src/config/index_spec.d.ts +1 -0
- package/src/config/index_spec.js +23 -0
- package/src/config/index_spec.js.map +1 -0
- package/src/config/schema.json +31 -0
- package/src/guard/auth/index.d.ts +2 -0
- package/src/guard/auth/index.js +60 -0
- package/src/guard/auth/index.js.map +1 -0
- package/src/guard/auth/index_spec.d.ts +1 -0
- package/src/guard/auth/index_spec.js +23 -0
- package/src/guard/auth/index_spec.js.map +1 -0
- package/src/guard/permissions/index.d.ts +2 -0
- package/src/guard/permissions/index.js +51 -0
- package/src/guard/permissions/index.js.map +1 -0
- package/src/guard/permissions/index_spec.d.ts +1 -0
- package/src/guard/permissions/index_spec.js +23 -0
- package/src/guard/permissions/index_spec.js.map +1 -0
- package/src/module/index.d.ts +2 -0
- package/src/module/index.js +94 -0
- package/src/module/index.js.map +1 -0
- package/src/module/index_spec.d.ts +1 -0
- package/src/module/index_spec.js +23 -0
- package/src/module/index_spec.js.map +1 -0
- package/src/module/schema.json +17 -0
- package/src/other/taf-add-import-to-module/index.d.ts +2 -0
- package/src/other/taf-add-import-to-module/index.js +20 -0
- package/src/other/taf-add-import-to-module/index.js.map +1 -0
- package/src/other/taf-add-import-to-module/index_spec.d.ts +1 -0
- package/src/other/taf-add-import-to-module/index_spec.js +23 -0
- package/src/other/taf-add-import-to-module/index_spec.js.map +1 -0
- package/src/service/api/index.d.ts +2 -0
- package/src/service/api/index.js +508 -0
- package/src/service/api/index.js.map +1 -0
- package/src/service/api/index_spec.d.ts +1 -0
- package/src/service/api/index_spec.js +23 -0
- package/src/service/api/index_spec.js.map +1 -0
- package/src/templates/add/add.html.d.ts +1 -0
- package/src/templates/add/add.html.js +124 -0
- package/src/templates/add/add.html.js.map +1 -0
- package/src/templates/add/add.ts.d.ts +1 -0
- package/src/templates/add/add.ts.js +112 -0
- package/src/templates/add/add.ts.js.map +1 -0
- package/src/templates/edit/edit.html.d.ts +1 -0
- package/src/templates/edit/edit.html.js +121 -0
- package/src/templates/edit/edit.html.js.map +1 -0
- package/src/templates/edit/edit.ts.d.ts +1 -0
- package/src/templates/edit/edit.ts.js +117 -0
- package/src/templates/edit/edit.ts.js.map +1 -0
- package/src/templates/list/list.html.d.ts +1 -0
- package/src/templates/list/list.html.js +98 -0
- package/src/templates/list/list.html.js.map +1 -0
- package/src/templates/list/list.ts.d.ts +2 -0
- package/src/templates/list/list.ts.js +144 -0
- package/src/templates/list/list.ts.js.map +1 -0
- package/src/templates/test/test.ts.d.ts +4 -0
- package/src/templates/test/test.ts.js +145 -0
- package/src/templates/test/test.ts.js.map +1 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
// You don't have to export the function as default. You can also have more than one rule factory
|
|
6
|
+
// per file.
|
|
7
|
+
function config(options) {
|
|
8
|
+
let les_types = ["add", "edit", "list", "details", "login", "type"];
|
|
9
|
+
// exemple de configuration
|
|
10
|
+
let Config = {
|
|
11
|
+
"projectName": "projet1.angular",
|
|
12
|
+
"style": "css",
|
|
13
|
+
"decription": "Fichier de configuration de config",
|
|
14
|
+
"config_base_url": "localhost/my_backend/config/",
|
|
15
|
+
"les_modules": [
|
|
16
|
+
{
|
|
17
|
+
"module": "home",
|
|
18
|
+
"les_tables": [
|
|
19
|
+
{ "table": "auteur" },
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"module": "public",
|
|
24
|
+
"les_tables": [
|
|
25
|
+
{ "table": "login" },
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
"forcer": false
|
|
30
|
+
};
|
|
31
|
+
return (tree) => {
|
|
32
|
+
if (options.test) { // nous sommes en test
|
|
33
|
+
console.warn("Phase de test");
|
|
34
|
+
console.log("Details= ", get_details(tree));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let tc = tree.get("config.json"); // lire le fichier config.json qui se trouve dans ton projet
|
|
38
|
+
if (!tc) {
|
|
39
|
+
console.error("Le fichier de configuration (config.json) est inexistant!");
|
|
40
|
+
console.log("Générez le avec votre backend config");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
Config = JSON.parse(tc.content.toString());
|
|
45
|
+
//console.log("config.json= ", Config)
|
|
46
|
+
let details = get_details(tree);
|
|
47
|
+
// mise à jour du style
|
|
48
|
+
Config.style = details.style;
|
|
49
|
+
// mise à jour du nom du projet
|
|
50
|
+
Config.projectName = details.projectName;
|
|
51
|
+
// mise à jour du nom du projet
|
|
52
|
+
Config.forcer = options.forcer || false;
|
|
53
|
+
}
|
|
54
|
+
// pas de module précisé
|
|
55
|
+
if (!options.module) {
|
|
56
|
+
return (0, schematics_1.chain)([
|
|
57
|
+
// création de tous les modules du fichier de configuration
|
|
58
|
+
...Config.les_modules.map((un_module) => {
|
|
59
|
+
return (0, schematics_1.schematic)("module", { module: un_module.module, projectName: Config.projectName, les_tables: un_module.les_tables, Config: Config });
|
|
60
|
+
}),
|
|
61
|
+
// mise en place de ApiService
|
|
62
|
+
(0, schematics_1.schematic)("service/api", { projectName: Config.projectName, Config: Config }),
|
|
63
|
+
// mise en place de AuthGuard
|
|
64
|
+
(0, schematics_1.schematic)("guard/auth", { projectName: Config.projectName }),
|
|
65
|
+
(0, schematics_1.schematic)("guard/permissions", { projectName: Config.projectName }),
|
|
66
|
+
// Rajout des composant pour le module home
|
|
67
|
+
(0, schematics_1.schematic)("sidebar", { projectName: Config.projectName, style: 'scss' }),
|
|
68
|
+
(0, schematics_1.schematic)("header", { projectName: Config.projectName, style: 'scss' }) // création du composant header
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
// module précisé
|
|
72
|
+
let module = options.module;
|
|
73
|
+
// recupération des details du module dans le fichier de configuration
|
|
74
|
+
let selected_module = Config.les_modules.find((un_module) => { return un_module.module == module; });
|
|
75
|
+
//console.log("selected_module= ", selected_module)
|
|
76
|
+
if (!selected_module) { // module introuvable
|
|
77
|
+
console.error("Module introuvable dans le fichier de configuration config.json");
|
|
78
|
+
let les_modules = Config.les_modules.map((un_module) => { return un_module.module; }).join(" , ");
|
|
79
|
+
console.log("Voici les modules disponibles : ", les_modules);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// pas de table précisée donc toutes les tables
|
|
83
|
+
if (!options.table) {
|
|
84
|
+
// génération du module précisé et de toutes ses table
|
|
85
|
+
return (0, schematics_1.chain)([
|
|
86
|
+
(0, schematics_1.schematic)("module", { module: module, projectName: Config.projectName, les_tables: selected_module.les_tables, Config: Config }),
|
|
87
|
+
// mise en place de ApiService
|
|
88
|
+
(0, schematics_1.schematic)("service/api", { projectName: Config.projectName, Config: Config }),
|
|
89
|
+
// mise en place de AuthGuard
|
|
90
|
+
(0, schematics_1.schematic)("guard/auth", { projectName: Config.projectName }),
|
|
91
|
+
(0, schematics_1.schematic)("guard/permissions", { projectName: Config.projectName })
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
// table précisée
|
|
95
|
+
let table = options.table;
|
|
96
|
+
// récupération de la table précisée
|
|
97
|
+
let selected_table = selected_module.les_tables.find((une_table) => { return une_table.table == table; });
|
|
98
|
+
if (!selected_table) { // table non retrouvée
|
|
99
|
+
console.error("Table inexistante dans le fichier de configuration config.json");
|
|
100
|
+
let les_tables = Config.les_modules
|
|
101
|
+
.map((un_module) => { return "Module " + un_module.module + " => " + un_module.les_tables.map((une_table) => { return une_table.table; }).join(" , "); })
|
|
102
|
+
.join("\n\t");
|
|
103
|
+
console.log("Voici les tables disponibles : \n\t", les_tables);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// table retrouvée
|
|
107
|
+
// type de composant non précisé, donc tous les types ( add, edit, list, details)
|
|
108
|
+
if (!options.type) {
|
|
109
|
+
// génération du module précisé , de la table précisée et de tous le types
|
|
110
|
+
return (0, schematics_1.chain)([
|
|
111
|
+
(0, schematics_1.schematic)("module", { module: module, projectName: Config.projectName, les_tables: [selected_table], Config: Config }),
|
|
112
|
+
// mise en place de ApiService
|
|
113
|
+
(0, schematics_1.schematic)("service/api", { projectName: Config.projectName, Config: Config }),
|
|
114
|
+
// mise en place de AuthGuard
|
|
115
|
+
(0, schematics_1.schematic)("guard/auth", { projectName: Config.projectName }),
|
|
116
|
+
(0, schematics_1.schematic)("guard/permissions", { projectName: Config.projectName })
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
// type de composant précisé
|
|
120
|
+
let type = options.type;
|
|
121
|
+
let selected_type = les_types.find((un_type) => { return un_type == type; });
|
|
122
|
+
// le type de composant est introuvable parmi ceux autorisés pour cette table
|
|
123
|
+
if (!selected_type) {
|
|
124
|
+
console.error("Type introuvable pour la table " + selected_table.table);
|
|
125
|
+
let les_types_tables = les_types.join(" , ");
|
|
126
|
+
console.log("Voici les types disponibles : ", les_types_tables);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// type trouvé
|
|
130
|
+
// génération du module précisé , de la table précisée et types précisé
|
|
131
|
+
selected_table.les_types = [selected_type];
|
|
132
|
+
return (0, schematics_1.chain)([
|
|
133
|
+
(0, schematics_1.schematic)("module", { module: module, projectName: Config.projectName, les_tables: [selected_table], Config: Config }),
|
|
134
|
+
// mise en place de ApiService
|
|
135
|
+
(0, schematics_1.schematic)("service/api", { projectName: Config.projectName, Config: Config }),
|
|
136
|
+
// mise en place de AuthGuard
|
|
137
|
+
(0, schematics_1.schematic)("guard/auth", { projectName: Config.projectName }),
|
|
138
|
+
(0, schematics_1.schematic)("guard/permissions", { projectName: Config.projectName })
|
|
139
|
+
]);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
exports.config = config;
|
|
143
|
+
function get_details(tree) {
|
|
144
|
+
var _a;
|
|
145
|
+
let resultat = { style: "css", projectName: "" };
|
|
146
|
+
const angularJsonContent = tree.read('angular.json');
|
|
147
|
+
if (angularJsonContent) {
|
|
148
|
+
//console.log("contenu angularJSON")
|
|
149
|
+
// Convertir le contenu en objet JSON
|
|
150
|
+
const angularJson = JSON.parse(angularJsonContent.toString('utf-8'));
|
|
151
|
+
let les_projets = angularJson.projects;
|
|
152
|
+
resultat.projectName = Object.keys(les_projets)[0];
|
|
153
|
+
const un_projet = les_projets[resultat.projectName];
|
|
154
|
+
//console.log(un_projet)
|
|
155
|
+
if (un_projet.schematics && un_projet.schematics['@schematics/angular:component']) {
|
|
156
|
+
//console.log("resultat= ", resultat)
|
|
157
|
+
resultat.style = ((_a = un_projet.schematics['@schematics/angular:component']) === null || _a === void 0 ? void 0 : _a.style) || "css";
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
resultat.style = "css";
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return resultat;
|
|
164
|
+
}
|
|
165
|
+
;
|
|
166
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAA0E;AAG1E,iGAAiG;AACjG,YAAY;AACZ,SAAgB,MAAM,CAAC,OAAY;IACjC,IAAI,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACnE,2BAA2B;IAC3B,IAAI,MAAM,GAAG;QACX,aAAa,EAAE,iBAAiB;QAChC,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,oCAAoC;QAClD,iBAAiB,EAAE,8BAA8B;QACjD,aAAa,EAAE;YACb;gBACE,QAAQ,EAAE,MAAM;gBAChB,YAAY,EAAE;oBACZ,EAAE,OAAO,EAAE,QAAQ,EAAE;iBACtB;aACF;YACD;gBACE,QAAQ,EAAE,QAAQ;gBAClB,YAAY,EAAE;oBACZ,EAAE,OAAO,EAAE,OAAO,EAAE;iBACrB;aACF;SACF;QACD,QAAQ,EAAE,KAAK;KAChB,CAAA;IAED,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,OAAO,CAAC,IAAI,EAAE,EAAC,sBAAsB;YACvC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;YAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;YAC3C,OAAM;SACP;QACD,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA,CAAA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C;AAAA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('config', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematic('config', {}, schematics_1.Tree.empty());
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index_spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAEnE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "config-schematic",
|
|
4
|
+
"title": "angular-generate générateurs de composants angular",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"module": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Nom du module dans lequel ajouter le composant"
|
|
10
|
+
},
|
|
11
|
+
"table": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "Nom de la table liée au composant"
|
|
14
|
+
},
|
|
15
|
+
"type": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Type de composant souhaité : list,add,edit,details,login,deconnexion,not-found"
|
|
18
|
+
},
|
|
19
|
+
"test": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"default": false,
|
|
22
|
+
"description": "Simulation"
|
|
23
|
+
},
|
|
24
|
+
"forcer": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"default": false,
|
|
27
|
+
"description": "Forcer la création du composant même si le fichier existe déjà"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": []
|
|
31
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.auth = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
// You don't have to export the function as default. You can also have more than one rule factory
|
|
6
|
+
// per file.
|
|
7
|
+
function auth(_options) {
|
|
8
|
+
let { projectName } = _options;
|
|
9
|
+
let guardName = "auth";
|
|
10
|
+
return (tree) => {
|
|
11
|
+
// Le composant existe dèja
|
|
12
|
+
let c_path = `/src/app/guard/${guardName}/${guardName}.guard.ts`;
|
|
13
|
+
if (tree.exists(c_path)) {
|
|
14
|
+
console.warn(`Le guard ${guardName} existe dèja : ${c_path}`);
|
|
15
|
+
return tree;
|
|
16
|
+
}
|
|
17
|
+
// le composant n'existe pas encore
|
|
18
|
+
return (0, schematics_1.chain)([
|
|
19
|
+
// création du guard
|
|
20
|
+
(0, schematics_1.externalSchematic)("@schematics/angular", "guard", { project: projectName, name: `guard/${guardName}/${guardName}`, implements: ["CanActivate"] }),
|
|
21
|
+
// modification des fichiers
|
|
22
|
+
(tree) => {
|
|
23
|
+
// modifier le fichier TS
|
|
24
|
+
tree.overwrite(`src/app/guard/${guardName}/${guardName}.guard.ts`, // guard/api/api.guard.ts
|
|
25
|
+
get_ts_content());
|
|
26
|
+
}
|
|
27
|
+
]);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.auth = auth;
|
|
31
|
+
function get_ts_content() {
|
|
32
|
+
return `import { Injectable } from '@angular/core';
|
|
33
|
+
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';
|
|
34
|
+
import { ApiService } from '../../service/api/api.service';
|
|
35
|
+
|
|
36
|
+
@Injectable({
|
|
37
|
+
providedIn: 'root'
|
|
38
|
+
})
|
|
39
|
+
export class AuthGuard implements CanActivate {
|
|
40
|
+
constructor(private api:ApiService,private routage:Router) { }
|
|
41
|
+
async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
|
|
42
|
+
// var token= await this.api.get_token()
|
|
43
|
+
var token= await this.api.get_token()
|
|
44
|
+
console.log("token on guard= ",token)
|
|
45
|
+
if (token!=undefined && token!=null) {
|
|
46
|
+
console.log("Utilisateur connecté")
|
|
47
|
+
// await this.api.update_data_from_token()
|
|
48
|
+
this.api.custom_menu();
|
|
49
|
+
return true
|
|
50
|
+
} else {
|
|
51
|
+
console.log("Utilisateur non connecté")
|
|
52
|
+
// this.routage.navigate(['/public/login'])
|
|
53
|
+
this.routage.navigate(['/public/login'], { queryParams: { returnUrl: state.url } });
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAAkF;AAGlF,iGAAiG;AACjG,YAAY;AACZ,SAAgB,IAAI,CAAC,QAAa;IAChC,IAAI,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAA;IAC9B,IAAI,SAAS,GAAG,MAAM,CAAA;IACtB,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,2BAA2B;QAC3B,IAAI,MAAM,GAAG,kBAAkB,SAAS,IAAI,SAAS,WAAW,CAAA;QAChE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC,YAAY,SAAS,kBAAkB,MAAM,EAAE,CAAC,CAAA;YAC7D,OAAO,IAAI,CAAA;SACZ;QAED,mCAAmC;QACnC,OAAO,IAAA,kBAAK,EAAC;YACX,oBAAoB;YACpB,IAAA,8BAAiB,EAAC,qBAAqB,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,SAAS,IAAI,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC;YACjJ,4BAA4B;YAC5B,CAAC,IAAU,EAAE,EAAE;gBACb,yBAAyB;gBACzB,IAAI,CAAC,SAAS,CACZ,iBAAiB,SAAS,IAAI,SAAS,WAAW,EAAE,yBAAyB;gBAC7E,cAAc,EAAE,CACjB,CAAA;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAzBD,oBAyBC;AACD,SAAS,cAAc;IACrB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BP,CAAA;AAEF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('guard/auth', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematic('guard/auth', {}, schematics_1.Tree.empty());
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index_spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAEvE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.permissions = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
// You don't have to export the function as default. You can also have more than one rule factory
|
|
6
|
+
// per file.
|
|
7
|
+
function permissions(_options) {
|
|
8
|
+
let { projectName } = _options;
|
|
9
|
+
let guardName = "permissions";
|
|
10
|
+
return (tree) => {
|
|
11
|
+
// Le composant existe dèja
|
|
12
|
+
let c_path = `/src/app/guard/${guardName}/${guardName}.guard.ts`;
|
|
13
|
+
if (tree.exists(c_path)) {
|
|
14
|
+
console.warn(`Le guard ${guardName} existe dèja : ${c_path}`);
|
|
15
|
+
return tree;
|
|
16
|
+
}
|
|
17
|
+
// le composant n'existe pas encore
|
|
18
|
+
return (0, schematics_1.chain)([
|
|
19
|
+
// création du guard
|
|
20
|
+
(0, schematics_1.externalSchematic)("@schematics/angular", "guard", { project: projectName, name: `guard/${guardName}/${guardName}`, implements: ["CanActivate"] }),
|
|
21
|
+
// modification des fichiers
|
|
22
|
+
(tree) => {
|
|
23
|
+
// modifier le fichier TS
|
|
24
|
+
tree.overwrite(`src/app/guard/${guardName}/${guardName}.guard.ts`, // guard/api/api.guard.ts
|
|
25
|
+
get_ts_content());
|
|
26
|
+
}
|
|
27
|
+
]);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.permissions = permissions;
|
|
31
|
+
function get_ts_content() {
|
|
32
|
+
return `import { inject } from '@angular/core';
|
|
33
|
+
import { CanActivateFn } from '@angular/router';
|
|
34
|
+
import { ApiService } from '../../service/api/api.service';
|
|
35
|
+
|
|
36
|
+
export const permissionsGuard: CanActivateFn = (route, state) => {
|
|
37
|
+
const service = inject(ApiService);
|
|
38
|
+
// console.warn("route -> ", state.url);
|
|
39
|
+
// console.warn("menu -> ", service.menu);
|
|
40
|
+
let decision = false
|
|
41
|
+
service.menu.map((one_menu: any) => {
|
|
42
|
+
// console.warn("one_menu split -> ", state.url.split('/'));
|
|
43
|
+
// console.warn("one_menu split -> ", state.url.split('/').slice(0, -1).join('/'));
|
|
44
|
+
decision=one_menu.items.some((sous_menu: any) => sous_menu.path == state.url);
|
|
45
|
+
});
|
|
46
|
+
// console.warn("decision -> ", decision);
|
|
47
|
+
return decision;
|
|
48
|
+
};
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAAkF;AAGlF,iGAAiG;AACjG,YAAY;AACZ,SAAgB,WAAW,CAAC,QAAa;IACvC,IAAI,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAA;IAC9B,IAAI,SAAS,GAAG,aAAa,CAAA;IAC7B,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,2BAA2B;QAC3B,IAAI,MAAM,GAAG,kBAAkB,SAAS,IAAI,SAAS,WAAW,CAAA;QAChE,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC,YAAY,SAAS,kBAAkB,MAAM,EAAE,CAAC,CAAA;YAC7D,OAAO,IAAI,CAAA;SACZ;QAED,mCAAmC;QACnC,OAAO,IAAA,kBAAK,EAAC;YACX,oBAAoB;YACpB,IAAA,8BAAiB,EAAC,qBAAqB,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,SAAS,IAAI,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC;YACjJ,4BAA4B;YAC5B,CAAC,IAAU,EAAE,EAAE;gBACb,yBAAyB;gBACzB,IAAI,CAAC,SAAS,CACZ,iBAAiB,SAAS,IAAI,SAAS,WAAW,EAAE,yBAAyB;gBAC7E,cAAc,EAAE,CACjB,CAAA;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC;AAzBD,kCAyBC;AACD,SAAS,cAAc;IACrB,OAAO;;;;;;;;;;;;;;;;;CAiBR,CAAA;AAED,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('guard/auth', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematic('guard/auth', {}, schematics_1.Tree.empty());
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index_spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAEvE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.module = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
6
|
+
// You don't have to export the function as default. You can also have more than one rule factory
|
|
7
|
+
// per file.
|
|
8
|
+
function module(options) {
|
|
9
|
+
const Config = options.Config;
|
|
10
|
+
const projectName = options.projectName;
|
|
11
|
+
const module = options.module;
|
|
12
|
+
const les_tables = options.les_tables;
|
|
13
|
+
return (tree) => {
|
|
14
|
+
// Le module existe dèja
|
|
15
|
+
let module_path = `/src/app/${module}/${module}.module.ts`;
|
|
16
|
+
let routing_module_path = `/src/app/${module}/${module}-routing.module.ts`;
|
|
17
|
+
//console.log('module_path= ',module_path)
|
|
18
|
+
if (tree.exists(module_path)) {
|
|
19
|
+
console.warn(`Le module ${module} existe dèja`);
|
|
20
|
+
return (0, schematics_1.chain)([
|
|
21
|
+
// création de tables
|
|
22
|
+
...les_tables.map((une_table) => { return (0, schematics_1.schematic)("api", { projectName: projectName, table: une_table, parent: module, Config: Config }); })
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
// le module n'existe pas encore
|
|
26
|
+
return (0, schematics_1.chain)([
|
|
27
|
+
// crétion du module avec routing s'il n'existe pas encore
|
|
28
|
+
(0, schematics_1.externalSchematic)("@schematics/angular", "module", { name: module, project: projectName, routing: true }),
|
|
29
|
+
(tree) => {
|
|
30
|
+
// modifier le fichier "module"-routing.module.ts
|
|
31
|
+
tree.overwrite(routing_module_path, get_routing_ts_content(Config, module));
|
|
32
|
+
// modifier le fichier "module".module.ts
|
|
33
|
+
tree.overwrite(module_path, get_ts_content(module));
|
|
34
|
+
},
|
|
35
|
+
// création du wrapper
|
|
36
|
+
(0, schematics_1.schematic)("wrapper", { name: module, projectName: projectName, Config: Config }),
|
|
37
|
+
// création de tables
|
|
38
|
+
...les_tables.map((une_table) => { return (0, schematics_1.schematic)("api", { projectName: projectName, table: une_table, parent: module, Config: Config }); })
|
|
39
|
+
]);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.module = module;
|
|
43
|
+
function get_routing_ts_content(Config, module) {
|
|
44
|
+
let les_tables = Config.les_modules.find((un_module) => un_module.module == module).les_tables;
|
|
45
|
+
let importations = les_tables.map((une_table) => {
|
|
46
|
+
return `import { List${(0, strings_1.classify)(une_table.table)}Component } from './${(0, strings_1.dasherize)(une_table.table)}/list-${(0, strings_1.dasherize)(une_table.table)}/list-${(0, strings_1.dasherize)(une_table.table)}.component';`;
|
|
47
|
+
}).join("\n");
|
|
48
|
+
let routes = les_tables.map((une_table, index) => {
|
|
49
|
+
if (une_table.les_types.find((un_type) => un_type == "not-found")) { // le composant not-found
|
|
50
|
+
return `{path:"**",component:List${(0, strings_1.classify)(une_table.table)}Component}`;
|
|
51
|
+
}
|
|
52
|
+
else if (index == 0) { // le premier composant
|
|
53
|
+
return `{path:"",component:List${(0, strings_1.classify)(une_table.table)}Component},\n{path:"${une_table.table}",component:List${(0, strings_1.classify)(une_table.table)}Component}`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return `{path:"${une_table.table}",component:List${(0, strings_1.classify)(une_table.table)}Component}`;
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.join(",\n");
|
|
60
|
+
// rajouter not-found
|
|
61
|
+
return `import { NgModule } from '@angular/core';
|
|
62
|
+
import { RouterModule, Routes } from '@angular/router';
|
|
63
|
+
${importations}
|
|
64
|
+
|
|
65
|
+
const routes: Routes = [
|
|
66
|
+
${routes}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
@NgModule({
|
|
70
|
+
imports: [RouterModule.forChild(routes)],
|
|
71
|
+
exports: [RouterModule]
|
|
72
|
+
})
|
|
73
|
+
export class HomeRoutingModule { }`;
|
|
74
|
+
}
|
|
75
|
+
function get_ts_content(module) {
|
|
76
|
+
return `import { NgModule } from '@angular/core';
|
|
77
|
+
import { CommonModule } from '@angular/common';
|
|
78
|
+
|
|
79
|
+
import { HomeRoutingModule } from './${module}-routing.module';
|
|
80
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@NgModule({
|
|
84
|
+
declarations: [],
|
|
85
|
+
imports: [
|
|
86
|
+
CommonModule,
|
|
87
|
+
HomeRoutingModule,
|
|
88
|
+
ReactiveFormsModule
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
export class ${(0, strings_1.classify)(module)}Module { }
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,2DAA6F;AAC7F,oEAA6E;AAE7E,iGAAiG;AACjG,YAAY;AACZ,SAAgB,MAAM,CAAC,OAAY;IACjC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;IACvC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;IAGrC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,wBAAwB;QACxB,IAAI,WAAW,GAAG,YAAY,MAAM,IAAI,MAAM,YAAY,CAAA;QAC1D,IAAI,mBAAmB,GAAG,YAAY,MAAM,IAAI,MAAM,oBAAoB,CAAA;QAC1E,0CAA0C;QAC1C,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,aAAa,MAAM,cAAc,CAAC,CAAA;YAC/C,OAAO,IAAA,kBAAK,EAAC;gBACX,qBAAqB;gBACrB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAc,EAAE,EAAE,GAAG,OAAO,IAAA,sBAAS,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,KA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,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
|
16
|
+
describe('module', () => {
|
|
17
|
+
it('works', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
19
|
+
const tree = yield runner.runSchematic('module', {}, schematics_1.Tree.empty());
|
|
20
|
+
expect(tree.files).toEqual([]);
|
|
21
|
+
}));
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=index_spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAEnE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"properties": {
|
|
3
|
+
"projectName": {
|
|
4
|
+
"type": "string",
|
|
5
|
+
"x-prompt": "Quel est le nom de votre projet Angular ?"
|
|
6
|
+
},
|
|
7
|
+
"module": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"x-prompt": "Quel est le nom du module ( le parents des futur composants ) ?"
|
|
10
|
+
},
|
|
11
|
+
"les_tables": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"x-prompt": "Quel sont les tables à générer ?"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"required": []
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configAddImportToModule = void 0;
|
|
4
|
+
const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
|
|
5
|
+
function configAddImportToModule(_options) {
|
|
6
|
+
let modulePath = "src/app/home/home.module.ts";
|
|
7
|
+
return (tree, context) => {
|
|
8
|
+
const appModulePath = modulePath;
|
|
9
|
+
const sourceFile = appModulePath;
|
|
10
|
+
const importText = `import { ReactiveFormsModule } from '@angular/forms';`;
|
|
11
|
+
const change = (0, ast_utils_1.addImportToModule)(sourceFile, importText, 'ReactiveFormsModule', appModulePath);
|
|
12
|
+
const declarationRecorder = tree.beginUpdate(sourceFile);
|
|
13
|
+
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
14
|
+
tree.commitUpdate(declarationRecorder);
|
|
15
|
+
context.logger.info(`"${importText}" added to ${appModulePath}.`);
|
|
16
|
+
return tree;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.configAddImportToModule = configAddImportToModule;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AACA,qEAA0E;AAI1E,SAAgB,uBAAuB,CAAC,QAAa;IACnD,IAAI,UAAU,GAAC,6BAA6B,CAAA;IAC5C,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,aAAa,GAAG,UAAU,CAAC;QACjC,MAAM,UAAU,GAAO,aAAa,CAAC;QACrC,MAAM,UAAU,GAAG,uDAAuD,CAAC;QAC3E,MAAM,MAAM,GAAG,IAAA,6BAAiB,EAAC,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,aAAa,CAAC,CAAC;QAC/F,MAAM,mBAAmB,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACzD,mBAAmB,CAAC,UAAU,CAAE,MAAkC,CAAC,GAAG,EAAG,MAAkC,CAAC,KAAK,CAAC,CAAC;QACnH,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,cAAc,aAAa,GAAG,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAbD,0DAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|