From a388ef3e263ead103e36db5bf6eb25300547261d Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Thu, 25 May 2017 22:19:22 -0700 Subject: [PATCH] Rename 'examples' to 'docs/storybook' Also changes several npm script names --- .gitignore | 1 - CONTRIBUTING.md | 82 ++++++++++-------- .../storybook}/.storybook/config.js | 0 .../.storybook/decorator-centered.js | 0 .../storybook}/.storybook/webpack.config.js | 2 +- .../apis/Clipboard/ClipboardExample.js | 0 .../apis/I18nManager/I18nManagerExample.js | 0 .../storybook}/apis/Linking/LinkingExample.js | 0 .../apis/PanResponder/PanResponderExample.js | 0 .../ActivityIndicatorExample.js | 0 .../components/Button/ButtonExample.js | 0 .../components/Image/ImageExample.js | 0 .../storybook}/components/Image/bunny.png | Bin .../components/Image/uie_thumb_normal@2x.png | Bin .../Image/uie_thumb_selected@2x.png | Bin .../components/ListView/ListViewExample.js | 0 .../ProgressBar/ProgressBarExample.js | 0 .../ScrollView/ScrollViewExample.js | 0 .../components/Switch/SwitchExample.js | 0 .../storybook}/components/Text/TextExample.js | 0 .../components/TextInput/TextInputExample.js | 0 .../components/Touchable/TouchableExample.js | 0 .../storybook}/components/View/ViewExample.js | 0 .../components/View/ViewTransformsExample.js | 0 .../storybook}/demos/Game2048/Game2048.js | 0 .../demos/Game2048/Game2048Example.js | 0 .../storybook}/demos/Game2048/GameBoard.js | 0 .../storybook}/demos/TicTacToe/TicTacToe.js | 8 +- .../demos/TicTacToe/TicTacToeExample.js | 0 package.json | 16 ++-- 30 files changed, 61 insertions(+), 48 deletions(-) rename {examples => docs/storybook}/.storybook/config.js (100%) rename {examples => docs/storybook}/.storybook/decorator-centered.js (100%) rename {examples => docs/storybook}/.storybook/webpack.config.js (91%) rename {examples => docs/storybook}/apis/Clipboard/ClipboardExample.js (100%) rename {examples => docs/storybook}/apis/I18nManager/I18nManagerExample.js (100%) rename {examples => docs/storybook}/apis/Linking/LinkingExample.js (100%) rename {examples => docs/storybook}/apis/PanResponder/PanResponderExample.js (100%) rename {examples => docs/storybook}/components/ActivityIndicator/ActivityIndicatorExample.js (100%) rename {examples => docs/storybook}/components/Button/ButtonExample.js (100%) rename {examples => docs/storybook}/components/Image/ImageExample.js (100%) rename {examples => docs/storybook}/components/Image/bunny.png (100%) rename {examples => docs/storybook}/components/Image/uie_thumb_normal@2x.png (100%) rename {examples => docs/storybook}/components/Image/uie_thumb_selected@2x.png (100%) rename {examples => docs/storybook}/components/ListView/ListViewExample.js (100%) rename {examples => docs/storybook}/components/ProgressBar/ProgressBarExample.js (100%) rename {examples => docs/storybook}/components/ScrollView/ScrollViewExample.js (100%) rename {examples => docs/storybook}/components/Switch/SwitchExample.js (100%) rename {examples => docs/storybook}/components/Text/TextExample.js (100%) rename {examples => docs/storybook}/components/TextInput/TextInputExample.js (100%) rename {examples => docs/storybook}/components/Touchable/TouchableExample.js (100%) rename {examples => docs/storybook}/components/View/ViewExample.js (100%) rename {examples => docs/storybook}/components/View/ViewTransformsExample.js (100%) rename {examples => docs/storybook}/demos/Game2048/Game2048.js (100%) rename {examples => docs/storybook}/demos/Game2048/Game2048Example.js (100%) rename {examples => docs/storybook}/demos/Game2048/GameBoard.js (100%) rename {examples => docs/storybook}/demos/TicTacToe/TicTacToe.js (97%) rename {examples => docs/storybook}/demos/TicTacToe/TicTacToeExample.js (100%) diff --git a/.gitignore b/.gitignore index 0c264cb9..f06235c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ node_modules dist -dist-examples diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cdcb1760..97ea7abc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,7 @@ Before opening an issue, please search the [issue tracker](https://github.com/necolas/react-native-web/issues) to make sure your issue hasn't already been reported. -## Development +## Getting started Visit the [Issue tracker](https://github.com/necolas/react-native-web/issues) to find a list of open issues that need attention. @@ -23,51 +23,63 @@ Install dependencies (requires [yarn](https://yarnpkg.com/en/docs/install): yarn ``` -Run the examples: +## Unit tests + +To run the unit tests: ``` -npm run examples +npm test ``` -Run the benchmarks in a browser by opening `./performance/index.html` after running: - -``` -npm run build:performance -``` - -### Building - -``` -npm run build -``` - -To create a UMD build: - -``` -npm run build:umd -``` - -### Testing and Linting - -To run the tests: - -``` -npm run test -``` - -To continuously watch and run tests, run the following: +…in watch mode: ``` npm run test:watch ``` -Before create a commit run: +## Visual tests + +Run the interactive storybook: + +``` +npm run docs:start +``` + +Run generate a static build of the storybook: + +``` +npm run docs:build +``` + +Run the performance benchmarks in a browser (opening `./performance/index.html`): + +``` +npm run benchmarks +``` + +## Compile and build + +Compile the source code to `dist`: + +``` +npm run compile +``` + +To create a UMD bundle of the library: + +``` +npm run build +``` + +### Pre-commit + +Before creating a commit run: ``` npm run precommit ``` -To format or lint the entire project: +To format and lint the entire project: ``` npm run fmt @@ -88,8 +100,10 @@ that we won't want to accept. * Make sure all tests pass and there are no linting errors. * Submit a pull request, referencing any issues it addresses. -Please try to keep your pull request focused in scope and avoid including unrelated commits. +Please try to keep your pull request focused in scope and avoid including +unrelated commits. -After you have submitted your pull request, we'll try to get back to you as soon as possible. We may suggest some changes or improvements. +After you have submitted your pull request, we'll try to get back to you as +soon as possible. We may suggest some changes or improvements. Thank you for contributing! diff --git a/examples/.storybook/config.js b/docs/storybook/.storybook/config.js similarity index 100% rename from examples/.storybook/config.js rename to docs/storybook/.storybook/config.js diff --git a/examples/.storybook/decorator-centered.js b/docs/storybook/.storybook/decorator-centered.js similarity index 100% rename from examples/.storybook/decorator-centered.js rename to docs/storybook/.storybook/decorator-centered.js diff --git a/examples/.storybook/webpack.config.js b/docs/storybook/.storybook/webpack.config.js similarity index 91% rename from examples/.storybook/webpack.config.js rename to docs/storybook/.storybook/webpack.config.js index 51f0b4c7..c59058f6 100644 --- a/examples/.storybook/webpack.config.js +++ b/docs/storybook/.storybook/webpack.config.js @@ -27,7 +27,7 @@ module.exports = { ], resolve: { alias: { - 'react-native': path.join(__dirname, '../../src/module') + 'react-native': path.join(__dirname, '../../../src/module') } } }; diff --git a/examples/apis/Clipboard/ClipboardExample.js b/docs/storybook/apis/Clipboard/ClipboardExample.js similarity index 100% rename from examples/apis/Clipboard/ClipboardExample.js rename to docs/storybook/apis/Clipboard/ClipboardExample.js diff --git a/examples/apis/I18nManager/I18nManagerExample.js b/docs/storybook/apis/I18nManager/I18nManagerExample.js similarity index 100% rename from examples/apis/I18nManager/I18nManagerExample.js rename to docs/storybook/apis/I18nManager/I18nManagerExample.js diff --git a/examples/apis/Linking/LinkingExample.js b/docs/storybook/apis/Linking/LinkingExample.js similarity index 100% rename from examples/apis/Linking/LinkingExample.js rename to docs/storybook/apis/Linking/LinkingExample.js diff --git a/examples/apis/PanResponder/PanResponderExample.js b/docs/storybook/apis/PanResponder/PanResponderExample.js similarity index 100% rename from examples/apis/PanResponder/PanResponderExample.js rename to docs/storybook/apis/PanResponder/PanResponderExample.js diff --git a/examples/components/ActivityIndicator/ActivityIndicatorExample.js b/docs/storybook/components/ActivityIndicator/ActivityIndicatorExample.js similarity index 100% rename from examples/components/ActivityIndicator/ActivityIndicatorExample.js rename to docs/storybook/components/ActivityIndicator/ActivityIndicatorExample.js diff --git a/examples/components/Button/ButtonExample.js b/docs/storybook/components/Button/ButtonExample.js similarity index 100% rename from examples/components/Button/ButtonExample.js rename to docs/storybook/components/Button/ButtonExample.js diff --git a/examples/components/Image/ImageExample.js b/docs/storybook/components/Image/ImageExample.js similarity index 100% rename from examples/components/Image/ImageExample.js rename to docs/storybook/components/Image/ImageExample.js diff --git a/examples/components/Image/bunny.png b/docs/storybook/components/Image/bunny.png similarity index 100% rename from examples/components/Image/bunny.png rename to docs/storybook/components/Image/bunny.png diff --git a/examples/components/Image/uie_thumb_normal@2x.png b/docs/storybook/components/Image/uie_thumb_normal@2x.png similarity index 100% rename from examples/components/Image/uie_thumb_normal@2x.png rename to docs/storybook/components/Image/uie_thumb_normal@2x.png diff --git a/examples/components/Image/uie_thumb_selected@2x.png b/docs/storybook/components/Image/uie_thumb_selected@2x.png similarity index 100% rename from examples/components/Image/uie_thumb_selected@2x.png rename to docs/storybook/components/Image/uie_thumb_selected@2x.png diff --git a/examples/components/ListView/ListViewExample.js b/docs/storybook/components/ListView/ListViewExample.js similarity index 100% rename from examples/components/ListView/ListViewExample.js rename to docs/storybook/components/ListView/ListViewExample.js diff --git a/examples/components/ProgressBar/ProgressBarExample.js b/docs/storybook/components/ProgressBar/ProgressBarExample.js similarity index 100% rename from examples/components/ProgressBar/ProgressBarExample.js rename to docs/storybook/components/ProgressBar/ProgressBarExample.js diff --git a/examples/components/ScrollView/ScrollViewExample.js b/docs/storybook/components/ScrollView/ScrollViewExample.js similarity index 100% rename from examples/components/ScrollView/ScrollViewExample.js rename to docs/storybook/components/ScrollView/ScrollViewExample.js diff --git a/examples/components/Switch/SwitchExample.js b/docs/storybook/components/Switch/SwitchExample.js similarity index 100% rename from examples/components/Switch/SwitchExample.js rename to docs/storybook/components/Switch/SwitchExample.js diff --git a/examples/components/Text/TextExample.js b/docs/storybook/components/Text/TextExample.js similarity index 100% rename from examples/components/Text/TextExample.js rename to docs/storybook/components/Text/TextExample.js diff --git a/examples/components/TextInput/TextInputExample.js b/docs/storybook/components/TextInput/TextInputExample.js similarity index 100% rename from examples/components/TextInput/TextInputExample.js rename to docs/storybook/components/TextInput/TextInputExample.js diff --git a/examples/components/Touchable/TouchableExample.js b/docs/storybook/components/Touchable/TouchableExample.js similarity index 100% rename from examples/components/Touchable/TouchableExample.js rename to docs/storybook/components/Touchable/TouchableExample.js diff --git a/examples/components/View/ViewExample.js b/docs/storybook/components/View/ViewExample.js similarity index 100% rename from examples/components/View/ViewExample.js rename to docs/storybook/components/View/ViewExample.js diff --git a/examples/components/View/ViewTransformsExample.js b/docs/storybook/components/View/ViewTransformsExample.js similarity index 100% rename from examples/components/View/ViewTransformsExample.js rename to docs/storybook/components/View/ViewTransformsExample.js diff --git a/examples/demos/Game2048/Game2048.js b/docs/storybook/demos/Game2048/Game2048.js similarity index 100% rename from examples/demos/Game2048/Game2048.js rename to docs/storybook/demos/Game2048/Game2048.js diff --git a/examples/demos/Game2048/Game2048Example.js b/docs/storybook/demos/Game2048/Game2048Example.js similarity index 100% rename from examples/demos/Game2048/Game2048Example.js rename to docs/storybook/demos/Game2048/Game2048Example.js diff --git a/examples/demos/Game2048/GameBoard.js b/docs/storybook/demos/Game2048/GameBoard.js similarity index 100% rename from examples/demos/Game2048/GameBoard.js rename to docs/storybook/demos/Game2048/GameBoard.js diff --git a/examples/demos/TicTacToe/TicTacToe.js b/docs/storybook/demos/TicTacToe/TicTacToe.js similarity index 97% rename from examples/demos/TicTacToe/TicTacToe.js rename to docs/storybook/demos/TicTacToe/TicTacToe.js index 089c71b2..bca9e18f 100644 --- a/examples/demos/TicTacToe/TicTacToe.js +++ b/docs/storybook/demos/TicTacToe/TicTacToe.js @@ -1,3 +1,5 @@ +/* eslint-disable react/jsx-no-bind */ + /** * The examples provided by Facebook are for non-commercial testing and * evaluation purposes only. @@ -14,12 +16,10 @@ * @providesModule TicTacToeApp * @flow */ -'use strict'; import createReactClass from 'create-react-class'; -const React = require('react'); -const ReactNative = require('react-native'); -const { AppRegistry, StyleSheet, Text, TouchableHighlight, View } = ReactNative; +import React from 'react'; +import { AppRegistry, StyleSheet, Text, TouchableHighlight, View } from 'react-native'; class Board { grid: Array>; diff --git a/examples/demos/TicTacToe/TicTacToeExample.js b/docs/storybook/demos/TicTacToe/TicTacToeExample.js similarity index 100% rename from examples/demos/TicTacToe/TicTacToeExample.js rename to docs/storybook/demos/TicTacToe/TicTacToeExample.js diff --git a/package.json b/package.json index 3fe6d7c6..78ae2a22 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,18 @@ ], "scripts": { "benchmarks": "cd benchmarks && yarn && webpack && open index.html", - "build": "del ./dist && mkdir dist && babel src -d dist --ignore **/__tests__", - "build:examples": "build-storybook -o dist-examples -c ./examples/.storybook", - "build:umd": "webpack --config webpack.config.js --sort-assets-by --progress", - "deploy:examples": "git checkout gh-pages && rm -rf ./storybook && mv dist-examples storybook && git add -A && git commit -m \"Storybook deploy\" && git push origin gh-pages && git checkout -", - "examples": "start-storybook -p 9001 -c ./examples/.storybook --dont-track", + "build": "webpack --config webpack.config.js --sort-assets-by --progress", + "compile": "del ./dist && mkdir dist && babel src -d dist --ignore **/__tests__", + "docs:build": "build-storybook -o ./docs/dist -c ./docs/storybook/.storybook", + "docs:start": "start-storybook -p 9001 -c ./docs/storybook/.storybook --dont-track", + "docs:publish": "git checkout gh-pages && rm -rf ./storybook && mv docs/dist storybook && git add -A && git commit -m \"Storybook deploy\" && git push origin gh-pages && git checkout -", "flow": "flow", - "fmt": "find benchmarks examples src -name '*.js' | grep -v -E '(node_modules|dist)' | xargs npm run fmt:cmd", + "fmt": "find benchmarks docs src -name '*.js' | grep -v -E '(node_modules|dist)' | xargs npm run fmt:cmd", "fmt:cmd": "prettier --print-width=100 --single-quote --write", - "lint": "npm run lint:cmd -- benchmarks examples src", + "lint": "npm run lint:cmd -- benchmarks docs src", "lint:cmd": "eslint --fix --ignore-path .gitignore", "precommit": "lint-staged", - "release": "npm run build && npm run build:umd && npm publish", + "release": "npm run compile && npm run build && npm publish", "test": "jest", "test:watch": "npm run test -- --watch" },