mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 15:11:10 +08:00
Add babel-loader peer dep
This commit is contained in:
parent
170160ddfe
commit
3c0e3832e1
17
MIGRATION.md
17
MIGRATION.md
@ -62,18 +62,13 @@ Storybook now uses webpack 4. If you have a [custom webpack config](https://stor
|
||||
|
||||
### Babel 7
|
||||
|
||||
Storybook now uses Babel 7. There's some chance that it will still work with your Babel 6 based application. If it doesn't, you can override the loader for JS files using [Full Control Mode](https://storybook.js.org/configurations/custom-webpack-config/#full-control-mode):
|
||||
Storybook now uses Babel 7. There's a couple of cases when it can break with your app:
|
||||
|
||||
```js
|
||||
module.exports = (baseConfig, env, defaultConfig) => {
|
||||
defaultConfig.module.rules[0].use = {
|
||||
loader: 'babel-loader',
|
||||
};
|
||||
return defaultConfig;
|
||||
};
|
||||
```
|
||||
|
||||
In that case, please make sure that you have direct dependencies on `babel-core@6` and `babel-loader@7`.
|
||||
* If you aren't using Babel yourself, and don't have .babelrc, install following dependencies:
|
||||
```
|
||||
npm i -D babel-core@bridge @babel/core babel-loader@next
|
||||
```
|
||||
* If you're using Babel 6, make sure that you have direct dependencies on `babel-core@6` and `babel-loader@7`.
|
||||
|
||||
## From version 3.3.x to 3.4.x
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
"@angular/forms": ">=6.0.0",
|
||||
"@angular/platform-browser": ">=6.0.0",
|
||||
"@angular/platform-browser-dynamic": ">=6.0.0",
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0"
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0"
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
"react-dom": "^16.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0"
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0"
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@
|
||||
"react-dom": "^16.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0",
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"marko": "^4.10.0",
|
||||
"marko-widgets": "^7.0.1"
|
||||
}
|
||||
|
@ -34,7 +34,8 @@
|
||||
"mithril": "^1.1.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0",
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"mithril": "^1.1.6"
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,8 @@
|
||||
"polymer-webpack-loader": "^2.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0",
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"lit-html": "0.10.0",
|
||||
"polymer-webpack-loader": "2.0.2"
|
||||
}
|
||||
|
@ -36,7 +36,8 @@
|
||||
"react-emotion": "^9.1.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0",
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"react": ">=15.0.0",
|
||||
"react-dom": ">=15.0.0"
|
||||
}
|
||||
|
@ -36,7 +36,8 @@
|
||||
"vue-template-compiler": "^2.5.16"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0",
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"vue": "2.5.16",
|
||||
"vue-loader": "14.2.3",
|
||||
"vue-template-compiler": "2.5.16"
|
||||
|
@ -1,6 +1,6 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
@ -9,23 +9,19 @@ export default async npmOptions => {
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/angular',
|
||||
'@storybook/addon-notes',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
|
||||
|
||||
const packageJson = getPackageJson();
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
packageJson.dependencies = packageJson.dependencies || {};
|
||||
packageJson.devDependencies = packageJson.devDependencies || {};
|
||||
packageJson.devDependencies['@storybook/angular'] = storybookVersion;
|
||||
|
@ -1,14 +1,10 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import npmInit from '../../lib/npm_init';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersion, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [storybookVersion, babelCoreVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/html',
|
||||
'@babel/core'
|
||||
);
|
||||
const storybookVersion = await getVersion(npmOptions, '@storybook/html');
|
||||
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
|
||||
|
||||
let packageJson = getPackageJson();
|
||||
@ -21,9 +17,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies = packageJson.devDependencies || {};
|
||||
packageJson.devDependencies['@storybook/html'] = storybookVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -1,19 +1,13 @@
|
||||
import path from 'path';
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
addonActionVersion,
|
||||
addonKnobsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, addonActionVersion, addonKnobsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/marko',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-knobs',
|
||||
'@babel/core'
|
||||
'@storybook/addon-knobs'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
|
||||
@ -26,9 +20,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addon-actions'] = addonActionVersion;
|
||||
packageJson.devDependencies['@storybook/addon-knobs'] = addonKnobsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -1,21 +1,14 @@
|
||||
import path from 'path';
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/mithril',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
|
||||
@ -29,9 +22,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
packageJson.devDependencies['@storybook/mithril'] = storybookVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -1,12 +1,11 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [storybookVersion, babelCoreVersion, polymerLoaderVarion] = await getVersions(
|
||||
const [storybookVersion, polymerLoaderVarion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/polymer',
|
||||
'@babel/core',
|
||||
'polymer-webpack-loader'
|
||||
);
|
||||
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
|
||||
@ -17,9 +16,8 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies = packageJson.devDependencies || {};
|
||||
packageJson.devDependencies['@storybook/polymer'] = storybookVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
if (
|
||||
!packageJson.dependencies['polymer-webpack-loader'] &&
|
||||
!packageJson.devDependencies['polymer-webpack-loader']
|
||||
|
@ -1,21 +1,14 @@
|
||||
import path from 'path';
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/react',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
|
||||
@ -29,9 +22,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -1,22 +1,15 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/react',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
|
||||
@ -31,9 +24,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts.storybook = 'start-storybook -p 9009';
|
||||
packageJson.scripts['build-storybook'] = 'build-storybook';
|
||||
|
@ -1,21 +1,14 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/vue',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
|
||||
@ -29,9 +22,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -2,7 +2,7 @@
|
||||
import path from 'path';
|
||||
import { spawn } from 'child-process-promise';
|
||||
import { packageNames } from '@storybook/codemod';
|
||||
import { getVersion, getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersion, installBabel, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
|
||||
async function updatePackage(devDependencies, oldName, newName, npmOptions) {
|
||||
if (devDependencies[oldName]) {
|
||||
@ -11,22 +11,6 @@ async function updatePackage(devDependencies, oldName, newName, npmOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
async function addPeerDependencies(packageJson, npmOptions) {
|
||||
const [addonsVersion, babelCoreVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
);
|
||||
|
||||
packageJson.dependencies = packageJson.dependencies || {};
|
||||
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePackageJson(npmOptions) {
|
||||
const packageJson = getPackageJson();
|
||||
const { devDependencies } = packageJson;
|
||||
@ -42,7 +26,7 @@ async function updatePackageJson(npmOptions) {
|
||||
throw new Error('Expected to find `@kadira/[react-native]-storybook` in devDependencies');
|
||||
}
|
||||
|
||||
await addPeerDependencies(packageJson, npmOptions);
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
writePackageJson(packageJson);
|
||||
}
|
||||
|
@ -1,21 +1,14 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/vue',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template'), '.', 'overwrite');
|
||||
@ -29,9 +22,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -1,21 +1,14 @@
|
||||
import mergeDirs from 'merge-dirs';
|
||||
import path from 'path';
|
||||
import { getVersions, getPackageJson, writePackageJson } from '../../lib/helpers';
|
||||
import { getVersions, getPackageJson, writePackageJson, installBabel } from '../../lib/helpers';
|
||||
|
||||
export default async npmOptions => {
|
||||
const [
|
||||
storybookVersion,
|
||||
actionsVersion,
|
||||
linksVersion,
|
||||
addonsVersion,
|
||||
babelCoreVersion,
|
||||
] = await getVersions(
|
||||
const [storybookVersion, actionsVersion, linksVersion, addonsVersion] = await getVersions(
|
||||
npmOptions,
|
||||
'@storybook/react',
|
||||
'@storybook/addon-actions',
|
||||
'@storybook/addon-links',
|
||||
'@storybook/addons',
|
||||
'@babel/core'
|
||||
'@storybook/addons'
|
||||
);
|
||||
|
||||
mergeDirs(path.resolve(__dirname, 'template/'), '.', 'overwrite');
|
||||
@ -29,9 +22,7 @@ export default async npmOptions => {
|
||||
packageJson.devDependencies['@storybook/addon-links'] = linksVersion;
|
||||
packageJson.devDependencies['@storybook/addons'] = addonsVersion;
|
||||
|
||||
if (!packageJson.dependencies['@babel/core'] && !packageJson.devDependencies['@babel/core']) {
|
||||
packageJson.devDependencies['@babel/core'] = babelCoreVersion;
|
||||
}
|
||||
await installBabel(npmOptions, packageJson);
|
||||
|
||||
packageJson.scripts = packageJson.scripts || {};
|
||||
packageJson.scripts.storybook = 'start-storybook -p 6006';
|
||||
|
@ -1,15 +1,16 @@
|
||||
/* eslint-disable no-param-reassign */
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import chalk from 'chalk';
|
||||
import { sync as spawnSync } from 'cross-spawn';
|
||||
import { gt } from 'semver';
|
||||
import { gt, satisfies } from 'semver';
|
||||
import latestVersion from './latest_version';
|
||||
|
||||
import { version, devDependencies } from '../package.json';
|
||||
|
||||
const logger = console;
|
||||
|
||||
export async function getVersion(npmOptions, packageName) {
|
||||
export async function getVersion(npmOptions, packageName, constraint) {
|
||||
let current;
|
||||
if (packageName === '@storybook/cli') {
|
||||
current = version;
|
||||
@ -19,7 +20,7 @@ export async function getVersion(npmOptions, packageName) {
|
||||
|
||||
let latest;
|
||||
try {
|
||||
latest = await latestVersion(npmOptions, packageName);
|
||||
latest = await latestVersion(npmOptions, packageName, constraint);
|
||||
} catch (e) {
|
||||
if (current) {
|
||||
logger.warn(`\n ${chalk.yellow(e.message)}`);
|
||||
@ -30,7 +31,8 @@ export async function getVersion(npmOptions, packageName) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const versionToUse = current && gt(current, latest) ? current : latest;
|
||||
const versionToUse =
|
||||
current && satisfies(current, constraint) && gt(current, latest) ? current : latest;
|
||||
return `^${versionToUse}`;
|
||||
}
|
||||
|
||||
@ -162,3 +164,45 @@ export function installDeps(options) {
|
||||
}
|
||||
done();
|
||||
}
|
||||
|
||||
export async function installBabel(npmOptions, packageJson) {
|
||||
let babelLoaderVersion = '^8.0.0-0';
|
||||
|
||||
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 {
|
||||
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.'`)
|
||||
);
|
||||
}
|
||||
babelLoaderVersion = '^7.0.0';
|
||||
}
|
||||
}
|
||||
|
||||
if (!packageJson.dependencies['babel-loader'] && !packageJson.devDependencies['babel-loader']) {
|
||||
packageJson.devDependencies['babel-loader'] = await getVersion(
|
||||
npmOptions,
|
||||
'babel-loader',
|
||||
babelLoaderVersion
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,26 @@
|
||||
import { spawn } from 'cross-spawn';
|
||||
import { satisfies } from 'semver';
|
||||
|
||||
export default function latestVersion(npmOptions, packageName) {
|
||||
export default function latestVersion(npmOptions, packageName, constraint) {
|
||||
const packageManager = npmOptions.useYarn ? 'yarn' : 'npm';
|
||||
return new Promise((resolve, reject) => {
|
||||
const command = spawn(packageManager, ['info', packageName, 'version', '--json', '--silent'], {
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf-8',
|
||||
silent: true,
|
||||
});
|
||||
const command = spawn(
|
||||
packageManager,
|
||||
['info', packageName, constraint ? 'versions' : 'version', '--json', '--silent'],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf-8',
|
||||
silent: true,
|
||||
}
|
||||
);
|
||||
|
||||
const processResult = result => {
|
||||
if (!constraint) return result;
|
||||
|
||||
return result.reverse().find(version => satisfies(version, constraint));
|
||||
};
|
||||
|
||||
command.stdout.on('data', data => {
|
||||
try {
|
||||
@ -19,10 +30,10 @@ export default function latestVersion(npmOptions, packageName) {
|
||||
reject(new Error(info.error.summary));
|
||||
} else if (info.type === 'inspect') {
|
||||
// yarn success
|
||||
resolve(info.data);
|
||||
resolve(processResult(info.data));
|
||||
} else {
|
||||
// npm success
|
||||
resolve(info);
|
||||
resolve(processResult(info));
|
||||
}
|
||||
} catch (e) {
|
||||
// yarn info output
|
||||
|
4
lib/cli/test/fixtures/react_babel_6/.babelrc
vendored
Normal file
4
lib/cli/test/fixtures/react_babel_6/.babelrc
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"presets": ["react"],
|
||||
"plugins": ["external-helpers"]
|
||||
}
|
11
lib/cli/test/fixtures/react_babel_6/index.html
vendored
Normal file
11
lib/cli/test/fixtures/react_babel_6/index.html
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Hello world</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="dist/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
7
lib/cli/test/fixtures/react_babel_6/index.js
vendored
Normal file
7
lib/cli/test/fixtures/react_babel_6/index.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
ReactDOM.render(
|
||||
<h1>Hello, world!</h1>,
|
||||
document.getElementById('root')
|
||||
);
|
23
lib/cli/test/fixtures/react_babel_6/package.json
vendored
Normal file
23
lib/cli/test/fixtures/react_babel_6/package.json
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "react-babel-6-fixture",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "rollup -c"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^15.6.1",
|
||||
"react-dom": "^15.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"rollup": "^0.49.1",
|
||||
"rollup-plugin-babel": "^3.0.2",
|
||||
"rollup-plugin-commonjs": "^8.2.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"rollup-plugin-replace": "^1.1.1"
|
||||
}
|
||||
}
|
22
lib/cli/test/fixtures/react_babel_6/rollup.config.js
vendored
Normal file
22
lib/cli/test/fixtures/react_babel_6/rollup.config.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import replace from 'rollup-plugin-replace';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import babel from 'rollup-plugin-babel';
|
||||
|
||||
export default {
|
||||
input: 'index.js',
|
||||
output: {
|
||||
file: 'dist/bundle.js',
|
||||
format: 'iife'
|
||||
},
|
||||
plugins: [
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify('production')
|
||||
}),
|
||||
commonjs(),
|
||||
resolve(),
|
||||
babel({
|
||||
exclude: 'node_modules/**' // only transpile our source code
|
||||
})
|
||||
]
|
||||
};
|
@ -44,11 +44,13 @@
|
||||
"ts-node": "1.2.1",
|
||||
"tslint": "^4.3.0",
|
||||
"typescript": "~2.4.0",
|
||||
"@babel/core": "^7.0.0-beta.51",
|
||||
"@storybook/angular": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-notes": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12"
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4",
|
||||
"@storybook/angular": "^3.4.8",
|
||||
"@storybook/addon-notes": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8"
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,12 @@
|
||||
"marko": "^4.9.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/marko": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-knobs": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/marko": "^4.0.0-alpha.11",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-knobs": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4"
|
||||
},
|
||||
"scripts": {
|
||||
"storybook": "start-storybook -p 6006",
|
||||
|
@ -14,14 +14,14 @@
|
||||
"react-dom": "^16.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/preset-env": "^7.0.0-beta.51",
|
||||
"@babel/preset-react": "^7.0.0-beta.51",
|
||||
"@babel/preset-stage-0": "^7.0.0-beta.51",
|
||||
"@babel/preset-env": "^7.0.0-beta.52",
|
||||
"@babel/preset-react": "^7.0.0-beta.52",
|
||||
"@babel/preset-stage-0": "^7.0.0-beta.52",
|
||||
"babel-root-slash-import": "^1.1.0",
|
||||
"@babel/core": "^7.0.0-beta.51",
|
||||
"@storybook/react": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12"
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"@storybook/react": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8"
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,12 @@
|
||||
"mithril": "^1.1.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@storybook/mithril": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"@storybook/mithril": "^4.0.0-alpha.11",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,10 @@
|
||||
"@polymer/polymer": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/polymer": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51",
|
||||
"@storybook/polymer": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4",
|
||||
"polymer-webpack-loader": "^2.0.2"
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,12 @@
|
||||
"rollup-plugin-commonjs": "^8.2.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.0",
|
||||
"rollup-plugin-replace": "^1.1.1",
|
||||
"@storybook/react": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/react": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
@ -16,10 +16,10 @@
|
||||
"babel-preset-react-native": "3.0.1",
|
||||
"jest": "20.0.4",
|
||||
"react-test-renderer": "16.0.0-alpha.12",
|
||||
"@storybook/react-native": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@storybook/react-native": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"react-dom": "16.0.0-alpha.12",
|
||||
|
@ -6,10 +6,10 @@
|
||||
"react-native-scripts": "1.3.1",
|
||||
"jest-expo": "~20.0.0",
|
||||
"react-test-renderer": "16.0.0-alpha.12",
|
||||
"@storybook/react-native": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@storybook/react-native": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"react-dom": "16.0.0-alpha.12",
|
||||
|
@ -14,11 +14,13 @@
|
||||
"@babel/preset-react": "^7.0.0-beta.51",
|
||||
"react": "^15.6.1",
|
||||
"react-dom": "^15.6.1",
|
||||
"@storybook/react": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/react": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
|
@ -16,10 +16,12 @@
|
||||
"build-storybook": "build-storybook -s public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/react": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/react": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4"
|
||||
}
|
||||
}
|
||||
|
@ -49,10 +49,11 @@
|
||||
"webpack-dev-middleware": "^1.10.0",
|
||||
"webpack-hot-middleware": "^2.18.0",
|
||||
"webpack-merge": "^4.1.0",
|
||||
"@storybook/vue": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12"
|
||||
"@storybook/vue": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 4.0.0",
|
||||
|
@ -8,9 +8,10 @@
|
||||
"react-scripts": "0.9.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/react": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/react": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0",
|
||||
"@babel/core": "^7.0.0-beta.52",
|
||||
"babel-loader": "^8.0.0-beta.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
@ -34,10 +34,10 @@
|
||||
"rollup-plugin-serve": "^0.4.0",
|
||||
"rollup-plugin-vue": "^2.4.0",
|
||||
"rollup-watch": "^4.0.0",
|
||||
"@storybook/vue": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12",
|
||||
"@babel/core": "^7.0.0-beta.51"
|
||||
"@storybook/vue": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-loader": "^7.1.5"
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,10 @@
|
||||
"@babel/preset-react": "^7.0.0-beta.51",
|
||||
"babel-loader": "^8.0.0-beta.4",
|
||||
"webpack": "^3.5.5",
|
||||
"@storybook/react": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-actions": "^4.0.0-alpha.12",
|
||||
"@storybook/addon-links": "^4.0.0-alpha.12",
|
||||
"@storybook/addons": "^4.0.0-alpha.12"
|
||||
"@storybook/react": "^3.4.8",
|
||||
"@storybook/addon-actions": "^3.4.8",
|
||||
"@storybook/addon-links": "^3.4.8",
|
||||
"@storybook/addons": "^3.4.8",
|
||||
"babel-core": "^7.0.0-bridge.0"
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
"@storybook/ui": "4.0.0-alpha.12",
|
||||
"airbnb-js-shims": "^1.6.0",
|
||||
"autoprefixer": "^8.6.0",
|
||||
"babel-loader": "^8.0.0-beta.4",
|
||||
"babel-plugin-macros": "^2.2.2",
|
||||
"babel-preset-minify": "canary",
|
||||
"case-sensitive-paths-webpack-plugin": "^2.1.2",
|
||||
@ -68,7 +67,8 @@
|
||||
"mock-fs": "^4.5.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.41 <8.0.0",
|
||||
"babel-core": "^6.26.0 || ^7.0.0-0",
|
||||
"babel-loader": "^7.0.0 || ^8.0.0",
|
||||
"react": ">=15.0.0",
|
||||
"react-dom": ">=15.0.0"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user