Skip to content

Commit

Permalink
fix(misc): make sure to add e2e crystal plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Feb 28, 2024
1 parent 8fb5b05 commit bf5c5c1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/cypress/src/generators/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { addLinterToCyProject } from '../../utils/add-linter';
import { addDefaultE2EConfig } from '../../utils/config';
import { installedCypressVersion } from '../../utils/cypress-version';
import { typesNodeVersion, viteVersion } from '../../utils/versions';
import cypressInitGenerator from '../init/init';
import cypressInitGenerator, { addPlugin } from '../init/init';
import { addBaseCypressSetup } from '../base-setup/base-setup';

export interface CypressE2EConfigSchema {
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function configurationGeneratorInternal(
options: CypressE2EConfigSchema
) {
const opts = normalizeOptions(tree, options);

opts.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
const tasks: GeneratorCallback[] = [];

if (!installedCypressVersion()) {
Expand All @@ -76,10 +76,12 @@ export async function configurationGeneratorInternal(
await cypressInitGenerator(tree, {
...opts,
skipFormat: true,
addPlugin: options.addPlugin,
})
);
} else if (opts.addPlugin) {
addPlugin(tree);
}

const projectGraph = await createProjectGraphAsync();
const nxJson = readNxJson(tree);
const hasPlugin = nxJson.plugins?.some((p) =>
Expand All @@ -96,7 +98,6 @@ export async function configurationGeneratorInternal(
const linterTask = await addLinterToCyProject(tree, {
...opts,
cypressDir: opts.directory,
addPlugin: opts.addPlugin,
});
tasks.push(linterTask);

Expand Down Expand Up @@ -151,7 +152,6 @@ In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:

return {
...options,
addPlugin: options.addPlugin ?? process.env.NX_ADD_PLUGINS !== 'false',
bundler: options.bundler ?? 'webpack',
rootProject: options.rootProject ?? projectConfig.root === '.',
linter: options.linter ?? Linter.EsLint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ async function normalizeOptions(

options.linter = options.linter || Linter.EsLint;
options.bundler = options.bundler || 'webpack';
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';

return {
...options,
// other generators depend on the rootProject flag down stream
Expand Down
3 changes: 1 addition & 2 deletions packages/cypress/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function updateDependencies(tree: Tree, options: Schema) {
return runTasksInSerial(...tasks);
}

function addPlugin(tree: Tree) {
export function addPlugin(tree: Tree) {
const nxJson = readNxJson(tree);
nxJson.plugins ??= [];

Expand Down Expand Up @@ -105,7 +105,6 @@ export async function cypressInitGeneratorInternal(
options: Schema
) {
updateProductionFileset(tree);

options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';

if (options.addPlugin) {
Expand Down
2 changes: 0 additions & 2 deletions packages/playwright/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export async function initGeneratorInternal(
options: InitGeneratorSchema
) {
const tasks: GeneratorCallback[] = [];

options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';

if (!options.skipPackageJson) {
tasks.push(
addDependenciesToPackageJson(
Expand Down
2 changes: 2 additions & 0 deletions packages/vue/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function applicationGeneratorInternal(
_options: Schema
): Promise<GeneratorCallback> {
const options = await normalizeOptions(tree, _options);
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';

const tasks: GeneratorCallback[] = [];

addProjectConfiguration(tree, options.name, {
Expand Down
1 change: 1 addition & 0 deletions packages/vue/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export async function addE2e(
implicitDependencies: [options.projectName],
});
return configurationGenerator(tree, {
...options,
project: options.e2eProjectName,
skipFormat: true,
skipPackageJson: options.skipPackageJson,
Expand Down

0 comments on commit bf5c5c1

Please sign in to comment.