@rxap/plugin-angular 16.1.0-dev.4 → 16.1.0-dev.41

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