mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 05:51:06 +08:00
28 lines
961 B
JavaScript
Executable File
28 lines
961 B
JavaScript
Executable File
import mergeDirs from 'merge-dirs';
|
|
import path from 'path';
|
|
import npmInit from '../../lib/npm_init';
|
|
import { getVersion, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
|
|
|
export default async npmOptions => {
|
|
const storybookVersion = await getVersion(npmOptions, '@storybook/html');
|
|
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
|
|
|
|
let packageJson = getPackageJson();
|
|
if (!packageJson) {
|
|
await npmInit();
|
|
packageJson = getPackageJson();
|
|
}
|
|
|
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
packageJson.devDependencies['@storybook/html'] = storybookVersion;
|
|
|
|
await installBabel(npmOptions, packageJson);
|
|
|
|
packageJson.scripts = packageJson.scripts || {};
|
|
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
|
packageJson.scripts['build-storybook'] = 'build-storybook';
|
|
|
|
writePackageJson(packageJson);
|
|
};
|