@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,147 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import {
3
- CoerceAppConfigProvider,
4
- CoerceImports,
5
- ProviderObject,
6
- } from '@rxap/ts-morph';
7
- import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
8
- import { InitApplicationGeneratorSchema } from './schema';
9
-
10
- export function coerceAppConfig(tree: Tree, projectName: string, options: InitApplicationGeneratorSchema,) {
11
- TsMorphAngularProjectTransform(tree, {
12
- project: projectName,
13
- }, (_, [ sourceFile ]) => {
14
- const providers: Array<string | ProviderObject> = [
15
- 'provideRouter(appRoutes, withEnabledBlockingInitialNavigation())',
16
- 'provideAnimations()',
17
- 'ProvideErrorHandler()',
18
- 'ProvideEnvironment(environment)',
19
- ];
20
- const httpInterceptors = [
21
- 'HttpErrorInterceptor',
22
- ];
23
- const importProvidersFrom: string[] = [];
24
- CoerceImports(sourceFile, [
25
- {
26
- moduleSpecifier: '@angular/platform-browser/animations',
27
- namedImports: [ 'provideAnimations' ],
28
- },
29
- {
30
- moduleSpecifier: '@angular/router',
31
- namedImports: [ 'provideRouter', 'withEnabledBlockingInitialNavigation' ],
32
- },
33
- {
34
- moduleSpecifier: './app.routes',
35
- namedImports: [ 'appRoutes' ],
36
- },
37
- {
38
- moduleSpecifier: '@rxap/ngx-error',
39
- namedImports: [ 'ProvideErrorHandler', 'HttpErrorInterceptor' ],
40
- },
41
- {
42
- moduleSpecifier: '@rxap/environment',
43
- namedImports: [ 'ProvideEnvironment' ],
44
- },
45
- {
46
- moduleSpecifier: '../environments/environment',
47
- namedImports: [ 'environment' ],
48
- },
49
- ]);
50
- if (options.monolithic) {
51
- providers.push('ProvidePubSub()');
52
- providers.push('ProvideChangelog()');
53
- providers.push('provideTheme()');
54
- providers.push('provideExternalApps()');
55
- importProvidersFrom.push('MarkdownModule.forRoot()');
56
- CoerceImports(sourceFile, [
57
- {
58
- moduleSpecifier: '@rxap/ngx-changelog',
59
- namedImports: [ 'ProvideChangelog' ],
60
- },
61
- {
62
- moduleSpecifier: 'ngx-markdown',
63
- namedImports: [ 'MarkdownModule' ],
64
- },
65
- {
66
- moduleSpecifier: '@rxap/ngx-pub-sub',
67
- namedImports: [ 'ProvidePubSub' ],
68
- },
69
- {
70
- moduleSpecifier: '@rxap/ngx-theme',
71
- namedImports: [ 'provideTheme' ],
72
- },
73
- {
74
- moduleSpecifier: '@rxap/layout',
75
- namedImports: [ 'provideExternalApps' ],
76
- }
77
- ]);
78
- }
79
- if (options.oauth) {
80
- providers.push('provideOAuthClient()');
81
- providers.push('ProvideAuth()');
82
- httpInterceptors.push('BearerTokenInterceptor');
83
- CoerceImports(sourceFile, [
84
- {
85
- moduleSpecifier: 'angular-oauth2-oidc',
86
- namedImports: [ 'provideOAuthClient' ],
87
- },
88
- {
89
- moduleSpecifier: '@rxap/oauth',
90
- namedImports: [ 'ProvideAuth' ],
91
- },
92
- {
93
- moduleSpecifier: '@rxap/authentication',
94
- namedImports: [ 'BearerTokenInterceptor' ],
95
- },
96
- ]);
97
- }
98
- if (options.i18n) {
99
- httpInterceptors.push('LanguageInterceptor');
100
- CoerceImports(sourceFile, [
101
- {
102
- moduleSpecifier: '@rxap/ngx-localize',
103
- namedImports: [ 'LanguageInterceptor' ],
104
- },
105
- ]);
106
- }
107
- if (options.serviceWorker) {
108
- providers.push(
109
- `provideServiceWorker('ngsw-worker.js', { enabled: environment.serviceWorker, registrationStrategy: 'registerWhenStable:30000' })`);
110
- providers.push('ProvideServiceWorkerUpdater(withDialogUpdater())');
111
- CoerceImports(sourceFile, [
112
- {
113
- moduleSpecifier: '@angular/service-worker',
114
- namedImports: [ 'provideServiceWorker' ],
115
- },
116
- {
117
- moduleSpecifier: '@rxap/service-worker',
118
- namedImports: [ 'ProvideServiceWorkerUpdater', 'withDialogUpdater' ],
119
- },
120
- ]);
121
- }
122
- if (options.material) {
123
- providers.push('ProvideIconAssetPath()');
124
- CoerceImports(sourceFile, [
125
- {
126
- moduleSpecifier: '@rxap/icon',
127
- namedImports: [ 'ProvideIconAssetPath' ],
128
- },
129
- ]);
130
- }
131
- switch (options.authentication) {
132
- case 'oauth2-proxy':
133
- providers.push('provideOauth2Proxy()');
134
- CoerceImports(sourceFile, {
135
- moduleSpecifier: '@rxap/ngx-oauth2-proxy',
136
- namedImports: [ 'provideOauth2Proxy' ],
137
- });
138
- break;
139
- }
140
- CoerceAppConfigProvider(sourceFile, {
141
- overwrite: options.overwrite,
142
- providers,
143
- httpInterceptors,
144
- importProvidersFrom,
145
- });
146
- }, [ '/app/app.config.ts' ]);
147
- }
@@ -1,105 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import {
3
- CoerceImports,
4
- CoerceVariableDeclaration,
5
- } from '@rxap/ts-morph';
6
- import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
7
- import {
8
- WriterFunction,
9
- Writers,
10
- } from 'ts-morph';
11
- import { InitApplicationGeneratorSchema } from './schema';
12
-
13
- export function coerceEnvironmentFiles(tree: Tree, options: InitApplicationGeneratorSchema & { project: string }) {
14
-
15
- TsMorphAngularProjectTransform(
16
- tree,
17
- {
18
- project: options.project,
19
- },
20
- (project, [ sourceFile, prodSourceFile ]) => {
21
-
22
- CoerceImports(sourceFile, {
23
- moduleSpecifier: '@rxap/environment',
24
- namedImports: [ 'Environment' ],
25
- });
26
- CoerceImports(prodSourceFile, {
27
- moduleSpecifier: '@rxap/environment',
28
- namedImports: [ 'Environment' ],
29
- });
30
-
31
- const baseEnvironment: Record<string, WriterFunction | string> = {
32
- name: w => w.quote('development'),
33
- production: 'false',
34
- app: w => w.quote(options.project),
35
- };
36
-
37
- // region dev environment
38
-
39
- if (options.serviceWorker) {
40
- baseEnvironment['serviceWorker'] = 'false';
41
- }
42
-
43
- if (options.sentry) {
44
- baseEnvironment['sentry'] = Writers.object({
45
- enabled: 'false',
46
- debug: 'false',
47
- });
48
- }
49
-
50
- if (options.moduleFederation === 'host') {
51
- baseEnvironment['moduleFederation'] = Writers.object({
52
- manifest: w => w.quote('/module-federation.manifest.json'),
53
- });
54
- }
55
-
56
- const normal = CoerceVariableDeclaration(sourceFile, 'environment', {
57
- type: 'Environment',
58
- initializer: Writers.object(baseEnvironment),
59
- });
60
-
61
- if (options.overwrite) {
62
- normal.set({ initializer: Writers.object(baseEnvironment) });
63
- }
64
-
65
- // region
66
-
67
- // region prod environment
68
-
69
- if (options.moduleFederation === 'host') {
70
- delete baseEnvironment['moduleFederation'];
71
- }
72
-
73
- if (options.serviceWorker) {
74
- baseEnvironment['serviceWorker'] = 'true';
75
- }
76
-
77
- if (options.sentry) {
78
- baseEnvironment['sentry'] = Writers.object({
79
- enabled: 'true',
80
- debug: 'false',
81
- });
82
- }
83
-
84
- baseEnvironment['name'] = w => w.quote('production');
85
- baseEnvironment['production'] = 'true';
86
-
87
- const prod = CoerceVariableDeclaration(prodSourceFile, 'environment', {
88
- type: 'Environment',
89
- initializer: Writers.object(baseEnvironment),
90
- });
91
-
92
- if (options.overwrite) {
93
- prod.set({ initializer: Writers.object(baseEnvironment) });
94
- }
95
-
96
- // endregion
97
-
98
- },
99
- [
100
- '/environments/environment.ts?',
101
- '/environments/environment.prod.ts?',
102
- ],
103
- );
104
-
105
- }
@@ -1,26 +0,0 @@
1
- import {
2
- ProjectConfiguration,
3
- Tree,
4
- } from '@nx/devkit';
5
- import { CoerceFile } from '@rxap/workspace-utilities';
6
- import { join } from 'path';
7
-
8
- export function coerceLocalazyConfigFile(tree: Tree, project: ProjectConfiguration) {
9
- const projectRoot = project.root;
10
- const localazyConfigPath = join(projectRoot, 'localazy.json');
11
- CoerceFile(tree, localazyConfigPath, JSON.stringify({
12
- upload: {
13
- type: 'xliff',
14
- deprecate: 'file',
15
- features: [
16
- 'use_defined_lang_for_source',
17
- 'dont_parse_target',
18
- ],
19
- files: 'src/i18n/messages.xlf',
20
- },
21
- download: {
22
- includeSourceLang: true,
23
- files: 'src/i18n/${languageCode}.xlf',
24
- },
25
- }, null, 2));
26
- }
@@ -1,128 +0,0 @@
1
- import {
2
- applicationGenerator as angularApplicationGenerator,
3
- E2eTestRunner,
4
- host as angularHostGenerator,
5
- remote as angularRemoteGenerator,
6
- UnitTestRunner,
7
- } from '@nx/angular/generators';
8
- import { Schema as AngularApplicationGeneratorSchema } from '@nx/angular/src/generators/application/schema';
9
- import { Schema as AngularHostGeneratorSchema } from '@nx/angular/src/generators/host/schema';
10
- import { Schema as AngularRemoteGeneratorSchema } from '@nx/angular/src/generators/remote/schema';
11
- import { Tree } from '@nx/devkit';
12
- import {
13
- GetDefaultGeneratorOptions,
14
- HasProject,
15
- } from '@rxap/workspace-utilities';
16
- import { InitApplicationGeneratorSchema } from './schema';
17
-
18
- export async function CoerceProjects(tree: Tree, options: InitApplicationGeneratorSchema) {
19
-
20
- if (!options.coerce) {
21
- return;
22
- }
23
-
24
- for (const projectName of options.projects ?? []) {
25
-
26
- if (!HasProject(tree, projectName)) {
27
-
28
- await CoerceProject(tree, projectName, options);
29
-
30
- }
31
-
32
- }
33
-
34
- }
35
-
36
- export async function CoerceProject(tree: Tree, projectName: string, options: InitApplicationGeneratorSchema) {
37
-
38
- if (HasProject(tree, projectName)) {
39
- console.log(`Project ${ projectName } already exists`);
40
- return;
41
- }
42
-
43
- let directory = 'user-interface';
44
- if (projectName.includes('-feature-')) {
45
- directory += '/feature';
46
- }
47
- directory += `/${ projectName.replace('user-interface-', '').replace('feature-', '') }`;
48
-
49
- const formOptions: any = options.coerce && typeof options.coerce === 'object' ? options.coerce : {};
50
-
51
- if (formOptions.directory && (options.projects?.length ?? 0) > 1) {
52
- throw new Error('The directory option is not allowed when multiple projects are initialized!');
53
- }
54
-
55
- if (options.moduleFederation) {
56
-
57
- if (options.moduleFederation === 'host') {
58
- const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularHostGeneratorSchema>>(tree, '@nx/angular:host');
59
- const schema: AngularHostGeneratorSchema = {
60
- style: 'scss',
61
- inlineStyle: false,
62
- inlineTemplate: false,
63
- skipTests: false,
64
- skipFormat: false,
65
- skipPackageJson: false,
66
- unitTestRunner: UnitTestRunner.Jest,
67
- e2eTestRunner: E2eTestRunner.None,
68
- linter: 'eslint',
69
- strict: true,
70
- standaloneConfig: true,
71
- ...defaultOptions,
72
- directory,
73
- ...formOptions,
74
- name: projectName,
75
- dynamic: true,
76
- projectNameAndRootFormat: 'as-provided',
77
- };
78
- await angularHostGenerator(tree, schema);
79
- } else {
80
- const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularRemoteGeneratorSchema>>(tree, '@nx/angular:remote');
81
- const schema: AngularRemoteGeneratorSchema = {
82
- style: 'scss',
83
- inlineStyle: false,
84
- inlineTemplate: false,
85
- skipTests: false,
86
- skipFormat: false,
87
- skipPackageJson: false,
88
- unitTestRunner: UnitTestRunner.Jest,
89
- e2eTestRunner: E2eTestRunner.None,
90
- linter: 'eslint',
91
- strict: true,
92
- standaloneConfig: true,
93
- ...defaultOptions,
94
- directory,
95
- ...formOptions,
96
- host: options.host,
97
- name: projectName,
98
- projectNameAndRootFormat: 'as-provided',
99
- };
100
- await angularRemoteGenerator(tree, schema);
101
- }
102
-
103
- } else {
104
- const defaultOptions = GetDefaultGeneratorOptions<Partial<AngularApplicationGeneratorSchema>>(tree, '@nx/angular:application');
105
- const schema: AngularApplicationGeneratorSchema = {
106
- style: 'scss',
107
- routing: true,
108
- inlineStyle: false,
109
- inlineTemplate: false,
110
- skipTests: false,
111
- skipFormat: false,
112
- skipPackageJson: false,
113
- unitTestRunner: UnitTestRunner.Jest,
114
- e2eTestRunner: E2eTestRunner.None,
115
- linter: 'eslint',
116
- strict: true,
117
- standaloneConfig: true,
118
- minimal: true,
119
- ...defaultOptions,
120
- directory,
121
- ...formOptions,
122
- name: projectName,
123
- projectNameAndRootFormat: 'as-provided',
124
- };
125
- await angularApplicationGenerator(tree, schema);
126
- }
127
-
128
- }
@@ -1,122 +0,0 @@
1
- import {
2
- ProjectConfiguration,
3
- Tree,
4
- } from '@nx/devkit';
5
- import {
6
- CoerceAppRoutes,
7
- CoerceImports,
8
- CoerceRouteGuard,
9
- } from '@rxap/ts-morph';
10
- import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
11
- import {
12
- AddPackageJsonDependency,
13
- CoerceTarget,
14
- GetProject,
15
- GetWorkspaceProject,
16
- GetWorkspaceProjectName,
17
- UpdateJsonFile,
18
- } from '@rxap/workspace-utilities';
19
- import { parseDocument } from 'yaml';
20
- import { InitApplicationGeneratorSchema } from './schema';
21
-
22
- async function defaultAuthentication(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
23
-
24
- console.log('default authentication');
25
-
26
- await AddPackageJsonDependency(tree, '@rxap/ngx-material-authentication', 'latest', { soft: true });
27
-
28
- TsMorphAngularProjectTransform(tree, {
29
- project: projectName,
30
- }, (_, [ appSourceFile ]) => {
31
- CoerceAppRoutes(appSourceFile, {
32
- itemList: [
33
- {
34
- route: {
35
- path: 'authentication',
36
- loadChildren: {
37
- import: '@rxap/ngx-material-authentication',
38
- then: 'AUTHENTICATION_ROUTE'
39
- }
40
- }
41
- }
42
- ]
43
- });
44
- CoerceRouteGuard(appSourceFile, [''], 'RxapAuthenticationGuard', { routeArrayName: 'appRoutes' });
45
- CoerceImports(appSourceFile, {
46
- namedImports: ['RxapAuthenticationGuard'],
47
- moduleSpecifier: '@rxap/authentication',
48
- });
49
- }, [ 'app/app.routes.ts?' ]);
50
- }
51
-
52
- async function oauth2ProxyAuthentication(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
53
-
54
- console.log('oauth2-proxy authentication');
55
-
56
- await AddPackageJsonDependency(tree, '@rxap/ngx-oauth2-proxy', 'latest', { soft: true });
57
-
58
- TsMorphAngularProjectTransform(tree, {
59
- project: projectName,
60
- }, (_, [ appSourceFile ]) => {
61
- CoerceRouteGuard(appSourceFile, [''], 'oauth2ProxyGuard', { routeArrayName: 'appRoutes' });
62
- CoerceImports(appSourceFile, {
63
- namedImports: ['oauth2ProxyGuard'],
64
- moduleSpecifier: '@rxap/ngx-oauth2-proxy',
65
- });
66
- }, [ 'app/app.routes.ts?' ]);
67
-
68
- if (tree.exists('docker-compose.yml')) {
69
- const dockerComposeContent = tree.read('docker-compose.yml', 'utf-8')!;
70
- const dockerCompose = parseDocument(dockerComposeContent);
71
- if (dockerCompose.hasIn(['services', 'rxap-service-user'])) {
72
- if (!dockerCompose.hasIn(['services', 'rxap-service-user', 'labels'])) {
73
- dockerCompose.setIn(['services', 'rxap-service-user', 'labels'], [
74
- 'traefik.http.routers.user.middlewares=oauth-signin@docker,oauth-verify@docker'
75
- ]);
76
- }
77
- }
78
- }
79
-
80
- if (tree.exists('shared/angular/proxy.conf.json')) {
81
- UpdateJsonFile(tree, proxyConf => {
82
- proxyConf['/oauth2'] ??= {
83
- "target": "https://127-0-0-1.nip.io:8443",
84
- "secure": false
85
- };
86
- }, 'shared/angular/proxy.conf.json');
87
- }
88
-
89
- const workspaceProject = GetWorkspaceProject(tree);
90
- if (workspaceProject.targets && 'docker-compose' in workspaceProject.targets) {
91
- CoerceTarget(workspaceProject, 'docker-compose', {
92
- options: {
93
- options: {
94
- middlewares: [
95
- 'oauth-signin@docker',
96
- 'oauth-verify@docker',
97
- ],
98
- },
99
- },
100
- });
101
- }
102
-
103
- }
104
-
105
- export async function generateAuthentication(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
106
-
107
- console.log('generate authentication');
108
-
109
- switch (options.authentication) {
110
-
111
- default:
112
- case true:
113
- return defaultAuthentication(tree, projectName, project, options);
114
-
115
- case 'oauth2-proxy':
116
- return oauth2ProxyAuthentication(tree, projectName, project, options);
117
-
118
- }
119
-
120
-
121
-
122
- }
@@ -1,45 +0,0 @@
1
- import {
2
- addProjectConfiguration,
3
- readProjectConfiguration,
4
- Tree,
5
- } from '@nx/devkit';
6
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
7
- import { generateMonolithic } from './generate-monolithic';
8
-
9
- describe('generateMonolithic()', () => {
10
-
11
- let tree: Tree;
12
- const projectName = 'app';
13
-
14
- beforeEach(() => {
15
- tree = createTreeWithEmptyWorkspace();
16
- addProjectConfiguration(tree, projectName, {
17
- root: 'app',
18
- sourceRoot: 'app/src',
19
- projectType: 'application',
20
- });
21
- });
22
-
23
- it('should generate a monolithic application configuration', () => {
24
-
25
- generateMonolithic(tree, projectName, readProjectConfiguration(tree, projectName), {});
26
- expect(tree.children('app/src/app')).toMatchSnapshot();
27
- expect(tree.read('app/src/app/app.routes.ts', 'utf-8')).toMatchSnapshot();
28
- expect(tree.read('app/src/app/layout.routes.ts', 'utf-8')).toMatchSnapshot();
29
- expect(tree.read('app/src/app/app.navigation.ts', 'utf-8')).toMatchSnapshot();
30
-
31
- });
32
-
33
- it('should use MinimalLayoutComponent and no navigation when moduleFederation is host', () => {
34
-
35
- generateMonolithic(tree, projectName, readProjectConfiguration(tree, projectName), {
36
- moduleFederation: 'host',
37
- });
38
- expect(tree.children('app/src/app')).toMatchSnapshot();
39
- expect(tree.read('app/src/app/app.routes.ts', 'utf-8')).toMatchSnapshot();
40
- expect(tree.read('app/src/app/layout.routes.ts', 'utf-8')).toMatchSnapshot();
41
- expect(tree.exists('app/src/app/app.navigation.ts')).toBeFalsy();
42
-
43
- });
44
-
45
- });
@@ -1,57 +0,0 @@
1
- import {
2
- ProjectConfiguration,
3
- Tree,
4
- } from '@nx/devkit';
5
- import {
6
- CoerceAppNavigation,
7
- CoerceAppRoutes,
8
- CoerceLayoutRoutes,
9
- } from '@rxap/ts-morph';
10
- import { TsMorphAngularProjectTransform } from '@rxap/workspace-ts-morph';
11
- import { CoerceFile } from '@rxap/workspace-utilities';
12
- import { join } from 'path';
13
- import { InitApplicationGeneratorSchema } from './schema';
14
-
15
- export function generateMonolithic(tree: Tree, projectName: string, project: ProjectConfiguration, options: InitApplicationGeneratorSchema) {
16
-
17
- if (!project.sourceRoot) {
18
- throw new Error(`Project source root not found for project ${ projectName }`);
19
- }
20
-
21
- if (!tree.exists(join(project.sourceRoot, 'assets', 'logo.png'))) {
22
- if (tree.exists('logo.png')) {
23
- CoerceFile(tree, join(project.sourceRoot, 'assets', 'logo.png'), tree.read('logo.png')!, true);
24
- }
25
- }
26
-
27
- TsMorphAngularProjectTransform(tree, {
28
- project: projectName,
29
- }, (_, [ appSourceFile, layoutSourceFile ]) => {
30
- CoerceLayoutRoutes(layoutSourceFile, {
31
- component: options.moduleFederation === 'host' ? 'MinimalLayoutComponent' : 'LayoutComponent',
32
- withNavigation: options.moduleFederation !== 'host',
33
- withStatusCheckGuard: options.apiStatusCheck,
34
- });
35
- CoerceAppRoutes(appSourceFile, {
36
- itemList: [
37
- {
38
- route: {
39
- path: options.layoutRoutePath ?? '',
40
- loadChildren: './layout.routes'
41
- }
42
- }
43
- ]
44
- });
45
- }, [ 'app/app.routes.ts?', 'app/layout.routes.ts?' ]);
46
-
47
- if (options.moduleFederation !== 'host') {
48
-
49
- TsMorphAngularProjectTransform(tree, {
50
- project: projectName,
51
- }, (_, [ navigationSourceFile ]) => {
52
- CoerceAppNavigation(navigationSourceFile, { overwrite: options.overwrite });
53
- }, [ 'app/app.navigation.ts?' ]);
54
-
55
- }
56
-
57
- }