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

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 (80) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +16 -3
  3. package/.eslintignore +0 -6
  4. package/.eslintrc.json +0 -44
  5. package/LICENSE +0 -621
  6. package/README.md.handlebars +0 -115
  7. package/jest.config.ts +0 -11
  8. package/project.json +0 -68
  9. package/schematics.yaml +0 -6
  10. package/src/application.ts +0 -124
  11. package/src/executors/check-ng-package/executor.ts +0 -33
  12. package/src/executors/config/executor.ts +0 -74
  13. package/src/executors/i18n/executor.ts +0 -198
  14. package/src/executors/tailwind/executor.ts +0 -34
  15. package/src/generators/convert-to-buildable-library/generator.ts +0 -110
  16. package/src/generators/fix-schematic/generator.ts +0 -103
  17. package/src/generators/fix-schematic/index.ts +0 -5
  18. package/src/generators/init/coerce-nx-json.ts +0 -72
  19. package/src/generators/init/generator.ts +0 -28
  20. package/src/generators/init/index.ts +0 -5
  21. package/src/generators/init/init-workspace.ts +0 -84
  22. package/src/generators/init-application/assert-main-statements.ts +0 -74
  23. package/src/generators/init-application/cleanup.ts +0 -127
  24. package/src/generators/init-application/coerce-app-config.ts +0 -147
  25. package/src/generators/init-application/coerce-environment-files.ts +0 -105
  26. package/src/generators/init-application/coerce-localazy-config-file.ts +0 -26
  27. package/src/generators/init-application/coerce-project.ts +0 -128
  28. package/src/generators/init-application/generate-authentication.ts +0 -122
  29. package/src/generators/init-application/generate-monolithic.spec.ts +0 -45
  30. package/src/generators/init-application/generate-monolithic.ts +0 -57
  31. package/src/generators/init-application/generator.ts +0 -356
  32. package/src/generators/init-application/index.ts +0 -5
  33. package/src/generators/init-application/link-mfe-remote-with-host.ts +0 -60
  34. package/src/generators/init-application/project-i18n-configuration.ts +0 -4
  35. package/src/generators/init-application/update-git-ignore.ts +0 -22
  36. package/src/generators/init-application/update-main-file.ts +0 -118
  37. package/src/generators/init-application/update-project-targets.ts +0 -229
  38. package/src/generators/init-application/update-tags.ts +0 -30
  39. package/src/generators/init-application/update-target-defaults.ts +0 -43
  40. package/src/generators/init-application/update-ts-config.ts +0 -31
  41. package/src/generators/init-component/generator.ts +0 -147
  42. package/src/generators/init-component/index.ts +0 -5
  43. package/src/generators/init-feature/generator.ts +0 -77
  44. package/src/generators/init-feature/index.ts +0 -5
  45. package/src/generators/init-feature-library/generator.ts +0 -82
  46. package/src/generators/init-feature-library/index.ts +0 -5
  47. package/src/generators/init-feature-library/init-project.ts +0 -53
  48. package/src/generators/init-feature-library/init-workspace.ts +0 -10
  49. package/src/generators/init-library/check-if-secondary-entrypoint-include-in-the-ts-config.ts +0 -46
  50. package/src/generators/init-library/cleanup.ts +0 -22
  51. package/src/generators/init-library/coerce-projects.ts +0 -118
  52. package/src/generators/init-library/coerce-tailwind-theme-scss.ts +0 -27
  53. package/src/generators/init-library/extend-angular-specific-eslint.ts +0 -37
  54. package/src/generators/init-library/generator.ts +0 -87
  55. package/src/generators/init-library/has-index-scss.ts +0 -14
  56. package/src/generators/init-library/has-tailwind-config.ts +0 -9
  57. package/src/generators/init-library/index.ts +0 -5
  58. package/src/generators/init-library/init-project.ts +0 -46
  59. package/src/generators/init-library/init-workspace.ts +0 -26
  60. package/src/generators/init-library/is-ng-packagr-project.ts +0 -9
  61. package/src/generators/init-library/ng-package-json.ts +0 -23
  62. package/src/generators/init-library/set-general-target-defaults.ts +0 -36
  63. package/src/generators/init-library/update-package-json.ts +0 -26
  64. package/src/generators/init-library/update-project-ng-package-configuration.ts +0 -51
  65. package/src/generators/init-library/update-ts-config.ts +0 -24
  66. package/src/generators/schematic/generator.ts +0 -179
  67. package/src/generators/schematic/index.ts +0 -5
  68. package/src/i18n.ts +0 -130
  69. package/src/index.ts +0 -3
  70. package/src/lib/angular-version.ts +0 -1
  71. package/src/lib/coerce-cypress-component-testing.ts +0 -113
  72. package/src/lib/coerce-test-setup.ts +0 -60
  73. package/src/library.ts +0 -153
  74. package/src/migrations/update-19-0-0/add-m2-prefix-to-material-scss-functions.ts +0 -32
  75. package/src/migrations/update-19-0-0/migration.ts +0 -283
  76. package/src/test-setup.ts +0 -24
  77. package/tsconfig.json +0 -20
  78. package/tsconfig.lib.json +0 -10
  79. package/tsconfig.spec.json +0 -15
  80. package/tsconfig.typedoc.json +0 -5
