Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/lib/cli-storybook/src/ai/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export async function aiSetup(options: AiSetupOptions): Promise<void> {
const detectedLanguage = await projectTypeService.detectLanguage();
const language = detectedLanguage === SupportedLanguage.TYPESCRIPT ? 'ts' : 'js';

const needsUserOnboarding = await cache.get('onboarding-pending');

projectInfo = {
storybookVersion: data.versionInstalled,
majorVersion,
Expand All @@ -60,6 +62,7 @@ export async function aiSetup(options: AiSetupOptions): Promise<void> {
packageManagerName: getPrettyPackageManagerName(data.packageManager.type),
language,
hasCsfFactoryPreview: data.hasCsfFactoryPreview,
needsUserOnboarding,
Comment thread
Sidnioulz marked this conversation as resolved.
};
} catch (err) {
logger.error(
Expand Down
4 changes: 3 additions & 1 deletion code/lib/cli-storybook/src/ai/setup-prompts/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
} from './partials/rules.ts';

export function instructions(projectInfo: ProjectInfo): string {
const { configDir, language, packageManager, packageManagerName } = projectInfo;
const { configDir, language, needsUserOnboarding, packageManager, packageManagerName } =
projectInfo;
const tsx = ext(language, true);
const ts = ext(language, false);
const docsUrl = (path: string) => getDocsMarkdownUrl(path, projectInfo);
Expand All @@ -41,6 +42,7 @@ export function instructions(projectInfo: ProjectInfo): string {
configDir,
docsUrl,
mswInstall,
needsUserOnboarding,
packageManager,
packageManagerName,
tsx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
} from './partials/rules.ts';

export function instructions(projectInfo: ProjectInfo): string {
const { configDir, language, packageManager, packageManagerName } = projectInfo;
const { configDir, language, needsUserOnboarding, packageManager, packageManagerName } =
projectInfo;
const tsx = ext(language, true);
const ts = ext(language, false);
const docsUrl = (path: string) => getDocsMarkdownUrl(path, projectInfo);
Expand All @@ -39,6 +40,7 @@ export function instructions(projectInfo: ProjectInfo): string {
configDir,
docsUrl,
mswInstall,
needsUserOnboarding,
packageManager,
packageManagerName,
tsx,
Expand Down
8 changes: 6 additions & 2 deletions code/lib/cli-storybook/src/ai/setup-prompts/partials/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,16 @@ export function verifyStep(
}

export function cleanupStep(
projectInfo: ProjectInfo,
{ needsUserOnboarding }: ProjectInfo,
ctx: InstructionsContext
): { title: string; body: string } {
const onboardingInstructions = needsUserOnboarding
? 'You must preserve the components, CSS, stories and MDX docs initially created by Storybook, as they are required for user onboarding in the UI.'
: 'Delete the components, CSS, stories and MDX docs initially created by Storybook only if you managed to write successful stories.';

return {
title: `Clean up`,
body: `Before finishing, remove debug code, broad mocks added during diagnosis, unused deps, and eval artifacts.`,
body: `Before finishing, remove debug code, broad mocks added during diagnosis, unused deps, and eval artifacts. ${onboardingInstructions}`,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import {
} from './partials/rules.ts';

export function instructions(projectInfo: ProjectInfo): string {
const { configDir, language, packageManager, packageManagerName } = projectInfo;
const { configDir, language, needsUserOnboarding, packageManager, packageManagerName } =
projectInfo;
const tsx = ext(language, true);
const ts = ext(language, false);
const docsUrl = (path: string) => getDocsMarkdownUrl(path, projectInfo);
Expand All @@ -39,6 +40,7 @@ export function instructions(projectInfo: ProjectInfo): string {
configDir,
docsUrl,
mswInstall,
needsUserOnboarding,
packageManager,
packageManagerName,
tsx,
Expand Down
3 changes: 3 additions & 0 deletions code/lib/cli-storybook/src/ai/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ export interface ProjectInfo {
packageManagerName?: string;
/** Whether the project's preview file uses the CSF Factory format. */
hasCsfFactoryPreview: boolean;
/** Whether the user has requested to be onboarded into Storybook. */
needsUserOnboarding: boolean;
}

export interface SetupInstructionsContext {
configDir: string;
docsUrl: (path: string) => string;
mswInstall: string;
needsUserOnboarding: boolean;
packageManager: JsPackageManager;
packageManagerName: string | undefined;
tsx: string;
Expand Down
Loading