CHANGE the installBabel to only install babel-loader & RENAME to installBabelLoader

This commit is contained in:
Norbert de Langen 2018-08-16 16:23:58 +02:00
parent 224e1f905a
commit aadd8f0e0b
No known key found for this signature in database
GPG Key ID: 976651DA156C2825
12 changed files with 86 additions and 34 deletions

View File

@ -1,6 +1,11 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [
@ -21,7 +26,7 @@ export default async npmOptions => {
const packageJson = getPackageJson();
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.dependencies = packageJson.dependencies || {};
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/angular'] = storybookVersion;

View File

@ -1,7 +1,12 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import npmInit from '../../lib/npm_init';
import { getVersion, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersion,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const storybookVersion = await getVersion(npmOptions, '@storybook/html');
@ -17,7 +22,7 @@ export default async npmOptions => {
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/html'] = storybookVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -1,6 +1,11 @@
import path from 'path';
import mergeDirs from 'merge-dirs';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, addonActionVersion, addonKnobsVersion] = await getVersions(
@ -20,7 +25,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-actions'] = addonActionVersion;
packageJson.devDependencies['@storybook/addon-knobs'] = addonKnobsVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -1,6 +1,11 @@
import path from 'path';
import mergeDirs from 'merge-dirs';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
@ -22,7 +27,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
packageJson.devDependencies['@storybook/mithril'] = storybookVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -1,6 +1,11 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, polymerLoaderVarion] = await getVersions(
@ -16,7 +21,7 @@ export default async npmOptions => {
packageJson.devDependencies = packageJson.devDependencies || {};
packageJson.devDependencies['@storybook/polymer'] = storybookVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
if (
!packageJson.dependencies['polymer-webpack-loader'] &&

View File

@ -1,6 +1,11 @@
import path from 'path';
import mergeDirs from 'merge-dirs';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
@ -22,7 +27,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -1,7 +1,12 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import fs from 'fs';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
@ -24,7 +29,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts.storybook = 'start-storybook -p 9009';
packageJson.scripts['build-storybook'] = 'build-storybook';

View File

@ -1,6 +1,11 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
@ -22,7 +27,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -2,7 +2,12 @@
import path from 'path';
import { spawn } from 'child-process-promise';
import { packageNames } from '@storybook/codemod';
import { getVersion, installBabel, getPackageJson, writePackageJson } from '../../lib/helpers';
import {
getVersion,
installBabelLoader,
getPackageJson,
writePackageJson,
} from '../../lib/helpers';
async function updatePackage(devDependencies, oldName, newName, npmOptions) {
if (devDependencies[oldName]) {
@ -26,7 +31,7 @@ async function updatePackageJson(npmOptions) {
throw new Error('Expected to find `@kadira/[react-native]-storybook` in devDependencies');
}
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
writePackageJson(packageJson);
}

View File

@ -1,6 +1,11 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
@ -22,7 +27,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -1,6 +1,11 @@
import mergeDirs from 'merge-dirs';
import path from 'path';
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
import {
getVersions,
getPackageJson,
writePackageJson,
installBabelLoader,
} from '../../lib/helpers';
export default async npmOptions => {
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
@ -22,7 +27,7 @@ export default async npmOptions => {
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
await installBabel(npmOptions, packageJson);
await installBabelLoader(npmOptions, packageJson);
packageJson.scripts = packageJson.scripts || {};
packageJson.scripts.storybook = 'start-storybook -p 6006';

View File

@ -167,33 +167,30 @@ export function installDeps(options) {
done();
}
export async function installBabel(npmOptions, packageJson) {
export async function installBabelLoader(npmOptions, packageJson) {
let babelLoaderVersion = '^8.0.0-0';
if (packageJson.dependencies['babel-loader'] || packageJson.devDependencies['babel-loader']) {
return;
}
const babelCoreVersion =
packageJson.dependencies['babel-core'] || packageJson.devDependencies['babel-core'];
if (!babelCoreVersion) {
packageJson.devDependencies['babel-core'] = await getVersion(
npmOptions,
'babel-core',
'^7.0.0-bridge.0'
);
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
packageJson.devDependencies['@babel/core'] = await getVersion(npmOptions, '@babel/core');
}
} else {
if (babelCoreVersion) {
const latestCompatibleBabelVersion = await latestVersion(
npmOptions,
'babel-core',
babelCoreVersion
);
// Babel 6
if (satisfies(latestCompatibleBabelVersion, '^6.0.0')) {
if (!getBabelRc()) {
logger.warn(
chalk.red(`
You have a dependency on Babel 6 but don't have a .babelrc file. Please add one either in project directory or in .storybook.'`)
You have a dependency on Babel 6 but don't have a .babelrc file.
Please add one either in project directory or in .storybook.'`)
);
}
babelLoaderVersion = '^7.0.0';