@nx/angular 16.10.0-beta.2 → 17.0.0-beta.1
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/generators.d.ts +0 -1
- package/generators.js +0 -1
- package/generators.json +0 -12
- package/package.json +9 -9
- package/src/builders/utilities/module-federation.js +1 -1
- package/src/builders/utilities/webpack.js +5 -3
- package/src/generators/host/files/ts/webpack.server.config.ts__tmpl__ +4 -0
- package/src/generators/host/host.d.ts +1 -1
- package/src/generators/host/host.js +6 -3
- package/src/generators/host/lib/add-ssr.d.ts +1 -1
- package/src/generators/host/lib/add-ssr.js +7 -3
- package/src/generators/host/schema.d.ts +1 -0
- package/src/generators/host/schema.json +5 -0
- package/src/generators/ng-add/migrators/migrator.js +5 -7
- package/src/generators/ng-add/utilities/workspace.js +4 -13
- package/src/generators/remote/files/base-ts/webpack.server.config.ts__tmpl__ +4 -0
- package/src/generators/remote/lib/add-ssr.d.ts +2 -1
- package/src/generators/remote/lib/add-ssr.js +7 -3
- package/src/generators/remote/remote.d.ts +1 -1
- package/src/generators/remote/remote.js +5 -2
- package/src/generators/remote/schema.d.ts +1 -0
- package/src/generators/remote/schema.json +5 -0
- package/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +12 -0
- package/src/generators/setup-mf/files/ts-webpack/webpack.config.ts__tmpl__ +4 -0
- package/src/generators/setup-mf/files/ts-webpack/webpack.prod.config.ts__tmpl__ +16 -0
- package/src/generators/setup-mf/lib/add-remote-to-host.js +7 -4
- package/src/generators/setup-mf/lib/change-build-target.js +3 -2
- package/src/generators/setup-mf/lib/generate-config.js +8 -2
- package/src/generators/setup-mf/lib/normalize-options.js +1 -0
- package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +1 -1
- package/src/generators/setup-mf/schema.d.ts +1 -0
- package/src/generators/setup-mf/schema.json +5 -0
- package/src/generators/setup-ssr/lib/update-project-config.js +4 -0
- package/src/generators/storybook-configuration/storybook-configuration.js +1 -1
- package/src/generators/convert-tslint-to-eslint/compat.d.ts +0 -4
- package/src/generators/convert-tslint-to-eslint/compat.js +0 -10
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.d.ts +0 -6
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +0 -171
- package/src/generators/convert-tslint-to-eslint/schema.json +0 -55
- /package/src/generators/host/files/{src → common/src}/main.server.ts__tmpl__ +0 -0
- /package/src/generators/host/files/{webpack.server.config.js__tmpl__ → js/webpack.server.config.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{base → common}/src/main.server.ts__tmpl__ +0 -0
package/generators.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from './src/generators/application/application';
|
|
|
3
3
|
export * from './src/generators/component-cypress-spec/component-cypress-spec';
|
|
4
4
|
export * from './src/generators/component-story/component-story';
|
|
5
5
|
export * from './src/generators/component/component';
|
|
6
|
-
export * from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint';
|
|
7
6
|
export * from './src/generators/directive/directive';
|
|
8
7
|
export * from './src/generators/host/host';
|
|
9
8
|
export * from './src/generators/init/init';
|
package/generators.js
CHANGED
|
@@ -6,7 +6,6 @@ tslib_1.__exportStar(require("./src/generators/application/application"), export
|
|
|
6
6
|
tslib_1.__exportStar(require("./src/generators/component-cypress-spec/component-cypress-spec"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./src/generators/component-story/component-story"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./src/generators/component/component"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./src/generators/directive/directive"), exports);
|
|
11
10
|
tslib_1.__exportStar(require("./src/generators/host/host"), exports);
|
|
12
11
|
tslib_1.__exportStar(require("./src/generators/init/init"), exports);
|
package/generators.json
CHANGED
|
@@ -39,12 +39,6 @@
|
|
|
39
39
|
"schema": "./src/generators/component-test/schema.json",
|
|
40
40
|
"description": "Creates a cypress component test file for a component."
|
|
41
41
|
},
|
|
42
|
-
"convert-tslint-to-eslint": {
|
|
43
|
-
"factory": "./src/generators/convert-tslint-to-eslint/compat",
|
|
44
|
-
"schema": "./src/generators/convert-tslint-to-eslint/schema.json",
|
|
45
|
-
"description": "Converts a project from TSLint to ESLint.",
|
|
46
|
-
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
|
|
47
|
-
},
|
|
48
42
|
"init": {
|
|
49
43
|
"factory": "./src/generators/init/init.compat#initSchematic",
|
|
50
44
|
"schema": "./src/generators/init/schema.json",
|
|
@@ -193,12 +187,6 @@
|
|
|
193
187
|
"schema": "./src/generators/component-test/schema.json",
|
|
194
188
|
"description": "Creates a cypress component test file for a component."
|
|
195
189
|
},
|
|
196
|
-
"convert-tslint-to-eslint": {
|
|
197
|
-
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator",
|
|
198
|
-
"schema": "./src/generators/convert-tslint-to-eslint/schema.json",
|
|
199
|
-
"description": "Converts a project from TSLint to ESLint.",
|
|
200
|
-
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
|
|
201
|
-
},
|
|
202
190
|
"directive": {
|
|
203
191
|
"factory": "./src/generators/directive/directive",
|
|
204
192
|
"schema": "./src/generators/directive/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"webpack": "^5.80.0",
|
|
80
80
|
"webpack-merge": "^5.8.0",
|
|
81
81
|
"enquirer": "^2.3.6",
|
|
82
|
-
"@nx/devkit": "
|
|
83
|
-
"@nx/cypress": "
|
|
84
|
-
"@nx/jest": "
|
|
85
|
-
"@nx/js": "
|
|
86
|
-
"@nx/linter": "
|
|
87
|
-
"@nx/webpack": "
|
|
88
|
-
"@nx/workspace": "
|
|
89
|
-
"@nrwl/angular": "
|
|
82
|
+
"@nx/devkit": "17.0.0-beta.1",
|
|
83
|
+
"@nx/cypress": "17.0.0-beta.1",
|
|
84
|
+
"@nx/jest": "17.0.0-beta.1",
|
|
85
|
+
"@nx/js": "17.0.0-beta.1",
|
|
86
|
+
"@nx/linter": "17.0.0-beta.1",
|
|
87
|
+
"@nx/webpack": "17.0.0-beta.1",
|
|
88
|
+
"@nx/workspace": "17.0.0-beta.1",
|
|
89
|
+
"@nrwl/angular": "17.0.0-beta.1"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@angular-devkit/build-angular": ">= 14.0.0 < 17.0.0",
|
|
@@ -47,7 +47,7 @@ function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot) {
|
|
|
47
47
|
let moduleFederationConfigPath = moduleFederationConfigPathJS;
|
|
48
48
|
let cleanupTranspiler = () => { };
|
|
49
49
|
if ((0, fs_1.existsSync)(moduleFederationConfigPathTS)) {
|
|
50
|
-
cleanupTranspiler = (0, internal_1.registerTsProject)(
|
|
50
|
+
cleanupTranspiler = (0, internal_1.registerTsProject)((0, path_1.join)(workspaceRoot, tsconfigPath));
|
|
51
51
|
moduleFederationConfigPath = moduleFederationConfigPathTS;
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveIndexHtmlTransformer = exports.resolveCustomWebpackConfig = exports.mergeCustomWebpackConfig = void 0;
|
|
4
4
|
const webpack_merge_1 = require("webpack-merge");
|
|
5
5
|
const internal_1 = require("@nx/js/src/internal");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const path_1 = require("path");
|
|
6
8
|
async function mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig, options, target) {
|
|
7
|
-
const customWebpackConfiguration = resolveCustomWebpackConfig(pathToWebpackConfig, options.tsConfig);
|
|
9
|
+
const customWebpackConfiguration = resolveCustomWebpackConfig(pathToWebpackConfig, (0, path_1.join)(devkit_1.workspaceRoot, options.tsConfig));
|
|
8
10
|
// The extra Webpack configuration file can also export a Promise, for instance:
|
|
9
11
|
// `module.exports = new Promise(...)`. If it exports a single object, but not a Promise,
|
|
10
12
|
// then await will just resolve that object.
|
|
@@ -20,7 +22,7 @@ async function mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig,
|
|
|
20
22
|
}
|
|
21
23
|
exports.mergeCustomWebpackConfig = mergeCustomWebpackConfig;
|
|
22
24
|
function resolveCustomWebpackConfig(path, tsConfig) {
|
|
23
|
-
const cleanupTranspiler = (0, internal_1.registerTsProject)(
|
|
25
|
+
const cleanupTranspiler = (0, internal_1.registerTsProject)(tsConfig);
|
|
24
26
|
const customWebpackConfig = require(path);
|
|
25
27
|
cleanupTranspiler();
|
|
26
28
|
// If the user provides a configuration in TS file
|
|
@@ -32,7 +34,7 @@ function resolveCustomWebpackConfig(path, tsConfig) {
|
|
|
32
34
|
}
|
|
33
35
|
exports.resolveCustomWebpackConfig = resolveCustomWebpackConfig;
|
|
34
36
|
function resolveIndexHtmlTransformer(path, tsConfig, target) {
|
|
35
|
-
const cleanupTranspiler = (0, internal_1.registerTsProject)(
|
|
37
|
+
const cleanupTranspiler = (0, internal_1.registerTsProject)(tsConfig);
|
|
36
38
|
const indexTransformer = require(path);
|
|
37
39
|
cleanupTranspiler();
|
|
38
40
|
const transform = indexTransformer.default ?? indexTransformer;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
3
|
export declare function host(tree: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
-
export declare function hostInternal(tree: Tree,
|
|
4
|
+
export declare function hostInternal(tree: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
5
5
|
export default host;
|
|
@@ -17,12 +17,13 @@ async function host(tree, options) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
exports.host = host;
|
|
20
|
-
async function hostInternal(tree,
|
|
20
|
+
async function hostInternal(tree, schema) {
|
|
21
21
|
const installedAngularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
22
|
-
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') &&
|
|
22
|
+
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') && schema.standalone) {
|
|
23
23
|
throw new Error((0, devkit_1.stripIndents) `The "standalone" option is only supported in Angular >= 14.1.0. You are currently using ${installedAngularVersionInfo.version}.
|
|
24
24
|
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
|
25
25
|
}
|
|
26
|
+
const { typescriptConfiguration = true, ...options } = schema;
|
|
26
27
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
27
28
|
const remotesToGenerate = [];
|
|
28
29
|
const remotesToIntegrate = [];
|
|
@@ -64,10 +65,11 @@ async function hostInternal(tree, options) {
|
|
|
64
65
|
skipE2E,
|
|
65
66
|
e2eProjectName: skipE2E ? undefined : `${hostProjectName}-e2e`,
|
|
66
67
|
prefix: options.prefix,
|
|
68
|
+
typescriptConfiguration,
|
|
67
69
|
});
|
|
68
70
|
let installTasks = [appInstallTask];
|
|
69
71
|
if (options.ssr) {
|
|
70
|
-
let ssrInstallTask = await (0, lib_1.addSsr)(tree, options, hostProjectName);
|
|
72
|
+
let ssrInstallTask = await (0, lib_1.addSsr)(tree, options, hostProjectName, typescriptConfiguration);
|
|
71
73
|
installTasks.push(ssrInstallTask);
|
|
72
74
|
}
|
|
73
75
|
for (const remote of remotesToGenerate) {
|
|
@@ -88,6 +90,7 @@ async function hostInternal(tree, options) {
|
|
|
88
90
|
host: hostProjectName,
|
|
89
91
|
skipFormat: true,
|
|
90
92
|
standalone: options.standalone,
|
|
93
|
+
typescriptConfiguration,
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
if (!options.skipFormat) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from '../schema';
|
|
3
|
-
export declare function addSsr(tree: Tree, options: Schema, appName: string): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
3
|
+
export declare function addSsr(tree: Tree, options: Schema, appName: string, typescriptConfiguration: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const setup_ssr_1 = require("../../setup-ssr/setup-ssr");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
async function addSsr(tree, options, appName) {
|
|
8
|
+
async function addSsr(tree, options, appName, typescriptConfiguration) {
|
|
9
9
|
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
10
10
|
await (0, setup_ssr_1.default)(tree, {
|
|
11
11
|
project: appName,
|
|
@@ -14,17 +14,21 @@ async function addSsr(tree, options, appName) {
|
|
|
14
14
|
tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
|
|
15
15
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'server.ts'), "import('./src/main.server');");
|
|
16
16
|
const browserBundleOutput = (0, devkit_1.joinPathFragments)(project.targets.build.options.outputPath, 'browser');
|
|
17
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files'), project.root, {
|
|
17
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
|
|
18
18
|
appName,
|
|
19
19
|
browserBundleOutput,
|
|
20
20
|
standalone: options.standalone,
|
|
21
21
|
tmpl: '',
|
|
22
22
|
});
|
|
23
|
+
const pathToTemplateFiles = typescriptConfiguration ? 'ts' : 'js';
|
|
24
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files', pathToTemplateFiles), project.root, {
|
|
25
|
+
tmpl: '',
|
|
26
|
+
});
|
|
23
27
|
// update project.json
|
|
24
28
|
project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
25
29
|
project.targets.server.executor = '@nx/angular:webpack-server';
|
|
26
30
|
project.targets.server.options.customWebpackConfig = {
|
|
27
|
-
path: (0, devkit_1.joinPathFragments)(project.root,
|
|
31
|
+
path: (0, devkit_1.joinPathFragments)(project.root, `webpack.server.config.${pathToTemplateFiles}`),
|
|
28
32
|
};
|
|
29
33
|
project.targets['serve-ssr'].executor =
|
|
30
34
|
'@nx/angular:module-federation-dev-ssr';
|
|
@@ -173,6 +173,11 @@
|
|
|
173
173
|
"type": "boolean",
|
|
174
174
|
"default": false,
|
|
175
175
|
"x-priority": "important"
|
|
176
|
+
},
|
|
177
|
+
"typescriptConfiguration": {
|
|
178
|
+
"type": "boolean",
|
|
179
|
+
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
180
|
+
"default": true
|
|
176
181
|
}
|
|
177
182
|
},
|
|
178
183
|
"additionalProperties": false,
|
|
@@ -62,13 +62,11 @@ class Migrator {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const nxJson = (0, devkit_1.readNxJson)(this.tree);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
]));
|
|
71
|
-
});
|
|
65
|
+
nxJson.targetDefaults ??= {};
|
|
66
|
+
for (const target of targetNames) {
|
|
67
|
+
nxJson.targetDefaults[target] ??= {};
|
|
68
|
+
nxJson.targetDefaults[target].cache ??= true;
|
|
69
|
+
}
|
|
72
70
|
(0, devkit_1.updateNxJson)(this.tree, nxJson);
|
|
73
71
|
}
|
|
74
72
|
// TODO(leo): This should be moved to BuilderMigrator once everything is split into builder migrators.
|
|
@@ -31,19 +31,6 @@ function createNxJson(tree, options, defaultProject) {
|
|
|
31
31
|
affected: {
|
|
32
32
|
defaultBase: options.defaultBase ?? (0, default_base_1.deduceDefaultBase)(),
|
|
33
33
|
},
|
|
34
|
-
tasksRunnerOptions: {
|
|
35
|
-
default: {
|
|
36
|
-
runner: 'nx/tasks-runners/default',
|
|
37
|
-
options: {
|
|
38
|
-
cacheableOperations: [
|
|
39
|
-
'build',
|
|
40
|
-
targets.test ? 'test' : undefined,
|
|
41
|
-
targets.lint ? 'lint' : undefined,
|
|
42
|
-
targets.e2e ? 'e2e' : undefined,
|
|
43
|
-
].filter(Boolean),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
34
|
namedInputs: {
|
|
48
35
|
sharedGlobals: [],
|
|
49
36
|
default: ['{projectRoot}/**/*', 'sharedGlobals'],
|
|
@@ -65,10 +52,12 @@ function createNxJson(tree, options, defaultProject) {
|
|
|
65
52
|
build: {
|
|
66
53
|
dependsOn: ['^build'],
|
|
67
54
|
inputs: ['production', '^production'],
|
|
55
|
+
cache: true,
|
|
68
56
|
},
|
|
69
57
|
test: targets.test
|
|
70
58
|
? {
|
|
71
59
|
inputs: ['default', '^production', '{workspaceRoot}/karma.conf.js'],
|
|
60
|
+
cache: true,
|
|
72
61
|
}
|
|
73
62
|
: undefined,
|
|
74
63
|
lint: targets.lint
|
|
@@ -78,11 +67,13 @@ function createNxJson(tree, options, defaultProject) {
|
|
|
78
67
|
'{workspaceRoot}/.eslintrc.json',
|
|
79
68
|
'{workspaceRoot}/eslint.config.js',
|
|
80
69
|
],
|
|
70
|
+
cache: true,
|
|
81
71
|
}
|
|
82
72
|
: undefined,
|
|
83
73
|
e2e: targets.e2e
|
|
84
74
|
? {
|
|
85
75
|
inputs: ['default', '^production'],
|
|
76
|
+
cache: true,
|
|
86
77
|
}
|
|
87
78
|
: undefined,
|
|
88
79
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function addSsr(tree: Tree, { appName, port, standalone, }: {
|
|
2
|
+
export declare function addSsr(tree: Tree, { appName, port, standalone, typescriptConfiguration, }: {
|
|
3
3
|
appName: string;
|
|
4
4
|
port: number;
|
|
5
5
|
standalone: boolean;
|
|
6
|
+
typescriptConfiguration: boolean;
|
|
6
7
|
}): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -4,7 +4,7 @@ exports.addSsr = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const setup_ssr_1 = require("../../setup-ssr/setup-ssr");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
async function addSsr(tree, { appName, port, standalone, }) {
|
|
7
|
+
async function addSsr(tree, { appName, port, standalone, typescriptConfiguration, }) {
|
|
8
8
|
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
9
9
|
await (0, setup_ssr_1.default)(tree, {
|
|
10
10
|
project: appName,
|
|
@@ -14,13 +14,17 @@ async function addSsr(tree, { appName, port, standalone, }) {
|
|
|
14
14
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'server.ts'), "import('./src/main.server');");
|
|
15
15
|
const browserBundleOutput = (0, devkit_1.joinPathFragments)(project.targets.build.options.outputPath, 'browser');
|
|
16
16
|
const serverBundleOutput = (0, devkit_1.joinPathFragments)(project.targets.build.options.outputPath, 'server');
|
|
17
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname,
|
|
17
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/common`), project.root, {
|
|
18
18
|
appName,
|
|
19
19
|
browserBundleOutput,
|
|
20
20
|
serverBundleOutput,
|
|
21
21
|
standalone,
|
|
22
22
|
tmpl: '',
|
|
23
23
|
});
|
|
24
|
+
const pathToTemplateFiles = typescriptConfiguration ? 'base-ts' : 'base';
|
|
25
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToTemplateFiles}`), project.root, {
|
|
26
|
+
tmpl: '',
|
|
27
|
+
});
|
|
24
28
|
if (standalone) {
|
|
25
29
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../files/standalone'), project.root, {
|
|
26
30
|
appName,
|
|
@@ -32,7 +36,7 @@ async function addSsr(tree, { appName, port, standalone, }) {
|
|
|
32
36
|
project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
33
37
|
project.targets.server.executor = '@nx/angular:webpack-server';
|
|
34
38
|
project.targets.server.options.customWebpackConfig = {
|
|
35
|
-
path: (0, devkit_1.joinPathFragments)(project.root,
|
|
39
|
+
path: (0, devkit_1.joinPathFragments)(project.root, `webpack.server.config.${typescriptConfiguration ? 'ts' : 'js'}`),
|
|
36
40
|
};
|
|
37
41
|
project.targets['serve-ssr'].options = {
|
|
38
42
|
...(project.targets['serve-ssr'].options ?? {}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
3
|
export declare function remote(tree: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
-
export declare function remoteInternal(tree: Tree,
|
|
4
|
+
export declare function remoteInternal(tree: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
5
5
|
export default remote;
|
|
@@ -16,12 +16,13 @@ async function remote(tree, options) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
exports.remote = remote;
|
|
19
|
-
async function remoteInternal(tree,
|
|
19
|
+
async function remoteInternal(tree, schema) {
|
|
20
20
|
const installedAngularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
21
|
-
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') &&
|
|
21
|
+
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') && schema.standalone) {
|
|
22
22
|
throw new Error((0, devkit_1.stripIndents) `The "standalone" option is only supported in Angular >= 14.1.0. You are currently using ${installedAngularVersionInfo.version}.
|
|
23
23
|
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
|
24
24
|
}
|
|
25
|
+
const { typescriptConfiguration = true, ...options } = schema;
|
|
25
26
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
26
27
|
if (options.host && !projects.has(options.host)) {
|
|
27
28
|
throw new Error(`The name of the application to be used as the host app does not exist. (${options.host})`);
|
|
@@ -55,12 +56,14 @@ async function remoteInternal(tree, options) {
|
|
|
55
56
|
e2eProjectName: skipE2E ? undefined : `${remoteProjectName}-e2e`,
|
|
56
57
|
standalone: options.standalone,
|
|
57
58
|
prefix: options.prefix,
|
|
59
|
+
typescriptConfiguration,
|
|
58
60
|
});
|
|
59
61
|
let installTasks = [appInstallTask];
|
|
60
62
|
if (options.ssr) {
|
|
61
63
|
let ssrInstallTask = await (0, lib_1.addSsr)(tree, {
|
|
62
64
|
appName: remoteProjectName,
|
|
63
65
|
port,
|
|
66
|
+
typescriptConfiguration,
|
|
64
67
|
standalone: options.standalone,
|
|
65
68
|
});
|
|
66
69
|
installTasks.push(ssrInstallTask);
|
|
@@ -166,6 +166,11 @@
|
|
|
166
166
|
"description": "Whether to configure SSR for the remote application to be consumed by a host application using SSR.",
|
|
167
167
|
"type": "boolean",
|
|
168
168
|
"default": false
|
|
169
|
+
},
|
|
170
|
+
"typescriptConfiguration": {
|
|
171
|
+
"type": "boolean",
|
|
172
|
+
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
173
|
+
"default": true
|
|
169
174
|
}
|
|
170
175
|
},
|
|
171
176
|
"additionalProperties": false,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ModuleFederationConfig } from '@nx/webpack';
|
|
2
|
+
|
|
3
|
+
const config: ModuleFederationConfig = {
|
|
4
|
+
name: '<%= name %>',<% if(type === 'host') { %>
|
|
5
|
+
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
|
6
|
+
exposes: {<% if(standalone) { %>
|
|
7
|
+
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
|
8
|
+
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
|
|
9
|
+
},<% } %>
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default config;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {withModuleFederation} from '@nx/angular/module-federation';
|
|
2
|
+
import config from './module-federation.config';
|
|
3
|
+
|
|
4
|
+
export default withModuleFederation({
|
|
5
|
+
...config,
|
|
6
|
+
/*
|
|
7
|
+
* Remote overrides for production.
|
|
8
|
+
* Each entry is a pair of a unique name and the URL where it is deployed.
|
|
9
|
+
*
|
|
10
|
+
* e.g.
|
|
11
|
+
* remotes: [
|
|
12
|
+
* ['app1', 'https://app1.example.com'],
|
|
13
|
+
* ['app2', 'https://app2.example.com'],
|
|
14
|
+
* ]
|
|
15
|
+
*/
|
|
16
|
+
});
|
|
@@ -20,8 +20,9 @@ function addRemoteToHost(tree, options) {
|
|
|
20
20
|
const hostProject = (0, devkit_1.readProjectConfiguration)(tree, options.host);
|
|
21
21
|
const pathToMFManifest = (0, devkit_1.joinPathFragments)(hostProject.sourceRoot, 'assets/module-federation.manifest.json');
|
|
22
22
|
const hostFederationType = determineHostFederationType(tree, pathToMFManifest);
|
|
23
|
+
const isHostUsingTypescriptConfig = tree.exists((0, devkit_1.joinPathFragments)(hostProject.root, 'module-federation.config.ts'));
|
|
23
24
|
if (hostFederationType === 'static') {
|
|
24
|
-
addRemoteToStaticHost(tree, options, hostProject);
|
|
25
|
+
addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescriptConfig);
|
|
25
26
|
}
|
|
26
27
|
else if (hostFederationType === 'dynamic') {
|
|
27
28
|
addRemoteToDynamicHost(tree, options, pathToMFManifest);
|
|
@@ -46,10 +47,12 @@ exports.addRemoteToHost = addRemoteToHost;
|
|
|
46
47
|
function determineHostFederationType(tree, pathToMfManifest) {
|
|
47
48
|
return tree.exists(pathToMfManifest) ? 'dynamic' : 'static';
|
|
48
49
|
}
|
|
49
|
-
function addRemoteToStaticHost(tree, options, hostProject) {
|
|
50
|
-
const hostMFConfigPath = (0, devkit_1.joinPathFragments)(hostProject.root,
|
|
50
|
+
function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescrpt) {
|
|
51
|
+
const hostMFConfigPath = (0, devkit_1.joinPathFragments)(hostProject.root, isHostUsingTypescrpt
|
|
52
|
+
? 'module-federation.config.ts'
|
|
53
|
+
: 'module-federation.config.js');
|
|
51
54
|
if (!hostMFConfigPath || !tree.exists(hostMFConfigPath)) {
|
|
52
|
-
throw new Error(`The selected host application, ${options.host}, does not contain a module-federation.config.js or module-federation.manifest.json file. Are you sure it has been set up as a host application?`);
|
|
55
|
+
throw new Error(`The selected host application, ${options.host}, does not contain a module-federation.config.{ts,js} or module-federation.manifest.json file. Are you sure it has been set up as a host application?`);
|
|
53
56
|
}
|
|
54
57
|
const hostMFConfig = tree.read(hostMFConfigPath, 'utf-8');
|
|
55
58
|
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
@@ -4,17 +4,18 @@ exports.changeBuildTarget = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function changeBuildTarget(host, options) {
|
|
6
6
|
const appConfig = (0, devkit_1.readProjectConfiguration)(host, options.appName);
|
|
7
|
+
const configExtName = options.typescriptConfiguration ? 'ts' : 'js';
|
|
7
8
|
appConfig.targets.build.executor = '@nx/angular:webpack-browser';
|
|
8
9
|
appConfig.targets.build.options = {
|
|
9
10
|
...appConfig.targets.build.options,
|
|
10
11
|
customWebpackConfig: {
|
|
11
|
-
path: `${appConfig.root}/webpack.config
|
|
12
|
+
path: `${appConfig.root}/webpack.config.${configExtName}`,
|
|
12
13
|
},
|
|
13
14
|
};
|
|
14
15
|
appConfig.targets.build.configurations.production = {
|
|
15
16
|
...appConfig.targets.build.configurations.production,
|
|
16
17
|
customWebpackConfig: {
|
|
17
|
-
path: `${appConfig.root}/webpack.prod.config
|
|
18
|
+
path: `${appConfig.root}/webpack.prod.config.${configExtName}`,
|
|
18
19
|
},
|
|
19
20
|
};
|
|
20
21
|
(0, devkit_1.updateProjectConfiguration)(host, options.appName, appConfig);
|
|
@@ -5,11 +5,17 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
function generateWebpackConfig(tree, options, appRoot, remotesWithPorts) {
|
|
6
6
|
if (tree.exists(`${appRoot}/module-federation.config.js`) ||
|
|
7
7
|
tree.exists(`${appRoot}/webpack.config.js`) ||
|
|
8
|
-
tree.exists(`${appRoot}/webpack.prod.config.js`)
|
|
8
|
+
tree.exists(`${appRoot}/webpack.prod.config.js`) ||
|
|
9
|
+
tree.exists(`${appRoot}/module-federation.config.ts`) ||
|
|
10
|
+
tree.exists(`${appRoot}/webpack.config.ts`) ||
|
|
11
|
+
tree.exists(`${appRoot}/webpack.prod.config.ts`)) {
|
|
9
12
|
devkit_1.logger.warn(`NOTE: We encountered an existing webpack config for the app ${options.appName}. We have overwritten this file with the Module Federation Config.\n
|
|
10
13
|
If this was not the outcome you expected, you can discard the changes we have made, create a backup of your current webpack config, and run the command again.`);
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
const pathToWebpackTemplateFiles = options.typescriptConfiguration
|
|
16
|
+
? 'ts-webpack'
|
|
17
|
+
: 'webpack';
|
|
18
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, `../files/${pathToWebpackTemplateFiles}`), appRoot, {
|
|
13
19
|
tmpl: '',
|
|
14
20
|
type: options.mfType,
|
|
15
21
|
name: options.appName,
|
|
@@ -5,6 +5,7 @@ const project_1 = require("../../utils/project");
|
|
|
5
5
|
function normalizeOptions(tree, options) {
|
|
6
6
|
return {
|
|
7
7
|
...options,
|
|
8
|
+
typescriptConfiguration: options.typescriptConfiguration ?? true,
|
|
8
9
|
federationType: options.federationType ?? 'static',
|
|
9
10
|
prefix: options.prefix ?? (0, project_1.getProjectPrefix)(tree, options.appName),
|
|
10
11
|
};
|
|
@@ -11,7 +11,7 @@ function setupHostIfDynamic(tree, options) {
|
|
|
11
11
|
if (!tree.exists(pathToMFManifest)) {
|
|
12
12
|
tree.write(pathToMFManifest, '{}');
|
|
13
13
|
}
|
|
14
|
-
const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(project.root,
|
|
14
|
+
const pathToProdWebpackConfig = (0, devkit_1.joinPathFragments)(project.root, `webpack.prod.config.${options.typescriptConfiguration ? 'ts' : 'js'}`);
|
|
15
15
|
if (tree.exists(pathToProdWebpackConfig)) {
|
|
16
16
|
tree.delete(pathToProdWebpackConfig);
|
|
17
17
|
}
|
|
@@ -73,6 +73,11 @@
|
|
|
73
73
|
"type": "boolean",
|
|
74
74
|
"description": "Whether the application is a standalone application. _Note: This is only supported in Angular versions >= 14.1.0_",
|
|
75
75
|
"default": false
|
|
76
|
+
},
|
|
77
|
+
"typescriptConfiguration": {
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
80
|
+
"default": true
|
|
76
81
|
}
|
|
77
82
|
},
|
|
78
83
|
"required": ["appName", "mfType"],
|
|
@@ -67,6 +67,10 @@ function updateProjectConfig(tree, schema) {
|
|
|
67
67
|
];
|
|
68
68
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
69
69
|
}
|
|
70
|
+
nxJson.targetDefaults ??= {};
|
|
71
|
+
nxJson.targetDefaults.server ??= {};
|
|
72
|
+
nxJson.targetDefaults.server.cache ??= true;
|
|
73
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
70
74
|
}
|
|
71
75
|
exports.updateProjectConfig = updateProjectConfig;
|
|
72
76
|
function getServerOptions(options = {}) {
|
|
@@ -6,7 +6,7 @@ const assert_compatible_storybook_version_1 = require("./lib/assert-compatible-s
|
|
|
6
6
|
const generate_stories_1 = require("./lib/generate-stories");
|
|
7
7
|
const generate_storybook_configuration_1 = require("./lib/generate-storybook-configuration");
|
|
8
8
|
const validate_options_1 = require("./lib/validate-options");
|
|
9
|
-
// TODO(
|
|
9
|
+
// TODO(katerina): Nx 18 -> remove Cypress
|
|
10
10
|
async function storybookConfigurationGenerator(tree, options) {
|
|
11
11
|
(0, assert_compatible_storybook_version_1.assertCompatibleStorybookVersion)();
|
|
12
12
|
(0, validate_options_1.validateOptions)(options);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.conversionSchematic = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const warn_for_schematic_usage_1 = require("../utils/warn-for-schematic-usage");
|
|
6
|
-
const convert_tslint_to_eslint_1 = require("./convert-tslint-to-eslint");
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated This generator will be removed in v17
|
|
9
|
-
*/
|
|
10
|
-
exports.conversionSchematic = (0, warn_for_schematic_usage_1.warnForSchematicUsage)((0, devkit_1.convertNxGenerator)(convert_tslint_to_eslint_1.conversionGenerator));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { ConvertTSLintToESLintSchema } from '@nx/linter';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated This generator will be removed in v17
|
|
5
|
-
*/
|
|
6
|
-
export declare function conversionGenerator(host: Tree, options: ConvertTSLintToESLintSchema): Promise<() => Promise<void>>;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.conversionGenerator = void 0;
|
|
4
|
-
const cypress_1 = require("@nx/cypress");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const linter_1 = require("@nx/linter");
|
|
7
|
-
const add_linting_1 = require("../add-linting/add-linting");
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This generator will be removed in v17
|
|
10
|
-
*/
|
|
11
|
-
async function conversionGenerator(host, options) {
|
|
12
|
-
/**
|
|
13
|
-
* The ProjectConverter instance encapsulates all the standard operations we need
|
|
14
|
-
* to perform in order to convert a project from TSLint to ESLint, as well as some
|
|
15
|
-
* extensibility points for adjusting the behavior on a per package basis.
|
|
16
|
-
*
|
|
17
|
-
* E.g. @nx/angular projects might need to make different changes to the final
|
|
18
|
-
* ESLint config when compared with @nx/next projects.
|
|
19
|
-
*
|
|
20
|
-
* See the ProjectConverter implementation for a full breakdown of what it does.
|
|
21
|
-
*/
|
|
22
|
-
const projectConverter = new linter_1.ProjectConverter({
|
|
23
|
-
host,
|
|
24
|
-
projectName: options.project,
|
|
25
|
-
ignoreExistingTslintConfig: options.ignoreExistingTslintConfig,
|
|
26
|
-
eslintInitializer: async ({ projectName, projectConfig }) => {
|
|
27
|
-
await (0, add_linting_1.addLintingGenerator)(host, {
|
|
28
|
-
projectName,
|
|
29
|
-
projectRoot: projectConfig.root,
|
|
30
|
-
prefix: projectConfig.prefix || 'app',
|
|
31
|
-
/**
|
|
32
|
-
* We set the parserOptions.project config just in case the converted config uses
|
|
33
|
-
* rules which require type-checking. Later in the conversion we check if it actually
|
|
34
|
-
* does and remove the config again if it doesn't, so that it is most efficient.
|
|
35
|
-
*/
|
|
36
|
-
setParserOptionsProject: true,
|
|
37
|
-
skipFormat: true,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
/**
|
|
42
|
-
* If root eslint configuration already exists it will not be recreated
|
|
43
|
-
* but we also don't want to re-run the tslint config conversion
|
|
44
|
-
* as it was likely already done
|
|
45
|
-
*/
|
|
46
|
-
const rootEslintConfigExists = host.exists('.eslintrc.json');
|
|
47
|
-
/**
|
|
48
|
-
* Create the standard (which is applicable to the current package) ESLint setup
|
|
49
|
-
* for converting the project.
|
|
50
|
-
*/
|
|
51
|
-
const eslintInitInstallTask = await projectConverter.initESLint();
|
|
52
|
-
/**
|
|
53
|
-
* Convert the root tslint.json and apply the converted rules to the root .eslintrc.json
|
|
54
|
-
*/
|
|
55
|
-
const rootConfigInstallTask = await projectConverter.convertRootTSLintConfig((json) => {
|
|
56
|
-
json.overrides = [
|
|
57
|
-
{ files: ['*.ts'], rules: {} },
|
|
58
|
-
{ files: ['*.html'], rules: {} },
|
|
59
|
-
];
|
|
60
|
-
return applyAngularRulesToCorrectOverrides(json);
|
|
61
|
-
}, rootEslintConfigExists);
|
|
62
|
-
/**
|
|
63
|
-
* Convert the project's tslint.json to an equivalent ESLint config.
|
|
64
|
-
*/
|
|
65
|
-
const projectConfigInstallTask = await projectConverter.convertProjectConfig((json) => applyAngularRulesToCorrectOverrides(json));
|
|
66
|
-
/**
|
|
67
|
-
* Clean up the original TSLint configuration for the project.
|
|
68
|
-
*/
|
|
69
|
-
projectConverter.removeProjectTSLintFile();
|
|
70
|
-
// Only project shouldn't be added as a default
|
|
71
|
-
const { project, ...defaults } = options;
|
|
72
|
-
/**
|
|
73
|
-
* Store user preferences for the collection
|
|
74
|
-
*/
|
|
75
|
-
projectConverter.setDefaults('@nx/angular', defaults);
|
|
76
|
-
/**
|
|
77
|
-
* If the Angular project is an app which has an e2e project, try and convert that as well.
|
|
78
|
-
*/
|
|
79
|
-
let cypressInstallTask = () => Promise.resolve(undefined);
|
|
80
|
-
const e2eProjectName = projectConverter.getE2EProjectName();
|
|
81
|
-
if (e2eProjectName) {
|
|
82
|
-
try {
|
|
83
|
-
cypressInstallTask = await (0, cypress_1.conversionGenerator)(host, {
|
|
84
|
-
project: e2eProjectName,
|
|
85
|
-
ignoreExistingTslintConfig: options.ignoreExistingTslintConfig,
|
|
86
|
-
/**
|
|
87
|
-
* We can always set this to false, because it will already be handled by the next
|
|
88
|
-
* step of this parent generator, if applicable
|
|
89
|
-
*/
|
|
90
|
-
removeTSLintIfNoMoreTSLintTargets: false,
|
|
91
|
-
skipFormat: true,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
devkit_1.logger.warn('This Angular app has an e2e project, but it was not possible to convert it from TSLint to ESLint. This could be because the e2e project did not have a tslint.json file to begin with.');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Based on user preference and remaining usage, remove TSLint from the workspace entirely.
|
|
100
|
-
*/
|
|
101
|
-
let uninstallTSLintTask = () => Promise.resolve(undefined);
|
|
102
|
-
if (options.removeTSLintIfNoMoreTSLintTargets &&
|
|
103
|
-
!projectConverter.isTSLintUsedInWorkspace()) {
|
|
104
|
-
uninstallTSLintTask = projectConverter.removeTSLintFromWorkspace();
|
|
105
|
-
}
|
|
106
|
-
if (!options.skipFormat) {
|
|
107
|
-
await (0, devkit_1.formatFiles)(host);
|
|
108
|
-
}
|
|
109
|
-
return async () => {
|
|
110
|
-
await eslintInitInstallTask();
|
|
111
|
-
await rootConfigInstallTask();
|
|
112
|
-
await projectConfigInstallTask();
|
|
113
|
-
await cypressInstallTask();
|
|
114
|
-
await uninstallTSLintTask();
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
exports.conversionGenerator = conversionGenerator;
|
|
118
|
-
/**
|
|
119
|
-
* In the case of Angular lint rules, we need to apply them to correct override depending upon whether
|
|
120
|
-
* or not they require @typescript-eslint/parser or @angular-eslint/template-parser in order to function.
|
|
121
|
-
*
|
|
122
|
-
* By this point, the applicable overrides have already been scaffolded for us by the Nx generators
|
|
123
|
-
* that ran earlier within this generator.
|
|
124
|
-
*/
|
|
125
|
-
function applyAngularRulesToCorrectOverrides(json) {
|
|
126
|
-
const rules = json.rules;
|
|
127
|
-
if (rules && Object.keys(rules).length) {
|
|
128
|
-
for (const [ruleName, ruleConfig] of Object.entries(rules)) {
|
|
129
|
-
for (const override of json.overrides) {
|
|
130
|
-
if (override.files.includes('*.html') &&
|
|
131
|
-
ruleName.startsWith('@angular-eslint/template')) {
|
|
132
|
-
// Prioritize the converted rules over any base implementations from the original Nx generator
|
|
133
|
-
override.rules[ruleName] = ruleConfig;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* By default, tslint-to-eslint-config will try and apply any rules without known converters
|
|
137
|
-
* by using eslint-plugin-tslint. We instead explicitly warn the user about this missing converter,
|
|
138
|
-
* and therefore at this point we strip out any rules which start with @typescript-eslint/tslint/config
|
|
139
|
-
*/
|
|
140
|
-
if (override.files.includes('*.ts') &&
|
|
141
|
-
!ruleName.startsWith('@angular-eslint/template')) {
|
|
142
|
-
// Prioritize the converted rules over any base implementations from the original Nx generator
|
|
143
|
-
override.rules[ruleName] = ruleConfig;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// It's possible that there are plugins to apply to the TS override
|
|
149
|
-
if (json.plugins) {
|
|
150
|
-
for (const override of json.overrides) {
|
|
151
|
-
if (override.files.includes('*.ts')) {
|
|
152
|
-
override.plugins = override.plugins || [];
|
|
153
|
-
override.plugins = [
|
|
154
|
-
...override.plugins,
|
|
155
|
-
...json.plugins.filter((plugin) => plugin !== '@angular-eslint/eslint-plugin-template'),
|
|
156
|
-
];
|
|
157
|
-
}
|
|
158
|
-
if (override.files.includes('*.html') &&
|
|
159
|
-
json.plugins.includes('@angular-eslint/eslint-plugin-template')) {
|
|
160
|
-
override.plugins = ['@angular-eslint/eslint-plugin-template'];
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
delete json.plugins;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* We now no longer need the flat list of rules at the root of the config
|
|
167
|
-
* because they have all been applied to an appropriate override.
|
|
168
|
-
*/
|
|
169
|
-
delete json.rules;
|
|
170
|
-
return json;
|
|
171
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "NxAngularConvertTSLintToESLintGenerator",
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"title": "Convert an Angular project from TSLint to ESLint",
|
|
6
|
-
"description": "Convert an Angular project from TSLint to ESLint. NOTE: Does not work in `--dry-run mode`.",
|
|
7
|
-
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint.",
|
|
8
|
-
"examples": [
|
|
9
|
-
{
|
|
10
|
-
"command": "nx g convert-tslint-to-eslint myapp",
|
|
11
|
-
"description": "The following will first configure the project, `myapp`, the same way a _new_ project is configured i.e. It will use Nx's new recommended ESLint config. By default, this also adds the existing TSLint configuration on top of the default ESLint config from Nx to continue checking what it checks today. This is done by migrating TSLint rules to their equivalent ESLint rules to the best of its abilities. Some TSLint rules may not have ESLint equivalents and will be reported during the conversion"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"command": "nx g convert-tslint-to-eslint myapp --ignoreExistingTslintConfig=true",
|
|
15
|
-
"description": "If your TSLint config isn't extremely important to you, ignoring it makes this process more deterministic. Unlike the prior example, this will discard the existing TSLint configuration, meaning that the project will only have the Nx's latest recommended ESLint configuration which may be good enough for some workspaces"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"command": "nx g convert-tslint-to-eslint myapp --removeTSLintIfNoMoreTSLintTargets=false",
|
|
19
|
-
"description": "By default, this process removes the TSLint related dependencies and configuration once no more projects use TSLint. This can be disabled with the following flag to keep TSLint related dependencies and configuration in the repo"
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"type": "object",
|
|
23
|
-
"properties": {
|
|
24
|
-
"project": {
|
|
25
|
-
"description": "The name of the Angular project to convert. Please note, if the project is an Angular app with an associated Cypress e2e project, it will also attempt to convert that.",
|
|
26
|
-
"type": "string",
|
|
27
|
-
"$default": {
|
|
28
|
-
"$source": "argv",
|
|
29
|
-
"index": 0
|
|
30
|
-
},
|
|
31
|
-
"x-prompt": "Which Angular project would you like to convert from TSLint to ESLint?",
|
|
32
|
-
"x-priority": "important"
|
|
33
|
-
},
|
|
34
|
-
"ignoreExistingTslintConfig": {
|
|
35
|
-
"type": "boolean",
|
|
36
|
-
"description": "If true, it will not use existing TSLint config as a reference, it will just reset the project with the latest recommended ESLint config.",
|
|
37
|
-
"default": false,
|
|
38
|
-
"x-prompt": "Would you like to ignore the existing TSLint config? Recommended if the TSLint config has not been altered much as it makes the new ESLint config cleaner."
|
|
39
|
-
},
|
|
40
|
-
"removeTSLintIfNoMoreTSLintTargets": {
|
|
41
|
-
"type": "boolean",
|
|
42
|
-
"description": "If this conversion leaves no more TSLint usage in the workspace, it will remove TSLint and related dependencies and configuration.",
|
|
43
|
-
"default": true,
|
|
44
|
-
"x-prompt": "Would you like to remove TSLint and its related config if there are no TSLint projects remaining after this conversion?"
|
|
45
|
-
},
|
|
46
|
-
"skipFormat": {
|
|
47
|
-
"type": "boolean",
|
|
48
|
-
"description": "Skip formatting files.",
|
|
49
|
-
"default": false,
|
|
50
|
-
"x-priority": "internal"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"additionalProperties": false,
|
|
54
|
-
"required": ["project"]
|
|
55
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|