Skip to content

Commit e21b1ae

Browse files
committed
Merge branch 'master' of github.com:bertho-zero/react-redux-universal-hot-example
2 parents 869b274 + 5fdd9c8 commit e21b1ae

142 files changed

Lines changed: 14819 additions & 3352 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,58 @@
11
{
22
"presets": [
3-
"react",
4-
"es2015",
5-
"stage-0"
3+
"@babel/preset-react",
4+
[
5+
"@babel/preset-env",
6+
{
7+
"targets": {
8+
"browsers": ["last 2 versions", "IE >= 8"],
9+
"node": "current"
10+
},
11+
"useBuiltIns": "entry"
12+
}
13+
]
614
],
715
"plugins": [
8-
"transform-runtime",
9-
"add-module-exports",
10-
"transform-decorators-legacy"
16+
[
17+
"@babel/plugin-transform-runtime",
18+
{
19+
"corejs": 2
20+
}
21+
],
22+
[
23+
"@babel/plugin-proposal-decorators",
24+
{
25+
"legacy": true
26+
}
27+
],
28+
"react-loadable/babel",
29+
"react-hot-loader/babel",
30+
"@babel/plugin-syntax-dynamic-import",
31+
"@babel/plugin-syntax-import-meta",
32+
"@babel/plugin-proposal-class-properties",
33+
"@babel/plugin-proposal-json-strings",
34+
"@babel/plugin-proposal-function-sent",
35+
"@babel/plugin-proposal-export-namespace-from",
36+
"@babel/plugin-proposal-numeric-separator",
37+
"@babel/plugin-proposal-throw-expressions",
38+
"@babel/plugin-proposal-export-default-from",
39+
"@babel/plugin-proposal-logical-assignment-operators",
40+
"@babel/plugin-proposal-optional-chaining",
41+
[
42+
"@babel/plugin-proposal-pipeline-operator",
43+
{
44+
"proposal": "minimal"
45+
}
46+
],
47+
"@babel/plugin-proposal-nullish-coalescing-operator",
48+
"@babel/plugin-proposal-do-expressions",
49+
"@babel/plugin-proposal-function-bind"
1150
],
1251
"env": {
1352
"development": {
14-
"plugins": []
53+
"plugins": [
54+
"@babel/plugin-transform-react-jsx-source"
55+
]
1556
}
1657
}
1758
}

