Skip to content

Commit

Permalink
fix(core): addPlugin should not conflict on project.json targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed May 9, 2024
1 parent 8f705e3 commit 8dfebc5
Show file tree
Hide file tree
Showing 35 changed files with 264 additions and 229 deletions.
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, projectGraph, false);
await addPlugin(tree, false);
}

const nxJson = readNxJson(tree);
Expand Down
21 changes: 3 additions & 18 deletions packages/cypress/src/generators/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
import {
addDependenciesToPackageJson,
createProjectGraphAsync,
formatFiles,
GeneratorCallback,
ProjectGraph,
readNxJson,
removeDependenciesFromPackageJson,
runTasksInSerial,
Tree,
updateNxJson,
} from '@nx/devkit';
import {
addPlugin as _addPlugin,
generateCombinations,
} from '@nx/devkit/src/utils/add-plugin';
import { addPlugin as _addPlugin } 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 @@ -60,14 +54,9 @@ function updateDependencies(tree: Tree, options: Schema) {
return runTasksInSerial(...tasks);
}

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

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

Expand All @@ -38,7 +34,6 @@ 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 8dfebc5

Please sign in to comment.