Gaëtan Maisse 2912bcbefe
refactor: remove unneeded params and variables
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.
2020-06-08 20:08:15 +02:00

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;