mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 01:41:05 +08:00
Add a new fixture that has a frozen lock file Add documentation to the helper functions I changed
47 lines
1.3 KiB
JavaScript
Executable File
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',
|
|
]);
|
|
};
|