fix(angular): do not force explicit targets for separate e2e projects (#21865)
This commit is contained in:
parent
fe17fc3287
commit
ca3965fcf3
@ -4,6 +4,7 @@ import {
|
|||||||
cleanupProject,
|
cleanupProject,
|
||||||
killProcessAndPorts,
|
killProcessAndPorts,
|
||||||
newProject,
|
newProject,
|
||||||
|
readFile,
|
||||||
readJson,
|
readJson,
|
||||||
runCLI,
|
runCLI,
|
||||||
runCommandUntil,
|
runCommandUntil,
|
||||||
@ -376,10 +377,22 @@ describe('Angular Module Federation', () => {
|
|||||||
const buildRemoteOutput = runCLI(`build ${remote}`);
|
const buildRemoteOutput = runCLI(`build ${remote}`);
|
||||||
expect(buildRemoteOutput).toContain('Successfully ran target build');
|
expect(buildRemoteOutput).toContain('Successfully ran target build');
|
||||||
|
|
||||||
|
// increase default timeout for the Cypress web server, MF apps can take longer to start
|
||||||
|
const cypressConfig = readFile(`${host}-e2e/cypress.config.ts`);
|
||||||
|
updateFile(
|
||||||
|
`${host}-e2e/cypress.config.ts`,
|
||||||
|
cypressConfig.replace(
|
||||||
|
`nxE2EPreset(__filename, {`,
|
||||||
|
`nxE2EPreset(__filename, {
|
||||||
|
webServerConfig: {
|
||||||
|
timeout: 30000,
|
||||||
|
},`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (runE2ETests('cypress')) {
|
if (runE2ETests('cypress')) {
|
||||||
const e2eProcess = await runCommandUntil(
|
const e2eProcess = await runCommandUntil(`e2e ${host}-e2e`, (output) =>
|
||||||
`e2e ${host}-e2e --no-watch`,
|
output.includes('All specs passed!')
|
||||||
(output) => output.includes('All specs passed!')
|
|
||||||
);
|
);
|
||||||
await killProcessAndPorts(e2eProcess.pid, hostPort, hostPort + 1);
|
await killProcessAndPorts(e2eProcess.pid, hostPort, hostPort + 1);
|
||||||
}
|
}
|
||||||
@ -468,10 +481,22 @@ describe('Angular Module Federation', () => {
|
|||||||
const buildRemoteOutput = runCLI(`build ${remote}`);
|
const buildRemoteOutput = runCLI(`build ${remote}`);
|
||||||
expect(buildRemoteOutput).toContain('Successfully ran target build');
|
expect(buildRemoteOutput).toContain('Successfully ran target build');
|
||||||
|
|
||||||
|
// increase default timeout for the Cypress web server, MF apps can take longer to start
|
||||||
|
const cypressConfig = readFile(`${host}-e2e/cypress.config.ts`);
|
||||||
|
updateFile(
|
||||||
|
`${host}-e2e/cypress.config.ts`,
|
||||||
|
cypressConfig.replace(
|
||||||
|
`nxE2EPreset(__filename, {`,
|
||||||
|
`nxE2EPreset(__filename, {
|
||||||
|
webServerConfig: {
|
||||||
|
timeout: 30000,
|
||||||
|
},`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (runE2ETests('cypress')) {
|
if (runE2ETests('cypress')) {
|
||||||
const e2eProcess = await runCommandUntil(
|
const e2eProcess = await runCommandUntil(`e2e ${host}-e2e`, (output) =>
|
||||||
`e2e ${host}-e2e --no-watch`,
|
output.includes('All specs passed!')
|
||||||
(output) => output.includes('All specs passed!')
|
|
||||||
);
|
);
|
||||||
await killProcessAndPorts(e2eProcess.pid, hostPort, hostPort + 1);
|
await killProcessAndPorts(e2eProcess.pid, hostPort, hostPort + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import { ProjectConfiguration, readNxJson, Tree } from '@nx/devkit';
|
|
||||||
import {
|
import {
|
||||||
|
ProjectConfiguration,
|
||||||
|
Tree,
|
||||||
addProjectConfiguration,
|
addProjectConfiguration,
|
||||||
readJson,
|
readJson,
|
||||||
readProjectConfiguration,
|
|
||||||
} from '@nx/devkit';
|
} from '@nx/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
||||||
import * as linter from '@nx/eslint';
|
import * as linter from '@nx/eslint';
|
||||||
@ -32,7 +32,6 @@ describe('addLinting generator', () => {
|
|||||||
projectName: appProjectName,
|
projectName: appProjectName,
|
||||||
projectRoot: appProjectRoot,
|
projectRoot: appProjectRoot,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
addPlugin: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(linter.lintProjectGenerator).toHaveBeenCalled();
|
expect(linter.lintProjectGenerator).toHaveBeenCalled();
|
||||||
@ -44,7 +43,6 @@ describe('addLinting generator', () => {
|
|||||||
projectName: appProjectName,
|
projectName: appProjectName,
|
||||||
projectRoot: appProjectRoot,
|
projectRoot: appProjectRoot,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
addPlugin: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { devDependencies } = readJson(tree, 'package.json');
|
const { devDependencies } = readJson(tree, 'package.json');
|
||||||
@ -61,31 +59,9 @@ describe('addLinting generator', () => {
|
|||||||
projectName: appProjectName,
|
projectName: appProjectName,
|
||||||
projectRoot: appProjectRoot,
|
projectRoot: appProjectRoot,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
addPlugin: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const eslintConfig = readJson(tree, `${appProjectRoot}/.eslintrc.json`);
|
const eslintConfig = readJson(tree, `${appProjectRoot}/.eslintrc.json`);
|
||||||
expect(eslintConfig).toMatchSnapshot();
|
expect(eslintConfig).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add @nx/eslint/plugin', async () => {
|
|
||||||
await addLintingGenerator(tree, {
|
|
||||||
prefix: 'myOrg',
|
|
||||||
projectName: appProjectName,
|
|
||||||
projectRoot: appProjectRoot,
|
|
||||||
skipFormat: true,
|
|
||||||
addPlugin: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const nxJson = readNxJson(tree);
|
|
||||||
expect(
|
|
||||||
nxJson.plugins.find((p) => {
|
|
||||||
if (typeof p === 'string') {
|
|
||||||
return p === '@nx/eslint/plugin';
|
|
||||||
} else {
|
|
||||||
return p.plugin === '@nx/eslint/plugin';
|
|
||||||
}
|
|
||||||
})
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -36,7 +36,7 @@ export async function addLintingGenerator(
|
|||||||
setParserOptionsProject: options.setParserOptionsProject,
|
setParserOptionsProject: options.setParserOptionsProject,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
rootProject: rootProject,
|
rootProject: rootProject,
|
||||||
addPlugin: options.addPlugin,
|
addPlugin: false,
|
||||||
addExplicitTargets: true,
|
addExplicitTargets: true,
|
||||||
});
|
});
|
||||||
tasks.push(lintTask);
|
tasks.push(lintTask);
|
||||||
|
|||||||
@ -6,6 +6,4 @@ export interface AddLintingGeneratorSchema {
|
|||||||
skipFormat?: boolean;
|
skipFormat?: boolean;
|
||||||
skipPackageJson?: boolean;
|
skipPackageJson?: boolean;
|
||||||
unitTestRunner?: string;
|
unitTestRunner?: string;
|
||||||
addPlugin?: boolean;
|
|
||||||
addExplicitTargets?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -314,27 +314,7 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh
|
|||||||
"root": "apps/my-dir/my-app-e2e",
|
"root": "apps/my-dir/my-app-e2e",
|
||||||
"sourceRoot": "apps/my-dir/my-app-e2e/src",
|
"sourceRoot": "apps/my-dir/my-app-e2e/src",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"targets": {
|
"targets": {},
|
||||||
"e2e": {
|
|
||||||
"configurations": {
|
|
||||||
"ci": {
|
|
||||||
"devServerTarget": "my-dir-my-app:serve-static",
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"devServerTarget": "my-dir-my-app:serve:production",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"executor": "@nx/cypress:cypress",
|
|
||||||
"options": {
|
|
||||||
"cypressConfig": "apps/my-dir/my-app-e2e/cypress.config.ts",
|
|
||||||
"devServerTarget": "my-dir-my-app:serve:development",
|
|
||||||
"testingType": "e2e",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"lint": {
|
|
||||||
"executor": "@nx/eslint:lint",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -533,27 +513,7 @@ exports[`app --project-name-and-root-format=derived should generate correctly wh
|
|||||||
"root": "apps/my-app-e2e",
|
"root": "apps/my-app-e2e",
|
||||||
"sourceRoot": "apps/my-app-e2e/src",
|
"sourceRoot": "apps/my-app-e2e/src",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"targets": {
|
"targets": {},
|
||||||
"e2e": {
|
|
||||||
"configurations": {
|
|
||||||
"ci": {
|
|
||||||
"devServerTarget": "my-app:serve-static",
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"devServerTarget": "my-app:serve:production",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"executor": "@nx/cypress:cypress",
|
|
||||||
"options": {
|
|
||||||
"cypressConfig": "apps/my-app-e2e/cypress.config.ts",
|
|
||||||
"devServerTarget": "my-app:serve:development",
|
|
||||||
"testingType": "e2e",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"lint": {
|
|
||||||
"executor": "@nx/eslint:lint",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -1047,27 +1007,7 @@ exports[`app nested should create project configs 2`] = `
|
|||||||
"root": "my-dir/my-app-e2e",
|
"root": "my-dir/my-app-e2e",
|
||||||
"sourceRoot": "my-dir/my-app-e2e/src",
|
"sourceRoot": "my-dir/my-app-e2e/src",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"targets": {
|
"targets": {},
|
||||||
"e2e": {
|
|
||||||
"configurations": {
|
|
||||||
"ci": {
|
|
||||||
"devServerTarget": "my-app:serve-static",
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"devServerTarget": "my-app:serve:production",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"executor": "@nx/cypress:cypress",
|
|
||||||
"options": {
|
|
||||||
"cypressConfig": "my-dir/my-app-e2e/cypress.config.ts",
|
|
||||||
"devServerTarget": "my-app:serve:development",
|
|
||||||
"testingType": "e2e",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"lint": {
|
|
||||||
"executor": "@nx/eslint:lint",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -1179,27 +1119,7 @@ exports[`app not nested should create project configs 2`] = `
|
|||||||
"root": "my-app-e2e",
|
"root": "my-app-e2e",
|
||||||
"sourceRoot": "my-app-e2e/src",
|
"sourceRoot": "my-app-e2e/src",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"targets": {
|
"targets": {},
|
||||||
"e2e": {
|
|
||||||
"configurations": {
|
|
||||||
"ci": {
|
|
||||||
"devServerTarget": "my-app:serve-static",
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"devServerTarget": "my-app:serve:production",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"executor": "@nx/cypress:cypress",
|
|
||||||
"options": {
|
|
||||||
"cypressConfig": "my-app-e2e/cypress.config.ts",
|
|
||||||
"devServerTarget": "my-app:serve:development",
|
|
||||||
"testingType": "e2e",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"lint": {
|
|
||||||
"executor": "@nx/eslint:lint",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,7 @@ import {
|
|||||||
import { generateTestApplication } from '../utils/testing';
|
import { generateTestApplication } from '../utils/testing';
|
||||||
import type { Schema } from './schema';
|
import type { Schema } from './schema';
|
||||||
|
|
||||||
// need to mock cypress otherwise it'll use the nx installed version from package.json
|
// need to mock cypress otherwise it'll use installed version in this repo's package.json
|
||||||
// which is v9 while we are testing for the new v10 version
|
|
||||||
jest.mock('@nx/cypress/src/utils/cypress-version');
|
jest.mock('@nx/cypress/src/utils/cypress-version');
|
||||||
jest.mock('enquirer');
|
jest.mock('enquirer');
|
||||||
jest.mock('@nx/devkit', () => {
|
jest.mock('@nx/devkit', () => {
|
||||||
@ -43,7 +42,7 @@ describe('app', () => {
|
|||||||
> = installedCypressVersion as never;
|
> = installedCypressVersion as never;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockedInstalledCypressVersion.mockReturnValue(10);
|
mockedInstalledCypressVersion.mockReturnValue(null);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
enquirer.prompt = jest
|
enquirer.prompt = jest
|
||||||
.fn()
|
.fn()
|
||||||
@ -530,7 +529,7 @@ describe('app', () => {
|
|||||||
|
|
||||||
describe('--linter', () => {
|
describe('--linter', () => {
|
||||||
describe('eslint', () => {
|
describe('eslint', () => {
|
||||||
it('should add lint target', async () => {
|
it('should add lint target to application', async () => {
|
||||||
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });
|
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });
|
||||||
expect(readProjectConfiguration(appTree, 'my-app').targets.lint)
|
expect(readProjectConfiguration(appTree, 'my-app').targets.lint)
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
@ -538,12 +537,40 @@ describe('app', () => {
|
|||||||
"executor": "@nx/eslint:lint",
|
"executor": "@nx/eslint:lint",
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
expect(readProjectConfiguration(appTree, 'my-app-e2e').targets.lint)
|
});
|
||||||
.toMatchInlineSnapshot(`
|
|
||||||
{
|
it('should add eslint plugin and no lint target to e2e project', async () => {
|
||||||
"executor": "@nx/eslint:lint",
|
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });
|
||||||
}
|
|
||||||
|
expect(readNxJson(appTree).plugins).toMatchInlineSnapshot(`
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"options": {
|
||||||
|
"componentTestingTargetName": "component-test",
|
||||||
|
"targetName": "e2e",
|
||||||
|
},
|
||||||
|
"plugin": "@nx/cypress/plugin",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"options": {
|
||||||
|
"targetName": "lint",
|
||||||
|
},
|
||||||
|
"plugin": "@nx/eslint/plugin",
|
||||||
|
},
|
||||||
|
]
|
||||||
`);
|
`);
|
||||||
|
expect(
|
||||||
|
readProjectConfiguration(appTree, 'my-app-e2e').targets.lint
|
||||||
|
).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not add eslint plugin when no e2e test runner', async () => {
|
||||||
|
await generateApp(appTree, 'my-app', {
|
||||||
|
linter: Linter.EsLint,
|
||||||
|
e2eTestRunner: E2eTestRunner.None,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(readNxJson(appTree).plugins).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add valid eslint JSON configuration which extends from Nx presets', async () => {
|
it('should add valid eslint JSON configuration which extends from Nx presets', async () => {
|
||||||
@ -1262,7 +1289,6 @@ async function generateApp(
|
|||||||
unitTestRunner: UnitTestRunner.Jest,
|
unitTestRunner: UnitTestRunner.Jest,
|
||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
standalone: false,
|
standalone: false,
|
||||||
addPlugin: false,
|
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,6 @@ export async function applicationGenerator(
|
|||||||
): Promise<GeneratorCallback> {
|
): Promise<GeneratorCallback> {
|
||||||
return await applicationGeneratorInternal(tree, {
|
return await applicationGeneratorInternal(tree, {
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'derived',
|
||||||
addPlugin: false,
|
|
||||||
...schema,
|
...schema,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,9 @@ import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
|
|||||||
import type { NormalizedSchema } from './normalized-schema';
|
import type { NormalizedSchema } from './normalized-schema';
|
||||||
|
|
||||||
export async function addE2e(tree: Tree, options: NormalizedSchema) {
|
export async function addE2e(tree: Tree, options: NormalizedSchema) {
|
||||||
|
// since e2e are separate projects, default to adding plugins
|
||||||
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false';
|
||||||
|
|
||||||
if (options.e2eTestRunner === 'cypress') {
|
if (options.e2eTestRunner === 'cypress') {
|
||||||
// TODO: This can call `@nx/web:static-config` generator when ready
|
// TODO: This can call `@nx/web:static-config` generator when ready
|
||||||
addFileServerTarget(tree, options, 'serve-static');
|
addFileServerTarget(tree, options, 'serve-static');
|
||||||
@ -34,8 +37,7 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
|
|||||||
devServerTarget: `${options.name}:serve:development`,
|
devServerTarget: `${options.name}:serve:development`,
|
||||||
baseUrl: 'http://localhost:4200',
|
baseUrl: 'http://localhost:4200',
|
||||||
rootProject: options.rootProject,
|
rootProject: options.rootProject,
|
||||||
addPlugin: false,
|
addPlugin,
|
||||||
addExplicitTargets: false, // since e2e is a separate project, use inferred targets
|
|
||||||
});
|
});
|
||||||
} else if (options.e2eTestRunner === 'playwright') {
|
} else if (options.e2eTestRunner === 'playwright') {
|
||||||
const { configurationGenerator: playwrightConfigurationGenerator } =
|
const { configurationGenerator: playwrightConfigurationGenerator } =
|
||||||
@ -63,7 +65,7 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
|
|||||||
}`,
|
}`,
|
||||||
webServerAddress: `http://localhost:${options.port ?? 4200}`,
|
webServerAddress: `http://localhost:${options.port ?? 4200}`,
|
||||||
rootProject: options.rootProject,
|
rootProject: options.rootProject,
|
||||||
addPlugin: false,
|
addPlugin,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,5 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
|
|||||||
skipPackageJson: options.skipPackageJson,
|
skipPackageJson: options.skipPackageJson,
|
||||||
unitTestRunner: options.unitTestRunner,
|
unitTestRunner: options.unitTestRunner,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
addPlugin: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,6 @@ export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
|
|||||||
projectRoot: options.appProjectRoot,
|
projectRoot: options.appProjectRoot,
|
||||||
skipPackageJson: options.skipPackageJson,
|
skipPackageJson: options.skipPackageJson,
|
||||||
strict: options.strict,
|
strict: options.strict,
|
||||||
addPlugin: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ export async function normalizeOptions(
|
|||||||
});
|
});
|
||||||
options.rootProject = appProjectRoot === '.';
|
options.rootProject = appProjectRoot === '.';
|
||||||
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
||||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
||||||
|
|
||||||
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
||||||
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
||||||
|
|||||||
@ -31,5 +31,4 @@ export interface Schema {
|
|||||||
minimal?: boolean;
|
minimal?: boolean;
|
||||||
bundler?: 'webpack' | 'esbuild';
|
bundler?: 'webpack' | 'esbuild';
|
||||||
ssr?: boolean;
|
ssr?: boolean;
|
||||||
addPlugin?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,6 @@ export function cypressComponentConfiguration(
|
|||||||
options: CypressComponentConfigSchema
|
options: CypressComponentConfigSchema
|
||||||
) {
|
) {
|
||||||
return cypressComponentConfigurationInternal(tree, {
|
return cypressComponentConfigurationInternal(tree, {
|
||||||
addPlugin: false,
|
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -46,8 +45,6 @@ export async function cypressComponentConfigurationInternal(
|
|||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: CypressComponentConfigSchema
|
options: CypressComponentConfigSchema
|
||||||
) {
|
) {
|
||||||
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
||||||
|
|
||||||
const projectConfig = readProjectConfiguration(tree, options.project);
|
const projectConfig = readProjectConfiguration(tree, options.project);
|
||||||
const installTask = await baseCyCTConfig(tree, {
|
const installTask = await baseCyCTConfig(tree, {
|
||||||
project: options.project,
|
project: options.project,
|
||||||
|
|||||||
@ -3,5 +3,4 @@ export interface CypressComponentConfigSchema {
|
|||||||
generateTests: boolean;
|
generateTests: boolean;
|
||||||
skipFormat?: boolean;
|
skipFormat?: boolean;
|
||||||
buildTarget?: string;
|
buildTarget?: string;
|
||||||
addPlugin?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,6 @@ export async function normalizeOptions(
|
|||||||
standaloneComponentName: `${
|
standaloneComponentName: `${
|
||||||
names(projectNames.projectSimpleName).className
|
names(projectNames.projectSimpleName).className
|
||||||
}Component`,
|
}Component`,
|
||||||
addPlugin: options.addPlugin ?? process.env.NX_ADD_PLUGINS === 'true',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -38,7 +38,6 @@ export interface NormalizedSchema {
|
|||||||
parsedTags: string[];
|
parsedTags: string[];
|
||||||
ngCliSchematicLibRoot: string;
|
ngCliSchematicLibRoot: string;
|
||||||
standaloneComponentName: string;
|
standaloneComponentName: string;
|
||||||
addPlugin?: boolean;
|
|
||||||
};
|
};
|
||||||
componentOptions: {
|
componentOptions: {
|
||||||
name: string;
|
name: string;
|
||||||
|
|||||||
@ -134,7 +134,6 @@ async function addUnitTestRunner(
|
|||||||
projectRoot: options.projectRoot,
|
projectRoot: options.projectRoot,
|
||||||
skipPackageJson: options.skipPackageJson,
|
skipPackageJson: options.skipPackageJson,
|
||||||
strict: options.strict,
|
strict: options.strict,
|
||||||
addPlugin: false,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -191,7 +191,7 @@ export async function updateRootEsLintConfig(
|
|||||||
unitTestRunner?: string
|
unitTestRunner?: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await lintInitGenerator(tree, {
|
await lintInitGenerator(tree, {
|
||||||
addPlugin: process.env.NX_ADD_PLUGINS === 'true',
|
addPlugin: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!existingEsLintConfig) {
|
if (!existingEsLintConfig) {
|
||||||
|
|||||||
@ -6,8 +6,6 @@ export async function generateStorybookConfiguration(
|
|||||||
tree: Tree,
|
tree: Tree,
|
||||||
options: StorybookConfigurationOptions
|
options: StorybookConfigurationOptions
|
||||||
): Promise<GeneratorCallback> {
|
): Promise<GeneratorCallback> {
|
||||||
const addPlugin = process.env.NX_ADD_PLUGINS === 'true';
|
|
||||||
|
|
||||||
const { configurationGenerator } = ensurePackage<
|
const { configurationGenerator } = ensurePackage<
|
||||||
typeof import('@nx/storybook')
|
typeof import('@nx/storybook')
|
||||||
>('@nx/storybook', nxVersion);
|
>('@nx/storybook', nxVersion);
|
||||||
@ -21,7 +19,7 @@ export async function generateStorybookConfiguration(
|
|||||||
interactionTests: options.interactionTests,
|
interactionTests: options.interactionTests,
|
||||||
configureStaticServe: options.configureStaticServe,
|
configureStaticServe: options.configureStaticServe,
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
addPlugin: addPlugin,
|
addPlugin: false,
|
||||||
addExplicitTargets: !addPlugin,
|
addExplicitTargets: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ export type AddJestOptions = {
|
|||||||
projectRoot: string;
|
projectRoot: string;
|
||||||
skipPackageJson: boolean;
|
skipPackageJson: boolean;
|
||||||
strict: boolean;
|
strict: boolean;
|
||||||
addPlugin?: boolean;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function addJest(
|
export async function addJest(
|
||||||
|
|||||||
@ -82,7 +82,6 @@ async function setup(tree: Tree, name: string) {
|
|||||||
skipPackageJson: true,
|
skipPackageJson: true,
|
||||||
projectNameAndRootFormat: 'derived',
|
projectNameAndRootFormat: 'derived',
|
||||||
skipFormat: true,
|
skipFormat: true,
|
||||||
addPlugin: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const projectConfig = readProjectConfiguration(tree, name);
|
const projectConfig = readProjectConfiguration(tree, name);
|
||||||
|
|||||||
@ -554,48 +554,6 @@ export default defineConfig({
|
|||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should support generating explicit targets', async () => {
|
|
||||||
mockedInstalledCypressVersion.mockReturnValue(undefined); // ensure init is called
|
|
||||||
addProject(tree, { name: 'explicit-lib', type: 'apps' });
|
|
||||||
addProject(tree, { name: 'inferred-lib', type: 'apps' });
|
|
||||||
|
|
||||||
await cypressE2EConfigurationGenerator(tree, {
|
|
||||||
project: 'explicit-lib',
|
|
||||||
baseUrl: 'http://localhost:4200',
|
|
||||||
addPlugin: true,
|
|
||||||
addExplicitTargets: true,
|
|
||||||
});
|
|
||||||
await cypressE2EConfigurationGenerator(tree, {
|
|
||||||
project: 'inferred-lib',
|
|
||||||
baseUrl: 'http://localhost:4200',
|
|
||||||
addPlugin: true,
|
|
||||||
addExplicitTargets: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(readProjectConfiguration(tree, 'explicit-lib').targets.e2e)
|
|
||||||
.toMatchInlineSnapshot(`
|
|
||||||
{
|
|
||||||
"configurations": {
|
|
||||||
"ci": {
|
|
||||||
"devServerTarget": "explicit-lib:serve-static",
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"devServerTarget": "explicit-lib:serve:production",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"executor": "@nx/cypress:cypress",
|
|
||||||
"options": {
|
|
||||||
"cypressConfig": "apps/explicit-lib/cypress.config.ts",
|
|
||||||
"devServerTarget": "explicit-lib:serve",
|
|
||||||
"testingType": "e2e",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
`);
|
|
||||||
expect(
|
|
||||||
readProjectConfiguration(tree, 'inferred-lib').targets.e2e
|
|
||||||
).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,6 @@ export interface CypressE2EConfigSchema {
|
|||||||
webServerCommands?: Record<string, string>;
|
webServerCommands?: Record<string, string>;
|
||||||
ciWebServerCommand?: string;
|
ciWebServerCommand?: string;
|
||||||
addPlugin?: boolean;
|
addPlugin?: boolean;
|
||||||
addExplicitTargets?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NormalizedSchema = ReturnType<typeof normalizeOptions>;
|
type NormalizedSchema = ReturnType<typeof normalizeOptions>;
|
||||||
@ -90,7 +89,7 @@ export async function configurationGeneratorInternal(
|
|||||||
);
|
);
|
||||||
|
|
||||||
await addFiles(tree, opts, projectGraph, hasPlugin);
|
await addFiles(tree, opts, projectGraph, hasPlugin);
|
||||||
if (!hasPlugin || options.addExplicitTargets) {
|
if (!hasPlugin) {
|
||||||
addTarget(tree, opts);
|
addTarget(tree, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +97,6 @@ export async function configurationGeneratorInternal(
|
|||||||
...opts,
|
...opts,
|
||||||
cypressDir: opts.directory,
|
cypressDir: opts.directory,
|
||||||
addPlugin: opts.addPlugin,
|
addPlugin: opts.addPlugin,
|
||||||
addExplicitTargets: opts.addExplicitTargets,
|
|
||||||
});
|
});
|
||||||
tasks.push(linterTask);
|
tasks.push(linterTask);
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,6 @@ export interface CyLinterOptions {
|
|||||||
**/
|
**/
|
||||||
overwriteExisting?: boolean;
|
overwriteExisting?: boolean;
|
||||||
addPlugin?: boolean;
|
addPlugin?: boolean;
|
||||||
addExplicitTargets?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function addLinterToCyProject(
|
export async function addLinterToCyProject(
|
||||||
@ -66,7 +65,6 @@ export async function addLinterToCyProject(
|
|||||||
skipPackageJson: options.skipPackageJson,
|
skipPackageJson: options.skipPackageJson,
|
||||||
rootProject: options.rootProject,
|
rootProject: options.rootProject,
|
||||||
addPlugin: options.addPlugin,
|
addPlugin: options.addPlugin,
|
||||||
addExplicitTargets: options.addExplicitTargets,
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -331,7 +331,6 @@ describe('app', () => {
|
|||||||
it('should configure proxy', async () => {
|
it('should configure proxy', async () => {
|
||||||
await angularApplicationGenerator(tree, {
|
await angularApplicationGenerator(tree, {
|
||||||
name: 'my-frontend',
|
name: 'my-frontend',
|
||||||
addPlugin: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await applicationGenerator(tree, {
|
await applicationGenerator(tree, {
|
||||||
@ -349,7 +348,6 @@ describe('app', () => {
|
|||||||
it('should configure proxies for multiple node projects with the same frontend app', async () => {
|
it('should configure proxies for multiple node projects with the same frontend app', async () => {
|
||||||
await angularApplicationGenerator(tree, {
|
await angularApplicationGenerator(tree, {
|
||||||
name: 'my-frontend',
|
name: 'my-frontend',
|
||||||
addPlugin: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await applicationGenerator(tree, {
|
await applicationGenerator(tree, {
|
||||||
@ -375,7 +373,6 @@ describe('app', () => {
|
|||||||
it('should work with unnormalized project names', async () => {
|
it('should work with unnormalized project names', async () => {
|
||||||
await angularApplicationGenerator(tree, {
|
await angularApplicationGenerator(tree, {
|
||||||
name: 'myFrontend',
|
name: 'myFrontend',
|
||||||
addPlugin: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await applicationGenerator(tree, {
|
await applicationGenerator(tree, {
|
||||||
|
|||||||
@ -34,7 +34,6 @@ async function createPreset(tree: Tree, options: Schema) {
|
|||||||
e2eTestRunner: options.e2eTestRunner ?? 'cypress',
|
e2eTestRunner: options.e2eTestRunner ?? 'cypress',
|
||||||
bundler: options.bundler,
|
bundler: options.bundler,
|
||||||
ssr: options.ssr,
|
ssr: options.ssr,
|
||||||
addPlugin,
|
|
||||||
});
|
});
|
||||||
} else if (options.preset === Preset.AngularStandalone) {
|
} else if (options.preset === Preset.AngularStandalone) {
|
||||||
const {
|
const {
|
||||||
@ -53,7 +52,6 @@ async function createPreset(tree: Tree, options: Schema) {
|
|||||||
e2eTestRunner: options.e2eTestRunner ?? 'cypress',
|
e2eTestRunner: options.e2eTestRunner ?? 'cypress',
|
||||||
bundler: options.bundler,
|
bundler: options.bundler,
|
||||||
ssr: options.ssr,
|
ssr: options.ssr,
|
||||||
addPlugin,
|
|
||||||
});
|
});
|
||||||
} else if (options.preset === Preset.ReactMonorepo) {
|
} else if (options.preset === Preset.ReactMonorepo) {
|
||||||
const { applicationGenerator: reactApplicationGenerator } = require('@nx' +
|
const { applicationGenerator: reactApplicationGenerator } = require('@nx' +
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user