@nx/plugin 18.0.0-canary.20240202-ea5befb → 18.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "18.0.0
|
|
3
|
+
"version": "18.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
|
|
6
6
|
"repository": {
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
32
32
|
"fs-extra": "^11.1.0",
|
|
33
33
|
"tslib": "^2.3.0",
|
|
34
|
-
"@nx/devkit": "18.0.0
|
|
35
|
-
"@nx/jest": "18.0.0
|
|
36
|
-
"@nx/js": "18.0.0
|
|
37
|
-
"@nx/eslint": "18.0.0
|
|
38
|
-
"@nrwl/nx-plugin": "18.0.0
|
|
34
|
+
"@nx/devkit": "18.0.0",
|
|
35
|
+
"@nx/jest": "18.0.0",
|
|
36
|
+
"@nx/js": "18.0.0",
|
|
37
|
+
"@nx/eslint": "18.0.0",
|
|
38
|
+
"@nrwl/nx-plugin": "18.0.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -11,6 +11,7 @@ const eslint_1 = require("@nx/eslint");
|
|
|
11
11
|
const path_1 = require("path");
|
|
12
12
|
async function normalizeOptions(host, options) {
|
|
13
13
|
const projectName = options.rootProject ? 'e2e' : `${options.pluginName}-e2e`;
|
|
14
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
14
15
|
let projectRoot;
|
|
15
16
|
if (options.projectNameAndRootFormat === 'as-provided') {
|
|
16
17
|
const projectNameAndRootOptions = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
@@ -72,26 +73,26 @@ async function addJest(host, options) {
|
|
|
72
73
|
});
|
|
73
74
|
const jestTask = await (0, jest_1.configurationGenerator)(host, {
|
|
74
75
|
project: options.projectName,
|
|
76
|
+
targetName: 'e2e',
|
|
75
77
|
setupFile: 'none',
|
|
76
78
|
supportTsx: false,
|
|
77
79
|
skipSerializers: true,
|
|
78
80
|
skipFormat: true,
|
|
81
|
+
addPlugin: options.addPlugin,
|
|
79
82
|
});
|
|
80
83
|
const { startLocalRegistryPath, stopLocalRegistryPath } = (0, add_local_registry_scripts_1.addLocalRegistryScripts)(host);
|
|
81
84
|
(0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalSetup', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), startLocalRegistryPath));
|
|
82
85
|
(0, jest_1.addPropertyToJestConfig)(host, (0, path_1.join)(options.projectRoot, 'jest.config.ts'), 'globalTeardown', (0, path_1.join)((0, devkit_1.offsetFromRoot)(options.projectRoot), stopLocalRegistryPath));
|
|
83
86
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
84
|
-
const
|
|
87
|
+
const e2eTarget = project.targets.e2e;
|
|
85
88
|
project.targets.e2e = {
|
|
86
|
-
...
|
|
89
|
+
...e2eTarget,
|
|
87
90
|
dependsOn: [`^build`],
|
|
88
91
|
options: {
|
|
89
|
-
...
|
|
92
|
+
...e2eTarget.options,
|
|
90
93
|
runInBand: true,
|
|
91
94
|
},
|
|
92
95
|
};
|
|
93
|
-
// remove the jest build target
|
|
94
|
-
delete project.targets.test;
|
|
95
96
|
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
96
97
|
return jestTask;
|
|
97
98
|
}
|
|
@@ -105,11 +106,13 @@ async function addLintingToApplication(tree, options) {
|
|
|
105
106
|
unitTestRunner: 'jest',
|
|
106
107
|
skipFormat: true,
|
|
107
108
|
setParserOptionsProject: false,
|
|
109
|
+
addPlugin: options.addPlugin,
|
|
108
110
|
});
|
|
109
111
|
return lintTask;
|
|
110
112
|
}
|
|
111
113
|
async function e2eProjectGenerator(host, schema) {
|
|
112
114
|
return await e2eProjectGeneratorInternal(host, {
|
|
115
|
+
addPlugin: false,
|
|
113
116
|
projectNameAndRootFormat: 'derived',
|
|
114
117
|
...schema,
|
|
115
118
|
});
|
|
@@ -10,7 +10,7 @@ async function pluginLintCheckGenerator(host, options) {
|
|
|
10
10
|
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
11
11
|
const packageJson = (0, devkit_1.readJson)(host, (0, devkit_1.joinPathFragments)(project.root, 'package.json'));
|
|
12
12
|
// This rule is eslint **only**
|
|
13
|
-
if (projectIsEsLintEnabled(project)) {
|
|
13
|
+
if (projectIsEsLintEnabled(host, project)) {
|
|
14
14
|
updateRootEslintConfig(host);
|
|
15
15
|
updateProjectEslintConfig(host, project, packageJson);
|
|
16
16
|
updateProjectTarget(host, options, packageJson);
|
|
@@ -18,12 +18,6 @@ async function pluginLintCheckGenerator(host, options) {
|
|
|
18
18
|
if (host.exists('.vscode')) {
|
|
19
19
|
setupVsCodeLintingForJsonFiles(host);
|
|
20
20
|
}
|
|
21
|
-
// Project contains migrations.json
|
|
22
|
-
const migrationsPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
|
|
23
|
-
if (migrationsPath &&
|
|
24
|
-
host.exists((0, devkit_1.joinPathFragments)(project.root, migrationsPath))) {
|
|
25
|
-
addMigrationJsonChecks(host, options, packageJson);
|
|
26
|
-
}
|
|
27
21
|
}
|
|
28
22
|
else {
|
|
29
23
|
devkit_1.logger.error(`${logger_1.NX_PREFIX} plugin lint checks can only be added to plugins which use eslint for linting`);
|
|
@@ -35,10 +29,10 @@ async function pluginLintCheckGenerator(host, options) {
|
|
|
35
29
|
exports.default = pluginLintCheckGenerator;
|
|
36
30
|
function addMigrationJsonChecks(host, options, packageJson) {
|
|
37
31
|
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
38
|
-
if (!projectIsEsLintEnabled(projectConfiguration)) {
|
|
32
|
+
if (!projectIsEsLintEnabled(host, projectConfiguration)) {
|
|
39
33
|
return;
|
|
40
34
|
}
|
|
41
|
-
const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration);
|
|
35
|
+
const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration) ?? [];
|
|
42
36
|
const relativeMigrationsJsonPath = (0, package_json_1.readNxMigrateConfig)(packageJson).migrations;
|
|
43
37
|
if (!relativeMigrationsJsonPath) {
|
|
44
38
|
return;
|
|
@@ -107,6 +101,7 @@ function updateProjectEslintConfig(host, options, packageJson) {
|
|
|
107
101
|
packageJson.executors,
|
|
108
102
|
packageJson.schematics,
|
|
109
103
|
packageJson.builders,
|
|
104
|
+
(0, package_json_1.readNxMigrateConfig)(packageJson).migrations,
|
|
110
105
|
].filter((f) => !!f);
|
|
111
106
|
const parser = (0, flat_config_1.useFlatConfig)(host)
|
|
112
107
|
? { languageOptions: { parser: 'jsonc-eslint-parser' } }
|
|
@@ -181,8 +176,8 @@ function setupVsCodeLintingForJsonFiles(host) {
|
|
|
181
176
|
}
|
|
182
177
|
(0, devkit_1.writeJson)(host, '.vscode/settings.json', existing);
|
|
183
178
|
}
|
|
184
|
-
function projectIsEsLintEnabled(project) {
|
|
185
|
-
return !!
|
|
179
|
+
function projectIsEsLintEnabled(tree, project) {
|
|
180
|
+
return !!(0, eslint_file_1.findEslintFile)(tree, project.root);
|
|
186
181
|
}
|
|
187
182
|
function getEsLintOptions(project) {
|
|
188
183
|
return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nx/eslint:lint' ||
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.migrationGeneratorInternal = exports.migrationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const path_1 = require("path");
|
|
6
7
|
const generator_1 = require("../lint-checks/generator");
|
|
7
8
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
8
9
|
const versions_1 = require("../../utils/versions");
|
|
9
10
|
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
10
|
-
const path_1 = require("path");
|
|
11
11
|
async function normalizeOptions(tree, options) {
|
|
12
12
|
let name;
|
|
13
13
|
if (options.name) {
|