mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-31 05:03:21 +08:00
Merge pull request #18866 from storybookjs/fix/no-init-on-repro
CLI: add --no-init to repro-next command
This commit is contained in:
commit
67102c84f5
@ -152,6 +152,7 @@ program
|
||||
.description('Create a reproduction from a set of possible templates')
|
||||
.option('-o --output <outDir>', 'Define an output directory')
|
||||
.option('-b --branch <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);
|
||||
|
@ -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<Choice[]>((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:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user