@rxap/plugin-angular 20.0.1-dev.1 → 20.0.1-dev.11

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 (274) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc.json +44 -0
  3. package/CHANGELOG.md +43 -0
  4. package/LICENSE +621 -0
  5. package/README.md.handlebars +115 -0
  6. package/jest.config.ts +11 -0
  7. package/package.json +11 -24
  8. package/project.json +68 -0
  9. package/schematics.yaml +6 -0
  10. package/src/application.ts +124 -0
  11. package/src/executors/check-ng-package/executor.ts +33 -0
  12. package/src/executors/config/executor.ts +74 -0
  13. package/src/executors/i18n/executor.ts +198 -0
  14. package/src/executors/tailwind/executor.ts +34 -0
  15. package/src/generators/convert-to-buildable-library/generator.ts +110 -0
  16. package/src/generators/fix-schematic/generator.ts +103 -0
  17. package/src/generators/fix-schematic/index.ts +5 -0
  18. package/src/generators/init/coerce-nx-json.ts +72 -0
  19. package/src/generators/init/generator.ts +28 -0
  20. package/src/generators/init/index.ts +5 -0
  21. package/src/generators/init/init-workspace.ts +84 -0
  22. package/src/generators/init-application/assert-main-statements.ts +74 -0
  23. package/src/generators/init-application/cleanup.ts +127 -0
  24. package/src/generators/init-application/coerce-app-config.ts +147 -0
  25. package/src/generators/init-application/coerce-environment-files.ts +105 -0
  26. package/src/generators/init-application/coerce-localazy-config-file.ts +26 -0
  27. package/src/generators/init-application/coerce-project.ts +128 -0
  28. package/src/generators/init-application/generate-authentication.ts +122 -0
  29. package/src/generators/init-application/generate-monolithic.spec.ts +45 -0
  30. package/src/generators/init-application/generate-monolithic.ts +57 -0
  31. package/src/generators/init-application/generator.ts +356 -0
  32. package/src/generators/init-application/index.ts +5 -0
  33. package/src/generators/init-application/link-mfe-remote-with-host.ts +60 -0
  34. package/src/generators/init-application/project-i18n-configuration.ts +4 -0
  35. package/src/generators/init-application/update-git-ignore.ts +22 -0
  36. package/src/generators/init-application/update-main-file.ts +118 -0
  37. package/src/generators/init-application/update-project-targets.ts +229 -0
  38. package/src/generators/init-application/update-tags.ts +30 -0
  39. package/src/generators/init-application/update-target-defaults.ts +43 -0
  40. package/src/generators/init-application/update-ts-config.ts +31 -0
  41. package/src/generators/init-component/generator.ts +147 -0
  42. package/src/generators/init-component/index.ts +5 -0
  43. package/src/generators/init-feature/generator.ts +77 -0
  44. package/src/generators/init-feature/index.ts +5 -0
  45. package/src/generators/init-feature-library/generator.ts +82 -0
  46. package/src/generators/init-feature-library/index.ts +5 -0
  47. package/src/generators/init-feature-library/init-project.ts +53 -0
  48. package/src/generators/init-feature-library/init-workspace.ts +10 -0
  49. package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.ts +46 -0
  50. package/src/generators/init-library/cleanup.ts +22 -0
  51. package/src/generators/init-library/coerce-projects.ts +118 -0
  52. package/src/generators/init-library/coerce-tailwind-theme-scss.ts +27 -0
  53. package/src/generators/init-library/extend-angular-specific-eslint.ts +37 -0
  54. package/src/generators/init-library/generator.ts +87 -0
  55. package/src/generators/init-library/has-index-scss.ts +14 -0
  56. package/src/generators/init-library/has-tailwind-config.ts +9 -0
  57. package/src/generators/init-library/index.ts +5 -0
  58. package/src/generators/init-library/init-project.ts +46 -0
  59. package/src/generators/init-library/init-workspace.ts +26 -0
  60. package/src/generators/init-library/is-ng-packagr-project.ts +9 -0
  61. package/src/generators/init-library/ng-package-json.ts +23 -0
  62. package/src/generators/init-library/set-general-target-defaults.ts +36 -0
  63. package/src/generators/init-library/update-package-json.ts +26 -0
  64. package/src/generators/init-library/update-project-ng-package-configuration.ts +51 -0
  65. package/src/generators/init-library/update-ts-config.ts +24 -0
  66. package/src/generators/schematic/generator.ts +179 -0
  67. package/src/generators/schematic/index.ts +5 -0
  68. package/src/i18n.ts +130 -0
  69. package/src/lib/angular-version.ts +1 -0
  70. package/src/lib/coerce-cypress-component-testing.ts +113 -0
  71. package/src/lib/coerce-test-setup.ts +60 -0
  72. package/src/library.ts +153 -0
  73. package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.ts +32 -0
  74. package/src/migrations/update-19-0-0/migration.ts +283 -0
  75. package/src/test-setup.ts +24 -0
  76. package/tsconfig.json +20 -0
  77. package/tsconfig.lib.json +10 -0
  78. package/tsconfig.spec.json +15 -0
  79. package/tsconfig.typedoc.json +5 -0
  80. package/src/application.d.ts +0 -6
  81. package/src/application.js +0 -77
  82. package/src/application.js.map +0 -1
  83. package/src/executors/check-ng-package/executor.d.ts +0 -5
  84. package/src/executors/check-ng-package/executor.js +0 -30
  85. package/src/executors/check-ng-package/executor.js.map +0 -1
  86. package/src/executors/config/executor.d.ts +0 -10
  87. package/src/executors/config/executor.js +0 -65
  88. package/src/executors/config/executor.js.map +0 -1
  89. package/src/executors/i18n/executor.d.ts +0 -9
  90. package/src/executors/i18n/executor.js +0 -158
  91. package/src/executors/i18n/executor.js.map +0 -1
  92. package/src/executors/tailwind/executor.d.ts +0 -5
  93. package/src/executors/tailwind/executor.js +0 -31
  94. package/src/executors/tailwind/executor.js.map +0 -1
  95. package/src/generators/convert-to-buildable-library/generator.d.ts +0 -4
  96. package/src/generators/convert-to-buildable-library/generator.js +0 -88
  97. package/src/generators/convert-to-buildable-library/generator.js.map +0 -1
  98. package/src/generators/fix-schematic/generator.d.ts +0 -4
  99. package/src/generators/fix-schematic/generator.js +0 -72
  100. package/src/generators/fix-schematic/generator.js.map +0 -1
  101. package/src/generators/fix-schematic/index.d.ts +0 -2
  102. package/src/generators/fix-schematic/index.js +0 -7
  103. package/src/generators/fix-schematic/index.js.map +0 -1
  104. package/src/generators/init/coerce-nx-json.d.ts +0 -3
  105. package/src/generators/init/coerce-nx-json.js +0 -74
  106. package/src/generators/init/coerce-nx-json.js.map +0 -1
  107. package/src/generators/init/generator.d.ts +0 -4
  108. package/src/generators/init/generator.js +0 -19
  109. package/src/generators/init/generator.js.map +0 -1
  110. package/src/generators/init/index.d.ts +0 -2
  111. package/src/generators/init/index.js +0 -7
  112. package/src/generators/init/index.js.map +0 -1
  113. package/src/generators/init/init-workspace.d.ts +0 -3
  114. package/src/generators/init/init-workspace.js +0 -73
  115. package/src/generators/init/init-workspace.js.map +0 -1
  116. package/src/generators/init-application/assert-main-statements.d.ts +0 -4
  117. package/src/generators/init-application/assert-main-statements.js +0 -76
  118. package/src/generators/init-application/assert-main-statements.js.map +0 -1
  119. package/src/generators/init-application/cleanup.d.ts +0 -3
  120. package/src/generators/init-application/cleanup.js +0 -108
  121. package/src/generators/init-application/cleanup.js.map +0 -1
  122. package/src/generators/init-application/coerce-app-config.d.ts +0 -3
  123. package/src/generators/init-application/coerce-app-config.js +0 -143
  124. package/src/generators/init-application/coerce-app-config.js.map +0 -1
  125. package/src/generators/init-application/coerce-environment-files.d.ts +0 -5
  126. package/src/generators/init-application/coerce-environment-files.js +0 -75
  127. package/src/generators/init-application/coerce-environment-files.js.map +0 -1
  128. package/src/generators/init-application/coerce-localazy-config-file.d.ts +0 -2
  129. package/src/generators/init-application/coerce-localazy-config-file.js +0 -25
  130. package/src/generators/init-application/coerce-localazy-config-file.js.map +0 -1
  131. package/src/generators/init-application/coerce-project.d.ts +0 -4
  132. package/src/generators/init-application/coerce-project.js +0 -56
  133. package/src/generators/init-application/coerce-project.js.map +0 -1
  134. package/src/generators/init-application/generate-authentication.d.ts +0 -3
  135. package/src/generators/init-application/generate-authentication.js +0 -97
  136. package/src/generators/init-application/generate-authentication.js.map +0 -1
  137. package/src/generators/init-application/generate-monolithic.d.ts +0 -3
  138. package/src/generators/init-application/generate-monolithic.js +0 -45
  139. package/src/generators/init-application/generate-monolithic.js.map +0 -1
  140. package/src/generators/init-application/generator.d.ts +0 -4
  141. package/src/generators/init-application/generator.js +0 -257
  142. package/src/generators/init-application/generator.js.map +0 -1
  143. package/src/generators/init-application/index.d.ts +0 -2
  144. package/src/generators/init-application/index.js +0 -7
  145. package/src/generators/init-application/index.js.map +0 -1
  146. package/src/generators/init-application/link-mfe-remote-with-host.d.ts +0 -3
  147. package/src/generators/init-application/link-mfe-remote-with-host.js +0 -54
  148. package/src/generators/init-application/link-mfe-remote-with-host.js.map +0 -1
  149. package/src/generators/init-application/project-i18n-configuration.d.ts +0 -7
  150. package/src/generators/init-application/project-i18n-configuration.js +0 -3
  151. package/src/generators/init-application/project-i18n-configuration.js.map +0 -1
  152. package/src/generators/init-application/update-git-ignore.d.ts +0 -3
  153. package/src/generators/init-application/update-git-ignore.js +0 -17
  154. package/src/generators/init-application/update-git-ignore.js.map +0 -1
  155. package/src/generators/init-application/update-main-file.d.ts +0 -3
  156. package/src/generators/init-application/update-main-file.js +0 -106
  157. package/src/generators/init-application/update-main-file.js.map +0 -1
  158. package/src/generators/init-application/update-project-targets.d.ts +0 -6
  159. package/src/generators/init-application/update-project-targets.js +0 -210
  160. package/src/generators/init-application/update-project-targets.js.map +0 -1
  161. package/src/generators/init-application/update-tags.d.ts +0 -3
  162. package/src/generators/init-application/update-tags.js +0 -25
  163. package/src/generators/init-application/update-tags.js.map +0 -1
  164. package/src/generators/init-application/update-target-defaults.d.ts +0 -3
  165. package/src/generators/init-application/update-target-defaults.js +0 -30
  166. package/src/generators/init-application/update-target-defaults.js.map +0 -1
  167. package/src/generators/init-application/update-ts-config.d.ts +0 -2
  168. package/src/generators/init-application/update-ts-config.js +0 -30
  169. package/src/generators/init-application/update-ts-config.js.map +0 -1
  170. package/src/generators/init-component/generator.d.ts +0 -5
  171. package/src/generators/init-component/generator.js +0 -106
  172. package/src/generators/init-component/generator.js.map +0 -1
  173. package/src/generators/init-component/index.d.ts +0 -2
  174. package/src/generators/init-component/index.js +0 -7
  175. package/src/generators/init-component/index.js.map +0 -1
  176. package/src/generators/init-feature/generator.d.ts +0 -4
  177. package/src/generators/init-feature/generator.js +0 -53
  178. package/src/generators/init-feature/generator.js.map +0 -1
  179. package/src/generators/init-feature/index.d.ts +0 -2
  180. package/src/generators/init-feature/index.js +0 -7
  181. package/src/generators/init-feature/index.js.map +0 -1
  182. package/src/generators/init-feature-library/generator.d.ts +0 -4
  183. package/src/generators/init-feature-library/generator.js +0 -51
  184. package/src/generators/init-feature-library/generator.js.map +0 -1
  185. package/src/generators/init-feature-library/index.d.ts +0 -2
  186. package/src/generators/init-feature-library/index.js +0 -7
  187. package/src/generators/init-feature-library/index.js.map +0 -1
  188. package/src/generators/init-feature-library/init-project.d.ts +0 -3
  189. package/src/generators/init-feature-library/init-project.js +0 -41
  190. package/src/generators/init-feature-library/init-project.js.map +0 -1
  191. package/src/generators/init-feature-library/init-workspace.d.ts +0 -3
  192. package/src/generators/init-feature-library/init-workspace.js +0 -12
  193. package/src/generators/init-feature-library/init-workspace.js.map +0 -1
  194. package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.d.ts +0 -2
  195. package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.js +0 -39
  196. package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.js.map +0 -1
  197. package/src/generators/init-library/cleanup.d.ts +0 -2
  198. package/src/generators/init-library/cleanup.js +0 -16
  199. package/src/generators/init-library/cleanup.js.map +0 -1
  200. package/src/generators/init-library/coerce-projects.d.ts +0 -3
  201. package/src/generators/init-library/coerce-projects.js +0 -92
  202. package/src/generators/init-library/coerce-projects.js.map +0 -1
  203. package/src/generators/init-library/coerce-tailwind-theme-scss.d.ts +0 -2
  204. package/src/generators/init-library/coerce-tailwind-theme-scss.js +0 -22
  205. package/src/generators/init-library/coerce-tailwind-theme-scss.js.map +0 -1
  206. package/src/generators/init-library/extend-angular-specific-eslint.d.ts +0 -2
  207. package/src/generators/init-library/extend-angular-specific-eslint.js +0 -25
  208. package/src/generators/init-library/extend-angular-specific-eslint.js.map +0 -1
  209. package/src/generators/init-library/generator.d.ts +0 -4
  210. package/src/generators/init-library/generator.js +0 -56
  211. package/src/generators/init-library/generator.js.map +0 -1
  212. package/src/generators/init-library/has-index-scss.d.ts +0 -2
  213. package/src/generators/init-library/has-index-scss.js +0 -11
  214. package/src/generators/init-library/has-index-scss.js.map +0 -1
  215. package/src/generators/init-library/has-tailwind-config.d.ts +0 -2
  216. package/src/generators/init-library/has-tailwind-config.js +0 -8
  217. package/src/generators/init-library/has-tailwind-config.js.map +0 -1
  218. package/src/generators/init-library/index.d.ts +0 -2
  219. package/src/generators/init-library/index.js +0 -7
  220. package/src/generators/init-library/index.js.map +0 -1
  221. package/src/generators/init-library/init-project.d.ts +0 -3
  222. package/src/generators/init-library/init-project.js +0 -37
  223. package/src/generators/init-library/init-project.js.map +0 -1
  224. package/src/generators/init-library/init-workspace.d.ts +0 -3
  225. package/src/generators/init-library/init-workspace.js +0 -21
  226. package/src/generators/init-library/init-workspace.js.map +0 -1
  227. package/src/generators/init-library/is-ng-packagr-project.d.ts +0 -2
  228. package/src/generators/init-library/is-ng-packagr-project.js +0 -8
  229. package/src/generators/init-library/is-ng-packagr-project.js.map +0 -1
  230. package/src/generators/init-library/ng-package-json.d.ts +0 -8
  231. package/src/generators/init-library/ng-package-json.js +0 -16
  232. package/src/generators/init-library/ng-package-json.js.map +0 -1
  233. package/src/generators/init-library/set-general-target-defaults.d.ts +0 -2
  234. package/src/generators/init-library/set-general-target-defaults.js +0 -27
  235. package/src/generators/init-library/set-general-target-defaults.js.map +0 -1
  236. package/src/generators/init-library/update-package-json.d.ts +0 -2
  237. package/src/generators/init-library/update-package-json.js +0 -17
  238. package/src/generators/init-library/update-package-json.js.map +0 -1
  239. package/src/generators/init-library/update-project-ng-package-configuration.d.ts +0 -2
  240. package/src/generators/init-library/update-project-ng-package-configuration.js +0 -37
  241. package/src/generators/init-library/update-project-ng-package-configuration.js.map +0 -1
  242. package/src/generators/init-library/update-ts-config.d.ts +0 -2
  243. package/src/generators/init-library/update-ts-config.js +0 -22
  244. package/src/generators/init-library/update-ts-config.js.map +0 -1
  245. package/src/generators/schematic/generator.d.ts +0 -6
  246. package/src/generators/schematic/generator.js +0 -127
  247. package/src/generators/schematic/generator.js.map +0 -1
  248. package/src/generators/schematic/index.d.ts +0 -2
  249. package/src/generators/schematic/index.js +0 -7
  250. package/src/generators/schematic/index.js.map +0 -1
  251. package/src/i18n.d.ts +0 -6
  252. package/src/i18n.js +0 -83
  253. package/src/i18n.js.map +0 -1
  254. package/src/index.js +0 -10
  255. package/src/index.js.map +0 -1
  256. package/src/lib/angular-version.d.ts +0 -1
  257. package/src/lib/angular-version.js +0 -5
  258. package/src/lib/angular-version.js.map +0 -1
  259. package/src/lib/coerce-cypress-component-testing.d.ts +0 -2
  260. package/src/lib/coerce-cypress-component-testing.js +0 -78
  261. package/src/lib/coerce-cypress-component-testing.js.map +0 -1
  262. package/src/lib/coerce-test-setup.d.ts +0 -2
  263. package/src/lib/coerce-test-setup.js +0 -47
  264. package/src/lib/coerce-test-setup.js.map +0 -1
  265. package/src/library.d.ts +0 -6
  266. package/src/library.js +0 -100
  267. package/src/library.js.map +0 -1
  268. package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.d.ts +0 -2
  269. package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.js +0 -29
  270. package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.js.map +0 -1
  271. package/src/migrations/update-19-0-0/migration.d.ts +0 -9
  272. package/src/migrations/update-19-0-0/migration.js +0 -220
  273. package/src/migrations/update-19-0-0/migration.js.map +0 -1
  274. /package/src/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,147 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import {
3
+ CoerceAppConfigProvider,
4
+ CoerceImports,
5
+ ProviderObject,
6
+ } from '@rxap/ts-morph';
7
+ import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
8
+ import { InitApplicationGeneratorSchema } from './schema';
9
+
10
+ export function coerceAppConfig(tree: Tree, projectName: string, options: InitApplicationGeneratorSchema,) {
11
+ TsMorphAngularProjectTransform(tree, {
12
+ project: projectName,
13
+ }, (_, [ sourceFile ]) => {
14
+ const providers: Array<string | ProviderObject> = [
15
+ 'provideRouter(appRoutes, withEnabledBlockingInitialNavigation())',
16
+ 'provideAnimations()',
17
+ 'ProvideErrorHandler()',
18
+ 'ProvideEnvironment(environment)',
19
+ ];
20
+ const httpInterceptors = [
21
+ 'HttpErrorInterceptor',
22
+ ];
23
+ const importProvidersFrom: string[] = [];
24
+ CoerceImports(sourceFile, [
25
+ {
26
+ moduleSpecifier: '@angular/platform-browser/animations',
27
+ namedImports: [ 'provideAnimations' ],
28
+ },
29
+ {
30
+ moduleSpecifier: '@angular/router',
31
+ namedImports: [ 'provideRouter', 'withEnabledBlockingInitialNavigation' ],
32
+ },
33
+ {
34
+ moduleSpecifier: './app.routes',
35
+ namedImports: [ 'appRoutes' ],
36
+ },
37
+ {
38
+ moduleSpecifier: '@rxap/ngx-error',
39
+ namedImports: [ 'ProvideErrorHandler', 'HttpErrorInterceptor' ],
40
+ },
41
+ {
42
+ moduleSpecifier: '@rxap/environment',
43
+ namedImports: [ 'ProvideEnvironment' ],
44
+ },
45
+ {
46
+ moduleSpecifier: '../environments/environment',
47
+ namedImports: [ 'environment' ],
48
+ },
49
+ ]);
50
+ if (options.monolithic) {
51
+ providers.push('ProvidePubSub()');
52
+ providers.push('ProvideChangelog()');
53
+ providers.push('provideTheme()');
54
+ providers.push('provideExternalApps()');
55
+ importProvidersFrom.push('MarkdownModule.forRoot()');
56
+ CoerceImports(sourceFile, [
57
+ {
58
+ moduleSpecifier: '@rxap/ngx-changelog',
59
+ namedImports: [ 'ProvideChangelog' ],
60
+ },
61
+ {
62
+ moduleSpecifier: 'ngx-markdown',
63
+ namedImports: [ 'MarkdownModule' ],
64
+ },
65
+ {
66
+ moduleSpecifier: '@rxap/ngx-pub-sub',
67
+ namedImports: [ 'ProvidePubSub' ],
68
+ },
69
+ {
70
+ moduleSpecifier: '@rxap/ngx-theme',
71
+ namedImports: [ 'provideTheme' ],
72
+ },
73
+ {
74
+ moduleSpecifier: '@rxap/layout',
75
+ namedImports: [ 'provideExternalApps' ],
76
+ }
77
+ ]);
78
+ }
79
+ if (options.oauth) {
80
+ providers.push('provideOAuthClient()');
81
+ providers.push('ProvideAuth()');
82
+ httpInterceptors.push('BearerTokenInterceptor');
83
+ CoerceImports(sourceFile, [
84
+ {
85
+ moduleSpecifier: 'angular-oauth2-oidc',
86
+ namedImports: [ 'provideOAuthClient' ],
87
+ },
88
+ {
89
+ moduleSpecifier: '@rxap/oauth',
90
+ namedImports: [ 'ProvideAuth' ],
91
+ },
92
+ {
93
+ moduleSpecifier: '@rxap/authentication',
94
+ namedImports: [ 'BearerTokenInterceptor' ],
95
+ },
96
+ ]);
97
+ }
98
+ if (options.i18n) {
99
+ httpInterceptors.push('LanguageInterceptor');
100
+ CoerceImports(sourceFile, [
101
+ {
102
+ moduleSpecifier: '@rxap/ngx-localize',
103
+ namedImports: [ 'LanguageInterceptor' ],
104
+ },
105
+ ]);
106
+ }
107
+ if (options.serviceWorker) {
108
+ providers.push(
109
+ `provideServiceWorker('ngsw-worker.js', { enabled: environment.serviceWorker, registrationStrategy: 'registerWhenStable:30000' })`);
110
+ providers.push('ProvideServiceWorkerUpdater(withDialogUpdater())');
111
+ CoerceImports(sourceFile, [
112
+ {
113
+ moduleSpecifier: '@angular/service-worker',
114
+ namedImports: [ 'provideServiceWorker' ],
115
+ },
116
+ {
117
+ moduleSpecifier: '@rxap/service-worker',
118
+ namedImports: [ 'ProvideServiceWorkerUpdater', 'withDialogUpdater' ],
119
+ },
120
+ ]);
121
+ }
122
+ if (options.material) {
123
+ providers.push('ProvideIconAssetPath()');
124
+ CoerceImports(sourceFile, [
125
+ {
126
+ moduleSpecifier: '@rxap/icon',
127
+ namedImports: [ 'ProvideIconAssetPath' ],
128
+ },
129
+ ]);
130
+ }
131
+ switch (options.authentication) {
132
+ case 'oauth2-proxy':
133
+ providers.push('provideOauth2Proxy()');
134
+ CoerceImports(sourceFile, {
135
+ moduleSpecifier: '@rxap/ngx-oauth2-proxy',
136
+ namedImports: [ 'provideOauth2Proxy' ],
137
+ });
138
+ break;
139
+ }
140
+ CoerceAppConfigProvider(sourceFile, {
141
+ overwrite: options.overwrite,
142
+ providers,
143
+ httpInterceptors,
144
+ importProvidersFrom,
145
+ });
146
+ }, [ '/app/app.config.ts' ]);
147
+ }
@@ -0,0 +1,105 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import {
3
+ CoerceImports,
4
+ CoerceVariableDeclaration,
5
+ } from '@rxap/ts-morph';
6
+ import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
7
+ import {
8
+ WriterFunction,
9
+ Writers,
10
+ } from 'ts-morph';
11
+ import { InitApplicationGeneratorSchema } from './schema';
12
+
13
+ export function coerceEnvironmentFiles(tree: Tree, options: InitApplicationGeneratorSchema & { project: string }) {
14
+
15
+ TsMorphAngularProjectTransform(
16
+ tree,
17
+ {
18
+ project: options.project,
19
+ },
20
+ (project, [ sourceFile, prodSourceFile ]) => {
21
+
22
+ CoerceImports(sourceFile, {
23
+ moduleSpecifier: '@rxap/environment',
24
+ namedImports: [ 'Environment' ],
25
+ });
26
+ CoerceImports(prodSourceFile, {
27
+ moduleSpecifier: '@rxap/environment',
28
+ namedImports: [ 'Environment' ],
29
+ });
30
+
31
+ const baseEnvironment: Record<string, WriterFunction | string> = {
32
+ name: w => w.quote('development'),
33
+ production: 'false',
34
+ app: w => w.quote(options.project),
35
+ };
36
+
37
+ // region dev environment
38
+
39
+ if (options.serviceWorker) {
40
+ baseEnvironment['serviceWorker'] = 'false';
41
+ }
42
+
43
+ if (options.sentry) {
44
+ baseEnvironment['sentry'] = Writers.object({
45
+ enabled: 'false',
46
+ debug: 'false',
47
+ });
48
+ }
49
+
50
+ if (options.moduleFederation === 'host') {
51
+ baseEnvironment['moduleFederation'] = Writers.object({
52
+ manifest: w => w.quote('/module-federation.manifest.json'),
53
+ });
54
+ }
55
+
56
+ const normal = CoerceVariableDeclaration(sourceFile, 'environment', {
57
+ type: 'Environment',
58
+ initializer: Writers.object(baseEnvironment),
59
+ });
60
+
61
+ if (options.overwrite) {
62
+ normal.set({ initializer: Writers.object(baseEnvironment) });
63
+ }
64
+
65
+ // region
66
+
67
+ // region prod environment
68
+
69
+ if (options.moduleFederation === 'host') {
70
+ delete baseEnvironment['moduleFederation'];
71
+ }
72
+
73
+ if (options.serviceWorker) {
74
+ baseEnvironment['serviceWorker'] = 'true';
75
+ }
76
+
77
+ if (options.sentry) {
78
+ baseEnvironment['sentry'] = Writers.object({
79
+ enabled: 'true',
80
+ debug: 'false',
81
+ });
82
+ }
83
+
84
+ baseEnvironment['name'] = w => w.quote('production');
85
+ baseEnvironment['production'] = 'true';
86
+
87
+ const prod = CoerceVariableDeclaration(prodSourceFile, 'environment', {
88
+ type: 'Environment',
89
+ initializer: Writers.object(baseEnvironment),
90
+ });
91
+
92
+ if (options.overwrite) {
93
+ prod.set({ initializer: Writers.object(baseEnvironment) });
94
+ }
95
+
96
+ // endregion
97
+
98
+ },
99
+ [
100
+ '/environments/environment.ts?',
101
+ '/environments/environment.prod.ts?',
102
+ ],
103
+ );
104
+
105
+ }
@@ -0,0 +1,26 @@
1
+ import {
2
+ ProjectConfiguration,
3
+ Tree,
4
+ } from '@nx/devkit';
5
+ import { CoerceFile } from '@rxap/workspace-utilities';
6
+ import { join } from 'path';
7
+
8
+ export function coerceLocalazyConfigFile(tree: Tree, project: ProjectConfiguration) {
9
+ const projectRoot = project.root;
10
+ const localazyConfigPath = join(projectRoot, 'localazy.json');
11
+ CoerceFile(tree, localazyConfigPath, JSON.stringify({
12
+ upload: {
13
+ type: 'xliff',
14
+ deprecate: 'file',
15
+ features: [
16
+ 'use_defined_lang_for_source',
17
+ 'dont_parse_target',
18
+ ],
19
+ files: 'src/i18n/messages.xlf',
20
+ },
21
+ download: {
22
+ includeSourceLang: true,
23
+ files: 'src/i18n/${languageCode}.xlf',
24
+ },
25
+ }, null, 2));
26
+ }
@@ -0,0 +1,128 @@
1
+ import {
2
+ applicationGenerator as angularApplicationGenerator,
3
+ E2eTestRunner,
4
+ host as angularHostGenerator,
5
+ remote as angularRemoteGenerator,
6
+ UnitTestRunner,
7
+ } from '@nx/angular/generators';
8
+ import { Schema as AngularApplicationGeneratorSchema } from '@nx/angular/src/generators/application/schema';
9
+ import { Schema as AngularHostGeneratorSchema } from '@nx/angular/src/generators/host/schema';
10
+ import { Schema as AngularRemoteGeneratorSchema } from '@nx/angular/src/generators/remote/schema';
11
+ import { Tree } from '@nx/devkit';
12
+ import {
13
+ GetDefaultGeneratorOptions,
14
+ HasProject,
15
+ } from '@rxap/workspace-utilities';
16
+ import { InitApplicationGeneratorSchema } from './schema';
17
+
18
+ export async function CoerceProjects(tree: Tree, options: InitApplicationGeneratorSchema) {
19
+
20
+ if (!options.coerce) {
21
+ return;
22
+ }
23
+
24
+ for (const projectName of options.projects ?? []) {
25
+
26
+ if (!HasProject(tree, projectName)) {
27
+
28
+ await CoerceProject(tree, projectName, options);
29
+
30
+ }
31
+
32
+ }
33
+
34
+ }
35
+
36
+ export async function CoerceProject(tree: Tree, projectName: string, options: InitApplicationGeneratorSchema) {
37
+
38
+ if (HasProject(tree, projectName)) {
39
+ console.log(`Project ${ projectName } already exists`);
40
+ return;
41
+ }
42
+
43
+ let directory = 'user-interface';
44
+ if (projectName.includes('-feature-')) {
45
+ directory += '/feature';
46
+ }
47
+ directory += `/${ projectName.replace('user-interface-', '').replace('feature-', '') }`;
48
+
49
+ const formOptions: any = options.coerce && typeof options.coerce === 'object' ? options.coerce : {};
50
+
51
+ if (formOptions.directory && (options.projects?.length ?? 0) > 1) {
52
+ throw new Error('The directory option is not allowed when multiple projects are initialized!');
53
+ }
54
+
55
+ if (options.moduleFederation) {
56
+
57
+ if (options.moduleFederation === 'host') {
58
+ const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularHostGeneratorSchema>>(tree, '@nx/angular:host');
59
+ const schema: AngularHostGeneratorSchema = {
60
+ style: 'scss',
61
+ inlineStyle: false,
62
+ inlineTemplate: false,
63
+ skipTests: false,
64
+ skipFormat: false,
65
+ skipPackageJson: false,
66
+ unitTestRunner: UnitTestRunner.Jest,
67
+ e2eTestRunner: E2eTestRunner.None,
68
+ linter: 'eslint',
69
+ strict: true,
70
+ standaloneConfig: true,
71
+ ...defaultOptions,
72
+ directory,
73
+ ...formOptions,
74
+ name: projectName,
75
+ dynamic: true,
76
+ projectNameAndRootFormat: 'as-provided',
77
+ };
78
+ await angularHostGenerator(tree, schema);
79
+ } else {
80
+ const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularRemoteGeneratorSchema>>(tree, '@nx/angular:remote');
81
+ const schema: AngularRemoteGeneratorSchema = {
82
+ style: 'scss',
83
+ inlineStyle: false,
84
+ inlineTemplate: false,
85
+ skipTests: false,
86
+ skipFormat: false,
87
+ skipPackageJson: false,
88
+ unitTestRunner: UnitTestRunner.Jest,
89
+ e2eTestRunner: E2eTestRunner.None,
90
+ linter: 'eslint',
91
+ strict: true,
92
+ standaloneConfig: true,
93
+ ...defaultOptions,
94
+ directory,
95
+ ...formOptions,
96
+ host: options.host,
97
+ name: projectName,
98
+ projectNameAndRootFormat: 'as-provided',
99
+ };
100
+ await angularRemoteGenerator(tree, schema);
101
+ }
102
+
103
+ } else {
104
+ const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularApplicationGeneratorSchema>>(tree, '@nx/angular:application');
105
+ const schema: AngularApplicationGeneratorSchema = {
106
+ style: 'scss',
107
+ routing: true,
108
+ inlineStyle: false,
109
+ inlineTemplate: false,
110
+ skipTests: false,
111
+ skipFormat: false,
112
+ skipPackageJson: false,
113
+ unitTestRunner: UnitTestRunner.Jest,
114
+ e2eTestRunner: E2eTestRunner.None,
115
+ linter: 'eslint',
116
+ strict: true,
117
+ standaloneConfig: true,
118
+ minimal: true,
119
+ ...defaultOptions,
120
+ directory,
121
+ ...formOptions,
122
+ name: projectName,
123
+ projectNameAndRootFormat: 'as-provided',
124
+ };
125
+ await angularApplicationGenerator(tree, schema);
126
+ }
127
+
128
+ }
@@ -0,0 +1,122 @@
1
+ import {
2
+ ProjectConfiguration,
3
+ Tree,
4
+ } from '@nx/devkit';
5
+ import {
6
+ CoerceAppRoutes,
7
+ CoerceImports,
8
+ CoerceRouteGuard,
9
+ } from '@rxap/ts-morph';
10
+ import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
11
+ import {
12
+ AddPackageJsonDependency,
13
+ CoerceTarget,
14
+ GetProject,
15
+ GetWorkspaceProject,
16
+ GetWorkspaceProjectName,
17
+ UpdateJsonFile,
18
+ } from '@rxap/workspace-utilities';
19
+ import { parseDocument } from 'yaml';
20
+ import { InitApplicationGeneratorSchema } from './schema';
21
+
22
+ async function defaultAuthentication(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
23
+
24
+ console.log('default authentication');
25
+
26
+ await AddPackageJsonDependency(tree, '@rxap/ngx-material-authentication', 'latest', { soft: true });
27
+
28
+ TsMorphAngularProjectTransform(tree, {
29
+ project: projectName,
30
+ }, (_, [ appSourceFile ]) => {
31
+ CoerceAppRoutes(appSourceFile, {
32
+ itemList: [
33
+ {
34
+ route: {
35
+ path: 'authentication',
36
+ loadChildren: {
37
+ import: '@rxap/ngx-material-authentication',
38
+ then: 'AUTHENTICATION_ROUTE'
39
+ }
40
+ }
41
+ }
42
+ ]
43
+ });
44
+ CoerceRouteGuard(appSourceFile, [''], 'RxapAuthenticationGuard', { routeArrayName: 'appRoutes' });
45
+ CoerceImports(appSourceFile, {
46
+ namedImports: ['RxapAuthenticationGuard'],
47
+ moduleSpecifier: '@rxap/authentication',
48
+ });
49
+ }, [ 'app/app.routes.ts?' ]);
50
+ }
51
+
52
+ async function oauth2ProxyAuthentication(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
53
+
54
+ console.log('oauth2-proxy authentication');
55
+
56
+ await AddPackageJsonDependency(tree, '@rxap/ngx-oauth2-proxy', 'latest', { soft: true });
57
+
58
+ TsMorphAngularProjectTransform(tree, {
59
+ project: projectName,
60
+ }, (_, [ appSourceFile ]) => {
61
+ CoerceRouteGuard(appSourceFile, [''], 'oauth2ProxyGuard', { routeArrayName: 'appRoutes' });
62
+ CoerceImports(appSourceFile, {
63
+ namedImports: ['oauth2ProxyGuard'],
64
+ moduleSpecifier: '@rxap/ngx-oauth2-proxy',
65
+ });
66
+ }, [ 'app/app.routes.ts?' ]);
67
+
68
+ if (tree.exists('docker-compose.yml')) {
69
+ const dockerComposeContent = tree.read('docker-compose.yml', 'utf-8')!;
70
+ const dockerCompose = parseDocument(dockerComposeContent);
71
+ if (dockerCompose.hasIn(['services', 'rxap-service-user'])) {
72
+ if (!dockerCompose.hasIn(['services', 'rxap-service-user', 'labels'])) {
73
+ dockerCompose.setIn(['services', 'rxap-service-user', 'labels'], [
74
+ 'traefik.http.routers.user.middlewares=oauth-signin@docker,oauth-verify@docker'
75
+ ]);
76
+ }
77
+ }
78
+ }
79
+
80
+ if (tree.exists('shared/angular/proxy.conf.json')) {
81
+ UpdateJsonFile(tree, proxyConf => {
82
+ proxyConf['/oauth2'] ??= {
83
+ "target": "https://127-0-0-1.nip.io:8443",
84
+ "secure": false
85
+ };
86
+ }, 'shared/angular/proxy.conf.json');
87
+ }
88
+
89
+ const workspaceProject = GetWorkspaceProject(tree);
90
+ if (workspaceProject.targets && 'docker-compose' in workspaceProject.targets) {
91
+ CoerceTarget(workspaceProject, 'docker-compose', {
92
+ options: {
93
+ options: {
94
+ middlewares: [
95
+ 'oauth-signin@docker',
96
+ 'oauth-verify@docker',
97
+ ],
98
+ },
99
+ },
100
+ });
101
+ }
102
+
103
+ }
104
+
105
+ export async function generateAuthentication(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
106
+
107
+ console.log('generate authentication');
108
+
109
+ switch (options.authentication) {
110
+
111
+ default:
112
+ case true:
113
+ return defaultAuthentication(tree, projectName, project, options);
114
+
115
+ case 'oauth2-proxy':
116
+ return oauth2ProxyAuthentication(tree, projectName, project, options);
117
+
118
+ }
119
+
120
+
121
+
122
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ addProjectConfiguration,
3
+ readProjectConfiguration,
4
+ Tree,
5
+ } from '@nx/devkit';
6
+ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
7
+ import { generateMonolithic } from './generate-monolithic';
8
+
9
+ describe('generateMonolithic()', () => {
10
+
11
+ let tree: Tree;
12
+ const projectName = 'app';
13
+
14
+ beforeEach(() => {
15
+ tree = createTreeWithEmptyWorkspace();
16
+ addProjectConfiguration(tree, projectName, {
17
+ root: 'app',
18
+ sourceRoot: 'app/src',
19
+ projectType: 'application',
20
+ });
21
+ });
22
+
23
+ it('should generate a monolithic application configuration', () => {
24
+
25
+ generateMonolithic(tree, projectName, readProjectConfiguration(tree, projectName), {});
26
+ expect(tree.children('app/src/app')).toMatchSnapshot();
27
+ expect(tree.read('app/src/app/app.routes.ts', 'utf-8')).toMatchSnapshot();
28
+ expect(tree.read('app/src/app/layout.routes.ts', 'utf-8')).toMatchSnapshot();
29
+ expect(tree.read('app/src/app/app.navigation.ts', 'utf-8')).toMatchSnapshot();
30
+
31
+ });
32
+
33
+ it('should use MinimalLayoutComponent and no navigation when moduleFederation is host', () => {
34
+
35
+ generateMonolithic(tree, projectName, readProjectConfiguration(tree, projectName), {
36
+ moduleFederation: 'host',
37
+ });
38
+ expect(tree.children('app/src/app')).toMatchSnapshot();
39
+ expect(tree.read('app/src/app/app.routes.ts', 'utf-8')).toMatchSnapshot();
40
+ expect(tree.read('app/src/app/layout.routes.ts', 'utf-8')).toMatchSnapshot();
41
+ expect(tree.exists('app/src/app/app.navigation.ts')).toBeFalsy();
42
+
43
+ });
44
+
45
+ });
@@ -0,0 +1,57 @@
1
+ import {
2
+ ProjectConfiguration,
3
+ Tree,
4
+ } from '@nx/devkit';
5
+ import {
6
+ CoerceAppNavigation,
7
+ CoerceAppRoutes,
8
+ CoerceLayoutRoutes,
9
+ } from '@rxap/ts-morph';
10
+ import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
11
+ import { CoerceFile } from '@rxap/workspace-utilities';
12
+ import { join } from 'path';
13
+ import { InitApplicationGeneratorSchema } from './schema';
14
+
15
+ export function generateMonolithic(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
16
+
17
+ if (!project.sourceRoot) {
18
+ throw new Error(`Project source root not found for project ${ projectName }`);
19
+ }
20
+
21
+ if (!tree.exists(join(project.sourceRoot, 'assets', 'logo.png'))) {
22
+ if (tree.exists('logo.png')) {
23
+ CoerceFile(tree, join(project.sourceRoot, 'assets', 'logo.png'), tree.read('logo.png')!, true);
24
+ }
25
+ }
26
+
27
+ TsMorphAngularProjectTransform(tree, {
28
+ project: projectName,
29
+ }, (_, [ appSourceFile, layoutSourceFile ]) => {
30
+ CoerceLayoutRoutes(layoutSourceFile, {
31
+ component: options.moduleFederation === 'host' ? 'MinimalLayoutComponent' : 'LayoutComponent',
32
+ withNavigation: options.moduleFederation !== 'host',
33
+ withStatusCheckGuard: options.apiStatusCheck,
34
+ });
35
+ CoerceAppRoutes(appSourceFile, {
36
+ itemList: [
37
+ {
38
+ route: {
39
+ path: options.layoutRoutePath ?? '',
40
+ loadChildren: './layout.routes'
41
+ }
42
+ }
43
+ ]
44
+ });
45
+ }, [ 'app/app.routes.ts?', 'app/layout.routes.ts?' ]);
46
+
47
+ if (options.moduleFederation !== 'host') {
48
+
49
+ TsMorphAngularProjectTransform(tree, {
50
+ project: projectName,
51
+ }, (_, [ navigationSourceFile ]) => {
52
+ CoerceAppNavigation(navigationSourceFile, { overwrite: options.overwrite });
53
+ }, [ 'app/app.navigation.ts?' ]);
54
+
55
+ }
56
+
57
+ }