mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
REMOVE deprecated APIs in lib/cli
This commit is contained in:
parent
2d66c93253
commit
e4d6c1a581
@ -12,100 +12,89 @@ import { extract } from './extract';
|
||||
|
||||
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', 'Force add storybook')
|
||||
.option('-s --skip-install', 'Skip installing deps')
|
||||
.option('-N --use-npm', 'Use npm to install deps')
|
||||
.option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser')
|
||||
.option('-t --type <type>', 'Add Storybook for a specific project type')
|
||||
.option('--story-format <csf | csf-ts | mdx >', 'Generate stories in a specified format')
|
||||
.option('-y --yes', 'Answer yes to all prompts')
|
||||
.action(options => initiate(options, pkg));
|
||||
program
|
||||
.command('init')
|
||||
.description('Initialize Storybook into your project.')
|
||||
.option('-f --force', 'Force add storybook')
|
||||
.option('-s --skip-install', 'Skip installing deps')
|
||||
.option('-N --use-npm', 'Use npm to install deps')
|
||||
.option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser')
|
||||
.option('-t --type <type>', 'Add Storybook for a specific project type')
|
||||
.option('--story-format <csf | csf-ts | mdx >', 'Generate stories in a specified format')
|
||||
.option('-y --yes', 'Answer yes to all prompts')
|
||||
.action(options => initiate(options, pkg));
|
||||
|
||||
program
|
||||
.command('add <addon>')
|
||||
.description('Add an addon to your Storybook')
|
||||
.option('-N --use-npm', 'Use NPM to build the Storybook server')
|
||||
.option('-s --skip-postinstall', 'Skip package specific postinstall config modifications')
|
||||
.action((addonName, options) => add(addonName, options));
|
||||
program
|
||||
.command('add <addon>')
|
||||
.description('Add an addon to your Storybook')
|
||||
.option('-N --use-npm', 'Use NPM to build the Storybook server')
|
||||
.option('-s --skip-postinstall', 'Skip package specific postinstall config modifications')
|
||||
.action((addonName, options) => add(addonName, options));
|
||||
|
||||
program
|
||||
.command('info')
|
||||
.description('Prints debugging information about the local environment')
|
||||
.action(() => {
|
||||
logger.log(chalk.bold('\nEnvironment Info:'));
|
||||
envinfo
|
||||
.run({
|
||||
System: ['OS', 'CPU'],
|
||||
Binaries: ['Node', 'Yarn', 'npm'],
|
||||
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
||||
npmPackages: '@storybook/*',
|
||||
npmGlobalPackages: '@storybook/*',
|
||||
})
|
||||
.then(logger.log);
|
||||
});
|
||||
|
||||
program
|
||||
.command('migrate [migration]')
|
||||
.description('Run a storybook codemod migration on your source files')
|
||||
.option('-l --list', 'List available migrations')
|
||||
.option('-g --glob <glob>', 'Glob for files upon which to apply the migration', '**/*.js')
|
||||
.option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser')
|
||||
.option(
|
||||
'-n --dry-run',
|
||||
'Dry run: verify the migration exists and show the files to which it will be applied'
|
||||
)
|
||||
.option(
|
||||
'-r --rename <from-to>',
|
||||
'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"'
|
||||
)
|
||||
.action((migration, { configDir, glob, dryRun, list, rename, parser }) => {
|
||||
migrate(migration, { configDir, glob, dryRun, list, rename, parser, logger }).catch(err => {
|
||||
logger.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
program
|
||||
.command('extract [location] [output]')
|
||||
.description('extract stories.json from a built version')
|
||||
.action((location = 'storybook-static', output = path.join(location, 'stories.json')) =>
|
||||
extract(location, output).catch(e => {
|
||||
logger.error(e);
|
||||
process.exit(1);
|
||||
program
|
||||
.command('info')
|
||||
.description('Prints debugging information about the local environment')
|
||||
.action(() => {
|
||||
logger.log(chalk.bold('\nEnvironment Info:'));
|
||||
envinfo
|
||||
.run({
|
||||
System: ['OS', 'CPU'],
|
||||
Binaries: ['Node', 'Yarn', 'npm'],
|
||||
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
||||
npmPackages: '@storybook/*',
|
||||
npmGlobalPackages: '@storybook/*',
|
||||
})
|
||||
);
|
||||
|
||||
program.command('*', { noHelp: true }).action(() => {
|
||||
const [, , invalidCmd] = process.argv;
|
||||
logger.error(
|
||||
' Invalid command: %s.\n See --help for a list of available commands.',
|
||||
invalidCmd
|
||||
);
|
||||
// eslint-disable-next-line
|
||||
const availableCommands = program.commands.map(cmd => cmd._name);
|
||||
const suggestion = availableCommands.find(cmd => leven(cmd, invalidCmd) < 3);
|
||||
if (suggestion) {
|
||||
logger.log(`\n Did you mean ${suggestion}?`);
|
||||
}
|
||||
process.exit(1);
|
||||
.then(logger.log);
|
||||
});
|
||||
|
||||
program
|
||||
.usage('<command> [options]')
|
||||
.version(pkg.version)
|
||||
.parse(process.argv);
|
||||
program
|
||||
.command('migrate [migration]')
|
||||
.description('Run a storybook codemod migration on your source files')
|
||||
.option('-l --list', 'List available migrations')
|
||||
.option('-g --glob <glob>', 'Glob for files upon which to apply the migration', '**/*.js')
|
||||
.option('-p --parser <babel | babylon | flow | ts | tsx>', 'jscodeshift parser')
|
||||
.option(
|
||||
'-n --dry-run',
|
||||
'Dry run: verify the migration exists and show the files to which it will be applied'
|
||||
)
|
||||
.option(
|
||||
'-r --rename <from-to>',
|
||||
'Rename suffix of matching files after codemod has been applied, e.g. ".js:.ts"'
|
||||
)
|
||||
.action((migration, { configDir, glob, dryRun, list, rename, parser }) => {
|
||||
migrate(migration, { configDir, glob, dryRun, list, rename, parser, logger }).catch(err => {
|
||||
logger.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
if (program.rawArgs.length < 3) {
|
||||
program.help();
|
||||
program
|
||||
.command('extract [location] [output]')
|
||||
.description('extract stories.json from a built version')
|
||||
.action((location = 'storybook-static', output = path.join(location, 'stories.json')) =>
|
||||
extract(location, output).catch(e => {
|
||||
logger.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
);
|
||||
|
||||
program.command('*', { noHelp: true }).action(() => {
|
||||
const [, , invalidCmd] = process.argv;
|
||||
logger.error(' Invalid command: %s.\n See --help for a list of available commands.', invalidCmd);
|
||||
// eslint-disable-next-line
|
||||
const availableCommands = program.commands.map(cmd => cmd._name);
|
||||
const suggestion = availableCommands.find(cmd => leven(cmd, invalidCmd) < 3);
|
||||
if (suggestion) {
|
||||
logger.log(`\n Did you mean ${suggestion}?`);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
program
|
||||
.usage('<command> [options]')
|
||||
.version(pkg.version)
|
||||
.parse(process.argv);
|
||||
|
||||
if (program.rawArgs.length < 3) {
|
||||
program.help();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user