nx/packages/cypress/src/migrations/update-17-2-0/add-nx-cypress-plugin.ts
2023-11-14 08:13:38 -05:00

25 lines
796 B
TypeScript

import { formatFiles, getProjects, Tree } from '@nx/devkit';
import { createNodes } from '../../plugins/plugin';
import { createProjectRootMappingsFromProjectConfigurations } from 'nx/src/project-graph/utils/find-project-for-path';
import { replaceProjectConfigurationsWithPlugin } from '@nx/devkit/src/utils/replace-project-configuration-with-plugin';
export default async function update(tree: Tree) {
const proj = Object.fromEntries(getProjects(tree).entries());
const rootMappings = createProjectRootMappingsFromProjectConfigurations(proj);
await replaceProjectConfigurationsWithPlugin(
tree,
rootMappings,
'@nx/cypress/plugin',
createNodes,
{
targetName: 'e2e',
componentTestingTargetName: 'component-test',
}
);
await formatFiles(tree);
}