@rxap/plugin-angular 16.2.0-dev.8 → 16.2.0

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 (55) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +15 -1
  3. package/generators.json +10 -0
  4. package/package.json +27 -22
  5. package/src/generators/convert-to-buildable-library/generator.d.ts +4 -0
  6. package/src/generators/convert-to-buildable-library/generator.js +89 -0
  7. package/src/generators/convert-to-buildable-library/generator.js.map +1 -0
  8. package/src/generators/convert-to-buildable-library/schema.d.ts +3 -0
  9. package/src/generators/convert-to-buildable-library/schema.json +12 -0
  10. package/src/generators/init/generator.js +4 -0
  11. package/src/generators/init/generator.js.map +1 -1
  12. package/src/generators/init/schema.d.ts +1 -0
  13. package/src/generators/init/schema.json +4 -0
  14. package/src/generators/init-application/coerce-project.d.ts +4 -0
  15. package/src/generators/init-application/coerce-project.js +53 -0
  16. package/src/generators/init-application/coerce-project.js.map +1 -0
  17. package/src/generators/init-application/files/mfe-remote/Dockerfile +29 -0
  18. package/src/generators/init-application/files/mfe-remote/index.html.template +165 -0
  19. package/src/generators/init-application/files/root/favicon.ico +0 -0
  20. package/src/generators/init-application/files/root/styles.scss.template +3 -0
  21. package/src/generators/init-application/files/shared/ngsw-config.json +11 -1
  22. package/src/generators/init-application/files/styles/_fonts.scss +2 -0
  23. package/src/generators/init-application/generate-monolithic.js +2 -7
  24. package/src/generators/init-application/generate-monolithic.js.map +1 -1
  25. package/src/generators/init-application/generator.js +326 -73
  26. package/src/generators/init-application/generator.js.map +1 -1
  27. package/src/generators/init-application/schema.d.ts +12 -0
  28. package/src/generators/init-application/schema.json +54 -26
  29. package/src/generators/init-component/generator.d.ts +4 -0
  30. package/src/generators/init-component/generator.js +71 -0
  31. package/src/generators/init-component/generator.js.map +1 -0
  32. package/src/generators/init-component/index.d.ts +2 -0
  33. package/src/generators/init-component/index.js +7 -0
  34. package/src/generators/init-component/index.js.map +1 -0
  35. package/src/generators/init-component/schema.d.ts +25 -0
  36. package/src/generators/init-component/schema.json +141 -0
  37. package/src/generators/init-feature/generator.js +5 -1
  38. package/src/generators/init-feature/generator.js.map +1 -1
  39. package/src/generators/init-feature/schema.d.ts +2 -1
  40. package/src/generators/init-feature/schema.json +4 -0
  41. package/src/generators/init-feature-library/generator.d.ts +4 -0
  42. package/src/generators/init-feature-library/generator.js +12 -0
  43. package/src/generators/init-feature-library/generator.js.map +1 -0
  44. package/src/generators/init-feature-library/schema.d.ts +10 -0
  45. package/src/generators/init-feature-library/schema.json +222 -0
  46. package/src/generators/init-library/generator.js +67 -54
  47. package/src/generators/init-library/generator.js.map +1 -1
  48. package/src/generators/init-library/schema.d.ts +1 -1
  49. package/src/generators/init-library/schema.json +182 -150
  50. package/src/lib/coerce-test-setup.d.ts +2 -0
  51. package/src/lib/coerce-test-setup.js +40 -0
  52. package/src/lib/coerce-test-setup.js.map +1 -0
  53. package/src/generators/init-application/files/shared/assets/custom.svg +0 -1
  54. /package/src/generators/init-application/files/{monolithic → mfe-remote}/styles.scss.template +0 -0
  55. /package/src/generators/init-application/files/{monolithic → root}/index.html.template +0 -0
@@ -4,7 +4,7 @@ exports.initApplicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const plugin_application_1 = require("@rxap/plugin-application");
7
- const plugin_docker_1 = require("@rxap/plugin-docker");
7
+ const plugin_gitlab_ci_1 = require("@rxap/plugin-gitlab-ci");
8
8
  const plugin_localazy_1 = require("@rxap/plugin-localazy");
9
9
  const ts_morph_1 = require("@rxap/ts-morph");
10
10
  const utilities_1 = require("@rxap/utilities");
@@ -12,6 +12,8 @@ const workspace_ts_morph_1 = require("@rxap/workspace-ts-morph");
12
12
  const workspace_utilities_1 = require("@rxap/workspace-utilities");
