mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 05:31:49 +08:00
"sb start/build" should call start-storybook and build-storybook directly, rather than calling "yarn storybook". This way we can use "sb start/build" in the package.json NPM scripts and expose users to the CLI that way. For now let's remove it.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import program from 'commander';
|
|
import chalk from 'chalk';
|
|
import pkg from '../package.json';
|
|
import initiate from '../lib/initiate';
|
|
import { codeLog } from '../lib/helpers';
|
|
|
|
const logger = console;
|
|
|
|
if (process.argv[1].includes('getstorybook')) {
|
|
logger.log(chalk.yellow('WARNING: getstorybook is deprecated.'));
|
|
logger.log(chalk.yellow('The official command to install Storybook from now on is:\n'));
|
|
codeLog(['sb init']);
|
|
logger.log();
|
|
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('*', { 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();
|
|
}
|
|
}
|