@@ -1,110 +0,0 @@
1
- import {
2
- readProjectConfiguration,
3
- Tree,
4
- } from '@nx/devkit';
5
- import {
6
- CoerceArrayItems,
7
- equals,
8
- } from '@rxap/utilities';
9
- import {
10
- AddPackageJsonDevDependency,
11
- CoerceTarget,
12
- GetProjectRoot,
13
- HasProject,
14
- UpdateJsonFile,
15
- UpdateProjectPackageJson,
16
- UpdateProjectTsConfigJson,
17
- } from '@rxap/workspace-utilities';
18
- import {
19
- join,
20
- relative,
21
- } from 'path';
22
- import initLibraryGenerator from '../init-library/generator';
23
- import { ConvertToBuildableLibraryGeneratorSchema } from './schema';
24
-
25
- export async function convertToBuildableLibraryGenerator(
26
- tree: Tree,
27
- options: ConvertToBuildableLibraryGeneratorSchema,
28
- ) {
29
- if (!HasProject(tree, options.project)) {
30
- throw new Error(`Project ${ options.project } not found`);
31
- }
32
-
33
- await AddPackageJsonDevDependency(tree, 'postcss', '^8.3.6', { soft: true });
34
- await AddPackageJsonDevDependency(tree, 'postcss-import', '~14.1.0', { soft: true });
35
- await AddPackageJsonDevDependency(tree, 'postcss-preset-env', '~7.5.0', { soft: true });
36
- await AddPackageJsonDevDependency(tree, 'postcss-url', '~10.1.3', { soft: true });
37
-
38
- const projectRoot = GetProjectRoot(tree, options.project);
39
- const toRoot = relative(projectRoot, '/');
40
-
41
- const project = readProjectConfiguration(tree, options.project);
42
-
43
- CoerceTarget(project, 'build', {
44
- executor: '@nx/angular:ng-packagr-lite',
45
- outputs: [
46
- '{workspaceRoot}/dist/{projectRoot}',
47
- ],
48
- options: {
49
- project: 'angular/components/ng-package.json',
50
- },
51
- configurations: {
52
- production: {
53
- tsConfig: 'angular/components/tsconfig.lib.prod.json',
54
- },
55
- development: {
56
- tsConfig: 'angular/components/tsconfig.lib.json',
57
- },
58
- },
59
- defaultConfiguration: 'production',
60
- });
61
-
62
- UpdateJsonFile(tree, ngPackage => {
63
- ngPackage.$schema = join(toRoot, 'node_modules/ng-packagr/ng-package.schema.json');
64
- ngPackage.lib ??= {};
65
- ngPackage.lib.entryFile = 'src/index.ts';
66
- ngPackage.dist ??= join(toRoot, 'dist', projectRoot);
67
- }, join(projectRoot, 'ng-package.json'), { create: true });
68
-
69
- UpdateProjectPackageJson(tree, (packageJson) => {
70
- packageJson.name = options.project;
71
- packageJson.private = true;
72
- packageJson.peerDependencies ??= {};
73
- packageJson.dependencies ??= {};
74
- packageJson.dependencies['tslib'] = '^2.3.0';
75
- packageJson.sideEffects = false;
76
- packageJson.version = '0.0.0';
77
- }, {
78
- projectName: options.project,
79
- create: true,
80
- });
81
-
82
- UpdateJsonFile(tree, eslintrc => {
83
- CoerceArrayItems(eslintrc.overrides, [
84
- {
85
- files: [
86
- '*.json',
87
- ],
88
- parser: 'jsonc-eslint-parser',
89
- rules: {
90
- '@nx/dependency-checks': 'error',
91
- },
92
- },
93
- ], (a, b) => a.parser === b.parser && equals(a.files, b.files));
94
- }, join(projectRoot, '.eslintrc.json'));
95
-
96
- UpdateProjectTsConfigJson(tree, (tsConfig) => {
97
- tsConfig.extends = './tsconfig.lib.json';
98
- tsConfig.compilerOptions ??= {};
99
- tsConfig.compilerOptions.declarationMap ??= false;
100
- tsConfig.angularCompilerOptions ??= {};
101
- }, {
102
- project: options.project,
103
- infix: 'lib.prod',
104
- });
105
-
106
- await initLibraryGenerator(tree, { project: options.project });
107
-
108
- }
109
-
110
- export default convertToBuildableLibraryGenerator;
@@ -1,103 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import {
3
- CoerceFile,
4
- GetProjectPackageJson,
5
- GetProjectRoot,
6
- GetProjectSourceRoot,
7
- HasProjectPackageJson,
8
- VisitTree,
9
- } from '@rxap/workspace-utilities';
10
- import {
11
- dirname,
12
- join,
13
- relative,
14
- } from 'path';
15
- import { FixSchematicGeneratorSchema } from './schema';
16
-
17
- export async function fixSchematicGenerator(
18
- tree: Tree,
19
- options: FixSchematicGeneratorSchema,
20
- ) {
21
- const projectRoot = GetProjectRoot(tree, options.project);
22
- const projectSourceRoot = GetProjectSourceRoot(tree, options.project);
23
- if (!projectSourceRoot) {
24
- throw new Error(`Project source root not found for project ${ options.project }`);
25
- }
26
- const schematicsSourceRoot = join(projectSourceRoot, 'schematics');
27
-
28
- if (!tree.exists(schematicsSourceRoot)) {
29
- console.warn(`The schematics source root ${ schematicsSourceRoot } does not exists!`);
30
- return;
31
- }
32
-
33
- if (!HasProjectPackageJson(tree, options.project)) {
34
- throw new Error(`The project ${ options.project } does not contains a package.json file!`);
35
- }
36
-
37
- const packageJson = GetProjectPackageJson(tree, options.project);
38
-
39
- if (!packageJson.schematics) {
40
- console.warn(`The package.json file does not contains schematics property!`);
41
- return;
42
- }
43
-
44
- const collectionFile = join(projectRoot, packageJson.schematics);
45
-
46
- if (!tree.exists(collectionFile)) {
47
- console.warn(`The collection file ${ collectionFile } does not exists!`);
48
- return;
49
- }
50
-
51
- const collection = JSON.parse(tree.read(collectionFile)!.toString('utf-8'));
52
-
53
- collection.schematics ??= {};
54
-
55
- const { schematics } = collection;
56
-
57
- const detectedSchemaJsonFiles: string[] = [];
58
-
59
- for (const {
60
- path,
61
- isFile
62
- } of VisitTree(tree, schematicsSourceRoot)) {
63
- if (isFile && path.endsWith('schema.json')) {
64
- detectedSchemaJsonFiles.push('./' + relative(projectRoot, path));
65
- }
66
- }
67
-
68
- const notDefinedSchematics: string[] = detectedSchemaJsonFiles
69
- .filter(schemaJsonFile =>
70
- !Object.values(schematics)
71
- .some((schematic: any) => schematic.schema === schemaJsonFile),
72
- );
73
-
74
- console.log(`Not defined schematics: ${ notDefinedSchematics.length }`);
75
- if (notDefinedSchematics.length) {
76
- console.log(` - ${ notDefinedSchematics.join('\n - ') }`);
77
- } else {
78
- console.log('All schematics are defined');
79
- }
80
-
81
- for (const schemaJsonFile of notDefinedSchematics) {
82
- const basePath = dirname(schemaJsonFile);
83
- const schematicName = basePath.split('/').pop()!;
84
- if (schematics[schematicName]) {
85
- console.warn(`The schematic ${ schematicName } is already defined!`);
86
- continue;
87
- }
88
- schematics[schematicName] = {
89
- schema: schemaJsonFile,
90
- factory: `${ basePath }/index`,
91
- };
92
- }
93
-
94
- for (const [ name, schematic ] of Object.entries(schematics as Record<string, any>)) {
95
- schematic['description'] ??= `The ${ name } schematic`;
96
- }
97
-
98
- console.log('Update collection file');
99
- CoerceFile(tree, collectionFile, JSON.stringify(collection, null, 2), true);
100
-
101
- }
102
-
103
- export default fixSchematicGenerator;
@@ -1,5 +0,0 @@
1
- import { convertNxGenerator } from '@nx/devkit';
2
- import generator from './generator';
3
-
4
- const schematic = convertNxGenerator(generator);
5
- export default schematic;
@@ -1,72 +0,0 @@
1
- import {
2
- readNxJson,
3
- Tree,
4
- updateNxJson,
5
- } from '@nx/devkit';
6
- import { CoerceNxJsonGenerators } from '@rxap/workspace-utilities';
7
- import { InitGeneratorSchema } from './schema';
8
-
9
- export function coerceNxJson(tree: Tree, options: InitGeneratorSchema) {
10
- const nxJson = readNxJson(tree)!;
11
-
12
- CoerceNxJsonGenerators(nxJson, '@nx/angular:application', {
13
- 'style': 'scss',
14
- 'linter': 'eslint',
15
- 'unitTestRunner': 'jest',
16
- 'e2eTestRunner': 'none',
17
- 'tags': 'angular,ngx',
18
- 'prefix': options.prefix ?? 'rxap',
19
- 'standalone': true,
20
- 'addTailwind': true,
21
- 'routing': true,
22
- });
23
- CoerceNxJsonGenerators(nxJson, '@nx/angular:host', {
24
- 'style': 'scss',
25
- 'linter': 'eslint',
26
- 'unitTestRunner': 'jest',
27
- 'e2eTestRunner': 'none',
28
- 'tags': 'angular,ngx',
29
- 'prefix': options.prefix ?? 'rxap',
30
- 'standalone': true,
31
- 'addTailwind': true,
32
- name: 'shell',
33
- 'directory': `user-interface/shell`,
34
- });
35
- CoerceNxJsonGenerators(nxJson, '@nx/angular:remote', {
36
- 'style': 'scss',
37
- 'linter': 'eslint',
38
- 'unitTestRunner': 'jest',
39
- 'e2eTestRunner': 'none',
40
- 'tags': 'angular,ngx',
41
- 'prefix': options.prefix ?? 'rxap',
42
- 'standalone': true,
43
- 'addTailwind': true,
44
- host: 'shell',
45
- });
46
- CoerceNxJsonGenerators(nxJson, '@nx/angular:component', {
47
- 'style': 'scss',
48
- 'standalone': true,
49
- });
50
- CoerceNxJsonGenerators(nxJson, '@nx/angular:library', {
51
- 'linter': 'eslint',
52
- 'unitTestRunner': 'jest',
53
- 'publishable': false,
54
- 'addTailwind': false,
55
- 'changeDetection': 'OnPush',
56
- 'standalone': true,
57
- 'style': 'scss',
58
- 'tags': 'angular,ngx',
59
- 'prefix': 'rxap',
60
- 'skipModule': true,
61
- buildable: false,
62
- });
63
- CoerceNxJsonGenerators(nxJson, '@nx/angular:directive', {
64
- 'standalone': true,
65
- 'skipTests': true,
66
- });
67
- CoerceNxJsonGenerators(nxJson, '@nx/angular:library-secondary-entry-point', {
68
- 'skipModule': true,
69
- });
70
-
71
- updateNxJson(tree, nxJson);
72
- }
@@ -1,28 +0,0 @@
1
- import {
2
- formatFiles,
3
- Tree,
4
- } from '@nx/devkit';
5
- import { GenerateSerializedSchematicFile } from '@rxap/workspace-utilities';
6
- import { initWorkspace } from './init-workspace';
7
- import { InitGeneratorSchema } from './schema';
8
-
9
- export async function initGenerator(tree: Tree, options: InitGeneratorSchema) {
10
- console.log('angular init generator:', options);
11
-
12
- await initWorkspace(tree, options);
13
-
14
- GenerateSerializedSchematicFile(
15
- tree,
16
- '/',
17
- '@rxap/plugin-angular',
18
- 'init',
19
- options,
20
- );
21
-
22
- if (!options.skipFormat) {
23
- await formatFiles(tree);
24
- }
25
-
26
- }
27
-
28
- export default initGenerator;
@@ -1,5 +0,0 @@
1
- import { convertNxGenerator } from '@nx/devkit';
2
- import generator from './generator';
3
-
4
- const schematic = convertNxGenerator(generator);
5
- export default schematic;
@@ -1,84 +0,0 @@
1
- import {
2
- readNxJson,
3
- Tree,
4
- updateNxJson,
5
- } from '@nx/devkit';
6
- import {
7
- AddPackageJsonDevDependency,
8
- CoerceNxPlugin,
9
- GetNxVersion,
10
- IsRxapRepository,
11
- } from '@rxap/workspace-utilities';
12
- import { join } from 'path';
13
- import initLibraryGenerator from '../init-library/generator';
14
- import { coerceNxJson } from './coerce-nx-json';
15
- import { InitGeneratorSchema } from './schema';
16
-
17
- export async function initWorkspace(tree: Tree, options: InitGeneratorSchema) {
18
- console.log('init angular workspace');
19
-
20
- const nxJson = readNxJson(tree)!;
21
-
22
- if (IsRxapRepository(tree)) {
23
- CoerceNxPlugin(nxJson, './packages/plugin/angular/src/library.ts');
24
- CoerceNxPlugin(nxJson, './packages/plugin/angular/src/application.ts');
25
- } else {
26
- CoerceNxPlugin(nxJson, '@rxap/plugin-angular/library');
27
- CoerceNxPlugin(nxJson, '@rxap/plugin-angular/application');
28
- }
29
-
30
- updateNxJson(tree, nxJson);
31
-
32
- await AddPackageJsonDevDependency(tree, '@nx/angular', GetNxVersion(tree), { soft: true });
33
-
34
- coerceNxJson(tree, options);
35
-
36
- if (options.withSharedLibraries) {
37
- for (const projectName of [
38
- 'components',
39
- 'forms',
40
- 'controls',
41
- 'tables'
42
- ]) {
43
- await initLibraryGenerator(tree, {
44
- project: 'angular-' + projectName,
45
- targets: {
46
- indexExport: true,
47
- },
48
- coerce: {
49
- directory: join('angular', projectName),
50
- addTailwind: true,
51
- buildable: true,
52
- }
53
- });
54
- }
55
-
56
- for (const projectName of [
57
- 'methods',
58
- 'data-sources',
59
- 'pipes',
60
- 'directives',
61
- 'guards',
62
- 'services',
63
- 'application-providers',
64
- 'utilities',
65
- 'shared',
66
- 'testing',
67
- 'resolvers',
68
- 'http-interceptors',
69
- 'bootstrap-hooks'
70
- ]) {
71
- await initLibraryGenerator(tree, {
72
- project: 'angular-' + projectName,
73
- targets: {
74
- indexExport: true,
75
- },
76
- coerce: {
77
- directory: join('angular', projectName),
78
- buildable: true,
79
- }
80
- });
81
- }
82
- }
83
-
84
- }
@@ -1,74 +0,0 @@
1
- import { CoerceImports } from '@rxap/ts-morph';
2
- import { SourceFile } from 'ts-morph';
3
- import { InitApplicationGeneratorSchema } from './schema';
4
-
5
- export const MAIN_BOOTSTRAP_STATEMENT = `application.bootstrap().catch((err) => console.error(err));`;
6
- const MAIN_LOGGER_STATEMENT = `application.importProvidersFrom(LoggerModule.forRoot({
7
- serverLoggingUrl: '/api/logs',
8
- level: NgxLoggerLevel.DEBUG,
9
- serverLogLevel: NgxLoggerLevel.ERROR,
10
- }));`;
11
- const MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplication(
12
- environment,
13
- AppComponent,
14
- appConfig,
15
- );`;
16
- const REMOTE_MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplication(
17
- environment,
18
- RemoteEntryComponent,
19
- appConfig,
20
- );`;
21
-
22
- export function assertMainStatements(sourceFile: SourceFile, options: InitApplicationGeneratorSchema) {
23
- const statements: string[] = [];
24
-
25
- statements.push('const application = new StandaloneApplication(');
26
- statements.push('application.importProvidersFrom(LoggerModule.forRoot({');
27
- const existingStatements = sourceFile.getStatements().map(s => s.getText()) ?? [];
28
- for (const statement of statements) {
29
- if (!existingStatements.includes(statement)) {
30
- console.error(`Missing statement from angular main.ts: ${ statement }`);
31
- sourceFile.set({
32
- statements: [
33
- options.moduleFederation === 'remote' ? REMOTE_MAIN_APP_CREATION_STATEMENT : MAIN_APP_CREATION_STATEMENT,
34
- MAIN_LOGGER_STATEMENT,
35
- MAIN_BOOTSTRAP_STATEMENT,
36
- ],
37
- });
38
- CoerceImports(sourceFile, [
39
- {
40
- moduleSpecifier: './app/app.config',
41
- namedImports: [ 'appConfig' ],
42
- },
43
- {
44
- moduleSpecifier: './environments/environment',
45
- namedImports: [ 'environment' ],
46
- },
47
- {
48
- moduleSpecifier: 'ngx-logger',
49
- namedImports: [ 'LoggerModule', 'NgxLoggerLevel' ],
50
- },
51
- {
52
- moduleSpecifier: '@rxap/ngx-bootstrap',
53
- namedImports: [ 'StandaloneApplication' ],
54
- },
55
- ]);
56
- if (options.moduleFederation === 'remote') {
57
- CoerceImports(sourceFile, [
58
- {
59
- moduleSpecifier: './app/remote-entry/entry.component',
60
- namedImports: [ 'RemoteEntryComponent' ],
61
- },
62
- ]);
63
- } else {
64
- CoerceImports(sourceFile, [
65
- {
66
- moduleSpecifier: './app/app.component',
67
- namedImports: [ 'AppComponent' ],
68
- },
69
- ]);
70
- }
71
- return;
72
- }
73
- }
74
- }
@@ -1,127 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import {
3
- CoerceComponentImport,
4
- CoerceDefaultExport,
5
- GetComponentDecoratorObject,
6
- RemoveComponentImport,
7
- RemoveRoute,
8
- } from '@rxap/ts-morph';
9
- import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
10
- import {
11
- CoerceFile,
12
- GetProjectRoot,
13
- GetProjectSourceRoot,
14
- UpdateTsConfigJson,
15
- } from '@rxap/workspace-utilities';
16
- import { join } from 'path';
17
- import { SyntaxKind } from 'ts-morph';
18
- import { InitApplicationGeneratorSchema } from './schema';
19
-
20
- export function cleanup(tree: Tree, projectName: string, options: InitApplicationGeneratorSchema) {
21
-
22
- const sourceRoot = GetProjectSourceRoot(tree, projectName);
23
-
24
- const deleteFiles = [
25
- 'app/app.component.spec.ts',
26
- 'app/nx-welcome.component.ts',
27
- 'app/remote-entry/nx-welcome.component.ts',
28
- 'app/nx-welcome.component.cy.ts',
29
- ];
30
-
31
- for (const file of deleteFiles) {
32
- if (tree.exists(join(sourceRoot, file))) {
33
- tree.delete(join(sourceRoot, file));
34
- }
35
- }
36
-
37
- if (tree.exists(join(sourceRoot, 'app/app.component.html'))) {
38
- const content = tree.read(join(sourceRoot, 'app/app.component.html'), 'utf-8')!
39
- .replace(/<.+-nx-welcome><\/.+-nx-welcome> /, '')
40
- .replace(/<ul class="remote-menu">[\s\S]*<\/ul>/, '');
41
- CoerceFile(tree, join(sourceRoot, 'app/app.component.html'), content, true);
42
- }
43
-
44
- if (options.moduleFederation !== 'remote') {
45
-
46
- TsMorphAngularProjectTransform(tree, {
47
- project: projectName,
48
- }, (_, [ appRoutes, appComponent ]) => {
49
- RemoveRoute(appRoutes, {
50
- component: 'NxWelcomeComponent',
51
- name: 'appRoutes',
52
- });
53
- appRoutes.getImportDeclaration('./nx-welcome.component')?.remove();
54
- appComponent.getClass('AppComponent')?.getProperty('title')?.remove();
55
- RemoveComponentImport(appComponent, 'NxWelcomeComponent');
56
- }, [ 'app/app.routes.ts', 'app/app.component.ts' ]);
57
-
58
- }
59
-
60
- if (options.moduleFederation === 'remote') {
61
-
62
- // region module-federation config
63
- const projectRoot = GetProjectRoot(tree, projectName);
64
- let content = tree.read(join(projectRoot, 'module-federation.config.ts'), 'utf-8')!;
65
- content = content.replace('./Routes', './routes');
66
- CoerceFile(tree, join(projectRoot, 'module-federation.config.ts'), content, true);
67
- // endregion
68
-
69
- // region tsconfig.base.json
70
- UpdateTsConfigJson(tree, tsConfig => {
71
- tsConfig.compilerOptions ??= {};
72
- tsConfig.compilerOptions.paths ??= {};
73
- if (tsConfig.compilerOptions.paths[`${ projectName }/Routes`]) {
74
- delete tsConfig.compilerOptions.paths[`${ projectName }/Routes`];
75
- }
76
- }, { infix: 'base' });
77
- // endregion
78
-
79
- TsMorphAngularProjectTransform(tree, {
80
- project: projectName,
81
- }, (_, [ entryRoutes ]) => {
82
- CoerceDefaultExport(entryRoutes.getVariableStatement('remoteRoutes')!.getDeclarations()[0]);
83
- }, [
84
- 'app/remote-entry/entry.routes.ts',
85
- ]);
86
- if (tree.exists(join(sourceRoot, 'app/remote-entry/entry.component.ts'))) {
87
- TsMorphAngularProjectTransform(tree, {
88
- project: projectName,
89
- }, (_, [ entryComponent ]) => {
90
- entryComponent.getImportDeclaration('./nx-welcome.component')?.remove();
91
- RemoveComponentImport(entryComponent, 'NxWelcomeComponent');
92
- RemoveComponentImport(entryComponent, 'CommonModule');
93
- const componentOptions = GetComponentDecoratorObject(entryComponent);
94
- const templateProp = componentOptions.getProperty('template');
95
- if (templateProp && templateProp.asKindOrThrow(SyntaxKind.PropertyAssignment).getInitializer()?.getText().match(
96
- /<.+nx-welcome><\/.+nx-welcome>/)) {
97
- templateProp.remove();
98
- componentOptions.addPropertyAssignment({
99
- name: 'template',
100
- initializer: w => w.quote('<router-outlet></router-outlet>'),
101
- });
102
- CoerceComponentImport(entryComponent, {
103
- name: 'RouterModule',
104
- moduleSpecifier: '@angular/router',
105
- });
106
- }
107
- }, [
108
- 'app/remote-entry/entry.component.ts',
109
- ]);
110
- }
111
- if (options.host) {
112
- TsMorphAngularProjectTransform(tree, {
113
- project: options.host,
114
- }, (_, [ appRoutes ]) => {
115
- RemoveRoute(appRoutes, {
116
- loadRemoteModule: {
117
- name: projectName,
118
- entry: './Routes',
119
- },
120
- name: 'appRoutes',
121
- });
122
- appRoutes.organizeImports();
123
- }, [ 'app/app.routes.ts' ]);
124
- }
125
- }
126
-
127
- }