Skip to content

Commit 2cae242

Browse files
committed
Revert "fix(core): addPlugin should not conflict on project.json targ… (#23391)
…ets (#23264)" This reverts commit 85c8916 <!-- 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 --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes # (cherry picked from commit cfadd7d)
1 parent 860d0b1 commit 2cae242

File tree

58 files changed

+239
-291
lines changed

Some content is hidden

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

58 files changed

+239
-291
lines changed

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

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

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2-
31
import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
42
import {
53
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2-
31
import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
42
import type { Tree } from '@nx/devkit';
53
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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-load-nx-plugin';
1+
import 'nx/src/internal-testing-utils/mock-project-graph';
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: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
2-
31
import {
42
ProjectGraph,
53
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, false);
83+
await addPlugin(tree, projectGraph, false);
8484
}
8585

8686
const nxJson = readNxJson(tree);

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import {
22
addDependenciesToPackageJson,
3+
createProjectGraphAsync,
34
formatFiles,
45
GeneratorCallback,
6+
ProjectGraph,
57
readNxJson,
68
removeDependenciesFromPackageJson,
79
runTasksInSerial,
810
Tree,
911
updateNxJson,
1012
} from '@nx/devkit';
11-
import { addPlugin as _addPlugin } from '@nx/devkit/src/utils/add-plugin';
13+
import {
14+
addPlugin as _addPlugin,
15+
generateCombinations,
16+
} from '@nx/devkit/src/utils/add-plugin';
1217
import { createNodes } from '../../plugins/plugin';
1318
import { cypressVersion, nxVersion } from '../../utils/versions';
1419
import { Schema } from './schema';
20+
import { CypressPluginOptions } from '../../plugins/plugin';
1521

1622
function setupE2ETargetDefaults(tree: Tree) {
1723
const nxJson = readNxJson(tree);
@@ -54,9 +60,14 @@ function updateDependencies(tree: Tree, options: Schema) {
5460
return runTasksInSerial(...tasks);
5561
}
5662

57-
export function addPlugin(tree: Tree, updatePackageScripts: boolean) {
63+
export function addPlugin(
64+
tree: Tree,
65+
graph: ProjectGraph,
66+
updatePackageScripts: boolean
67+
) {
5868
return _addPlugin(
5969
tree,
70+
graph,
6071
'@nx/cypress/plugin',
6172
createNodes,
6273
{
@@ -107,7 +118,11 @@ export async function cypressInitGeneratorInternal(
107118
nxJson.useInferencePlugins !== false;
108119

109120
if (options.addPlugin) {
110-
await addPlugin(tree, options.updatePackageScripts);
121+
await addPlugin(
122+
tree,
123+
await createProjectGraphAsync(),
124+
options.updatePackageScripts
125+
);
111126
} else {
112127
setupE2ETargetDefaults(tree);
113128
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import {
22
addDependenciesToPackageJson,
3+
createProjectGraphAsync,
34
formatFiles,
45
GeneratorCallback,
56
readNxJson,
67
removeDependenciesFromPackageJson,
78
runTasksInSerial,
89
Tree,
910
} from '@nx/devkit';
10-
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
11-
import { createNodes } from '../../plugins/plugin';
11+
import {
12+
addPlugin,
13+
generateCombinations,
14+
} from '@nx/devkit/src/utils/add-plugin';
15+
import { createNodes, DetoxPluginOptions } from '../../plugins/plugin';
1216
import { detoxVersion, nxVersion } from '../../utils/versions';
1317
import { Schema } from './schema';
1418

@@ -34,6 +38,7 @@ export async function detoxInitGeneratorInternal(host: Tree, schema: Schema) {
3438
if (schema.addPlugin) {
3539
await addPlugin(
3640
host,
41+
await createProjectGraphAsync(),
3742
'@nx/detox/plugin',
3843
createNodes,
3944
{

0 commit comments

Comments
 (0)