diff --git a/docs/generated/manifests/menus.json b/docs/generated/manifests/menus.json index 8f3fb2d28b032..9c7e822ce0cb8 100644 --- a/docs/generated/manifests/menus.json +++ b/docs/generated/manifests/menus.json @@ -4647,17 +4647,17 @@ "disableCollapsible": false }, { - "id": "cypress-e2e-configuration", - "path": "/packages/cypress/generators/cypress-e2e-configuration", - "name": "cypress-e2e-configuration", + "id": "configuration", + "path": "/packages/cypress/generators/configuration", + "name": "configuration", "children": [], "isExternal": false, "disableCollapsible": false }, { - "id": "cypress-component-configuration", - "path": "/packages/cypress/generators/cypress-component-configuration", - "name": "cypress-component-configuration", + "id": "component-configuration", + "path": "/packages/cypress/generators/component-configuration", + "name": "component-configuration", "children": [], "isExternal": false, "disableCollapsible": false diff --git a/docs/generated/manifests/packages.json b/docs/generated/manifests/packages.json index cf9da9f004552..ab397134b52de 100644 --- a/docs/generated/manifests/packages.json +++ b/docs/generated/manifests/packages.json @@ -483,22 +483,22 @@ "path": "/packages/cypress/generators/cypress-project", "type": "generator" }, - "/packages/cypress/generators/cypress-e2e-configuration": { + "/packages/cypress/generators/configuration": { "description": "Add a Cypress E2E Configuration to an existing project.", - "file": "generated/packages/cypress/generators/cypress-e2e-configuration.json", + "file": "generated/packages/cypress/generators/configuration.json", "hidden": false, - "name": "cypress-e2e-configuration", - "originalFilePath": "/packages/cypress/src/generators/cypress-e2e-configuration/schema.json", - "path": "/packages/cypress/generators/cypress-e2e-configuration", + "name": "configuration", + "originalFilePath": "/packages/cypress/src/generators/configuration/schema.json", + "path": "/packages/cypress/generators/configuration", "type": "generator" }, - "/packages/cypress/generators/cypress-component-configuration": { + "/packages/cypress/generators/component-configuration": { "description": "Set up Cypress Component Test for a project", - "file": "generated/packages/cypress/generators/cypress-component-configuration.json", + "file": "generated/packages/cypress/generators/component-configuration.json", "hidden": true, - "name": "cypress-component-configuration", - "originalFilePath": "/packages/cypress/src/generators/cypress-component-configuration/schema.json", - "path": "/packages/cypress/generators/cypress-component-configuration", + "name": "component-configuration", + "originalFilePath": "/packages/cypress/src/generators/component-configuration/schema.json", + "path": "/packages/cypress/generators/component-configuration", "type": "generator" }, "/packages/cypress/generators/migrate-to-cypress-11": { diff --git a/docs/generated/packages-metadata.json b/docs/generated/packages-metadata.json index 6efa02fb1bf79..176350597fcc7 100644 --- a/docs/generated/packages-metadata.json +++ b/docs/generated/packages-metadata.json @@ -477,20 +477,20 @@ }, { "description": "Add a Cypress E2E Configuration to an existing project.", - "file": "generated/packages/cypress/generators/cypress-e2e-configuration.json", + "file": "generated/packages/cypress/generators/configuration.json", "hidden": false, - "name": "cypress-e2e-configuration", - "originalFilePath": "/packages/cypress/src/generators/cypress-e2e-configuration/schema.json", - "path": "cypress/generators/cypress-e2e-configuration", + "name": "configuration", + "originalFilePath": "/packages/cypress/src/generators/configuration/schema.json", + "path": "cypress/generators/configuration", "type": "generator" }, { "description": "Set up Cypress Component Test for a project", - "file": "generated/packages/cypress/generators/cypress-component-configuration.json", + "file": "generated/packages/cypress/generators/component-configuration.json", "hidden": true, - "name": "cypress-component-configuration", - "originalFilePath": "/packages/cypress/src/generators/cypress-component-configuration/schema.json", - "path": "cypress/generators/cypress-component-configuration", + "name": "component-configuration", + "originalFilePath": "/packages/cypress/src/generators/component-configuration/schema.json", + "path": "cypress/generators/component-configuration", "type": "generator" }, { diff --git a/docs/generated/packages/cypress/generators/component-configuration.json b/docs/generated/packages/cypress/generators/component-configuration.json new file mode 100644 index 0000000000000..6fc62deecec01 --- /dev/null +++ b/docs/generated/packages/cypress/generators/component-configuration.json @@ -0,0 +1,47 @@ +{ + "name": "component-configuration", + "aliases": ["cypress-component-configuration"], + "factory": "./src/generators/component-configuration/component-configuration", + "schema": { + "$schema": "http://json-schema.org/schema", + "$id": "NxCypressComponentConfiguration", + "cli": "nx", + "title": "Set up Cypress component testing for a project", + "description": "Set up Cypress component test for a project.", + "type": "object", + "examples": [ + { + "command": "nx g @nx/cypress:component-configuration --project=my-cool-lib ", + "description": "Add cypress component testing to an existing project named my-cool-lib" + } + ], + "properties": { + "project": { + "type": "string", + "description": "The name of the project to add cypress component testing to", + "$default": { "$source": "projectName" }, + "x-prompt": "What project should we add Cypress component testing to?" + }, + "bundler": { + "description": "The Cypress bundler to use.", + "type": "string", + "enum": ["vite", "webpack"], + "x-prompt": "Which Cypress bundler do you want to use for the dev-server?", + "default": "webpack" + }, + "directory": { + "type": "string", + "description": "A directory where the project is placed relative from the project root", + "default": "cypress" + } + }, + "required": ["project"], + "examplesFile": "This is a framework-agnostic generator for adding component testing to a project.\n\n```bash\nnx g cypress-component-configuration --project=my-cool-project\n```\n\nRunning this generator, adds the required files to the specified project without any configurations for Cypress. It's best to use the framework specific generator, instead `cypress-component-configuration` directly\n\n- [React component testing](/packages/react/generators/cypress-component-configuration)\n- [Angular component testing](/packages/angular/generators/cypress-component-configuration)\n\nA new `component-test` target will be added to the specified project.\n\n```bash\nnx g component-test my-cool-project\n```\n\nRead more about [Cypress Component Testing](/cypress/cypress-component-testing)\n", + "presets": [] + }, + "description": "Set up Cypress Component Test for a project", + "hidden": true, + "implementation": "/packages/cypress/src/generators/component-configuration/component-configuration.ts", + "path": "/packages/cypress/src/generators/component-configuration/schema.json", + "type": "generator" +} diff --git a/docs/generated/packages/cypress/generators/configuration.json b/docs/generated/packages/cypress/generators/configuration.json new file mode 100644 index 0000000000000..d9b209b8a9398 --- /dev/null +++ b/docs/generated/packages/cypress/generators/configuration.json @@ -0,0 +1,95 @@ +{ + "name": "configuration", + "aliases": ["cypress-e2e-configuration", "e2e", "e2e-config"], + "factory": "./src/generators/configuration/configuration", + "schema": { + "$schema": "http://json-schema.org/schema", + "$id": "NxCypressE2EConfigGenerator", + "cli": "nx", + "title": "Add a Cypress Configuration.", + "description": "Add a Cypress configuration to an existing project.", + "type": "object", + "properties": { + "project": { + "type": "string", + "description": "The project to add a Cypress configuration to", + "$default": { "$source": "projectName" }, + "x-priority": "important", + "x-prompt": "What project do you want to add Cypress to?" + }, + "devServerTarget": { + "type": "string", + "description": "A devServerTarget,':[:], that will be used to run tests against. This is usually the app this project will be used in. Pass --baseUrl if you wish to not use a devServerTarget.", + "x-priority": "important" + }, + "port": { + "oneOf": [ + { "type": "string", "enum": ["cypress-auto"] }, + { "type": "number" } + ], + "description": "Set the 'port' option on the e2e target. It's recommend to set a different port so you can run tests e2e targets in parallel. Most dev servers support using '0' to automatically find a free port. The value 'cypress-auto' can be used if the underlying dev server does not support automatically finding a free port.", + "x-priority": "important" + }, + "baseUrl": { + "type": "string", + "description": "The address (with the port) which your application is running on. If you wish to start your application when running the e2e target, then use --devServerTarget instead." + }, + "directory": { + "type": "string", + "description": "A directory where the project is placed relative from the project root", + "x-priority": "important", + "default": "cypress" + }, + "linter": { + "description": "The tool to use for running lint checks.", + "type": "string", + "enum": ["eslint", "none"], + "default": "eslint" + }, + "js": { + "description": "Generate JavaScript files rather than TypeScript files.", + "type": "boolean", + "default": false + }, + "skipFormat": { + "description": "Skip formatting files.", + "type": "boolean", + "default": false, + "x-priority": "internal" + }, + "setParserOptionsProject": { + "type": "boolean", + "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.", + "default": false + }, + "skipPackageJson": { + "type": "boolean", + "default": false, + "description": "Do not add dependencies to `package.json`.", + "x-priority": "internal" + }, + "rootProject": { + "description": "Create a application at the root of the workspace", + "type": "boolean", + "default": false, + "hidden": true, + "x-priority": "internal" + }, + "bundler": { + "description": "The Cypress bundler to use.", + "type": "string", + "enum": ["vite", "webpack", "none"], + "x-prompt": "Which Cypress bundler do you want to use?", + "default": "webpack" + } + }, + "required": ["project"], + "examplesFile": "This is a generator to add a cypress e2e configuration to an existing project.\n\n```bash\nnx g @nx/cypress:configuration --project=my-cool-project --devServerTarget=some-app:serve\n```\n\nRunning this generator, adds the required files to run cypress tests for a project,\nMainly a `cypress.config.ts` file and default files in the `/cypress/` directory.\nTests will be located in `/cypress/e2e/*` by default.\n\nYou can customize the directory used via the `--directory` flag, the value is relative to the project root.\n\nFor example if you wanted to place the files inside an `e2e` folder\n\n```bash\nnx g @nx/cypress:configuration --project=my-cool-project --devServerTarget=some-app:serve --directory=e2e\n```\n\nProviding a `--devServerTarget` is optional if you provide a `--baseUrl` or the project you're adding the configuration to has a `serve` target already.\nOtherwise, a `--devServerTarget` is recommend for the `@nx/cypress:cypress` executor to spin up the dev server for you automatically when needed.\n\n## Feature Based Testing\n\nThis generator helps in creating feature based e2e/integration testing setups where you can place the feature tests in the same project as the feature library.\nThis differs from creating a separate e2e project that contained all tests for an application which can easily cause more tests to run than is strictly necessary.\n\nTake the following workspace where the `feature-cart` project is affected.\n\n{% graph height=\"450px\" %}\n\n```json\n{\n \"projects\": [\n {\n \"type\": \"app\",\n \"name\": \"fancy-app\",\n \"data\": {\n \"tags\": []\n }\n },\n {\n \"type\": \"app\",\n \"name\": \"fancy-app-e2e\",\n \"data\": {\n \"tags\": []\n }\n },\n {\n \"type\": \"lib\",\n \"name\": \"feature-user\",\n \"data\": {\n \"tags\": []\n }\n },\n {\n \"type\": \"lib\",\n \"name\": \"feature-dashboard\",\n \"data\": {\n \"tags\": []\n }\n },\n {\n \"type\": \"lib\",\n \"name\": \"feature-cart\",\n \"data\": {\n \"tags\": []\n }\n }\n ],\n \"groupByFolder\": false,\n \"workspaceLayout\": {\n \"appsDir\": \"apps\",\n \"libsDir\": \"libs\"\n },\n \"dependencies\": {\n \"fancy-app\": [\n {\n \"target\": \"feature-user\",\n \"source\": \"fancy-app\",\n \"type\": \"static\"\n },\n {\n \"target\": \"feature-cart\",\n \"source\": \"fancy-app\",\n \"type\": \"static\"\n }\n ],\n \"fancy-app-e2e\": [\n {\n \"target\": \"fancy-app\",\n \"source\": \"fancy-app-e2e\",\n \"type\": \"implicit\"\n }\n ],\n \"feature-user\": [\n {\n \"target\": \"feature-dashboard\",\n \"source\": \"feature-user\",\n \"type\": \"direct\"\n }\n ],\n \"feature-cart\": [],\n \"feature-dashboard\": []\n },\n \"affectedProjectIds\": [\"feature-cart\", \"fancy-app\", \"fancy-app-e2e\"]\n}\n```\n\n{% /graph %}\n\nIn this case, if tests for the all the `feature-*` projects where contained in the `fancy-app-e2e` project, then all of those features will be tested in the app, when only the `feature-cart` tests need to run.\n\nRunning these e2e/integration tests more often than they should results in longer CI times.\n\nBrining those e2e test closer to each feature can result is lowering CI times since we don't need to test those features if they did not change.\n\nBuilding this way leaves the `fancy-app-e2e` for mostly smoke type testing instead of more in-depth feature testing.\n\nUsing the `@nx/cypress:configuration` generator can help you accomplish this in your workspace.\n\n```bash\nnx g @nx/cypress:configuration --project=feature-cart --devServerTarget=fancy-app:serve\nnx g @nx/cypress:configuration --project=feature-user --devServerTarget=fancy-app:serve\nnx g @nx/cypress:configuration --project=feature-dashboard --devServerTarget=fancy-app:serve\n```\n\nEach project will now get their own `e2e` target, where the feature project is only concerned with itself. This allows for more focused tests without worrying about forcing unrelated tests to also run.\n\nIt's important to remember that these feature tests are still going to be leveraging the same app to run the tests against so if you plan to run in parallel, you can leverage using a file server and the ability for `@nx/cypress:cypress` executor to pass through a port or find a free port to allow running tests in parallel. Read more [about the --port flag](/packages/cypress/executors/cypress#port)\n", + "presets": [] + }, + "description": "Add a Cypress E2E Configuration to an existing project.", + "implementation": "/packages/cypress/src/generators/configuration/configuration.ts", + "hidden": false, + "path": "/packages/cypress/src/generators/configuration/schema.json", + "type": "generator" +} diff --git a/docs/shared/reference/sitemap.md b/docs/shared/reference/sitemap.md index d1a8b24fcdd01..bcf99cf1a0a1d 100644 --- a/docs/shared/reference/sitemap.md +++ b/docs/shared/reference/sitemap.md @@ -330,8 +330,8 @@ - [generators](/packages/cypress/generators) - [init](/packages/cypress/generators/init) - [cypress-project](/packages/cypress/generators/cypress-project) - - [cypress-e2e-configuration](/packages/cypress/generators/cypress-e2e-configuration) - - [cypress-component-configuration](/packages/cypress/generators/cypress-component-configuration) + - [configuration](/packages/cypress/generators/configuration) + - [component-configuration](/packages/cypress/generators/component-configuration) - [migrate-to-cypress-11](/packages/cypress/generators/migrate-to-cypress-11) - [detox](/packages/detox) - [documents](/packages/detox/documents) diff --git a/nx-dev/nx-dev/redirect-rules.js b/nx-dev/nx-dev/redirect-rules.js index 5f52ad21c4e6a..f3c66b863c569 100644 --- a/nx-dev/nx-dev/redirect-rules.js +++ b/nx-dev/nx-dev/redirect-rules.js @@ -144,6 +144,10 @@ const schemaUrls = { '/react-native/start': '/packages/react-native/executors/start', '/react-native/storybook': '/packages/react-native/executors/storybook', '/react-native/sync-deps': '/packages/react-native/executors/sync-deps', + '/packages/cypress/generators/cypress-e2e-configuration': + '/packages/cypress/generators/configuration', + '/packages/cypress/generators/cypress-component-configuration': + '/packages/cypress/generators/component-configuration', '/packages/nx-plugin/generators/executor': '/packages/plugin/generators/executor', '/packages/nx-plugin/generators/migration': diff --git a/packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts b/packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts index cf1afd3bf9d41..7a38051ffa144 100644 --- a/packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts +++ b/packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts @@ -1,4 +1,4 @@ -import { cypressComponentConfiguration as baseCyCTConfig } from '@nx/cypress'; +import { componentConfigurationGenerator as baseCyCTConfig } from '@nx/cypress'; import { addDefaultCTConfig, addMountDefinition, diff --git a/packages/cypress/docs/cypress-e2e-config-examples.md b/packages/cypress/docs/cypress-e2e-config-examples.md index 4472ebaf40512..60c535aabf4ba 100644 --- a/packages/cypress/docs/cypress-e2e-config-examples.md +++ b/packages/cypress/docs/cypress-e2e-config-examples.md @@ -1,7 +1,7 @@ This is a generator to add a cypress e2e configuration to an existing project. ```bash -nx g cypress-e2e-configuration --project=my-cool-project --devServerTarget=some-app:serve +nx g @nx/cypress:configuration --project=my-cool-project --devServerTarget=some-app:serve ``` Running this generator, adds the required files to run cypress tests for a project, @@ -13,7 +13,7 @@ You can customize the directory used via the `--directory` flag, the value is re For example if you wanted to place the files inside an `e2e` folder ```bash -nx g cypress-e2e-configuration --project=my-cool-project --devServerTarget=some-app:serve --directory=e2e +nx g @nx/cypress:configuration --project=my-cool-project --devServerTarget=some-app:serve --directory=e2e ``` Providing a `--devServerTarget` is optional if you provide a `--baseUrl` or the project you're adding the configuration to has a `serve` target already. @@ -116,12 +116,12 @@ Brining those e2e test closer to each feature can result is lowering CI times si Building this way leaves the `fancy-app-e2e` for mostly smoke type testing instead of more in-depth feature testing. -Using the `cypress-e2e-configuration` generator can help you accomplish this in your workspace. +Using the `@nx/cypress:configuration` generator can help you accomplish this in your workspace. ```bash -nx g cypress-e2e-configuration --project=feature-cart --devServerTarget=fancy-app:serve -nx g cypress-e2e-configuration --project=feature-user --devServerTarget=fancy-app:serve -nx g cypress-e2e-configuration --project=feature-dashboard --devServerTarget=fancy-app:serve +nx g @nx/cypress:configuration --project=feature-cart --devServerTarget=fancy-app:serve +nx g @nx/cypress:configuration --project=feature-user --devServerTarget=fancy-app:serve +nx g @nx/cypress:configuration --project=feature-dashboard --devServerTarget=fancy-app:serve ``` Each project will now get their own `e2e` target, where the feature project is only concerned with itself. This allows for more focused tests without worrying about forcing unrelated tests to also run. diff --git a/packages/cypress/generators.json b/packages/cypress/generators.json index a4763971eeb3d..873814a0e79f7 100644 --- a/packages/cypress/generators.json +++ b/packages/cypress/generators.json @@ -14,15 +14,16 @@ "schema": "./src/generators/cypress-project/schema.json", "description": "Add a Cypress E2E Project." }, - "cypress-e2e-configuration": { - "aliases": ["e2e", "e2e-config"], - "factory": "./src/generators/cypress-e2e-configuration/cypress-e2e-configuration#compat", - "schema": "./src/generators/cypress-e2e-configuration/schema.json", + "configuration": { + "aliases": ["cypress-e2e-configuration", "e2e", "e2e-config"], + "factory": "./src/generators/configuration/configuration#compat", + "schema": "./src/generators/configuration/schema.json", "description": "Add a Cypress E2E Configuration to an existing project." }, - "cypress-component-configuration": { - "factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration", - "schema": "./src/generators/cypress-component-configuration/schema.json", + "component-configuration": { + "aliases": ["cypress-component-configuration"], + "factory": "./src/generators/component-configuration/component-configuration#compat", + "schema": "./src/generators/component-configuration/schema.json", "description": "Set up Cypress Component Test for a project" }, "migrate-to-cypress-11": { @@ -45,15 +46,16 @@ "description": "Add a Cypress E2E Project.", "hidden": true }, - "cypress-e2e-configuration": { - "aliases": ["e2e", "e2e-config"], - "factory": "./src/generators/cypress-e2e-configuration/cypress-e2e-configuration", - "schema": "./src/generators/cypress-e2e-configuration/schema.json", + "configuration": { + "aliases": ["cypress-e2e-configuration", "e2e", "e2e-config"], + "factory": "./src/generators/configuration/configuration", + "schema": "./src/generators/configuration/schema.json", "description": "Add a Cypress E2E Configuration to an existing project." }, - "cypress-component-configuration": { - "factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration", - "schema": "./src/generators/cypress-component-configuration/schema.json", + "component-configuration": { + "aliases": ["cypress-component-configuration"], + "factory": "./src/generators/component-configuration/component-configuration", + "schema": "./src/generators/component-configuration/schema.json", "description": "Set up Cypress Component Test for a project", "hidden": true }, diff --git a/packages/cypress/index.ts b/packages/cypress/index.ts index bab858ef04a73..5b62a7fb29870 100644 --- a/packages/cypress/index.ts +++ b/packages/cypress/index.ts @@ -1,6 +1,13 @@ +import { configurationGenerator } from './src/generators/configuration/configuration'; +import { componentConfigurationGenerator } from './src/generators/component-configuration/component-configuration'; +export { configurationGenerator, componentConfigurationGenerator }; + +// Maintain backwards compatibility with the old names in case community plugins used them. +/** @deprecated Use `configurationGenerator` instead. */ +export const cypressComponentConfiguration = componentConfigurationGenerator; + +export { configurationGenerator as cypressE2EConfigurationGenerator }; export { cypressProjectGenerator } from './src/generators/cypress-project/cypress-project'; export { cypressInitGenerator } from './src/generators/init/init'; export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint'; -export { cypressComponentConfiguration } from './src/generators/cypress-component-configuration/cypress-component-configuration'; export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11'; -export { cypressE2EConfigurationGenerator } from './src/generators/cypress-e2e-configuration/cypress-e2e-configuration'; diff --git a/packages/cypress/src/generators/cypress-component-configuration/__snapshots__/cypress-component-configuration.spec.ts.snap b/packages/cypress/src/generators/component-configuration/__snapshots__/component-configuration.spec.ts.snap similarity index 100% rename from packages/cypress/src/generators/cypress-component-configuration/__snapshots__/cypress-component-configuration.spec.ts.snap rename to packages/cypress/src/generators/component-configuration/__snapshots__/component-configuration.spec.ts.snap diff --git a/packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.spec.ts b/packages/cypress/src/generators/component-configuration/component-configuration.spec.ts similarity index 95% rename from packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.spec.ts rename to packages/cypress/src/generators/component-configuration/component-configuration.spec.ts index 22e47c4525612..83d91822038f2 100644 --- a/packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.spec.ts +++ b/packages/cypress/src/generators/component-configuration/component-configuration.spec.ts @@ -9,7 +9,7 @@ import { } from '@nx/devkit'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { installedCypressVersion } from '../../utils/cypress-version'; -import { cypressComponentConfiguration } from './cypress-component-configuration'; +import { componentConfigurationGenerator } from './component-configuration'; jest.mock('../../utils/cypress-version'); let projectConfig: ProjectConfiguration = { @@ -97,7 +97,7 @@ describe('Cypress Component Configuration', () => { it('should add base cypress component testing config', async () => { mockedInstalledCypressVersion.mockReturnValue(10); - await cypressComponentConfiguration(tree, { + await componentConfigurationGenerator(tree, { project: 'cool-lib', skipFormat: false, }); @@ -157,7 +157,7 @@ describe('Cypress Component Configuration', () => { }; return json; }); - await cypressComponentConfiguration(tree, { + await componentConfigurationGenerator(tree, { project: 'cool-lib', skipFormat: false, }); @@ -202,7 +202,7 @@ export default defineConfig({ }, }); - await cypressComponentConfiguration(tree, { + await componentConfigurationGenerator(tree, { project: 'cool-lib', skipFormat: true, }); @@ -219,7 +219,7 @@ export default defineConfig({ mockedInstalledCypressVersion.mockReturnValue(9); await expect( async () => - await cypressComponentConfiguration(tree, { + await componentConfigurationGenerator(tree, { project: 'cool-lib', skipFormat: true, }) diff --git a/packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.ts b/packages/cypress/src/generators/component-configuration/component-configuration.ts similarity index 96% rename from packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.ts rename to packages/cypress/src/generators/component-configuration/component-configuration.ts index 67e4979d9ba4d..e05e14d9897da 100644 --- a/packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.ts +++ b/packages/cypress/src/generators/component-configuration/component-configuration.ts @@ -11,6 +11,7 @@ import { updateJson, updateProjectConfiguration, updateNxJson, + convertNxGenerator, } from '@nx/devkit'; import { installedCypressVersion } from '../../utils/cypress-version'; @@ -25,7 +26,7 @@ import { addBaseCypressSetup } from '../base-setup/base-setup'; type NormalizeCTOptions = ReturnType; -export async function cypressComponentConfiguration( +export async function componentConfigurationGenerator( tree: Tree, options: CypressComponentConfigurationSchema ) { @@ -216,4 +217,5 @@ export function updateTsConfigForComponentTesting( } } -export default cypressComponentConfiguration; +export default componentConfigurationGenerator; +export const compat = convertNxGenerator(componentConfigurationGenerator); diff --git a/packages/cypress/src/generators/cypress-component-configuration/files/__directory__/support/component-index.html b/packages/cypress/src/generators/component-configuration/files/__directory__/support/component-index.html similarity index 100% rename from packages/cypress/src/generators/cypress-component-configuration/files/__directory__/support/component-index.html rename to packages/cypress/src/generators/component-configuration/files/__directory__/support/component-index.html diff --git a/packages/cypress/src/generators/cypress-component-configuration/files/__directory__/support/component.ts__ext__ b/packages/cypress/src/generators/component-configuration/files/__directory__/support/component.ts__ext__ similarity index 100% rename from packages/cypress/src/generators/cypress-component-configuration/files/__directory__/support/component.ts__ext__ rename to packages/cypress/src/generators/component-configuration/files/__directory__/support/component.ts__ext__ diff --git a/packages/cypress/src/generators/cypress-component-configuration/schema.d.ts b/packages/cypress/src/generators/component-configuration/schema.d.ts similarity index 100% rename from packages/cypress/src/generators/cypress-component-configuration/schema.d.ts rename to packages/cypress/src/generators/component-configuration/schema.d.ts diff --git a/packages/cypress/src/generators/cypress-component-configuration/schema.json b/packages/cypress/src/generators/component-configuration/schema.json similarity index 92% rename from packages/cypress/src/generators/cypress-component-configuration/schema.json rename to packages/cypress/src/generators/component-configuration/schema.json index b59a72ed17578..a34fbc9d8cbd0 100644 --- a/packages/cypress/src/generators/cypress-component-configuration/schema.json +++ b/packages/cypress/src/generators/component-configuration/schema.json @@ -7,7 +7,7 @@ "type": "object", "examples": [ { - "command": "nx g @nx/cypress:cypress-component-configuration --project=my-cool-lib ", + "command": "nx g @nx/cypress:component-configuration --project=my-cool-lib ", "description": "Add cypress component testing to an existing project named my-cool-lib" } ], diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/__snapshots__/cypress-e2e-configuration.spec.ts.snap b/packages/cypress/src/generators/configuration/__snapshots__/configuration.spec.ts.snap similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/__snapshots__/cypress-e2e-configuration.spec.ts.snap rename to packages/cypress/src/generators/configuration/__snapshots__/configuration.spec.ts.snap diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.spec.ts b/packages/cypress/src/generators/configuration/configuration.spec.ts similarity index 99% rename from packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.spec.ts rename to packages/cypress/src/generators/configuration/configuration.spec.ts index 0bc0554a6b8bb..db32cf1cba186 100644 --- a/packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.spec.ts +++ b/packages/cypress/src/generators/configuration/configuration.spec.ts @@ -7,7 +7,7 @@ import { updateProjectConfiguration, } from '@nx/devkit'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; -import { cypressE2EConfigurationGenerator } from './cypress-e2e-configuration'; +import cypressE2EConfigurationGenerator from './configuration'; import { installedCypressVersion } from '../../utils/cypress-version'; diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.ts b/packages/cypress/src/generators/configuration/configuration.ts similarity index 97% rename from packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.ts rename to packages/cypress/src/generators/configuration/configuration.ts index a20defaebea5d..a4aa0f33bfbe0 100644 --- a/packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.ts +++ b/packages/cypress/src/generators/configuration/configuration.ts @@ -39,7 +39,7 @@ export interface CypressE2EConfigSchema { } type NormalizedSchema = ReturnType; -export async function cypressE2EConfigurationGenerator( +export async function configurationGenerator( tree: Tree, options: CypressE2EConfigSchema ) { @@ -220,5 +220,5 @@ function addTarget(tree: Tree, opts: NormalizedSchema) { updateProjectConfiguration(tree, opts.project, projectConfig); } -export default cypressE2EConfigurationGenerator; -export const compat = convertNxGenerator(cypressE2EConfigurationGenerator); +export default configurationGenerator; +export const compat = convertNxGenerator(configurationGenerator); diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v10/__directory__/e2e/app.cy.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v10/__directory__/e2e/app.cy.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v10/__directory__/e2e/app.cy.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v10/__directory__/e2e/app.cy.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v10/__directory__/support/app.po.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v10/__directory__/support/app.po.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v10/__directory__/support/app.po.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v10/__directory__/support/app.po.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v10/__directory__/support/e2e.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v10/__directory__/support/e2e.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v10/__directory__/support/e2e.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v10/__directory__/support/e2e.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/fixtures/example.json__tmpl__ b/packages/cypress/src/generators/configuration/files/v9/__directory__/fixtures/example.json__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/fixtures/example.json__tmpl__ rename to packages/cypress/src/generators/configuration/files/v9/__directory__/fixtures/example.json__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/plugins/index.js b/packages/cypress/src/generators/configuration/files/v9/__directory__/plugins/index.js similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/plugins/index.js rename to packages/cypress/src/generators/configuration/files/v9/__directory__/plugins/index.js diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/support/app.po.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v9/__directory__/support/app.po.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/support/app.po.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v9/__directory__/support/app.po.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/support/commands.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v9/__directory__/support/commands.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/support/commands.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v9/__directory__/support/commands.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/support/index.ts__tmpl__ b/packages/cypress/src/generators/configuration/files/v9/__directory__/support/index.ts__tmpl__ similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/support/index.ts__tmpl__ rename to packages/cypress/src/generators/configuration/files/v9/__directory__/support/index.ts__tmpl__ diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/tsconfig.json b/packages/cypress/src/generators/configuration/files/v9/__directory__/tsconfig.json similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/__directory__/tsconfig.json rename to packages/cypress/src/generators/configuration/files/v9/__directory__/tsconfig.json diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/files/v9/cypress.json b/packages/cypress/src/generators/configuration/files/v9/cypress.json similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/files/v9/cypress.json rename to packages/cypress/src/generators/configuration/files/v9/cypress.json diff --git a/packages/cypress/src/generators/cypress-e2e-configuration/schema.json b/packages/cypress/src/generators/configuration/schema.json similarity index 100% rename from packages/cypress/src/generators/cypress-e2e-configuration/schema.json rename to packages/cypress/src/generators/configuration/schema.json diff --git a/packages/cypress/src/migrations/update-15-0-0/update-cy-mount-usage.spec.ts b/packages/cypress/src/migrations/update-15-0-0/update-cy-mount-usage.spec.ts index 4da3c27a3654f..6c98abd0266d0 100644 --- a/packages/cypress/src/migrations/update-15-0-0/update-cy-mount-usage.spec.ts +++ b/packages/cypress/src/migrations/update-15-0-0/update-cy-mount-usage.spec.ts @@ -11,7 +11,7 @@ import { updateCyMountUsage, } from './update-cy-mount-usage'; import { libraryGenerator } from '@nx/js'; -import { cypressComponentConfiguration } from '../../generators/cypress-component-configuration/cypress-component-configuration'; +import cypressComponentConfiguration from '../../generators/component-configuration/component-configuration'; jest.mock('../../utils/cypress-version'); // nested code imports graph from the repo, which might have innacurate graph version diff --git a/packages/cypress/src/migrations/update-15-1-0/cypress-11.spec.ts b/packages/cypress/src/migrations/update-15-1-0/cypress-11.spec.ts index 8b3f953b39e15..02980e019e526 100644 --- a/packages/cypress/src/migrations/update-15-1-0/cypress-11.spec.ts +++ b/packages/cypress/src/migrations/update-15-1-0/cypress-11.spec.ts @@ -9,7 +9,7 @@ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import updateToCypress11 from './cypress-11'; import { installedCypressVersion } from '../../utils/cypress-version'; jest.mock('../../utils/cypress-version'); -import { cypressComponentConfiguration } from '../../generators/cypress-component-configuration/cypress-component-configuration'; +import cypressComponentConfiguration from '../../generators/component-configuration/component-configuration'; describe('Cypress 11 Migration', () => { let tree: Tree; diff --git a/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts b/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts index a018c34d63b2c..eb6e972ded842 100644 --- a/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts +++ b/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts @@ -22,7 +22,7 @@ export async function cypressComponentConfiguration( ) { const tasks: GeneratorCallback[] = []; - const { cypressComponentConfiguration: baseCyCtConfig } = ensurePackage< + const { componentConfigurationGenerator: baseCyCtConfig } = ensurePackage< typeof import('@nx/cypress') >('@nx/cypress', nxVersion); tasks.push( diff --git a/packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts b/packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts index dd2b75a552a79..761ca09d80d13 100644 --- a/packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts +++ b/packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts @@ -18,7 +18,7 @@ export async function cypressComponentConfigGenerator( tree: Tree, options: CypressComponentConfigurationSchema ) { - const { cypressComponentConfiguration: baseCyCtConfig } = ensurePackage< + const { componentConfigurationGenerator: baseCyCtConfig } = ensurePackage< typeof import('@nx/cypress') >('@nx/cypress', nxVersion); const projectConfig = readProjectConfiguration(tree, options.project);