mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 01:01:07 +08:00
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
import mergeDirs from 'merge-dirs';
|
|
import path from 'path';
|
|
import fs from 'fs';
|
|
import latestVersion from 'latest-version';
|
|
import { getPackageJson, writePackageJson } from '../../lib/helpers';
|
|
|
|
export default Promise.all([
|
|
latestVersion('@storybook/react'),
|
|
latestVersion('@storybook/addon-actions'),
|
|
latestVersion('@storybook/addon-links'),
|
|
]).then(([storybookVersion, actionsVersion, linksVersion]) => {
|
|
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
|
|
|
|
const packageJson = getPackageJson();
|
|
|
|
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
|
|
packageJson.devDependencies['@storybook/react'] = `^${storybookVersion}`;
|
|
packageJson.devDependencies['@storybook/addon-actions'] = `^${actionsVersion}`;
|
|
packageJson.devDependencies['@storybook/addon-links'] = `^${linksVersion}`;
|
|
|
|
packageJson.scripts.storybook = 'start-storybook -p 9009';
|
|
packageJson.scripts['build-storybook'] = 'build-storybook';
|
|
|
|
if (fs.existsSync(path.resolve('./public'))) {
|
|
// has a public folder and add support to it.
|
|
packageJson.scripts.storybook += ' -s public';
|
|
packageJson.scripts['build-storybook'] += ' -s public';
|
|
}
|
|
|
|
writePackageJson(packageJson);
|
|
});
|