@rxap/plugin-angular 16.2.0-dev.9 → 16.2.1-dev.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.
- package/CHANGELOG.md +105 -0
- package/README.md +15 -1
- package/generators.json +10 -0
- package/package.json +27 -22
- package/src/generators/convert-to-buildable-library/generator.d.ts +4 -0
- package/src/generators/convert-to-buildable-library/generator.js +89 -0
- package/src/generators/convert-to-buildable-library/generator.js.map +1 -0
- package/src/generators/convert-to-buildable-library/schema.d.ts +3 -0
- package/src/generators/convert-to-buildable-library/schema.json +12 -0
- package/src/generators/init/generator.js +4 -0
- package/src/generators/init/generator.js.map +1 -1
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/init/schema.json +4 -0
- package/src/generators/init-application/coerce-project.d.ts +4 -0
- package/src/generators/init-application/coerce-project.js +53 -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/ngsw-config.json +11 -1
- package/src/generators/init-application/files/styles/_fonts.scss +2 -0
- package/src/generators/init-application/generate-monolithic.js +2 -7
- package/src/generators/init-application/generate-monolithic.js.map +1 -1
- package/src/generators/init-application/generator.js +308 -77
- package/src/generators/init-application/generator.js.map +1 -1
- package/src/generators/init-application/schema.d.ts +11 -0
- package/src/generators/init-application/schema.json +49 -26
- package/src/generators/init-component/generator.d.ts +4 -0
- package/src/generators/init-component/generator.js +71 -0
- package/src/generators/init-component/generator.js.map +1 -0
- package/src/generators/init-component/index.d.ts +2 -0
- package/src/generators/init-component/index.js +7 -0
- package/src/generators/init-component/index.js.map +1 -0
- package/src/generators/init-component/schema.d.ts +25 -0
- package/src/generators/init-component/schema.json +141 -0
- package/src/generators/init-feature/generator.js +5 -1
- package/src/generators/init-feature/generator.js.map +1 -1
- package/src/generators/init-feature/schema.d.ts +2 -1
- package/src/generators/init-feature/schema.json +4 -0
- package/src/generators/init-feature-library/generator.d.ts +4 -0
- package/src/generators/init-feature-library/generator.js +12 -0
- package/src/generators/init-feature-library/generator.js.map +1 -0
- package/src/generators/init-feature-library/schema.d.ts +10 -0
- package/src/generators/init-feature-library/schema.json +222 -0
- package/src/generators/init-library/generator.js +70 -54
- package/src/generators/init-library/generator.js.map +1 -1
- package/src/generators/init-library/schema.d.ts +1 -1
- package/src/generators/init-library/schema.json +182 -150
- package/src/lib/angular-version.d.ts +1 -0
- package/src/lib/angular-version.js +5 -0
- package/src/lib/angular-version.js.map +1 -0
- package/src/lib/coerce-test-setup.d.ts +2 -0
- package/src/lib/coerce-test-setup.js +40 -0
- package/src/lib/coerce-test-setup.js.map +1 -0
- package/src/generators/init-application/files/shared/assets/custom.svg +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
|
@@ -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
|
|
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,9 @@ 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 angular_version_1 = require("../../lib/angular-version");
|
|
16
|
+
const coerce_test_setup_1 = require("../../lib/coerce-test-setup");
|
|
17
|
+
const coerce_project_1 = require("./coerce-project");
|
|
15
18
|
const generate_authentication_1 = require("./generate-authentication");
|
|
16
19
|
const generate_monolithic_1 = require("./generate-monolithic");
|
|
17
20
|
function skipProject(tree, options, project, projectName) {
|
|
@@ -23,16 +26,20 @@ function skipProject(tree, options, project, projectName) {
|
|
|
23
26
|
}
|
|
24
27
|
return false;
|
|
25
28
|
}
|
|
26
|
-
function updateProjectTargets(project, options) {
|
|
29
|
+
function updateProjectTargets(projectName, project, options) {
|
|
27
30
|
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
31
|
var _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
29
32
|
(_a = project.targets) !== null && _a !== void 0 ? _a : (project.targets = {});
|
|
30
33
|
if (!project.targets['build']) {
|
|
31
34
|
throw new Error(`The project '${project.name}' has no build target`);
|
|
32
35
|
}
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
if (!options.skipDocker) {
|
|
37
|
+
if (project.targets['docker']) {
|
|
38
|
+
(_b = (_z = project.targets['docker']).options) !== null && _b !== void 0 ? _b : (_z.options = {});
|
|
39
|
+
(_c = (_0 = project.targets['docker'].options).dockerfile) !== null && _c !== void 0 ? _c : (_0.dockerfile = options.moduleFederation === 'remote' ?
|
|
40
|
+
(0, path_1.join)(project.sourceRoot, 'Dockerfile') :
|
|
41
|
+
'shared/angular/Dockerfile');
|
|
42
|
+
}
|
|
36
43
|
}
|
|
37
44
|
(0, workspace_utilities_1.CoerceTarget)(project, 'serve', {
|
|
38
45
|
options: {
|
|
@@ -106,8 +113,10 @@ function updateProjectTargets(project, options) {
|
|
|
106
113
|
project.targets['build'].options.sourceMap = true;
|
|
107
114
|
(_q = (_10 = project.targets['build'].options).assets) !== null && _q !== void 0 ? _q : (_10.assets = []);
|
|
108
115
|
(_r = (_11 = project.targets['build'].options).scripts) !== null && _r !== void 0 ? _r : (_11.scripts = []);
|
|
109
|
-
if (
|
|
110
|
-
project.targets['build'].options.scripts.
|
|
116
|
+
if (options.moduleFederation !== 'remote') {
|
|
117
|
+
if (!project.targets['build'].options.scripts.includes('node_modules/marked/marked.min.js')) {
|
|
118
|
+
project.targets['build'].options.scripts.push('node_modules/marked/marked.min.js');
|
|
119
|
+
}
|
|
111
120
|
}
|
|
112
121
|
(0, workspace_utilities_1.CoerceAssets)(project.targets['build'].options.assets, [
|
|
113
122
|
{
|
|
@@ -168,6 +177,24 @@ function updateProjectTargets(project, options) {
|
|
|
168
177
|
}
|
|
169
178
|
}
|
|
170
179
|
}
|
|
180
|
+
if (options.incrementalBuild) {
|
|
181
|
+
project.targets['build'].executor = '@nx/angular:webpack-browser';
|
|
182
|
+
project.targets['build'].options.buildLibsFromSource = false;
|
|
183
|
+
(0, workspace_utilities_1.CoerceTarget)(project, 'serve-static', {
|
|
184
|
+
executor: '@nx/web:file-server',
|
|
185
|
+
options: {
|
|
186
|
+
proxyUrl: 'https://127-0-0-1.nip.io:8443'
|
|
187
|
+
},
|
|
188
|
+
configurations: {
|
|
189
|
+
production: {
|
|
190
|
+
buildTarget: `${projectName}:build:production`
|
|
191
|
+
},
|
|
192
|
+
development: {
|
|
193
|
+
buildTarget: `${projectName}:build:development`
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
171
198
|
if (options.deploy) {
|
|
172
199
|
switch (options.deploy) {
|
|
173
200
|
case 'web3-storage':
|
|
@@ -255,6 +282,10 @@ function updateTags(project, options) {
|
|
|
255
282
|
if (options.sentry) {
|
|
256
283
|
tags.push('sentry');
|
|
257
284
|
}
|
|
285
|
+
if (options.moduleFederation) {
|
|
286
|
+
tags.push('module-federation');
|
|
287
|
+
tags.push(`mfe:${options.moduleFederation}`);
|
|
288
|
+
}
|
|
258
289
|
(0, workspace_utilities_1.CoerceProjectTags)(project, tags);
|
|
259
290
|
}
|
|
260
291
|
const MAIN_BOOTSTRAP_STATEMENT = `application.bootstrap().catch((err) => console.error(err));`;
|
|
@@ -268,7 +299,12 @@ const MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplicati
|
|
|
268
299
|
AppComponent,
|
|
269
300
|
appConfig,
|
|
270
301
|
);`;
|
|
271
|
-
|
|
302
|
+
const REMOTE_MAIN_APP_CREATION_STATEMENT = `const application = new StandaloneApplication(
|
|
303
|
+
environment,
|
|
304
|
+
RemoteEntryComponent,
|
|
305
|
+
appConfig,
|
|
306
|
+
);`;
|
|
307
|
+
function assertMainStatements(sourceFile, options) {
|
|
272
308
|
var _a;
|
|
273
309
|
const statements = [];
|
|
274
310
|
statements.push('const application = new StandaloneApplication(');
|
|
@@ -279,16 +315,12 @@ function assertMainStatements(sourceFile) {
|
|
|
279
315
|
console.error(`Missing statement from angular main.ts: ${statement}`);
|
|
280
316
|
sourceFile.set({
|
|
281
317
|
statements: [
|
|
282
|
-
MAIN_APP_CREATION_STATEMENT,
|
|
318
|
+
options.moduleFederation === 'remote' ? REMOTE_MAIN_APP_CREATION_STATEMENT : MAIN_APP_CREATION_STATEMENT,
|
|
283
319
|
MAIN_LOGGER_STATEMENT,
|
|
284
320
|
MAIN_BOOTSTRAP_STATEMENT,
|
|
285
321
|
],
|
|
286
322
|
});
|
|
287
323
|
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
288
|
-
{
|
|
289
|
-
moduleSpecifier: './app/app.component',
|
|
290
|
-
namedImports: ['AppComponent'],
|
|
291
|
-
},
|
|
292
324
|
{
|
|
293
325
|
moduleSpecifier: './app/app.config',
|
|
294
326
|
namedImports: ['appConfig'],
|
|
@@ -306,29 +338,124 @@ function assertMainStatements(sourceFile) {
|
|
|
306
338
|
namedImports: ['StandaloneApplication'],
|
|
307
339
|
},
|
|
308
340
|
]);
|
|
341
|
+
if (options.moduleFederation === 'remote') {
|
|
342
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
343
|
+
{
|
|
344
|
+
moduleSpecifier: './app/remote-entry/entry.component',
|
|
345
|
+
namedImports: ['RemoteEntryComponent'],
|
|
346
|
+
},
|
|
347
|
+
]);
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
(0, ts_morph_1.CoerceImports)(sourceFile, [
|
|
351
|
+
{
|
|
352
|
+
moduleSpecifier: './app/app.component',
|
|
353
|
+
namedImports: ['AppComponent'],
|
|
354
|
+
},
|
|
355
|
+
]);
|
|
356
|
+
}
|
|
309
357
|
return;
|
|
310
358
|
}
|
|
311
359
|
}
|
|
312
360
|
}
|
|
313
|
-
function cleanup(tree,
|
|
361
|
+
function cleanup(tree, projectName, options) {
|
|
362
|
+
const sourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, projectName);
|
|
314
363
|
const deleteFiles = [
|
|
315
364
|
'app/app.component.spec.ts',
|
|
316
365
|
'app/nx-welcome.component.ts',
|
|
366
|
+
'app/remote-entry/nx-welcome.component.ts',
|
|
317
367
|
'app/nx-welcome.component.cy.ts',
|
|
318
368
|
];
|
|
319
369
|
for (const file of deleteFiles) {
|
|
320
|
-
if (tree.exists((0, path_1.join)(
|
|
321
|
-
tree.delete((0, path_1.join)(
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
370
|
+
if (tree.exists((0, path_1.join)(sourceRoot, file))) {
|
|
371
|
+
tree.delete((0, path_1.join)(sourceRoot, file));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (tree.exists((0, path_1.join)(sourceRoot, 'app/app.component.html'))) {
|
|
375
|
+
const content = tree.read((0, path_1.join)(sourceRoot, 'app/app.component.html'), 'utf-8')
|
|
376
|
+
.replace(/<.+-nx-welcome><\/.+-nx-welcome> /, '')
|
|
377
|
+
.replace(/<ul class="remote-menu">[\s\S]*<\/ul>/, '');
|
|
378
|
+
tree.write((0, path_1.join)(sourceRoot, 'app/app.component.html'), content);
|
|
379
|
+
}
|
|
380
|
+
if (options.moduleFederation !== 'remote') {
|
|
381
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
382
|
+
project: projectName,
|
|
383
|
+
}, (_, [appRoutes, appComponent]) => {
|
|
384
|
+
var _a, _b, _c;
|
|
385
|
+
(0, ts_morph_1.RemoveRoute)(appRoutes, {
|
|
386
|
+
component: 'NxWelcomeComponent',
|
|
387
|
+
name: 'appRoutes'
|
|
388
|
+
});
|
|
389
|
+
(_a = appRoutes.getImportDeclaration('./nx-welcome.component')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
390
|
+
(_c = (_b = appComponent.getClass('AppComponent')) === null || _b === void 0 ? void 0 : _b.getProperty('title')) === null || _c === void 0 ? void 0 : _c.remove();
|
|
391
|
+
(0, ts_morph_1.RemoveComponentImport)(appComponent, 'NxWelcomeComponent');
|
|
392
|
+
}, ['app/app.routes.ts', 'app/app.component.ts']);
|
|
393
|
+
}
|
|
394
|
+
if (options.moduleFederation === 'remote') {
|
|
395
|
+
// region module-federation config
|
|
396
|
+
const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
|
|
397
|
+
let content = tree.read((0, path_1.join)(projectRoot, 'module-federation.config.js'), 'utf-8');
|
|
398
|
+
content = content.replace('./Routes', './routes');
|
|
399
|
+
tree.write((0, path_1.join)(projectRoot, 'module-federation.config.js'), content);
|
|
400
|
+
// endregion
|
|
401
|
+
// region tsconfig.base.json
|
|
402
|
+
(0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
|
|
403
|
+
var _a, _b;
|
|
404
|
+
var _c;
|
|
405
|
+
(_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
|
|
406
|
+
(_b = (_c = tsConfig.compilerOptions).paths) !== null && _b !== void 0 ? _b : (_c.paths = {});
|
|
407
|
+
if (tsConfig.compilerOptions.paths[`${projectName}/Routes`]) {
|
|
408
|
+
delete tsConfig.compilerOptions.paths[`${projectName}/Routes`];
|
|
409
|
+
}
|
|
410
|
+
}, { infix: 'base' });
|
|
411
|
+
// endregion
|
|
412
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
413
|
+
project: projectName,
|
|
414
|
+
}, (_, [entryRoutes]) => {
|
|
415
|
+
(0, ts_morph_1.CoerceDefaultExport)(entryRoutes.getVariableStatement('remoteRoutes').getDeclarations()[0]);
|
|
416
|
+
}, [
|
|
417
|
+
'app/remote-entry/entry.routes.ts',
|
|
418
|
+
]);
|
|
419
|
+
if (tree.exists((0, path_1.join)(sourceRoot, 'app/remote-entry/entry.component.ts'))) {
|
|
420
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
421
|
+
project: projectName,
|
|
422
|
+
}, (_, [entryComponent]) => {
|
|
423
|
+
var _a, _b;
|
|
424
|
+
(_a = entryComponent.getImportDeclaration('./nx-welcome.component')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
425
|
+
(0, ts_morph_1.RemoveComponentImport)(entryComponent, 'NxWelcomeComponent');
|
|
426
|
+
(0, ts_morph_1.RemoveComponentImport)(entryComponent, 'CommonModule');
|
|
427
|
+
const componentOptions = (0, ts_morph_1.GetComponentDecoratorObject)(entryComponent);
|
|
428
|
+
const templateProp = componentOptions.getProperty('template');
|
|
429
|
+
if (templateProp && ((_b = templateProp.asKindOrThrow(ts_morph_2.SyntaxKind.PropertyAssignment).getInitializer()) === null || _b === void 0 ? void 0 : _b.getText().match(/<.+nx-welcome><\/.+nx-welcome>/))) {
|
|
430
|
+
templateProp.remove();
|
|
431
|
+
componentOptions.addPropertyAssignment({
|
|
432
|
+
name: 'template',
|
|
433
|
+
initializer: w => w.quote('<router-outlet></router-outlet>'),
|
|
434
|
+
});
|
|
435
|
+
(0, ts_morph_1.CoerceComponentImport)(entryComponent, {
|
|
436
|
+
name: 'RouterModule',
|
|
437
|
+
moduleSpecifier: '@angular/router'
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
}, [
|
|
441
|
+
'app/remote-entry/entry.component.ts',
|
|
442
|
+
]);
|
|
443
|
+
}
|
|
444
|
+
if (options.host) {
|
|
445
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
446
|
+
project: options.host,
|
|
447
|
+
}, (_, [appRoutes]) => {
|
|
448
|
+
(0, ts_morph_1.RemoveRoute)(appRoutes, {
|
|
449
|
+
loadRemoteModule: {
|
|
450
|
+
name: projectName,
|
|
451
|
+
entry: './Routes',
|
|
452
|
+
},
|
|
453
|
+
name: 'appRoutes'
|
|
454
|
+
});
|
|
455
|
+
appRoutes.organizeImports();
|
|
456
|
+
}, ['app/app.routes.ts']);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
332
459
|
}
|
|
333
460
|
function updateMainFile(tree, projectName, project, options) {
|
|
334
461
|
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
@@ -336,7 +463,7 @@ function updateMainFile(tree, projectName, project, options) {
|
|
|
336
463
|
// directory: '..' // to move from the apps/demo/src/app folder into the apps/demo/src folder
|
|
337
464
|
}, (project, [sourceFile, mainSourceFile]) => {
|
|
338
465
|
var _a;
|
|
339
|
-
assertMainStatements(sourceFile);
|
|
466
|
+
assertMainStatements(sourceFile, options);
|
|
340
467
|
const importDeclarations = [];
|
|
341
468
|
const statements = [];
|
|
342
469
|
if (options.serviceWorker) {
|
|
@@ -386,11 +513,41 @@ function updateMainFile(tree, projectName, project, options) {
|
|
|
386
513
|
sourceFile.insertStatements(index, statement);
|
|
387
514
|
}
|
|
388
515
|
}
|
|
389
|
-
if (options.moduleFederation) {
|
|
516
|
+
if (options.moduleFederation === 'host') {
|
|
390
517
|
mainSourceFile.set({
|
|
391
518
|
statements: [
|
|
392
|
-
|
|
393
|
-
|
|
519
|
+
`import {
|
|
520
|
+
setRemoteDefinitions,
|
|
521
|
+
setRemoteUrlResolver
|
|
522
|
+
} from '@nx/angular/mf';
|
|
523
|
+
import type { Environment } from '@rxap/environment';
|
|
524
|
+
import { environment } from './environments/environment';
|
|
525
|
+
|
|
526
|
+
export async function SetupDynamicMfe(environment: Environment) {
|
|
527
|
+
|
|
528
|
+
const manifest = environment.moduleFederation?.manifest;
|
|
529
|
+
|
|
530
|
+
if (!manifest) {
|
|
531
|
+
const release = environment.tag || environment.branch || 'latest';
|
|
532
|
+
setRemoteUrlResolver((remoteName: string) => \`\${ location.origin }/__mfe/\${ release }/\${ remoteName }\`);
|
|
533
|
+
} else {
|
|
534
|
+
|
|
535
|
+
let definitions: Record<string, string>;
|
|
536
|
+
|
|
537
|
+
if (typeof manifest === 'object') {
|
|
538
|
+
definitions = manifest;
|
|
539
|
+
} else {
|
|
540
|
+
definitions = await fetch(manifest).then((res) => res.json());
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
setRemoteDefinitions(definitions);
|
|
544
|
+
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
SetupDynamicMfe(environment).then(() => import('./bootstrap').catch((err) => console.error(err)));
|
|
550
|
+
`,
|
|
394
551
|
]
|
|
395
552
|
});
|
|
396
553
|
}
|
|
@@ -415,8 +572,11 @@ function coerceEnvironmentFiles(tree, options) {
|
|
|
415
572
|
name: w => w.quote('development'),
|
|
416
573
|
production: 'false',
|
|
417
574
|
app: w => w.quote(options.project),
|
|
418
|
-
serviceWorker: 'false',
|
|
419
575
|
};
|
|
576
|
+
// region dev environment
|
|
577
|
+
if (options.serviceWorker) {
|
|
578
|
+
baseEnvironment['serviceWorker'] = 'false';
|
|
579
|
+
}
|
|
420
580
|
if (options.sentry) {
|
|
421
581
|
baseEnvironment['sentry'] = ts_morph_2.Writers.object({
|
|
422
582
|
enabled: 'false',
|
|
@@ -432,21 +592,25 @@ function coerceEnvironmentFiles(tree, options) {
|
|
|
432
592
|
type: 'Environment',
|
|
433
593
|
initializer: ts_morph_2.Writers.object(baseEnvironment),
|
|
434
594
|
});
|
|
595
|
+
if (options.overwrite) {
|
|
596
|
+
normal.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
|
|
597
|
+
}
|
|
598
|
+
// region
|
|
599
|
+
// region prod environment
|
|
435
600
|
if (options.moduleFederation === 'host') {
|
|
436
601
|
delete baseEnvironment['moduleFederation'];
|
|
437
602
|
}
|
|
438
|
-
if (options.
|
|
439
|
-
|
|
603
|
+
if (options.serviceWorker) {
|
|
604
|
+
baseEnvironment['serviceWorker'] = 'true';
|
|
440
605
|
}
|
|
441
|
-
baseEnvironment['name'] = w => w.quote('production');
|
|
442
|
-
baseEnvironment['production'] = 'true';
|
|
443
|
-
baseEnvironment['serviceWorker'] = 'true';
|
|
444
606
|
if (options.sentry) {
|
|
445
607
|
baseEnvironment['sentry'] = ts_morph_2.Writers.object({
|
|
446
608
|
enabled: 'true',
|
|
447
609
|
debug: 'false',
|
|
448
610
|
});
|
|
449
611
|
}
|
|
612
|
+
baseEnvironment['name'] = w => w.quote('production');
|
|
613
|
+
baseEnvironment['production'] = 'true';
|
|
450
614
|
const prod = (0, ts_morph_1.CoerceVariableDeclaration)(prodSourceFile, 'environment', {
|
|
451
615
|
type: 'Environment',
|
|
452
616
|
initializer: ts_morph_2.Writers.object(baseEnvironment),
|
|
@@ -454,6 +618,7 @@ function coerceEnvironmentFiles(tree, options) {
|
|
|
454
618
|
if (options.overwrite) {
|
|
455
619
|
prod.set({ initializer: ts_morph_2.Writers.object(baseEnvironment) });
|
|
456
620
|
}
|
|
621
|
+
// endregion
|
|
457
622
|
}, [
|
|
458
623
|
'/environments/environment.ts?',
|
|
459
624
|
'/environments/environment.prod.ts?',
|
|
@@ -483,46 +648,90 @@ function updateTsConfig(tree, projectName) {
|
|
|
483
648
|
const projectRoot = (0, workspace_utilities_1.GetProjectRoot)(tree, projectName);
|
|
484
649
|
for (const tsConfigName of ['app', 'editor', 'spec']) {
|
|
485
650
|
(0, workspace_utilities_1.UpdateTsConfigJson)(tree, tsConfig => {
|
|
486
|
-
var _a, _b;
|
|
487
|
-
var
|
|
651
|
+
var _a, _b, _c;
|
|
652
|
+
var _d;
|
|
488
653
|
(_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : (tsConfig.compilerOptions = {});
|
|
489
|
-
(_b = (
|
|
654
|
+
(_b = (_d = tsConfig.compilerOptions).types) !== null && _b !== void 0 ? _b : (_d.types = []);
|
|
490
655
|
if (!tsConfig.compilerOptions.types.includes('@angular/localize')) {
|
|
491
656
|
tsConfig.compilerOptions.types.push('@angular/localize');
|
|
492
657
|
}
|
|
658
|
+
if (['app', 'spec'].includes(tsConfigName)) {
|
|
659
|
+
(_c = tsConfig.exclude) !== null && _c !== void 0 ? _c : (tsConfig.exclude = []);
|
|
660
|
+
(0, utilities_1.CoerceArrayItems)(tsConfig.exclude, [
|
|
661
|
+
'src/**/*.stories.ts',
|
|
662
|
+
'src/**/*.cy.ts',
|
|
663
|
+
]);
|
|
664
|
+
}
|
|
493
665
|
}, { infix: tsConfigName, basePath: projectRoot });
|
|
494
666
|
}
|
|
495
667
|
}
|
|
668
|
+
function linkMfeRemoteWithHost(tree, projectName, options) {
|
|
669
|
+
if (!options.host) {
|
|
670
|
+
throw new Error('The host project must be defined');
|
|
671
|
+
}
|
|
672
|
+
const hostSourceRoot = (0, workspace_utilities_1.GetProjectSourceRoot)(tree, options.host);
|
|
673
|
+
const isHostMonolithic = tree.exists((0, path_1.join)(hostSourceRoot, 'app/layout.routes.ts'));
|
|
674
|
+
const path = projectName.replace('user-interface-', '').replace('feature-', '');
|
|
675
|
+
if (isHostMonolithic && !options.standaloneImport) {
|
|
676
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
677
|
+
project: options.host,
|
|
678
|
+
}, (project, [layoutSourceFile]) => {
|
|
679
|
+
(0, ts_morph_1.CoerceLayoutRoutes)(layoutSourceFile, {
|
|
680
|
+
itemList: [
|
|
681
|
+
{
|
|
682
|
+
route: {
|
|
683
|
+
path,
|
|
684
|
+
loadRemoteModule: projectName
|
|
685
|
+
},
|
|
686
|
+
component: 'LayoutComponent'
|
|
687
|
+
}
|
|
688
|
+
]
|
|
689
|
+
});
|
|
690
|
+
}, ['app/layout.routes.ts']);
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
(0, workspace_ts_morph_1.TsMorphAngularProjectTransform)(tree, {
|
|
694
|
+
project: options.host,
|
|
695
|
+
}, (project, [appRoutes]) => {
|
|
696
|
+
(0, ts_morph_1.CoerceAppRoutes)(appRoutes, {
|
|
697
|
+
itemList: [
|
|
698
|
+
{
|
|
699
|
+
route: {
|
|
700
|
+
path,
|
|
701
|
+
loadRemoteModule: projectName
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
],
|
|
705
|
+
});
|
|
706
|
+
}, ['app/app.routes.ts']);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
496
709
|
function initApplicationGenerator(tree, options) {
|
|
497
|
-
var _a, _b, _c
|
|
710
|
+
var _a, _b, _c;
|
|
498
711
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
499
|
-
(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
(
|
|
506
|
-
|
|
507
|
-
|
|
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 = []);
|
|
712
|
+
if (options.authentik) {
|
|
713
|
+
options.oauth = true;
|
|
714
|
+
}
|
|
715
|
+
if (options.monolithic) {
|
|
716
|
+
options.openApi = true;
|
|
717
|
+
}
|
|
718
|
+
if (options.i18n) {
|
|
719
|
+
(_a = options.languages) !== null && _a !== void 0 ? _a : (options.languages = ['en']);
|
|
720
|
+
}
|
|
518
721
|
if (options.project) {
|
|
722
|
+
(_b = options.projects) !== null && _b !== void 0 ? _b : (options.projects = []);
|
|
519
723
|
(0, utilities_1.CoerceArrayItems)(options.projects, [options.project]);
|
|
520
724
|
}
|
|
725
|
+
if (options.host) {
|
|
726
|
+
options.moduleFederation = 'remote';
|
|
727
|
+
}
|
|
521
728
|
if (options.moduleFederation === 'remote') {
|
|
522
729
|
options.authentication = false;
|
|
523
730
|
options.oauth = false;
|
|
524
731
|
options.authentik = false;
|
|
525
732
|
options.serviceWorker = false;
|
|
733
|
+
options.sentry = false;
|
|
734
|
+
options.monolithic = false;
|
|
526
735
|
}
|
|
527
736
|
console.log('angular application init generator:', options);
|
|
528
737
|
yield (0, plugin_application_1.ApplicationInitWorkspace)(tree, options);
|
|
@@ -546,9 +755,9 @@ function initApplicationGenerator(tree, options) {
|
|
|
546
755
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/pipes', 'latest', { soft: true });
|
|
547
756
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/mixin', 'latest', { soft: true });
|
|
548
757
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/reflect-metadata', 'latest', { soft: true });
|
|
549
|
-
|
|
758
|
+
yield (0, workspace_utilities_1.AddPackageJsonDevDependency)(tree, '@rxap/browser-tailwind', 'latest', { soft: true, withoutNonRxapPeerDependencies: false });
|
|
550
759
|
// must always be added as some rxap components use the i18n tag
|
|
551
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize',
|
|
760
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/localize', angular_version_1.ANGULAR_VERSION, { soft: true });
|
|
552
761
|
// must always be added as some rxap components use interfaces from the package
|
|
553
762
|
// TODO : refactor the @rxap/ngx-error and @rxap/ngx-status-check to be independent from the @sentry/angular-ivy package
|
|
554
763
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@sentry/angular-ivy', 'latest', { soft: true });
|
|
@@ -558,12 +767,12 @@ function initApplicationGenerator(tree, options) {
|
|
|
558
767
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/oauth', 'latest', { soft: true });
|
|
559
768
|
}
|
|
560
769
|
if (options.material) {
|
|
561
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/material',
|
|
562
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/cdk',
|
|
770
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/material', angular_version_1.ANGULAR_VERSION, { soft: true });
|
|
771
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/cdk', angular_version_1.ANGULAR_VERSION, { soft: true });
|
|
563
772
|
}
|
|
564
773
|
if (options.serviceWorker) {
|
|
565
774
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/service-worker', 'latest', { soft: true });
|
|
566
|
-
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/service-worker',
|
|
775
|
+
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@angular/service-worker', angular_version_1.ANGULAR_VERSION, { soft: true });
|
|
567
776
|
}
|
|
568
777
|
if (options.monolithic) {
|
|
569
778
|
yield (0, workspace_utilities_1.AddPackageJsonDependency)(tree, '@rxap/layout', 'latest', { soft: true });
|
|
@@ -614,7 +823,10 @@ function initApplicationGenerator(tree, options) {
|
|
|
614
823
|
target: 'shared/angular',
|
|
615
824
|
overwrite: options.overwrite,
|
|
616
825
|
});
|
|
617
|
-
if (
|
|
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
|
-
|
|
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)(
|
|
784
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', 'service-worker'),
|
|
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)(
|
|
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
|
-
|
|
798
|
-
|
|
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;
|