Skip to content

Commit

Permalink
feat(scripts-executors): add inferred projects support to start exper…
Browse files Browse the repository at this point in the history
…ience (#33198)
  • Loading branch information
Hotell authored Nov 4, 2024
1 parent 2558ddc commit 2a6ab96
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check-tooling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:

- run: yarn nx list @fluentui/workspace-plugin

# pre-build react-jsx-runtime - as generate-api executor doesn't provide copy assets capability
- run: yarn nx run react-jsx-runtime:build

- run: yarn nx g @fluentui/workspace-plugin:react-library --name hello-world --owner '@microsoft/fluentui-react-build' --kind standard --no-interactive
- run: yarn nx g @fluentui/workspace-plugin:react-component --project hello-world-preview --name Aiur --no-interactive
- run: yarn nx g @fluentui/workspace-plugin:cypress-component-configuration --project hello-world-preview --no-interactive
Expand Down
47 changes: 31 additions & 16 deletions scripts/executors/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,19 @@ async function getSelectedTarget(
.filter(targetName => {
return omitTargets.includes(targetName) ? false : true;
})
.map(targetName => {
const targetConfigurations = Object.keys(projectTargets[targetName].configurations || {});

if (targetConfigurations) {
return [targetName, ...targetConfigurations.map(target => `${targetName}:${target}`)];
}

return targetName;
})
.flat()
.sort()
.concat('help');

const preselectedTargetChoice =
preselectedTarget && availableTargets.indexOf(preselectedTarget) !== -1
? availableTargets.indexOf(preselectedTarget)
Expand Down Expand Up @@ -269,39 +280,43 @@ function createTargetDescription(
targetName: string,
targetsDescription: Record<string, string>,
) {
const description = targetsDescription[targetName];
const manualConfigDrivenDescription = targetsDescription[targetName];
const nxTargetConfiguration = projectConfig.data.targets?.[targetName];
const nxMetadataDescription = nxTargetConfiguration?.metadata?.description;
const scriptContent: string | undefined = nxTargetConfiguration?.metadata?.scriptContent;
const command = scriptContent || nxTargetConfiguration?.options.command || nxTargetConfiguration?.command;

// special case for non existent targets that we add artificially like `help`
if (!nxTargetConfiguration) {
return description;
return manualConfigDrivenDescription;
}

if (nxMetadataDescription) {
return nxMetadataDescription;
}

if (targetName === 'start') {
const scriptContent = nxTargetConfiguration.metadata?.scriptContent;
if (scriptContent.includes('storybook')) {
if (command && command.includes('storybook')) {
return `Start the project (Alias of "storybook" target)`;
}
return description;

return manualConfigDrivenDescription;
}

if (targetName === 'e2e') {
const scriptContent = nxTargetConfiguration.metadata?.scriptContent;
const runnerType = getRunnerType(scriptContent);

if (!runnerType) {
return scriptContent;
}
const runnerType = command && getRunnerType(command);
console.log({ runnerType, command });

return description + ` (using ${runnerType})`;
return runnerType ? manualConfigDrivenDescription + ` (using ${runnerType})` : manualConfigDrivenDescription;
}

return description ?? nxTargetConfiguration.metadata?.scriptContent;
return manualConfigDrivenDescription ?? command;

function getRunnerType(scriptContent: string): 'cypress' | 'playwright' | null {
if (scriptContent.includes('cypress')) {
function getRunnerType(value: string): 'cypress' | 'playwright' | null {
if (value.includes('cypress')) {
return 'cypress';
}
if (scriptContent.includes('playwright')) {
if (value.includes('playwright')) {
return 'playwright';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ function normalizeOptions(schema: GenerateApiExecutorSchema, context: ExecutorCo

const project = context.projectsConfigurations!.projects[context.projectName!];

const resolveLocalFlag = Boolean(process.env.__FORCE_API_MD_UPDATE__) || isCI() ? false : resolvedSchema.local;
const resolveLocalFlag = Boolean(process.env.__FORCE_API_MD_UPDATE__) || (isCI() ? false : resolvedSchema.local);

const projectAbsolutePath = join(context.root, project.root);
const resolveConfig = getApiExtractorConfigPath(resolvedSchema, projectAbsolutePath);
const tsConfigPathForCompilation = getTsConfigPathUsedForProduction(projectAbsolutePath);
Expand Down

0 comments on commit 2a6ab96

Please sign in to comment.