fix(storybook): proper detection of e2e project existence (#13635)
This commit is contained in:
parent
4196ad3758
commit
b959109390
@ -1,10 +1,4 @@
|
|||||||
import {
|
import { formatFiles, joinPathFragments, logger, Tree } from '@nrwl/devkit';
|
||||||
formatFiles,
|
|
||||||
joinPathFragments,
|
|
||||||
logger,
|
|
||||||
readProjectConfiguration,
|
|
||||||
Tree,
|
|
||||||
} from '@nrwl/devkit';
|
|
||||||
import componentCypressSpecGenerator from '../component-cypress-spec/component-cypress-spec';
|
import componentCypressSpecGenerator from '../component-cypress-spec/component-cypress-spec';
|
||||||
import componentStoryGenerator from '../component-story/component-story';
|
import componentStoryGenerator from '../component-story/component-story';
|
||||||
import type { ComponentInfo } from '../utils/storybook-ast/component-info';
|
import type { ComponentInfo } from '../utils/storybook-ast/component-info';
|
||||||
@ -25,7 +19,6 @@ export function angularStoriesGenerator(
|
|||||||
const e2eProjectName = options.cypressProject ?? `${options.name}-e2e`;
|
const e2eProjectName = options.cypressProject ?? `${options.name}-e2e`;
|
||||||
const e2eProject = getE2EProject(tree, e2eProjectName);
|
const e2eProject = getE2EProject(tree, e2eProjectName);
|
||||||
const entryPoints = getProjectEntryPoints(tree, options.name);
|
const entryPoints = getProjectEntryPoints(tree, options.name);
|
||||||
const { root } = readProjectConfiguration(tree, options.name);
|
|
||||||
const componentsInfo: ComponentInfo[] = [];
|
const componentsInfo: ComponentInfo[] = [];
|
||||||
for (const entryPoint of entryPoints) {
|
for (const entryPoint of entryPoints) {
|
||||||
const moduleFilePaths = getModuleFilePaths(tree, entryPoint);
|
const moduleFilePaths = getModuleFilePaths(tree, entryPoint);
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import {
|
|||||||
createProjectStorybookDir,
|
createProjectStorybookDir,
|
||||||
createRootStorybookDir,
|
createRootStorybookDir,
|
||||||
createRootStorybookDirForRootProject,
|
createRootStorybookDirForRootProject,
|
||||||
|
getE2EProjectName,
|
||||||
projectIsRootProjectInNestedWorkspace,
|
projectIsRootProjectInNestedWorkspace,
|
||||||
updateLintConfig,
|
updateLintConfig,
|
||||||
} from './util-functions';
|
} from './util-functions';
|
||||||
@ -106,19 +107,20 @@ export async function configurationGenerator(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (schema.configureCypress) {
|
const e2eProject = getE2EProjectName(tree, schema.name);
|
||||||
if (projectType !== 'application') {
|
if (schema.configureCypress && !e2eProject) {
|
||||||
const cypressTask = await cypressProjectGenerator(tree, {
|
const cypressTask = await cypressProjectGenerator(tree, {
|
||||||
name: schema.name,
|
name: schema.name,
|
||||||
js: schema.js,
|
js: schema.js,
|
||||||
linter: schema.linter,
|
linter: schema.linter,
|
||||||
directory: schema.cypressDirectory,
|
directory: schema.cypressDirectory,
|
||||||
standaloneConfig: schema.standaloneConfig,
|
standaloneConfig: schema.standaloneConfig,
|
||||||
});
|
});
|
||||||
tasks.push(cypressTask);
|
tasks.push(cypressTask);
|
||||||
} else {
|
} else {
|
||||||
logger.warn('There is already an e2e project setup');
|
logger.warn(
|
||||||
}
|
`There is already an e2e project setup for ${schema.name}, called ${e2eProject}.`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextBuildTarget && projectType === 'application') {
|
if (nextBuildTarget && projectType === 'application') {
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
generateFiles,
|
generateFiles,
|
||||||
|
getProjects,
|
||||||
joinPathFragments,
|
joinPathFragments,
|
||||||
logger,
|
logger,
|
||||||
offsetFromRoot,
|
offsetFromRoot,
|
||||||
|
parseTargetString,
|
||||||
readJson,
|
readJson,
|
||||||
readProjectConfiguration,
|
readProjectConfiguration,
|
||||||
readWorkspaceConfiguration,
|
readWorkspaceConfiguration,
|
||||||
@ -24,6 +26,7 @@ import {
|
|||||||
} from '../../utils/utilities';
|
} from '../../utils/utilities';
|
||||||
import { StorybookConfigureSchema } from './schema';
|
import { StorybookConfigureSchema } from './schema';
|
||||||
import { getRootTsConfigPathInTree } from '@nrwl/workspace/src/utilities/typescript';
|
import { getRootTsConfigPathInTree } from '@nrwl/workspace/src/utilities/typescript';
|
||||||
|
import { forEachExecutorOptions } from '@nrwl/workspace/src/utilities/executor-options-utils';
|
||||||
|
|
||||||
const DEFAULT_PORT = 4400;
|
const DEFAULT_PORT = 4400;
|
||||||
|
|
||||||
@ -533,3 +536,31 @@ export function rootFileIsTs(
|
|||||||
return tsConfiguration;
|
return tsConfiguration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getE2EProjectName(
|
||||||
|
tree: Tree,
|
||||||
|
mainProject: string
|
||||||
|
): string | undefined {
|
||||||
|
let e2eProject: string;
|
||||||
|
forEachExecutorOptions(
|
||||||
|
tree,
|
||||||
|
'@nrwl/cypress:cypress',
|
||||||
|
(options, projectName) => {
|
||||||
|
if (e2eProject) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (options['devServerTarget']) {
|
||||||
|
const { project, target } = parseTargetString(
|
||||||
|
options['devServerTarget']
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
(project === mainProject && target === 'serve') ||
|
||||||
|
(project === mainProject && target === 'storybook')
|
||||||
|
) {
|
||||||
|
e2eProject = projectName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return e2eProject;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user