Merge branch 'master' into move-server-config-to-core

This commit is contained in:
Igor 2018-03-25 12:07:53 +03:00 committed by GitHub
commit f217b9befd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 192 additions and 374 deletions

6
.github/stale.yml vendored
View File

@ -1,7 +1,7 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 45
daysUntilStale: 21
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 15
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:
- todo
@ -20,7 +20,7 @@ markComment: >
If there are still questions, comments, or bugs, please feel free to continue
the discussion. Unfortunately, we don't have time to get to every issue. We
are always open to contributions so please send us a pull request if you would
like to help. Inactive issues will be closed after 60 days. Thanks!
like to help. Inactive issues will be closed after 30 days. Thanks!
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
Hey there, it's me again! I am going close this issue to help our maintainers

View File

@ -21,7 +21,7 @@
},
"dependencies": {
"babel-runtime": "^6.26.0",
"marked": "^0.3.17",
"marked": "^0.3.18",
"prop-types": "^15.6.1",
"util-deprecate": "^1.0.2"
},

View File

@ -31,10 +31,10 @@ Usually, you might already have completed this step. If not, here are some resou
If you are using Create React App, it's already configured for Jest. You just need to create a filename with the extension `.test.js`.
Otherwise check these links:
If you aren't familiar with Jest, here are some resources:
- [Egghead lesson](https://egghead.io/lessons/javascript-test-javascript-with-jest). ***paid content***
- [Official Docs](https://facebook.github.io/jest/docs/en/getting-started.html)
- [Getting Started - Jest Official Documentation](https://facebook.github.io/jest/docs/en/getting-started.html)
- [Javascript Testing with Jest - Egghead](https://egghead.io/lessons/javascript-test-javascript-with-jest). ***paid content***
> Note: If you use React 16, you'll need to follow [these additional instructions](https://github.com/facebook/react/issues/9102#issuecomment-283873039).

View File

@ -49,7 +49,6 @@
"react": "^16.0.0",
"react-dev-utils": "^5.0.0",
"react-dom": "^16.0.0",
"redux": "^3.6.0",
"sass-loader": "^6.0.7",
"ts-loader": "^3.5.0",
"uglifyjs-webpack-plugin": "^1.2.4",

View File

@ -1,30 +1,9 @@
import { window, navigator } from 'global';
import { createStore } from 'redux';
import addons from '@storybook/addons';
import createChannel from '@storybook/channel-postmessage';
import { handleKeyboardShortcuts } from '@storybook/ui/dist/libs/key_events';
import {
StoryStore,
ClientApi,
ConfigApi,
Actions,
reducer,
syncUrlWithStore,
} from '@storybook/core/client';
import { start } from '@storybook/core/client';
import render from './render';
// check whether we're running on node/browser
const isBrowser =
navigator &&
navigator.userAgent &&
navigator.userAgent !== 'storyshots' &&
!(navigator.userAgent.indexOf('Node.js') > -1) &&
!(navigator.userAgent.indexOf('jsdom') > -1);
const { clientApi, configApi, forceReRender } = start(render);
const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const context = { storyStore, reduxStore };
const clientApi = new ClientApi(context);
export const {
storiesOf,
setAddon,
@ -34,39 +13,5 @@ export const {
getStorybook,
} = clientApi;
let channel;
if (isBrowser) {
// create preview channel
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(Actions.selectStory(data.kind, data.story));
});
addons.setChannel(channel);
Object.assign(context, { channel });
syncUrlWithStore(reduxStore);
// Handle keyboard shortcuts
window.onkeydown = handleKeyboardShortcuts(channel);
}
// Provide access to external scripts if `window` is defined.
// NOTE this is different to isBrowser, primarily for the JSDOM use case
if (typeof window !== 'undefined') {
window.__STORYBOOK_CLIENT_API__ = clientApi;
window.__STORYBOOK_ADDONS_CHANNEL__ = channel; // may not be defined
}
const configApi = new ConfigApi({ ...context, clearDecorators });
export const { configure } = configApi;
// initialize the UI
const renderUI = () => {
if (isBrowser) {
render(context);
}
};
reduxStore.subscribe(renderUI);
export const forceReRender = () => render(context, true);
export { forceReRender };

View File

@ -28,7 +28,7 @@
"@storybook/core": "3.4.0-rc.3",
"@storybook/node-logger": "3.4.0-rc.3",
"@storybook/ui": "3.4.0-rc.3",
"@webcomponents/webcomponentsjs": "^1.1.0",
"@webcomponents/webcomponentsjs": "^1.1.1",
"airbnb-js-shims": "^1.4.1",
"babel-loader": "^7.1.4",
"babel-plugin-macros": "^2.2.0",
@ -51,7 +51,6 @@
"react": "^16.0.0",
"react-dev-utils": "^5.0.0",
"react-dom": "^16.0.0",
"redux": "^3.7.2",
"uglifyjs-webpack-plugin": "^1.2.4",
"util-deprecate": "^1.0.2",
"webpack": "^3.11.0",

View File

@ -1,32 +1,9 @@
import { createStore } from 'redux';
import addons from '@storybook/addons';
import { navigator, window } from 'global';
import createChannel from '@storybook/channel-postmessage';
import { handleKeyboardShortcuts } from '@storybook/ui/dist/libs/key_events';
import {
StoryStore,
ClientApi,
ConfigApi,
Actions,
reducer,
syncUrlWithStore,
} from '@storybook/core/client';
import { start } from '@storybook/core/client';
import render from './render';
// check whether we're running on node/browser
const isBrowser =
navigator &&
navigator.userAgent &&
navigator.userAgent !== 'storyshots' &&
!(navigator.userAgent.indexOf('Node.js') > -1) &&
!(navigator.userAgent.indexOf('jsdom') > -1);
const { clientApi, configApi, forceReRender } = start(render);
const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const context = { storyStore, reduxStore };
const clientApi = new ClientApi(context);
export const {
storiesOf,
setAddon,
@ -36,39 +13,5 @@ export const {
getStorybook,
} = clientApi;
let channel;
if (isBrowser) {
// setup preview channel
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(Actions.selectStory(data.kind, data.story));
});
addons.setChannel(channel);
Object.assign(context, { channel });
syncUrlWithStore(reduxStore);
// Handle keyboard shortcuts
window.onkeydown = handleKeyboardShortcuts(channel);
}
// Provide access to external scripts if `window` is defined.
// NOTE this is different to isBrowser, primarily for the JSDOM use case
if (typeof window !== 'undefined') {
window.__STORYBOOK_CLIENT_API__ = clientApi;
window.__STORYBOOK_ADDONS_CHANNEL__ = channel; // may not be defined
}
const configApi = new ConfigApi({ clearDecorators, ...context });
export const { configure } = configApi;
// initialize the UI
const renderUI = () => {
if (isBrowser) {
render(context);
}
};
reduxStore.subscribe(renderUI);
export const forceReRender = () => render(context, true);
export { forceReRender };

View File

@ -2,16 +2,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { ifIphoneX } from 'react-native-iphone-x-helper';
import {
Animated,
Dimensions,
Easing,
View,
TouchableWithoutFeedback,
Image,
Text,
StatusBar,
} from 'react-native';
import { Dimensions, View, TouchableWithoutFeedback, Image, Text, StatusBar } from 'react-native';
import style from './style';
import StoryListView from '../StoryListView';
import StoryView from '../StoryView';
@ -34,7 +25,6 @@ export default class OnDeviceUI extends Component {
super(...args);
this.state = {
menuAnimation: new Animated.Value(0),
isMenuOpen: false,
selectedKind: null,
selectedStory: null,
@ -71,22 +61,14 @@ export default class OnDeviceUI extends Component {
};
handleToggleMenu = () => {
const isMenuOpen = !this.state.isMenuOpen;
Animated.timing(this.state.menuAnimation, {
toValue: isMenuOpen ? 1 : 0,
duration: 150,
easing: Easing.linear,
}).start();
this.setState({
isMenuOpen,
isMenuOpen: !this.state.isMenuOpen,
});
};
render() {
const { stories, events, url } = this.props;
const { isPortrait, menuAnimation, selectedKind, selectedStory } = this.state;
const { isPortrait, isMenuOpen, selectedKind, selectedStory } = this.state;
const iPhoneXStyles = ifIphoneX(
isPortrait
@ -104,10 +86,7 @@ export default class OnDeviceUI extends Component {
{
transform: [
{
translateX: menuAnimation.interpolate({
inputRange: [0, 1],
outputRange: [-DRAWER_WIDTH - 30, 0],
}),
translateX: isMenuOpen ? 0 : -DRAWER_WIDTH - 30,
},
],
},
@ -117,10 +96,7 @@ export default class OnDeviceUI extends Component {
const headerStyles = [
style.headerContainer,
{
opacity: menuAnimation.interpolate({
inputRange: [0, 1],
outputRange: [1, 0],
}),
opacity: +!isMenuOpen,
},
];
@ -144,7 +120,7 @@ export default class OnDeviceUI extends Component {
return (
<View style={style.main}>
<View style={previewContainerStyles}>
<Animated.View style={headerStyles}>
<View style={headerStyles}>
<TouchableWithoutFeedback
onPress={this.handleToggleMenu}
testID="Storybook.OnDeviceUI.open"
@ -157,14 +133,14 @@ export default class OnDeviceUI extends Component {
<Text style={style.headerText} numberOfLines={1}>
{selectedKind} {selectedStory}
</Text>
</Animated.View>
</View>
<View style={previewWrapperStyles}>
<View style={style.preview}>
<StoryView url={url} events={events} />
</View>
</View>
</View>
<Animated.View style={menuStyles}>
<View style={menuStyles}>
<TouchableWithoutFeedback
onPress={this.handleToggleMenu}
testID="Storybook.OnDeviceUI.close"
@ -181,7 +157,7 @@ export default class OnDeviceUI extends Component {
selectedKind={selectedKind}
selectedStory={selectedStory}
/>
</Animated.View>
</View>
</View>
);
}

View File

@ -25,7 +25,7 @@ export default {
right: null,
paddingHorizontal: 10,
paddingBottom: 10,
backgroundColor: 'rgba(255, 255, 255, 0.8)',
backgroundColor: 'white',
},
previewContainer: {
flex: 1,

View File

@ -73,11 +73,9 @@ export default class Preview {
this._sendGetCurrentStory();
// finally return the preview component
return params.onDeviceUI ? (
<OnDeviceUI stories={this._stories} events={this._events} url={webUrl} />
) : (
<StoryView url={webUrl} events={this._events} />
);
return params.onDeviceUI
? <OnDeviceUI stories={this._stories} events={this._events} url={webUrl} />
: <StoryView url={webUrl} events={this._events} />;
};
}

View File

@ -57,7 +57,6 @@
"markdown-loader": "^2.0.2",
"prop-types": "^15.6.1",
"react-dev-utils": "^5.0.0",
"redux": "^3.7.2",
"uglifyjs-webpack-plugin": "^1.2.4",
"util-deprecate": "^1.0.2",
"webpack": "^3.11.0",

View File

@ -1,32 +1,9 @@
import { createStore } from 'redux';
import addons from '@storybook/addons';
import { navigator, window } from 'global';
import createChannel from '@storybook/channel-postmessage';
import { handleKeyboardShortcuts } from '@storybook/ui/dist/libs/key_events';
import {
StoryStore,
ClientApi,
ConfigApi,
Actions,
reducer,
syncUrlWithStore,
} from '@storybook/core/client';
import { start } from '@storybook/core/client';
import render from './render';
// check whether we're running on node/browser
const isBrowser =
navigator &&
navigator.userAgent &&
navigator.userAgent !== 'storyshots' &&
!(navigator.userAgent.indexOf('Node.js') > -1) &&
!(navigator.userAgent.indexOf('jsdom') > -1);
const { clientApi, configApi, forceReRender } = start(render);
const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const context = { storyStore, reduxStore };
const clientApi = new ClientApi(context);
export const {
storiesOf,
setAddon,
@ -36,39 +13,5 @@ export const {
getStorybook,
} = clientApi;
let channel;
if (isBrowser) {
// setup preview channel
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(Actions.selectStory(data.kind, data.story));
});
addons.setChannel(channel);
Object.assign(context, { channel });
syncUrlWithStore(reduxStore);
// Handle keyboard shortcuts
window.onkeydown = handleKeyboardShortcuts(channel);
}
// Provide access to external scripts if `window` is defined.
// NOTE this is different to isBrowser, primarily for the JSDOM use case
if (typeof window !== 'undefined') {
window.__STORYBOOK_CLIENT_API__ = clientApi;
window.__STORYBOOK_ADDONS_CHANNEL__ = channel; // may not be defined
}
const configApi = new ConfigApi({ clearDecorators, ...context });
export const { configure } = configApi;
// initialize the UI
const renderUI = () => {
if (isBrowser) {
render(context);
}
};
reduxStore.subscribe(renderUI);
export const forceReRender = () => render(context, true);
export { forceReRender };

View File

@ -49,7 +49,6 @@
"react": "^16.2.0",
"react-dev-utils": "^5.0.0",
"react-dom": "^16.2.0",
"redux": "^3.7.2",
"uglifyjs-webpack-plugin": "^1.2.4",
"util-deprecate": "^1.0.2",
"webpack": "^3.11.0",
@ -58,14 +57,14 @@
"devDependencies": {
"nodemon": "^1.17.2",
"vue": "^2.5.16",
"vue-loader": "^14.2.1",
"vue-loader": "^14.2.2",
"vue-template-compiler": "^2.5.16"
},
"peerDependencies": {
"babel-core": "^6.26.0 || ^7.0.0-0",
"babel-runtime": ">=6.0.0",
"vue": "2.5.16",
"vue-loader": "14.2.1",
"vue-loader": "14.2.2",
"vue-template-compiler": "2.5.16"
}
}

View File

@ -1,30 +1,7 @@
import { createStore } from 'redux';
import addons from '@storybook/addons';
import createChannel from '@storybook/channel-postmessage';
import { navigator, window } from 'global';
import { handleKeyboardShortcuts } from '@storybook/ui/dist/libs/key_events';
import {
StoryStore,
ClientApi,
ConfigApi,
Actions,
reducer,
syncUrlWithStore,
} from '@storybook/core/client';
import { start } from '@storybook/core/client';
import render from './render';
// check whether we're running on node/browser
const isBrowser =
navigator &&
navigator.userAgent &&
navigator.userAgent !== 'storyshots' &&
!(navigator.userAgent.indexOf('Node.js') > -1) &&
!(navigator.userAgent.indexOf('jsdom') > -1);
const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const createWrapperComponent = Target => ({
functional: true,
render(h, c) {
@ -42,8 +19,9 @@ const decorateStory = (getStory, decorators) =>
},
getStory
);
const context = { storyStore, reduxStore, decorateStory };
const clientApi = new ClientApi(context);
const { clientApi, configApi, forceReRender } = start(render, { decorateStory });
export const {
storiesOf,
setAddon,
@ -53,39 +31,5 @@ export const {
getStorybook,
} = clientApi;
let channel;
if (isBrowser) {
// create preview channel
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(Actions.selectStory(data.kind, data.story));
});
addons.setChannel(channel);
Object.assign(context, { channel });
syncUrlWithStore(reduxStore);
// Handle keyboard shortcuts
window.onkeydown = handleKeyboardShortcuts(channel);
}
// Provide access to external scripts if `window` is defined.
// NOTE this is different to isBrowser, primarily for the JSDOM use case
if (typeof window !== 'undefined') {
window.__STORYBOOK_CLIENT_API__ = clientApi;
window.__STORYBOOK_ADDONS_CHANNEL__ = channel; // may not be defined
}
const configApi = new ConfigApi({ ...context, clearDecorators });
export const { configure } = configApi;
// initialize the UI
const renderUI = () => {
if (isBrowser) {
render(context);
}
};
reduxStore.subscribe(renderUI);
export const forceReRender = () => render(context, true);
export { forceReRender };

View File

@ -24,12 +24,12 @@
"@storybook/react": "^3.3.15",
"babel-loader": "^6.4.1",
"bootstrap": "^3.3.7",
"gatsby": "^1.9.238",
"gatsby": "^1.9.240",
"gatsby-link": "^1.6.39",
"gatsby-plugin-sharp": "^1.6.41",
"gatsby-remark-autolink-headers": "^1.4.13",
"gatsby-remark-copy-linked-files": "^1.5.30",
"gatsby-remark-images": "^1.5.56",
"gatsby-remark-images": "^1.5.59",
"gatsby-remark-smartypants": "^1.4.12",
"gatsby-source-filesystem": "^1.5.27",
"gatsby-transformer-remark": "^1.7.37",
@ -37,7 +37,7 @@
"global": "^4.3.2",
"highlight.js": "^9.12.0",
"lodash": "^4.17.5",
"marked": "^0.3.17",
"marked": "^0.3.18",
"prop-types": "^15.6.1",
"react": "^15.6.1",
"react-document-title": "^2.0.3",

View File

@ -19,6 +19,13 @@ lonelyplanet:
source: https://github.com/lonelyplanet/backpack-ui
demo: https://lonelyplanet.github.io/backpack-ui/
site: https://www.lonelyplanet.com/
uber:
thumbnail: uber.png
title: Uber React-Vis
description: A composable charting library.
source: https://github.com/uber/react-vis
demo: https://uber.github.io/react-vis/website/dist/storybook/index.html
site: https://uber.github.io/react-vis/
atlassian:
thumbnail: atlassian.png
title: Atlassian AtlasKit

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -4455,9 +4455,9 @@ gatsby-1-config-extract-plugin@^1.0.2:
babel-runtime "^6.26.0"
extract-text-webpack-plugin "^1.0.1"
gatsby-cli@^1.1.46:
version "1.1.46"
resolved "https://registry.yarnpkg.com/gatsby-cli/-/gatsby-cli-1.1.46.tgz#ebbca830805c63f6ef5be0a0c4d308dd597ad10b"
gatsby-cli@^1.1.48:
version "1.1.48"
resolved "https://registry.yarnpkg.com/gatsby-cli/-/gatsby-cli-1.1.48.tgz#7ce1e15e5c02195ff4d8981a23a385e51e7d6cf0"
dependencies:
babel-code-frame "^6.26.0"
babel-runtime "^6.26.0"
@ -4494,23 +4494,6 @@ gatsby-module-loader@^1.0.11:
babel-runtime "^6.26.0"
loader-utils "^0.2.16"
gatsby-plugin-sharp@^1.6.39:
version "1.6.39"
resolved "https://registry.yarnpkg.com/gatsby-plugin-sharp/-/gatsby-plugin-sharp-1.6.39.tgz#842a814f0f68470b703830e36c51c95083678265"
dependencies:
async "^2.1.2"
babel-runtime "^6.26.0"
bluebird "^3.5.0"
imagemin "^5.2.2"
imagemin-pngquant "^5.0.0"
imagemin-webp "^4.0.0"
lodash "^4.17.4"
potrace "^2.1.1"
probe-image-size "^3.2.0"
progress "^1.1.8"
sharp "^0.20.0"
svgo "^0.7.2"
gatsby-plugin-sharp@^1.6.41:
version "1.6.41"
resolved "https://registry.yarnpkg.com/gatsby-plugin-sharp/-/gatsby-plugin-sharp-1.6.41.tgz#87dc28d226d70e63408bf31983268efdf10e8b1d"
@ -4558,13 +4541,13 @@ gatsby-remark-copy-linked-files@^1.5.30:
probe-image-size "^3.2.0"
unist-util-visit "^1.1.1"
gatsby-remark-images@^1.5.56:
version "1.5.56"
resolved "https://registry.yarnpkg.com/gatsby-remark-images/-/gatsby-remark-images-1.5.56.tgz#f3dd9323b6eed803d5388a3a688ae22c82578d97"
gatsby-remark-images@^1.5.59:
version "1.5.59"
resolved "https://registry.yarnpkg.com/gatsby-remark-images/-/gatsby-remark-images-1.5.59.tgz#2701f4812698d492a3114b6014bb6c2e120837ff"
dependencies:
babel-runtime "^6.26.0"
cheerio "^1.0.0-rc.2"
gatsby-plugin-sharp "^1.6.39"
gatsby-plugin-sharp "^1.6.41"
is-relative-url "^2.0.0"
lodash "^4.17.4"
slash "^1.0.0"
@ -4620,9 +4603,9 @@ gatsby-transformer-remark@^1.7.37:
unist-util-select "^1.5.0"
unist-util-visit "^1.1.1"
gatsby@^1.9.238:
version "1.9.238"
resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-1.9.238.tgz#b97354208e60140c2d7f2a369494b20e8138f540"
gatsby@^1.9.240:
version "1.9.240"
resolved "https://registry.yarnpkg.com/gatsby/-/gatsby-1.9.240.tgz#08e56c5dc4a2494b8483833cc040119ffa83e96e"
dependencies:
async "^2.1.2"
babel-code-frame "^6.22.0"
@ -4664,7 +4647,7 @@ gatsby@^1.9.238:
fs-extra "^4.0.1"
gatsby-1-config-css-modules "^1.0.10"
gatsby-1-config-extract-plugin "^1.0.2"
gatsby-cli "^1.1.46"
gatsby-cli "^1.1.48"
gatsby-link "^1.6.39"
gatsby-module-loader "^1.0.11"
gatsby-react-router-scroll "^1.0.14"
@ -6847,9 +6830,9 @@ markdown-table@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.1.tgz#4b3dd3a133d1518b8ef0dbc709bf2a1b4824bc8c"
marked@^0.3.17:
version "0.3.17"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.17.tgz#607f06668b3c6b1246b28f13da76116ac1aa2d2b"
marked@^0.3.18:
version "0.3.18"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.18.tgz#3ef058cd926101849b92a7a7c15db18c7fc76b2f"
marked@^0.3.6:
version "0.3.9"

View File

@ -37,7 +37,7 @@
"@storybook/addons": "3.4.0-rc.3",
"@storybook/angular": "3.4.0-rc.3",
"@types/jasmine": "~2.8.6",
"@types/node": "~9.4.7",
"@types/node": "~9.6.0",
"global": "^4.3.2",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",

View File

@ -8,7 +8,7 @@
"storybook": "start-storybook -p 9001 -c .storybook"
},
"dependencies": {
"@polymer/polymer": "^2.5.0",
"@polymer/polymer": "^2.6.0",
"@storybook/addon-actions": "3.4.0-rc.3",
"@storybook/addon-knobs": "3.4.0-rc.3",
"@storybook/addon-links": "3.4.0-rc.3",
@ -17,7 +17,7 @@
"@storybook/addon-storysource": "3.4.0-rc.3",
"@storybook/addon-viewport": "3.4.0-rc.3",
"@storybook/polymer": "3.4.0-rc.3",
"@webcomponents/webcomponentsjs": "^1.1.0",
"@webcomponents/webcomponentsjs": "^1.1.1",
"global": "^4.3.2",
"polymer-webpack-loader": "^2.0.2",
"webpack": "^3.11.0"

View File

@ -31,7 +31,7 @@
"cross-env": "^5.1.4",
"file-loader": "^1.1.11",
"svg-url-loader": "^2.3.2",
"vue-loader": "^14.2.1",
"vue-loader": "^14.2.2",
"webpack": "^3.11.0",
"webpack-dev-server": "^2.11.2"
}

View File

@ -1,9 +1,9 @@
import path from 'path';
import fs from 'fs';
import chalk from 'chalk';
import latestVersion from 'latest-version';
import { sync as spawnSync } from 'cross-spawn';
import { gt } from 'semver';
import latestVersion from './latest_version';
import { version, devDependencies } from '../package.json';

View File

@ -0,0 +1,17 @@
import { sync as spawnSync } from 'cross-spawn';
import hasYarn from './has_yarn';
const packageManager = hasYarn() ? 'yarn' : 'npm';
export default async function latestVersion(packageName) {
const result = spawnSync(packageManager, ['info', packageName, '--json'], {
cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
encoding: 'utf-8',
silent: true,
});
const info = JSON.parse(result.output[1].toString());
return info.data.version;
}

View File

@ -36,7 +36,6 @@
"cross-spawn": "^6.0.5",
"jscodeshift": "^0.5.0",
"json5": "^0.5.1",
"latest-version": "^3.1.0",
"merge-dirs": "^0.2.1",
"semver": "^5.5.0",
"shelljs": "^0.8.1",

View File

@ -22,7 +22,7 @@
"@storybook/client-logger": "3.4.0-rc.3",
"@storybook/node-logger": "3.4.0-rc.3",
"@storybook/ui": "3.4.0-rc.3",
"autoprefixer": "^8.1.0",
"autoprefixer": "^8.2.0",
"babel-runtime": "^6.26.0",
"chalk": "^2.3.2",
"commander": "^2.15.1",
@ -41,6 +41,7 @@
"qs": "^6.5.1",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"redux": "^3.7.2",
"serve-favicon": "^2.4.5",
"shelljs": "^0.8.1",
"style-loader": "^0.20.3",

View File

@ -1,3 +1,4 @@
import start from './start';
import * as Actions from './actions';
import ClientApi from './client_api';
import ConfigApi from './config_api';
@ -5,4 +6,4 @@ import StoryStore from './story_store';
import reducer from './reducer';
import syncUrlWithStore from './syncUrlWithStore';
export default { Actions, ClientApi, ConfigApi, StoryStore, reducer, syncUrlWithStore };
export default { start, Actions, ClientApi, ConfigApi, StoryStore, reducer, syncUrlWithStore };

View File

@ -0,0 +1,65 @@
import { createStore } from 'redux';
import addons from '@storybook/addons';
import { navigator, window } from 'global';
import createChannel from '@storybook/channel-postmessage';
import { handleKeyboardShortcuts } from '@storybook/ui/dist/libs/key_events';
import StoryStore from './story_store';
import ClientApi from './client_api';
import ConfigApi from './config_api';
import reducer from './reducer';
import * as Actions from './actions';
import syncUrlWithStore from './syncUrlWithStore';
export default function start(render, { decorateStory } = {}) {
// check whether we're running on node/browser
const isBrowser =
navigator &&
navigator.userAgent &&
navigator.userAgent !== 'storyshots' &&
!(navigator.userAgent.indexOf('Node.js') > -1) &&
!(navigator.userAgent.indexOf('jsdom') > -1);
const storyStore = new StoryStore();
const reduxStore = createStore(reducer);
const context = { storyStore, reduxStore, decorateStory };
const clientApi = new ClientApi(context);
let channel;
if (isBrowser) {
// setup preview channel
channel = createChannel({ page: 'preview' });
channel.on('setCurrentStory', data => {
reduxStore.dispatch(Actions.selectStory(data.kind, data.story));
});
addons.setChannel(channel);
Object.assign(context, { channel });
syncUrlWithStore(reduxStore);
// Handle keyboard shortcuts
window.onkeydown = handleKeyboardShortcuts(channel);
}
// Provide access to external scripts if `window` is defined.
// NOTE this is different to isBrowser, primarily for the JSDOM use case
if (typeof window !== 'undefined') {
window.__STORYBOOK_CLIENT_API__ = clientApi;
window.__STORYBOOK_ADDONS_CHANNEL__ = channel; // may not be defined
}
const { clearDecorators } = clientApi;
const configApi = new ConfigApi({ clearDecorators, ...context });
// initialize the UI
const renderUI = () => {
if (isBrowser) {
render(context);
}
};
reduxStore.subscribe(renderUI);
return { context, clientApi, configApi, forceReRender: () => render(context, true) };
}

View File

@ -59,7 +59,7 @@
"danger": "^3.3.2",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^4.19.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.9.0",

View File

@ -250,9 +250,9 @@
lodash "^4.17.4"
url-template "^2.0.8"
"@polymer/polymer@^2.5.0":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@polymer/polymer/-/polymer-2.5.0.tgz#261439f5ab691c230d0c5dfb518b9247064ac13d"
"@polymer/polymer@^2.6.0":
version "2.6.0"
resolved "https://registry.yarnpkg.com/@polymer/polymer/-/polymer-2.6.0.tgz#98601124122a045e74f4b41f55975006ef327dbc"
"@schematics/angular@0.3.2":
version "0.3.2"
@ -336,9 +336,9 @@
version "6.0.96"
resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.96.tgz#7bf0bf40d6ce51e93762cc47d010c8cc5ebb2179"
"@types/node@~9.4.7":
version "9.4.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275"
"@types/node@~9.6.0":
version "9.6.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.0.tgz#d3480ee666df9784b1001a1872a2f6ccefb6c2d7"
"@types/parse5@^2.2.32":
version "2.2.34"
@ -366,9 +366,9 @@
version "0.0.30"
resolved "https://registry.yarnpkg.com/@types/strip-json-comments/-/strip-json-comments-0.0.30.tgz#9aa30c04db212a9a0649d6ae6fd50accc40748a1"
"@webcomponents/webcomponentsjs@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@webcomponents/webcomponentsjs/-/webcomponentsjs-1.1.0.tgz#1392799c266fca142622a720176f688beb74d181"
"@webcomponents/webcomponentsjs@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@webcomponents/webcomponentsjs/-/webcomponentsjs-1.1.1.tgz#50caffdf8a901e5357532b7d85e776637a56446a"
JSONStream@^1.0.3, JSONStream@^1.0.4, JSONStream@~1.3.1:
version "1.3.2"
@ -988,15 +988,15 @@ autoprefixer@^7.2.3:
postcss "^6.0.16"
postcss-value-parser "^3.2.3"
autoprefixer@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-8.1.0.tgz#374cf35be1c0e8fce97408d876f95f66f5cb4641"
autoprefixer@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-8.2.0.tgz#1e49b611b31a5259b86b7a6b2b1b8faf091abe2a"
dependencies:
browserslist "^3.1.1"
caniuse-lite "^1.0.30000810"
browserslist "^3.2.0"
caniuse-lite "^1.0.30000817"
normalize-range "^0.1.2"
num2fraction "^1.2.2"
postcss "^6.0.19"
postcss "^6.0.20"
postcss-value-parser "^3.2.3"
aws-sign2@~0.6.0:
@ -2699,12 +2699,12 @@ browserslist@^2.1.2, browserslist@^2.11.1, browserslist@^2.5.1:
caniuse-lite "^1.0.30000789"
electron-to-chromium "^1.3.30"
browserslist@^3.1.1:
version "3.2.0"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.0.tgz#3d4a99710c12101e4567c9aeedade49c958cb883"
browserslist@^3.2.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.1.tgz#4960a45fbfe39b2be36fe5ba07cce9ea32c8221c"
dependencies:
caniuse-lite "^1.0.30000815"
electron-to-chromium "^1.3.39"
caniuse-lite "^1.0.30000819"
electron-to-chromium "^1.3.40"
bser@1.0.2:
version "1.0.2"
@ -2953,9 +2953,9 @@ caniuse-lite@^1.0.30000748, caniuse-lite@^1.0.30000789, caniuse-lite@^1.0.300007
version "1.0.30000791"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000791.tgz#8e35745efd483a3e23bb7d350990326d2319fc16"
caniuse-lite@^1.0.30000810, caniuse-lite@^1.0.30000815:
version "1.0.30000817"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000817.tgz#e993c380eb4bfe76a2aed4223f841c02d6e0d832"
caniuse-lite@^1.0.30000817, caniuse-lite@^1.0.30000819:
version "1.0.30000819"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000819.tgz#aabee5fd15a080febab6ae5d30c9ea15f4c6d4e2"
capture-stack-trace@^1.0.0:
version "1.0.0"
@ -4890,7 +4890,7 @@ electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.30:
dependencies:
electron-releases "^2.1.0"
electron-to-chromium@^1.3.39:
electron-to-chromium@^1.3.40:
version "1.3.40"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.40.tgz#1fbd6d97befd72b8a6f921dc38d22413d2f6fddf"
@ -5435,9 +5435,9 @@ eslint@4.10.0:
table "^4.0.1"
text-table "~0.2.0"
eslint@^4.19.0:
version "4.19.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.0.tgz#9e900efb5506812ac374557034ef6f5c3642fc4c"
eslint@^4.19.1:
version "4.19.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.19.1.tgz#32d1d653e1d90408854bfb296f076ec7e186a300"
dependencies:
ajv "^5.3.0"
babel-code-frame "^6.22.0"
@ -9304,7 +9304,7 @@ latest-version@^2.0.0:
dependencies:
package-json "^2.0.0"
latest-version@^3.0.0, latest-version@^3.1.0:
latest-version@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15"
dependencies:
@ -10128,9 +10128,9 @@ markdown-table@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.1.tgz#4b3dd3a133d1518b8ef0dbc709bf2a1b4824bc8c"
marked@^0.3.17:
version "0.3.17"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.17.tgz#607f06668b3c6b1246b28f13da76116ac1aa2d2b"
marked@^0.3.18:
version "0.3.18"
resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.18.tgz#3ef058cd926101849b92a7a7c15db18c7fc76b2f"
marked@^0.3.9:
version "0.3.12"
@ -12282,9 +12282,9 @@ postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.13, postcss@^6.0.16, postcss@^6.0.8
source-map "^0.6.1"
supports-color "^5.1.0"
postcss@^6.0.19:
version "6.0.20"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.20.tgz#686107e743a12d5530cb68438c590d5b2bf72c3c"
postcss@^6.0.20:
version "6.0.21"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.21.tgz#8265662694eddf9e9a5960db6da33c39e4cd069d"
dependencies:
chalk "^2.3.2"
source-map "^0.6.1"
@ -13395,7 +13395,7 @@ reduce-function-call@^1.0.1:
dependencies:
balanced-match "^0.4.2"
redux@^3.6.0, redux@^3.7.2:
redux@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b"
dependencies:
@ -16418,9 +16418,9 @@ vue-hot-reload-api@^2.2.0:
version "2.2.4"
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.2.4.tgz#683bd1d026c0d3b3c937d5875679e9a87ec6cd8f"
vue-loader@^14.2.1:
version "14.2.1"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-14.2.1.tgz#3ace19f98187b1fa9e0709defa963a0a2396b6b3"
vue-loader@^14.2.2:
version "14.2.2"
resolved "https://registry.yarnpkg.com/vue-loader/-/vue-loader-14.2.2.tgz#c8cf3c2e29b6fb2ee595248a2aa6005038a125b3"
dependencies:
consolidate "^0.14.0"
hash-sum "^1.0.2"