mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 07:21:16 +08:00
All this variables were used to check if user was running Yarn and do this accordingly. Now we use the factory to get the "right" version of JsPackageManager instance so there is no need to worry anywhere about that.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import fse from 'fs-extra';
|
|
import path from 'path';
|
|
import { writePackageJson, getBabelDependencies } from '../../helpers';
|
|
import { Generator } from '../Generator';
|
|
|
|
const generator: Generator = async (packageManager, npmOptions) => {
|
|
const storybookVersion = await packageManager.getVersion('@storybook/marionette');
|
|
fse.copySync(path.resolve(__dirname, 'template/'), '.', { overwrite: true });
|
|
|
|
const packageJson = packageManager.retrievePackageJson();
|
|
|
|
packageJson.dependencies = packageJson.dependencies || {};
|
|
packageJson.devDependencies = packageJson.devDependencies || {};
|
|
|
|
packageJson.scripts = packageJson.scripts || {};
|
|
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
|
packageJson.scripts['build-storybook'] = 'build-storybook';
|
|
|
|
writePackageJson(packageJson);
|
|
|
|
const babelDependencies = await getBabelDependencies(packageManager, packageJson);
|
|
|
|
packageManager.addDependencies({ ...npmOptions, packageJson }, [
|
|
`@storybook/marionette@${storybookVersion}`,
|
|
...babelDependencies,
|
|
]);
|
|
};
|
|
|
|
export default generator;
|