@rxap/plugin-angular 16.1.0-dev.5 → 16.1.0-dev.50

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 (107) hide show
  1. package/CHANGELOG.md +396 -0
  2. package/LICENSE.md +621 -0
  3. package/README.md +50 -1
  4. package/generators.json +37 -0
  5. package/package.json +65 -46
  6. package/src/generators/fix-schematic/index.d.ts +2 -0
  7. package/src/generators/fix-schematic/index.js +7 -0
  8. package/src/generators/fix-schematic/index.js.map +1 -0
  9. package/src/generators/init/generator.js +13 -7
  10. package/src/generators/init/generator.js.map +1 -1
  11. package/src/generators/init/index.d.ts +2 -0
  12. package/src/generators/init/index.js +7 -0
  13. package/src/generators/init/index.js.map +1 -0
  14. package/src/generators/init/schema.d.ts +2 -0
  15. package/src/generators/init/schema.json +10 -0
  16. package/src/generators/init-application/files/app/app.navigation.ts.template +11 -0
  17. package/src/generators/init-application/files/app/app.routes.ts.template +14 -0
  18. package/src/generators/init-application/files/app/layout.routes.ts.template +33 -0
  19. package/src/generators/init-application/files/assets/icons/create-pwa-icons.sh +11 -0
  20. package/src/generators/init-application/files/assets/icons/icon-114x114.png +0 -0
  21. package/src/generators/init-application/files/assets/icons/icon-120x120.png +0 -0
  22. package/src/generators/init-application/files/assets/icons/icon-128x128.png +0 -0
  23. package/src/generators/init-application/files/assets/icons/icon-144x144.png +0 -0
  24. package/src/generators/init-application/files/assets/icons/icon-152x152.png +0 -0
  25. package/src/generators/init-application/files/assets/icons/icon-16x16.png +0 -0
  26. package/src/generators/init-application/files/assets/icons/icon-180x180.png +0 -0
  27. package/src/generators/init-application/files/assets/icons/icon-192x192.png +0 -0
  28. package/src/generators/init-application/files/assets/icons/icon-32x32.png +0 -0
  29. package/src/generators/init-application/files/assets/icons/icon-384x384.png +0 -0
  30. package/src/generators/init-application/files/assets/icons/icon-512x512.png +0 -0
  31. package/src/generators/init-application/files/assets/icons/icon-57x57.png +0 -0
  32. package/src/generators/init-application/files/assets/icons/icon-60x60.png +0 -0
  33. package/src/generators/init-application/files/assets/icons/icon-72x72.png +0 -0
  34. package/src/generators/init-application/files/assets/icons/icon-76x76.png +0 -0
  35. package/src/generators/init-application/files/assets/icons/icon-96x96.png +0 -0
  36. package/src/generators/init-application/files/assets/icons/icon.png +0 -0
  37. package/src/generators/init-application/files/assets/icons/icon.svg +43 -0
  38. package/src/generators/init-application/files/assets/logo.png +0 -0
  39. package/src/generators/init-application/files/assets/logo.svg +63 -0
  40. package/src/generators/init-application/files/monolithic/app/app.navigation.ts.template +11 -0
  41. package/src/generators/init-application/files/monolithic/app/app.routes.ts.template +14 -0
  42. package/src/generators/init-application/files/monolithic/app/layout.routes.ts.template +32 -0
  43. package/src/generators/init-application/files/monolithic/index.html.template +165 -0
  44. package/src/generators/init-application/files/monolithic/styles.scss.template +3 -0
  45. package/src/generators/init-application/files/oauth/silent-refresh.html +42 -0
  46. package/src/generators/init-application/files/service-worker/manifest.webmanifest +52 -0
  47. package/src/generators/init-application/files/shared/Dockerfile +29 -0
  48. package/src/generators/init-application/files/shared/assets/build.json +1 -0
  49. package/src/generators/init-application/files/shared/ngsw-config.json +2 -14
  50. package/src/generators/init-application/files/styles/_fonts.scss +9 -0
  51. package/src/generators/init-application/files/styles/_index.scss +10 -0
  52. package/src/generators/init-application/files/styles/_loading-animation.scss +200 -0
  53. package/src/generators/init-application/files/styles/_palette.scss +98 -0
  54. package/src/generators/init-application/files/styles/_table.scss +45 -0
  55. package/src/generators/init-application/files/styles/_theme.scss +14 -0
  56. package/src/generators/init-application/files/styles/_utilities.scss +112 -0
  57. package/src/generators/init-application/files/styles/_variables.scss +77 -0
  58. package/src/generators/init-application/files/styles/fonts/_croissant-one.scss +7 -0
  59. package/src/generators/init-application/files/styles/fonts/_fuggles.scss +7 -0
  60. package/src/generators/init-application/files/styles/fonts/_inclusive-sans.scss +7 -0
  61. package/src/generators/init-application/files/styles/fonts/_material-icons.scss +20 -0
  62. package/src/generators/init-application/files/styles/fonts/_mooli.scss +7 -0
  63. package/src/generators/init-application/files/styles/fonts/_pixelify-sans.scss +7 -0
  64. package/src/generators/init-application/files/styles/fonts/_roboto-mono.scss +7 -0
  65. package/src/generators/init-application/files/styles/fonts/_roboto.scss +95 -0
  66. package/src/generators/init-application/files/styles/fonts/_young-serif.scss +7 -0
  67. package/src/generators/init-application/files/styles/fonts/croissant-one.ttf +0 -0
  68. package/src/generators/init-application/files/styles/fonts/fuggles.ttf +0 -0
  69. package/src/generators/init-application/files/styles/fonts/inclusive-sans.ttf +0 -0
  70. package/src/generators/init-application/files/styles/fonts/material-icons.ttf +0 -0
  71. package/src/generators/init-application/files/styles/fonts/molli.ttf +0 -0
  72. package/src/generators/init-application/files/styles/fonts/pixelify-sans.ttf +0 -0
  73. package/src/generators/init-application/files/styles/fonts/roboto-mono.ttf +0 -0
  74. package/src/generators/init-application/files/styles/fonts/young-serif.ttf +0 -0
  75. package/src/generators/init-application/generator.js +446 -82
  76. package/src/generators/init-application/generator.js.map +1 -1
  77. package/src/generators/init-application/index.d.ts +2 -0
  78. package/src/generators/init-application/index.js +7 -0
  79. package/src/generators/init-application/index.js.map +1 -0
  80. package/src/generators/init-application/schema.d.ts +8 -0
  81. package/src/generators/init-application/schema.json +54 -8
  82. package/src/generators/init-feature/files/feature/__name__/routes.ts.template +10 -0
  83. package/src/generators/init-feature/generator.d.ts +11 -0
  84. package/src/generators/init-feature/generator.js +106 -0
  85. package/src/generators/init-feature/generator.js.map +1 -0
  86. package/src/generators/init-feature/index.d.ts +2 -0
  87. package/src/generators/init-feature/index.js +7 -0
  88. package/src/generators/init-feature/index.js.map +1 -0
  89. package/src/generators/init-feature/schema.d.ts +4 -0
  90. package/src/generators/init-feature/schema.json +20 -0
  91. package/src/generators/init-library/generator.js +88 -15
  92. package/src/generators/init-library/generator.js.map +1 -1
  93. package/src/generators/init-library/index.d.ts +2 -0
  94. package/src/generators/init-library/index.js +7 -0
  95. package/src/generators/init-library/index.js.map +1 -0
  96. package/src/generators/init-library/schema.d.ts +2 -0
  97. package/src/generators/init-library/schema.json +10 -0
  98. package/src/generators/schematic/index.d.ts +2 -0
  99. package/src/generators/schematic/index.js +7 -0
  100. package/src/generators/schematic/index.js.map +1 -0
  101. package/src/lib/skip-project.js +3 -3
  102. package/src/lib/skip-project.js.map +1 -1
  103. package/src/generators/init-application/files/shared/assets/Dockerfile +0 -5
  104. package/src/generators/init-application/files/shared/assets/nginx.conf +0 -74
  105. package/src/generators/init-application/files/shared/configuration/.gitkeep +0 -0
  106. package/src/generators/init-application/files/shared/i18n.index.html.hbs +0 -40
  107. /package/src/generators/init-application/files/{shared → assets}/.gitkeep +0 -0
