Skip to content

Commit

Permalink
Revert "fix(core): addPlugin should not conflict on project.json targ… (
Browse files Browse the repository at this point in the history
#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 #
  • Loading branch information
FrozenPandaz authored May 14, 2024
1 parent e28d872 commit cfadd7d
Show file tree
Hide file tree
Showing 58 changed files with 239 additions and 291 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';

import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
import type { Tree } from '@nx/devkit';
import * as devkit from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';

import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
import {
DependencyType,
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/host/host.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import { readJson, updateJson } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import {
getProjects,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import type { Tree } from '@nx/devkit';
import { readJson } from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import type { Tree } from '@nx/devkit';
import { readJson } from '@nx/devkit';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/ngrx/ngrx.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import type { Tree } from '@nx/devkit';
import * as devkit from '@nx/devkit';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/remote/remote.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import { E2eTestRunner } from '../../utils/test-runners';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import scamGenerator from '../scam/scam';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/setup-mf/setup-mf.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import {
readJson,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import {
NxJsonConfiguration,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
import type { Tree } from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';

import { installedCypressVersion } from '@nx/cypress/src/utils/cypress-version';
import type { Tree } from '@nx/devkit';
import { readJson, writeJson } from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import type { Tree } from '@nx/devkit';
import * as devkit from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import { readJson, updateJson } from '@nx/devkit';
import * as devkit from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import type { Tree } from '@nx/devkit';
import * as devkit from '@nx/devkit';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import {
readJson,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';
import 'nx/src/internal-testing-utils/mock-project-graph';

import * as devkit from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'nx/src/internal-testing-utils/mock-load-nx-plugin';

import {
ProjectGraph,
readJson,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export async function configurationGeneratorInternal(
})
);
} else if (opts.addPlugin) {
await addPlugin(tree, false);
await addPlugin(tree, projectGraph, false);
}

const nxJson = readNxJson(tree);
Expand Down
21 changes: 18 additions & 3 deletions packages/cypress/src/generators/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
formatFiles,
GeneratorCallback,
ProjectGraph,
readNxJson,
removeDependenciesFromPackageJson,
runTasksInSerial,
Tree,
updateNxJson,
} from '@nx/devkit';
import { addPlugin as _addPlugin } from '@nx/devkit/src/utils/add-plugin';
import {
addPlugin as _addPlugin,
generateCombinations,
} from '@nx/devkit/src/utils/add-plugin';
import { createNodes } from '../../plugins/plugin';
import { cypressVersion, nxVersion } from '../../utils/versions';
import { Schema } from './schema';
import { CypressPluginOptions } from '../../plugins/plugin';

function setupE2ETargetDefaults(tree: Tree) {
const nxJson = readNxJson(tree);
Expand Down Expand Up @@ -54,9 +60,14 @@ function updateDependencies(tree: Tree, options: Schema) {
return runTasksInSerial(...tasks);
}

export function addPlugin(tree: Tree, updatePackageScripts: boolean) {
export function addPlugin(
tree: Tree,
graph: ProjectGraph,
updatePackageScripts: boolean
) {
return _addPlugin(
tree,
graph,
'@nx/cypress/plugin',
createNodes,
{
Expand Down Expand Up @@ -107,7 +118,11 @@ export async function cypressInitGeneratorInternal(
nxJson.useInferencePlugins !== false;

if (options.addPlugin) {
await addPlugin(tree, options.updatePackageScripts);
await addPlugin(
tree,
await createProjectGraphAsync(),
options.updatePackageScripts
);
} else {
setupE2ETargetDefaults(tree);
}
Expand Down
9 changes: 7 additions & 2 deletions packages/detox/src/generators/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
formatFiles,
GeneratorCallback,
readNxJson,
removeDependenciesFromPackageJson,
runTasksInSerial,
Tree,
} from '@nx/devkit';
import { addPlugin } from '@nx/devkit/src/utils/add-plugin';
import { createNodes } from '../../plugins/plugin';
import {
addPlugin,
generateCombinations,
} from '@nx/devkit/src/utils/add-plugin';
import { createNodes, DetoxPluginOptions } from '../../plugins/plugin';
import { detoxVersion, nxVersion } from '../../utils/versions';
import { Schema } from './schema';

Expand All @@ -34,6 +38,7 @@ export async function detoxInitGeneratorInternal(host: Tree, schema: Schema) {
if (schema.addPlugin) {
await addPlugin(
host,
await createProjectGraphAsync(),
'@nx/detox/plugin',
createNodes,
{
Expand Down
Loading

0 comments on commit cfadd7d

Please sign in to comment.