@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,189 +1,188 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google LLC All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* import {
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Adds a provider to the root of the project.
|
|
45
|
-
* @param project Name of the project to which to add the import.
|
|
46
|
-
* @param callback Function that generates the code block which should be inserted.
|
|
47
|
-
* @example
|
|
48
|
-
*
|
|
49
|
-
* ```ts
|
|
50
|
-
* import { Rule } from '@angular-devkit/schematics';
|
|
51
|
-
* import { addRootProvider } from '@schematics/angular/utility';
|
|
52
|
-
*
|
|
53
|
-
* export default function(): Rule {
|
|
54
|
-
* return addRootProvider('default', ({code, external}) => {
|
|
55
|
-
* return code`${external('provideLibrary', '@my/library')}({})`;
|
|
56
|
-
* });
|
|
57
|
-
* }
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
function addRootProvider(project, callback) {
|
|
61
|
-
return getRootInsertionRule(project, callback, 'providers');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
* @param
|
|
68
|
-
*
|
|
69
|
-
* app is
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
let
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
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
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google LLC All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.addRootImport = addRootImport;
|
|
11
|
+
exports.addRootProvider = addRootProvider;
|
|
12
|
+
const core_1 = require("@angular-devkit/core");
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
const ast_utils_1 = require("../ast-utils");
|
|
15
|
+
const change_1 = require("../change");
|
|
16
|
+
const ng_ast_utils_1 = require("../ng-ast-utils");
|
|
17
|
+
const app_config_1 = require("./app_config");
|
|
18
|
+
const code_block_1 = require("./code_block");
|
|
19
|
+
const util_1 = require("./util");
|
|
20
|
+
/**
|
|
21
|
+
* Adds an import to the root of the project.
|
|
22
|
+
* @param project Name of the project to which to add the import.
|
|
23
|
+
* @param callback Function that generates the code block which should be inserted.
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { Rule } from '@angular-devkit/schematics';
|
|
28
|
+
* import { addRootImport } from '@schematics/angular/utility';
|
|
29
|
+
*
|
|
30
|
+
* export default function(): Rule {
|
|
31
|
+
* return addRootImport('default', ({code, external}) => {
|
|
32
|
+
* return code`${external('MyModule', '@my/module')}.forRoot({})`;
|
|
33
|
+
* });
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function addRootImport(project, callback) {
|
|
38
|
+
return getRootInsertionRule(project, callback, 'imports', {
|
|
39
|
+
name: 'importProvidersFrom',
|
|
40
|
+
module: '@angular/core',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Adds a provider to the root of the project.
|
|
45
|
+
* @param project Name of the project to which to add the import.
|
|
46
|
+
* @param callback Function that generates the code block which should be inserted.
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { Rule } from '@angular-devkit/schematics';
|
|
51
|
+
* import { addRootProvider } from '@schematics/angular/utility';
|
|
52
|
+
*
|
|
53
|
+
* export default function(): Rule {
|
|
54
|
+
* return addRootProvider('default', ({code, external}) => {
|
|
55
|
+
* return code`${external('provideLibrary', '@my/library')}({})`;
|
|
56
|
+
* });
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
function addRootProvider(project, callback) {
|
|
61
|
+
return getRootInsertionRule(project, callback, 'providers');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Creates a rule that inserts code at the root of either a standalone or NgModule-based project.
|
|
65
|
+
* @param project Name of the project into which to inser tthe code.
|
|
66
|
+
* @param callback Function that generates the code block which should be inserted.
|
|
67
|
+
* @param ngModuleField Field of the root NgModule into which the code should be inserted, if the
|
|
68
|
+
* app is based on NgModule
|
|
69
|
+
* @param standaloneWrapperFunction Function with which to wrap the code if the app is standalone.
|
|
70
|
+
*/
|
|
71
|
+
function getRootInsertionRule(project, callback, ngModuleField, standaloneWrapperFunction) {
|
|
72
|
+
return async (host) => {
|
|
73
|
+
const mainFilePath = await (0, util_1.getMainFilePath)(host, project);
|
|
74
|
+
const codeBlock = new code_block_1.CodeBlock();
|
|
75
|
+
if ((0, ng_ast_utils_1.isStandaloneApp)(host, mainFilePath)) {
|
|
76
|
+
return tree => addProviderToStandaloneBootstrap(tree, callback(codeBlock), mainFilePath, standaloneWrapperFunction);
|
|
77
|
+
}
|
|
78
|
+
const modulePath = (0, ng_ast_utils_1.getAppModulePath)(host, mainFilePath);
|
|
79
|
+
const pendingCode = code_block_1.CodeBlock.transformPendingCode(callback(codeBlock), modulePath);
|
|
80
|
+
return (0, schematics_1.chain)([
|
|
81
|
+
...pendingCode.rules,
|
|
82
|
+
tree => {
|
|
83
|
+
const changes = (0, ast_utils_1.addSymbolToNgModuleMetadata)((0, util_1.getSourceFile)(tree, modulePath), modulePath, ngModuleField, pendingCode.code.expression,
|
|
84
|
+
// Explicitly set the import path to null since we deal with imports here separately.
|
|
85
|
+
null);
|
|
86
|
+
(0, util_1.applyChangesToFile)(tree, modulePath, changes);
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Adds a provider to the root of a standalone project.
|
|
93
|
+
* @param host Tree of the root rule.
|
|
94
|
+
* @param pendingCode Code that should be inserted.
|
|
95
|
+
* @param mainFilePath Path to the project's main file.
|
|
96
|
+
* @param wrapperFunction Optional function with which to wrap the provider.
|
|
97
|
+
*/
|
|
98
|
+
function addProviderToStandaloneBootstrap(host, pendingCode, mainFilePath, wrapperFunction) {
|
|
99
|
+
const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainFilePath);
|
|
100
|
+
const fileToEdit = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainFilePath)?.filePath || mainFilePath;
|
|
101
|
+
const { code, rules } = code_block_1.CodeBlock.transformPendingCode(pendingCode, fileToEdit);
|
|
102
|
+
return (0, schematics_1.chain)([
|
|
103
|
+
...rules,
|
|
104
|
+
() => {
|
|
105
|
+
let wrapped;
|
|
106
|
+
let additionalRules;
|
|
107
|
+
if (wrapperFunction) {
|
|
108
|
+
const block = new code_block_1.CodeBlock();
|
|
109
|
+
const result = code_block_1.CodeBlock.transformPendingCode(block.code `${block.external(wrapperFunction.name, wrapperFunction.module)}(${code.expression})`, fileToEdit);
|
|
110
|
+
wrapped = result.code;
|
|
111
|
+
additionalRules = result.rules;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
wrapped = code;
|
|
115
|
+
additionalRules = [];
|
|
116
|
+
}
|
|
117
|
+
return (0, schematics_1.chain)([
|
|
118
|
+
...additionalRules,
|
|
119
|
+
tree => insertStandaloneRootProvider(tree, mainFilePath, wrapped.expression),
|
|
120
|
+
]);
|
|
121
|
+
},
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Inserts a string expression into the root of a standalone project.
|
|
126
|
+
* @param tree File tree used to modify the project.
|
|
127
|
+
* @param mainFilePath Path to the main file of the project.
|
|
128
|
+
* @param expression Code expression to be inserted.
|
|
129
|
+
*/
|
|
130
|
+
function insertStandaloneRootProvider(tree, mainFilePath, expression) {
|
|
131
|
+
const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(tree, mainFilePath);
|
|
132
|
+
const appConfig = (0, app_config_1.findAppConfig)(bootstrapCall, tree, mainFilePath);
|
|
133
|
+
if (bootstrapCall.arguments.length === 0) {
|
|
134
|
+
throw new schematics_1.SchematicsException(`Cannot add provider to invalid bootstrapApplication call in ${bootstrapCall.getSourceFile().fileName}`);
|
|
135
|
+
}
|
|
136
|
+
if (appConfig) {
|
|
137
|
+
addProvidersExpressionToAppConfig(tree, appConfig, expression);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const newAppConfig = `, {\n${core_1.tags.indentBy(2) `providers: [${expression}]`}\n}`;
|
|
141
|
+
let targetCall;
|
|
142
|
+
if (bootstrapCall.arguments.length === 1) {
|
|
143
|
+
targetCall = bootstrapCall;
|
|
144
|
+
}
|
|
145
|
+
else if ((0, util_1.isMergeAppConfigCall)(bootstrapCall.arguments[1])) {
|
|
146
|
+
targetCall = bootstrapCall.arguments[1];
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new schematics_1.SchematicsException(`Cannot statically analyze bootstrapApplication call in ${bootstrapCall.getSourceFile().fileName}`);
|
|
150
|
+
}
|
|
151
|
+
(0, util_1.applyChangesToFile)(tree, mainFilePath, [
|
|
152
|
+
(0, ast_utils_1.insertAfterLastOccurrence)(targetCall.arguments, newAppConfig, mainFilePath, targetCall.getEnd() - 1),
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Adds a string expression to an app config object.
|
|
157
|
+
* @param tree File tree used to modify the project.
|
|
158
|
+
* @param appConfig Resolved configuration object of the project.
|
|
159
|
+
* @param expression Code expression to be inserted.
|
|
160
|
+
*/
|
|
161
|
+
function addProvidersExpressionToAppConfig(tree, appConfig, expression) {
|
|
162
|
+
const { node, filePath } = appConfig;
|
|
163
|
+
const configProps = node.properties;
|
|
164
|
+
const providersLiteral = (0, util_1.findProvidersLiteral)(node);
|
|
165
|
+
// If there's a `providers` property, we can add the provider
|
|
166
|
+
// to it, otherwise we need to declare it ourselves.
|
|
167
|
+
if (providersLiteral) {
|
|
168
|
+
(0, util_1.applyChangesToFile)(tree, filePath, [
|
|
169
|
+
(0, ast_utils_1.insertAfterLastOccurrence)(providersLiteral.elements, (providersLiteral.elements.length === 0 ? '' : ', ') + expression, filePath, providersLiteral.getStart() + 1),
|
|
170
|
+
]);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const prop = core_1.tags.indentBy(2) `providers: [${expression}]`;
|
|
174
|
+
let toInsert;
|
|
175
|
+
let insertPosition;
|
|
176
|
+
if (configProps.length === 0) {
|
|
177
|
+
toInsert = '\n' + prop + '\n';
|
|
178
|
+
insertPosition = node.getEnd() - 1;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const hasTrailingComma = configProps.hasTrailingComma;
|
|
182
|
+
toInsert = (hasTrailingComma ? '' : ',') + '\n' + prop;
|
|
183
|
+
insertPosition = configProps[configProps.length - 1].getEnd() + (hasTrailingComma ? 1 : 0);
|
|
184
|
+
}
|
|
185
|
+
(0, util_1.applyChangesToFile)(tree, filePath, [new change_1.InsertChange(filePath, insertPosition, toInsert)]);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
189
188
|
//# sourceMappingURL=rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../packages/schematics/src/utils/angular/standalone/rules.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../packages/schematics/src/utils/angular/standalone/rules.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAoCH,sCAKC;AAmBD,0CAEC;AA5DD,+CAA4C;AAC5C,2DAAoF;AAEpF,4CAAsF;AACtF,sCAAyC;AACzC,kDAAoE;AACpE,6CAAgE;AAChE,6CAAyE;AACzE,iCAOgB;AAEhB;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,QAA2B;IACxE,OAAO,oBAAoB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE;QACxD,IAAI,EAAE,qBAAqB;QAC3B,MAAM,EAAE,eAAe;KACxB,CAAC,C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AC;QAC7F,CAAC;QAED,IAAA,yBAAkB,EAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,qBAAY,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
-
*/
|
|
8
|
-
import { Tree } from '@angular-devkit/schematics';
|
|
9
|
-
import * as ts from 'typescript';
|
|
10
|
-
import { Change } from '../change';
|
|
11
|
-
/**
|
|
12
|
-
* Finds the main file of a project.
|
|
13
|
-
* @param tree File tree for the project.
|
|
14
|
-
* @param projectName Name of the project in which to search.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getMainFilePath(tree: Tree, projectName: string): Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Gets a TypeScript source file at a specific path.
|
|
19
|
-
* @param tree File tree of a project.
|
|
20
|
-
* @param path Path to the file.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getSourceFile(tree: Tree, path: string): ts.SourceFile;
|
|
23
|
-
/** Finds the call to `bootstrapApplication` within a file. */
|
|
24
|
-
export declare function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression;
|
|
25
|
-
/**
|
|
26
|
-
* Applies a set of changes to a file.
|
|
27
|
-
* @param tree File tree of the project.
|
|
28
|
-
* @param path Path to the file that is being changed.
|
|
29
|
-
* @param changes Changes that should be applied to the file.
|
|
30
|
-
*/
|
|
31
|
-
export declare function applyChangesToFile(tree: Tree, path: string, changes: Change[]): void;
|
|
32
|
-
/** Checks whether a node is a call to `mergeApplicationConfig`. */
|
|
33
|
-
export declare function isMergeAppConfigCall(node: ts.Node): node is ts.CallExpression;
|
|
34
|
-
/** Finds the `providers` array literal within an application config. */
|
|
35
|
-
export declare function findProvidersLiteral(config: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null;
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
7
|
+
*/
|
|
8
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
9
|
+
import * as ts from 'typescript';
|
|
10
|
+
import { Change } from '../change';
|
|
11
|
+
/**
|
|
12
|
+
* Finds the main file of a project.
|
|
13
|
+
* @param tree File tree for the project.
|
|
14
|
+
* @param projectName Name of the project in which to search.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getMainFilePath(tree: Tree, projectName: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Gets a TypeScript source file at a specific path.
|
|
19
|
+
* @param tree File tree of a project.
|
|
20
|
+
* @param path Path to the file.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getSourceFile(tree: Tree, path: string): ts.SourceFile;
|
|
23
|
+
/** Finds the call to `bootstrapApplication` within a file. */
|
|
24
|
+
export declare function findBootstrapApplicationCall(tree: Tree, mainFilePath: string): ts.CallExpression;
|
|
25
|
+
/**
|
|
26
|
+
* Applies a set of changes to a file.
|
|
27
|
+
* @param tree File tree of the project.
|
|
28
|
+
* @param path Path to the file that is being changed.
|
|
29
|
+
* @param changes Changes that should be applied to the file.
|
|
30
|
+
*/
|
|
31
|
+
export declare function applyChangesToFile(tree: Tree, path: string, changes: Change[]): void;
|
|
32
|
+
/** Checks whether a node is a call to `mergeApplicationConfig`. */
|
|
33
|
+
export declare function isMergeAppConfigCall(node: ts.Node): node is ts.CallExpression;
|
|
34
|
+
/** Finds the `providers` array literal within an application config. */
|
|
35
|
+
export declare function findProvidersLiteral(config: ts.ObjectLiteralExpression): ts.ArrayLiteralExpression | null;
|