@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.
Files changed (259) hide show
  1. package/commands/ai-config/index.d.ts +3 -3
  2. package/commands/ai-config/index.js +88 -88
  3. package/commands/ai-config/index.js.map +1 -1
  4. package/commands/ai-config/model.d.ts +10 -10
  5. package/commands/ai-config/model.js +2 -2
  6. package/commands/api/files-service/proxy/__namespace@dir__/__name@kebab__.service.ts.template +6 -4
  7. package/commands/api/index.d.ts +2 -2
  8. package/commands/api/index.js +139 -138
  9. package/commands/api/index.js.map +1 -1
  10. package/commands/change-theme/index.d.ts +28 -28
  11. package/commands/change-theme/index.js +474 -473
  12. package/commands/change-theme/index.js.map +1 -1
  13. package/commands/change-theme/model.d.ts +5 -5
  14. package/commands/change-theme/model.js +2 -2
  15. package/commands/change-theme/style-map.d.ts +16 -16
  16. package/commands/change-theme/style-map.js +424 -424
  17. package/commands/change-theme/theme-options.enum.d.ts +6 -6
  18. package/commands/change-theme/theme-options.enum.js +11 -11
  19. package/commands/change-theme/theme-options.enum.js.map +1 -1
  20. package/commands/create-lib/index.d.ts +13 -13
  21. package/commands/create-lib/index.js +298 -298
  22. package/commands/create-lib/index.js.map +1 -1
  23. package/commands/create-lib/models/generate-lib-schema.d.ts +20 -20
  24. package/commands/create-lib/models/generate-lib-schema.js +8 -8
  25. package/commands/create-lib/models/generate-lib-schema.js.map +1 -1
  26. package/commands/create-lib/models/index.d.ts +1 -1
  27. package/commands/create-lib/models/index.js +4 -17
  28. package/commands/create-lib/models/index.js.map +1 -1
  29. package/commands/proxy-add/index.d.ts +2 -2
  30. package/commands/proxy-add/index.js +41 -41
  31. package/commands/proxy-add/index.js.map +1 -1
  32. package/commands/proxy-index/index.d.ts +5 -5
  33. package/commands/proxy-index/index.js +14 -14
  34. package/commands/proxy-index/index.js.map +1 -1
  35. package/commands/proxy-refresh/index.d.ts +3 -3
  36. package/commands/proxy-refresh/index.js +27 -27
  37. package/commands/proxy-refresh/index.js.map +1 -1
  38. package/commands/proxy-remove/index.d.ts +3 -3
  39. package/commands/proxy-remove/index.js +33 -33
  40. package/commands/proxy-remove/index.js.map +1 -1
  41. package/commands/ssr-add/index.d.ts +11 -11
  42. package/commands/ssr-add/index.js +360 -361
  43. package/commands/ssr-add/index.js.map +1 -1
  44. package/commands/ssr-add/server/index.d.ts +10 -10
  45. package/commands/ssr-add/server/index.js +209 -205
  46. package/commands/ssr-add/server/index.js.map +1 -1
  47. package/commands/ssr-add/server/index.ts +6 -2
  48. package/constants/api.d.ts +1 -1
  49. package/constants/api.js +4 -4
  50. package/constants/index.d.ts +4 -4
  51. package/constants/index.js +7 -20
  52. package/constants/index.js.map +1 -1
  53. package/constants/proxy.d.ts +4 -4
  54. package/constants/proxy.js +7 -7
  55. package/constants/symbols.d.ts +1 -1
  56. package/constants/symbols.js +4 -4
  57. package/constants/system-types.d.ts +1 -1
  58. package/constants/system-types.js +29 -29
  59. package/constants/volo.d.ts +5 -5
  60. package/constants/volo.js +34 -34
  61. package/enums/binding-source-id.d.ts +8 -7
  62. package/enums/binding-source-id.js +12 -11
  63. package/enums/binding-source-id.js.map +1 -1
  64. package/enums/exception.d.ts +17 -17
  65. package/enums/exception.js +2 -2
  66. package/enums/import-keyword.d.ts +4 -4
  67. package/enums/import-keyword.js +8 -8
  68. package/enums/import-keyword.js.map +1 -1
  69. package/enums/index.d.ts +5 -5
  70. package/enums/index.js +8 -21
  71. package/enums/index.js.map +1 -1
  72. package/enums/method-modifier.d.ts +6 -6
  73. package/enums/method-modifier.js +10 -10
  74. package/enums/method-modifier.js.map +1 -1
  75. package/enums/service-types.d.ts +6 -6
  76. package/enums/service-types.js +10 -10
  77. package/enums/service-types.js.map +1 -1
  78. package/index.d.ts +3 -3
  79. package/index.js +6 -19
  80. package/index.js.map +1 -1
  81. package/models/api-definition.d.ts +97 -93
  82. package/models/api-definition.js +2 -2
  83. package/models/generate-proxy-schema.d.ts +28 -28
  84. package/models/generate-proxy-schema.js +2 -2
  85. package/models/import.d.ts +11 -11
  86. package/models/import.js +13 -13
  87. package/models/index.d.ts +11 -11
  88. package/models/index.js +14 -27
  89. package/models/index.js.map +1 -1
  90. package/models/method.d.ts +36 -34
  91. package/models/method.js +73 -70
  92. package/models/method.js.map +1 -1
  93. package/models/model.d.ts +48 -48
  94. package/models/model.js +76 -76
  95. package/models/model.js.map +1 -1
  96. package/models/project.d.ts +5 -5
  97. package/models/project.js +2 -2
  98. package/models/proxy-config.d.ts +4 -4
  99. package/models/proxy-config.js +2 -2
  100. package/models/rule.d.ts +2 -2
  101. package/models/rule.js +2 -2
  102. package/models/service.d.ts +21 -21
  103. package/models/service.js +11 -11
  104. package/models/tree.d.ts +1 -1
  105. package/models/tree.js +2 -2
  106. package/models/util.d.ts +7 -7
  107. package/models/util.js +2 -2
  108. package/package.json +6 -6
  109. package/utils/angular/add-declaration-to-ng-module.d.ts +20 -20
  110. package/utils/angular/add-declaration-to-ng-module.js +45 -45
  111. package/utils/angular/add-declaration-to-ng-module.js.map +1 -1
  112. package/utils/angular/ast-utils.d.ts +106 -106
  113. package/utils/angular/ast-utils.js +518 -518
  114. package/utils/angular/ast-utils.js.map +1 -1
  115. package/utils/angular/change.d.ts +68 -68
  116. package/utils/angular/change.js +121 -121
  117. package/utils/angular/change.js.map +1 -1
  118. package/utils/angular/dependencies.d.ts +23 -23
  119. package/utils/angular/dependencies.js +56 -56
  120. package/utils/angular/dependencies.js.map +1 -1
  121. package/utils/angular/dependency.d.ts +96 -96
  122. package/utils/angular/dependency.js +123 -122
  123. package/utils/angular/dependency.js.map +1 -1
  124. package/utils/angular/eol.d.ts +8 -8
  125. package/utils/angular/eol.js +22 -23
  126. package/utils/angular/eol.js.map +1 -1
  127. package/utils/angular/find-module.d.ts +33 -33
  128. package/utils/angular/find-module.js +105 -105
  129. package/utils/angular/find-module.js.map +1 -1
  130. package/utils/angular/generate-from-files.d.ts +19 -19
  131. package/utils/angular/generate-from-files.js +48 -49
  132. package/utils/angular/generate-from-files.js.map +1 -1
  133. package/utils/angular/index.d.ts +15 -15
  134. package/utils/angular/index.js +18 -31
  135. package/utils/angular/index.js.map +1 -1
  136. package/utils/angular/json-file.d.ts +24 -24
  137. package/utils/angular/json-file.js +71 -71
  138. package/utils/angular/json-file.js.map +1 -1
  139. package/utils/angular/latest-versions/index.d.ts +28 -28
  140. package/utils/angular/latest-versions/index.js +31 -31
  141. package/utils/angular/ng-ast-utils.d.ts +12 -12
  142. package/utils/angular/ng-ast-utils.js +79 -79
  143. package/utils/angular/ng-ast-utils.js.map +1 -1
  144. package/utils/angular/parse-name.d.ts +13 -13
  145. package/utils/angular/parse-name.js +19 -20
  146. package/utils/angular/parse-name.js.map +1 -1
  147. package/utils/angular/paths.d.ts +8 -8
  148. package/utils/angular/paths.js +17 -18
  149. package/utils/angular/paths.js.map +1 -1
  150. package/utils/angular/project-targets.d.ts +11 -11
  151. package/utils/angular/project-targets.js +21 -22
  152. package/utils/angular/project-targets.js.map +1 -1
  153. package/utils/angular/standalone/app_component.d.ts +29 -29
  154. package/utils/angular/standalone/app_component.js +107 -107
  155. package/utils/angular/standalone/app_component.js.map +1 -1
  156. package/utils/angular/standalone/app_config.d.ts +23 -23
  157. package/utils/angular/standalone/app_config.js +89 -89
  158. package/utils/angular/standalone/app_config.js.map +1 -1
  159. package/utils/angular/standalone/code_block.d.ts +53 -53
  160. package/utils/angular/standalone/code_block.js +80 -79
  161. package/utils/angular/standalone/code_block.js.map +1 -1
  162. package/utils/angular/standalone/index.d.ts +9 -9
  163. package/utils/angular/standalone/index.js +13 -13
  164. package/utils/angular/standalone/rules.d.ts +45 -45
  165. package/utils/angular/standalone/rules.js +187 -188
  166. package/utils/angular/standalone/rules.js.map +1 -1
  167. package/utils/angular/standalone/util.d.ts +35 -35
  168. package/utils/angular/standalone/util.js +135 -135
  169. package/utils/angular/standalone/util.js.map +1 -1
  170. package/utils/angular/test/create-app-module.d.ts +9 -9
  171. package/utils/angular/test/create-app-module.js +14 -15
  172. package/utils/angular/test/create-app-module.js.map +1 -1
  173. package/utils/angular/test/get-file-content.d.ts +9 -9
  174. package/utils/angular/test/get-file-content.js +17 -18
  175. package/utils/angular/test/get-file-content.js.map +1 -1
  176. package/utils/angular/test/index.d.ts +9 -9
  177. package/utils/angular/test/index.js +12 -25
  178. package/utils/angular/test/index.js.map +1 -1
  179. package/utils/angular/validation.d.ts +10 -10
  180. package/utils/angular/validation.js +28 -28
  181. package/utils/angular/validation.js.map +1 -1
  182. package/utils/angular/workspace-models.d.ts +167 -167
  183. package/utils/angular/workspace-models.js +43 -43
  184. package/utils/angular/workspace-models.js.map +1 -1
  185. package/utils/angular/workspace.d.ts +65 -65
  186. package/utils/angular/workspace.js +135 -135
  187. package/utils/angular/workspace.js.map +1 -1
  188. package/utils/angular-schematic/generate-lib.d.ts +3 -3
  189. package/utils/angular-schematic/generate-lib.js +52 -53
  190. package/utils/angular-schematic/generate-lib.js.map +1 -1
  191. package/utils/angular-schematic/index.d.ts +1 -1
  192. package/utils/angular-schematic/index.js +4 -17
  193. package/utils/angular-schematic/index.js.map +1 -1
  194. package/utils/api.d.ts +2 -2
  195. package/utils/api.js +7 -8
  196. package/utils/api.js.map +1 -1
  197. package/utils/ast.d.ts +5 -5
  198. package/utils/ast.js +28 -28
  199. package/utils/ast.js.map +1 -1
  200. package/utils/barrel.d.ts +4 -4
  201. package/utils/barrel.js +86 -87
  202. package/utils/barrel.js.map +1 -1
  203. package/utils/common.d.ts +11 -11
  204. package/utils/common.js +78 -78
  205. package/utils/common.js.map +1 -1
  206. package/utils/enum.d.ts +18 -18
  207. package/utils/enum.js +39 -40
  208. package/utils/enum.js.map +1 -1
  209. package/utils/file.d.ts +2 -2
  210. package/utils/file.js +8 -9
  211. package/utils/file.js.map +1 -1
  212. package/utils/generics.d.ts +26 -26
  213. package/utils/generics.js +89 -89
  214. package/utils/generics.js.map +1 -1
  215. package/utils/import.d.ts +3 -3
  216. package/utils/import.js +10 -11
  217. package/utils/import.js.map +1 -1
  218. package/utils/index.d.ts +22 -22
  219. package/utils/index.js +25 -38
  220. package/utils/index.js.map +1 -1
  221. package/utils/methods.d.ts +4 -4
  222. package/utils/methods.js +31 -31
  223. package/utils/methods.js.map +1 -1
  224. package/utils/model.d.ts +14 -14
  225. package/utils/model.js +217 -211
  226. package/utils/model.js.map +1 -1
  227. package/utils/namespace.d.ts +1 -1
  228. package/utils/namespace.js +17 -18
  229. package/utils/namespace.js.map +1 -1
  230. package/utils/ng-module.d.ts +46 -46
  231. package/utils/ng-module.js +126 -125
  232. package/utils/ng-module.js.map +1 -1
  233. package/utils/path.d.ts +2 -2
  234. package/utils/path.js +35 -36
  235. package/utils/path.js.map +1 -1
  236. package/utils/rule.d.ts +4 -4
  237. package/utils/rule.js +32 -33
  238. package/utils/rule.js.map +1 -1
  239. package/utils/service.d.ts +8 -8
  240. package/utils/service.js +280 -171
  241. package/utils/service.js.map +1 -1
  242. package/utils/source.d.ts +13 -13
  243. package/utils/source.js +165 -165
  244. package/utils/source.js.map +1 -1
  245. package/utils/standalone.d.ts +59 -59
  246. package/utils/standalone.js +146 -145
  247. package/utils/standalone.js.map +1 -1
  248. package/utils/text.d.ts +10 -10
  249. package/utils/text.js +59 -59
  250. package/utils/text.js.map +1 -1
  251. package/utils/tree.d.ts +14 -14
  252. package/utils/tree.js +83 -83
  253. package/utils/tree.js.map +1 -1
  254. package/utils/type.d.ts +13 -13
  255. package/utils/type.js +112 -113
  256. package/utils/type.js.map +1 -1
  257. package/utils/workspace.d.ts +20 -20
  258. package/utils/workspace.js +113 -114
  259. package/utils/workspace.js.map +1 -1
