2019-03-17 13:18:17 +03:00

44 lines
1.4 KiB
JavaScript

import path from 'path';
import mergeDirs from 'merge-dirs';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
export default async npmOptions => {
const [
storybookVersion,
actionsVersion,
linksVersion,
addonsVersion,
svelte,
svelteLoader,
] = await getVersions(
npmOptions,
'@storybook/svelte',
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addons',
'svelte',
'svelte-loader'
);
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
const packageJson = getPackageJson();
packageJson.dependencies = packageJson.dependencies || {};
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/svelte'] = storybookVersion;
packageJson.devDependencies['@storybook/addon-actions'] = actionsVersion;
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
packageJson.devDependencies.svelte = svelte;
packageJson.devDependencies['svelte-loader'] = svelteLoader;
await installBabel(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';
packageJson.scripts['build-storybook'] = 'build-storybook';
writePackageJson(packageJson);
};