diff --git a/code/lib/cli/src/generate.ts b/code/lib/cli/src/generate.ts index e6e58fbd8ea4..acfcb7e79021 100644 --- a/code/lib/cli/src/generate.ts +++ b/code/lib/cli/src/generate.ts @@ -152,6 +152,7 @@ program .description('Create a reproduction from a set of possible templates') .option('-o --output ', 'Define an output directory') .option('-b --branch ', 'Define the branch to degit from', 'next') + .option('--no-init', 'Whether to download a template without an initialized Storybook', false) .action((filterValue, options) => reproNext({ filterValue, ...options }).catch((e) => { logger.error(e); diff --git a/code/lib/cli/src/repro-next.ts b/code/lib/cli/src/repro-next.ts index 7d0b03049a35..e3fffdf84457 100644 --- a/code/lib/cli/src/repro-next.ts +++ b/code/lib/cli/src/repro-next.ts @@ -14,12 +14,18 @@ interface ReproOptions { filterValue?: string; output?: string; branch?: string; + init?: boolean; } type Choice = keyof typeof TEMPLATES; const toChoices = (c: Choice): prompts.Choice => ({ title: TEMPLATES[c].name, value: c }); -export const reproNext = async ({ output: outputDirectory, filterValue, branch }: ReproOptions) => { +export const reproNext = async ({ + output: outputDirectory, + filterValue, + branch, + init, +}: ReproOptions) => { const keys = Object.keys(TEMPLATES) as Choice[]; // get value from template and reduce through TEMPLATES to filter out the correct template const choices = keys.reduce((acc, group) => { @@ -123,9 +129,10 @@ export const reproNext = async ({ output: outputDirectory, filterValue, branch } logger.log('📦 Downloading repro template...'); try { + const templateType = init ? 'after-storybook' : 'before-storybook'; // Download the repro based on subfolder "after-storybook" and selected branch await degit( - `storybookjs/repro-templates-temp/${selectedTemplate}/after-storybook#${branch}`, + `storybookjs/repro-templates-temp/${selectedTemplate}/${templateType}#${branch}`, { force: true, } @@ -135,13 +142,17 @@ export const reproNext = async ({ output: outputDirectory, filterValue, branch } return; } + const initMessage = init + ? chalk.yellow(`yarn storybook`) + : `Recreate your setup, then ${chalk.yellow(`run npx storybook init`)}`; + logger.info( boxen( dedent` 🎉 Your Storybook reproduction project is ready to use! 🎉 ${chalk.yellow(`cd ${selectedDirectory}`)} - ${chalk.yellow(`yarn storybook`)} + ${initMessage} Once you've recreated the problem you're experiencing, please: