From 6e2f87f61c4c462ad7d671af3b9670d5e63b7ca9 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 28 May 2019 18:24:42 +0300 Subject: [PATCH 1/6] jetbridge starter kit --- packages/react-scripts/scripts/init.js | 43 ++++++- .../template-typescript/.circleci/config.yml | 48 ++++++++ .../template-typescript/.eslintrc.js | 28 +++++ .../template-typescript/.prettierrc.yaml | 5 + .../template-typescript/.storybook/addons.js | 2 + .../template-typescript/.storybook/config.js | 9 ++ .../.storybook/preview-head.html | 0 .../.storybook/tsconfig.json | 8 ++ .../.storybook/webpack.config.js | 12 ++ .../template-typescript/README.md | 116 ++++++++++++++++-- .../template-typescript/public/favicon.ico | Bin 3870 -> 0 bytes .../template-typescript/public/index.html | 2 +- .../template-typescript/public/manifest.json | 4 +- .../template-typescript/src/App.css | 33 ----- .../template-typescript/src/App.tsx | 24 +--- .../stories/app.stories.tsx | 7 ++ 16 files changed, 269 insertions(+), 72 deletions(-) create mode 100644 packages/react-scripts/template-typescript/.circleci/config.yml create mode 100644 packages/react-scripts/template-typescript/.eslintrc.js create mode 100644 packages/react-scripts/template-typescript/.prettierrc.yaml create mode 100644 packages/react-scripts/template-typescript/.storybook/addons.js create mode 100644 packages/react-scripts/template-typescript/.storybook/config.js create mode 100644 packages/react-scripts/template-typescript/.storybook/preview-head.html create mode 100644 packages/react-scripts/template-typescript/.storybook/tsconfig.json create mode 100644 packages/react-scripts/template-typescript/.storybook/webpack.config.js delete mode 100644 packages/react-scripts/template-typescript/public/favicon.ico delete mode 100644 packages/react-scripts/template-typescript/src/App.css create mode 100644 packages/react-scripts/template-typescript/stories/app.stories.tsx diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 9b473ab3d95..d71a2af2dbb 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -91,6 +91,40 @@ module.exports = function( // Copy over some of the devDependencies appPackage.dependencies = appPackage.dependencies || {}; + appPackage.dependencies = { + ...appPackage.dependencies, + axios: 'latest', + classnames: '2.2.6', + }; + + appPackage.devDependencies = { + '@storybook/addon-actions': 'latest', + '@storybook/addon-centered': 'latest', + '@storybook/addon-info': 'latest', + '@storybook/addon-links': 'latest', + '@storybook/addons': 'latest', + '@storybook/core': 'latest', + '@storybook/react': 'latest', + '@types/storybook__react': 'latest', + 'awesome-typescript-loader': 'latest', + 'react-docgen-typescript-loader': 'latest', + 'react-docgen-typescript-webpack-plugin': 'latest', + 'lint-staged': 'latest', + prettier: '^latest', + 'babel-loader': 'latest', + eslint: 'latest', + husky: 'latest', + }; + + appPackage.husky = { + hooks: { + 'pre-commit': 'lint-staged', + }, + }; + appPackage['lint-staged'] = { + '**/*.{js,jsx,ts,tsx}': ['prettier --write', 'eslint --fix', 'git add'], + }; + const useTypeScript = appPackage.dependencies['typescript'] != null; // Setup the script rules @@ -99,11 +133,10 @@ module.exports = function( build: 'react-scripts build', test: 'react-scripts test', eject: 'react-scripts eject', - }; - - // Setup the eslint config - appPackage.eslintConfig = { - extends: 'react-app', + lint: 'eslint src/**/*.ts src/**/*.tsx', + fix: + 'prettier --write src/**/*.ts src/**/*.tsx && eslint --fix src/**/*.ts src/**/*.tsx', + storybook: 'start-storybook -p 6006', }; // Setup the browsers list diff --git a/packages/react-scripts/template-typescript/.circleci/config.yml b/packages/react-scripts/template-typescript/.circleci/config.yml new file mode 100644 index 00000000000..313eaba3e7c --- /dev/null +++ b/packages/react-scripts/template-typescript/.circleci/config.yml @@ -0,0 +1,48 @@ +# Javascript Node CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-javascript/ for more details +# +version: 2 +jobs: + build: + docker: + - image: circleci/node:10 + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: + name: Install yarn dependencies + command: yarn install + - run: + name: Install JUnit coverage reporter + command: yarn add --dev jest-junit + + - save_cache: + paths: + - node_modules + key: v1-dependencies-{{ checksum "package.json" }} + - run: + name: Build application + command: + yarn build + - run: + name: ESLint + command: | + mkdir -p ~/reports + yarn lint --format junit --output-file ~/reports/eslint.xml + - run: + name: Run tests + command: yarn test --coverage --collectCoverage=true --runInBand --reporters=default --reporters=jest-junit + environment: + JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml' + - store_test_results: + path: reports + - store_artifacts: + path: coverage diff --git a/packages/react-scripts/template-typescript/.eslintrc.js b/packages/react-scripts/template-typescript/.eslintrc.js new file mode 100644 index 00000000000..7cb12e4b94d --- /dev/null +++ b/packages/react-scripts/template-typescript/.eslintrc.js @@ -0,0 +1,28 @@ +module.exports = { + parser: '@typescript-eslint/parser', + extends: ['plugin:@typescript-eslint/recommended', 'plugin:react/recommended', 'react-app'], + plugins: ['@typescript-eslint', 'react'], + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, + settings: { + react: { + version: 'detect', + }, + }, + rules: { + '@typescript-eslint/indent': ['warn', 2], + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/camelcase': 'off', + '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/explicit-member-accessibility': 'off', + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/class-name-casing': 'warn', // withTheme, etc + '@typescript-eslint/explicit-function-return-type': 'off', // just infer it... + 'react/prop-types': 'off', // use TS + '@typescript-eslint/member-delimiter-style': 'off', + 'jsx-a11y/alt-text': 'off', + }, +} diff --git a/packages/react-scripts/template-typescript/.prettierrc.yaml b/packages/react-scripts/template-typescript/.prettierrc.yaml new file mode 100644 index 00000000000..435d2da7e0e --- /dev/null +++ b/packages/react-scripts/template-typescript/.prettierrc.yaml @@ -0,0 +1,5 @@ +tabWidth: 2 +semi: false +singleQuote: true +printWidth: 120 +trailingComma: es5 diff --git a/packages/react-scripts/template-typescript/.storybook/addons.js b/packages/react-scripts/template-typescript/.storybook/addons.js new file mode 100644 index 00000000000..402ccc13eba --- /dev/null +++ b/packages/react-scripts/template-typescript/.storybook/addons.js @@ -0,0 +1,2 @@ +import '@storybook/addon-actions/register' +import '@storybook/addon-links/register' diff --git a/packages/react-scripts/template-typescript/.storybook/config.js b/packages/react-scripts/template-typescript/.storybook/config.js new file mode 100644 index 00000000000..158d082b195 --- /dev/null +++ b/packages/react-scripts/template-typescript/.storybook/config.js @@ -0,0 +1,9 @@ +import { configure } from '@storybook/react' + +// automatically import all files ending in *.stories.tsx +const req = require.context('../stories', true, /.stories.tsx$/) +function loadStories() { + req.keys().forEach(filename => req(filename)) +} + +configure(loadStories, module) diff --git a/packages/react-scripts/template-typescript/.storybook/preview-head.html b/packages/react-scripts/template-typescript/.storybook/preview-head.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/react-scripts/template-typescript/.storybook/tsconfig.json b/packages/react-scripts/template-typescript/.storybook/tsconfig.json new file mode 100644 index 00000000000..7b21240ded6 --- /dev/null +++ b/packages/react-scripts/template-typescript/.storybook/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig", + "compilerOptions": { + "jsx": "react", + "isolatedModules": false, + "noEmit": false + } +} diff --git a/packages/react-scripts/template-typescript/.storybook/webpack.config.js b/packages/react-scripts/template-typescript/.storybook/webpack.config.js new file mode 100644 index 00000000000..39447390b8a --- /dev/null +++ b/packages/react-scripts/template-typescript/.storybook/webpack.config.js @@ -0,0 +1,12 @@ +const path = require('path') +const TSDocgenPlugin = require('react-docgen-typescript-webpack-plugin') +module.exports = ({ config }) => { + config.module.rules.push({ + test: /\.(ts|tsx)$/, + loader: require.resolve('awesome-typescript-loader'), + options: { configFileName: path.resolve(__dirname, './tsconfig.json') }, // << added + }) + config.plugins.push(new TSDocgenPlugin()) // optional + config.resolve.extensions.push('.ts', '.tsx') + return config +} diff --git a/packages/react-scripts/template-typescript/README.md b/packages/react-scripts/template-typescript/README.md index 897dc836601..51e34f1d79f 100644 --- a/packages/react-scripts/template-typescript/README.md +++ b/packages/react-scripts/template-typescript/README.md @@ -1,10 +1,14 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +# JetBridge Frontend Starter Kit + +For best practices, consult [Notion](https://www.notion.so/jetbridge/Starting-A-New-Project-cf03a080207b4569b53bb3b7d06f7f2c). + +This project was bootstrapped with [Create React App](https://github.com/jetbridge/create-react-app) ## Available Scripts In the project directory, you can run: -### `npm start` +### `yarn start` Runs the app in the development mode.
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. @@ -12,12 +16,12 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser. The page will reload if you make edits.
You will also see any lint errors in the console. -### `npm test` +### `yarn test` Launches the test runner in the interactive watch mode.
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. -### `npm run build` +### `yarn build` Builds the app for production to the `build` folder.
It correctly bundles React in production mode and optimizes the build for the best performance. @@ -27,18 +31,106 @@ Your app is ready to be deployed! See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. -### `npm run eject` +### `yarn storybook` + +Launches the [storybook](https://github.com/storybooks/storybook) environment. + +### `yarn lint` + +Runs linter over all files in `./src` folder and its subfolders + +### `yarn fix` + +Runs linter over all files in `./src` folder and its subfolders and applies the code formatting fixes where possible + +### `yarn test` + +Runs jest tests in a watch mode + +## Code style + +### Basic Rules + +- Only include one React component per file. + - However, multiple [Stateless, or Pure, Components](https://facebook.github.io/react/docs/reusable-components.html#stateless-functions) are allowed per file +- Always use TSX syntax. + +### Indentation: + +Use 2 spaces for indentation + +### Naming: + +- **Extensions**: Use `.tsx` extension for React components. +- **Filename**: Use PascalCase for filenames. E.g., `AdminDashboard.tsx`. + **Reference Naming**: Use PascalCase for React components and camelCase for their instances. + +```tsx +// bad +import reservationCard from './ReservationCard' + +// good +import ReservationCard from './ReservationCard' + +// bad +const ReservationItem = + +// good +const reservationItem = +``` + +- **Component Naming**: Use the filename as the component name. For example, `ReservationCard.tsx` should have a reference name of `ReservationCard`. However, for root components of a directory, use `index.tsx` as the filename and use the directory name as the component name: + + ```tsx + // bad + import Footer from './Footer/Footer' + + // bad + import Footer from './Footer/index' + + // good + import Footer from './Footer' + ``` + +- **Types naming**: interface names should start with I: + `tsx ILoginScreenProps: { }` + +- **Higher-order Component Naming**: Use a composite of the higher-order component’s name and the passed-in component’s name as the `displayName` on the generated component. For example, the higher-order component `withFoo()`, when passed a component `Bar` should produce a component with a `displayName` of `withFoo(Bar)`. + +### Types: + +Always specify prop types and state types for components and functions. Return types for API Requests are required. + +### Props -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** +- Always use camelCase for prop names. -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + ```tsx + // bad + -Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + // good + + ``` -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. +- We don’t recommend using indexes for keys if the order of items may change. -## Learn More +```tsx +// bad +{ + todos.map((todo, index) => ) +} -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). +// good +{ + todos.map(todo => ) +} +``` -To learn React, check out the [React documentation](https://reactjs.org/). +- Do not do props drilling. We recommend using [React Context API](https://reactjs.org/docs/context.html) for passing props down to the children's children components. diff --git a/packages/react-scripts/template-typescript/public/favicon.ico b/packages/react-scripts/template-typescript/public/favicon.ico deleted file mode 100644 index a11777cc471a4344702741ab1c8a588998b1311a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3870 zcma);c{J4h9>;%nil|2-o+rCuEF-(I%-F}ijC~o(k~HKAkr0)!FCj~d>`RtpD?8b; zXOC1OD!V*IsqUwzbMF1)-gEDD=A573Z-&G7^LoAC9|WO7Xc0Cx1g^Zu0u_SjAPB3vGa^W|sj)80f#V0@M_CAZ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GWx8e}nQ=w7bZ|eVP4?*Tb!$(R)iC z9)&%bS*u(lXqzitAN)Oo=&Ytn>%Hzjc<5liuPi>zC_nw;Z0AE3Y$Jao_Q90R-gl~5 z_xAb2J%eArrC1CN4G$}-zVvCqF1;H;abAu6G*+PDHSYFx@Tdbfox*uEd3}BUyYY-l zTfEsOqsi#f9^FoLO;ChK<554qkri&Av~SIM*{fEYRE?vH7pTAOmu2pz3X?Wn*!ROX ztd54huAk&mFBemMooL33RV-*1f0Q3_(7hl$<#*|WF9P!;r;4_+X~k~uKEqdzZ$5Al zV63XN@)j$FN#cCD;ek1R#l zv%pGrhB~KWgoCj%GT?%{@@o(AJGt*PG#l3i>lhmb_twKH^EYvacVY-6bsCl5*^~L0 zonm@lk2UvvTKr2RS%}T>^~EYqdL1q4nD%0n&Xqr^cK^`J5W;lRRB^R-O8b&HENO||mo0xaD+S=I8RTlIfVgqN@SXDr2&-)we--K7w= zJVU8?Z+7k9dy;s;^gDkQa`0nz6N{T?(A&Iz)2!DEecLyRa&FI!id#5Z7B*O2=PsR0 zEvc|8{NS^)!d)MDX(97Xw}m&kEO@5jqRaDZ!+%`wYOI<23q|&js`&o4xvjP7D_xv@ z5hEwpsp{HezI9!~6O{~)lLR@oF7?J7i>1|5a~UuoN=q&6N}EJPV_GD`&M*v8Y`^2j zKII*d_@Fi$+i*YEW+Hbzn{iQk~yP z>7N{S4)r*!NwQ`(qcN#8SRQsNK6>{)X12nbF`*7#ecO7I)Q$uZsV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ diff --git a/packages/react-scripts/template-typescript/public/index.html b/packages/react-scripts/template-typescript/public/index.html index dd1ccfd4cd3..d3249b9b42e 100644 --- a/packages/react-scripts/template-typescript/public/index.html +++ b/packages/react-scripts/template-typescript/public/index.html @@ -19,7 +19,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + JetBridge App diff --git a/packages/react-scripts/template-typescript/public/manifest.json b/packages/react-scripts/template-typescript/public/manifest.json index 1f2f141fafd..df642cd44fe 100644 --- a/packages/react-scripts/template-typescript/public/manifest.json +++ b/packages/react-scripts/template-typescript/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "React App", - "name": "Create React App Sample", + "short_name": "JetBridge App", + "name": "JetBridge App Starter Kit", "icons": [ { "src": "favicon.ico", diff --git a/packages/react-scripts/template-typescript/src/App.css b/packages/react-scripts/template-typescript/src/App.css deleted file mode 100644 index b41d297cab1..00000000000 --- a/packages/react-scripts/template-typescript/src/App.css +++ /dev/null @@ -1,33 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - animation: App-logo-spin infinite 20s linear; - height: 40vmin; - pointer-events: none; -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/packages/react-scripts/template-typescript/src/App.tsx b/packages/react-scripts/template-typescript/src/App.tsx index 226ee6316af..cebafedd0c7 100644 --- a/packages/react-scripts/template-typescript/src/App.tsx +++ b/packages/react-scripts/template-typescript/src/App.tsx @@ -1,26 +1,12 @@ -import React from 'react'; -import logo from './logo.svg'; -import './App.css'; +import * as React from 'react' const App: React.FC = () => { return ( - ); + ) } -export default App; +export default App diff --git a/packages/react-scripts/template-typescript/stories/app.stories.tsx b/packages/react-scripts/template-typescript/stories/app.stories.tsx new file mode 100644 index 00000000000..abc1e3dd1d6 --- /dev/null +++ b/packages/react-scripts/template-typescript/stories/app.stories.tsx @@ -0,0 +1,7 @@ +import * as React from 'react' +import { storiesOf } from '@storybook/react' +import App from '../src/App' + +storiesOf('App', module).add('App', () => { + return +}) From 19d9b281831a7001cdaddde840e0d87cf90db87e Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 28 May 2019 18:40:25 +0300 Subject: [PATCH 2/6] rename jetbridge-react-scripts --- README.md | 205 +----------------- packages/react-scripts/package.json | 8 +- packages/react-scripts/scripts/init.js | 2 +- .../scripts/utils/verifyTypeScriptSetup.js | 2 +- 4 files changed, 9 insertions(+), 208 deletions(-) diff --git a/README.md b/README.md index 75aed91b989..72b5f40dee2 100644 --- a/README.md +++ b/README.md @@ -1,203 +1,4 @@ -# Create React App [![Build Status](https://travis-ci.org/facebook/create-react-app.svg?branch=master)](https://travis-ci.org/facebook/create-react-app) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/pulls) +# JetBridge Starter Kit -Create React apps with no build configuration. - -- [Creating an App](#creating-an-app) – How to create a new app. -- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App. - -Create React App works on macOS, Windows, and Linux.
-If something doesn’t work, please [file an issue](https://github.com/facebook/create-react-app/issues/new). - -## Quick Overview - -```sh -npx create-react-app my-app -cd my-app -npm start -``` - -_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_ - -Then open [http://localhost:3000/](http://localhost:3000/) to see your app.
-When you’re ready to deploy to production, create a minified bundle with `npm run build`. - -

-npm start -

- -### Get Started Immediately - -You **don’t** need to install or configure tools like Webpack or Babel.
-They are preconfigured and hidden so that you can focus on the code. - -Just create a project, and you’re good to go. - -## Creating an App - -**You’ll need to have Node 8.10.0 or later on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects. - -To create a new app, you may choose one of the following methods: - -### npx - -```sh -npx create-react-app my-app -``` - -_([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))_ - -### npm - -```sh -npm init react-app my-app -``` - -_`npm init ` is available in npm 6+_ - -### Yarn - -```sh -yarn create react-app my-app -``` - -_`yarn create` is available in Yarn 0.25+_ - -It will create a directory called `my-app` inside the current folder.
-Inside that directory, it will generate the initial project structure and install the transitive dependencies: - -``` -my-app -├── README.md -├── node_modules -├── package.json -├── .gitignore -├── public -│ ├── favicon.ico -│ ├── index.html -│ └── manifest.json -└── src - ├── App.css - ├── App.js - ├── App.test.js - ├── index.css - ├── index.js - ├── logo.svg - └── serviceWorker.js -``` - -No configuration or complicated folder structures, just the files you need to build your app.
-Once the installation is done, you can open your project folder: - -```sh -cd my-app -``` - -Inside the newly created project, you can run some built-in commands: - -### `npm start` or `yarn start` - -Runs the app in development mode.
-Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will automatically reload if you make changes to the code.
-You will see the build errors and lint warnings in the console. - -

-Build errors -

- -### `npm test` or `yarn test` - -Runs the test watcher in an interactive mode.
-By default, runs tests related to files changed since the last commit. - -[Read more about testing.](https://facebook.github.io/create-react-app/docs/running-tests) - -### `npm run build` or `yarn build` - -Builds the app for production to the `build` folder.
-It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.
- -Your app is ready to be deployed. - -## User Guide - -You can find detailed instructions on using Create React App and many tips in [its documentation](https://facebook.github.io/create-react-app/). - -## How to Update to New Versions? - -Please refer to the [User Guide](https://facebook.github.io/create-react-app/docs/updating-to-new-releases) for this and other information. - -## Philosophy - -- **One Dependency:** There is just one build dependency. It uses Webpack, Babel, ESLint, and other amazing projects, but provides a cohesive curated experience on top of them. - -- **No Configuration Required:** You don't need to configure anything. A reasonably good configuration of both development and production builds is handled for you so you can focus on writing code. - -- **No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off. - -## What’s Included? - -Your environment will have everything you need to build a modern single-page React app: - -- React, JSX, ES6, TypeScript and Flow syntax support. -- Language extras beyond ES6 like the object spread operator. -- Autoprefixed CSS, so you don’t need `-webkit-` or other prefixes. -- A fast interactive unit test runner with built-in support for coverage reporting. -- A live development server that warns about common mistakes. -- A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps. -- An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) criteria. (_Note: Using the service worker is opt-in as of `react-scripts@2.0.0` and higher_) -- Hassle-free updates for the above tools with a single dependency. - -Check out [this guide](https://github.com/nitishdayal/cra_closer_look) for an overview of how these tools fit together. - -The tradeoff is that **these tools are preconfigured to work in a specific way**. If your project needs more customization, you can ["eject"](https://facebook.github.io/create-react-app/docs/available-scripts#npm-run-eject) and customize it, but then you will need to maintain this configuration. - -## Popular Alternatives - -Create React App is a great fit for: - -- **Learning React** in a comfortable and feature-rich development environment. -- **Starting new single-page React applications.** -- **Creating examples** with React for your libraries and components. - -Here are a few common cases where you might want to try something else: - -- If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html). - -- If you need to **integrate React code with a server-side template framework** like Rails, Django or Symfony, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb), or [Neutrino](https://neutrino.js.org/) which are more flexible. For Rails specifically, you can use [Rails Webpacker](https://github.com/rails/webpacker). For Symfony, try [Symfony's Webpack Encore](https://symfony.com/doc/current/frontend/encore/reactjs.html). - -- If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries), as well as [Neutrino's react-components preset](https://neutrino.js.org/packages/react-components/). - -- If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles. - -- If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time. - -- Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/). - -All of the above tools can work with little to no configuration. - -If you prefer configuring the build yourself, [follow this guide](https://reactjs.org/docs/add-react-to-an-existing-app.html). - -## Contributing - -We'd love to have your helping hand on `create-react-app`! See [CONTRIBUTING.md](CONTRIBUTING.md) for more information on what we're looking for and how to get started. - -## React Native - -Looking for something similar, but for React Native?
-Check out [Expo CLI](https://github.com/expo/expo-cli). - -## Acknowledgements - -We are grateful to the authors of existing related projects for their ideas and collaboration: - -- [@eanplatter](https://github.com/eanplatter) -- [@insin](https://github.com/insin) -- [@mxstbr](https://github.com/mxstbr) - -## License - -Create React App is open source software [licensed as MIT](https://github.com/facebook/create-react-app/blob/master/LICENSE). +To use: +`create-react-app myapp --typescript --scripts-version jetbridge-react-scripts diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index e4a93a37e03..2a5d67b49be 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,10 +1,10 @@ { - "name": "react-scripts", - "version": "3.0.1", + "name": "jetbridge-react-scripts", + "version": "1.0.0", "description": "Configuration and scripts for Create React App.", "repository": { "type": "git", - "url": "https://github.com/facebook/create-react-app.git", + "url": "https://github.com/jetbridge/create-react-app.git", "directory": "packages/react-scripts" }, "license": "MIT", @@ -12,7 +12,7 @@ "node": ">=8.10" }, "bugs": { - "url": "https://github.com/facebook/create-react-app/issues" + "url": "https://github.com/jetbridge/create-react-app/issues" }, "files": [ "bin", diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index d71a2af2dbb..880255a84b9 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -288,7 +288,7 @@ module.exports = function( ); } console.log(); - console.log('Happy hacking!'); + console.log(chalk.green("Let's Make It Happen!")); }; function isReactInstalled(appPackage) { diff --git a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js index a73b8c0db3b..ad22009c608 100644 --- a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js +++ b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js @@ -257,7 +257,7 @@ function verifyTypeScriptSetup() { if (!fs.existsSync(paths.appTypeDeclarations)) { fs.writeFileSync( paths.appTypeDeclarations, - `/// ${os.EOL}` + `/// ${os.EOL}` ); } } From a37392f332deaf1df4d6d44a6ff2af5acffc47ae Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 28 May 2019 19:50:06 +0300 Subject: [PATCH 3/6] storybook --- packages/react-scripts/scripts/init.js | 22 ++++++++++++------- .../template-typescript/.eslintrc.js | 1 + .../template-typescript/.storybook/config.js | 9 -------- .../.storybook/preview-head.html | 0 .../.storybook/tsconfig.json | 8 ------- .../.storybook/webpack.config.js | 12 ---------- .../template-typescript/src/logo.svg | 7 ------ .../stories/app.stories.tsx | 7 ------ 8 files changed, 15 insertions(+), 51 deletions(-) delete mode 100644 packages/react-scripts/template-typescript/.storybook/config.js delete mode 100644 packages/react-scripts/template-typescript/.storybook/preview-head.html delete mode 100644 packages/react-scripts/template-typescript/.storybook/tsconfig.json delete mode 100644 packages/react-scripts/template-typescript/.storybook/webpack.config.js delete mode 100644 packages/react-scripts/template-typescript/src/logo.svg delete mode 100644 packages/react-scripts/template-typescript/stories/app.stories.tsx diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 880255a84b9..5bab07dbae1 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -32,6 +32,10 @@ function isInGitRepository() { } } +function initStorybook() { + execSync('npx -p @storybook/cli sb init'); +} + function isInMercurialRepository() { try { execSync('hg --cwd . root', { stdio: 'ignore' }); @@ -94,7 +98,9 @@ module.exports = function( appPackage.dependencies = { ...appPackage.dependencies, axios: 'latest', - classnames: '2.2.6', + classnames: 'latest', + '@jetbridge/frontend-core': + 'git+ssh://git@github.com:jetbridge/frontend-core.git', }; appPackage.devDependencies = { @@ -103,17 +109,14 @@ module.exports = function( '@storybook/addon-info': 'latest', '@storybook/addon-links': 'latest', '@storybook/addons': 'latest', - '@storybook/core': 'latest', - '@storybook/react': 'latest', + '@types/node': 'latest', + '@types/react': 'latest', '@types/storybook__react': 'latest', - 'awesome-typescript-loader': 'latest', - 'react-docgen-typescript-loader': 'latest', - 'react-docgen-typescript-webpack-plugin': 'latest', 'lint-staged': 'latest', - prettier: '^latest', - 'babel-loader': 'latest', + prettier: 'latest', eslint: 'latest', husky: 'latest', + 'babel-loader': '8.0.5', }; appPackage.husky = { @@ -237,6 +240,9 @@ module.exports = function( console.log('Initialized a git repository.'); } + console.log('Initializing storybook...'); + initStorybook(); + // Display the most elegant way to cd. // This needs to handle an undefined originalDirectory for // backward compatibility with old global-cli's. diff --git a/packages/react-scripts/template-typescript/.eslintrc.js b/packages/react-scripts/template-typescript/.eslintrc.js index 7cb12e4b94d..e70e017f24e 100644 --- a/packages/react-scripts/template-typescript/.eslintrc.js +++ b/packages/react-scripts/template-typescript/.eslintrc.js @@ -24,5 +24,6 @@ module.exports = { 'react/prop-types': 'off', // use TS '@typescript-eslint/member-delimiter-style': 'off', 'jsx-a11y/alt-text': 'off', + '@typescript-eslint/prefer-interface': 'off', }, } diff --git a/packages/react-scripts/template-typescript/.storybook/config.js b/packages/react-scripts/template-typescript/.storybook/config.js deleted file mode 100644 index 158d082b195..00000000000 --- a/packages/react-scripts/template-typescript/.storybook/config.js +++ /dev/null @@ -1,9 +0,0 @@ -import { configure } from '@storybook/react' - -// automatically import all files ending in *.stories.tsx -const req = require.context('../stories', true, /.stories.tsx$/) -function loadStories() { - req.keys().forEach(filename => req(filename)) -} - -configure(loadStories, module) diff --git a/packages/react-scripts/template-typescript/.storybook/preview-head.html b/packages/react-scripts/template-typescript/.storybook/preview-head.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/react-scripts/template-typescript/.storybook/tsconfig.json b/packages/react-scripts/template-typescript/.storybook/tsconfig.json deleted file mode 100644 index 7b21240ded6..00000000000 --- a/packages/react-scripts/template-typescript/.storybook/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../tsconfig", - "compilerOptions": { - "jsx": "react", - "isolatedModules": false, - "noEmit": false - } -} diff --git a/packages/react-scripts/template-typescript/.storybook/webpack.config.js b/packages/react-scripts/template-typescript/.storybook/webpack.config.js deleted file mode 100644 index 39447390b8a..00000000000 --- a/packages/react-scripts/template-typescript/.storybook/webpack.config.js +++ /dev/null @@ -1,12 +0,0 @@ -const path = require('path') -const TSDocgenPlugin = require('react-docgen-typescript-webpack-plugin') -module.exports = ({ config }) => { - config.module.rules.push({ - test: /\.(ts|tsx)$/, - loader: require.resolve('awesome-typescript-loader'), - options: { configFileName: path.resolve(__dirname, './tsconfig.json') }, // << added - }) - config.plugins.push(new TSDocgenPlugin()) // optional - config.resolve.extensions.push('.ts', '.tsx') - return config -} diff --git a/packages/react-scripts/template-typescript/src/logo.svg b/packages/react-scripts/template-typescript/src/logo.svg deleted file mode 100644 index 6b60c1042f5..00000000000 --- a/packages/react-scripts/template-typescript/src/logo.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/packages/react-scripts/template-typescript/stories/app.stories.tsx b/packages/react-scripts/template-typescript/stories/app.stories.tsx deleted file mode 100644 index abc1e3dd1d6..00000000000 --- a/packages/react-scripts/template-typescript/stories/app.stories.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import * as React from 'react' -import { storiesOf } from '@storybook/react' -import App from '../src/App' - -storiesOf('App', module).add('App', () => { - return -}) From 13ecc18b8d9d506a93d023f89c0524ad8309b823 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 28 May 2019 19:54:27 +0300 Subject: [PATCH 4/6] readme --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 72b5f40dee2..b7fc5c6a6e4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # JetBridge Starter Kit -To use: -`create-react-app myapp --typescript --scripts-version jetbridge-react-scripts +### To use: + +`create-react-app myapp --typescript --scripts-version jetbridge-react-scripts` From 5aecc6d9dca5345bf576cf03bd3f2ed3784eccce Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 28 May 2019 21:02:53 +0300 Subject: [PATCH 5/6] storybook... --- packages/react-scripts/scripts/init.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 5bab07dbae1..a6d0a3cd992 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -116,7 +116,6 @@ module.exports = function( prettier: 'latest', eslint: 'latest', husky: 'latest', - 'babel-loader': '8.0.5', }; appPackage.husky = { @@ -139,7 +138,6 @@ module.exports = function( lint: 'eslint src/**/*.ts src/**/*.tsx', fix: 'prettier --write src/**/*.ts src/**/*.tsx && eslint --fix src/**/*.ts src/**/*.tsx', - storybook: 'start-storybook -p 6006', }; // Setup the browsers list From b088040ef46cbc73b7fba508beace84558a77c60 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Tue, 28 May 2019 21:54:35 +0300 Subject: [PATCH 6/6] typo --- packages/react-scripts/template-typescript/src/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template-typescript/src/App.tsx b/packages/react-scripts/template-typescript/src/App.tsx index cebafedd0c7..7407deeb593 100644 --- a/packages/react-scripts/template-typescript/src/App.tsx +++ b/packages/react-scripts/template-typescript/src/App.tsx @@ -2,8 +2,8 @@ import * as React from 'react' const App: React.FC = () => { return ( -
-

New JetBrige App!

+
+

New JetBridge App!

Enjoy!

)