@abp/ng.schematics 10.5.0 → 10.6.0-rc.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/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,411 +1,414 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function
|
|
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
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatFile = exports.styleCompareFn = void 0;
|
|
4
|
+
exports.default = default_1;
|
|
5
|
+
exports.removeImportPath = removeImportPath;
|
|
6
|
+
exports.removeImportFromNgModuleMetadata = removeImportFromNgModuleMetadata;
|
|
7
|
+
exports.removeImportsFromStandaloneProviders = removeImportsFromStandaloneProviders;
|
|
8
|
+
exports.removeProviderFromNgModuleMetadata = removeProviderFromNgModuleMetadata;
|
|
9
|
+
exports.insertHelperImports = insertHelperImports;
|
|
10
|
+
exports.insertImports = insertImports;
|
|
11
|
+
exports.insertProviders = insertProviders;
|
|
12
|
+
exports.createSourceFile = createSourceFile;
|
|
13
|
+
exports.getImportPaths = getImportPaths;
|
|
14
|
+
exports.getProjectTargetOptions = getProjectTargetOptions;
|
|
15
|
+
exports.removeThemeBasedStyles = removeThemeBasedStyles;
|
|
16
|
+
exports.cleanEmptyExpressions = cleanEmptyExpressions;
|
|
17
|
+
exports.adjustProvideAbpThemeShared = adjustProvideAbpThemeShared;
|
|
18
|
+
exports.updateIndexHtml = updateIndexHtml;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
21
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
22
|
+
const style_map_1 = require("./style-map");
|
|
23
|
+
const utils_1 = require("../../utils");
|
|
24
|
+
const theme_options_enum_1 = require("./theme-options.enum");
|
|
25
|
+
const ast_utils_1 = require("../../utils/angular/ast-utils");
|
|
26
|
+
const util_1 = require("../../utils/angular/standalone/util");
|
|
27
|
+
function default_1(_options) {
|
|
28
|
+
return async () => {
|
|
29
|
+
const targetThemeName = _options.name;
|
|
30
|
+
const selectedProject = _options.targetProject;
|
|
31
|
+
if (!targetThemeName) {
|
|
32
|
+
throw new schematics_1.SchematicsException('The theme name does not selected');
|
|
33
|
+
}
|
|
34
|
+
return (0, schematics_1.chain)([
|
|
35
|
+
(0, utils_1.updateWorkspace)(storedWorkspace => {
|
|
36
|
+
updateProjectStyle(selectedProject, storedWorkspace, targetThemeName);
|
|
37
|
+
}),
|
|
38
|
+
updateAppModule(selectedProject, targetThemeName),
|
|
39
|
+
]);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function updateProjectStyle(projectName, workspace, targetThemeName) {
|
|
43
|
+
const project = workspace.projects.get(projectName);
|
|
44
|
+
if (!project) {
|
|
45
|
+
throw new schematics_1.SchematicsException('The target project does not selected');
|
|
46
|
+
}
|
|
47
|
+
if ((0, utils_1.isLibrary)(project)) {
|
|
48
|
+
throw new schematics_1.SchematicsException('The library project does not supported');
|
|
49
|
+
}
|
|
50
|
+
const targetOption = getProjectTargetOptions(project, 'build');
|
|
51
|
+
const styles = targetOption.styles;
|
|
52
|
+
const sanitizedStyles = removeThemeBasedStyles(styles);
|
|
53
|
+
const newStyles = style_map_1.styleMap.get(targetThemeName);
|
|
54
|
+
if (!newStyles) {
|
|
55
|
+
throw new schematics_1.SchematicsException('The theme does not found');
|
|
56
|
+
}
|
|
57
|
+
targetOption.styles = [...newStyles, ...sanitizedStyles];
|
|
58
|
+
}
|
|
59
|
+
function updateAppModule(selectedProject, targetThemeName) {
|
|
60
|
+
return async (host) => {
|
|
61
|
+
const mainFilePath = await (0, util_1.getMainFilePath)(host, selectedProject);
|
|
62
|
+
const isStandalone = (0, utils_1.isStandaloneApp)(host, mainFilePath);
|
|
63
|
+
const appModulePath = isStandalone
|
|
64
|
+
? (0, utils_1.getAppConfigPath)(host, mainFilePath)
|
|
65
|
+
: (0, utils_1.getAppModulePath)(host, mainFilePath);
|
|
66
|
+
return (0, schematics_1.chain)([
|
|
67
|
+
removeImportPath(appModulePath, targetThemeName),
|
|
68
|
+
...(!isStandalone ? [removeImportFromNgModuleMetadata(appModulePath, targetThemeName)] : []),
|
|
69
|
+
isStandalone
|
|
70
|
+
? removeImportsFromStandaloneProviders(appModulePath, targetThemeName)
|
|
71
|
+
: removeProviderFromNgModuleMetadata(appModulePath, targetThemeName),
|
|
72
|
+
insertHelperImports(appModulePath, targetThemeName),
|
|
73
|
+
insertImports(selectedProject, targetThemeName),
|
|
74
|
+
insertProviders(selectedProject, targetThemeName),
|
|
75
|
+
adjustProvideAbpThemeShared(appModulePath, targetThemeName),
|
|
76
|
+
updateIndexHtml(selectedProject, targetThemeName),
|
|
77
|
+
cleanEmptyExpressions(appModulePath, isStandalone),
|
|
78
|
+
]);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function removeImportPath(filePath, selectedTheme) {
|
|
82
|
+
return (host) => {
|
|
83
|
+
const buffer = host.read(filePath);
|
|
84
|
+
if (!buffer)
|
|
85
|
+
return host;
|
|
86
|
+
const sourceText = buffer.toString('utf-8');
|
|
87
|
+
const source = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
88
|
+
const recorder = host.beginUpdate(filePath);
|
|
89
|
+
const impMap = getImportPaths(selectedTheme, true);
|
|
90
|
+
const nodes = (0, ast_utils_1.findNodes)(source, ts.isImportDeclaration);
|
|
91
|
+
const filteredNodes = nodes.filter(node => {
|
|
92
|
+
const importPath = node.moduleSpecifier.text;
|
|
93
|
+
const namedBindings = node.importClause?.namedBindings;
|
|
94
|
+
return impMap.some(({ path, importName }) => {
|
|
95
|
+
const symbol = importName.split('.')[0];
|
|
96
|
+
const matchesPath = !!path && importPath === path;
|
|
97
|
+
const matchesSymbol = !!namedBindings &&
|
|
98
|
+
ts.isNamedImports(namedBindings) &&
|
|
99
|
+
namedBindings.elements.some(e => e.name.text === symbol);
|
|
100
|
+
return matchesPath || matchesSymbol;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
for (const node of filteredNodes) {
|
|
104
|
+
recorder.remove(node.getStart(), node.getWidth());
|
|
105
|
+
}
|
|
106
|
+
host.commitUpdate(recorder);
|
|
107
|
+
return host;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function removeImportFromNgModuleMetadata(appModulePath, selectedTheme) {
|
|
111
|
+
return (host) => {
|
|
112
|
+
const recorder = host.beginUpdate(appModulePath);
|
|
113
|
+
const source = createSourceFile(host, appModulePath);
|
|
114
|
+
const impMap = getImportPaths(selectedTheme, true);
|
|
115
|
+
const node = (0, ast_utils_1.getDecoratorMetadata)(source, 'NgModule', '@angular/core')[0] || {};
|
|
116
|
+
if (!node) {
|
|
117
|
+
throw new schematics_1.SchematicsException('The app module does not found');
|
|
118
|
+
}
|
|
119
|
+
const matchingProperties = (0, ast_utils_1.getMetadataField)(node, 'imports');
|
|
120
|
+
const assignment = matchingProperties[0];
|
|
121
|
+
const assignmentInit = assignment.initializer;
|
|
122
|
+
const elements = assignmentInit.elements;
|
|
123
|
+
if (!elements || elements.length < 1) {
|
|
124
|
+
throw new schematics_1.SchematicsException(`Elements could not found: ${elements}`);
|
|
125
|
+
}
|
|
126
|
+
const filteredElements = elements.filter(f => impMap.some(s => f.getText().match(s.importName)));
|
|
127
|
+
if (!filteredElements || filteredElements.length < 1) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
filteredElements.map(willRemoveModule => recorder.remove(willRemoveModule.getStart(), willRemoveModule.getWidth() + 1));
|
|
131
|
+
host.commitUpdate(recorder);
|
|
132
|
+
return host;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function removeImportsFromStandaloneProviders(mainPath, selectedTheme) {
|
|
136
|
+
return (host) => {
|
|
137
|
+
const buffer = host.read(mainPath);
|
|
138
|
+
if (!buffer)
|
|
139
|
+
return host;
|
|
140
|
+
const sourceText = buffer.toString('utf-8');
|
|
141
|
+
const source = ts.createSourceFile(mainPath, sourceText, ts.ScriptTarget.Latest, true);
|
|
142
|
+
const recorder = host.beginUpdate(mainPath);
|
|
143
|
+
const impMap = getImportPaths(selectedTheme, true);
|
|
144
|
+
const callExpressions = (0, ast_utils_1.findNodes)(source, ts.isCallExpression);
|
|
145
|
+
for (const expr of callExpressions) {
|
|
146
|
+
const exprText = expr.getText();
|
|
147
|
+
if (expr.expression.getText() === 'importProvidersFrom') {
|
|
148
|
+
const args = expr.arguments;
|
|
149
|
+
let modules = [];
|
|
150
|
+
if (args.length === 1 && ts.isArrayLiteralExpression(args[0])) {
|
|
151
|
+
modules = args[0].elements;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
modules = args;
|
|
155
|
+
}
|
|
156
|
+
const elementsToRemove = modules.filter(el => impMap.some(({ importName }) => el.getText().includes(importName)));
|
|
157
|
+
if (elementsToRemove.length) {
|
|
158
|
+
for (const removeEl of elementsToRemove) {
|
|
159
|
+
const start = removeEl.getFullStart();
|
|
160
|
+
const end = removeEl.getEnd();
|
|
161
|
+
const nextChar = sourceText.slice(end, end + 1);
|
|
162
|
+
const prevChar = sourceText.slice(start - 1, start);
|
|
163
|
+
if (nextChar === ',') {
|
|
164
|
+
recorder.remove(start, end - start + 1);
|
|
165
|
+
}
|
|
166
|
+
else if (prevChar === ',') {
|
|
167
|
+
recorder.remove(start - 1, end - start + 1);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
recorder.remove(start, end - start);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const remaining = modules.filter(el => !elementsToRemove.includes(el));
|
|
175
|
+
if (remaining.length === 0) {
|
|
176
|
+
const start = expr.getFullStart();
|
|
177
|
+
const end = expr.getEnd();
|
|
178
|
+
const nextChar = sourceText.slice(end, end + 1);
|
|
179
|
+
const prevChar = sourceText.slice(start - 1, start);
|
|
180
|
+
if (nextChar === ',') {
|
|
181
|
+
recorder.remove(start, end - start + 1);
|
|
182
|
+
}
|
|
183
|
+
else if (prevChar === ',') {
|
|
184
|
+
recorder.remove(start - 1, end - start + 1);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
recorder.remove(start, end - start);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const match = impMap.find(({ importName, provider }) => {
|
|
193
|
+
const moduleSymbol = importName?.split('.')[0];
|
|
194
|
+
return ((moduleSymbol && exprText.includes(moduleSymbol)) ||
|
|
195
|
+
(provider && exprText.includes(provider)));
|
|
196
|
+
});
|
|
197
|
+
if (match) {
|
|
198
|
+
const start = expr.getFullStart();
|
|
199
|
+
const end = expr.getEnd();
|
|
200
|
+
const nextChar = sourceText.slice(end, end + 1);
|
|
201
|
+
const prevChar = sourceText.slice(start - 1, start);
|
|
202
|
+
if (nextChar === ',') {
|
|
203
|
+
recorder.remove(start, end - start + 1);
|
|
204
|
+
}
|
|
205
|
+
else if (prevChar === ',') {
|
|
206
|
+
recorder.remove(start - 1, end - start + 1);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
recorder.remove(start, end - start);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
host.commitUpdate(recorder);
|
|
215
|
+
return host;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function removeProviderFromNgModuleMetadata(appModulePath, selectedTheme) {
|
|
219
|
+
return (host) => {
|
|
220
|
+
const recorder = host.beginUpdate(appModulePath);
|
|
221
|
+
const source = createSourceFile(host, appModulePath);
|
|
222
|
+
const impMap = getImportPaths(selectedTheme, true);
|
|
223
|
+
const node = (0, ast_utils_1.getDecoratorMetadata)(source, 'NgModule', '@angular/core')[0];
|
|
224
|
+
if (!node) {
|
|
225
|
+
throw new schematics_1.SchematicsException('The app module does not found');
|
|
226
|
+
}
|
|
227
|
+
const providersProperty = (0, ast_utils_1.getMetadataField)(node, 'providers')[0];
|
|
228
|
+
const providersArray = providersProperty.initializer;
|
|
229
|
+
if (!providersArray.elements.length)
|
|
230
|
+
return host;
|
|
231
|
+
for (const element of providersArray.elements) {
|
|
232
|
+
const elementText = element.getText();
|
|
233
|
+
const match = impMap.find(({ provider }) => {
|
|
234
|
+
if (!provider)
|
|
235
|
+
return false;
|
|
236
|
+
const providerName = provider.replace(/\(\s*\)$/, '').trim();
|
|
237
|
+
return provider && elementText.includes(providerName);
|
|
238
|
+
});
|
|
239
|
+
if (match) {
|
|
240
|
+
const start = element.getFullStart();
|
|
241
|
+
const end = element.getEnd();
|
|
242
|
+
const nextChar = source.text.slice(end, end + 1);
|
|
243
|
+
const prevChar = source.text.slice(start - 1, start);
|
|
244
|
+
if (nextChar === ',') {
|
|
245
|
+
recorder.remove(start, end - start + 1);
|
|
246
|
+
}
|
|
247
|
+
else if (prevChar === ',') {
|
|
248
|
+
recorder.remove(start - 1, end - start + 1);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
recorder.remove(start, end - start);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
host.commitUpdate(recorder);
|
|
256
|
+
return host;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function insertHelperImports(filePath, selectedTheme) {
|
|
260
|
+
return (host) => {
|
|
261
|
+
const selectedThemeImports = style_map_1.importMap.get(selectedTheme);
|
|
262
|
+
const helpers = selectedThemeImports?.filter(s => !s.doNotImport && s.importName && s.path && !s.expression && !s.provider);
|
|
263
|
+
if (!helpers || helpers.length === 0) {
|
|
264
|
+
return host;
|
|
265
|
+
}
|
|
266
|
+
const buffer = host.read(filePath);
|
|
267
|
+
if (!buffer)
|
|
268
|
+
return host;
|
|
269
|
+
const sourceText = buffer.toString('utf-8');
|
|
270
|
+
const source = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true);
|
|
271
|
+
const recorder = host.beginUpdate(filePath);
|
|
272
|
+
for (const { importName, path } of helpers) {
|
|
273
|
+
const existingImport = (0, ast_utils_1.findNodes)(source, ts.isImportDeclaration).find(node => {
|
|
274
|
+
const moduleSpecifier = node.moduleSpecifier.text;
|
|
275
|
+
const namedBindings = node.importClause?.namedBindings;
|
|
276
|
+
if (moduleSpecifier === path && namedBindings && ts.isNamedImports(namedBindings)) {
|
|
277
|
+
return namedBindings.elements.some(e => e.name.text === importName);
|
|
278
|
+
}
|
|
279
|
+
return false;
|
|
280
|
+
});
|
|
281
|
+
if (!existingImport) {
|
|
282
|
+
const importStatement = `import { ${importName} } from '${path}';\n`;
|
|
283
|
+
recorder.insertLeft(0, importStatement);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
host.commitUpdate(recorder);
|
|
287
|
+
return host;
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function insertImports(projectName, selectedTheme) {
|
|
291
|
+
const selectedThemeImports = style_map_1.importMap.get(selectedTheme);
|
|
292
|
+
const selected = selectedThemeImports?.filter(s => !s.doNotImport && !!s.expression);
|
|
293
|
+
if (!selected || selected.length === 0) {
|
|
294
|
+
return () => { };
|
|
295
|
+
}
|
|
296
|
+
return (0, utils_1.addRootImport)(projectName, code => {
|
|
297
|
+
const expressions = selected.map(({ importName, path, expression }) => {
|
|
298
|
+
if (importName && path) {
|
|
299
|
+
code.external(importName, path);
|
|
300
|
+
}
|
|
301
|
+
return expression.trim();
|
|
302
|
+
});
|
|
293
303
|
return code.code `
|
|
294
|
-
${expressions.join(',\n')}`;
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
});
|
|
304
|
+
${expressions.join(',\n')}`;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function insertProviders(projectName, selectedTheme) {
|
|
308
|
+
const selectedThemeImports = style_map_1.importMap.get(selectedTheme);
|
|
309
|
+
const selected = selectedThemeImports?.filter(s => !s.doNotImport && !!s.provider);
|
|
310
|
+
if (!selected || selected.length === 0) {
|
|
311
|
+
return () => { };
|
|
312
|
+
}
|
|
313
|
+
return (0, utils_1.addRootProvider)(projectName, code => {
|
|
314
|
+
const providers = selected.map(({ provider, path, importName }) => {
|
|
315
|
+
code.external(importName, path);
|
|
316
|
+
return provider;
|
|
317
|
+
});
|
|
309
318
|
return code.code `
|
|
310
|
-
${providers.join(',\n')}`;
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
*
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
return
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const originalText = sourceText.substring(exprStart, exprEnd);
|
|
404
|
-
let newText = originalText;
|
|
405
|
-
const hasHttpErrorConfig = originalText.includes('withHttpErrorConfig');
|
|
406
|
-
const hasValidationBluePrint = originalText.includes('withValidationBluePrint');
|
|
407
|
-
if (selectedTheme === theme_options_enum_1.ThemeOptionsEnum.LeptonX) {
|
|
408
|
-
if (!hasHttpErrorConfig) {
|
|
319
|
+
${providers.join(',\n')}`;
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function createSourceFile(host, appModulePath) {
|
|
323
|
+
const buffer = host.read(appModulePath);
|
|
324
|
+
if (!buffer || buffer.length === 0) {
|
|
325
|
+
throw new schematics_1.SchematicsException(`${appModulePath} file could not be read.`);
|
|
326
|
+
}
|
|
327
|
+
const sourceText = buffer.toString('utf-8');
|
|
328
|
+
return ts.createSourceFile(appModulePath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Returns all import paths except the selected theme
|
|
332
|
+
* @param selectedTheme The selected theme
|
|
333
|
+
* @param getAll If true, returns all import paths
|
|
334
|
+
*/
|
|
335
|
+
function getImportPaths(selectedTheme, getAll = false) {
|
|
336
|
+
if (getAll) {
|
|
337
|
+
return Array.from(style_map_1.importMap.values()).reduce((acc, val) => [...acc, ...val], []);
|
|
338
|
+
}
|
|
339
|
+
return Array.from(style_map_1.importMap.values())
|
|
340
|
+
.filter(f => f !== style_map_1.importMap.get(selectedTheme))
|
|
341
|
+
.reduce((acc, val) => [...acc, ...val], []);
|
|
342
|
+
}
|
|
343
|
+
function getProjectTargetOptions(project, buildTarget) {
|
|
344
|
+
const options = project.targets?.get(buildTarget)?.options;
|
|
345
|
+
if (!options) {
|
|
346
|
+
throw new schematics_1.SchematicsException(`Cannot determine project target configuration for: ${buildTarget}.`);
|
|
347
|
+
}
|
|
348
|
+
return options;
|
|
349
|
+
}
|
|
350
|
+
function removeThemeBasedStyles(styles) {
|
|
351
|
+
return styles.filter(s => !style_map_1.allStyles.some(x => (0, exports.styleCompareFn)(s, x)));
|
|
352
|
+
}
|
|
353
|
+
const styleCompareFn = (item1, item2) => {
|
|
354
|
+
const type1 = typeof item1;
|
|
355
|
+
const type2 = typeof item1;
|
|
356
|
+
if (type1 !== type2) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
if (type1 === 'string') {
|
|
360
|
+
return item1 === item2;
|
|
361
|
+
}
|
|
362
|
+
const o1 = item1;
|
|
363
|
+
const o2 = item2;
|
|
364
|
+
return o1.bundleName && o2.bundleName && o1.bundleName == o2.bundleName;
|
|
365
|
+
};
|
|
366
|
+
exports.styleCompareFn = styleCompareFn;
|
|
367
|
+
const formatFile = (filePath) => {
|
|
368
|
+
return (tree) => {
|
|
369
|
+
const buffer = tree.read(filePath);
|
|
370
|
+
if (!buffer)
|
|
371
|
+
return tree;
|
|
372
|
+
const source = ts.createSourceFile(filePath, buffer.toString(), ts.ScriptTarget.Latest, true);
|
|
373
|
+
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
374
|
+
const formatted = printer.printFile(source);
|
|
375
|
+
tree.overwrite(filePath, formatted);
|
|
376
|
+
return tree;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
exports.formatFile = formatFile;
|
|
380
|
+
function cleanEmptyExpressions(modulePath, isStandalone) {
|
|
381
|
+
return (host) => {
|
|
382
|
+
const buffer = host.read(modulePath);
|
|
383
|
+
if (!buffer)
|
|
384
|
+
throw new schematics_1.SchematicsException(`Cannot read ${modulePath}`);
|
|
385
|
+
const source = ts.createSourceFile(modulePath, buffer.toString('utf-8'), ts.ScriptTarget.Latest, true);
|
|
386
|
+
const recorder = host.beginUpdate(modulePath);
|
|
387
|
+
if (isStandalone) {
|
|
388
|
+
(0, utils_1.cleanEmptyExprFromProviders)(source, recorder);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
(0, utils_1.cleanEmptyExprFromModule)(source, recorder);
|
|
392
|
+
}
|
|
393
|
+
host.commitUpdate(recorder);
|
|
394
|
+
return host;
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function adjustProvideAbpThemeShared(appModulePath, selectedTheme) {
|
|
398
|
+
return (host) => {
|
|
399
|
+
const source = createSourceFile(host, appModulePath);
|
|
400
|
+
const recorder = host.beginUpdate(appModulePath);
|
|
401
|
+
const sourceText = source.getText();
|
|
402
|
+
const callExpressions = findProvideAbpThemeSharedCalls(source);
|
|
403
|
+
for (const expr of callExpressions) {
|
|
404
|
+
const exprStart = expr.getStart();
|
|
405
|
+
const exprEnd = expr.getEnd();
|
|
406
|
+
const originalText = sourceText.substring(exprStart, exprEnd);
|
|
407
|
+
let newText = originalText;
|
|
408
|
+
const hasHttpErrorConfig = originalText.includes('withHttpErrorConfig');
|
|
409
|
+
const hasValidationBluePrint = originalText.includes('withValidationBluePrint');
|
|
410
|
+
if (selectedTheme === theme_options_enum_1.ThemeOptionsEnum.LeptonX) {
|
|
411
|
+
if (!hasHttpErrorConfig) {
|
|
409
412
|
newText = newText.replace('(', `(
|
|
410
413
|
withHttpErrorConfig({
|
|
411
414
|
errorScreen: {
|
|
@@ -413,74 +416,72 @@ function adjustProvideAbpThemeShared(appModulePath, selectedTheme) {
|
|
|
413
416
|
forWhichErrors: [401, 403, 404, 500],
|
|
414
417
|
hideCloseIcon: true
|
|
415
418
|
}
|
|
416
|
-
}),`);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
if (hasHttpErrorConfig) {
|
|
421
|
-
newText = newText.replace(/withHttpErrorConfig\([^)]*\),?/, '');
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
if (!hasValidationBluePrint) {
|
|
419
|
+
}),`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
if (hasHttpErrorConfig) {
|
|
424
|
+
newText = newText.replace(/withHttpErrorConfig\([^)]*\),?/, '');
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if (!hasValidationBluePrint) {
|
|
425
428
|
newText = newText.replace('(', `(
|
|
426
429
|
withValidationBluePrint({
|
|
427
430
|
wrongPassword: 'Please choose 1q2w3E*'
|
|
428
|
-
}),`);
|
|
429
|
-
}
|
|
430
|
-
if (newText && newText !== originalText) {
|
|
431
|
-
recorder.remove(exprStart, exprEnd - exprStart);
|
|
432
|
-
recorder.insertLeft(exprStart, newText);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
host.commitUpdate(recorder);
|
|
436
|
-
return host;
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
exports.updateIndexHtml = updateIndexHtml;
|
|
431
|
+
}),`);
|
|
432
|
+
}
|
|
433
|
+
if (newText && newText !== originalText) {
|
|
434
|
+
recorder.remove(exprStart, exprEnd - exprStart);
|
|
435
|
+
recorder.insertLeft(exprStart, newText);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
host.commitUpdate(recorder);
|
|
439
|
+
return host;
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function findProvideAbpThemeSharedCalls(source) {
|
|
443
|
+
const result = [];
|
|
444
|
+
const visit = (node) => {
|
|
445
|
+
if (ts.isCallExpression(node)) {
|
|
446
|
+
const expressionText = node.expression.getText();
|
|
447
|
+
if (expressionText.includes('provideAbpThemeShared')) {
|
|
448
|
+
result.push(node);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
ts.forEachChild(node, visit);
|
|
452
|
+
};
|
|
453
|
+
visit(source);
|
|
454
|
+
return result;
|
|
455
|
+
}
|
|
456
|
+
function updateIndexHtml(projectName, themeName) {
|
|
457
|
+
return async (host) => {
|
|
458
|
+
const workspace = await (0, utils_1.getWorkspace)(host);
|
|
459
|
+
const project = workspace.projects.get(projectName);
|
|
460
|
+
if (!project) {
|
|
461
|
+
throw new Error(`Project "${projectName}" not found in workspace.`);
|
|
462
|
+
}
|
|
463
|
+
const buildOptions = project.targets.get('build')?.options;
|
|
464
|
+
const indexPath = buildOptions?.index;
|
|
465
|
+
if (!indexPath || !host.exists(indexPath)) {
|
|
466
|
+
throw new Error(`index.html not found at path: ${indexPath}`);
|
|
467
|
+
}
|
|
468
|
+
const buffer = host.read(indexPath);
|
|
469
|
+
if (!buffer)
|
|
470
|
+
return;
|
|
471
|
+
const content = buffer.toString('utf-8');
|
|
472
|
+
const loaderDiv = `<div id="lp-page-loader"></div>`;
|
|
473
|
+
let updatedContent = content;
|
|
474
|
+
if (themeName === theme_options_enum_1.ThemeOptionsEnum.LeptonX) {
|
|
475
|
+
if (!content.includes(loaderDiv)) {
|
|
476
|
+
updatedContent = content.replace(/<body([^>]*)>/i, `<body$1>\n ${loaderDiv}`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
if (content.includes(loaderDiv)) {
|
|
481
|
+
updatedContent = content.replace(loaderDiv, '');
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
host.overwrite(indexPath, updatedContent);
|
|
485
|
+
};
|
|
486
|
+
}
|
|
486
487
|
//# sourceMappingURL=index.js.map
|