@rxap/plugin-angular 16.2.0-dev.9 → 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 +99 -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 +303 -72
  26. package/src/generators/init-application/generator.js.map +1 -1
  27. package/src/generators/init-application/schema.d.ts +11 -0
  28. package/src/generators/init-application/schema.json +49 -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,29 +337,124 @@ 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, {
@@ -336,7 +462,7 @@ function updateMainFile(tree, projectName, project, options) {
336
462
  // directory: '..' // to move from the apps/demo/src/app folder into the apps/demo/src folder
337
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,11 +512,41 @@ function updateMainFile(tree, projectName, project, options) {
386
512
  sourceFile.insertStatements(index, statement);
387
513
  }
388
514
  }
389
- if (options.moduleFederation) {
515
+ if (options.moduleFederation === 'host') {
390
516
  mainSourceFile.set({
391
517
  statements: [
392
- 'import { SetupDynamicMfe } from \'@rxap/ngx-bootstrap\';',
393
- 'SetupDynamicMfe(environment).then(() => import(\'./bootstrap\').catch((err) => console.error(err)));',
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
+ `,
394
550
  ]
395
551
  });
396
552
  }
@@ -415,8 +571,11 @@ function coerceEnvironmentFiles(tree, options) {
415
571
  name: w => w.quote('development'),
416
572
  production: 'false',
417
573
  app: w => w.quote(options.project),
418
- serviceWorker: 'false',
419
574
  };
575
+ // region dev environment
576
+ if (options.serviceWorker) {
577
+ baseEnvironment['serviceWorker'] = 'false';
578
+ }
420
579
  if (options.sentry) {
421
580
  baseEnvironment['sentry'] = ts_morph_2.Writers.object({
422
581
  enabled: 'false',
@@ -432,21 +591,25 @@ function coerceEnvironmentFiles(tree, options) {
432
591
  type: 'Environment',
433
592
  initializer: ts_morph_2.Writers.object(baseEnvironment),
434
593
  });
594
+ if (options.overwrite) {
595
+ normal.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
596
+ }
597
+ // region
598
+ // region prod environment
435
599
  if (options.moduleFederation === 'host') {
436
600
  delete baseEnvironment['moduleFederation'];
437
601
  }
438
- if (options.overwrite) {
439
- normal.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
602
+ if (options.serviceWorker) {
603
+ baseEnvironment['serviceWorker'] = 'true';
440
604
  }
441
- baseEnvironment['name'] = w => w.quote('production');
442
- baseEnvironment['production'] = 'true';
443
- baseEnvironment['serviceWorker'] = 'true';
444
605
  if (options.sentry) {
445
606
  baseEnvironment['sentry'] = ts_morph_2.Writers.object({
446
607
  enabled: 'true',
447
608
  debug: 'false',
448
609
  });
449
610
  }
611
+ baseEnvironment['name'] = w => w.quote('production');
612
+ baseEnvironment['production'] = 'true';
450
613
  const prod = (0, ts_morph_1.CoerceVariableDeclaration)(prodSourceFile, 'environment', {
451
614
  type: 'Environment',
452
615
  initializer: ts_morph_2.Writers.object(baseEnvironment),
@@ -454,6 +617,7 @@ function coerceEnvironmentFiles(tree, options) {
454
617
  if (options.overwrite) {
455
618
  prod.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
456
619
  }
620
+ // endregion
457
621
  }, [
458
622
  '/environments/environment.ts?',
459
623
  '/environments/environment.prod.ts?',
@@ -483,46 +647,90 @@ function updateTsConfig(tree, projectName) {
483
647
  const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
484
648
  for (const tsConfigName of ['app', 'editor', 'spec']) {
485
649
  (0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
486
- var _a, _b;
487
- var _c;
650
+ var _a, _b, _c;
651
+ var _d;
488
652
  (_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
489
- (_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 = []);
490
654
  if (!tsConfig.compilerOptions.types.includes('@angular/localize')) {
491
655
  tsConfig.compilerOptions.types.push('@angular/localize');
492
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
+ }
493
664
  }, { infix: tsConfigName, basePath: projectRoot });
494
665
  }
495
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
+ }
496
708
  function initApplicationGenerator(tree, options) {
497
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
709
+ var _a, _b, _c;
498
710
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
499
- (_a = options.moduleFederation) !== null && _a !== void 0 ? _a : (options.moduleFederation = undefined);
500
- (_b = options.sentry) !== null && _b !== void 0 ? _b : (options.sentry = true);
501
- (_c = options.openApi) !== null && _c !== void 0 ? _c : (options.openApi = false);
502
- (_d = options.config) !== null && _d !== void 0 ? _d : (options.config = true);
503
- (_e = options.localazy) !== null && _e !== void 0 ? _e : (options.localazy = false);
504
- (_f = options.i18n) !== null && _f !== void 0 ? _f : (options.i18n = false);
505
- (_g = options.serviceWorker) !== null && _g !== void 0 ? _g : (options.serviceWorker = false);
506
- (_h = options.languages) !== null && _h !== void 0 ? _h : (options.languages = options.i18n ? ['en'] : []);
507
- (_j = options.material) !== null && _j !== void 0 ? _j : (options.material = true);
508
- (_k = options.generateMain) !== null && _k !== void 0 ? _k : (options.generateMain = false);
509
- (_l = options.overwrite) !== null && _l !== void 0 ? _l : (options.overwrite = false);
510
- (_m = options.monolithic) !== null && _m !== void 0 ? _m : (options.monolithic = false);
511
- options.openApi = options.openApi || options.monolithic;
512
- (_o = options.authentik) !== null && _o !== void 0 ? _o : (options.authentik = false);
513
- (_p = options.oauth) !== null && _p !== void 0 ? _p : (options.oauth = false);
514
- (_q = options.authentication) !== null && _q !== void 0 ? _q : (options.authentication = false);
515
- options.oauth = options.oauth || options.authentik;
516
- (_r = options.project) !== null && _r !== void 0 ? _r : (options.project = undefined);
517
- (_s = options.projects) !== null && _s !== void 0 ? _s : (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
+ }
518
720
  if (options.project) {
721
+ (_b = options.projects) !== null && _b !== void 0 ? _b : (options.projects = []);
519
722
  (0, utilities_1.CoerceArrayItems)(options.projects, [options.project]);
520
723
  }
724
+ if (options.host) {
725
+ options.moduleFederation = 'remote';
726
+ }
521
727
  if (options.moduleFederation === 'remote') {
522
728
  options.authentication = false;
523
729
  options.oauth = false;
524
730
  options.authentik = false;
525
731
  options.serviceWorker = false;
732
+ options.sentry = false;
733
+ options.monolithic = false;
526
734
  }
527
735
  console.log('angular application init generator:', options);
528
736
  yield (0, plugin_application_1.ApplicationInitWorkspace)(tree, options);
@@ -546,6 +754,7 @@ function initApplicationGenerator(tree, options) {
546
754
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/pipes', 'latest', { soft: true });
547
755
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/mixin', 'latest', { soft: true });
548
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 });
549
758
  const angularVersion = '~16.2.0';
550
759
  // must always be added as some rxap components use the i18n tag
551
760
  yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize', angularVersion, { soft: true });
@@ -614,7 +823,10 @@ function initApplicationGenerator(tree, options) {
614
823
  target: 'shared/angular',
615
824
  overwrite: options.overwrite,
616
825
  });
617
- 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) {
618
830
  let dockerfileContent = tree.read('shared/angular/Dockerfile', 'utf-8');
619
831
  dockerfileContent = dockerfileContent.replace('registry.gitlab.com/rxap/docker/nginx:', 'registry.gitlab.com/rxap/docker/i18n-nginx:');
620
832
  tree.write('shared/angular/Dockerfile', dockerfileContent);
@@ -632,6 +844,7 @@ function initApplicationGenerator(tree, options) {
632
844
  });
633
845
  }
634
846
  updateTargetDefaults(tree, options);
847
+ yield (0, coerce_project_1.CoerceProjects)(tree, options);
635
848
  if (!options.skipProjects) {
636
849
  for (const [projectName, project] of (0, devkit_1.getProjects)(tree).entries()) {
637
850
  if (skipProject(tree, options, project, projectName)) {
@@ -639,11 +852,18 @@ function initApplicationGenerator(tree, options) {
639
852
  }
640
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']));
641
854
  console.log(`init angular application project: ${projectName}`);
855
+ const sourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName);
642
856
  (0, plugin_application_1.ApplicationInitProject)(tree, projectName, project, options);
643
- 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);
644
861
  updateTags(project, options);
645
862
  updateGitIgnore(project, tree, options);
646
863
  updateTsConfig(tree, projectName);
864
+ if (options.cleanup || options.coerce) {
865
+ cleanup(tree, projectName, options);
866
+ }
647
867
  coerceEnvironmentFiles(tree, Object.assign(Object.assign({}, options), { project: projectName }));
648
868
  (0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
649
869
  project: projectName,
@@ -764,12 +984,6 @@ function initApplicationGenerator(tree, options) {
764
984
  if (options.generateMain) {
765
985
  updateMainFile(tree, projectName, project, options);
766
986
  }
767
- if (!project.sourceRoot) {
768
- throw new Error(`Project source root not found for project ${projectName}`);
769
- }
770
- if (options.cleanup) {
771
- cleanup(tree, project.sourceRoot);
772
- }
773
987
  if (options.localazy) {
774
988
  coerceLocalazyConfigFile(tree, project);
775
989
  }
@@ -779,23 +993,40 @@ function initApplicationGenerator(tree, options) {
779
993
  if (options.monolithic) {
780
994
  (0, generate_monolithic_1.generateMonolithic)(tree, projectName, project, options);
781
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
+ }
782
1007
  if (options.serviceWorker) {
783
- if (options.overwrite || !tree.exists((0, path_1.join)(project.sourceRoot, 'manifest.webmanifest'))) {
784
- (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,
785
1010
  dasherize: utilities_1.dasherize }));
786
1011
  }
787
1012
  }
788
1013
  (0, workspace_utilities_1.CoerceFilesStructure)(tree, {
789
1014
  srcFolder: (0, path_1.join)(__dirname, 'files', 'assets'),
790
- target: (0, path_1.join)(project.sourceRoot, 'assets'),
1015
+ target: (0, path_1.join)(sourceRoot, 'assets'),
791
1016
  overwrite: options.overwrite,
792
1017
  });
1018
+ (0, coerce_test_setup_1.coerceTestSetup)(tree, projectName);
793
1019
  // apply changes to the project configuration
794
1020
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
795
1021
  }
796
1022
  }
797
- yield (0, plugin_localazy_1.LocalazyGitlabCiGenerator)(tree, {});
798
- 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
+ }
799
1030
  });
800
1031
  }
801
1032
  exports.initApplicationGenerator = initApplicationGenerator;