.bootstraprc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"bootstrapVersion": 3,
33
"preBootstrapCustomizations": "./src/theme/variables.scss",
4-
"appStyles": "./src/theme/bootstrap.overrides.scss",
4+
"appStyles": "./src/theme/app.scss",
55
"loglevel": "disabled",
66
"env": {
77
"development": {

.dockerignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
.git/
22
.idea/
33
node_modules/
4-
yarn.lock
4+
package-lock.json
5+
npm-debug.log
6+
yarn-error.log
57
static/dist/
68
*.iml
79
webpack-assets.json
810
webpack-stats.json
9-
npm-debug.log
10-
.happypack
11+
.happypack/
1112
webpack/dlls/*.json
12-
api/**/*.nedb
13-
*.report.html
13+
# api/**/*.nedb
14+
*.report.html
15+
coverage/

.eslintignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
webpack/*
2-
karma.conf.js
3-
tests.webpack.js
1+
node_modules/
2+
static/dist/

.eslintrc

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
11
{
2-
"extends": "eslint-config-airbnb",
2+
"extends": "airbnb",
33
"env": {
44
"browser": true,
55
"node": true,
6-
"mocha": true,
6+
"jest": true,
77
"es6": true
88
},
99
"rules": {
10-
"react/no-multi-comp": "warn",
11-
"react/jsx-first-prop-new-line": ["warn", "multiline"],
12-
"react/prefer-stateless-function": "off",
13-
"react/jsx-closing-bracket-location": "off",
10+
"arrow-parens": ["error", "as-needed"],
11+
"comma-dangle": ["error", "only-multiline"],
12+
"consistent-return": "off",
13+
"global-require": "off",
14+
"indent": ["error", 2, {"SwitchCase": 1}],
15+
"max-len": ["warn", 120],
16+
"no-alert": "off",
17+
"no-confusing-arrow": "off",
18+
"no-console": "off",
19+
"no-param-reassign": "off",
20+
"no-underscore-dangle": "off",
21+
"prefer-promise-reject-errors": "warn",
22+
"prefer-template": "warn",
23+
"react/forbid-prop-types": "warn",
24+
"react/jsx-closing-tag-location": "off",
1425
"react/jsx-filename-extension": "off",
15-
"react/self-closing-comp": "off",
1626
"react/jsx-no-target-blank": "warn",
17-
"react/no-find-dom-node": "warn",
18-
"react/forbid-prop-types": "off",
27+
"react/jsx-one-expression-per-line": "off",
28+
"react/no-multi-comp": ["error", {"ignoreStateless": true}],
1929
"react/no-unescaped-entities": "off",
30+
"react/prefer-stateless-function": "warn",
31+
"jsx-a11y/label-has-for": ["error", {"allowChildren": true}],
32+
"jsx-a11y/anchor-is-valid": [
33+
"error",
34+
{
35+
"components": ["Link"],
36+
"specialLink": ["to"],
37+
"aspects": ["noHref", "invalidHref", "preferButton"]
38+
}
39+
],
2040
"import/default": "off",
21-
"import/extensions": ["off"],
22-
"import/no-duplicates": "off",
23-
"import/named": "off",
24-
"import/namespace": "off",
25-
"import/no-unresolved": "off",
26-
"import/no-named-as-default": "error",
27-
"import/imports-first": "off",
28-
"import/prefer-default-export": "off",
41+
"import/extensions": "off",
2942
"import/no-extraneous-dependencies": "off",
30-
"import/newline-after-import": "off",
31-
"comma-dangle": "off", // not sure why airbnb turned this on. gross!
32-
"consistent-return": "off",
33-
"no-param-reassign": "off",
34-
"prefer-template": "warn",
35-
"global-require": "off",
36-
"no-case-declarations": "off",
37-
"no-underscore-dangle": "off",
38-
"arrow-parens": "off",
39-
"class-methods-use-this": "off",
40-
"no-bitwise": "off",
41-
"no-plusplus": "off",
42-
"no-console": "off",
43-
"no-alert": "off",
44-
"max-len": ["error", 120],
45-
"indent": ["error", 2, {"SwitchCase": 1}]
43+
"import/no-named-as-default": "error",
44+
"import/no-unresolved": "off"
4645
},
4746
"plugins": [
4847
"react",
@@ -52,7 +51,8 @@
5251
"import/resolve": {
5352
"moduleDirectory": [
5453
"node_modules",
55-
"src"
54+
"src",
55+
"api"
5656
]
5757
}
5858
},
@@ -67,7 +67,6 @@
6767
"__DISABLE_SSR__": true,
6868
"__DEVTOOLS__": true,
6969
"__DLLS__": true,
70-
"socket": true,
7170
"webpackIsomorphicTools": true
7271
}
7372
}

.gitignore

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
.idea/
22
node_modules/
3-
yarn.lock
3+
package-lock.json
4+
npm-debug.log
5+
yarn-error.log
46
static/dist/
57
*.iml
68
webpack-assets.json
79
webpack-stats.json
8-
npm-debug.log
9-
.happypack
10+
.happypack/
1011
webpack/dlls/*.json
1112
api/**/*.nedb
12-
*.report.html
13+
*.report.html
14+
coverage/

.travis.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ dist: trusty
33
language: node_js
44

55
node_js:
6-
- "4"
7-
- "5"
8-
- "6"
9-
- "stable"
6+
- '10'
7+
- '8'
108

119
addons:
1210
apt:
@@ -20,16 +18,25 @@ sudo: required
2018

2119
before_install:
2220
- sudo apt-get -qq update
21+
- curl -o- -L https://yarnpkg.com/install.sh | bash
22+
- export PATH="$HOME/.yarn/bin:$PATH"
23+
24+
install:
25+
- yarn
2326

2427
before_script:
2528
- export DISPLAY=:99.0
2629
- sh -e /etc/init.d/xvfb start
2730
- export NODE_ENV=development
2831

32+
cache:
33+
yarn: true
34+
directories:
35+
- node_modules
36+
2937
script:
30-
- npm run lint
31-
- npm test
32-
- npm run test-node
38+
- yarn lint
39+
- yarn test
3340

3441
env:
3542
- TRAVIS=travis CXX=g++-4.8

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Please make sure that there aren't existing pull requests attempting to address
1212

1313
### Linting
1414

15-
Please check your code using `npm run lint` before submitting your pull requests, as the CI build will fail if `eslint` fails.
15+
Please check your code using `yarn lint` before submitting your pull requests, as the CI build will fail if `eslint` fails.
1616

1717
### Commit Message Format
1818

Dockerfile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mhart/alpine-node:6
1+
FROM mhart/alpine-node:8
22

33
# Install required dependencies (Alpine Linux packages)
44
RUN apk update && \
@@ -17,16 +17,19 @@ RUN apk update && \
1717

1818
# Add user and make it sudoer
1919
ARG uid=1000
20-
ARG user
21-
RUN adduser -DS -u $uid $user
20+
ARG user=username
21+
RUN set -x ; \
22+
addgroup -g $uid -S $user ; \
23+
adduser -u $uid -D -S -G $user $user \
24+
&& exit 0 ; exit 1
2225
RUN echo $user' ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
2326

24-
# Switch to directory for external dependencies (installed from source)
25-
WORKDIR /external
26-
27-
# Install (global) NPM packages/dependencies
28-
RUN npm install -g \
29-
node-gyp
27+
# Install (global) Yarn packages/dependencies
28+
RUN yarn global add node-gyp
29+
RUN git clone --recursive https://github.com/sass/node-sass.git \
30+
&& cd node-sass \
31+
&& yarn \
32+
&& node scripts/build -f
3033

3134
# Make project directory with permissions
3235
RUN mkdir /project
@@ -37,5 +40,10 @@ WORKDIR /project
3740
# Copy required stuff
3841
COPY . .
3942

40-
# Install (local) NPM packages and build
41-
RUN npm install && npm run postinstall
43+
# Give owner rights to the current user
44+
RUN chown -Rh $user:$user /project
45+
46+
# Install (local) Yarn packages and build
47+
RUN yarn
48+
49+
USER $user

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ This is a starter boilerplate app I've put together using the following technolo
2626
* [Redux Dev Tools](https://github.com/reactjs/redux-devtools) for next generation DX (developer experience). Watch [Dan Abramov's talk](https://www.youtube.com/watch?v=xsSnOQynTHs).
2727
* [React Router Redux](https://github.com/reactjs/react-router-redux) Redux/React Router bindings.
2828
* [ESLint](http://eslint.org) to maintain a consistent code style
29-
* [redux-form](http://redux-form.com/) to manage form state in Redux
29+
* [react-final-form](https://github.com/final-form/react-final-form) to manage form state
3030
* [lru-memoize](https://github.com/erikras/lru-memoize) to speed up form validation
3131
* [multireducer](https://github.com/erikras/multireducer) to combine single reducers into one key-based reducer
3232
* [style-loader](https://github.com/webpack/style-loader), [sass-loader](https://github.com/jtangelder/sass-loader) and [less-loader](https://github.com/webpack/less-loader) to allow import of stylesheets in plain css, sass and less,
33-
* [bootstrap-loader](https://github.com/shakacode/bootstrap-loader) and [font-awesome-webpack](https://github.com/gowravshekar/font-awesome-webpack) to customize Bootstrap and FontAwesome
33+
* [bootstrap-loader](https://github.com/shakacode/bootstrap-loader) to customize Bootstrap
34+
* [font-awesome](https://github.com/FortAwesome/Font-Awesome)
3435
* [react-helmet](https://github.com/nfl/react-helmet) to manage title and meta tag information on both server and client
3536
* [webpack-isomorphic-tools](https://github.com/halt-hammerzeit/webpack-isomorphic-tools) to allow require() work for statics both on client and server
36-
* [Jest](https://facebook.github.io/jest/) and [mocha](https://mochajs.org/) to allow writing unit tests for the project.
37+
* [Jest](https://facebook.github.io/jest/) to allow writing unit tests for the project.
3738

3839
I cobbled this together from a wide variety of similar "starter" repositories. As I post this in June 2015, all of these libraries are right at the bleeding edge of web development. They may fall out of fashion as quickly as they have come into it, but I personally believe that this stack is the future of web development and will survive for several years. I'm building my new projects like this, and I recommend that you do, too.
3940

@@ -81,13 +82,13 @@ This new level of quality allows Progressive Web Apps to earn a place on the use
8182
## Installation
8283

8384
```bash
84-
npm install
85+
yarn
8586
```
8687

8788
## Running Dev Server
8889

8990
```bash
90-
npm run dev
91+
yarn dev
9192
```
9293

9394
The first time it may take a little while to generate the first `webpack-assets.json` and complain with a few dozen `[webpack-isomorphic-tools] (waiting for the first Webpack build to finish)` printouts, but be patient. Give it 30 seconds.
@@ -108,8 +109,8 @@ DevTools are not enabled during production by default.
108109
## Building and Running Production Server
109110

110111
```bash
111-
npm run build
112-
npm run start
112+
yarn build
113+
yarn start
113114
```
114115

115116
## Demo
@@ -133,7 +134,7 @@ We also spit out the `redux` state into a global `window.__data` variable in the
133134

134135
#### Server-side Data Fetching
135136

136-
The [redux-connect](https://www.npmjs.com/package/redux-connect) package exposes an API to return promises that need to be fulfilled before a route is rendered. It exposes a `<ReduxAsyncConnect />` container, which wraps our render tree on both [server](https://github.com/bertho-zero/react-redux-universal-hot-example/blob/master/src/server.js) and [client](https://github.com/bertho-zero/react-redux-universal-hot-example/blob/master/src/client.js). More documentation is available on the [redux-connect](https://www.npmjs.com/package/redux-connect) page.
137+
The [redial](https://www.npmjs.com/package/redial) package exposes an API to return promises that need to be fulfilled before a route is rendered. It exposes a `<ReduxAsyncConnect />` container, which wraps our render tree on both [server](https://github.com/bertho-zero/react-redux-universal-hot-example/blob/master/src/server.js) and [client](https://github.com/bertho-zero/react-redux-universal-hot-example/blob/master/src/client.js). More documentation is available on the [redial](https://www.npmjs.com/package/redial) page.
137138

138139
#### Client Side
139140

@@ -240,17 +241,15 @@ After this modification to both loaders you will be able to use scss and less fi
240241
241242
#### Unit Tests
242243
243-
The project uses [Jest](https://facebook.github.io/jest/) and [Mocha](https://mochajs.org/) to run your unit tests, it uses [Karma](http://karma-runner.github.io/0.13/index.html) as the test runner, it enables the feature that you are able to render your tests to the browser (e.g: Firefox, Chrome etc.), which means you are able to use the [Test Utilities](http://facebook.github.io/react/docs/test-utils.html) from Facebook api like `renderIntoDocument()`.
244+
The project uses [Jest](https://facebook.github.io/jest/) to run your unit tests.
244245
245-
To run the tests in the project, just simply run `npm test` if you have `Chrome` installed, it will be automatically launched as a test service for you.
246-
247-
To keep watching your test suites that you are working on, just set `singleRun: false` in the `karma.conf.js` file. Please be sure set it to `true` if you are running `npm test` on a continuous integration server (travis-ci, etc).
246+
To run the tests in the project, just simply run `yarn test` if you have `Chrome` installed, it will be automatically launched as a test service for you.
248247
249248
## Deployment on Heroku
250249
251250
To get this project to work on Heroku, you need to:
252251
253-
1. Remove the `"PORT": 8080` line from the `betterScripts` / `start-prod` section of `package.json`.
252+
1. Remove the `"PORT": 8080` line from the `start-prod` script of `package.json`.
254253
2. `heroku config:set NODE_ENV=production`
255254
3. `heroku config:set NODE_PATH=./src`
256255
4. `heroku config:set NPM_CONFIG_PRODUCTION=false`

0 commit comments

Comments
 (0)