13
13
  const path_1 = require("path");
14
14
  const ts_morph_2 = require("ts-morph");
15
+ const coerce_test_setup_1 = require("../../lib/coerce-test-setup");
16
+ const coerce_project_1 = require("./coerce-project");
15
17
  const generate_authentication_1 = require("./generate-authentication");
16
18
  const generate_monolithic_1 = require("./generate-monolithic");
17
19
  function skipProject(tree, options, project, projectName) {
@@ -23,16 +25,20 @@ function skipProject(tree, options, project, projectName) {
23
25
  }
24
26
  return false;
25
27
  }
26
- function updateProjectTargets(project, options) {
28
+ function updateProjectTargets(projectName, project, options) {
27
29
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
28
30
  var _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
29
31
  (_a = project.targets) !== null && _a !== void 0 ? _a : (project.targets = {});
30
32
  if (!project.targets['build']) {
31
33
  throw new Error(`The project '${project.name}' has no build target`);
32
34
  }
33
- if (project.targets['docker']) {
34
- (_b = (_z = project.targets['docker']).options) !== null && _b !== void 0 ? _b : (_z.options = {});
35
- (_c = (_0 = project.targets['docker'].options).dockerfile) !== null && _c !== void 0 ? _c : (_0.dockerfile = 'shared/angular/Dockerfile');
35
+ if (!options.skipDocker) {
36
+ if (project.targets['docker']) {
37
+ (_b = (_z = project.targets['docker']).options) !== null && _b !== void 0 ? _b : (_z.options = {});
38
+ (_c = (_0 = project.targets['docker'].options).dockerfile) !== null && _c !== void 0 ? _c : (_0.dockerfile = options.moduleFederation === 'remote' ?
39
+ (0, path_1.join)(project.sourceRoot, 'Dockerfile') :
40
+ 'shared/angular/Dockerfile');
41
+ }
36
42
  }
37
43
  (0, workspace_utilities_1.CoerceTarget)(project, 'serve', {
38
44
  options: {
@@ -106,8 +112,10 @@ function updateProjectTargets(project, options) {
106
112
  project.targets['build'].options.sourceMap = true;
107
113
  (_q = (_10 = project.targets['build'].options).assets) !== null && _q !== void 0 ? _q : (_10.assets = []);
108
114
  (_r = (_11 = project.targets['build'].options).scripts) !== null && _r !== void 0 ? _r : (_11.scripts = []);
109
- if (!project.targets['build'].options.scripts.includes('node_modules/marked/marked.min.js')) {
110
- project.targets['build'].options.scripts.push('node_modules/marked/marked.min.js');
115
+ if (options.moduleFederation !== 'remote') {
116
+ if (!project.targets['build'].options.scripts.includes('node_modules/marked/marked.min.js')) {
117
+ project.targets['build'].options.scripts.push('node_modules/marked/marked.min.js');
118
+ }
111
119
  }
112
120
  (0, workspace_utilities_1.CoerceAssets)(project.targets['build'].options.assets, [
113
121
  {
@@ -168,6 +176,24 @@ function updateProjectTargets(project, options) {
168
176
  }
169
177
  }
170
178
  }
179
+ if (options.incrementalBuild) {
180
+ project.targets['build'].executor = '@nx/angular:webpack-browser';
181
+ project.targets['build'].options.buildLibsFromSource = false;
182
+ (0, workspace_utilities_1.CoerceTarget)(project, 'serve-static', {
183
+ executor: '@nx/web:file-server',
184
+ options: {
185
+ proxyUrl: 'https://127-0-0-1.nip.io:8443'
186
+ },
187
+ configurations: {
188
+ production: {
189
+ buildTarget: `${projectName}:build:production`
190
+ },
191
+ development: {
192
+ buildTarget: `${projectName}:build:development`
193
+ }
194
+ }
195
+ });
196
+ }
171
197
  if (options.deploy) {
172
198
  switch (options.deploy) {
173
199
  case 'web3-storage':
@@ -255,6 +281,10 @@ function updateTags(project, options) {
255
281
  if (options.sentry) {
256
282
  tags.push('sentry');
257
283
  }
284
+ if (options.moduleFederation) {
285
+ tags.push('module-federation');
286
+ tags.push(`mfe:${options.moduleFederation}`);
287
+ }
258
288
  (0, workspace_utilities_1.CoerceProjectTags)(project, tags);
259
289
  }
260
290
  const MAIN_BOOTSTRAP_STATEMENT = `application.bootstrap().catch((err) => console.error(err));`;
@@ -268,7 +298,12 @@ const MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplicati
268
298
  AppComponent,
269
299
  appConfig,
270
300
  );`;
271
- function assertMainStatements(sourceFile) {
301
+ const REMOTE_MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplication(
302
+ environment,
303
+ RemoteEntryComponent,
304
+ appConfig,
305
+ );`;
306
+ function assertMainStatements(sourceFile, options) {
272
307
  var _a;
273
308
  const statements = [];
274
309
  statements.push('const application = new StandaloneApplication(');
@@ -279,16 +314,12 @@ function assertMainStatements(sourceFile) {
279
314
  console.error(`Missing statement from angular main.ts: ${statement}`);
280
315
  sourceFile.set({
281
316
  statements: [
282
- MAIN_APP_CREATION_STATEMENT,
317
+ options.moduleFederation === 'remote' ? REMOTE_MAIN_APP_CREATION_STATEMENT : MAIN_APP_CREATION_STATEMENT,
283
318
  MAIN_LOGGER_STATEMENT,
284
319
  MAIN_BOOTSTRAP_STATEMENT,
285
320
  ],
286
321
  });
287
322
  (0, ts_morph_1.CoerceImports)(sourceFile, [
288
- {
289
- moduleSpecifier: './app/app.component',
290
- namedImports: ['AppComponent'],
291
- },
292
323
  {
293
324
  moduleSpecifier: './app/app.config',
294
325
  namedImports: ['appConfig'],
@@ -306,37 +337,132 @@ function assertMainStatements(sourceFile) {
306
337
  namedImports: ['StandaloneApplication'],
307
338
  },
308
339
  ]);
340
+ if (options.moduleFederation === 'remote') {
341
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
342
+ {
343
+ moduleSpecifier: './app/remote-entry/entry.component',
344
+ namedImports: ['RemoteEntryComponent'],
345
+ },
346
+ ]);
347
+ }
348
+ else {
349
+ (0, ts_morph_1.CoerceImports)(sourceFile, [
350
+ {
351
+ moduleSpecifier: './app/app.component',
352
+ namedImports: ['AppComponent'],
353
+ },
354
+ ]);
355
+ }
309
356
  return;
310
357
  }
311
358
  }
312
359
  }
313
- function cleanup(tree, projectSourceRoot) {
360
+ function cleanup(tree, projectName, options) {
361
+ const sourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName);
314
362
  const deleteFiles = [
315
363
  'app/app.component.spec.ts',
316
364
  'app/nx-welcome.component.ts',
365
+ 'app/remote-entry/nx-welcome.component.ts',
317
366
  'app/nx-welcome.component.cy.ts',
318
367
  ];
319
368
  for (const file of deleteFiles) {
320
- if (tree.exists((0, path_1.join)(projectSourceRoot, file))) {
321
- tree.delete((0, path_1.join)(projectSourceRoot, file));
322
- }
323
- }
324
- let content = tree.read((0, path_1.join)(projectSourceRoot, 'app/app.component.ts'), 'utf-8')
325
- .replace('title = \'domain-product\';', '')
326
- .replace('import { NxWelcomeComponent } from \'./nx-welcome.component\';', '')
327
- .replace('NxWelcomeComponent, ', '');
328
- tree.write((0, path_1.join)(projectSourceRoot, 'app/app.component.ts'), content);
329
- content = tree.read((0, path_1.join)(projectSourceRoot, 'app/app.component.html'), 'utf-8')
330
- .replace(/<.+-nx-welcome><\/.+-nx-welcome> /, '');
331
- tree.write((0, path_1.join)(projectSourceRoot, 'app/app.component.html'), content);
369
+ if (tree.exists((0, path_1.join)(sourceRoot, file))) {
370
+ tree.delete((0, path_1.join)(sourceRoot, file));
371
+ }
372
+ }
373
+ if (tree.exists((0, path_1.join)(sourceRoot, 'app/app.component.html'))) {
374
+ const content = tree.read((0, path_1.join)(sourceRoot, 'app/app.component.html'), 'utf-8')
375
+ .replace(/<.+-nx-welcome><\/.+-nx-welcome> /, '')
376
+ .replace(/<ul class="remote-menu">[\s\S]*<\/ul>/, '');
377
+ tree.write((0, path_1.join)(sourceRoot, 'app/app.component.html'), content);
378
+ }
379
+ if (options.moduleFederation !== 'remote') {
380
+ (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
381
+ project: projectName,
382
+ }, (_, [appRoutes, appComponent]) => {
383
+ var _a, _b, _c;
384
+ (0, ts_morph_1.RemoveRoute)(appRoutes, {
385
+ component: 'NxWelcomeComponent',
386
+ name: 'appRoutes'
387
+ });
388
+ (_a = appRoutes.getImportDeclaration('./nx-welcome.component')) === null || _a === void 0 ? void 0 : _a.remove();
389
+ (_c = (_b = appComponent.getClass('AppComponent')) === null || _b === void 0 ? void 0 : _b.getProperty('title')) === null || _c === void 0 ? void 0 : _c.remove();
390
+ (0, ts_morph_1.RemoveComponentImport)(appComponent, 'NxWelcomeComponent');
391
+ }, ['app/app.routes.ts', 'app/app.component.ts']);
392
+ }
393
+ if (options.moduleFederation === 'remote') {
394
+ // region module-federation config
395
+ const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
396
+ let content = tree.read((0, path_1.join)(projectRoot, 'module-federation.config.js'), 'utf-8');
397
+ content = content.replace('./Routes', './routes');
398
+ tree.write((0, path_1.join)(projectRoot, 'module-federation.config.js'), content);
399
+ // endregion
400
+ // region tsconfig.base.json
401
+ (0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
402
+ var _a, _b;
403
+ var _c;
404
+ (_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
405
+ (_b = (_c = tsConfig.compilerOptions).paths) !== null && _b !== void 0 ? _b : (_c.paths = {});
406
+ if (tsConfig.compilerOptions.paths[`${projectName}/Routes`]) {
407
+ delete tsConfig.compilerOptions.paths[`${projectName}/Routes`];
408
+ }
409
+ }, { infix: 'base' });
410
+ // endregion
411
+ (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
412
+ project: projectName,
413
+ }, (_, [entryRoutes]) => {
414
+ (0, ts_morph_1.CoerceDefaultExport)(entryRoutes.getVariableStatement('remoteRoutes').getDeclarations()[0]);
415
+ }, [
416
+ 'app/remote-entry/entry.routes.ts',
417
+ ]);
418
+ if (tree.exists((0, path_1.join)(sourceRoot, 'app/remote-entry/entry.component.ts'))) {
419
+ (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
420
+ project: projectName,
421
+ }, (_, [entryComponent]) => {
422
+ var _a, _b;
423
+ (_a = entryComponent.getImportDeclaration('./nx-welcome.component')) === null || _a === void 0 ? void 0 : _a.remove();
424
+ (0, ts_morph_1.RemoveComponentImport)(entryComponent, 'NxWelcomeComponent');
425
+ (0, ts_morph_1.RemoveComponentImport)(entryComponent, 'CommonModule');
426
+ const componentOptions = (0, ts_morph_1.GetComponentDecoratorObject)(entryComponent);
427
+ const templateProp = componentOptions.getProperty('template');
428
+ if (templateProp && ((_b = templateProp.asKindOrThrow(ts_morph_2.SyntaxKind.PropertyAssignment).getInitializer()) === null || _b === void 0 ? void 0 : _b.getText().match(/<.+nx-welcome><\/.+nx-welcome>/))) {
429
+ templateProp.remove();
430
+ componentOptions.addPropertyAssignment({
431
+ name: 'template',
432
+ initializer: w => w.quote('<router-outlet></router-outlet>'),
433
+ });
434
+ (0, ts_morph_1.CoerceComponentImport)(entryComponent, {
435
+ name: 'RouterModule',
436
+ moduleSpecifier: '@angular/router'
437
+ });
438
+ }
439
+ }, [
440
+ 'app/remote-entry/entry.component.ts',
441
+ ]);
442
+ }
443
+ if (options.host) {
444
+ (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
445
+ project: options.host,
446
+ }, (_, [appRoutes]) => {
447
+ (0, ts_morph_1.RemoveRoute)(appRoutes, {
448
+ loadRemoteModule: {
449
+ name: projectName,
450
+ entry: './Routes',
451
+ },
452
+ name: 'appRoutes'
453
+ });
454
+ appRoutes.organizeImports();
455
+ }, ['app/app.routes.ts']);
456
+ }
457
+ }
332
458
  }
333
459
  function updateMainFile(tree, projectName, project, options) {
334
460
  (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
335
461
  project: projectName,
336
462
  // directory: '..' // to move from the apps/demo/src/app folder into the apps/demo/src folder
337
- }, (project, [sourceFile]) => {
463
+ }, (project, [sourceFile, mainSourceFile]) => {
338
464
  var _a;
339
- assertMainStatements(sourceFile);
465
+ assertMainStatements(sourceFile, options);
340
466
  const importDeclarations = [];
341
467
  const statements = [];
342
468
  if (options.serviceWorker) {
@@ -386,7 +512,48 @@ function updateMainFile(tree, projectName, project, options) {
386
512
  sourceFile.insertStatements(index, statement);
387
513
  }
388
514
  }
389
- }, ['main.ts']);
515
+ if (options.moduleFederation === 'host') {
516
+ mainSourceFile.set({
517
+ statements: [
518
+ `import {
519
+ setRemoteDefinitions,
520
+ setRemoteUrlResolver
521
+ } from '@nx/angular/mf';
522
+ import type { Environment } from '@rxap/environment';
523
+ import { environment } from './environments/environment';
524
+
525
+ export async function SetupDynamicMfe(environment: Environment) {
526
+
527
+ const manifest = environment.moduleFederation?.manifest;
528
+
529
+ if (!manifest) {
530
+ const release = environment.tag || environment.branch || 'latest';
531
+ setRemoteUrlResolver((remoteName: string) => \`\${ location.origin }/__mfe/\${ release }/\${ remoteName }\`);
532
+ } else {
533
+
534
+ let definitions: Record<string, string>;
535
+
536
+ if (typeof manifest === 'object') {
537
+ definitions = manifest;
538
+ } else {
539
+ definitions = await fetch(manifest).then((res) => res.json());
540
+ }
541
+
542
+ setRemoteDefinitions(definitions);
543
+
544
+ }
545
+
546
+ }
547
+
548
+ SetupDynamicMfe(environment).then(() => import('./bootstrap').catch((err) => console.error(err)));
549
+ `,
550
+ ]
551
+ });
552
+ }
553
+ }, [
554
+ options.moduleFederation ? 'bootstrap.ts' : 'main.ts',
555
+ 'main.ts'
556
+ ]);
390
557
  }
