Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cli gestorybook fix #4213

Merged
merged 3 commits into from
Sep 24, 2018
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
69 changes: 34 additions & 35 deletions lib/cli/bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,38 @@ if (process.argv[1].includes('getstorybook')) {
logger.log(chalk.yellow('The official command to install Storybook from now on is:\n'));
codeLog(['storybook init']);
logger.log();
initiate({}, pkg);
process.exit(0);
}

program
.command('init')
.description('Initialize Storybook into your project.')
.option('-f --force', 'Forcely add storybook')
.option('-s --skip-install', 'Skip installing deps')
.option('-N --use-npm', 'Use npm to install deps')
.option('-p --parser <babel | babylon | flow>', 'jscodeshift parser')
.option('-h --html', 'Add storybook for HTML')
.action(options => initiate(options, pkg));

program
.command('start')
.description('Start the local Storybook server')
.option('-N --use-npm', 'Use NPM to start the Storybook server')
.action(options => yarnSpawnSync(options, ['run', 'storybook']));

program
.command('build')
.description('Build the Storybook static application')
.option('-N --use-npm', 'Use NPM to build the Storybook server')
.action(options => yarnSpawnSync(options, ['build', 'storybook']));

program.command('*', { noHelp: true }).action(cmd => {
logger.error('Invalid command: %s.\nSee --help for a list of available commands.', cmd);
process.exit(1);
});

program.version(pkg.version).parse(process.argv);

if (!program.args.length) {
program.help();
initiate({}, pkg).then(() => process.exit(0));
} else {
program
.command('init')
.description('Initialize Storybook into your project.')
.option('-f --force', 'Forcely add storybook')
.option('-s --skip-install', 'Skip installing deps')
.option('-N --use-npm', 'Use npm to install deps')
.option('-p --parser <babel | babylon | flow>', 'jscodeshift parser')
.option('-h --html', 'Add storybook for HTML')
.action(options => initiate(options, pkg));

program
.command('start')
.description('Start the local Storybook server')
.option('-N --use-npm', 'Use NPM to start the Storybook server')
.action(options => yarnSpawnSync(options, ['run', 'storybook']));

program
.command('build')
.description('Build the Storybook static application')
.option('-N --use-npm', 'Use NPM to build the Storybook server')
.action(options => yarnSpawnSync(options, ['build', 'storybook']));

program.command('*', { noHelp: true }).action(cmd => {
logger.error('Invalid command: %s.\nSee --help for a list of available commands.', cmd);
process.exit(1);
});

program.version(pkg.version).parse(process.argv);

if (!program.args.length) {
program.help();
}
}
2 changes: 1 addition & 1 deletion lib/cli/lib/initiate.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export default function(options, pkg) {
}
};

runGenerator().catch(ex => {
return runGenerator().catch(ex => {
logger.error(`\n ${chalk.red(ex.stack)}`);
process.exit(1);
});
Expand Down