@@ -1,146 +1,147 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanEmptyExprFromProviders = exports.hasProviderInStandaloneAppConfig = exports.findAppRoutesPath = exports.getAppConfigPath = void 0;
4
- const schematics_1 = require("@angular-devkit/schematics");
5
- const util_1 = require("./angular/standalone/util");
6
- const app_config_1 = require("./angular/standalone/app_config");
7
- const ts = require("typescript");
8
- const core_1 = require("@angular-devkit/core");
9
- const path = require("path");
10
- const angular_1 = require("./angular");
11
- const ast_1 = require("./ast");
12
- /**
13
- * Retrieves the file path of the application's configuration used in a standalone
14
- * Angular application setup.
15
- *
16
- * This function locates the `bootstrapApplication` call in the main entry file and
17
- * resolves the path to the configuration object passed to it (typically `appConfig`).
18
- *
19
- * @param host - The virtual file system tree used by Angular schematics.
20
- * @param mainFilePath - The path to the main entry file of the Angular application (e.g., `main.ts`).
21
- * @returns The resolved file path of the application's configuration, or an empty string if not found.
22
- */
23
- const getAppConfigPath = (host, mainFilePath) => {
24
- const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainFilePath);
25
- const appConfig = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainFilePath);
26
- return appConfig?.filePath || '';
27
- };
28
- exports.getAppConfigPath = getAppConfigPath;
29
- /**
30
- * Attempts to locate the file path of the `routes` array used in a standalone
31
- * Angular application configuration.
32
- *
33
- * This function resolves the application's config file (typically where `routes` is defined or imported),
34
- * parses the file, and inspects its import declarations to find the import associated with `routes`.
35
- * It then resolves and normalizes the file path of the `routes` definition and returns it.
36
- *
37
- * @param tree - The virtual file system tree used by Angular schematics.
38
- * @param mainFilePath - The path to the main entry file of the Angular application (e.g., `main.ts`).
39
- * @returns The normalized workspace-relative path to the file where `routes` is defined, or `null` if not found.
40
- * @throws If the `routes` import path is found but the file does not exist in the tree.
41
- */
42
- function findAppRoutesPath(tree, mainFilePath) {
43
- const appConfigPath = (0, exports.getAppConfigPath)(tree, mainFilePath);
44
- if (!appConfigPath || !tree.exists(appConfigPath))
45
- return null;
46
- const buffer = tree.read(appConfigPath);
47
- if (!buffer)
48
- return null;
49
- const source = ts.createSourceFile(appConfigPath, buffer.toString('utf-8'), ts.ScriptTarget.Latest, true);
50
- for (const stmt of source.statements) {
51
- if (!ts.isImportDeclaration(stmt))
52
- continue;
53
- const importClause = stmt.importClause;
54
- if (!importClause?.namedBindings || !ts.isNamedImports(importClause.namedBindings))
55
- continue;
56
- const isRoutesImport = importClause.namedBindings.elements.some(el => el.name.getText() === 'routes');
57
- if (!isRoutesImport || !ts.isStringLiteral(stmt.moduleSpecifier))
58
- continue;
59
- let importPath = stmt.moduleSpecifier.text;
60
- if (!importPath.endsWith('.ts')) {
61
- importPath += '.ts';
62
- }
63
- const configDir = path.dirname(appConfigPath);
64
- const resolvedFsPath = path.resolve(configDir, importPath);
65
- const workspaceRelativePath = path.relative(process.cwd(), resolvedFsPath).replace(/\\/g, '/');
66
- const normalizedPath = (0, core_1.normalize)(workspaceRelativePath);
67
- if (!tree.exists(normalizedPath)) {
68
- throw new Error(`Cannot find routes file: ${normalizedPath}`);
69
- }
70
- return normalizedPath;
71
- }
72
- return null;
73
- }
74
- exports.findAppRoutesPath = findAppRoutesPath;
75
- /**
76
- * Checks whether a specific provider is registered in the `providers` array of the
77
- * standalone application configuration (typically within `app.config.ts`) in an Angular project.
78
- *
79
- * This function reads and parses the application configuration file, looks for the
80
- * `providers` property in the configuration object, and checks whether it includes
81
- * the specified provider name.
82
- *
83
- * @param host - The virtual file system tree used by Angular schematics.
84
- * @param projectName - The name of the Angular project.
85
- * @param providerName - The name of the provider to search for (as a string match).
86
- * @returns A promise that resolves to `true` if the provider is found, otherwise `false`.
87
- * @throws SchematicsException if the app config file cannot be read.
88
- */
89
- const hasProviderInStandaloneAppConfig = async (host, projectName, providerName) => {
90
- const mainFilePath = await (0, util_1.getMainFilePath)(host, projectName);
91
- const appConfigPath = (0, exports.getAppConfigPath)(host, mainFilePath);
92
- const buffer = host.read(appConfigPath);
93
- if (!buffer) {
94
- throw new schematics_1.SchematicsException(`Could not read file: ${appConfigPath}`);
95
- }
96
- const source = ts.createSourceFile(appConfigPath, buffer.toString('utf-8'), ts.ScriptTarget.Latest, true);
97
- const callExpressions = source.statements
98
- .flatMap(stmt => (ts.isVariableStatement(stmt) ? stmt.declarationList.declarations : []))
99
- .flatMap(decl => decl.initializer && ts.isObjectLiteralExpression(decl.initializer)
100
- ? decl.initializer.properties
101
- : [])
102
- .filter(ts.isPropertyAssignment)
103
- .filter(prop => prop.name.getText() === 'providers');
104
- if (callExpressions.length === 0)
105
- return false;
106
- const providersArray = callExpressions[0].initializer;
107
- return providersArray.elements.some(el => el.getText().includes(providerName));
108
- };
109
- exports.hasProviderInStandaloneAppConfig = hasProviderInStandaloneAppConfig;
110
- /**
111
- * Cleans up empty or invalid expressions (e.g., extra or trailing commas) from the
112
- * `providers` array within a standalone Angular application configuration object.
113
- *
114
- * This function parses the source file's AST to locate variable declarations that
115
- * define an object literal. It then searches for a `providers` property and removes
116
- * any empty elements from its array literal, replacing it with a cleaned version.
117
- *
118
- * Typically used in Angular schematics to ensure the `providers` array in `app.config.ts`
119
- * is free of empty slots after modifications.
120
- *
121
- * @param source - The TypeScript source file containing the app configuration.
122
- * @param recorder - The recorder used to apply changes to the source file.
123
- */
124
- function cleanEmptyExprFromProviders(source, recorder) {
125
- const varStatements = (0, angular_1.findNodes)(source, ts.isVariableStatement);
126
- const printer = ts.createPrinter();
127
- for (const stmt of varStatements) {
128
- const declList = stmt.declarationList;
129
- for (const decl of declList.declarations) {
130
- if (!decl.initializer || !ts.isObjectLiteralExpression(decl.initializer))
131
- continue;
132
- const obj = decl.initializer;
133
- const providersProp = obj.properties.find(prop => ts.isPropertyAssignment(prop) &&
134
- ts.isIdentifier(prop.name) &&
135
- prop.name.text === 'providers');
136
- if (!providersProp || !ts.isArrayLiteralExpression(providersProp.initializer))
137
- continue;
138
- const arrayLiteral = providersProp.initializer;
139
- const cleanedArray = (0, ast_1.removeEmptyElementsFromArrayLiteral)(arrayLiteral);
140
- recorder.remove(arrayLiteral.getStart(), arrayLiteral.getWidth());
141
- recorder.insertLeft(arrayLiteral.getStart(), printer.printNode(ts.EmitHint.Expression, cleanedArray, source));
142
- }
143
- }
144
- }
145
- exports.cleanEmptyExprFromProviders = cleanEmptyExprFromProviders;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasProviderInStandaloneAppConfig = exports.getAppConfigPath = void 0;
4
+ exports.findAppRoutesPath = findAppRoutesPath;
5
+ exports.cleanEmptyExprFromProviders = cleanEmptyExprFromProviders;
6
+ const tslib_1 = require("tslib");
7
+ const schematics_1 = require("@angular-devkit/schematics");
8
+ const util_1 = require("./angular/standalone/util");
9
+ const app_config_1 = require("./angular/standalone/app_config");
10
+ const ts = tslib_1.__importStar(require("typescript"));
11
+ const core_1 = require("@angular-devkit/core");
12
+ const path = tslib_1.__importStar(require("path"));
13
+ const angular_1 = require("./angular");
14
+ const ast_1 = require("./ast");
15
+ /**
16
+ * Retrieves the file path of the application's configuration used in a standalone
17
+ * Angular application setup.
18
+ *
19
+ * This function locates the `bootstrapApplication` call in the main entry file and
20
+ * resolves the path to the configuration object passed to it (typically `appConfig`).
21
+ *
22
+ * @param host - The virtual file system tree used by Angular schematics.
23
+ * @param mainFilePath - The path to the main entry file of the Angular application (e.g., `main.ts`).
24
+ * @returns The resolved file path of the application's configuration, or an empty string if not found.
25
+ */
26
+ const getAppConfigPath = (host, mainFilePath) => {
27
+ const bootstrapCall = (0, util_1.findBootstrapApplicationCall)(host, mainFilePath);
28
+ const appConfig = (0, app_config_1.findAppConfig)(bootstrapCall, host, mainFilePath);
29
+ return appConfig?.filePath || '';
30
+ };
31
+ exports.getAppConfigPath = getAppConfigPath;
32
+ /**
33
+ * Attempts to locate the file path of the `routes` array used in a standalone
34
+ * Angular application configuration.
35
+ *
36
+ * This function resolves the application's config file (typically where `routes` is defined or imported),
37
+ * parses the file, and inspects its import declarations to find the import associated with `routes`.
38
+ * It then resolves and normalizes the file path of the `routes` definition and returns it.
39
+ *
40
+ * @param tree - The virtual file system tree used by Angular schematics.
41
+ * @param mainFilePath - The path to the main entry file of the Angular application (e.g., `main.ts`).
42
+ * @returns The normalized workspace-relative path to the file where `routes` is defined, or `null` if not found.
43
+ * @throws If the `routes` import path is found but the file does not exist in the tree.
44
+ */
45
+ function findAppRoutesPath(tree, mainFilePath) {
46
+ const appConfigPath = (0, exports.getAppConfigPath)(tree, mainFilePath);
47
+ if (!appConfigPath || !tree.exists(appConfigPath))
48
+ return null;
49
+ const buffer = tree.read(appConfigPath);
50
+ if (!buffer)
51
+ return null;
52
+ const source = ts.createSourceFile(appConfigPath, buffer.toString('utf-8'), ts.ScriptTarget.Latest, true);
53
+ for (const stmt of source.statements) {
54
+ if (!ts.isImportDeclaration(stmt))
55
+ continue;
56
+ const importClause = stmt.importClause;
57
+ if (!importClause?.namedBindings || !ts.isNamedImports(importClause.namedBindings))
58
+ continue;
59
+ const isRoutesImport = importClause.namedBindings.elements.some(el => el.name.getText() === 'routes');
60
+ if (!isRoutesImport || !ts.isStringLiteral(stmt.moduleSpecifier))
61
+ continue;
62
+ let importPath = stmt.moduleSpecifier.text;
63
+ if (!importPath.endsWith('.ts')) {
64
+ importPath += '.ts';
65
+ }
66
+ const configDir = path.dirname(appConfigPath);
67
+ const resolvedFsPath = path.resolve(configDir, importPath);
68
+ const workspaceRelativePath = path.relative(process.cwd(), resolvedFsPath).replace(/\\/g, '/');
69
+ const normalizedPath = (0, core_1.normalize)(workspaceRelativePath);
70
+ if (!tree.exists(normalizedPath)) {
71
+ throw new Error(`Cannot find routes file: ${normalizedPath}`);
72
+ }
73
+ return normalizedPath;
74
+ }
75
+ return null;
76
+ }
77
+ /**
78
+ * Checks whether a specific provider is registered in the `providers` array of the
79
+ * standalone application configuration (typically within `app.config.ts`) in an Angular project.
80
+ *
81
+ * This function reads and parses the application configuration file, looks for the
82
+ * `providers` property in the configuration object, and checks whether it includes
83
+ * the specified provider name.
84
+ *
85
+ * @param host - The virtual file system tree used by Angular schematics.
86
+ * @param projectName - The name of the Angular project.
87
+ * @param providerName - The name of the provider to search for (as a string match).
88
+ * @returns A promise that resolves to `true` if the provider is found, otherwise `false`.
89
+ * @throws SchematicsException if the app config file cannot be read.
90
+ */
91
+ const hasProviderInStandaloneAppConfig = async (host, projectName, providerName) => {
92
+ const mainFilePath = await (0, util_1.getMainFilePath)(host, projectName);
93
+ const appConfigPath = (0, exports.getAppConfigPath)(host, mainFilePath);
94
+ const buffer = host.read(appConfigPath);
95
+ if (!buffer) {
96
+ throw new schematics_1.SchematicsException(`Could not read file: ${appConfigPath}`);
97
+ }
98
+ const source = ts.createSourceFile(appConfigPath, buffer.toString('utf-8'), ts.ScriptTarget.Latest, true);
99
+ const callExpressions = source.statements
100
+ .flatMap(stmt => (ts.isVariableStatement(stmt) ? stmt.declarationList.declarations : []))
101
+ .flatMap(decl => decl.initializer && ts.isObjectLiteralExpression(decl.initializer)
102
+ ? decl.initializer.properties
103
+ : [])
104
+ .filter(ts.isPropertyAssignment)
105
+ .filter(prop => prop.name.getText() === 'providers');
106
+ if (callExpressions.length === 0)
107
+ return false;
108
+ const providersArray = callExpressions[0].initializer;
109
+ return providersArray.elements.some(el => el.getText().includes(providerName));
110
+ };
111
+ exports.hasProviderInStandaloneAppConfig = hasProviderInStandaloneAppConfig;
112
+ /**
113
+ * Cleans up empty or invalid expressions (e.g., extra or trailing commas) from the
114
+ * `providers` array within a standalone Angular application configuration object.
115
+ *
116
+ * This function parses the source file's AST to locate variable declarations that
117
+ * define an object literal. It then searches for a `providers` property and removes
118
+ * any empty elements from its array literal, replacing it with a cleaned version.
119
+ *
120
+ * Typically used in Angular schematics to ensure the `providers` array in `app.config.ts`
121
+ * is free of empty slots after modifications.
122
+ *
123
+ * @param source - The TypeScript source file containing the app configuration.
124
+ * @param recorder - The recorder used to apply changes to the source file.
125
+ */
126
+ function cleanEmptyExprFromProviders(source, recorder) {
127
+ const varStatements = (0, angular_1.findNodes)(source, ts.isVariableStatement);
128
+ const printer = ts.createPrinter();
129
+ for (const stmt of varStatements) {
130
+ const declList = stmt.declarationList;
131
+ for (const decl of declList.declarations) {
132
+ if (!decl.initializer || !ts.isObjectLiteralExpression(decl.initializer))
133
+ continue;
134
+ const obj = decl.initializer;
135
+ const providersProp = obj.properties.find(prop => ts.isPropertyAssignment(prop) &&
136
+ ts.isIdentifier(prop.name) &&
137
+ prop.name.text === 'providers');
138
+ if (!providersProp || !ts.isArrayLiteralExpression(providersProp.initializer))
139
+ continue;
140
+ const arrayLiteral = providersProp.initializer;
141
+ const cleanedArray = (0, ast_1.removeEmptyElementsFromArrayLiteral)(arrayLiteral);
142
+ recorder.remove(arrayLiteral.getStart(), arrayLiteral.getWidth());
143
+ recorder.insertLeft(arrayLiteral.getStart(), printer.printNode(ts.EmitHint.Expression, cleanedArray, source));
144
+ }
145
+ }
146
+ }
146
147
  //# sourceMappingURL=standalone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standalone.js","sourceRoot":"","sources":["../../../../packages/schematics/src/utils/standalone.ts"],"names":[],"mappings":";;;AAAA,2DAAuF;AACvF,oDAA0F;AAC1F,gEAAgE;AAChE,iCAAiC;AACjC,+CAAuD;AACvD,6BAA6B;AAC7B,uCAAsC;AACtC,+BAA4D;AAE5D;;;;;;;;;;GAUG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAE,YAAoB,EAAU,EAAE;IAC3E,MAAM,aAAa,GAAG,IAAA,mCAA4B,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACvE,MAAM,SAAS,GAAG,IAAA,0BAAa,EAAC,aAAa,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACnE,OAAO,SAAS,EAAE,QAAQ,IAAI,EAAE,CAAC;AACnC,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B;AAEF;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAAC,IAAU,EAAE,YAAoB;IAChE,MAAM,aAAa,GAAG,IAAA,wBAAgB,EAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3D,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QAAE,OAAO,IAAI,CAAC;IAE/D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,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M,aAAa,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,CACvC,IAAI,CAAC,EAAE,CACL,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC;gBAC7B,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CACR,CAAC;YAE3B,IAAI,CAAC,aAAa,IAAI,CAAC,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC,WAAW,CAAC;gBAAE,SAAS;YAExF,MAAM,YAAY,GAAG,aAAa,CAAC,WAAW,CAAC;YAC/C,MAAM,YAAY,GAAG,IAAA,yCAAmC,EAAC,YAAY,CAAC,CAAC;YAEvE,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC;YAClE,QAAQ,CAAC,UAAU,CACjB,YAAY,CAAC,QAAQ,EAAE,EACvB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CAChE,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
