@nx/plugin 24.0.0-beta.3 → 24.0.0-beta.4
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.
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Schema as EsLintExecutorOptions } from '@nx/eslint/internal';
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
3
2
|
import { PluginLintChecksGeneratorSchema } from './schema';
|
|
4
3
|
import { PackageJson } from '@nx/devkit/internal';
|
|
5
4
|
export default function pluginLintCheckGenerator(host: Tree, options: PluginLintChecksGeneratorSchema): Promise<void>;
|
|
6
5
|
export declare function addMigrationJsonChecks(host: Tree, options: PluginLintChecksGeneratorSchema, packageJson: PackageJson): void;
|
|
7
|
-
export declare function getEsLintOptions(project: ProjectConfiguration): [target: string, configuration: TargetConfiguration<EsLintExecutorOptions>];
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = pluginLintCheckGenerator;
|
|
4
4
|
exports.addMigrationJsonChecks = addMigrationJsonChecks;
|
|
5
|
-
exports.getEsLintOptions = getEsLintOptions;
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const internal_1 = require("@nx/eslint/internal");
|
|
8
7
|
const internal_2 = require("@nx/devkit/internal");
|
|
@@ -13,7 +12,6 @@ async function pluginLintCheckGenerator(host, options) {
|
|
|
13
12
|
if (projectIsEsLintEnabled(host, project)) {
|
|
14
13
|
updateRootEslintConfig(host);
|
|
15
14
|
updateProjectEslintConfig(host, project, packageJson);
|
|
16
|
-
updateProjectTarget(host, options, packageJson);
|
|
17
15
|
// Project is setup for vscode
|
|
18
16
|
if (host.exists('.vscode')) {
|
|
19
17
|
setupVsCodeLintingForJsonFiles(host);
|
|
@@ -31,19 +29,10 @@ function addMigrationJsonChecks(host, options, packageJson) {
|
|
|
31
29
|
if (!projectIsEsLintEnabled(host, projectConfiguration)) {
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
34
|
-
const [eslintTarget, eslintTargetConfiguration] = getEsLintOptions(projectConfiguration) ?? [];
|
|
35
32
|
const relativeMigrationsJsonPath = (0, internal_2.readNxMigrateConfig)(packageJson).migrations;
|
|
36
33
|
if (!relativeMigrationsJsonPath) {
|
|
37
34
|
return;
|
|
38
35
|
}
|
|
39
|
-
const migrationsJsonPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, relativeMigrationsJsonPath);
|
|
40
|
-
// Add path to lintFilePatterns if different than default "{projectRoot}"
|
|
41
|
-
if (eslintTarget &&
|
|
42
|
-
eslintTargetConfiguration.options?.lintFilePatterns &&
|
|
43
|
-
!eslintTargetConfiguration.options.lintFilePatterns.includes(migrationsJsonPath)) {
|
|
44
|
-
eslintTargetConfiguration.options.lintFilePatterns.push(migrationsJsonPath);
|
|
45
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
|
|
46
|
-
}
|
|
47
36
|
// Update project level eslintrc
|
|
48
37
|
(0, internal_1.updateOverrideInLintConfig)(host, projectConfiguration.root, (o) => Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') ||
|
|
49
38
|
Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), (o) => {
|
|
@@ -65,57 +54,6 @@ function formatFilesEntries(tree, files) {
|
|
|
65
54
|
});
|
|
66
55
|
return filesAfter;
|
|
67
56
|
}
|
|
68
|
-
function updateProjectTarget(host, options, packageJson) {
|
|
69
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, options.projectName);
|
|
70
|
-
if (!project.targets) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
for (const [target, configuration] of Object.entries(project.targets)) {
|
|
74
|
-
if (configuration.executor === '@nx/eslint:lint' &&
|
|
75
|
-
// only add patterns if there are already hardcoded ones
|
|
76
|
-
configuration.options?.lintFilePatterns) {
|
|
77
|
-
const opts = configuration.options ?? {};
|
|
78
|
-
opts.lintFilePatterns ??= [];
|
|
79
|
-
if (packageJson.generators) {
|
|
80
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.generators));
|
|
81
|
-
}
|
|
82
|
-
if (packageJson.schematics &&
|
|
83
|
-
packageJson.schematics !== packageJson.generators) {
|
|
84
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.schematics));
|
|
85
|
-
}
|
|
86
|
-
if (packageJson.executors) {
|
|
87
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.executors));
|
|
88
|
-
}
|
|
89
|
-
if (packageJson.builders &&
|
|
90
|
-
packageJson.builders !== packageJson.executors) {
|
|
91
|
-
opts.lintFilePatterns.push((0, devkit_1.joinPathFragments)(project.root, packageJson.builders));
|
|
92
|
-
}
|
|
93
|
-
opts.lintFilePatterns.push(`${project.root}/package.json`);
|
|
94
|
-
opts.lintFilePatterns = [...new Set(opts.lintFilePatterns)];
|
|
95
|
-
project.targets[target].options = opts;
|
|
96
|
-
// Plugin checks read schema/implementation files which may live in the
|
|
97
|
-
// project's build outputs (and migration prompt files copied as assets).
|
|
98
|
-
// Ensure lint runs after build and includes the relevant build outputs
|
|
99
|
-
// as inputs so the sandbox allows the reads and the cache invalidates
|
|
100
|
-
// when those outputs change.
|
|
101
|
-
const targetConfig = project.targets[target];
|
|
102
|
-
const dependsOn = new Set(targetConfig.dependsOn ?? []);
|
|
103
|
-
dependsOn.add('build');
|
|
104
|
-
targetConfig.dependsOn = Array.from(dependsOn);
|
|
105
|
-
const inputs = targetConfig.inputs ?? ['...'];
|
|
106
|
-
const hasDependentOutputs = inputs.some((input) => typeof input === 'object' &&
|
|
107
|
-
input !== null &&
|
|
108
|
-
'dependentTasksOutputFiles' in input);
|
|
109
|
-
if (!hasDependentOutputs) {
|
|
110
|
-
inputs.push({
|
|
111
|
-
dependentTasksOutputFiles: '**/*.{json,d.ts,js,md}',
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
targetConfig.inputs = inputs;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
(0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
|
|
118
|
-
}
|
|
119
57
|
function updateProjectEslintConfig(host, options, packageJson) {
|
|
120
58
|
if ((0, internal_1.isEslintConfigSupported)(host, options.root)) {
|
|
121
59
|
const lookup = (o) => Object.keys(o.rules ?? {}).includes('@nx/nx-plugin-checks') ||
|
|
@@ -204,8 +142,3 @@ function setupVsCodeLintingForJsonFiles(host) {
|
|
|
204
142
|
function projectIsEsLintEnabled(tree, project) {
|
|
205
143
|
return !!(0, internal_1.findEslintFile)(tree, project.root);
|
|
206
144
|
}
|
|
207
|
-
function getEsLintOptions(project) {
|
|
208
|
-
return Object.entries(project.targets || {}).find(([, x]) => x.executor === '@nx/eslint:lint' ||
|
|
209
|
-
x.executor === '@nx/linter:eslint' ||
|
|
210
|
-
x.executor === '@nrwl/linter:eslint');
|
|
211
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/plugin",
|
|
3
|
-
"version": "24.0.0-beta.
|
|
3
|
+
"version": "24.0.0-beta.4",
|
|
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": {
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/devkit": "24.0.0-beta.
|
|
40
|
-
"@nx/jest": "24.0.0-beta.
|
|
41
|
-
"@nx/js": "24.0.0-beta.
|
|
42
|
-
"@nx/eslint": "24.0.0-beta.
|
|
39
|
+
"@nx/devkit": "24.0.0-beta.4",
|
|
40
|
+
"@nx/jest": "24.0.0-beta.4",
|
|
41
|
+
"@nx/js": "24.0.0-beta.4",
|
|
42
|
+
"@nx/eslint": "24.0.0-beta.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"nx": "24.0.0-beta.
|
|
45
|
+
"nx": "24.0.0-beta.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@nx/vitest": "24.0.0-beta.
|
|
48
|
+
"@nx/vitest": "24.0.0-beta.4"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"@nx/vitest": {
|