Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

big upgrade #173

Merged
merged 12 commits into from
Apr 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@
],
"env":{
"test": {
"presets": [
// Jest runs in Node and needs to transpile ES6 modules to CommonJS.
// For normal builds, Webpack 2 supports ES modules natively.
["env", {
"targets": {
"node": 6
},
"modules": "commonjs"
}]
]
"presets": [["env", { "modules": "commonjs" }]]
},
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
'react/jsx-filename-extension': [2, { extensions: ['.js'] }],
'react/prefer-stateless-function': 0,
'react/prop-types': 0,
'jsx-a11y/anchor-is-valid': [2, { specialLink: ['to'] }],
},
parserOptions: {
ecmaVersion: 8,
Expand All @@ -39,4 +40,7 @@ module.exports = {
es6: true,
jest: true,
},
settings: {
'import/resolver': 'webpack',
},
};
13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ cache: yarn
env:
global:
- NODE_ENV=test
before_install: yarn global add greenkeeper-lockfile
before_script: greenkeeper-lockfile-update
script:
- yarn run lint
- yarn run test -- --coverage
- yarn lint
- yarn test --coverage
- NODE_ENV=production $(yarn bin)/webpack
after_success:
- bash yarn.sh
- greenkeeper-lockfile-upload
- bash <(curl -s https://codecov.io/bash)
deploy:
provider: s3
Expand All @@ -26,9 +28,8 @@ deploy:
condition: $(node aws/utils bucketExists) = "true"
after_deploy:
- node aws/utils invalidate "/index.html"
# This package is broken with Yarn
- node_modules/sentry-cli-binary/bin/sentry-cli releases -o $(node config SentryOrg) -p $(node config SentryProject) new $TRAVIS_COMMIT
- node_modules/sentry-cli-binary/bin/sentry-cli releases -o $(node config SentryOrg) -p $(node config SentryProject) files $TRAVIS_COMMIT upload-sourcemaps dist
- $(yarn bin)/sentry-cli releases -o $(node config SentryOrg) -p $(node config SentryProject) new $TRAVIS_COMMIT
- $(yarn bin)/sentry-cli releases -o $(node config SentryOrg) -p $(node config SentryProject) files $TRAVIS_COMMIT upload-sourcemaps dist
notifications:
email: false
slack: bjacobel:xasDl3nTxo2feJGba70E43oR
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### v0.1.0
- Upgrade to React 16
- Upgrade to Webpack 4
- Many, many other package upgrades [see here for more](https://github.com/bjacobel/rak/pull/173/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2)
- Refactor test folder structure
- Shrink bundle size significantly

### v0.0.5
- Refactor with Prettier

Expand Down
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
collectCoverageFrom: ['src/**/*.js'],
coveragePathIgnorePatterns: ['polyfills.js'],
moduleNameMapper: {
'^.+\\.css$': '<rootDir>/__mocks__/stylesheets.js',
},
moduleDirectories: [__dirname, 'node_modules', 'src'],
snapshotSerializers: ['enzyme-to-json/serializer'],
setupFiles: ['raf/polyfill', './jest.setup.js'],
};
File renamed without changes.
109 changes: 48 additions & 61 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,67 @@
"bin": "install.js",
"bugs": "https://github.com/bjacobel/rak/issues",
"dependencies": {
"core-js": "^2.5.5",
"raf": "^3.4.0",
"raven-js": "^3.14.2",
"react": "^16.0.0",
"react-dom": "^16.0.0",
"react-redux": "^5.0.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.7",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"redux": "^3.6.0",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"description": "Opinionated skeleton to quickly set up a new React app.",
"devDependencies": {
"@bjacobel/cloudformer-node": "^0.0.13",
"@mapbox/cloudfriend": "^1.8.1",
"autoprefixer": "^7.0.0",
"aws-sdk": "^2.9.0",
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-plugin-transform-object-rest-spread": "^6.22.0",
"babel-polyfill": "^6.22.0",
"babel-preset-env": "^1.3.1",
"babel-preset-react": "^6.22.0",
"css-loader": "^0.28.0",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.1.0",
"eslint": "^4.3.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-prettier": "^2.3.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-react": "^7.1.0",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^1.0.0-rc.0",
"html-webpack-plugin": "^2.28.0",
"inline-manifest-webpack-plugin": "^3.0.1",
"jest-cli": "^21.1.0",
"postcss-font-magician": "^2.0.0",
"postcss-loader": "^2.0.1",
"postcss-modules-values": "^1.2.2",
"@mapbox/cloudfriend": "^1.9.0",
"@sentry/cli": "^1.30.5",
"autoprefixer": "^8.3.0",
"aws-sdk": "^2.205.0",
"babel-core": "^6.26.0",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.3",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-react-jsx-source": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.0",
"css-loader": "^0.28.10",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.1",
"eslint": "^4.18.2",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-import-resolver-webpack": "^0.9.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.7.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.0.4",
"jest-cli": "^21.0.2",
"mini-css-extract-plugin": "^0.4.0",
"postcss-font-magician": "^2.1.1",
"postcss-loader": "^2.1.4",
"postcss-modules-values": "^1.3.0",
"precss": "^2.0.0",
"prettier": "^1.4.4",
"react-test-renderer": "^16.0.0",
"redux-mock-store": "^1.2.2",
"script-ext-html-webpack-plugin": "^1.7.1",
"sentry-cli-binary": "^1.8.0",
"style-loader": "^0.19.0",
"stylelint": "^8.0.0",
"stylelint-config-css-modules": "^1.1.0",
"stylelint-config-standard": "^17.0.0",
"url-loader": "^0.6.2",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.4.0"
"prettier": "^1.11.1",
"react-test-renderer": "^16.2.0",
"redux-mock-store": "^1.5.1",
"script-ext-html-webpack-plugin": "^2.0.1",
"style-loader": "^0.20.2",
"stylelint": "^9.1.1",
"stylelint-config-css-modules": "^1.2.0",
"stylelint-config-standard": "^18.2.0",
"url-loader": "^1.0.1",
"webpack": "^4.2.0",
"webpack-cli": "^2.0.10",
"webpack-dev-server": "^3.1.0"
},
"engines": {
"node": "^8"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.js"
],
"moduleNameMapper": {
"^.+\\.css$": "<rootDir>/__mocks__/stylesheets.js"
},
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"setupFiles": [
"raf/polyfill",
"./jest.js"
],
"testRegex": "tests/.*/.*-test.js$"
},
"keywords": [
"boilerplate",
"react",
Expand All @@ -98,5 +85,5 @@
"start": "webpack-dev-server",
"test": "jest --coverage && ./install-test.sh"
},
"version": "0.0.5"
"version": "0.1.0"
}
20 changes: 7 additions & 13 deletions tests/actions/data-test.js → src/actions/__tests__/data-test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';