@@ -5,10 +5,12 @@ const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const generator_utilities_1 = require("@rxap/generator-utilities");
7
7
  const plugin_localazy_1 = require("@rxap/plugin-localazy");
8
- const schematics_ts_morph_1 = require("@rxap/schematics-ts-morph");
8
+ const ts_morph_1 = require("@rxap/ts-morph");
9
+ const utilities_1 = require("@rxap/utilities");
9
10
  const workspace_ts_morph_1 = require("@rxap/workspace-ts-morph");
10
11
  const workspace_utilities_1 = require("@rxap/workspace-utilities");
11
12
  const path_1 = require("path");
13
+ const ts_morph_2 = require("ts-morph");
12
14
  const skip_project_1 = require("../../lib/skip-project");
13
15
  function skipProject(tree, options, project, projectName) {
14
16
  if ((0, skip_project_1.SkipNonAngularProject)(tree, options, project, projectName)) {
@@ -20,65 +22,51 @@ function skipProject(tree, options, project, projectName) {
20
22
  return false;
21
23
  }
22
24
  function updateProjectTargets(project, options) {
23
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
24
- var _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
25
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
26
+ var _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
25
27
  (_a = project.targets) !== null && _a !== void 0 ? _a : (project.targets = {});
26
28
  if (!project.targets['build']) {
27
29
  throw new Error(`The project '${project.name}' has no build target`);
28
30
  }
29
- (_b = (_s = project.targets)['config']) !== null && _b !== void 0 ? _b : (_s['config'] = {
30
- executor: '@rxap/plugin-application:config',
31
- options: {},
32
- configurations: {
33
- production: {},
34
- development: {},
31
+ if (project.targets['docker']) {
32
+ (_b = (_w = project.targets['docker']).options) !== null && _b !== void 0 ? _b : (_w.options = {});
33
+ (_c = (_x = project.targets['docker'].options).dockerfile) !== null && _c !== void 0 ? _c : (_x.dockerfile = 'shared/angular/Dockerfile');
34
+ }
35
+ (0, workspace_utilities_1.CoerceTarget)(project, 'serve', {
36
+ options: {
37
+ proxyConfig: 'shared/angular/proxy.conf.json',
35
38
  },
36
- });
39
+ }, workspace_utilities_1.Strategy.OVERWRITE);
40
+ (0, workspace_utilities_1.CoerceTarget)(project, 'config', {});
37
41
  if (project.targets['extract-i18n']) {
38
42
  if (options.i18n) {
39
- (_c = options.languages) !== null && _c !== void 0 ? _c : (options.languages = []);
43
+ (_d = options.languages) !== null && _d !== void 0 ? _d : (options.languages = []);
40
44
  if (options.languages.length === 0) {
41
45
  options.languages.push('en');
42
46
  }
43
- (_d = (_t = project.targets)['i18n']) !== null && _d !== void 0 ? _d : (_t['i18n'] = {
44
- executor: '@rxap/plugin-application:i18n',
45
- options: {
46
- availableLanguages: options.languages,
47
- defaultLanguage: options.languages[0],
48
- indexHtmlTemplate: 'shared/i18n.index.html.hbs',
49
- assets: true,
50
- },
51
- configurations: {
52
- production: {},
53
- development: {},
54
- },
55
- });
56
47
  project.targets['build'].configurations.production.localize = options.languages;
57
48
  (_e = project.i18n) !== null && _e !== void 0 ? _e : (project.i18n = {});
58
- (_f = (_u = project.i18n).sourceLocale) !== null && _f !== void 0 ? _f : (_u.sourceLocale = 'en-US');
59
- (_g = (_v = project.i18n).locales) !== null && _g !== void 0 ? _g : (_v.locales = {});
49
+ (_f = (_y = project.i18n).sourceLocale) !== null && _f !== void 0 ? _f : (_y.sourceLocale = 'en-US');
50
+ (_g = (_z = project.i18n).locales) !== null && _g !== void 0 ? _g : (_z.locales = {});
60
51
  for (const language of options.languages) {
61
- (_h = (_w = project.i18n.locales)[language]) !== null && _h !== void 0 ? _h : (_w[language] = {
52
+ (_h = (_0 = project.i18n.locales)[language]) !== null && _h !== void 0 ? _h : (_0[language] = {
62
53
  translation: `${project.sourceRoot}/i18n/${language}.xlf`,
63
54
  baseHref: `${language}/`,
64
55
  });
65
56
  }
66
57
  }
67
- (_j = (_x = project.targets['extract-i18n']).options) !== null && _j !== void 0 ? _j : (_x.options = {});
58
+ (_j = (_1 = project.targets['extract-i18n']).options) !== null && _j !== void 0 ? _j : (_1.options = {});
68
59
  project.targets['extract-i18n'].options.format = 'xliff2';
69
60
  project.targets['extract-i18n'].options.outputPath = (0, path_1.join)(project.sourceRoot, 'i18n');
70
61
  if (options.localazy) {
71
- (_k = (_y = project.targets)['localazy-download']) !== null && _k !== void 0 ? _k : (_y['localazy-download'] = {
62
+ (_k = (_2 = project.targets)['localazy-download']) !== null && _k !== void 0 ? _k : (_2['localazy-download'] = {
72
63
  executor: '@rxap/plugin-localazy:download',
73
- options: {
64
+ options: (0, utilities_1.DeleteEmptyProperties)({
65
+ readKey: options.localazyReadKey,
74
66
  workingDirectory: project.root,
75
- },
76
- configurations: {
77
- production: {},
78
- development: {},
79
- },
67
+ }),
80
68
  });
81
- (_l = (_z = project.targets)['localazy-upload']) !== null && _l !== void 0 ? _l : (_z['localazy-upload'] = {
69
+ (_l = (_3 = project.targets)['localazy-upload']) !== null && _l !== void 0 ? _l : (_3['localazy-upload'] = {
82
70
  executor: '@rxap/plugin-localazy:upload',
83
71
  options: {
84
72
  extractTarget: `${project.name}:extract-i18n`,
@@ -86,40 +74,82 @@ function updateProjectTargets(project, options) {
86
74
  });
87
75
  }
88
76
  }
89
- (_m = (_0 = project.targets['build']).options) !== null && _m !== void 0 ? _m : (_0.options = {});
77
+ (0, workspace_utilities_1.CoerceTarget)(project, 'build', {
78
+ options: {
79
+ sourceMap: true,
80
+ },
81
+ configurations: {
82
+ production: {
83
+ fileReplacements: [
84
+ {
85
+ replace: `${project.sourceRoot}/environments/environment.ts`,
86
+ with: `${project.sourceRoot}/environments/environment.prod.ts`,
87
+ },
88
+ ],
89
+ },
90
+ },
91
+ }, workspace_utilities_1.Strategy.OVERWRITE);
92
+ (_m = (_4 = project.targets['build']).options) !== null && _m !== void 0 ? _m : (_4.options = {});
90
93
  project.targets['build'].options.sourceMap = true;
91
- (_o = (_1 = project.targets['build'].options).assets) !== null && _o !== void 0 ? _o : (_1.assets = []);
94
+ (_o = (_5 = project.targets['build'].options).assets) !== null && _o !== void 0 ? _o : (_5.assets = []);
95
+ (_p = (_6 = project.targets['build'].options).scripts) !== null && _p !== void 0 ? _p : (_6.scripts = []);
96
+ if (!project.targets['build'].options.scripts.includes('node_modules/marked/marked.min.js')) {
97
+ project.targets['build'].options.scripts.push('node_modules/marked/marked.min.js');
98
+ }
92
99
  (0, generator_utilities_1.CoerceAssets)(project.targets['build'].options.assets, [
93
100
  {
94
- glob: '*.json',
95
- input: 'config/',
96
- output: '/',
101
+ glob: '*',
102
+ input: 'shared/angular/assets/',
103
+ output: '.',
97
104
  },
98
105
  {
99
- glob: '*',
100
- input: 'shared/assets/',
101
- output: '/',
106
+ glob: 'mdi.svg',
107
+ input: './node_modules/@mdi/angular-material',
108
+ output: '.',
102
109
  },
103
110
  ]);
111
+ // ensure the property polyfills are defined
112
+ (_q = (_7 = project.targets['build'].options).polyfills) !== null && _q !== void 0 ? _q : (_7.polyfills = []);
113
+ if (!Array.isArray(project.targets['build'].options.polyfills)) {
114
+ // ensure the property is an array
115
+ project.targets['build'].options.polyfills = ['zone.js'];
116
+ }
117
+ if (options.i18n) {
118
+ (0, generator_utilities_1.CoerceAssets)(project.targets['build'].options.polyfills, ['@angular/localize/init']);
119
+ }
104
120
  if (options.serviceWorker) {
105
121
  (0, generator_utilities_1.CoerceAssets)(project.targets['build'].options.assets, [
106
122
  (0, path_1.join)(project.sourceRoot, 'manifest.webmanifest'),
107
123
  ]);
108
- (_p = (_2 = project.targets['build']).configurations) !== null && _p !== void 0 ? _p : (_2.configurations = {});
109
- (_q = (_3 = project.targets['build'].configurations).production) !== null && _q !== void 0 ? _q : (_3.production = {});
124
+ (_r = (_8 = project.targets['build']).configurations) !== null && _r !== void 0 ? _r : (_8.configurations = {});
125
+ (_s = (_9 = project.targets['build'].configurations).production) !== null && _s !== void 0 ? _s : (_9.production = {});
110
126
  project.targets['build'].configurations.production.serviceWorker = true;
111
- (_r = (_4 = project.targets['build'].configurations.production).ngswConfigPath) !== null && _r !== void 0 ? _r : (_4.ngswConfigPath = 'shared/ngsw-config.json');
127
+ (_t = (_10 = project.targets['build'].configurations.production).ngswConfigPath) !== null && _t !== void 0 ? _t : (_10.ngswConfigPath = 'shared/angular/ngsw-config.json');
128
+ }
129
+ (_u = (_11 = project.targets['build'].configurations).production) !== null && _u !== void 0 ? _u : (_11.production = {});
130
+ (_v = (_12 = project.targets['build'].configurations.production).budgets) !== null && _v !== void 0 ? _v : (_12.budgets = []);
131
+ const budget = project.targets['build'].configurations.production.budgets.find(b => b.type === 'initial');
132
+ if (!budget) {
133
+ project.targets['build'].configurations.production.budgets.push({
134
+ type: 'initial',
135
+ maximumWarning: '2mb',
136
+ maximumError: '5mb',
137
+ });
138
+ }
139
+ else {
140
+ budget.maximumWarning = '2mb';
141
+ budget.maximumError = '5mb';
112
142
  }
113
143
  }
114
144
  function updateTargetDefaults(tree, options) {
115
145
  const nxJson = (0, devkit_1.readNxJson)(tree);
116
- if (options.i18n) {
117
- (0, workspace_utilities_1.CoerceTargetDefaultsDependency)(nxJson, 'i18n', 'build');
118
- }
119
146
  if (options.localazy) {
120
147
  (0, workspace_utilities_1.CoerceTargetDefaultsDependency)(nxJson, 'build', 'localazy-download');
121
148
  (0, workspace_utilities_1.CoerceTargetDefaultsDependency)(nxJson, 'localazy-upload', 'extract-i18n');
122
149
  }
150
+ (0, workspace_utilities_1.CoerceTargetDefaultsDependency)(nxJson, 'build', '^generate-open-api');
151
+ (0, workspace_utilities_1.CoerceTargetDefaultsDependency)(nxJson, 'serve', '^generate-open-api');
152
+ (0, workspace_utilities_1.CoerceNxJsonCacheableOperation)(nxJson, 'localazy-download', 'localazy-upload', 'extract-i18n');
123
153
  (0, devkit_1.updateNxJson)(tree, nxJson);
124
154
  }
125
155
  function updateGitIgnore(project, tree, options) {
@@ -131,16 +161,32 @@ function updateGitIgnore(project, tree, options) {
131
161
  }
132
162
  }
133
163
  function updateTags(project, options) {
134
- const tags = ['frontend'];
164
+ const tags = ['frontend', 'user-interface'];
135
165
  if (options.i18n) {
136
166
  tags.push('i18n');
137
167
  }
138
168
  if (options.localazy) {
139
169
  tags.push('localazy');
140
170
  }
171
+ if (options.serviceWorker) {
172
+ tags.push('service-worker');
173
+ }
174
+ if (options.sentry) {
175
+ tags.push('sentry');
176
+ }
141
177
  (0, generator_utilities_1.CoerceProjectTags)(project, tags);
142
178
  }
143
179
  const MAIN_BOOTSTRAP_STATEMENT = `application.bootstrap().catch((err) => console.error(err));`;
180
+ const MAIN_LOGGER_STATEMENT = `application.importProvidersFrom(LoggerModule.forRoot({
181
+ serverLoggingUrl: '/api/logs',
182
+ level: NgxLoggerLevel.DEBUG,
183
+ serverLogLevel: NgxLoggerLevel.ERROR,
184
+ }));`;
185
+ const MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplication(
186
+ environment,
187
+ AppComponent,
188
+ appConfig,
189
+ );`;
144
190
  function assertMainStatements(sourceFile) {
145
191
  var _a;
146
192
  const statements = [];
@@ -152,20 +198,12 @@ function assertMainStatements(sourceFile) {
152
198
  console.error(`Missing statement from main.ts: ${statement}`);
153
199
  sourceFile.set({
154
200
  statements: [
155
- `const application = new StandaloneApplication(
156
- environment,
157
- AppComponent,
158
- appConfig,
159
- );`,
160
- `application.importProvidersFrom(LoggerModule.forRoot({
161
- serverLoggingUrl: '/api/logs',
162
- level: NgxLoggerLevel.DEBUG,
163
- serverLogLevel: NgxLoggerLevel.ERROR
164
- }));`,
201
+ MAIN_APP_CREATION_STATEMENT,
202
+ MAIN_LOGGER_STATEMENT,
165
203
  MAIN_BOOTSTRAP_STATEMENT,
166
204
  ],
167
205
  });
168
- (0, schematics_ts_morph_1.CoerceImports)(sourceFile, [
206
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
169
207
  {
170
208
  moduleSpecifier: './app/app.component',
171
209
  namedImports: ['AppComponent'],
@@ -175,12 +213,12 @@ function assertMainStatements(sourceFile) {
175
213
  namedImports: ['appConfig'],
176
214
  },
177
215
  {
178
- moduleSpecifier: './environment',
216
+ moduleSpecifier: './environments/environment',
179
217
  namedImports: ['environment'],
180
218
  },
181
219
  {
182
220
  moduleSpecifier: 'ngx-logger',
183
- namedImports: ['NgxLoggerLevel', 'LoggerModule'],
221
+ namedImports: ['LoggerModule', 'NgxLoggerLevel'],
184
222
  },
185
223
  {
186
224
  moduleSpecifier: '@rxap/ngx-bootstrap',
@@ -191,6 +229,26 @@ function assertMainStatements(sourceFile) {
191
229
  }
192
230
  }
193
231
  }
232
+ function cleanup(tree, projectSourceRoot) {
233
+ const deleteFiles = [
234
+ 'app/app.component.spec.ts',
235
+ 'app/nx-welcome.component.ts',
236
+ 'app/nx-welcome.component.cy.ts',
237
+ ];
238
+ for (const file of deleteFiles) {
239
+ if (tree.exists((0, path_1.join)(projectSourceRoot, file))) {
240
+ tree.delete((0, path_1.join)(projectSourceRoot, file));
241
+ }
242
+ }
243
+ let content = tree.read((0, path_1.join)(projectSourceRoot, 'app/app.component.ts'), 'utf-8')
244
+ .replace('title = \'domain-product\';', '')
245
+ .replace('import { NxWelcomeComponent } from \'./nx-welcome.component\';', '')
246
+ .replace('NxWelcomeComponent, ', '');
247
+ tree.write((0, path_1.join)(projectSourceRoot, 'app/app.component.ts'), content);
248
+ content = tree.read((0, path_1.join)(projectSourceRoot, 'app/app.component.html'), 'utf-8')
249
+ .replace(/<.+-nx-welcome><\/.+-nx-welcome> /, '');
250
+ tree.write((0, path_1.join)(projectSourceRoot, 'app/app.component.html'), content);
251
+ }
194
252
  function updateMainFile(tree, project, options) {
195
253
  (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
196
254
  project: project.name,
@@ -206,13 +264,18 @@ function updateMainFile(tree, project, options) {
206
264
  }
207
265
  if (options.openApi) {
208
266
  importDeclarations.push({ moduleSpecifier: '@rxap/open-api', namedImports: ['OpenApiInit'] });
209
- statements.push('application.before(() => OpenApiInit());');
267
+ if (options.openApiLegacy) {
268
+ statements.push('application.before(() => OpenApiInit({ load: true }));');
269
+ }
270
+ else {
271
+ statements.push('application.before(() => OpenApiInit());');
272
+ }
210
273
  }
211
274
  if (options.sentry) {
212
275
  importDeclarations.push({ moduleSpecifier: '@rxap/ngx-sentry', namedImports: ['SentryInit'] });
213
276
  statements.push('application.before(() => SentryInit(environment));');
214
277
  }
215
- (0, schematics_ts_morph_1.CoerceImports)(sourceFile, importDeclarations);
278
+ (0, ts_morph_1.CoerceImports)(sourceFile, importDeclarations);
216
279
  for (let i = 0; i < statements.length; i++) {
217
280
  const statement = statements[i];
218
281
  const lastStatement = i > 0 ? statements[i - 1] : null;
@@ -235,27 +298,328 @@ function updateMainFile(tree, project, options) {
235
298
  }
236
299
  }, ['main.ts']);
237
300
  }
301
+ function coerceEnvironmentFiles(tree, options) {
302
+ (0, workspace_ts_morph_1.TsMorphNestProjectTransform)(tree, {
303
+ project: options.project,
304
+ }, (project, [sourceFile, prodSourceFile]) => {
305
+ (0, ts_morph_1.CoerceImports)(sourceFile, {
306
+ moduleSpecifier: '@rxap/environment',
307
+ namedImports: ['Environment'],
308
+ });
309
+ (0, ts_morph_1.CoerceImports)(prodSourceFile, {
310
+ moduleSpecifier: '@rxap/environment',
311
+ namedImports: ['Environment'],
312
+ });
313
+ const baseEnvironment = {
314
+ name: w => w.quote('development'),
315
+ production: 'false',
316
+ app: w => w.quote(options.project),
317
+ serviceWorker: 'false',
318
+ };
319
+ if (options.sentry) {
320
+ baseEnvironment['sentry'] = ts_morph_2.Writers.object({
321
+ enabled: 'false',
322
+ debug: 'false',
323
+ });
324
+ }
325
+ const normal = (0, ts_morph_1.CoerceVariableDeclaration)(sourceFile, 'environment', {
326
+ type: 'Environment',
327
+ initializer: ts_morph_2.Writers.object(baseEnvironment),
328
+ });
329
+ if (options.overwrite) {
330
+ normal.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
331
+ }
332
+ baseEnvironment['name'] = w => w.quote('production');
333
+ baseEnvironment['production'] = 'true';
334
+ baseEnvironment['serviceWorker'] = 'true';
335
+ if (options.sentry) {
336
+ baseEnvironment['sentry'] = ts_morph_2.Writers.object({
337
+ enabled: 'true',
338
+ debug: 'false',
339
+ });
340
+ }
341
+ const prod = (0, ts_morph_1.CoerceVariableDeclaration)(prodSourceFile, 'environment', {
342
+ type: 'Environment',
343
+ initializer: ts_morph_2.Writers.object(baseEnvironment),
344
+ });
345
+ if (options.overwrite) {
346
+ prod.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
347
+ }
348
+ }, [
349
+ '/environments/environment.ts?',
350
+ '/environments/environment.prod.ts?',
351
+ ]);
352
+ }
353
+ function coerceLocalazyConfigFile(tree, project) {
354
+ const projectRoot = project.root;
355
+ const localazyConfigPath = (0, path_1.join)(projectRoot, 'localazy.json');
356
+ if (!tree.exists(localazyConfigPath)) {
357
+ tree.write(localazyConfigPath, JSON.stringify({
358
+ upload: {
359
+ type: 'xliff',
360
+ deprecate: 'file',
361
+ features: [
362
+ 'use_defined_lang_for_source',
363
+ 'dont_parse_target',
364
+ ],
365
+ files: 'src/i18n/messages.xlf',
366
+ },
367
+ download: {
368
+ files: 'src/i18n/${languageCode}.xlf',
369
+ },
370
+ }, null, 2));
371
+ }
372
+ }
238
373
  function initApplicationGenerator(tree, options) {
374
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
239
375
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
376
+ (_a = options.sentry) !== null && _a !== void 0 ? _a : (options.sentry = true);
377
+ (_b = options.openApi) !== null && _b !== void 0 ? _b : (options.openApi = false);
378
+ (_c = options.config) !== null && _c !== void 0 ? _c : (options.config = true);
379
+ (_d = options.localazy) !== null && _d !== void 0 ? _d : (options.localazy = false);
380
+ (_e = options.i18n) !== null && _e !== void 0 ? _e : (options.i18n = false);
381
+ (_f = options.serviceWorker) !== null && _f !== void 0 ? _f : (options.serviceWorker = false);
382
+ (_g = options.languages) !== null && _g !== void 0 ? _g : (options.languages = options.i18n ? ['en'] : []);
383
+ (_h = options.material) !== null && _h !== void 0 ? _h : (options.material = true);
384
+ (_j = options.generateMain) !== null && _j !== void 0 ? _j : (options.generateMain = false);
385
+ (_k = options.overwrite) !== null && _k !== void 0 ? _k : (options.overwrite = false);
386
+ (_l = options.monolithic) !== null && _l !== void 0 ? _l : (options.monolithic = false);
387
+ options.openApi = options.openApi || options.monolithic;
388
+ (_m = options.authentik) !== null && _m !== void 0 ? _m : (options.authentik = false);
389
+ (_o = options.oauth) !== null && _o !== void 0 ? _o : (options.oauth = false);
390
+ options.oauth = options.oauth || options.authentik;
240
391
  console.log('angular application init generator:', options);
241
- // only add the shared folder if it does not exist
242
- if (!tree.exists('shared')) {
243
- (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'shared'), 'shared', options);
392
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@mdi/angular-material', 'latest', { soft: true });
393
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-bootstrap', 'latest', { soft: true });
394
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'ngx-logger', 'latest', { soft: true });
395
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/environment', 'latest', { soft: true });
396
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-status-check', 'latest', { soft: true });
397
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-error', 'latest', { soft: true });
398
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-localize', 'latest', { soft: true });
399
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-changelog', 'latest', { soft: true });
400
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'ngx-markdown', 'latest', { soft: true });
401
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'marked', '4.3.0', { soft: true });
402
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/config', 'latest', { soft: true });
403
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/directives', 'latest', { soft: true });
404
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/components', 'latest', { soft: true });
405
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/rxjs', 'latest', { soft: true });
406
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/data-grid', 'latest', { soft: true });
407
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/forms', 'latest', { soft: true });
408
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/validator', 'latest', { soft: true });
409
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/pipes', 'latest', { soft: true });
410
+ if (options.oauth) {
411
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'angular-oauth2-oidc', 'latest', { soft: true });
412
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'angular-oauth2-oidc-jwks', 'latest', { soft: true });
413
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/oauth', 'latest', { soft: true });
244
414
  }
245
- for (const [projectName, project] of (0, devkit_1.getProjects)(tree).entries()) {
246
- if (skipProject(tree, options, project, projectName)) {
247
- continue;
248
- }
249
- console.log(`init project: ${projectName}`);
250
- updateProjectTargets(project, options);
251
- updateTags(project, options);
252
- updateTargetDefaults(tree, options);
253
- updateGitIgnore(project, tree, options);
254
- if (options.generateMain) {
255
- updateMainFile(tree, project, options);
415
+ if (options.material) {
416
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/material', 'latest', { soft: true });
417
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/cdk', 'latest', { soft: true });
418
+ }
419
+ if (options.serviceWorker) {
420
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/service-worker', 'latest', { soft: true });
421
+ }
422
+ if (options.monolithic) {
423
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/layout', 'latest', { soft: true });
424
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/services', 'latest', { soft: true });
425
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/data-source', 'latest', { soft: true });
426
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/pattern', 'latest', { soft: true });
427
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/definition', 'latest', { soft: true });
428
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/authentication', 'latest', { soft: true });
429
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/icon', 'latest', { soft: true });
430
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/material-directives', 'latest', { soft: true });
431
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/browser-utilities', 'latest', { soft: true });
432
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/flex-layout', 'latest', { soft: true });
433
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/authorization', 'latest', { soft: true });
434
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-user', 'latest', { soft: true });
435
+ }
436
+ if (options.openApi) {
437
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/open-api', 'latest', { soft: true });
438
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/remote-method', 'latest', { soft: true });
439
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/definition', 'latest', { soft: true });
440
+ }
441
+ if (options.sentry) {
442
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-sentry', 'latest', { soft: true });
443
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/angular-ivy', 'latest', { soft: true });
444
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/browser', 'latest', { soft: true });
445
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/integrations', 'latest', { soft: true });
446
+ }
447
+ if (options.i18n) {
448
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize', 'latest', { soft: true });
449
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/localize', 'latest', { soft: true });
450
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-user', 'latest', { soft: true });
451
+ }
452
+ if (options.localazy) {
453
+ yield (0, workspace_utilities_1.AddPackageJsonDevDependency)(tree, '@localazy/cli', 'latest', { soft: true });
454
+ yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/plugin-localazy', 'latest', { soft: true });
455
+ }
456
+ (0, workspace_utilities_1.CoerceFilesStructure)(tree, {
457
+ srcFolder: (0, path_1.join)(__dirname, 'files', 'shared'),
458
+ target: 'shared/angular',
459
+ overwrite: options.overwrite,
460
+ });
461
+ (0, workspace_utilities_1.CoerceFilesStructure)(tree, {
462
+ srcFolder: (0, path_1.join)(__dirname, 'files', 'styles'),
463
+ target: 'shared/angular/styles',
464
+ overwrite: options.overwrite,
465
+ });
466
+ if (options.oauth) {
467
+ (0, workspace_utilities_1.CoerceFilesStructure)(tree, {
468
+ srcFolder: (0, path_1.join)(__dirname, 'files', 'oauth'),
469
+ target: 'shared/angular/assets',
470
+ overwrite: options.overwrite,
471
+ });
472
+ }
473
+ updateTargetDefaults(tree, options);
474
+ if (!options.skipProjects) {
475
+ for (const [projectName, project] of (0, devkit_1.getProjects)(tree).entries()) {
476
+ if (skipProject(tree, options, project, projectName)) {
477
+ continue;
478
+ }
479
+ console.log(`init project: ${projectName}`);
480
+ updateProjectTargets(project, options);
481
+ updateTags(project, options);
482
+ updateGitIgnore(project, tree, options);
483
+ coerceEnvironmentFiles(tree, {
484
+ project: projectName,
485
+ sentry: options.sentry,
486
+ overwrite: options.overwrite,
487
+ });
488
+ (0, workspace_ts_morph_1.TsMorphNestProjectTransform)(tree, {
489
+ project: projectName,
490
+ }, (_, [sourceFile]) => {
491
+ const providers = [
492
+ 'provideRouter(appRoutes, withEnabledBlockingInitialNavigation())',
493
+ 'provideAnimations()',
494
+ 'ProvideErrorHandler()',
495
+ 'ProvideEnvironment(environment)',
496
+ ];
497
+ const httpInterceptors = [
498
+ 'HttpErrorInterceptor',
499
+ ];
500
+ const importProvidersFrom = [];
501
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
502
+ {
503
+ moduleSpecifier: '@angular/platform-browser/animations',
504
+ namedImports: ['provideAnimations'],
505
+ },
506
+ {
507
+ moduleSpecifier: '@angular/router',
508
+ namedImports: ['provideRouter', 'withEnabledBlockingInitialNavigation'],
509
+ },
510
+ {
511
+ moduleSpecifier: './app.routes',
512
+ namedImports: ['appRoutes'],
513
+ },
514
+ {
515
+ moduleSpecifier: '@rxap/ngx-error',
516
+ namedImports: ['ProvideErrorHandler', 'HttpErrorInterceptor'],
517
+ },
518
+ {
519
+ moduleSpecifier: '@rxap/environment',
520
+ namedImports: ['ProvideEnvironment'],
521
+ },
522
+ {
523
+ moduleSpecifier: '../environments/environment',
524
+ namedImports: ['environment'],
525
+ },
526
+ ]);
527
+ if (options.monolithic) {
528
+ providers.push('ProvideChangelog()');
529
+ importProvidersFrom.push('MarkdownModule.forRoot()');
530
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
531
+ {
532
+ moduleSpecifier: '@rxap/ngx-changelog',
533
+ namedImports: ['ProvideChangelog'],
534
+ },
535
+ {
536
+ moduleSpecifier: 'ngx-markdown',
537
+ namedImports: ['MarkdownModule'],
538
+ },
539
+ ]);
540
+ }
541
+ if (options.oauth) {
542
+ providers.push('provideOAuthClient()');
543
+ providers.push('ProvideAuth()');
544
+ httpInterceptors.push('BearerTokenInterceptor');
545
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
546
+ {
547
+ moduleSpecifier: 'angular-oauth2-oidc',
548
+ namedImports: ['provideOAuthClient'],
549
+ },
550
+ {
551
+ moduleSpecifier: '@rxap/oauth',
552
+ namedImports: ['ProvideAuth'],
553
+ },
554
+ {
555
+ moduleSpecifier: '@rxap/authentication',
556
+ namedImports: ['BearerTokenInterceptor'],
557
+ },
558
+ ]);
559
+ }
560
+ if (options.i18n) {
561
+ httpInterceptors.push('LanguageInterceptor');
562
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
563
+ {
564
+ moduleSpecifier: '@rxap/ngx-localize',
565
+ namedImports: ['LanguageInterceptor'],
566
+ },
567
+ ]);
568
+ }
569
+ if (options.serviceWorker) {
570
+ providers.push(`provideServiceWorker('ngsw-worker.js', { enabled: environment.serviceWorker, registrationStrategy: 'registerWhenStable:30000' })`);
571
+ providers.push('ProvideServiceWorkerUpdateDialog()');
572
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
573
+ {
574
+ moduleSpecifier: '@angular/service-worker',
575
+ namedImports: ['provideServiceWorker'],
576
+ },
577
+ {
578
+ moduleSpecifier: '@rxap/service-worker',
579
+ namedImports: ['ProvideServiceWorkerUpdateDialog'],
580
+ },
581
+ ]);
582
+ }
583
+ (0, ts_morph_1.CoerceAppConfigProvider)(sourceFile, {
584
+ overwrite: options.overwrite,
585
+ providers,
586
+ httpInterceptors,
587
+ importProvidersFrom,
588
+ });
589
+ }, ['/app/app.config.ts']);
590
+ if (options.generateMain) {
591
+ updateMainFile(tree, project, options);
592
+ }
593
+ if (options.cleanup) {
594
+ cleanup(tree, project.sourceRoot);
595
+ }
596
+ if (options.localazy) {
597
+ coerceLocalazyConfigFile(tree, project);
598
+ }
599
+ if (options.monolithic) {
600
+ if (!tree.exists((0, path_1.join)(project.sourceRoot, 'assets', 'logo.png'))) {
601
+ if (tree.exists('logo.png')) {
602
+ tree.write((0, path_1.join)(project.sourceRoot, 'assets', 'logo.png'), tree.read('logo.png'));
603
+ }
604
+ }
605
+ if (options.overwrite) {
606
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'monolithic'), project.sourceRoot, Object.assign(Object.assign({}, options), { relativePathToWorkspaceRoot: (0, path_1.relative)(project.sourceRoot, ''), name: projectName.replace(/^user-interface-/, ''), classify: utilities_1.classify, prefix: (0, workspace_utilities_1.GetProjectPrefix)(tree, projectName, 'rxap') }));
607
+ }
608
+ }
609
+ if (options.serviceWorker) {
610
+ if (options.overwrite || !tree.exists((0, path_1.join)(project.sourceRoot, 'manifest.webmanifest'))) {
611
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'service-worker'), project.sourceRoot, Object.assign(Object.assign({}, options), { name: projectName.replace(/^user-interface-/, ''), classify: utilities_1.classify,
612
+ dasherize: utilities_1.dasherize }));
613
+ }
614
+ }
615
+ (0, workspace_utilities_1.CoerceFilesStructure)(tree, {
616
+ srcFolder: (0, path_1.join)(__dirname, 'files', 'assets'),
617
+ target: (0, path_1.join)(project.sourceRoot, 'assets'),
618
+ overwrite: options.overwrite,
619
+ });
620
+ // apply changes to the project configuration
621
+ (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
256
622
  }
257
- // apply changes to the project configuration
258
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
259
623
  }
260
624
  yield (0, plugin_localazy_1.LocalazyGitlabCiGenerator)(tree, options);
261
625
  });