391
558
  function coerceEnvironmentFiles(tree, options) {
392
559
  (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
@@ -404,14 +571,22 @@ function coerceEnvironmentFiles(tree, options) {
404
571
  name: w => w.quote('development'),
405
572
  production: 'false',
406
573
  app: w => w.quote(options.project),
407
- serviceWorker: 'false',
408
574
  };
575
+ // region dev environment
576
+ if (options.serviceWorker) {
577
+ baseEnvironment['serviceWorker'] = 'false';
578
+ }
409
579
  if (options.sentry) {
410
580
  baseEnvironment['sentry'] = ts_morph_2.Writers.object({
411
581
  enabled: 'false',
412
582
  debug: 'false',
413
583
  });
414
584
  }
585
+ if (options.moduleFederation === 'host') {
586
+ baseEnvironment['moduleFederation'] = ts_morph_2.Writers.object({
587
+ manifest: w => w.quote('/assets/module-federation.manifest.json'),
588
+ });
589
+ }
415
590
  const normal = (0, ts_morph_1.CoerceVariableDeclaration)(sourceFile, 'environment', {
416
591
  type: 'Environment',
417
592
  initializer: ts_morph_2.Writers.object(baseEnvironment),
@@ -419,15 +594,22 @@ function coerceEnvironmentFiles(tree, options) {
419
594
  if (options.overwrite) {
420
595
  normal.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
421
596
  }
422
- baseEnvironment['name'] = w => w.quote('production');
423
- baseEnvironment['production'] = 'true';
424
- baseEnvironment['serviceWorker'] = 'true';
597
+ // region
598
+ // region prod environment
599
+ if (options.moduleFederation === 'host') {
600
+ delete baseEnvironment['moduleFederation'];
601
+ }
602
+ if (options.serviceWorker) {
603
+ baseEnvironment['serviceWorker'] = 'true';
604
+ }
425
605
  if (options.sentry) {
426
606
  baseEnvironment['sentry'] = ts_morph_2.Writers.object({
427
607
  enabled: 'true',
428
608
  debug: 'false',
429
609
  });
430
610
  }
611
+ baseEnvironment['name'] = w => w.quote('production');
612
+ baseEnvironment['production'] = 'true';
431
613
  const prod = (0, ts_morph_1.CoerceVariableDeclaration)(prodSourceFile, 'environment', {
432
614
  type: 'Environment',
433
615
  initializer: ts_morph_2.Writers.object(baseEnvironment),
@@ -435,6 +617,7 @@ function coerceEnvironmentFiles(tree, options) {
435
617
  if (options.overwrite) {
436
618
  prod.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
437
619
  }
620
+ // endregion
438
621
  }, [
439
622
  '/environments/environment.ts?',
440
623
  '/environments/environment.prod.ts?',
@@ -464,40 +647,91 @@ function updateTsConfig(tree, projectName) {
464
647
  const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
465
648
  for (const tsConfigName of ['app', 'editor', 'spec']) {
466
649
  (0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
467
- var _a, _b;
468
- var _c;
650
+ var _a, _b, _c;
651
+ var _d;
469
652
  (_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
470
- (_b = (_c = tsConfig.compilerOptions).types) !== null && _b !== void 0 ? _b : (_c.types = []);
653
+ (_b = (_d = tsConfig.compilerOptions).types) !== null && _b !== void 0 ? _b : (_d.types = []);
471
654
  if (!tsConfig.compilerOptions.types.includes('@angular/localize')) {
472
655
  tsConfig.compilerOptions.types.push('@angular/localize');
473
656
  }
657
+ if (['app', 'spec'].includes(tsConfigName)) {
658
+ (_c = tsConfig.exclude) !== null && _c !== void 0 ? _c : (tsConfig.exclude = []);
659
+ (0, utilities_1.CoerceArrayItems)(tsConfig.exclude, [
660
+ 'src/**/*.stories.ts',
661
+ 'src/**/*.cy.ts',
662
+ ]);
663
+ }
474
664
  }, { infix: tsConfigName, basePath: projectRoot });
475
665
  }
476
666
  }
667
+ function linkMfeRemoteWithHost(tree, projectName, options) {
668
+ if (!options.host) {
669
+ throw new Error('The host project must be defined');
670
+ }
671
+ const hostSourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, options.host);
672
+ const isHostMonolithic = tree.exists((0, path_1.join)(hostSourceRoot, 'app/layout.routes.ts'));
673
+ const path = projectName.replace('user-interface-', '').replace('feature-', '');
674
+ if (isHostMonolithic && !options.standaloneImport) {
675
+ (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
676
+ project: options.host,
677
+ }, (project, [layoutSourceFile]) => {
678
+ (0, ts_morph_1.CoerceLayoutRoutes)(layoutSourceFile, {
679
+ itemList: [
680
+ {
681
+ route: {
682
+ path,
683
+ loadRemoteModule: projectName
684
+ },
685
+ component: 'LayoutComponent'
686
+ }
687
+ ]
688
+ });
689
+ }, ['app/layout.routes.ts']);
690
+ }
691
+ else {
692
+ (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
693
+ project: options.host,
694
+ }, (project, [appRoutes]) => {
695
+ (0, ts_morph_1.CoerceAppRoutes)(appRoutes, {
696
+ itemList: [
697
+ {
698
+ route: {
699
+ path,
700
+ loadRemoteModule: projectName
701
+ },
702
+ },
703
+ ],
704
+ });
705
+ }, ['app/app.routes.ts']);
706
+ }
707
+ }
477
708
  function initApplicationGenerator(tree, options) {
478
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
709
+ var _a, _b, _c;
479
710
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
480
- (_a = options.sentry) !== null && _a !== void 0 ? _a : (options.sentry = true);
481
- (_b = options.openApi) !== null && _b !== void 0 ? _b : (options.openApi = false);
482
- (_c = options.config) !== null && _c !== void 0 ? _c : (options.config = true);
483
- (_d = options.localazy) !== null && _d !== void 0 ? _d : (options.localazy = false);
484
- (_e = options.i18n) !== null && _e !== void 0 ? _e : (options.i18n = false);
485
- (_f = options.serviceWorker) !== null && _f !== void 0 ? _f : (options.serviceWorker = false);
486
- (_g = options.languages) !== null && _g !== void 0 ? _g : (options.languages = options.i18n ? ['en'] : []);
487
- (_h = options.material) !== null && _h !== void 0 ? _h : (options.material = true);
488
- (_j = options.generateMain) !== null && _j !== void 0 ? _j : (options.generateMain = false);
489
- (_k = options.overwrite) !== null && _k !== void 0 ? _k : (options.overwrite = false);
490
- (_l = options.monolithic) !== null && _l !== void 0 ? _l : (options.monolithic = false);
491
- options.openApi = options.openApi || options.monolithic;
492
- (_m = options.authentik) !== null && _m !== void 0 ? _m : (options.authentik = false);
493
- (_o = options.oauth) !== null && _o !== void 0 ? _o : (options.oauth = false);
494
- (_p = options.authentication) !== null && _p !== void 0 ? _p : (options.authentication = false);
495
- options.oauth = options.oauth || options.authentik;
496
- (_q = options.project) !== null && _q !== void 0 ? _q : (options.project = undefined);
497
- (_r = options.projects) !== null && _r !== void 0 ? _r : (options.projects = []);
711
+ if (options.authentik) {
712
+ options.oauth = true;
713
+ }
714
+ if (options.monolithic) {
715
+ options.openApi = true;
716
+ }
717
+ if (options.i18n) {
718
+ (_a = options.languages) !== null && _a !== void 0 ? _a : (options.languages = ['en']);
719
+ }
498
720
  if (options.project) {
721
+ (_b = options.projects) !== null && _b !== void 0 ? _b : (options.projects = []);
499
722
  (0, utilities_1.CoerceArrayItems)(options.projects, [options.project]);
500
723
  }
724
+ if (options.host) {
725
+ options.moduleFederation = 'remote';
726
+ }
727
+ if (options.moduleFederation === 'remote') {
728
+ options.authentication = false;
729
+ options.oauth = false;
730
+ options.authentik = false;
731
+ options.serviceWorker = false;
732
+ options.sentry = false;
733
+ options.monolithic = false;
734
+ }
501
735
  console.log('angular application init generator:', options);
502
736
  yield (0, plugin_application_1.ApplicationInitWorkspace)(tree, options);
503
737
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@mdi/angular-material', 'latest', { soft: true });
@@ -520,6 +754,7 @@ function initApplicationGenerator(tree, options) {
520
754
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/pipes', 'latest', { soft: true });
521
755
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/mixin', 'latest', { soft: true });
522
756
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/reflect-metadata', 'latest', { soft: true });
757
+ yield (0, workspace_utilities_1.AddPackageJsonDevDependency)(tree, '@rxap/browser-tailwind', 'latest', { soft: true, withoutNonRxapPeerDependencies: false });
523
758
  const angularVersion = '~16.2.0';
524
759
  // must always be added as some rxap components use the i18n tag
525
760
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize', angularVersion, { soft: true });
@@ -588,7 +823,10 @@ function initApplicationGenerator(tree, options) {
588
823
  target: 'shared/angular',
589
824
  overwrite: options.overwrite,
590
825
  });
591
- if (options.i18n) {
826
+ if (!tree.exists('shared/angular/assets/custom.svg')) {
827
+ tree.write('shared/angular/assets/custom.svg', '<svg></svg>');
828
+ }
829
+ if (options.i18n && !options.skipDocker) {
592
830
  let dockerfileContent = tree.read('shared/angular/Dockerfile', 'utf-8');
593
831
  dockerfileContent = dockerfileContent.replace('registry.gitlab.com/rxap/docker/nginx:', 'registry.gitlab.com/rxap/docker/i18n-nginx:');
594
832
  tree.write('shared/angular/Dockerfile', dockerfileContent);
@@ -606,6 +844,7 @@ function initApplicationGenerator(tree, options) {
606
844
  });
607
845
  }
608
846
  updateTargetDefaults(tree, options);
847
+ yield (0, coerce_project_1.CoerceProjects)(tree, options);
609
848
  if (!options.skipProjects) {
610
849
  for (const [projectName, project] of (0, devkit_1.getProjects)(tree).entries()) {
611
850
  if (skipProject(tree, options, project, projectName)) {
@@ -613,16 +852,19 @@ function initApplicationGenerator(tree, options) {
613
852
  }
614
853
  (0, workspace_utilities_1.GenerateSerializedSchematicFile)(tree, (0, workspace_utilities_1.GetProjectRoot)(tree, projectName), '@rxap/plugin-angular', 'init-application', (0, utilities_1.DeleteProperties)(options, ['project', 'projects', 'overwrite', 'skipProjects']));
615
854
  console.log(`init angular application project: ${projectName}`);
855
+ const sourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName);
616
856
  (0, plugin_application_1.ApplicationInitProject)(tree, projectName, project, options);
617
- updateProjectTargets(project, options);
857
+ if (options.overwrite || !((_c = tree.read((0, path_1.join)(sourceRoot, 'styles.scss'), 'utf-8')) === null || _c === void 0 ? void 0 : _c.match(/@use ".+\/shared\/angular\/styles";/))) {
858
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'root'), sourceRoot, Object.assign(Object.assign({ serviceWorker: false }, options), { relativePathToWorkspaceRoot: (0, path_1.relative)(sourceRoot, ''), name: projectName.replace(/^user-interface-/, ''), classify: utilities_1.classify, prefix: (0, workspace_utilities_1.GetProjectPrefix)(tree, projectName, 'rxap') }));
859
+ }
860
+ updateProjectTargets(projectName, project, options);
618
861
  updateTags(project, options);
619
862
  updateGitIgnore(project, tree, options);
620
863
  updateTsConfig(tree, projectName);
621
- coerceEnvironmentFiles(tree, {
622
- project: projectName,
623
- sentry: options.sentry,
624
- overwrite: options.overwrite,
625
- });
864
+ if (options.cleanup || options.coerce) {
865
+ cleanup(tree, projectName, options);
866
+ }
867
+ coerceEnvironmentFiles(tree, Object.assign(Object.assign({}, options), { project: projectName }));
626
868
  (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
627
869
  project: projectName,
628
870
  }, (_, [sourceFile]) => {
@@ -742,12 +984,6 @@ function initApplicationGenerator(tree, options) {
742
984
  if (options.generateMain) {
743
985
  updateMainFile(tree, projectName, project, options);
744
986
  }
745
- if (!project.sourceRoot) {
746
- throw new Error(`Project source root not found for project ${projectName}`);
747
- }
748
- if (options.cleanup) {
749
- cleanup(tree, project.sourceRoot);
750
- }
751
987
  if (options.localazy) {
752
988
  coerceLocalazyConfigFile(tree, project);
753
989
  }
@@ -757,23 +993,40 @@ function initApplicationGenerator(tree, options) {
757
993
  if (options.monolithic) {
758
994
  (0, generate_monolithic_1.generateMonolithic)(tree, projectName, project, options);
759
995
  }
996
+ if (options.moduleFederation === 'remote') {
997
+ if (options.overwrite) {
998
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'mfe-remote'), sourceRoot, Object.assign(Object.assign({}, options), { relativePathToWorkspaceRoot: (0, path_1.relative)(sourceRoot, ''), name: projectName
999
+ .replace(/^user-interface-/, '')
1000
+ .replace(/^feature-/, ''), classify: utilities_1.classify,
1001
+ dasherize: utilities_1.dasherize, prefix: (0, workspace_utilities_1.GetProjectPrefix)(tree, projectName, 'rxap') }));
1002
+ }
1003
+ if (options.host) {
1004
+ linkMfeRemoteWithHost(tree, projectName, options);
1005
+ }
1006
+ }
760
1007
  if (options.serviceWorker) {
761
- if (options.overwrite || !tree.exists((0, path_1.join)(project.sourceRoot, 'manifest.webmanifest'))) {
762
- (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,
1008
+ if (options.overwrite || !tree.exists((0, path_1.join)(sourceRoot, 'manifest.webmanifest'))) {
1009
+ (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'service-worker'), sourceRoot, Object.assign(Object.assign({}, options), { name: projectName.replace(/^user-interface-/, ''), classify: utilities_1.classify,
763
1010
  dasherize: utilities_1.dasherize }));
764
1011
  }
765
1012
  }
766
1013
  (0, workspace_utilities_1.CoerceFilesStructure)(tree, {
767
1014
  srcFolder: (0, path_1.join)(__dirname, 'files', 'assets'),
768
- target: (0, path_1.join)(project.sourceRoot, 'assets'),
1015
+ target: (0, path_1.join)(sourceRoot, 'assets'),
769
1016
  overwrite: options.overwrite,
770
1017
  });
1018
+ (0, coerce_test_setup_1.coerceTestSetup)(tree, projectName);
771
1019
  // apply changes to the project configuration
772
1020
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
773
1021
  }
774
1022
  }
775
- yield (0, plugin_localazy_1.LocalazyGitlabCiGenerator)(tree, {});
776
- yield (0, plugin_docker_1.DockerGitlabCiGenerator)(tree, {});
1023
+ if (options.localazy) {
1024
+ yield (0, plugin_localazy_1.LocalazyGitlabCiGenerator)(tree, {});
1025
+ }
1026
+ (0, plugin_gitlab_ci_1.GenerateGitlabCi)(tree, {});
1027
+ if (!options.skipFormat) {
1028
+ yield (0, devkit_1.formatFiles)(tree);
1029
+ }
777
1030
  });
778
1031
  }
779
1032
  exports.initApplicationGenerator = initApplicationGenerator;