diff --git a/code/lib/cli-storybook/src/ai/index.ts b/code/lib/cli-storybook/src/ai/index.ts index f1371c2ce921..abaf21b30b9f 100644 --- a/code/lib/cli-storybook/src/ai/index.ts +++ b/code/lib/cli-storybook/src/ai/index.ts @@ -46,6 +46,8 @@ export async function aiSetup(options: AiSetupOptions): Promise { const detectedLanguage = await projectTypeService.detectLanguage(); const language = detectedLanguage === SupportedLanguage.TYPESCRIPT ? 'ts' : 'js'; + const needsUserOnboarding = await cache.get('onboarding-pending'); + projectInfo = { storybookVersion: data.versionInstalled, majorVersion, @@ -60,6 +62,7 @@ export async function aiSetup(options: AiSetupOptions): Promise { packageManagerName: getPrettyPackageManagerName(data.packageManager.type), language, hasCsfFactoryPreview: data.hasCsfFactoryPreview, + needsUserOnboarding, }; } catch (err) { logger.error( diff --git a/code/lib/cli-storybook/src/ai/setup-prompts/monorepo.ts b/code/lib/cli-storybook/src/ai/setup-prompts/monorepo.ts index b73e3f3e8656..3b8ae0f7147e 100644 --- a/code/lib/cli-storybook/src/ai/setup-prompts/monorepo.ts +++ b/code/lib/cli-storybook/src/ai/setup-prompts/monorepo.ts @@ -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); @@ -41,6 +42,7 @@ export function instructions(projectInfo: ProjectInfo): string { configDir, docsUrl, mswInstall, + needsUserOnboarding, packageManager, packageManagerName, tsx, diff --git a/code/lib/cli-storybook/src/ai/setup-prompts/optimized-tests.ts b/code/lib/cli-storybook/src/ai/setup-prompts/optimized-tests.ts index ac80395fd469..4f7dc1e1577d 100644 --- a/code/lib/cli-storybook/src/ai/setup-prompts/optimized-tests.ts +++ b/code/lib/cli-storybook/src/ai/setup-prompts/optimized-tests.ts @@ -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); @@ -39,6 +40,7 @@ export function instructions(projectInfo: ProjectInfo): string { configDir, docsUrl, mswInstall, + needsUserOnboarding, packageManager, packageManagerName, tsx, diff --git a/code/lib/cli-storybook/src/ai/setup-prompts/partials/steps.ts b/code/lib/cli-storybook/src/ai/setup-prompts/partials/steps.ts index 8b18a432a65b..0233a83ff338 100644 --- a/code/lib/cli-storybook/src/ai/setup-prompts/partials/steps.ts +++ b/code/lib/cli-storybook/src/ai/setup-prompts/partials/steps.ts @@ -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}`, }; } diff --git a/code/lib/cli-storybook/src/ai/setup-prompts/relaxed-limits.ts b/code/lib/cli-storybook/src/ai/setup-prompts/relaxed-limits.ts index eb7bca072429..5fdb96fff09d 100644 --- a/code/lib/cli-storybook/src/ai/setup-prompts/relaxed-limits.ts +++ b/code/lib/cli-storybook/src/ai/setup-prompts/relaxed-limits.ts @@ -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); @@ -39,6 +40,7 @@ export function instructions(projectInfo: ProjectInfo): string { configDir, docsUrl, mswInstall, + needsUserOnboarding, packageManager, packageManagerName, tsx, diff --git a/code/lib/cli-storybook/src/ai/types.ts b/code/lib/cli-storybook/src/ai/types.ts index c9663ae0d6ac..239b8acbef95 100644 --- a/code/lib/cli-storybook/src/ai/types.ts +++ b/code/lib/cli-storybook/src/ai/types.ts @@ -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;