package/utils/text.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export declare const lower: (text: string) => string;
2
- export declare const upper: (text: string) => string;
3
- export declare const camel: (text: string) => string;
4
- export declare const pascal: (text: string) => string;
5
- export declare const kebab: (text: string) => string;
6
- export declare const snake: (text: string) => string;
7
- export declare const macro: (text: string) => string;
8
- export declare const dir: (text: string) => string;
9
- export declare const quote: (value: number | string) => string | number;
10
- export declare function camelizeHyphen(str: string): string;
1
+ export declare const lower: (text: string) => string;
2
+ export declare const upper: (text: string) => string;
3
+ export declare const camel: (text: string) => string;
4
+ export declare const pascal: (text: string) => string;
5
+ export declare const kebab: (text: string) => string;
6
+ export declare const snake: (text: string) => string;
7
+ export declare const macro: (text: string) => string;
8
+ export declare const dir: (text: string) => string;
9
+ export declare const quote: (value: number | string) => string | number;
10
+ export declare function camelizeHyphen(str: string): string;
package/utils/text.js CHANGED
@@ -1,60 +1,60 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.camelizeHyphen = exports.quote = exports.dir = exports.macro = exports.snake = exports.kebab = exports.pascal = exports.camel = exports.upper = exports.lower = void 0;
4
- /* eslint-disable no-useless-escape */
5
- const core_1 = require("@angular-devkit/core");
6
- const lower = (text) => text.toLowerCase();
7
- exports.lower = lower;
8
- const upper = (text) => text.toUpperCase();
9
- exports.upper = upper;
10
- const camel = (text) => toCamelCase(_(text));
11
- exports.camel = camel;
12
- const pascal = (text) => core_1.strings.classify(_(text));
13
- exports.pascal = pascal;
14
- const kebab = (text) => core_1.strings.dasherize(_(text));
15
- exports.kebab = kebab;
16
- const snake = (text) => core_1.strings.underscore(_(text));
17
- exports.snake = snake;
18
- const macro = (text) => (0, exports.upper)((0, exports.snake)(text));
19
- exports.macro = macro;
20
- const dir = (text) => core_1.strings.dasherize(text.replace(/\./g, '/').replace(/\/\//g, '/'));
21
- exports.dir = dir;
22
- const quote = (value) => typeof value === 'string' ? `'${value.replace(/'/g, "\\'")}'` : value;
23
- exports.quote = quote;
24
- function _(text) {
25
- return text.replace(/\./g, '_');
26
- }
27
- // https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Utilities/StringUtils.cs#L155
28
- function toCamelCase(str) {
29
- if (!str || !isUpperCase(str[0]))
30
- return str;
31
- const chars = str.split('');
32
- const { length } = chars;
33
- for (let i = 0; i < length; i++) {
34
- if (i === 1 && !isUpperCase(chars[i]))
35
- break;
36
- const hasNext = i + 1 < length;
37
- if (i > 0 && hasNext && !isUpperCase(chars[i + 1])) {
38
- if (isSeparator(chars[i + 1])) {
39
- chars[i] = toLowerCase(chars[i]);
40
- }
41
- break;
42
- }
43
- chars[i] = toLowerCase(chars[i]);
44
- }
45
- return chars.join('');
46
- }
47
- function isSeparator(str = '') {
48
- return /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/.test(str);
49
- }
50
- function isUpperCase(str = '') {
51
- return /[A-Z]+/.test(str);
52
- }
53
- function toLowerCase(str = '') {
54
- return str.toLowerCase();
55
- }
56
- function camelizeHyphen(str) {
57
- return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
58
- }
59
- exports.camelizeHyphen = camelizeHyphen;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.quote = exports.dir = exports.macro = exports.snake = exports.kebab = exports.pascal = exports.camel = exports.upper = exports.lower = void 0;
4
+ exports.camelizeHyphen = camelizeHyphen;
5
+ /* eslint-disable no-useless-escape */
6
+ const core_1 = require("@angular-devkit/core");
7
+ const lower = (text) => text.toLowerCase();
8
+ exports.lower = lower;
9
+ const upper = (text) => text.toUpperCase();
10
+ exports.upper = upper;
11
+ const camel = (text) => toCamelCase(_(text));
12
+ exports.camel = camel;
13
+ const pascal = (text) => core_1.strings.classify(_(text));
14
+ exports.pascal = pascal;
15
+ const kebab = (text) => core_1.strings.dasherize(_(text));
16
+ exports.kebab = kebab;
17
+ const snake = (text) => core_1.strings.underscore(_(text));
18
+ exports.snake = snake;
19
+ const macro = (text) => (0, exports.upper)((0, exports.snake)(text));
20
+ exports.macro = macro;
21
+ const dir = (text) => core_1.strings.dasherize(text.replace(/\./g, '/').replace(/\/\//g, '/'));
22
+ exports.dir = dir;
23
+ const quote = (value) => typeof value === 'string' ? `'${value.replace(/'/g, "\\'")}'` : value;
24
+ exports.quote = quote;
25
+ function _(text) {
26
+ return text.replace(/\./g, '_');
27
+ }
28
+ // https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Utilities/StringUtils.cs#L155
29
+ function toCamelCase(str) {
30
+ if (!str || !isUpperCase(str[0]))
31
+ return str;
32
+ const chars = str.split('');
33
+ const { length } = chars;
34
+ for (let i = 0; i < length; i++) {
35
+ if (i === 1 && !isUpperCase(chars[i]))
36
+ break;
37
+ const hasNext = i + 1 < length;
38
+ if (i > 0 && hasNext && !isUpperCase(chars[i + 1])) {
39
+ if (isSeparator(chars[i + 1])) {
40
+ chars[i] = toLowerCase(chars[i]);
41
+ }
42
+ break;
43
+ }
44
+ chars[i] = toLowerCase(chars[i]);
45
+ }
46
+ return chars.join('');
47
+ }
48
+ function isSeparator(str = '') {
49
+ return /[\s\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]+/.test(str);
50
+ }
51
+ function isUpperCase(str = '') {
52
+ return /[A-Z]+/.test(str);
53
+ }
54
+ function toLowerCase(str = '') {
55
+ return str.toLowerCase();
56
+ }
57
+ function camelizeHyphen(str) {
58
+ return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
59
+ }
60
60
  //# sourceMappingURL=text.js.map
package/utils/text.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../packages/schematics/src/utils/text.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,+CAA+C;AAExC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAA7C,QAAA,KAAK,SAAwC;AACnD,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;AAA7C,QAAA,KAAK,SAAwC;AACnD,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAA/C,QAAA,KAAK,SAA0C;AACrD,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,cAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAArD,QAAA,MAAM,UAA+C;AAC3D,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,cAAO,C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,WAAW,CAAC,GAAG,GAAG,EAAE;IAC3B,OAAO,sEAAsE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1F,CAAC;AAED,SAAS,WAAW,CAAC,GAAG,GAAG,EAAE;IAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,WAAW,CAAC,GAAG,GAAG,EAAE;IAC3B,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC;AAC3B,CAAC;AACD,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAC3D,CAAC"}
package/utils/tree.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- export declare class TypeNode {
2
- data: string;
3
- parent: TypeNode | null;
4
- mapperFn: (node: TypeNode) => string;
5
- children: TypeNode[];
6
- index: number;
7
- constructor(data: string, parent: TypeNode | null, mapperFn?: (node: TypeNode) => string);
8
- toGenerics(): string[];
9
- toString(): string;
10
- valueOf(): string;
11
- }
12
- export declare function parseGenericsOld(type: string, mapperFn?: TypeNodeMapperFn): TypeNode;
13
- export declare function parseGenerics(type: string, mapperFn?: TypeNodeMapperFn, parent?: TypeNode | null): TypeNode;
14
- export declare type TypeNodeMapperFn = (node: TypeNode) => string;
1
+ export declare class TypeNode {
2
+ data: string;
3
+ parent: TypeNode | null;
4
+ mapperFn: (node: TypeNode) => string;
5
+ children: TypeNode[];
6
+ index: number;
7
+ constructor(data: string, parent: TypeNode | null, mapperFn?: (node: TypeNode) => string);
8
+ toGenerics(): string[];
9
+ toString(): string;
10
+ valueOf(): string;
11
+ }
12
+ export declare function parseGenericsOld(type: string, mapperFn?: TypeNodeMapperFn): TypeNode;
13
+ export declare function parseGenerics(type: string, mapperFn?: TypeNodeMapperFn, parent?: TypeNode | null): TypeNode;
14
+ export type TypeNodeMapperFn = (node: TypeNode) => string;