@abp/ng.schematics 10.5.0 → 10.6.0-rc.2
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/commands/ai-config/index.d.ts +3 -3
- package/commands/ai-config/index.js +88 -88
- package/commands/ai-config/index.js.map +1 -1
- package/commands/ai-config/model.d.ts +10 -10
- package/commands/ai-config/model.js +2 -2
- package/commands/api/files-service/proxy/__namespace@dir__/__name@kebab__.service.ts.template +6 -4
- package/commands/api/index.d.ts +2 -2
- package/commands/api/index.js +139 -138
- package/commands/api/index.js.map +1 -1
- package/commands/change-theme/index.d.ts +28 -28
- package/commands/change-theme/index.js +474 -473
- package/commands/change-theme/index.js.map +1 -1
- package/commands/change-theme/model.d.ts +5 -5
- package/commands/change-theme/model.js +2 -2
- package/commands/change-theme/style-map.d.ts +16 -16
- package/commands/change-theme/style-map.js +424 -424
- package/commands/change-theme/theme-options.enum.d.ts +6 -6
- package/commands/change-theme/theme-options.enum.js +11 -11
- package/commands/change-theme/theme-options.enum.js.map +1 -1
- package/commands/create-lib/index.d.ts +13 -13
- package/commands/create-lib/index.js +298 -298
- package/commands/create-lib/index.js.map +1 -1
- package/commands/create-lib/models/generate-lib-schema.d.ts +20 -20
- package/commands/create-lib/models/generate-lib-schema.js +8 -8
- package/commands/create-lib/models/generate-lib-schema.js.map +1 -1
- package/commands/create-lib/models/index.d.ts +1 -1
- package/commands/create-lib/models/index.js +4 -17
- package/commands/create-lib/models/index.js.map +1 -1
- package/commands/proxy-add/index.d.ts +2 -2
- package/commands/proxy-add/index.js +41 -41
- package/commands/proxy-add/index.js.map +1 -1
- package/commands/proxy-index/index.d.ts +5 -5
- package/commands/proxy-index/index.js +14 -14
- package/commands/proxy-index/index.js.map +1 -1
- package/commands/proxy-refresh/index.d.ts +3 -3
- package/commands/proxy-refresh/index.js +27 -27
- package/commands/proxy-refresh/index.js.map +1 -1
- package/commands/proxy-remove/index.d.ts +3 -3
- package/commands/proxy-remove/index.js +33 -33
- package/commands/proxy-remove/index.js.map +1 -1
- package/commands/ssr-add/index.d.ts +11 -11
- package/commands/ssr-add/index.js +360 -361
- package/commands/ssr-add/index.js.map +1 -1
- package/commands/ssr-add/server/index.d.ts +10 -10
- package/commands/ssr-add/server/index.js +209 -205
- package/commands/ssr-add/server/index.js.map +1 -1
- package/commands/ssr-add/server/index.ts +6 -2
- package/constants/api.d.ts +1 -1
- package/constants/api.js +4 -4
- package/constants/index.d.ts +4 -4
- package/constants/index.js +7 -20
- package/constants/index.js.map +1 -1
- package/constants/proxy.d.ts +4 -4
- package/constants/proxy.js +7 -7
- package/constants/symbols.d.ts +1 -1
- package/constants/symbols.js +4 -4
- package/constants/system-types.d.ts +1 -1
- package/constants/system-types.js +29 -29
- package/constants/volo.d.ts +5 -5
- package/constants/volo.js +34 -34
- package/enums/binding-source-id.d.ts +8 -7
- package/enums/binding-source-id.js +12 -11
- package/enums/binding-source-id.js.map +1 -1
- package/enums/exception.d.ts +17 -17
- package/enums/exception.js +2 -2
- package/enums/import-keyword.d.ts +4 -4
- package/enums/import-keyword.js +8 -8
- package/enums/import-keyword.js.map +1 -1
- package/enums/index.d.ts +5 -5
- package/enums/index.js +8 -21
- package/enums/index.js.map +1 -1
- package/enums/method-modifier.d.ts +6 -6
- package/enums/method-modifier.js +10 -10
- package/enums/method-modifier.js.map +1 -1
- package/enums/service-types.d.ts +6 -6
- package/enums/service-types.js +10 -10
- package/enums/service-types.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +6 -19
- package/index.js.map +1 -1
- package/models/api-definition.d.ts +97 -93
- package/models/api-definition.js +2 -2
- package/models/generate-proxy-schema.d.ts +28 -28
- package/models/generate-proxy-schema.js +2 -2
- package/models/import.d.ts +11 -11
- package/models/import.js +13 -13
- package/models/index.d.ts +11 -11
- package/models/index.js +14 -27
- package/models/index.js.map +1 -1
- package/models/method.d.ts +36 -34
- package/models/method.js +73 -70
- package/models/method.js.map +1 -1
- package/models/model.d.ts +48 -48
- package/models/model.js +76 -76
- package/models/model.js.map +1 -1
- package/models/project.d.ts +5 -5
- package/models/project.js +2 -2
- package/models/proxy-config.d.ts +4 -4
- package/models/proxy-config.js +2 -2
- package/models/rule.d.ts +2 -2
- package/models/rule.js +2 -2
- package/models/service.d.ts +21 -21
- package/models/service.js +11 -11
- package/models/tree.d.ts +1 -1
- package/models/tree.js +2 -2
- package/models/util.d.ts +7 -7
- package/models/util.js +2 -2
- package/package.json +6 -6
- package/utils/angular/add-declaration-to-ng-module.d.ts +20 -20
- package/utils/angular/add-declaration-to-ng-module.js +45 -45
- package/utils/angular/add-declaration-to-ng-module.js.map +1 -1
- package/utils/angular/ast-utils.d.ts +106 -106
- package/utils/angular/ast-utils.js +518 -518
- package/utils/angular/ast-utils.js.map +1 -1
- package/utils/angular/change.d.ts +68 -68
- package/utils/angular/change.js +121 -121
- package/utils/angular/change.js.map +1 -1
- package/utils/angular/dependencies.d.ts +23 -23
- package/utils/angular/dependencies.js +56 -56
- package/utils/angular/dependencies.js.map +1 -1
- package/utils/angular/dependency.d.ts +96 -96
- package/utils/angular/dependency.js +123 -122
- package/utils/angular/dependency.js.map +1 -1
- package/utils/angular/eol.d.ts +8 -8
- package/utils/angular/eol.js +22 -23
- package/utils/angular/eol.js.map +1 -1
- package/utils/angular/find-module.d.ts +33 -33
- package/utils/angular/find-module.js +105 -105
- package/utils/angular/find-module.js.map +1 -1
- package/utils/angular/generate-from-files.d.ts +19 -19
- package/utils/angular/generate-from-files.js +48 -49
- package/utils/angular/generate-from-files.js.map +1 -1
- package/utils/angular/index.d.ts +15 -15
- package/utils/angular/index.js +18 -31
- package/utils/angular/index.js.map +1 -1
- package/utils/angular/json-file.d.ts +24 -24
- package/utils/angular/json-file.js +71 -71
- package/utils/angular/json-file.js.map +1 -1
- package/utils/angular/latest-versions/index.d.ts +28 -28
- package/utils/angular/latest-versions/index.js +31 -31
- package/utils/angular/ng-ast-utils.d.ts +12 -12
- package/utils/angular/ng-ast-utils.js +79 -79
- package/utils/angular/ng-ast-utils.js.map +1 -1
- package/utils/angular/parse-name.d.ts +13 -13
- package/utils/angular/parse-name.js +19 -20
- package/utils/angular/parse-name.js.map +1 -1
- package/utils/angular/paths.d.ts +8 -8
- package/utils/angular/paths.js +17 -18
- package/utils/angular/paths.js.map +1 -1
- package/utils/angular/project-targets.d.ts +11 -11
- package/utils/angular/project-targets.js +21 -22
- package/utils/angular/project-targets.js.map +1 -1
- package/utils/angular/standalone/app_component.d.ts +29 -29
- package/utils/angular/standalone/app_component.js +107 -107
- package/utils/angular/standalone/app_component.js.map +1 -1
- package/utils/angular/standalone/app_config.d.ts +23 -23
- package/utils/angular/standalone/app_config.js +89 -89
- package/utils/angular/standalone/app_config.js.map +1 -1
- package/utils/angular/standalone/code_block.d.ts +53 -53
- package/utils/angular/standalone/code_block.js +80 -79
- package/utils/angular/standalone/code_block.js.map +1 -1
- package/utils/angular/standalone/index.d.ts +9 -9
- package/utils/angular/standalone/index.js +13 -13
- package/utils/angular/standalone/rules.d.ts +45 -45
- package/utils/angular/standalone/rules.js +187 -188
- package/utils/angular/standalone/rules.js.map +1 -1
- package/utils/angular/standalone/util.d.ts +35 -35
- package/utils/angular/standalone/util.js +135 -135
- package/utils/angular/standalone/util.js.map +1 -1
- package/utils/angular/test/create-app-module.d.ts +9 -9
- package/utils/angular/test/create-app-module.js +14 -15
- package/utils/angular/test/create-app-module.js.map +1 -1
- package/utils/angular/test/get-file-content.d.ts +9 -9
- package/utils/angular/test/get-file-content.js +17 -18
- package/utils/angular/test/get-file-content.js.map +1 -1
- package/utils/angular/test/index.d.ts +9 -9
- package/utils/angular/test/index.js +12 -25
- package/utils/angular/test/index.js.map +1 -1
- package/utils/angular/validation.d.ts +10 -10
- package/utils/angular/validation.js +28 -28
- package/utils/angular/validation.js.map +1 -1
- package/utils/angular/workspace-models.d.ts +167 -167
- package/utils/angular/workspace-models.js +43 -43
- package/utils/angular/workspace-models.js.map +1 -1
- package/utils/angular/workspace.d.ts +65 -65
- package/utils/angular/workspace.js +135 -135
- package/utils/angular/workspace.js.map +1 -1
- package/utils/angular-schematic/generate-lib.d.ts +3 -3
- package/utils/angular-schematic/generate-lib.js +52 -53
- package/utils/angular-schematic/generate-lib.js.map +1 -1
- package/utils/angular-schematic/index.d.ts +1 -1
- package/utils/angular-schematic/index.js +4 -17
- package/utils/angular-schematic/index.js.map +1 -1
- package/utils/api.d.ts +2 -2
- package/utils/api.js +7 -8
- package/utils/api.js.map +1 -1
- package/utils/ast.d.ts +5 -5
- package/utils/ast.js +28 -28
- package/utils/ast.js.map +1 -1
- package/utils/barrel.d.ts +4 -4
- package/utils/barrel.js +86 -87
- package/utils/barrel.js.map +1 -1
- package/utils/common.d.ts +11 -11
- package/utils/common.js +78 -78
- package/utils/common.js.map +1 -1
- package/utils/enum.d.ts +18 -18
- package/utils/enum.js +39 -40
- package/utils/enum.js.map +1 -1
- package/utils/file.d.ts +2 -2
- package/utils/file.js +8 -9
- package/utils/file.js.map +1 -1
- package/utils/generics.d.ts +26 -26
- package/utils/generics.js +89 -89
- package/utils/generics.js.map +1 -1
- package/utils/import.d.ts +3 -3
- package/utils/import.js +10 -11
- package/utils/import.js.map +1 -1
- package/utils/index.d.ts +22 -22
- package/utils/index.js +25 -38
- package/utils/index.js.map +1 -1
- package/utils/methods.d.ts +4 -4
- package/utils/methods.js +31 -31
- package/utils/methods.js.map +1 -1
- package/utils/model.d.ts +14 -14
- package/utils/model.js +217 -211
- package/utils/model.js.map +1 -1
- package/utils/namespace.d.ts +1 -1
- package/utils/namespace.js +17 -18
- package/utils/namespace.js.map +1 -1
- package/utils/ng-module.d.ts +46 -46
- package/utils/ng-module.js +126 -125
- package/utils/ng-module.js.map +1 -1
- package/utils/path.d.ts +2 -2
- package/utils/path.js +35 -36
- package/utils/path.js.map +1 -1
- package/utils/rule.d.ts +4 -4
- package/utils/rule.js +32 -33
- package/utils/rule.js.map +1 -1
- package/utils/service.d.ts +8 -8
- package/utils/service.js +280 -171
- package/utils/service.js.map +1 -1
- package/utils/source.d.ts +13 -13
- package/utils/source.js +165 -165
- package/utils/source.js.map +1 -1
- package/utils/standalone.d.ts +59 -59
- package/utils/standalone.js +146 -145
- package/utils/standalone.js.map +1 -1
- package/utils/text.d.ts +10 -10
- package/utils/text.js +59 -59
- package/utils/text.js.map +1 -1
- package/utils/tree.d.ts +14 -14
- package/utils/tree.js +83 -83
- package/utils/tree.js.map +1 -1
- package/utils/type.d.ts +13 -13
- package/utils/type.js +112 -113
- package/utils/type.js.map +1 -1
- package/utils/workspace.d.ts +20 -20
- package/utils/workspace.js +113 -114
- package/utils/workspace.js.map +1 -1
|
@@ -1,299 +1,299 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
(0, schematics_1.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
const
|
|
211
|
-
const
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
tree.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
.
|
|
269
|
-
decl.
|
|
270
|
-
|
|
271
|
-
decl.initializer
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
exports.addLibToWorkspaceIfNotExist = addLibToWorkspaceIfNotExist;
|
|
5
|
+
exports.updateTsConfig = updateTsConfig;
|
|
6
|
+
exports.createLibSecondaryEntry = createLibSecondaryEntry;
|
|
7
|
+
exports.createLibSecondaryEntryWithStandaloneTemplate = createLibSecondaryEntryWithStandaloneTemplate;
|
|
8
|
+
exports.importConfigModuleToDefaultProjectAppModule = importConfigModuleToDefaultProjectAppModule;
|
|
9
|
+
exports.addRoutingToAppRoutingModule = addRoutingToAppRoutingModule;
|
|
10
|
+
exports.addRouteToRoutesArray = addRouteToRoutesArray;
|
|
11
|
+
const tslib_1 = require("tslib");
|
|
12
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
13
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
14
|
+
const core_1 = require("@angular-devkit/core");
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
16
|
+
const generate_lib_1 = require("../../utils/angular-schematic/generate-lib");
|
|
17
|
+
const cases = tslib_1.__importStar(require("../../utils/text"));
|
|
18
|
+
const generate_lib_schema_1 = require("./models/generate-lib-schema");
|
|
19
|
+
const util_1 = require("../../utils/angular/standalone/util");
|
|
20
|
+
function default_1(schema) {
|
|
21
|
+
return async (tree) => {
|
|
22
|
+
if (schema.override || !(await checkLibExist(schema, tree))) {
|
|
23
|
+
return (0, schematics_1.chain)([createLibrary(schema)]);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async function checkLibExist(options, tree) {
|
|
28
|
+
const packageName = (0, utils_1.kebab)(options.packageName);
|
|
29
|
+
if (options.isSecondaryEntrypoint) {
|
|
30
|
+
const lib = await (0, utils_1.resolveProject)(tree, options.target);
|
|
31
|
+
const ngPackagePath = `${lib?.definition.root}/${packageName}/ng-package.json`;
|
|
32
|
+
const packageInfo = tree.read(ngPackagePath);
|
|
33
|
+
if (packageInfo) {
|
|
34
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Library Already Exists] \"{0}\" already exists. Use --override to override." /* Exception.LibraryAlreadyExists */, `${lib.name}/${packageName}`));
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const target = await (0, utils_1.resolveProject)(tree, options.packageName, null);
|
|
39
|
+
if (target) {
|
|
40
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Library Already Exists] \"{0}\" already exists. Use --override to override." /* Exception.LibraryAlreadyExists */, packageName));
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function createLibrary(options) {
|
|
45
|
+
return async (tree) => {
|
|
46
|
+
const target = await (0, utils_1.resolveProject)(tree, options.packageName, null);
|
|
47
|
+
if (!target || options.override) {
|
|
48
|
+
if (options.isSecondaryEntrypoint) {
|
|
49
|
+
if (options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone) {
|
|
50
|
+
return createLibSecondaryEntryWithStandaloneTemplate(tree, options);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return createLibSecondaryEntry(tree, options);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Module) {
|
|
57
|
+
return createLibFromModuleTemplate(tree, options);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return createLibFromModuleStandaloneTemplate(tree, options);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
throw new schematics_1.SchematicsException((0, utils_1.interpolate)("[Library Already Exists] \"{0}\" already exists. Use --override to override." /* Exception.LibraryAlreadyExists */, options.packageName));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
async function resolvePackagesDirFromAngularJson(host) {
|
|
69
|
+
const workspace = await (0, utils_1.getWorkspace)(host);
|
|
70
|
+
const projectFolder = readFirstLibInAngularJson(workspace);
|
|
71
|
+
return projectFolder?.root?.split('/')?.[0] || 'projects';
|
|
72
|
+
}
|
|
73
|
+
function readFirstLibInAngularJson(workspace) {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
+
const library = (Array.from(workspace.projects.values()).find((value) => (0, utils_1.isLibrary)(value)));
|
|
76
|
+
return library;
|
|
77
|
+
}
|
|
78
|
+
async function createLibFromModuleTemplate(tree, options) {
|
|
79
|
+
const packagesDir = await resolvePackagesDirFromAngularJson(tree);
|
|
80
|
+
const packageJson = JSON.parse(tree.read('./package.json').toString());
|
|
81
|
+
const abpVersion = packageJson.dependencies['@abp/ng.core'];
|
|
82
|
+
return (0, schematics_1.chain)([
|
|
83
|
+
(0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-package'), [
|
|
84
|
+
(0, schematics_1.applyTemplates)({
|
|
85
|
+
...cases,
|
|
86
|
+
libraryName: options.packageName,
|
|
87
|
+
abpVersion,
|
|
88
|
+
}),
|
|
89
|
+
(0, schematics_1.move)((0, core_1.normalize)(packagesDir)),
|
|
90
|
+
]),
|
|
91
|
+
addLibToWorkspaceIfNotExist(options, packagesDir),
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
async function createLibFromModuleStandaloneTemplate(tree, options) {
|
|
95
|
+
const packagesDir = await resolvePackagesDirFromAngularJson(tree);
|
|
96
|
+
const packageJson = JSON.parse(tree.read('./package.json').toString());
|
|
97
|
+
const abpVersion = packageJson.dependencies['@abp/ng.core'];
|
|
98
|
+
return (0, schematics_1.chain)([
|
|
99
|
+
(0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-package-standalone'), [
|
|
100
|
+
(0, schematics_1.applyTemplates)({
|
|
101
|
+
...cases,
|
|
102
|
+
libraryName: options.packageName,
|
|
103
|
+
abpVersion,
|
|
104
|
+
}),
|
|
105
|
+
(0, schematics_1.move)((0, core_1.normalize)(packagesDir)),
|
|
106
|
+
]),
|
|
107
|
+
addLibToWorkspaceIfNotExist(options, packagesDir),
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
function addLibToWorkspaceIfNotExist(options, packagesDir) {
|
|
111
|
+
return async (tree) => {
|
|
112
|
+
const workspace = await (0, utils_1.getWorkspace)(tree);
|
|
113
|
+
const packageName = (0, utils_1.kebab)(options.packageName);
|
|
114
|
+
const isProjectExist = workspace.projects.has(packageName);
|
|
115
|
+
const projectRoot = (0, core_1.join)((0, core_1.normalize)(packagesDir), packageName);
|
|
116
|
+
const pathImportLib = `${packagesDir}/${packageName}`;
|
|
117
|
+
return (0, schematics_1.chain)([
|
|
118
|
+
isProjectExist
|
|
119
|
+
? (0, utils_1.updateWorkspace)(w => {
|
|
120
|
+
w.projects.delete(packageName);
|
|
121
|
+
})
|
|
122
|
+
: (0, schematics_1.noop)(),
|
|
123
|
+
(0, generate_lib_1.addLibToWorkspaceFile)(projectRoot, packageName),
|
|
124
|
+
updateTsConfig(packageName, pathImportLib),
|
|
125
|
+
importConfigModuleToDefaultProjectAppModule(packageName, options),
|
|
126
|
+
addRoutingToAppRoutingModule(workspace, packageName, options),
|
|
127
|
+
]);
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function updateTsConfig(packageName, path) {
|
|
131
|
+
return (host) => {
|
|
132
|
+
const files = ['tsconfig.json', 'tsconfig.app.json', 'tsconfig.base.json'];
|
|
133
|
+
const tsConfig = files.find(f => host.exists(f));
|
|
134
|
+
if (!tsConfig) {
|
|
135
|
+
return host;
|
|
136
|
+
}
|
|
137
|
+
const file = new utils_1.JSONFile(host, tsConfig);
|
|
138
|
+
const jsonPath = ['compilerOptions', 'paths', packageName];
|
|
139
|
+
const jsonPathConfig = ['compilerOptions', 'paths', `${packageName}/config`];
|
|
140
|
+
file.modify(jsonPath, [`${path}/src/public-api.ts`]);
|
|
141
|
+
file.modify(jsonPathConfig, [`${path}/config/src/public-api.ts`]);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
async function createLibSecondaryEntry(tree, options) {
|
|
145
|
+
const targetLib = await (0, utils_1.resolveProject)(tree, options.target);
|
|
146
|
+
const packageName = `${(0, utils_1.kebab)(targetLib.name)}/${(0, utils_1.kebab)(options.packageName)}`;
|
|
147
|
+
const importPath = `${targetLib.definition.root}/${(0, utils_1.kebab)(options.packageName)}`;
|
|
148
|
+
return (0, schematics_1.chain)([
|
|
149
|
+
(0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-secondary-entrypoint'), [
|
|
150
|
+
(0, schematics_1.applyTemplates)({
|
|
151
|
+
...cases,
|
|
152
|
+
libraryName: options.packageName,
|
|
153
|
+
target: targetLib.name,
|
|
154
|
+
}),
|
|
155
|
+
(0, schematics_1.move)((0, core_1.normalize)(targetLib.definition.root)),
|
|
156
|
+
updateTsConfig(packageName, importPath),
|
|
157
|
+
]),
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
160
|
+
async function createLibSecondaryEntryWithStandaloneTemplate(tree, options) {
|
|
161
|
+
const targetLib = await (0, utils_1.resolveProject)(tree, options.target);
|
|
162
|
+
const packageName = `${(0, utils_1.kebab)(targetLib.name)}/${(0, utils_1.kebab)(options.packageName)}`;
|
|
163
|
+
const importPath = `${targetLib.definition.root}/${(0, utils_1.kebab)(options.packageName)}`;
|
|
164
|
+
return (0, schematics_1.chain)([
|
|
165
|
+
(0, utils_1.applyWithOverwrite)((0, schematics_1.url)('./files-secondary-entrypoint-standalone'), [
|
|
166
|
+
(0, schematics_1.applyTemplates)({
|
|
167
|
+
...cases,
|
|
168
|
+
libraryName: options.packageName,
|
|
169
|
+
target: targetLib.name,
|
|
170
|
+
}),
|
|
171
|
+
(0, schematics_1.move)((0, core_1.normalize)(targetLib.definition.root)),
|
|
172
|
+
updateTsConfig(packageName, importPath),
|
|
173
|
+
]),
|
|
174
|
+
]);
|
|
175
|
+
}
|
|
176
|
+
function importConfigModuleToDefaultProjectAppModule(packageName, options) {
|
|
177
|
+
return async (tree) => {
|
|
178
|
+
const projectName = (0, utils_1.getFirstApplication)(tree).name;
|
|
179
|
+
const mainFilePath = await (0, util_1.getMainFilePath)(tree, projectName);
|
|
180
|
+
const isSourceStandalone = (0, utils_1.isStandaloneApp)(tree, mainFilePath);
|
|
181
|
+
const rules = [];
|
|
182
|
+
const providerAlreadyExists = isSourceStandalone
|
|
183
|
+
? await (0, utils_1.hasProviderInStandaloneAppConfig)(tree, projectName, `provide${(0, utils_1.pascal)(packageName)}Config`)
|
|
184
|
+
: await (0, utils_1.hasImportInNgModule)(tree, projectName, options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone
|
|
185
|
+
? `provide${(0, utils_1.pascal)(packageName)}Config`
|
|
186
|
+
: `${(0, utils_1.pascal)(packageName)}ConfigModule`, options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone ? 'providers' : 'imports');
|
|
187
|
+
if (providerAlreadyExists) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone) {
|
|
191
|
+
rules.push((0, utils_1.addRootProvider)(projectName, code => {
|
|
192
|
+
const configFn = code.external(`provide${(0, utils_1.pascal)(packageName)}Config`, `${(0, utils_1.kebab)(packageName)}/config`);
|
|
193
|
+
return code.code `${configFn}()`;
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
rules.push((0, utils_1.addRootImport)(projectName, code => {
|
|
198
|
+
const configFn = code.external(`${(0, utils_1.pascal)(packageName)}ConfigModule`, `${(0, utils_1.kebab)(packageName)}/config`);
|
|
199
|
+
return code.code `${configFn}.forRoot()`;
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
return (0, schematics_1.chain)(rules);
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function addRoutingToAppRoutingModule(workspace, packageName, options) {
|
|
206
|
+
return async (tree) => {
|
|
207
|
+
const projectName = (0, utils_1.getFirstApplication)(tree).name;
|
|
208
|
+
const project = workspace.projects.get(projectName);
|
|
209
|
+
const mainFilePath = await (0, util_1.getMainFilePath)(tree, projectName);
|
|
210
|
+
const isSourceStandalone = (0, utils_1.isStandaloneApp)(tree, mainFilePath);
|
|
211
|
+
const pascalName = (0, utils_1.pascal)(packageName);
|
|
212
|
+
const macroName = (0, utils_1.macro)(packageName);
|
|
213
|
+
const routePath = `${(0, utils_1.kebab)(packageName)}`;
|
|
214
|
+
const moduleName = `${pascalName}Module`;
|
|
215
|
+
if (isSourceStandalone) {
|
|
216
|
+
const appRoutesPath = (0, utils_1.findAppRoutesPath)(tree, mainFilePath) || `${project?.sourceRoot}/app/app.routes.ts`;
|
|
217
|
+
const buffer = tree.read(appRoutesPath);
|
|
218
|
+
if (!buffer) {
|
|
219
|
+
throw new schematics_1.SchematicsException(`Cannot find routes file: ${appRoutesPath}`);
|
|
220
|
+
}
|
|
221
|
+
const content = buffer.toString();
|
|
222
|
+
const source = ts.createSourceFile(appRoutesPath, content, ts.ScriptTarget.Latest, true);
|
|
223
|
+
const routeExpr = options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone
|
|
224
|
+
? `() => import('${routePath}').then(m => m.${macroName}_ROUTES)`
|
|
225
|
+
: `() => import('${routePath}').then(m => m.${moduleName}.forLazy())`;
|
|
226
|
+
const routeToAdd = `{ path: '${routePath}', loadChildren: ${routeExpr} }`;
|
|
227
|
+
const change = addRouteToRoutesArray(source, routeToAdd);
|
|
228
|
+
if (change instanceof utils_1.InsertChange) {
|
|
229
|
+
const recorder = tree.beginUpdate(appRoutesPath);
|
|
230
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
231
|
+
tree.commitUpdate(recorder);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const appRoutingModulePath = await (0, utils_1.findAppRoutesModulePath)(tree, mainFilePath);
|
|
236
|
+
if (!appRoutingModulePath) {
|
|
237
|
+
throw new schematics_1.SchematicsException(`Cannot find routing module: ${appRoutingModulePath}`);
|
|
238
|
+
}
|
|
239
|
+
const appRoutingModule = tree.read(appRoutingModulePath);
|
|
240
|
+
if (!appRoutingModule) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const appRoutingModuleContent = appRoutingModule.toString();
|
|
244
|
+
const routeExpr = options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone
|
|
245
|
+
? `${macroName}_ROUTES`
|
|
246
|
+
: moduleName;
|
|
247
|
+
if (appRoutingModuleContent.includes(routeExpr)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const source = ts.createSourceFile(appRoutingModulePath, appRoutingModuleContent, ts.ScriptTarget.Latest, true);
|
|
251
|
+
const importStatement = options.templateType === generate_lib_schema_1.GenerateLibTemplateType.Standalone
|
|
252
|
+
? `() => import('${routePath}').then(m => m.${macroName}_ROUTES)`
|
|
253
|
+
: `() => import('${routePath}').then(m => m.${moduleName}.forLazy())`;
|
|
254
|
+
const routeDefinition = `{ path: '${routePath}', loadChildren: ${importStatement} }`;
|
|
255
|
+
const change = (0, utils_1.addRouteDeclarationToModule)(source, routePath, routeDefinition);
|
|
256
|
+
const recorder = tree.beginUpdate(appRoutingModulePath);
|
|
257
|
+
if (change instanceof utils_1.InsertChange) {
|
|
258
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
|
259
|
+
}
|
|
260
|
+
tree.commitUpdate(recorder);
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function addRouteToRoutesArray(source, routeToAdd) {
|
|
266
|
+
// Find all variable declarations that are array literals and contain route definitions
|
|
267
|
+
const routeArrays = source.statements
|
|
268
|
+
.filter(ts.isVariableStatement)
|
|
269
|
+
.flatMap(stmt => stmt.declarationList.declarations.filter(decl => ts.isVariableDeclaration(decl) &&
|
|
270
|
+
decl.initializer &&
|
|
271
|
+
ts.isArrayLiteralExpression(decl.initializer) &&
|
|
272
|
+
decl.initializer.elements.some(el => el.getText().includes('path:'))));
|
|
273
|
+
if (routeArrays.length === 0) {
|
|
274
|
+
throw new Error('No routes array found in source file.');
|
|
275
|
+
}
|
|
276
|
+
// Select the first routes array found
|
|
277
|
+
const declaration = routeArrays[0];
|
|
278
|
+
const arrayLiteral = declaration.initializer;
|
|
279
|
+
const getPathValue = (routeText) => {
|
|
280
|
+
const match = routeText.match(/path:\s*['"`](.+?)['"`]/);
|
|
281
|
+
return match?.[1] ?? null;
|
|
282
|
+
};
|
|
283
|
+
const newPath = getPathValue(routeToAdd);
|
|
284
|
+
const alreadyExists = arrayLiteral.elements.some(el => {
|
|
285
|
+
const existingPath = getPathValue(el.getText());
|
|
286
|
+
return existingPath === newPath;
|
|
287
|
+
});
|
|
288
|
+
if (alreadyExists) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
const hasTrailingComma = arrayLiteral.elements.hasTrailingComma ?? false;
|
|
292
|
+
const insertPos = hasTrailingComma || arrayLiteral.elements.length === 0
|
|
293
|
+
? arrayLiteral.getEnd() - 1
|
|
294
|
+
: arrayLiteral.elements[arrayLiteral.elements.length - 1].getEnd();
|
|
295
|
+
const prefix = arrayLiteral.elements.length > 0 && !hasTrailingComma ? ',\n ' : ' ';
|
|
296
|
+
const toAdd = `${prefix}${routeToAdd}`;
|
|
297
|
+
return new utils_1.InsertChange(source.fileName, insertPos, toAdd);
|
|
298
|
+
}
|
|
299
299
|
//# sourceMappingURL=index.js.map
|