Skip to content

Commit

Permalink
fix: use modern build of storybook to fix unresolved promises and oth…
Browse files Browse the repository at this point in the history
…er issues caused by polyfills [6.0] (#174)

* fix(): update all dependencies to latest alpha with fix for polyfils

* refactor: promise finally button

* refactor: rename the globtest folder
  • Loading branch information
dannyhw authored May 20, 2021
1 parent 61eb53a commit aa40501
Show file tree
Hide file tree
Showing 25 changed files with 2,609 additions and 1,783 deletions.
6 changes: 3 additions & 3 deletions addons/ondevice-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addons": "6.0.28",
"@storybook/core-events": "6.0.28",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/core-events": "6.3.0-alpha.33",
"core-js": "^3.0.1",
"fast-deep-equal": "^2.0.1"
},
"devDependencies": {
"@storybook/addon-actions": "6.0.28"
"@storybook/addon-actions": "6.3.0-alpha.33"
},
"peerDependencies": {
"@storybook/addon-actions": "*",
Expand Down
6 changes: 3 additions & 3 deletions addons/ondevice-backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addons": "6.0.28",
"@storybook/api": "6.0.28",
"@storybook/client-api": "6.0.28",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/api": "6.3.0-alpha.33",
"@storybook/client-api": "6.3.0-alpha.33",
"core-js": "^3.0.1",
"prop-types": "^15.7.2"
},
Expand Down
8 changes: 4 additions & 4 deletions addons/ondevice-knobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
},
"dependencies": {
"@emotion/native": "^10.0.14",
"@storybook/addons": "6.0.28",
"@storybook/core-events": "6.0.28",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/core-events": "6.3.0-alpha.33",
"core-js": "^3.0.1",
"deep-equal": "^1.0.1",
"prop-types": "^15.7.2",
Expand All @@ -38,10 +38,10 @@
"tinycolor2": "^1.4.1"
},
"devDependencies": {
"@storybook/addon-knobs": "6.0.28"
"@storybook/addon-knobs": "6.3.0-alpha.21"
},
"peerDependencies": {
"@storybook/addon-knobs": "6.0.28",
"@storybook/addon-knobs": "^6",
"react": "*",
"react-native": "*"
},
Expand Down
10 changes: 5 additions & 5 deletions addons/ondevice-notes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
},
"dependencies": {
"@emotion/core": "^10.0.20",
"@storybook/addons": "6.0.28",
"@storybook/api": "6.0.28",
"@storybook/client-api": "6.0.28",
"@storybook/client-logger": "6.0.28",
"@storybook/core-events": "6.0.28",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/api": "6.3.0-alpha.33",
"@storybook/client-api": "6.3.0-alpha.33",
"@storybook/client-logger": "6.3.0-alpha.33",
"@storybook/core-events": "6.3.0-alpha.33",
"core-js": "^3.0.1",
"prop-types": "^15.7.2",
"react-native-simple-markdown": "^1.1.0"
Expand Down
12 changes: 6 additions & 6 deletions app/react-native-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addons": "6.0.28",
"@storybook/api": "6.0.28",
"@storybook/channel-websocket": "6.0.28",
"@storybook/core": "6.0.28",
"@storybook/core-events": "6.0.28",
"@storybook/ui": "6.0.28",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/api": "6.3.0-alpha.33",
"@storybook/channel-websocket": "6.3.0-alpha.33",
"@storybook/core": "6.3.0-alpha.33",
"@storybook/core-events": "6.3.0-alpha.33",
"@storybook/ui": "6.3.0-alpha.33",
"commander": "^4.0.1",
"core-js": "^3.0.1",
"global": "^4.3.2",
Expand Down
2 changes: 1 addition & 1 deletion app/react-native-server/src/client/manager/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Consumer } from '@storybook/api';
import { Provider } from '@storybook/ui';
import createChannel from '@storybook/channel-websocket';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import Events from '@storybook/core-events';
import uuid from 'uuid';
import PreviewHelp from './components/PreviewHelp';
Expand Down
26 changes: 0 additions & 26 deletions app/react-native/babel.js