import {
GET_DATA_FAILED,
GET_DATA_SUCCEEDED,
getDataFailed,
getDataSucceeded,
getDataAsync,
} from '../../src/actions/data';
import { LOADING_STARTED, LOADING_ENDED } from '../../src/actions/loading';
import { getData } from '../../src/services/data';
import '../../src/services/errors';
import { GET_DATA_FAILED, GET_DATA_SUCCEEDED, getDataFailed, getDataSucceeded, getDataAsync } from 'actions/data';
import { LOADING_STARTED, LOADING_ENDED } from 'actions/loading';
import { getData } from 'services/data';
import 'services/errors';

jest.mock('../../src/services/data');
jest.mock('../../src/services/errors');
jest.mock('services/data');
jest.mock('services/errors');

const mockStore = configureMockStore([thunk]);

Expand Down Expand Up @@ -61,7 +55,7 @@ describe('data actions', () => {
}));

it('calls getData, on fail it dispatches loadingEnded and getDataFailed', () => {
getData.mockImplementationOnce(() => Promise.reject('error'));
getData.mockImplementationOnce(() => Promise.reject(new Error('error')));

return store.dispatch(getDataAsync()).then(() => {
expect(store.getActions()).toEqual(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loadingStarted, loadingEnded, LOADING_STARTED, LOADING_ENDED } from '../../src/actions/loading';
import { loadingStarted, loadingEnded, LOADING_STARTED, LOADING_ENDED } from 'actions/loading';

describe('loading actions', () => {
describe('loadingStarted', () => {
Expand Down
6 changes: 2 additions & 4 deletions src/components/Child.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import Link from 'react-router-dom/Link';

import styles from '../stylesheets/child.css';
import { link } from '../stylesheets/link.css';
Expand All @@ -9,9 +9,7 @@ export default class Child extends Component {
const { match } = this.props;
return (
<div>
<h3 className={styles.id}>
received param: {match.params.id}
</h3>
<h3 className={styles.id}>received param: {match.params.id}</h3>
<Link className={link} to="/">
Home
</Link>
Expand Down
8 changes: 3 additions & 5 deletions src/components/Main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import Link from 'react-router-dom/Link';

import styles from '../stylesheets/main.css';
import { link } from '../stylesheets/link.css';
Expand All @@ -25,10 +25,8 @@ class Main extends Component {
return (
<div>
<div className={styles.logo} />
<h3 className={styles.data}>
{data.text || ''}
</h3>
<Link className={link} to={'/child/foo'}>
<h3 className={styles.data}>{data.text || ''}</h3>
<Link className={link} to="/child/foo">
Routing demo
</Link>
<Link className={link} to="/asdf">
Expand Down
2 changes: 1 addition & 1 deletion src/components/NotFound.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import Link from 'react-router-dom/Link';

import styles from '../stylesheets/notFound.css';
import { link } from '../stylesheets/link.css';
Expand Down
4 changes: 3 additions & 1 deletion src/components/Routes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { Component } from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import BrowserRouter from 'react-router-dom/BrowserRouter';
import Route from 'react-router-dom/Route';
import Switch from 'react-router-dom/Switch';

import NotFound from './NotFound';
import Child from './Child';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import Child from '../../src/components/Child';
import Child from 'components/Child';

describe('child component', () => {
it('matches snapshot', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import Main from '../../src/components/Main';
import Main from 'components/Main';

describe('main component', () => {
describe('un-Connected component', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow } from 'enzyme';

import NotFound from '../../src/components/NotFound';
import NotFound from 'components/NotFound';

describe('404 component', () => {
it('matches snapshot', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { shallow, mount } from 'enzyme';

import Routes from '../../src/components/Routes';
import Analytics from '../../src/services/Analytics';
import Routes from 'components/Routes';
import Analytics from 'services/Analytics';

jest.mock('../../src/components/Main');
jest.mock('../../src/components/Child');
jest.mock('../../src/components/NotFound');
jest.mock('../../src/services/Analytics');
jest.mock('components/Main');
jest.mock('components/Child');
jest.mock('components/NotFound');
jest.mock('services/Analytics');

const setPath = value => {
// thanks @cpojer! https://github.com/facebook/jest/issues/890#issuecomment-209698782
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import 'babel-polyfill';
/* eslint-disable import/first */
import './polyfills';

import React from 'react';
import ReactDOM from 'react-dom';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware, compose } from 'redux';
/* eslint-enable import/first */

import reducer from './reducers';
import Routes from './components/Routes';
import { SHOW_DEV_TOOLS } from './constants';

const composeEnhancers = (SHOW_DEV_TOOLS && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; // eslint-disable-line max-len, no-underscore-dangle
const composeEnhancers = (SHOW_DEV_TOOLS && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; // eslint-disable-line no-underscore-dangle

const store = createStore(reducer, {}, composeEnhancers(applyMiddleware(...[thunk])));

Expand Down
3 changes: 3 additions & 0 deletions src/polyfills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'raf/polyfill';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import data from '../../src/reducers/data';
import { GET_DATA_SUCCEEDED } from '../../src/actions/data';
import data from 'reducers/data';
import { GET_DATA_SUCCEEDED } from 'actions/data';

describe('data reducer', () => {
describe(`action type ${GET_DATA_SUCCEEDED}`, () => {
Expand Down
Loading