@rxap/plugin-angular 16.2.0-dev.1 → 16.2.0-dev.12
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.
- package/CHANGELOG.md +101 -0
- package/README.md +1 -1
- package/package.json +27 -28
- package/src/generators/fix-schematic/generator.js +3 -4
- package/src/generators/fix-schematic/generator.js.map +1 -1
- package/src/generators/init/generator.js +34 -32
- package/src/generators/init/generator.js.map +1 -1
- package/src/generators/init-application/coerce-project.d.ts +4 -0
- package/src/generators/init-application/coerce-project.js +54 -0
- package/src/generators/init-application/coerce-project.js.map +1 -0
- package/src/generators/init-application/files/mfe-remote/Dockerfile +29 -0
- package/src/generators/init-application/files/mfe-remote/index.html.template +165 -0
- package/src/generators/init-application/files/root/favicon.ico +0 -0
- package/src/generators/init-application/files/root/styles.scss.template +3 -0
- package/src/generators/init-application/files/shared/Dockerfile +1 -1
- package/src/generators/init-application/files/shared/ngsw-config.json +11 -1
- package/src/generators/init-application/files/styles/_fonts.scss +2 -0
- package/src/generators/init-application/generate-authentication.js +5 -0
- package/src/generators/init-application/generate-authentication.js.map +1 -1
- package/src/generators/init-application/generate-monolithic.js +1 -7
- package/src/generators/init-application/generate-monolithic.js.map +1 -1
- package/src/generators/init-application/generator.js +323 -93
- package/src/generators/init-application/generator.js.map +1 -1
- package/src/generators/init-application/schema.d.ts +7 -0
- package/src/generators/init-application/schema.json +26 -0
- package/src/generators/init-feature/generator.js +18 -4
- package/src/generators/init-feature/generator.js.map +1 -1
- package/src/generators/init-feature/schema.d.ts +7 -0
- package/src/generators/init-feature/schema.json +54 -0
- package/src/generators/init-library/generator.js +102 -31
- package/src/generators/init-library/generator.js.map +1 -1
- package/src/generators/init-library/schema.d.ts +6 -1
- package/src/generators/init-library/schema.json +170 -5
- package/src/generators/schematic/generator.js +1 -2
- package/src/generators/schematic/generator.js.map +1 -1
- package/src/lib/skip-project.d.ts +0 -3
- package/src/lib/skip-project.js +0 -19
- package/src/lib/skip-project.js.map +0 -1
- /package/src/generators/init-application/files/{monolithic → mfe-remote}/styles.scss.template +0 -0
- /package/src/generators/init-application/files/{monolithic → root}/index.html.template +0 -0
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initApplicationGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const generator_utilities_1 = require("@rxap/generator-utilities");
|
|
7
6
|
const plugin_application_1 = require("@rxap/plugin-application");
|
|
8
7
|
const plugin_docker_1 = require("@rxap/plugin-docker");
|
|
9
8
|
const plugin_localazy_1 = require("@rxap/plugin-localazy");
|
|
@@ -13,14 +12,14 @@ const workspace_ts_morph_1 = require("@rxap/workspace-ts-morph");
|
|
|
13
12
|
const workspace_utilities_1 = require("@rxap/workspace-utilities");
|
|
14
13
|
const path_1 = require("path");
|
|
15
14
|
const ts_morph_2 = require("ts-morph");
|
|
16
|
-
const
|
|
15
|
+
const coerce_project_1 = require("./coerce-project");
|
|
17
16
|
const generate_authentication_1 = require("./generate-authentication");
|
|
18
17
|
const generate_monolithic_1 = require("./generate-monolithic");
|
|
19
18
|
function skipProject(tree, options, project, projectName) {
|
|
20
|
-
if ((0,
|
|
19
|
+
if ((0, workspace_utilities_1.SkipNonAngularProject)(tree, options, project, projectName)) {
|
|
21
20
|
return true;
|
|
22
21
|
}
|
|
23
|
-
if ((0,
|
|
22
|
+
if ((0, workspace_utilities_1.SkipNonApplicationProject)(tree, options, project, projectName)) {
|
|
24
23
|
return true;
|
|
25
24
|
}
|
|
26
25
|
return false;
|
|
@@ -34,7 +33,7 @@ function updateProjectTargets(project, options) {
|
|
|
34
33
|
}
|
|
35
34
|
if (project.targets['docker']) {
|
|
36
35
|
(_b = (_z = project.targets['docker']).options) !== null && _b !== void 0 ? _b : (_z.options = {});
|
|
37
|
-
(_c = (_0 = project.targets['docker'].options).dockerfile) !== null && _c !== void 0 ? _c : (_0.dockerfile = 'shared/angular/Dockerfile');
|
|
36
|
+
(_c = (_0 = project.targets['docker'].options).dockerfile) !== null && _c !== void 0 ? _c : (_0.dockerfile = options.moduleFederation === 'remote' ? (0, path_1.join)(project.sourceRoot, 'Dockerfile') : 'shared/angular/Dockerfile');
|
|
38
37
|
}
|
|
39
38
|
(0, workspace_utilities_1.CoerceTarget)(project, 'serve', {
|
|
40
39
|
options: {
|
|
@@ -108,10 +107,12 @@ function updateProjectTargets(project, options) {
|
|
|
108
107
|
project.targets['build'].options.sourceMap = true;
|
|
109
108
|
(_q = (_10 = project.targets['build'].options).assets) !== null && _q !== void 0 ? _q : (_10.assets = []);
|
|
110
109
|
(_r = (_11 = project.targets['build'].options).scripts) !== null && _r !== void 0 ? _r : (_11.scripts = []);
|
|
111
|
-
if (
|
|
112
|
-
project.targets['build'].options.scripts.
|
|
110
|
+
if (options.moduleFederation !== 'remote') {
|
|
111
|
+
if (!project.targets['build'].options.scripts.includes('node_modules/marked/marked.min.js')) {
|
|
112
|
+
project.targets['build'].options.scripts.push('node_modules/marked/marked.min.js');
|
|
113
|
+
}
|
|
113
114
|
}
|
|
114
|
-
(0,
|
|
115
|
+
(0, workspace_utilities_1.CoerceAssets)(project.targets['build'].options.assets, [
|
|
115
116
|
{
|
|
116
117
|
glob: '*',
|
|
117
118
|
input: 'shared/angular/assets/',
|
|
@@ -130,12 +131,12 @@ function updateProjectTargets(project, options) {
|
|
|
130
131
|
project.targets['build'].options.polyfills = ['zone.js'];
|
|
131
132
|
}
|
|
132
133
|
// always add the localize init polyfill as some rxap components use the i18n directive
|
|
133
|
-
(0,
|
|
134
|
+
(0, workspace_utilities_1.CoerceAssets)(project.targets['build'].options.polyfills, ['@angular/localize/init']);
|
|
134
135
|
if (options.serviceWorker) {
|
|
135
136
|
if (!project.sourceRoot) {
|
|
136
137
|
throw new Error(`The project ${project.name} has no source root`);
|
|
137
138
|
}
|
|
138
|
-
(0,
|
|
139
|
+
(0, workspace_utilities_1.CoerceAssets)(project.targets['build'].options.assets, [
|
|
139
140
|
(0, path_1.join)(project.sourceRoot, 'manifest.webmanifest'),
|
|
140
141
|
]);
|
|
141
142
|
(_t = (_13 = project.targets['build']).configurations) !== null && _t !== void 0 ? _t : (_13.configurations = {});
|
|
@@ -238,7 +239,7 @@ function updateGitIgnore(project, tree, options) {
|
|
|
238
239
|
throw new Error(`The project ${project.name} has no source root`);
|
|
239
240
|
}
|
|
240
241
|
const gitIgnorePath = (0, path_1.join)(project.sourceRoot, '.gitignore');
|
|
241
|
-
(0,
|
|
242
|
+
(0, workspace_utilities_1.CoerceIgnorePattern)(tree, gitIgnorePath, [
|
|
242
243
|
'/i18n',
|
|
243
244
|
]);
|
|
244
245
|
}
|
|
@@ -257,7 +258,11 @@ function updateTags(project, options) {
|
|
|
257
258
|
if (options.sentry) {
|
|
258
259
|
tags.push('sentry');
|
|
259
260
|
}
|
|
260
|
-
(
|
|
261
|
+
if (options.moduleFederation) {
|
|
262
|
+
tags.push('module-federation');
|
|
263
|
+
tags.push(`mfe:${options.moduleFederation}`);
|
|
264
|
+
}
|
|
265
|
+
(0, workspace_utilities_1.CoerceProjectTags)(project, tags);
|
|
261
266
|
}
|
|
262
267
|
const MAIN_BOOTSTRAP_STATEMENT = `application.bootstrap().catch((err) => console.error(err));`;
|
|
263
268
|
const MAIN_LOGGER_STATEMENT = `application.importProvidersFrom(LoggerModule.forRoot({
|
|
@@ -270,7 +275,12 @@ const MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplicati
|
|
|
270
275
|
AppComponent,
|
|
271
276
|
appConfig,
|
|
272
277
|
);`;
|
|
273
|
-
|
|
278
|
+
const REMOTE_MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplication(
|
|
279
|
+
environment,
|
|
280
|
+
RemoteEntryComponent,
|
|
281
|
+
appConfig,
|
|
282
|
+
);`;
|
|
283
|
+
function assertMainStatements(sourceFile, options) {
|
|
274
284
|
var _a;
|
|
275
285
|
const statements = [];
|
|
276
286
|
statements.push('const application = new StandaloneApplication(');
|
|
@@ -281,16 +291,12 @@ function assertMainStatements(sourceFile) {
|
|
|
281
291
|
console.error(`Missing statement from angular main.ts: ${statement}`);
|
|
282
292
|
sourceFile.set({
|
|
283
293
|
statements: [
|
|
284
|
-
MAIN_APP_CREATION_STATEMENT,
|
|
294
|
+
options.moduleFederation === 'remote' ? REMOTE_MAIN_APP_CREATION_STATEMENT : MAIN_APP_CREATION_STATEMENT,
|
|
285
295
|
MAIN_LOGGER_STATEMENT,
|
|
286
296
|
MAIN_BOOTSTRAP_STATEMENT,
|
|
287
297
|
],
|
|
288
298
|
});
|
|
289
299
|
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
290
|
-
{
|
|
291
|
-
moduleSpecifier: './app/app.component',
|
|
292
|
-
namedImports: ['AppComponent'],
|
|
293
|
-
},
|
|
294
300
|
{
|
|
295
301
|
moduleSpecifier: './app/app.config',
|
|
296
302
|
namedImports: ['appConfig'],
|
|
@@ -308,37 +314,119 @@ function assertMainStatements(sourceFile) {
|
|
|
308
314
|
namedImports: ['StandaloneApplication'],
|
|
309
315
|
},
|
|
310
316
|
]);
|
|
317
|
+
if (options.moduleFederation === 'remote') {
|
|
318
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
319
|
+
{
|
|
320
|
+
moduleSpecifier: './app/remote-entry/entry.component',
|
|
321
|
+
namedImports: ['RemoteEntryComponent'],
|
|
322
|
+
},
|
|
323
|
+
]);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
327
|
+
{
|
|
328
|
+
moduleSpecifier: './app/app.component',
|
|
329
|
+
namedImports: ['AppComponent'],
|
|
330
|
+
},
|
|
331
|
+
]);
|
|
332
|
+
}
|
|
311
333
|
return;
|
|
312
334
|
}
|
|
313
335
|
}
|
|
314
336
|
}
|
|
315
|
-
function cleanup(tree,
|
|
337
|
+
function cleanup(tree, projectName, options) {
|
|
338
|
+
const sourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName);
|
|
316
339
|
const deleteFiles = [
|
|
317
340
|
'app/app.component.spec.ts',
|
|
318
341
|
'app/nx-welcome.component.ts',
|
|
342
|
+
'app/remote-entry/nx-welcome.component.ts',
|
|
319
343
|
'app/nx-welcome.component.cy.ts',
|
|
320
344
|
];
|
|
321
345
|
for (const file of deleteFiles) {
|
|
322
|
-
if (tree.exists((0, path_1.join)(
|
|
323
|
-
tree.delete((0, path_1.join)(
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
.
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
346
|
+
if (tree.exists((0, path_1.join)(sourceRoot, file))) {
|
|
347
|
+
tree.delete((0, path_1.join)(sourceRoot, file));
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (tree.exists((0, path_1.join)(sourceRoot, 'app/app.component.html'))) {
|
|
351
|
+
const content = tree.read((0, path_1.join)(sourceRoot, 'app/app.component.html'), 'utf-8')
|
|
352
|
+
.replace(/<.+-nx-welcome><\/.+-nx-welcome> /, '')
|
|
353
|
+
.replace(/<ul class="remote-menu">[\s\S]*<\/ul>/, '');
|
|
354
|
+
tree.write((0, path_1.join)(sourceRoot, 'app/app.component.html'), content);
|
|
355
|
+
}
|
|
356
|
+
if (options.moduleFederation !== 'remote') {
|
|
357
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
358
|
+
project: projectName,
|
|
359
|
+
}, (_, [appRoutes, appComponent]) => {
|
|
360
|
+
var _a, _b, _c;
|
|
361
|
+
(0, ts_morph_1.RemoveRoute)(appRoutes, {
|
|
362
|
+
component: 'NxWelcomeComponent',
|
|
363
|
+
name: 'appRoutes'
|
|
364
|
+
});
|
|
365
|
+
(_a = appRoutes.getImportDeclaration('./nx-welcome.component')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
366
|
+
(_c = (_b = appComponent.getClass('AppComponent')) === null || _b === void 0 ? void 0 : _b.getProperty('title')) === null || _c === void 0 ? void 0 : _c.remove();
|
|
367
|
+
(0, ts_morph_1.RemoveComponentImport)(appComponent, 'NxWelcomeComponent');
|
|
368
|
+
}, ['app/app.routes.ts', 'app/app.component.ts']);
|
|
369
|
+
}
|
|
370
|
+
if (options.moduleFederation === 'remote') {
|
|
371
|
+
// region module-federation config
|
|
372
|
+
const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
|
|
373
|
+
let content = tree.read((0, path_1.join)(projectRoot, 'module-federation.config.js'), 'utf-8');
|
|
374
|
+
content = content.replace('./Routes', './routes');
|
|
375
|
+
tree.write((0, path_1.join)(projectRoot, 'module-federation.config.js'), content);
|
|
376
|
+
// endregion
|
|
377
|
+
// region tsconfig.base.json
|
|
378
|
+
(0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
|
|
379
|
+
var _a, _b;
|
|
380
|
+
var _c;
|
|
381
|
+
(_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
|
|
382
|
+
(_b = (_c = tsConfig.compilerOptions).paths) !== null && _b !== void 0 ? _b : (_c.paths = {});
|
|
383
|
+
if (tsConfig.compilerOptions.paths[`${projectName}/Routes`]) {
|
|
384
|
+
delete tsConfig.compilerOptions.paths[`${projectName}/Routes`];
|
|
385
|
+
}
|
|
386
|
+
}, { infix: 'base' });
|
|
387
|
+
// endregion
|
|
388
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
389
|
+
project: projectName,
|
|
390
|
+
}, (_, [entryComponent, entryRoutes]) => {
|
|
391
|
+
var _a, _b;
|
|
392
|
+
(_a = entryComponent.getImportDeclaration('./nx-welcome.component')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
393
|
+
(0, ts_morph_1.RemoveComponentImport)(entryComponent, 'NxWelcomeComponent');
|
|
394
|
+
(0, ts_morph_1.RemoveComponentImport)(entryComponent, 'CommonModule');
|
|
395
|
+
const componentOptions = (0, ts_morph_1.GetComponentDecoratorObject)(entryComponent);
|
|
396
|
+
const templateProp = componentOptions.getProperty('template');
|
|
397
|
+
if (templateProp && ((_b = templateProp.asKindOrThrow(ts_morph_2.SyntaxKind.PropertyAssignment).getInitializer()) === null || _b === void 0 ? void 0 : _b.getText().match(/<.+nx-welcome><\/.+nx-welcome>/))) {
|
|
398
|
+
templateProp.remove();
|
|
399
|
+
componentOptions.addPropertyAssignment({
|
|
400
|
+
name: 'template',
|
|
401
|
+
initializer: w => w.quote('<router-outlet></router-outlet>'),
|
|
402
|
+
});
|
|
403
|
+
(0, ts_morph_1.CoerceComponentImport)(entryComponent, { name: 'RouterModule', moduleSpecifier: '@angular/router' });
|
|
404
|
+
}
|
|
405
|
+
(0, ts_morph_1.CoerceDefaultExport)(entryRoutes.getVariableStatement('remoteRoutes').getDeclarations()[0]);
|
|
406
|
+
}, [
|
|
407
|
+
'app/remote-entry/entry.component.ts',
|
|
408
|
+
'app/remote-entry/entry.routes.ts',
|
|
409
|
+
]);
|
|
410
|
+
if (options.host) {
|
|
411
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
412
|
+
project: options.host,
|
|
413
|
+
}, (_, [appRoutes]) => {
|
|
414
|
+
(0, ts_morph_1.RemoveRoute)(appRoutes, {
|
|
415
|
+
loadRemoteModule: projectName,
|
|
416
|
+
name: 'appRoutes'
|
|
417
|
+
});
|
|
418
|
+
appRoutes.organizeImports();
|
|
419
|
+
}, ['app/app.routes.ts']);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
334
422
|
}
|
|
335
423
|
function updateMainFile(tree, projectName, project, options) {
|
|
336
424
|
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
337
425
|
project: projectName,
|
|
338
426
|
// directory: '..' // to move from the apps/demo/src/app folder into the apps/demo/src folder
|
|
339
|
-
}, (project, [sourceFile]) => {
|
|
427
|
+
}, (project, [sourceFile, mainSourceFile]) => {
|
|
340
428
|
var _a;
|
|
341
|
-
assertMainStatements(sourceFile);
|
|
429
|
+
assertMainStatements(sourceFile, options);
|
|
342
430
|
const importDeclarations = [];
|
|
343
431
|
const statements = [];
|
|
344
432
|
if (options.serviceWorker) {
|
|
@@ -388,10 +476,51 @@ function updateMainFile(tree, projectName, project, options) {
|
|
|
388
476
|
sourceFile.insertStatements(index, statement);
|
|
389
477
|
}
|
|
390
478
|
}
|
|
391
|
-
|
|
479
|
+
if (options.moduleFederation === 'host') {
|
|
480
|
+
mainSourceFile.set({
|
|
481
|
+
statements: [
|
|
482
|
+
`import {
|
|
483
|
+
setRemoteDefinitions,
|
|
484
|
+
setRemoteUrlResolver
|
|
485
|
+
} from '@nx/angular/mf';
|
|
486
|
+
import type { Environment } from '@rxap/environment';
|
|
487
|
+
import { environment } from './environments/environment';
|
|
488
|
+
|
|
489
|
+
export async function SetupDynamicMfe(environment: Environment) {
|
|
490
|
+
|
|
491
|
+
const manifest = environment.moduleFederation?.manifest;
|
|
492
|
+
|
|
493
|
+
if (!manifest) {
|
|
494
|
+
const release = environment.tag || environment.branch || 'latest';
|
|
495
|
+
setRemoteUrlResolver((remoteName: string) => \`\${ location.origin }/__mfe/\${ release }/\${ remoteName }\`);
|
|
496
|
+
} else {
|
|
497
|
+
|
|
498
|
+
let definitions: Record<string, string>;
|
|
499
|
+
|
|
500
|
+
if (typeof manifest === 'object') {
|
|
501
|
+
definitions = manifest;
|
|
502
|
+
} else {
|
|
503
|
+
definitions = await fetch(manifest).then((res) => res.json());
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
setRemoteDefinitions(definitions);
|
|
507
|
+
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
SetupDynamicMfe(environment).then(() => import('./bootstrap').catch((err) => console.error(err)));
|
|
513
|
+
`,
|
|
514
|
+
]
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}, [
|
|
518
|
+
options.moduleFederation ? 'bootstrap.ts' : 'main.ts',
|
|
519
|
+
'main.ts'
|
|
520
|
+
]);
|
|
392
521
|
}
|
|
393
522
|
function coerceEnvironmentFiles(tree, options) {
|
|
394
|
-
(0, workspace_ts_morph_1.
|
|
523
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
395
524
|
project: options.project,
|
|
396
525
|
}, (project, [sourceFile, prodSourceFile]) => {
|
|
397
526
|
(0, ts_morph_1.CoerceImports)(sourceFile, {
|
|
@@ -406,14 +535,22 @@ function coerceEnvironmentFiles(tree, options) {
|
|
|
406
535
|
name: w => w.quote('development'),
|
|
407
536
|
production: 'false',
|
|
408
537
|
app: w => w.quote(options.project),
|
|
409
|
-
serviceWorker: 'false',
|
|
410
538
|
};
|
|
539
|
+
// region dev environment
|
|
540
|
+
if (options.serviceWorker) {
|
|
541
|
+
baseEnvironment['serviceWorker'] = 'false';
|
|
542
|
+
}
|
|
411
543
|
if (options.sentry) {
|
|
412
544
|
baseEnvironment['sentry'] = ts_morph_2.Writers.object({
|
|
413
545
|
enabled: 'false',
|
|
414
546
|
debug: 'false',
|
|
415
547
|
});
|
|
416
548
|
}
|
|
549
|
+
if (options.moduleFederation === 'host') {
|
|
550
|
+
baseEnvironment['moduleFederation'] = ts_morph_2.Writers.object({
|
|
551
|
+
manifest: w => w.quote('/assets/module-federation.manifest.json'),
|
|
552
|
+
});
|
|
553
|
+
}
|
|
417
554
|
const normal = (0, ts_morph_1.CoerceVariableDeclaration)(sourceFile, 'environment', {
|
|
418
555
|
type: 'Environment',
|
|
419
556
|
initializer: ts_morph_2.Writers.object(baseEnvironment),
|
|
@@ -421,15 +558,22 @@ function coerceEnvironmentFiles(tree, options) {
|
|
|
421
558
|
if (options.overwrite) {
|
|
422
559
|
normal.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
|
|
423
560
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
561
|
+
// region
|
|
562
|
+
// region prod environment
|
|
563
|
+
if (options.moduleFederation === 'host') {
|
|
564
|
+
delete baseEnvironment['moduleFederation'];
|
|
565
|
+
}
|
|
566
|
+
if (options.serviceWorker) {
|
|
567
|
+
baseEnvironment['serviceWorker'] = 'true';
|
|
568
|
+
}
|
|
427
569
|
if (options.sentry) {
|
|
428
570
|
baseEnvironment['sentry'] = ts_morph_2.Writers.object({
|
|
429
571
|
enabled: 'true',
|
|
430
572
|
debug: 'false',
|
|
431
573
|
});
|
|
432
574
|
}
|
|
575
|
+
baseEnvironment['name'] = w => w.quote('production');
|
|
576
|
+
baseEnvironment['production'] = 'true';
|
|
433
577
|
const prod = (0, ts_morph_1.CoerceVariableDeclaration)(prodSourceFile, 'environment', {
|
|
434
578
|
type: 'Environment',
|
|
435
579
|
initializer: ts_morph_2.Writers.object(baseEnvironment),
|
|
@@ -437,6 +581,7 @@ function coerceEnvironmentFiles(tree, options) {
|
|
|
437
581
|
if (options.overwrite) {
|
|
438
582
|
prod.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
|
|
439
583
|
}
|
|
584
|
+
// endregion
|
|
440
585
|
}, [
|
|
441
586
|
'/environments/environment.ts?',
|
|
442
587
|
'/environments/environment.prod.ts?',
|
|
@@ -462,48 +607,99 @@ function coerceLocalazyConfigFile(tree, project) {
|
|
|
462
607
|
}, null, 2));
|
|
463
608
|
}
|
|
464
609
|
}
|
|
465
|
-
function updateTsConfig(tree,
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
if (!tsConfig.compilerOptions.types.includes('@angular/localize')) {
|
|
476
|
-
tsConfig.compilerOptions.types.push('@angular/localize');
|
|
477
|
-
}
|
|
478
|
-
}, (0, path_1.join)(projectRoot, `tsconfig.${tsConfigName}.json`));
|
|
610
|
+
function updateTsConfig(tree, projectName) {
|
|
611
|
+
const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
|
|
612
|
+
for (const tsConfigName of ['app', 'editor', 'spec']) {
|
|
613
|
+
(0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
|
|
614
|
+
var _a, _b;
|
|
615
|
+
var _c;
|
|
616
|
+
(_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
|
|
617
|
+
(_b = (_c = tsConfig.compilerOptions).types) !== null && _b !== void 0 ? _b : (_c.types = []);
|
|
618
|
+
if (!tsConfig.compilerOptions.types.includes('@angular/localize')) {
|
|
619
|
+
tsConfig.compilerOptions.types.push('@angular/localize');
|
|
479
620
|
}
|
|
480
|
-
}
|
|
481
|
-
}
|
|
621
|
+
}, { infix: tsConfigName, basePath: projectRoot });
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function linkMfeRemoteWithHost(tree, projectName, options) {
|
|
625
|
+
if (!options.host) {
|
|
626
|
+
throw new Error('The host project must be defined');
|
|
627
|
+
}
|
|
628
|
+
const hostSourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, options.host);
|
|
629
|
+
const isHostMonolithic = tree.exists((0, path_1.join)(hostSourceRoot, 'app/layout.routes.ts'));
|
|
630
|
+
const path = projectName.replace('user-interface-', '').replace('feature-', '');
|
|
631
|
+
if (isHostMonolithic) {
|
|
632
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
633
|
+
project: options.host,
|
|
634
|
+
}, (project, [layoutSourceFile]) => {
|
|
635
|
+
(0, ts_morph_1.CoerceLayoutRoutes)(layoutSourceFile, {
|
|
636
|
+
itemList: [
|
|
637
|
+
{
|
|
638
|
+
route: {
|
|
639
|
+
path,
|
|
640
|
+
loadRemoteModule: projectName
|
|
641
|
+
},
|
|
642
|
+
path: ['']
|
|
643
|
+
}
|
|
644
|
+
]
|
|
645
|
+
});
|
|
646
|
+
}, ['app/layout.routes.ts']);
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
650
|
+
project: options.host,
|
|
651
|
+
}, (project, [appRoutes]) => {
|
|
652
|
+
(0, ts_morph_1.CoerceAppRoutes)(appRoutes, {
|
|
653
|
+
itemList: [
|
|
654
|
+
{
|
|
655
|
+
route: {
|
|
656
|
+
path,
|
|
657
|
+
loadRemoteModule: projectName
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
],
|
|
661
|
+
});
|
|
662
|
+
}, ['app/app.routes.ts']);
|
|
663
|
+
}
|
|
482
664
|
}
|
|
483
665
|
function initApplicationGenerator(tree, options) {
|
|
484
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
666
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
485
667
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
486
|
-
(_a = options.
|
|
487
|
-
(_b = options.
|
|
488
|
-
(_c = options.
|
|
489
|
-
(_d = options.
|
|
490
|
-
(_e = options.
|
|
491
|
-
(_f = options.
|
|
492
|
-
(_g = options.
|
|
493
|
-
(_h = options.
|
|
494
|
-
(_j = options.
|
|
495
|
-
(_k = options.
|
|
496
|
-
(_l = options.
|
|
668
|
+
(_a = options.moduleFederation) !== null && _a !== void 0 ? _a : (options.moduleFederation = undefined);
|
|
669
|
+
(_b = options.sentry) !== null && _b !== void 0 ? _b : (options.sentry = true);
|
|
670
|
+
(_c = options.openApi) !== null && _c !== void 0 ? _c : (options.openApi = false);
|
|
671
|
+
(_d = options.config) !== null && _d !== void 0 ? _d : (options.config = true);
|
|
672
|
+
(_e = options.localazy) !== null && _e !== void 0 ? _e : (options.localazy = false);
|
|
673
|
+
(_f = options.i18n) !== null && _f !== void 0 ? _f : (options.i18n = false);
|
|
674
|
+
(_g = options.serviceWorker) !== null && _g !== void 0 ? _g : (options.serviceWorker = false);
|
|
675
|
+
(_h = options.languages) !== null && _h !== void 0 ? _h : (options.languages = options.i18n ? ['en'] : []);
|
|
676
|
+
(_j = options.material) !== null && _j !== void 0 ? _j : (options.material = true);
|
|
677
|
+
(_k = options.generateMain) !== null && _k !== void 0 ? _k : (options.generateMain = false);
|
|
678
|
+
(_l = options.overwrite) !== null && _l !== void 0 ? _l : (options.overwrite = false);
|
|
679
|
+
(_m = options.monolithic) !== null && _m !== void 0 ? _m : (options.monolithic = false);
|
|
497
680
|
options.openApi = options.openApi || options.monolithic;
|
|
498
|
-
(
|
|
499
|
-
(
|
|
500
|
-
(
|
|
681
|
+
(_o = options.authentik) !== null && _o !== void 0 ? _o : (options.authentik = false);
|
|
682
|
+
(_p = options.oauth) !== null && _p !== void 0 ? _p : (options.oauth = false);
|
|
683
|
+
(_q = options.authentication) !== null && _q !== void 0 ? _q : (options.authentication = false);
|
|
501
684
|
options.oauth = options.oauth || options.authentik;
|
|
502
|
-
(
|
|
503
|
-
(
|
|
685
|
+
(_r = options.project) !== null && _r !== void 0 ? _r : (options.project = undefined);
|
|
686
|
+
(_s = options.projects) !== null && _s !== void 0 ? _s : (options.projects = []);
|
|
687
|
+
(_t = options.cleanup) !== null && _t !== void 0 ? _t : (options.cleanup = true);
|
|
688
|
+
(_u = options.host) !== null && _u !== void 0 ? _u : (options.host = undefined);
|
|
504
689
|
if (options.project) {
|
|
505
690
|
(0, utilities_1.CoerceArrayItems)(options.projects, [options.project]);
|
|
506
691
|
}
|
|
692
|
+
if (options.host) {
|
|
693
|
+
options.moduleFederation = 'remote';
|
|
694
|
+
}
|
|
695
|
+
if (options.moduleFederation === 'remote') {
|
|
696
|
+
options.authentication = false;
|
|
697
|
+
options.oauth = false;
|
|
698
|
+
options.authentik = false;
|
|
699
|
+
options.serviceWorker = false;
|
|
700
|
+
options.sentry = false;
|
|
701
|
+
options.monolithic = false;
|
|
702
|
+
}
|
|
507
703
|
console.log('angular application init generator:', options);
|
|
508
704
|
yield (0, plugin_application_1.ApplicationInitWorkspace)(tree, options);
|
|
509
705
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@mdi/angular-material', 'latest', { soft: true });
|
|
@@ -526,17 +722,24 @@ function initApplicationGenerator(tree, options) {
|
|
|
526
722
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/pipes', 'latest', { soft: true });
|
|
527
723
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/mixin', 'latest', { soft: true });
|
|
528
724
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/reflect-metadata', 'latest', { soft: true });
|
|
725
|
+
const angularVersion = '~16.2.0';
|
|
726
|
+
// must always be added as some rxap components use the i18n tag
|
|
727
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize', angularVersion, { soft: true });
|
|
728
|
+
// must always be added as some rxap components use interfaces from the package
|
|
729
|
+
// TODO : refactor the @rxap/ngx-error and @rxap/ngx-status-check to be independent from the @sentry/angular-ivy package
|
|
730
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/angular-ivy', 'latest', { soft: true });
|
|
529
731
|
if (options.oauth) {
|
|
530
732
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'angular-oauth2-oidc', 'latest', { soft: true });
|
|
531
733
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, 'angular-oauth2-oidc-jwks', 'latest', { soft: true });
|
|
532
734
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/oauth', 'latest', { soft: true });
|
|
533
735
|
}
|
|
534
736
|
if (options.material) {
|
|
535
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/material',
|
|
536
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/cdk',
|
|
737
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/material', angularVersion, { soft: true });
|
|
738
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/cdk', angularVersion, { soft: true });
|
|
537
739
|
}
|
|
538
740
|
if (options.serviceWorker) {
|
|
539
741
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/service-worker', 'latest', { soft: true });
|
|
742
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/service-worker', angularVersion, { soft: true });
|
|
540
743
|
}
|
|
541
744
|
if (options.monolithic) {
|
|
542
745
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/layout', 'latest', { soft: true });
|
|
@@ -561,12 +764,10 @@ function initApplicationGenerator(tree, options) {
|
|
|
561
764
|
}
|
|
562
765
|
if (options.sentry) {
|
|
563
766
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-sentry', 'latest', { soft: true });
|
|
564
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/angular-ivy', 'latest', { soft: true });
|
|
565
767
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/browser', 'latest', { soft: true });
|
|
566
768
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/integrations', 'latest', { soft: true });
|
|
567
769
|
}
|
|
568
770
|
if (options.i18n) {
|
|
569
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize', 'latest', { soft: true });
|
|
570
771
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-localize', 'latest', { soft: true });
|
|
571
772
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/ngx-user', 'latest', { soft: true });
|
|
572
773
|
}
|
|
@@ -589,6 +790,14 @@ function initApplicationGenerator(tree, options) {
|
|
|
589
790
|
target: 'shared/angular',
|
|
590
791
|
overwrite: options.overwrite,
|
|
591
792
|
});
|
|
793
|
+
if (!tree.exists('shared/angular/assets/custom.svg')) {
|
|
794
|
+
tree.write('shared/angular/assets/custom.svg', '<svg></svg>');
|
|
795
|
+
}
|
|
796
|
+
if (options.i18n) {
|
|
797
|
+
let dockerfileContent = tree.read('shared/angular/Dockerfile', 'utf-8');
|
|
798
|
+
dockerfileContent = dockerfileContent.replace('registry.gitlab.com/rxap/docker/nginx:', 'registry.gitlab.com/rxap/docker/i18n-nginx:');
|
|
799
|
+
tree.write('shared/angular/Dockerfile', dockerfileContent);
|
|
800
|
+
}
|
|
592
801
|
(0, workspace_utilities_1.CoerceFilesStructure)(tree, {
|
|
593
802
|
srcFolder: (0, path_1.join)(__dirname, 'files', 'styles'),
|
|
594
803
|
target: 'shared/angular/styles',
|
|
@@ -602,23 +811,28 @@ function initApplicationGenerator(tree, options) {
|
|
|
602
811
|
});
|
|
603
812
|
}
|
|
604
813
|
updateTargetDefaults(tree, options);
|
|
814
|
+
yield (0, coerce_project_1.CoerceProjects)(tree, options);
|
|
605
815
|
if (!options.skipProjects) {
|
|
606
816
|
for (const [projectName, project] of (0, devkit_1.getProjects)(tree).entries()) {
|
|
607
817
|
if (skipProject(tree, options, project, projectName)) {
|
|
608
818
|
continue;
|
|
609
819
|
}
|
|
820
|
+
(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']));
|
|
610
821
|
console.log(`init angular application project: ${projectName}`);
|
|
822
|
+
const sourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName);
|
|
611
823
|
(0, plugin_application_1.ApplicationInitProject)(tree, projectName, project, options);
|
|
824
|
+
if (options.overwrite) {
|
|
825
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'root'), sourceRoot, Object.assign(Object.assign({}, 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') }));
|
|
826
|
+
}
|
|
612
827
|
updateProjectTargets(project, options);
|
|
613
828
|
updateTags(project, options);
|
|
614
829
|
updateGitIgnore(project, tree, options);
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
(0, workspace_ts_morph_1.TsMorphNestProjectTransform)(tree, {
|
|
830
|
+
updateTsConfig(tree, projectName);
|
|
831
|
+
if (options.cleanup) {
|
|
832
|
+
cleanup(tree, projectName, options);
|
|
833
|
+
}
|
|
834
|
+
coerceEnvironmentFiles(tree, Object.assign(Object.assign({}, options), { project: projectName }));
|
|
835
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
622
836
|
project: projectName,
|
|
623
837
|
}, (_, [sourceFile]) => {
|
|
624
838
|
const providers = [
|
|
@@ -718,6 +932,15 @@ function initApplicationGenerator(tree, options) {
|
|
|
718
932
|
},
|
|
719
933
|
]);
|
|
720
934
|
}
|
|
935
|
+
if (options.material) {
|
|
936
|
+
providers.push('ProvideIconAssetPath()');
|
|
937
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
938
|
+
{
|
|
939
|
+
moduleSpecifier: '@rxap/icon',
|
|
940
|
+
namedImports: ['ProvideIconAssetPath'],
|
|
941
|
+
},
|
|
942
|
+
]);
|
|
943
|
+
}
|
|
721
944
|
(0, ts_morph_1.CoerceAppConfigProvider)(sourceFile, {
|
|
722
945
|
overwrite: options.overwrite,
|
|
723
946
|
providers,
|
|
@@ -728,12 +951,6 @@ function initApplicationGenerator(tree, options) {
|
|
|
728
951
|
if (options.generateMain) {
|
|
729
952
|
updateMainFile(tree, projectName, project, options);
|
|
730
953
|
}
|
|
731
|
-
if (!project.sourceRoot) {
|
|
732
|
-
throw new Error(`Project source root not found for project ${projectName}`);
|
|
733
|
-
}
|
|
734
|
-
if (options.cleanup) {
|
|
735
|
-
cleanup(tree, project.sourceRoot);
|
|
736
|
-
}
|
|
737
954
|
if (options.localazy) {
|
|
738
955
|
coerceLocalazyConfigFile(tree, project);
|
|
739
956
|
}
|
|
@@ -743,22 +960,35 @@ function initApplicationGenerator(tree, options) {
|
|
|
743
960
|
if (options.monolithic) {
|
|
744
961
|
(0, generate_monolithic_1.generateMonolithic)(tree, projectName, project, options);
|
|
745
962
|
}
|
|
963
|
+
if (options.moduleFederation === 'remote') {
|
|
964
|
+
if (options.overwrite) {
|
|
965
|
+
(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
|
|
966
|
+
.replace(/^user-interface-/, '')
|
|
967
|
+
.replace(/^feature-/, ''), classify: utilities_1.classify,
|
|
968
|
+
dasherize: utilities_1.dasherize, prefix: (0, workspace_utilities_1.GetProjectPrefix)(tree, projectName, 'rxap') }));
|
|
969
|
+
}
|
|
970
|
+
if (options.host) {
|
|
971
|
+
linkMfeRemoteWithHost(tree, projectName, options);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
746
974
|
if (options.serviceWorker) {
|
|
747
|
-
if (options.overwrite || !tree.exists((0, path_1.join)(
|
|
748
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'service-worker'),
|
|
975
|
+
if (options.overwrite || !tree.exists((0, path_1.join)(sourceRoot, 'manifest.webmanifest'))) {
|
|
976
|
+
(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,
|
|
749
977
|
dasherize: utilities_1.dasherize }));
|
|
750
978
|
}
|
|
751
979
|
}
|
|
752
980
|
(0, workspace_utilities_1.CoerceFilesStructure)(tree, {
|
|
753
981
|
srcFolder: (0, path_1.join)(__dirname, 'files', 'assets'),
|
|
754
|
-
target: (0, path_1.join)(
|
|
982
|
+
target: (0, path_1.join)(sourceRoot, 'assets'),
|
|
755
983
|
overwrite: options.overwrite,
|
|
756
984
|
});
|
|
757
985
|
// apply changes to the project configuration
|
|
758
986
|
(0, devkit_1.updateProjectConfiguration)(tree, projectName, project);
|
|
759
987
|
}
|
|
760
988
|
}
|
|
761
|
-
|
|
989
|
+
if (options.localazy) {
|
|
990
|
+
yield (0, plugin_localazy_1.LocalazyGitlabCiGenerator)(tree, {});
|
|
991
|
+
}
|
|
762
992
|
yield (0, plugin_docker_1.DockerGitlabCiGenerator)(tree, {});
|
|
763
993
|
});
|
|
764
994
|
}
|