@nrwl/angular 13.10.0-beta.7 → 13.10.0-beta.8
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/esm2020/mfe/index.mjs +2 -2
- package/fesm2015/nrwl-angular-mfe.mjs +1 -1
- package/fesm2015/nrwl-angular-testing.mjs.map +1 -1
- package/fesm2015/nrwl-angular.mjs.map +1 -1
- package/fesm2020/nrwl-angular-mfe.mjs +1 -1
- package/fesm2020/nrwl-angular-testing.mjs.map +1 -1
- package/fesm2020/nrwl-angular.mjs.map +1 -1
- package/mfe/index.d.ts +1 -1
- package/mfe/index.js +2 -1
- package/mfe/index.js.map +1 -1
- package/package.json +6 -6
- package/src/builders/webpack-browser/schema.json +0 -15
- package/src/generators/application/lib/add-mfe.js +1 -0
- package/src/generators/application/lib/add-mfe.js.map +1 -1
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +6 -0
- package/src/generators/mfe-host/mfe-host.js +1 -0
- package/src/generators/mfe-host/mfe-host.js.map +1 -1
- package/src/generators/mfe-host/schema.d.ts +1 -0
- package/src/generators/mfe-host/schema.json +5 -0
- package/src/generators/ng-add/compat.d.ts +1 -1
- package/src/generators/ng-add/files/{root → root-karma}/karma.conf.js__tmpl__ +0 -0
- package/src/generators/ng-add/migrate-from-angular-cli.d.ts +2 -2
- package/src/generators/ng-add/migrate-from-angular-cli.js +38 -607
- package/src/generators/ng-add/migrate-from-angular-cli.js.map +1 -1
- package/src/generators/ng-add/ng-add.d.ts +3 -3
- package/src/generators/ng-add/ng-add.js +2 -2
- package/src/generators/ng-add/ng-add.js.map +1 -1
- package/src/generators/ng-add/schema.d.ts +1 -1
- package/src/generators/ng-add/utilities/app.migrator.d.ts +18 -0
- package/src/generators/ng-add/utilities/app.migrator.js +182 -0
- package/src/generators/ng-add/utilities/app.migrator.js.map +1 -0
- package/src/generators/ng-add/utilities/e2e-project.migrator.d.ts +19 -0
- package/src/generators/ng-add/utilities/e2e-project.migrator.js +186 -0
- package/src/generators/ng-add/utilities/e2e-project.migrator.js.map +1 -0
- package/src/generators/ng-add/utilities/e2e-utils.d.ts +7 -0
- package/src/generators/ng-add/utilities/e2e-utils.js +46 -0
- package/src/generators/ng-add/utilities/e2e-utils.js.map +1 -0
- package/src/generators/ng-add/utilities/get-all-projects.d.ts +3 -0
- package/src/generators/ng-add/utilities/get-all-projects.js +26 -0
- package/src/generators/ng-add/utilities/get-all-projects.js.map +1 -0
- package/src/generators/ng-add/utilities/normalize-options.d.ts +3 -0
- package/src/generators/ng-add/utilities/normalize-options.js +24 -0
- package/src/generators/ng-add/utilities/normalize-options.js.map +1 -0
- package/src/generators/ng-add/utilities/project.migrator.d.ts +21 -0
- package/src/generators/ng-add/utilities/project.migrator.js +53 -0
- package/src/generators/ng-add/utilities/project.migrator.js.map +1 -0
- package/src/generators/ng-add/utilities/types.d.ts +10 -0
- package/src/generators/ng-add/utilities/types.js +3 -0
- package/src/generators/ng-add/utilities/types.js.map +1 -0
- package/src/generators/ng-add/utilities/workspace.d.ts +12 -0
- package/src/generators/ng-add/utilities/workspace.js +258 -0
- package/src/generators/ng-add/utilities/workspace.js.map +1 -0
- package/src/generators/setup-mfe/lib/add-remote-to-host.d.ts +2 -2
- package/src/generators/setup-mfe/lib/add-remote-to-host.js +49 -23
- package/src/generators/setup-mfe/lib/add-remote-to-host.js.map +1 -1
- package/src/generators/setup-mfe/lib/fix-bootstrap.d.ts +2 -1
- package/src/generators/setup-mfe/lib/fix-bootstrap.js +13 -4
- package/src/generators/setup-mfe/lib/fix-bootstrap.js.map +1 -1
- package/src/generators/setup-mfe/lib/index.d.ts +1 -0
- package/src/generators/setup-mfe/lib/index.js +1 -0
- package/src/generators/setup-mfe/lib/index.js.map +1 -1
- package/src/generators/setup-mfe/lib/setup-host-if-dynamic.d.ts +3 -0
- package/src/generators/setup-mfe/lib/setup-host-if-dynamic.js +15 -0
- package/src/generators/setup-mfe/lib/setup-host-if-dynamic.js.map +1 -0
- package/src/generators/setup-mfe/schema.d.ts +1 -0
- package/src/generators/setup-mfe/schema.json +6 -0
- package/src/generators/setup-mfe/setup-mfe.d.ts +1 -1
- package/src/generators/setup-mfe/setup-mfe.js +16 -13
- package/src/generators/setup-mfe/setup-mfe.js.map +1 -1
- package/src/utils/versions.js +1 -1
- package/src/generators/ng-add/files/decorate-angular-cli/decorate-angular-cli.js__tmpl__ +0 -69
- package/src/generators/ng-add/files/root/nx.json__tmpl__ +0 -29
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-all-projects.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ng-add/utilities/get-all-projects.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAGjD,SAAgB,cAAc,CAAC,IAAU;IACvC,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IACnC,MAAM,MAAM,GAAsB;QAChC,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE;QACtC,MAAM,gBAAgB,GAAkC;YACtD,MAAM,EAAE,OAAO;YACf,IAAI;SACL,CAAC;QAEF,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE;YACrC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACpC;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACpC;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,wCAqBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = void 0;
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
function normalizeOptions(options, projects) {
|
|
6
|
+
var _a;
|
|
7
|
+
// TODO: this restrictions will be removed, it's here temporarily to
|
|
8
|
+
// execute for both a full migration and a minimal one to maintain
|
|
9
|
+
// the current behavior
|
|
10
|
+
const hasLibraries = projects.libs.length > 0;
|
|
11
|
+
if (projects.apps.length > 2 || hasLibraries) {
|
|
12
|
+
throw new Error('Can only convert projects with one app');
|
|
13
|
+
}
|
|
14
|
+
let npmScope = (_a = options.npmScope) !== null && _a !== void 0 ? _a : options.name;
|
|
15
|
+
if (npmScope) {
|
|
16
|
+
npmScope = (0, devkit_1.names)(npmScope).fileName;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
npmScope = projects.apps[0].name;
|
|
20
|
+
}
|
|
21
|
+
return Object.assign(Object.assign({}, options), { npmScope });
|
|
22
|
+
}
|
|
23
|
+
exports.normalizeOptions = normalizeOptions;
|
|
24
|
+
//# sourceMappingURL=normalize-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize-options.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ng-add/utilities/normalize-options.ts"],"names":[],"mappings":";;;AAAA,yCAAqC;AAIrC,SAAgB,gBAAgB,CAC9B,OAAyB,EACzB,QAA2B;;IAE3B,oEAAoE;IACpE,kEAAkE;IAClE,uBAAuB;IACvB,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9C,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC3D;IAED,IAAI,QAAQ,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,IAAI,CAAC;IAChD,IAAI,QAAQ,EAAE;QACZ,QAAQ,GAAG,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC;KACrC;SAAM;QACL,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAClC;IAED,uCAAY,OAAO,KAAE,QAAQ,IAAG;AAClC,CAAC;AApBD,4CAoBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ProjectConfiguration, Tree } from '@nrwl/devkit';
|
|
2
|
+
import { GeneratorOptions } from '../schema';
|
|
3
|
+
import { MigrationProjectConfiguration, ValidationResult } from './types';
|
|
4
|
+
export declare abstract class ProjectMigrator {
|
|
5
|
+
protected readonly tree: Tree;
|
|
6
|
+
protected readonly options: GeneratorOptions;
|
|
7
|
+
protected projectConfig: ProjectConfiguration;
|
|
8
|
+
protected project: {
|
|
9
|
+
name: string;
|
|
10
|
+
oldRoot: string;
|
|
11
|
+
oldSourceRoot: string;
|
|
12
|
+
newRoot: string;
|
|
13
|
+
newSourceRoot: string;
|
|
14
|
+
};
|
|
15
|
+
constructor(tree: Tree, options: GeneratorOptions, project: MigrationProjectConfiguration, rootDir: string);
|
|
16
|
+
abstract migrate(): Promise<void>;
|
|
17
|
+
abstract validate(): ValidationResult;
|
|
18
|
+
protected moveProjectRootFile(filePath: string, isRequired?: boolean): void;
|
|
19
|
+
protected moveDir(from: string, to: string): void;
|
|
20
|
+
protected moveFile(from: string, to: string, required?: boolean): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectMigrator = void 0;
|
|
4
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
class ProjectMigrator {
|
|
7
|
+
constructor(tree, options, project, rootDir) {
|
|
8
|
+
var _a, _b, _c;
|
|
9
|
+
this.tree = tree;
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.projectConfig = project.config;
|
|
12
|
+
this.project = {
|
|
13
|
+
name: project.name,
|
|
14
|
+
oldRoot: (_a = this.projectConfig.root) !== null && _a !== void 0 ? _a : '',
|
|
15
|
+
oldSourceRoot: (_c = (_b = this.projectConfig.sourceRoot) !== null && _b !== void 0 ? _b : this.projectConfig.root) !== null && _c !== void 0 ? _c : '',
|
|
16
|
+
newRoot: `${rootDir}/${project.name}`,
|
|
17
|
+
newSourceRoot: `${rootDir}/${project.name}/src`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
moveProjectRootFile(filePath, isRequired = true) {
|
|
21
|
+
if (!filePath) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const filename = !!filePath ? (0, path_1.basename)(filePath) : '';
|
|
25
|
+
const from = filePath;
|
|
26
|
+
const to = (0, devkit_1.joinPathFragments)(this.project.newRoot, filename);
|
|
27
|
+
this.moveFile(from, to, isRequired);
|
|
28
|
+
}
|
|
29
|
+
moveDir(from, to) {
|
|
30
|
+
(0, devkit_1.visitNotIgnoredFiles)(this.tree, from, (file) => {
|
|
31
|
+
this.moveFile(file, file.replace(from, to), true);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
moveFile(from, to, required = true) {
|
|
35
|
+
if (!this.tree.exists(from)) {
|
|
36
|
+
if (required) {
|
|
37
|
+
console.warn(`Path: ${from} does not exist`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if (this.tree.exists(to)) {
|
|
41
|
+
if (required) {
|
|
42
|
+
console.warn(`Path: ${to} already exists`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const contents = this.tree.read(from);
|
|
47
|
+
this.tree.write(to, contents);
|
|
48
|
+
this.tree.delete(from);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ProjectMigrator = ProjectMigrator;
|
|
53
|
+
//# sourceMappingURL=project.migrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.migrator.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ng-add/utilities/project.migrator.ts"],"names":[],"mappings":";;;AAAA,yC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O,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IAES,QAAQ,CAAC,IAAY,EAAE,EAAU,EAAE,WAAoB,IAAI;QACnE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC3B,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,iBAAiB,CAAC,CAAC;aAC9C;SACF;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;YAC/B,IAAI,QAAQ,EAAE;gBACZ,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;aAC5C;SACF;aAAM;YACL,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACxB;IACH,CAAC;CACF;AA9DD,0CA8DC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProjectConfiguration } from '@nrwl/devkit';
|
|
2
|
+
export declare type MigrationProjectConfiguration = {
|
|
3
|
+
config: ProjectConfiguration;
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type WorkspaceProjects = {
|
|
7
|
+
apps: MigrationProjectConfiguration[];
|
|
8
|
+
libs: MigrationProjectConfiguration[];
|
|
9
|
+
};
|
|
10
|
+
export declare type ValidationResult = string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ng-add/utilities/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tree } from '@nrwl/devkit';
|
|
2
|
+
import { GeneratorOptions } from '../schema';
|
|
3
|
+
import { WorkspaceProjects } from './types';
|
|
4
|
+
export declare function validateWorkspace(tree: Tree, projects: WorkspaceProjects): void;
|
|
5
|
+
export declare function createNxJson(tree: Tree, options: GeneratorOptions, setWorkspaceLayoutAsNewProjectRoot?: boolean): void;
|
|
6
|
+
export declare function decorateAngularCli(tree: Tree): void;
|
|
7
|
+
export declare function updateWorkspaceConfigDefaults(tree: Tree): void;
|
|
8
|
+
export declare function updateRootTsConfig(tree: Tree): void;
|
|
9
|
+
export declare function updatePackageJson(tree: Tree): void;
|
|
10
|
+
export declare function updateTsLint(tree: Tree): void;
|
|
11
|
+
export declare function createWorkspaceFiles(tree: Tree): Promise<void>;
|
|
12
|
+
export declare function createRootKarmaConfig(tree: Tree): void;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRootKarmaConfig = exports.createWorkspaceFiles = exports.updateTsLint = exports.updatePackageJson = exports.updateRootTsConfig = exports.updateWorkspaceConfigDefaults = exports.decorateAngularCli = exports.createNxJson = exports.validateWorkspace = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nrwl/devkit");
|
|
6
|
+
const workspace_1 = require("@nrwl/workspace/src/generators/workspace/workspace");
|
|
7
|
+
const default_base_1 = require("@nrwl/workspace/src/utilities/default-base");
|
|
8
|
+
const prettier_1 = require("@nrwl/workspace/src/utilities/prettier");
|
|
9
|
+
const typescript_1 = require("@nrwl/workspace/src/utilities/typescript");
|
|
10
|
+
const versions_1 = require("@nrwl/workspace/src/utils/versions");
|
|
11
|
+
const fs_1 = require("fs");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const versions_2 = require("../../../utils/versions");
|
|
14
|
+
const e2e_utils_1 = require("./e2e-utils");
|
|
15
|
+
// TODO: most of the validation here will be moved to the app migrator when
|
|
16
|
+
// support for multiple apps is added. This will only contain workspace-wide
|
|
17
|
+
// validation.
|
|
18
|
+
function validateWorkspace(tree, projects) {
|
|
19
|
+
try {
|
|
20
|
+
if (!tree.exists('package.json')) {
|
|
21
|
+
throw new Error('Cannot find package.json');
|
|
22
|
+
}
|
|
23
|
+
if (!tree.exists('angular.json')) {
|
|
24
|
+
throw new Error('Cannot find angular.json');
|
|
25
|
+
}
|
|
26
|
+
const e2eKey = (0, e2e_utils_1.getE2eKey)(projects);
|
|
27
|
+
const e2eApp = (0, e2e_utils_1.getE2eProject)(projects);
|
|
28
|
+
if (!e2eApp) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if ((0, e2e_utils_1.isProtractorE2eProject)(e2eApp.config)) {
|
|
32
|
+
if (tree.exists(e2eApp.config.targets.e2e.options.protractorConfig)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
console.info(`Make sure the "${e2eKey}.architect.e2e.options.protractorConfig" is valid or the "${e2eKey}" project is removed from "angular.json".`);
|
|
36
|
+
throw new Error(`An e2e project with Protractor was found but "${e2eApp.config.targets.e2e.options.protractorConfig}" could not be found.`);
|
|
37
|
+
}
|
|
38
|
+
if ((0, e2e_utils_1.isCypressE2eProject)(e2eApp.config)) {
|
|
39
|
+
const configFile = (0, e2e_utils_1.getCypressConfigFile)(e2eApp.config);
|
|
40
|
+
if (configFile && !tree.exists(configFile)) {
|
|
41
|
+
throw new Error(`An e2e project with Cypress was found but "${configFile}" could not be found.`);
|
|
42
|
+
}
|
|
43
|
+
if (!tree.exists('cypress')) {
|
|
44
|
+
throw new Error(`An e2e project with Cypress was found but the "cypress" directory could not be found.`);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`An e2e project was found but it's using an unsupported executor "${e2eApp.config.targets.e2e.executor}".`);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error(e.message);
|
|
52
|
+
console.error('Your workspace could not be converted into an Nx Workspace because of the above error.');
|
|
53
|
+
throw e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.validateWorkspace = validateWorkspace;
|
|
57
|
+
function createNxJson(tree, options, setWorkspaceLayoutAsNewProjectRoot = false) {
|
|
58
|
+
var _a;
|
|
59
|
+
const { projects = {}, newProjectRoot = '' } = (0, devkit_1.readJson)(tree, 'angular.json');
|
|
60
|
+
// TODO: temporarily leaving this here because it's the old behavior for a
|
|
61
|
+
// minimal migration, will be removed in a later PR
|
|
62
|
+
const hasLibraries = Object.keys(projects).find((project) => projects[project].projectType &&
|
|
63
|
+
projects[project].projectType !== 'application');
|
|
64
|
+
if (Object.keys(projects).length !== 1 || hasLibraries) {
|
|
65
|
+
throw new Error(`The schematic can only be used with Angular CLI workspaces with a single application.`);
|
|
66
|
+
}
|
|
67
|
+
(0, devkit_1.writeJson)(tree, 'nx.json', {
|
|
68
|
+
npmScope: options.npmScope,
|
|
69
|
+
affected: {
|
|
70
|
+
defaultBase: (_a = options.defaultBase) !== null && _a !== void 0 ? _a : (0, default_base_1.deduceDefaultBase)(),
|
|
71
|
+
},
|
|
72
|
+
implicitDependencies: {
|
|
73
|
+
'package.json': {
|
|
74
|
+
dependencies: '*',
|
|
75
|
+
devDependencies: '*',
|
|
76
|
+
},
|
|
77
|
+
'.eslintrc.json': '*',
|
|
78
|
+
},
|
|
79
|
+
tasksRunnerOptions: {
|
|
80
|
+
default: {
|
|
81
|
+
runner: 'nx/tasks-runners/default',
|
|
82
|
+
options: {
|
|
83
|
+
cacheableOperations: ['build', 'lint', 'test', 'e2e'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
targetDependencies: {
|
|
88
|
+
build: [
|
|
89
|
+
{
|
|
90
|
+
target: 'build',
|
|
91
|
+
projects: 'dependencies',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
workspaceLayout: setWorkspaceLayoutAsNewProjectRoot
|
|
96
|
+
? { appsDir: newProjectRoot, libsDir: newProjectRoot }
|
|
97
|
+
: undefined,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.createNxJson = createNxJson;
|
|
101
|
+
function decorateAngularCli(tree) {
|
|
102
|
+
const nrwlWorkspacePath = require.resolve('@nrwl/workspace/package.json');
|
|
103
|
+
const decorateCli = (0, fs_1.readFileSync)((0, path_1.join)((0, path_1.dirname)(nrwlWorkspacePath), 'src/generators/utils/decorate-angular-cli.js__tmpl__'), 'utf-8');
|
|
104
|
+
tree.write('decorate-angular-cli.js', decorateCli);
|
|
105
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
106
|
+
if (json.scripts &&
|
|
107
|
+
json.scripts.postinstall &&
|
|
108
|
+
!json.scripts.postinstall.includes('decorate-angular-cli.js')) {
|
|
109
|
+
// if exists, add execution of this script
|
|
110
|
+
json.scripts.postinstall += ' && node ./decorate-angular-cli.js';
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
if (!json.scripts)
|
|
114
|
+
json.scripts = {};
|
|
115
|
+
// if doesn't exist, set to execute this script
|
|
116
|
+
json.scripts.postinstall = 'node ./decorate-angular-cli.js';
|
|
117
|
+
}
|
|
118
|
+
if (json.scripts.ng) {
|
|
119
|
+
json.scripts.ng = 'nx';
|
|
120
|
+
}
|
|
121
|
+
return json;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
exports.decorateAngularCli = decorateAngularCli;
|
|
125
|
+
function updateWorkspaceConfigDefaults(tree) {
|
|
126
|
+
var _a;
|
|
127
|
+
const workspaceConfig = (0, devkit_1.readWorkspaceConfiguration)(tree);
|
|
128
|
+
delete workspaceConfig.newProjectRoot;
|
|
129
|
+
workspaceConfig.cli = (_a = workspaceConfig.cli) !== null && _a !== void 0 ? _a : {};
|
|
130
|
+
if (!workspaceConfig.cli.defaultCollection) {
|
|
131
|
+
workspaceConfig.cli.defaultCollection = '@nrwl/angular';
|
|
132
|
+
}
|
|
133
|
+
(0, devkit_1.updateWorkspaceConfiguration)(tree, workspaceConfig);
|
|
134
|
+
}
|
|
135
|
+
exports.updateWorkspaceConfigDefaults = updateWorkspaceConfigDefaults;
|
|
136
|
+
function updateRootTsConfig(tree) {
|
|
137
|
+
(0, devkit_1.writeJson)(tree, 'tsconfig.base.json', setUpCompilerOptions((0, devkit_1.readJson)(tree, (0, typescript_1.getRootTsConfigPathInTree)(tree))));
|
|
138
|
+
if (tree.exists('tsconfig.json')) {
|
|
139
|
+
tree.delete('tsconfig.json');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.updateRootTsConfig = updateRootTsConfig;
|
|
143
|
+
function updatePackageJson(tree) {
|
|
144
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
145
|
+
var _a, _b;
|
|
146
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
147
|
+
packageJson.scripts = Object.assign(Object.assign({}, packageJson.scripts), { nx: 'nx', 'affected:apps': 'nx affected:apps', 'affected:libs': 'nx affected:libs', 'affected:build': 'nx affected:build', 'affected:e2e': 'nx affected:e2e', 'affected:test': 'nx affected:test', 'affected:lint': 'nx affected:lint', 'affected:graph': 'nx affected:graph', affected: 'nx affected', format: 'nx format:write', 'format:write': 'nx format:write', 'format:check': 'nx format:check', update: 'ng update @nrwl/workspace', 'update:check': 'ng update', lint: 'nx workspace-lint && ng lint', graph: 'nx graph', 'workspace-generator': 'nx workspace-generator', help: 'nx help' });
|
|
148
|
+
packageJson.devDependencies = (_a = packageJson.devDependencies) !== null && _a !== void 0 ? _a : {};
|
|
149
|
+
packageJson.dependencies = (_b = packageJson.dependencies) !== null && _b !== void 0 ? _b : {};
|
|
150
|
+
if (!packageJson.dependencies['@nrwl/angular']) {
|
|
151
|
+
packageJson.dependencies['@nrwl/angular'] = versions_2.nxVersion;
|
|
152
|
+
}
|
|
153
|
+
if (!packageJson.devDependencies['@angular/cli']) {
|
|
154
|
+
packageJson.devDependencies['@angular/cli'] = versions_2.angularDevkitVersion;
|
|
155
|
+
}
|
|
156
|
+
if (!packageJson.devDependencies['@nrwl/workspace']) {
|
|
157
|
+
packageJson.devDependencies['@nrwl/workspace'] = versions_2.nxVersion;
|
|
158
|
+
}
|
|
159
|
+
if (!packageJson.devDependencies['nx']) {
|
|
160
|
+
packageJson.devDependencies['nx'] = versions_2.nxVersion;
|
|
161
|
+
}
|
|
162
|
+
if (!packageJson.devDependencies['prettier']) {
|
|
163
|
+
packageJson.devDependencies['prettier'] = versions_1.prettierVersion;
|
|
164
|
+
}
|
|
165
|
+
return packageJson;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
exports.updatePackageJson = updatePackageJson;
|
|
169
|
+
function updateTsLint(tree) {
|
|
170
|
+
if (!tree.exists(`tslint.json`)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
(0, devkit_1.updateJson)(tree, 'tslint.json', (tslintJson) => {
|
|
174
|
+
var _a;
|
|
175
|
+
[
|
|
176
|
+
'no-trailing-whitespace',
|
|
177
|
+
'one-line',
|
|
178
|
+
'quotemark',
|
|
179
|
+
'typedef-whitespace',
|
|
180
|
+
'whitespace',
|
|
181
|
+
].forEach((key) => {
|
|
182
|
+
tslintJson[key] = undefined;
|
|
183
|
+
});
|
|
184
|
+
tslintJson.rulesDirectory = (_a = tslintJson.rulesDirectory) !== null && _a !== void 0 ? _a : [];
|
|
185
|
+
tslintJson.rulesDirectory.push('node_modules/@nrwl/workspace/src/tslint');
|
|
186
|
+
tslintJson.rules['nx-enforce-module-boundaries'] = [
|
|
187
|
+
true,
|
|
188
|
+
{
|
|
189
|
+
allow: [],
|
|
190
|
+
depConstraints: [{ sourceTag: '*', onlyDependOnLibsWithTags: ['*'] }],
|
|
191
|
+
},
|
|
192
|
+
];
|
|
193
|
+
return tslintJson;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
exports.updateTsLint = updateTsLint;
|
|
197
|
+
function createWorkspaceFiles(tree) {
|
|
198
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
199
|
+
updateVsCodeRecommendedExtensions(tree);
|
|
200
|
+
yield updatePrettierConfig(tree);
|
|
201
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/root'), '.', {
|
|
202
|
+
tmpl: '',
|
|
203
|
+
dot: '.',
|
|
204
|
+
rootTsConfigPath: (0, typescript_1.getRootTsConfigPathInTree)(tree),
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
exports.createWorkspaceFiles = createWorkspaceFiles;
|
|
209
|
+
function createRootKarmaConfig(tree) {
|
|
210
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/root-karma'), '.', {
|
|
211
|
+
tmpl: '',
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
exports.createRootKarmaConfig = createRootKarmaConfig;
|
|
215
|
+
function updateVsCodeRecommendedExtensions(tree) {
|
|
216
|
+
const recommendations = [
|
|
217
|
+
'nrwl.angular-console',
|
|
218
|
+
'angular.ng-template',
|
|
219
|
+
'dbaeumer.vscode-eslint',
|
|
220
|
+
'esbenp.prettier-vscode',
|
|
221
|
+
];
|
|
222
|
+
if (tree.exists('.vscode/extensions.json')) {
|
|
223
|
+
(0, devkit_1.updateJson)(tree, '.vscode/extensions.json', (json) => {
|
|
224
|
+
json.recommendations = json.recommendations || [];
|
|
225
|
+
recommendations.forEach((extension) => {
|
|
226
|
+
if (!json.recommendations.includes(extension)) {
|
|
227
|
+
json.recommendations.push(extension);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return json;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
(0, devkit_1.writeJson)(tree, '.vscode/extensions.json', {
|
|
235
|
+
recommendations,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function updatePrettierConfig(tree) {
|
|
240
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
241
|
+
const existingPrettierConfig = yield (0, prettier_1.resolveUserExistingPrettierConfig)();
|
|
242
|
+
if (!existingPrettierConfig) {
|
|
243
|
+
(0, devkit_1.writeJson)(tree, '.prettierrc', workspace_1.DEFAULT_NRWL_PRETTIER_CONFIG);
|
|
244
|
+
}
|
|
245
|
+
if (!tree.exists('.prettierignore')) {
|
|
246
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/prettier'), '.', { tmpl: '', dot: '.' });
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function setUpCompilerOptions(tsconfig) {
|
|
251
|
+
if (!tsconfig.compilerOptions.paths) {
|
|
252
|
+
tsconfig.compilerOptions.paths = {};
|
|
253
|
+
}
|
|
254
|
+
tsconfig.compilerOptions.baseUrl = '.';
|
|
255
|
+
tsconfig.compilerOptions.rootDir = '.';
|
|
256
|
+
return tsconfig;
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ng-add/utilities/workspace.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,kFAAkG;AAClG,6EAA+E;AAC/E,qEAA2F;AAC3F,yEAAqF;AACrF,iEAAqE;AACrE,2BAAkC;AAClC,+BAAqC;AACrC,sDAA0E;AAE1E,2CAMqB;AAGrB,2EAA2E;AAC3E,4EAA4E;AAC5E,cAAc;AACd,SAAgB,iBAAiB,CAC/B,IAAU,EACV,QAA2B;IAE3B,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC7C;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;Y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CAAC;IACvC,QAAQ,CAAC,eAAe,CAAC,OAAO,GAAG,GAAG,CAAC;IAEvC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Tree } from '@nrwl/devkit';
|
|
2
2
|
import type { Schema } from '../schema';
|
|
3
3
|
export declare function checkIsCommaNeeded(mfeRemoteText: string): boolean;
|
|
4
|
-
export declare function addRemoteToHost(
|
|
4
|
+
export declare function addRemoteToHost(tree: Tree, options: Schema): void;
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addRemoteToHost = exports.checkIsCommaNeeded = void 0;
|
|
4
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
+
const devkit_2 = require("@nrwl/devkit");
|
|
5
6
|
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
7
|
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
7
8
|
const ts = require("typescript");
|
|
9
|
+
const ast_utils_2 = require("@nrwl/workspace/src/utilities/ast-utils");
|
|
8
10
|
function checkIsCommaNeeded(mfeRemoteText) {
|
|
9
11
|
const remoteText = mfeRemoteText.replace(/\s+/g, '');
|
|
10
12
|
return !remoteText.endsWith(',]')
|
|
@@ -14,44 +16,68 @@ function checkIsCommaNeeded(mfeRemoteText) {
|
|
|
14
16
|
: false;
|
|
15
17
|
}
|
|
16
18
|
exports.checkIsCommaNeeded = checkIsCommaNeeded;
|
|
17
|
-
function addRemoteToHost(
|
|
19
|
+
function addRemoteToHost(tree, options) {
|
|
18
20
|
if (options.mfeType === 'remote' && options.host) {
|
|
19
|
-
const hostProject = (0,
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const hostProject = (0, devkit_2.readProjectConfiguration)(tree, options.host);
|
|
22
|
+
const pathToMfeManifest = (0, devkit_2.joinPathFragments)(hostProject.sourceRoot, 'assets/mfe.manifest.json');
|
|
23
|
+
const hostFederationType = determineHostFederationType(tree, pathToMfeManifest);
|
|
24
|
+
if (hostFederationType === 'static') {
|
|
25
|
+
addRemoteToStaticHost(tree, options, hostProject);
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
host.write(hostMfeConfigPath, updatedConfig);
|
|
31
|
-
const declarationFilePath = (0, devkit_1.joinPathFragments)(hostProject.sourceRoot, 'decl.d.ts');
|
|
32
|
-
const declarationFileContent = (host.exists(declarationFilePath)
|
|
33
|
-
? host.read(declarationFilePath, 'utf-8')
|
|
27
|
+
else if (hostFederationType === 'dynamic') {
|
|
28
|
+
addRemoteToDynamicHost(tree, options, pathToMfeManifest);
|
|
29
|
+
}
|
|
30
|
+
const declarationFilePath = (0, devkit_2.joinPathFragments)(hostProject.sourceRoot, 'decl.d.ts');
|
|
31
|
+
const declarationFileContent = (tree.exists(declarationFilePath)
|
|
32
|
+
? tree.read(declarationFilePath, 'utf-8')
|
|
34
33
|
: '') + `\ndeclare module '${options.appName}/Module';`;
|
|
35
|
-
|
|
36
|
-
addLazyLoadedRouteToHostAppModule(
|
|
34
|
+
tree.write(declarationFilePath, declarationFileContent);
|
|
35
|
+
addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
exports.addRemoteToHost = addRemoteToHost;
|
|
39
|
+
function determineHostFederationType(tree, pathToMfeManifest) {
|
|
40
|
+
return tree.exists(pathToMfeManifest) ? 'dynamic' : 'static';
|
|
41
|
+
}
|
|
42
|
+
function addRemoteToStaticHost(tree, options, hostProject) {
|
|
43
|
+
const hostMfeConfigPath = (0, devkit_2.joinPathFragments)(hostProject.root, 'mfe.config.js');
|
|
44
|
+
if (!hostMfeConfigPath || !tree.exists(hostMfeConfigPath)) {
|
|
45
|
+
throw new Error(`The selected host application, ${options.host}, does not contain a mfe.config.js or mfe.manifest.json file. Are you sure it has been set up as a host application?`);
|
|
46
|
+
}
|
|
47
|
+
const hostMFEConfig = tree.read(hostMfeConfigPath, 'utf-8');
|
|
48
|
+
const webpackAst = tsquery_1.tsquery.ast(hostMFEConfig);
|
|
49
|
+
const mfRemotesNode = (0, tsquery_1.tsquery)(webpackAst, 'Identifier[name=remotes] ~ ArrayLiteralExpression', { visitAllChildren: true })[0];
|
|
50
|
+
const endOfPropertiesPos = mfRemotesNode.getEnd() - 1;
|
|
51
|
+
const isCommaNeeded = checkIsCommaNeeded(mfRemotesNode.getText());
|
|
52
|
+
const updatedConfig = `${hostMFEConfig.slice(0, endOfPropertiesPos)}${isCommaNeeded ? ',' : ''}'${options.appName}',${hostMFEConfig.slice(endOfPropertiesPos)}`;
|
|
53
|
+
tree.write(hostMfeConfigPath, updatedConfig);
|
|
54
|
+
}
|
|
55
|
+
function addRemoteToDynamicHost(tree, options, pathToMfeManifest) {
|
|
56
|
+
(0, devkit_1.updateJson)(tree, pathToMfeManifest, (manifest) => {
|
|
57
|
+
return Object.assign(Object.assign({}, manifest), { [options.appName]: `http://localhost:${options.port}` });
|
|
58
|
+
});
|
|
59
|
+
}
|
|
40
60
|
// TODO(colum): future work: allow dev to pass to path to routing module
|
|
41
|
-
function addLazyLoadedRouteToHostAppModule(
|
|
42
|
-
const hostAppConfig = (0,
|
|
61
|
+
function addLazyLoadedRouteToHostAppModule(tree, options, hostFederationType) {
|
|
62
|
+
const hostAppConfig = (0, devkit_2.readProjectConfiguration)(tree, options.host);
|
|
43
63
|
const pathToHostAppModule = `${hostAppConfig.sourceRoot}/app/app.module.ts`;
|
|
44
|
-
if (!
|
|
64
|
+
if (!tree.exists(pathToHostAppModule)) {
|
|
45
65
|
return;
|
|
46
66
|
}
|
|
47
|
-
const hostAppModule =
|
|
67
|
+
const hostAppModule = tree.read(pathToHostAppModule, 'utf-8');
|
|
48
68
|
if (!hostAppModule.includes('RouterModule.forRoot(')) {
|
|
49
69
|
return;
|
|
50
70
|
}
|
|
51
71
|
let sourceFile = ts.createSourceFile(pathToHostAppModule, hostAppModule, ts.ScriptTarget.Latest, true);
|
|
52
|
-
|
|
72
|
+
if (hostFederationType === 'dynamic') {
|
|
73
|
+
sourceFile = (0, ast_utils_2.insertImport)(tree, sourceFile, pathToHostAppModule, 'loadRemoteModule', '@nrwl/angular/mfe');
|
|
74
|
+
}
|
|
75
|
+
const routeToAdd = hostFederationType === 'dynamic'
|
|
76
|
+
? `loadRemoteModule('${options.appName}', './Module')`
|
|
77
|
+
: `import('${options.appName}/Module')`;
|
|
78
|
+
sourceFile = (0, ast_utils_1.addRoute)(tree, pathToHostAppModule, sourceFile, `{
|
|
53
79
|
path: '${options.appName}',
|
|
54
|
-
loadChildren: () =>
|
|
80
|
+
loadChildren: () => ${routeToAdd}.then(m => m.RemoteEntryModule)
|
|
55
81
|
}`);
|
|
56
82
|
}
|
|
57
83
|
//# sourceMappingURL=add-remote-to-host.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-remote-to-host.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/setup-mfe/lib/add-remote-to-host.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"add-remote-to-host.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/setup-mfe/lib/add-remote-to-host.ts"],"names":[],"mappings":";;;AAAA,yCAAsE;AAGtE,yCAA2E;AAC3E,uDAAoD;AAEpD,kEAG4C;AAE5C,iCAAiC;AACjC,uEAAuE;AAEvE,SAAgB,kBAAkB,CAAC,aAAqB;IACtD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC/B,CAAC,CAAC,UAAU,KAAK,IAAI;YACnB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI;QACR,CAAC,CAAC,KAAK,CAAC;AACZ,C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kit_1 = require("@nrwl/devkit");
|
|
5
|
-
function fixBootstrap(
|
|
5
|
+
function fixBootstrap(tree, appRoot, options) {
|
|
6
6
|
const mainFilePath = (0, devkit_1.joinPathFragments)(appRoot, 'src/main.ts');
|
|
7
|
-
const bootstrapCode =
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const bootstrapCode = tree.read(mainFilePath, 'utf-8');
|
|
8
|
+
tree.write((0, devkit_1.joinPathFragments)(appRoot, 'src/bootstrap.ts'), bootstrapCode);
|
|
9
|
+
const bootstrapImportCode = `import('./bootstrap').catch(err => console.error(err))`;
|
|
10
|
+
const fetchMfeManifestCode = `import { setRemoteDefinitions } from '@nrwl/angular/mfe';
|
|
11
|
+
|
|
12
|
+
fetch('/assets/mfe.manifest.json')
|
|
13
|
+
.then((res) => res.json())
|
|
14
|
+
.then(definitions => setRemoteDefinitions(definitions))
|
|
15
|
+
.then(() => ${bootstrapImportCode})`;
|
|
16
|
+
tree.write(mainFilePath, options.mfeType === 'host' && options.federationType === 'dynamic'
|
|
17
|
+
? fetchMfeManifestCode
|
|
18
|
+
: bootstrapImportCode);
|
|
10
19
|
}
|
|
11
20
|
exports.fixBootstrap = fixBootstrap;
|
|
12
21
|
//# sourceMappingURL=fix-bootstrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-bootstrap.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/setup-mfe/lib/fix-bootstrap.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fix-bootstrap.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/setup-mfe/lib/fix-bootstrap.ts"],"names":[],"mappings":";;;AAGA,yCAAiD;AAEjD,SAAgB,YAAY,CAAC,IAAU,EAAE,OAAe,EAAE,OAAe;IACvE,MAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACvD,IAAI,CAAC,KAAK,CAAC,IAAA,0BAAiB,EAAC,OAAO,EAAE,kBAAkB,CAAC,EAAE,aAAa,CAAC,CAAC;IAE1E,MAAM,mBAAmB,GAAG,wDAAwD,CAAC;IAErF,MAAM,oBAAoB,GAAG;;;;;gBAKf,mBAAmB,GAAG,CAAC;IAErC,IAAI,CAAC,KAAK,CACR,YAAY,EACZ,OAAO,CAAC,OAAO,KAAK,MAAM,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS;QAChE,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,mBAAmB,CACxB,CAAC;AACJ,CAAC;AApBD,oCAoBC"}
|
|
@@ -10,5 +10,6 @@ tslib_1.__exportStar(require("./fix-bootstrap"), exports);
|
|
|
10
10
|
tslib_1.__exportStar(require("./generate-config"), exports);
|
|
11
11
|
tslib_1.__exportStar(require("./get-remotes-with-ports"), exports);
|
|
12
12
|
tslib_1.__exportStar(require("./set-tsconfig-target"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./setup-host-if-dynamic"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./setup-serve-target"), exports);
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/setup-mfe/lib/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyC;AACzC,6DAAmC;AACnC,8DAAoC;AACpC,+DAAqC;AACrC,gEAAsC;AACtC,0DAAgC;AAChC,4DAAkC;AAClC,mEAAyC;AACzC,gEAAsC;AACtC,+DAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/setup-mfe/lib/index.ts"],"names":[],"mappings":";;;AAAA,mEAAyC;AACzC,6DAAmC;AACnC,8DAAoC;AACpC,+DAAqC;AACrC,gEAAsC;AACtC,0DAAgC;AAChC,4DAAkC;AAClC,mEAAyC;AACzC,gEAAsC;AACtC,kEAAwC;AACxC,+DAAqC"}
|