This file was deleted.

12 changes: 6 additions & 6 deletions app/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
"babel.js"
],
"scripts": {
"prepare": "node ../../scripts/prepare.js"
"prepare": "tsc"
},
"dependencies": {
"@emotion/core": "^10.0.20",
"@emotion/native": "^10.0.14",
"@storybook/addons": "6.0.28",
"@storybook/channel-websocket": "6.0.28",
"@storybook/channels": "6.0.28",
"@storybook/client-api": "6.0.28",
"@storybook/core-events": "6.0.28",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/channel-websocket": "6.3.0-alpha.33",
"@storybook/channels": "6.3.0-alpha.33",
"@storybook/client-api": "6.3.0-alpha.33",
"@storybook/core-events": "6.3.0-alpha.33",
"chokidar": "^3.4.3",
"core-js": "^3.0.1",
"emotion-theming": "^10.0.19",
Expand Down
14 changes: 8 additions & 6 deletions app/react-native/src/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from 'react';
import { ThemeProvider } from 'emotion-theming';

import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import Events from '@storybook/core-events';
import Channel from '@storybook/channels';
import { StoryStore, ClientApi } from '@storybook/client-api';
Expand Down Expand Up @@ -75,10 +75,12 @@ export default class Preview {
if (modules && modules.length > 0) {
modules.forEach((m) => {
const { default: meta, ...namedExports } = m;
const kind = this._clientApi.storiesOf(meta.title, m);
Object.entries(namedExports).forEach(([name, storyFn], i) => {
kind.add(name, storyFn as any);
});
if (meta) {
const kind = this._clientApi.storiesOf(meta.title, m);
Object.entries(namedExports).forEach(([name, storyFn], i) => {
kind.add(name, storyFn as any);
});
}
});
}
};
Expand All @@ -101,7 +103,7 @@ export default class Preview {
this._asyncStorage = params.asyncStorage;
}

this._channel.on(Events.SET_CURRENT_STORY, (d) => {
this._channel.on(Events.SET_CURRENT_STORY, (d: { storyId: string }) => {
this._selectStoryEvent(d);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/native';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import Channel from '@storybook/channels';
import { StoryStore } from '@storybook/client-api';
import React, { PureComponent } from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import { SafeAreaView } from 'react-native';
import styled from '@emotion/native';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import AddonsList from './List';
import AddonWrapper from './Wrapper';
import { Label } from '../../Shared/text';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import styled from '@emotion/native';
import addons from '@storybook/addons';
import { StoryStore } from '@storybook/client-api';
import { StoreItem } from '@storybook/client-api/dist/types';
import { addons } from '@storybook/addons';
import { StoryStore, StoreItem } from '@storybook/client-api';
import Events from '@storybook/core-events';
import React, { Component, FunctionComponent } from 'react';
import { StyleSheet } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { StoreItem } from '@storybook/client-api/dist/types';
import { StoreItem } from '@storybook/client-api';
import { Text, View, StyleSheet } from 'react-native';

interface Props {
Expand Down
13 changes: 11 additions & 2 deletions app/react-native/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"jsx": "react-native",
"rootDir": "./src",
"module": "ESNext",
"skipDefaultLibCheck": true,
"skipLibCheck": true,
"target": "ESNext",
"lib": ["ESNext"],
"allowSyntheticDefaultImports": true,
"paths": {
"@emotion/native": ["src/typings.d.ts"]
}
},
"outDir": "dist/",
"moduleResolution": "node",
"declaration": true
},
"include": ["src/**/*"],
"exclude": ["src/__tests__/**/*"]
Expand Down
6 changes: 4 additions & 2 deletions examples/native/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
//stories: ['./components/*/*.stories.?(ts|tsx|js|jsx)', './globtest/Buttonx/Buttonx.stories.tsx'],
stories: ['./components/Button/Button.stories.tsx'],
stories: [
'./components/*/*.stories.?(ts|tsx|js|jsx)',
'./other_components/AnotherButton/AnotherButton.stories.tsx',
],
};
23 changes: 19 additions & 4 deletions examples/native/components/Button1/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
import { storiesOf } from '@storybook/react-native';
import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { Button } from './Button';

storiesOf('button2', module)
.add('example2', () => <Button text="test3" onPress={() => null} />)
.add('example3', () => <Button text="test4" onPress={() => null} />);
const testing = () => {
const timeout = new Promise((resolve) => {
setTimeout(() => {
resolve('hi');
}, 1000);
});
timeout
.then((res) => {
console.log(res);
})
.finally(() => {
console.log('resolved ');
});
};

storiesOf('button promise', module)
.add('finally', () => <Button text="Do a promise" onPress={testing} />)
.add('nothing', () => <Button text="test4" onPress={() => null} />);
8 changes: 0 additions & 8 deletions examples/native/globtest/Buttonx/Buttonx.stories.tsx

This file was deleted.

1 change: 0 additions & 1 deletion examples/native/globtest/Buttonx/index.ts

This file was deleted.

3 changes: 3 additions & 0 deletions examples/native/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ module.exports = {
},
}),
},
resolver: {
resolverMainFields: ['sbmodern', 'main'],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { storiesOf } from '@storybook/react-native';
import React from 'react';
import { Button } from './AnotherButton';

storiesOf('Another Button', module)
.add('another button example', () => <Button text="test" onPress={() => null} />)
.add('again', () => <Button text="test2" onPress={() => null} />);
1 change: 1 addition & 0 deletions examples/native/other_components/AnotherButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button } from './AnotherButton';
15 changes: 5 additions & 10 deletions examples/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@
"preset": "react-native"
},
"dependencies": {
"@storybook/addon-actions": "6.0.28",
"@storybook/addon-knobs": "6.0.28",
"@storybook/addon-links": "6.0.28",
"@storybook/addon-ondevice-actions": "^5.3.23",
"@storybook/addon-ondevice-backgrounds": "^5.3.23",
"@storybook/addon-ondevice-knobs": "^5.3.25",
"@storybook/addon-ondevice-notes": "^5.3.23",
"@storybook/addons": "6.0.28",
"@storybook/addon-actions": "6.3.0-alpha.33",
"@storybook/addon-links": "6.3.0-alpha.33",
"@storybook/addons": "6.3.0-alpha.33",
"@storybook/react-native": "5.3.25",
"@storybook/react-native-server": "5.3.23",
"react": "16.13.1",
Expand All @@ -59,8 +54,8 @@
"metro-react-native-babel-preset": "^0.59.0",
"prettier": "^2.0.5",
"react-test-renderer": "16.13.1",
"ts-jest": "^26.1.4",
"typescript": "^3.8.3"
"ts-jest": "^26.5.6",
"typescript": "^4.2.4"
},
"detox": {
"test-runner": "jest",
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@
"babel-plugin-emotion": "^10.0.20",
"babel-plugin-macros": "^2.7.0",
"babel-plugin-require-context-hook": "^1.0.0",
"babel-preset-vue": "^2.0.2",
"chalk": "^3.0.0",
"codecov": "^3.5.0",
"codelyzer": "^5.0.0",
Expand Down Expand Up @@ -185,7 +184,6 @@
"jest-jasmine2": "^24.8.0",
"jest-matcher-utils": "^24.8.0",
"jest-raw-loader": "^1.0.1",
"jest-vue-preprocessor": "^1.5.0",
"jest-watch-typeahead": "^0.4.0",
"lerna": "^3.19.0",
"lint-staged": "^9.4.1",
Expand All @@ -210,7 +208,7 @@
"trash": "^6.1.1",
"ts-dedent": "^1.1.0",
"ts-jest": "^24.0.2",
"typescript": "^3.4.0",
"typescript": "^4.2.4",
"wait-on": "^3.3.0"
},
"engines": {
Expand Down
Loading

0 comments on commit aa40501

Please sign in to comment.