Mikael Carpenter fa991cc361 Update the remaining generators to use new install functions.
Add a new fixture that has a frozen lock file
   Add documentation to the helper functions I changed
2019-04-25 10:12:16 -07:00

47 lines
1.3 KiB
JavaScript
Executable File

import mergeDirs from 'merge-dirs';
import path from 'path';
import {
getVersions,
getPackageJson,
writePackageJson,
getBabelDependencies,
installDependencies,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, polymerLoaderVarion] = await getVersions(
npmOptions,
'@storybook/polymer',
'polymer-webpack-loader'
);
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
const packageJson = getPackageJson() || {}; // Maybe we are in a bower only project, still we need a package json
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);
let webpackDep = [];
if (
!packageJson.dependencies['polymer-webpack-loader'] &&
!packageJson.devDependencies['polymer-webpack-loader']
) {
webpackDep = [`polymer-webpack-loader@${polymerLoaderVarion}`];
}
const babelDependencies = await getBabelDependencies(npmOptions, packageJson);
installDependencies(npmOptions, [
`@storybook/polymer@${storybookVersion}`,
...webpackDep,
...babelDependencies,
'-D',
]);
};