Skip to content

Commit 5875a23

Browse files
Coly010FrozenPandaz
authored andcommitted
fix(core): addPlugin should not conflict on project.json targets (#23264)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> ## Current Behavior <!-- This is the behavior we have today --> Calculating conflicts in target names does not consider if the project.json defined targets will actually be impacted by the plugin that wants to be added creating false negatives ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Calculating conflicts should be more accurate ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #22476 (cherry picked from commit 85c8916)
1 parent e5a0a07 commit 5875a23

File tree

59 files changed

+291
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+291
-242
lines changed

packages/angular/src/generators/application/application.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2+
13
import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
24
import type { Tree } from '@nx/devkit';
35
import * as devkit from '@nx/devkit';

packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2+
13
import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
24
import {
35
DependencyType,

packages/angular/src/generators/host/host.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import { readJson, updateJson } from '@nx/devkit';
44
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';

packages/angular/src/generators/library/library.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import {
44
getProjects,

packages/angular/src/generators/ngrx-feature-store/ngrx-feature-store.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import type { Tree } from '@nx/devkit';
44
import { readJson } from '@nx/devkit';

packages/angular/src/generators/ngrx-root-store/ngrx-root-store.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import type { Tree } from '@nx/devkit';
44
import { readJson } from '@nx/devkit';

packages/angular/src/generators/ngrx/ngrx.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import type { Tree } from '@nx/devkit';
44
import * as devkit from '@nx/devkit';

packages/angular/src/generators/remote/remote.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import { E2eTestRunner } from '../../utils/test-runners';
44
import {

packages/angular/src/generators/scam-to-standalone/scam-to-standalone.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
44
import scamGenerator from '../scam/scam';

packages/angular/src/generators/setup-mf/setup-mf.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import {
44
readJson,

packages/angular/src/generators/setup-ssr/setup-ssr.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import {
44
NxJsonConfiguration,

packages/angular/src/generators/stories/stories-app.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
44
import type { Tree } from '@nx/devkit';

packages/angular/src/generators/storybook-configuration/storybook-configuration.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2+
13
import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
24
import type { Tree } from '@nx/devkit';
35
import { readJson, writeJson } from '@nx/devkit';

packages/angular/src/generators/web-worker/web-worker.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import type { Tree } from '@nx/devkit';
44
import * as devkit from '@nx/devkit';

packages/angular/src/migrations/update-14-8-0/rename-webpack-server.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import { readJson, updateJson } from '@nx/devkit';
44
import * as devkit from '@nx/devkit';

packages/angular/src/migrations/update-15-2-0/remove-browserlist-config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import type { Tree } from '@nx/devkit';
44
import * as devkit from '@nx/devkit';

packages/angular/src/migrations/update-15-2-0/update-typescript-target.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import {
44
readJson,

packages/angular/src/migrations/update-15-2-0/update-workspace-config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nx/src/internal-testing-utils/mock-project-graph';
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
22

33
import * as devkit from '@nx/devkit';
44
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';

packages/angular/src/migrations/update-15-9-0/update-testing-tsconfig.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2+
13
import {
24
ProjectGraph,
35
readJson,

packages/cypress/src/generators/configuration/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function configurationGeneratorInternal(
8080
})
8181
);
8282
} else if (opts.addPlugin) {
83-
await addPlugin(tree, projectGraph, false);
83+
await addPlugin(tree, false);
8484
}
8585

8686
const nxJson = readNxJson(tree);

packages/cypress/src/generators/init/init.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
import {
22
addDependenciesToPackageJson,
3-
createProjectGraphAsync,
43
formatFiles,
54
GeneratorCallback,
6-
ProjectGraph,
75
readNxJson,
86
removeDependenciesFromPackageJson,
97
runTasksInSerial,
108
Tree,
119
updateNxJson,
1210
} from '@nx/devkit';
13-
import {
14-
addPlugin as _addPlugin,
15-
generateCombinations,
16-
} from '@nx/devkit/src/utils/add-plugin';
11+
import { addPlugin as _addPlugin } from '@nx/devkit/src/utils/add-plugin';
1712
import { createNodes } from '../../plugins/plugin';
1813
import { cypressVersion, nxVersion } from '../../utils/versions';
1914
import { Schema } from './schema';
20-
import { CypressPluginOptions } from '../../plugins/plugin';
2115

2216
function setupE2ETargetDefaults(tree: Tree) {
2317
const nxJson = readNxJson(tree);
@@ -60,14 +54,9 @@ function updateDependencies(tree: Tree, options: Schema) {
6054
return runTasksInSerial(...tasks);
6155
}
6256

63-
export function addPlugin(
64-
tree: Tree,
65-
graph: ProjectGraph,
66-
updatePackageScripts: boolean
67-
) {
57+
export function addPlugin(tree: Tree, updatePackageScripts: boolean) {
6858
return _addPlugin(
6959
tree,
70-
graph,
7160
'@nx/cypress/plugin',
7261
createNodes,
7362
{
@@ -118,11 +107,7 @@ export async function cypressInitGeneratorInternal(
118107
nxJson.useInferencePlugins !== false;
119108

120109
if (options.addPlugin) {
121-
await addPlugin(
122-
tree,
123-
await createProjectGraphAsync(),
124-
options.updatePackageScripts
125-
);
110+
await addPlugin(tree, options.updatePackageScripts);
126111
} else {
127112
setupE2ETargetDefaults(tree);
128113
}

packages/detox/src/generators/init/init.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import {
22
addDependenciesToPackageJson,
3-
createProjectGraphAsync,
43
formatFiles,
54
GeneratorCallback,
65
readNxJson,
76
removeDependenciesFromPackageJson,
87
runTasksInSerial,
98
Tree,
109
} from '@nx/devkit';
11-
import {
12-
addPlugin,
13-
generateCombinations,
14-
} from '@nx/devkit/src/utils/add-plugin';
15-
import { createNodes, DetoxPluginOptions } from '../../plugins/plugin';
10+
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
11+
import { createNodes } from '../../plugins/plugin';
1612
import { detoxVersion, nxVersion } from '../../utils/versions';
1713
import { Schema } from './schema';
1814

@@ -38,7 +34,6 @@ export async function detoxInitGeneratorInternal(host: Tree, schema: Schema) {
3834
if (schema.addPlugin) {
3935
await addPlugin(
4036
host,
41-
await createProjectGraphAsync(),
4237
'@nx/detox/plugin',
4338
createNodes,
4439
{

0 commit comments

Comments
 (0)