2019-10-12 09:25:24 +08:00

40 lines
1.1 KiB
JavaScript

import {
getVersions,
getPackageJson,
writePackageJson,
getBabelDependencies,
installDependencies,
copyTemplate,
} from '../../lib/helpers';
export default async (npmOptions, { storyFormat = 'csf' }) => {
const [storybookVersion, addonActionVersion, addonKnobsVersion] = await getVersions(
npmOptions,
'@storybook/marko',
'@storybook/addon-actions',
'@storybook/addon-knobs'
);
copyTemplate(__dirname, storyFormat);
const packageJson = getPackageJson();
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(npmOptions, packageJson);
installDependencies(npmOptions, [
`@storybook/marko@${storybookVersion}`,
`@storybook/addon-actions@${addonActionVersion}`,
`@storybook/addon-knobs@${addonKnobsVersion}`,
...babelDependencies,
]);
};