Skip to content

Commit 5813f45

Browse files
authored
F/prettier (#87)
* feat(prettier): incorporate automatic formatting on commit * chore(prettier): normalize all source code to prettier style * feat(prettier): prettify additional filetypes * feat(prettier): prettify secrets, ignore package.json * chore(prettier): re-normalize according to stated prefs * feat(prettier): make automatic prettification opt-in * chore(prettier): prettify merged files (seed.js) * fix(scripts): re-remove prepush
1 parent ad468c9 commit 5813f45

23 files changed

+5779
-4427
lines changed

.eslintrc.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"root": true,
3-
"extends": "fullstack",
4-
"rules": {
5-
"semi": 0,
6-
"new-cap": [1, { "capIsNewExceptions": ["Router"] }]
7-
}
2+
"root": true,
3+
"extends": ["fullstack", "prettier", "prettier/react"],
4+
"rules": {
5+
"semi": 0
6+
}
87
}

.github/ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ For features, please specify at least minimal requirements, e.g.:
1212

1313
---
1414

15-
*Issue description here…*
15+
_Issue description here…_

.github/PULL_REQUEST_TEMPLATE.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
### Assignee Tasks
22

3-
- [ ] added unit tests (or none needed)
4-
- [ ] written relevant docs (or none needed)
5-
- [ ] referenced any relevant issues (or none exist)
3+
* [ ] added unit tests (or none needed)
4+
* [ ] written relevant docs (or none needed)
5+
* [ ] referenced any relevant issues (or none exist)
66

77
### Guidelines
88

99
Please add a description of this Pull Request's motivation, scope, outstanding issues or potential alternatives, reasoning behind the current solution, and any other relevant information for posterity.
1010

1111
---
1212

13-
*Your PR Notes Here*
13+
_Your PR Notes Here_

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public/bundle.js
2+
public/bundle.js.map
3+
package-lock.json
4+
package.json

.prettierrc.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# printWidth: 80 # 80
2+
# tabWidth: 2 # 2
3+
# useTabs: false # false
4+
semi: false # true
5+
singleQuote: true # false
6+
# trailingComma: none # none | es5 | all
7+
bracketSpacing: false # true
8+
# jsxBracketSameLine: false # false
9+
# arrowParens: avoid # avoid | always

README.md

+35-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Boilermaker
22

3-
*Good things come in pairs*
3+
_Good things come in pairs_
44

55
Looking to mix up a backend with express/sequelize and a frontend with react/redux? That's `boilermaker`!
66

@@ -35,9 +35,10 @@ Now that you've got the code, follow these steps to get acclimated:
3535
* Create two postgres databases: `boilermaker` and `boilermaker-test` (you can substitute these with the name of your own application - just be sure to go through and change the `package.json` and `.travis.yml` to refer to the new name)
3636
* By default, running `npm test` will use `boilermaker-test`, while regular development uses `boilermaker`
3737
* Create a file called `secrets.js` in the project root
38-
* This file is `.gitignore`'d, and will *only* be required in your *development* environment
38+
39+
* This file is `.gitignore`'d, and will _only_ be required in your _development_ environment
3940
* Its purpose is to attach the secret env variables that you'll use while developing
40-
* However, it's **very** important that you **not** push it to Github! Otherwise, *prying eyes* will find your secret API keys!
41+
* However, it's **very** important that you **not** push it to Github! Otherwise, _prying eyes_ will find your secret API keys!
4142
* It might look like this:
4243

4344
```
@@ -78,15 +79,19 @@ Ready to go world wide? Here's a guide to deployment! There are two (compatible)
7879
Either way, you'll need to set up your deployment server to start:
7980

8081
### Prep
81-
1. Set up the [Heroku command line tools](https://devcenter.heroku.com/articles/heroku-cli)
82-
2. `heroku login`
83-
3. Add a git remote for heroku:
84-
- **If you're creating a new app...**
85-
1. `heroku create` or `heroku create your-app-name` if you have a name in mind.
86-
2. `heroku addons:create heroku-postgresql:hobby-dev` to add ("provision") a postgres database to your heroku dyno
8782

88-
- **If you already have a Heroku app...**
89-
1. `heroku git:remote your-app-name` You'll need to be a collaborator on the app.
83+
1. Set up the [Heroku command line tools](https://devcenter.heroku.com/articles/heroku-cli)
84+
2. `heroku login`
85+
3. Add a git remote for heroku:
86+
87+
* **If you're creating a new app...**
88+
89+
1. `heroku create` or `heroku create your-app-name` if you have a name in mind.
90+
2. `heroku addons:create heroku-postgresql:hobby-dev` to add ("provision") a postgres database to your heroku dyno
91+
92+
* **If you already have a Heroku app...**
93+
94+
1. `heroku git:remote your-app-name` You'll need to be a collaborator on the app.
9095

9196
### When you're ready to deploy
9297

@@ -96,31 +101,32 @@ Either way, you'll need to set up your deployment server to start:
96101

97102
CI is not about testing per se – it's about _continuously integrating_ your changes into the live application, instead of periodically _releasing_ new versions. CI tools can not only test your code, but then automatically deploy your app. Boilermaker comes with a `.travis.yml` configuration almost ready for deployment; follow these steps to complete the job.
98103

99-
1. Run `git checkout master && git pull && git checkout -b f/travis-deploy` (or use some other new branch name).
100-
2. Un-comment the bottom part of `.travis.yml` (the `before_deploy` and `deploy` sections)
101-
3. Add your Heroku app name to `deploy.app`, where it says "YOUR HEROKU APP NAME HERE". For example, if your domain is `cool-salty-conifer.herokuapp.com`, your app name is `cool-salty-conifer`.
102-
4. Install the Travis CLI tools by following [the instructions here](https://github.com/travis-ci/travis.rb#installation).
103-
5. Run `travis encrypt $(heroku auth:token) --org` to encrypt your Heroku API key. _**Warning:** do not run the `--add` command suggested by Travis, that will rewrite part of our existing config!_
104-
6. Copy-paste your encrypted API key into the `.travis.yml` file under `deploy.api_key.secure`, where it says "YOUR ENCRYPTED API KEY HERE".
105-
7. `git add -A && git commit -m 'travis: activate deployment' && git push -u origin f/travis-deploy`
106-
8. Make a PR for the new branch, get it approved, and merge it into master.
104+
1. Run `git checkout master && git pull && git checkout -b f/travis-deploy` (or use some other new branch name).
105+
2. Un-comment the bottom part of `.travis.yml` (the `before_deploy` and `deploy` sections)
106+
3. Add your Heroku app name to `deploy.app`, where it says "YOUR HEROKU APP NAME HERE". For example, if your domain is `cool-salty-conifer.herokuapp.com`, your app name is `cool-salty-conifer`.
107+
4. Install the Travis CLI tools by following [the instructions here](https://github.com/travis-ci/travis.rb#installation).
108+
5. Run `travis encrypt $(heroku auth:token)` to encrypt your Heroku API key. _**Warning:** do not run the `--add` command suggested by Travis, that will rewrite part of our existing config!_
109+
6. Copy-paste your encrypted API key into the `.travis.yml` file under `deploy.api_key.secure`, where it says "YOUR ENCRYPTED API KEY HERE".
110+
7. `git add -A && git commit -m 'travis: activate deployment' && git push -u origin f/travis-deploy`
111+
8. Make a PR for the new branch, get it approved, and merge it into master.
107112

108113
That's it! From now on, whenever `master` is updated on GitHub, Travis will automatically push the app to Heroku for you.
109114

110115
#### Option B: Manual Deployment from your Local Machine
111116

112117
Some developers may prefer to control deployment rather than rely on automation. Your local copy of the application can be pushed up to Heroku at will, using Boilermaker's handy deployment script:
113118

114-
1. Make sure that all your work is fully committed and pushed to your master branch on Github.
115-
2. If you currently have an existing branch called "deploy", delete it now (`git branch -d deploy`). We're going to use a dummy branch with the name "deploy" (see below), so if you have one lying around, the script below will error
116-
3. `npm run deploy` - this will cause the following commands to happen in order:
117-
- `git checkout -b deploy`: checks out a new branch called "deploy". Note that the name "deploy" here isn't magical, but it needs to match the name of the branch we specify when we push to our heroku remote.
118-
- `webpack -p`: webpack will run in "production mode"
119-
- `git add -f public/bundle.js public/bundle.js.map`: "force" add the otherwise gitignored build files
120-
- `git commit --allow-empty -m 'Deploying'`: create a commit, even if nothing changed
121-
- `git push --force heroku deploy:master`: push your local "deploy" branch to the "master" branch on heroku
122-
- `git checkout master`: return to your master branch
123-
- `git branch -D deploy`: remove the deploy branch
119+
1. Make sure that all your work is fully committed and pushed to your master branch on Github.
120+
2. If you currently have an existing branch called "deploy", delete it now (`git branch -d deploy`). We're going to use a dummy branch with the name "deploy" (see below), so if you have one lying around, the script below will error
121+
3. `npm run deploy` - this will cause the following commands to happen in order:
122+
123+
* `git checkout -b deploy`: checks out a new branch called "deploy". Note that the name "deploy" here isn't magical, but it needs to match the name of the branch we specify when we push to our heroku remote.
124+
* `webpack -p`: webpack will run in "production mode"
125+
* `git add -f public/bundle.js public/bundle.js.map`: "force" add the otherwise gitignored build files
126+
* `git commit --allow-empty -m 'Deploying'`: create a commit, even if nothing changed
127+
* `git push --force heroku deploy:master`: push your local "deploy" branch to the "master" branch on heroku
128+
* `git checkout master`: return to your master branch
129+
* `git branch -D deploy`: remove the deploy branch
124130

125131
Now, you should be deployed!
126132

client/app.js

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React from 'react'
33
import {Navbar} from './components'
44
import Routes from './routes'
55

6-
76
const App = () => {
87
return (
98
<div>

client/components/auth-form.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ import {auth} from '../store'
66
/**
77
* COMPONENT
88
*/
9-
const AuthForm = (props) => {
9+
const AuthForm = props => {
1010
const {name, displayName, handleSubmit, error} = props
1111

1212
return (
1313
<div>
1414
<form onSubmit={handleSubmit} name={name}>
1515
<div>
16-
<label htmlFor="email"><small>Email</small></label>
16+
<label htmlFor="email">
17+
<small>Email</small>
18+
</label>
1719
<input name="email" type="text" />
1820
</div>
1921
<div>
20-
<label htmlFor="password"><small>Password</small></label>
22+
<label htmlFor="password">
23+
<small>Password</small>
24+
</label>
2125
<input name="password" type="password" />
2226
</div>
2327
<div>
@@ -37,25 +41,25 @@ const AuthForm = (props) => {
3741
* function, and share the same Component. This is a good example of how we
3842
* can stay DRY with interfaces that are very similar to each other!
3943
*/
40-
const mapLogin = (state) => {
44+
const mapLogin = state => {
4145
return {
4246
name: 'login',
4347
displayName: 'Login',
4448
error: state.user.error
4549
}
4650
}
4751

48-
const mapSignup = (state) => {
52+
const mapSignup = state => {
4953
return {
5054
name: 'signup',
5155
displayName: 'Sign Up',
5256
error: state.user.error
5357
}
5458
}
5559

56-
const mapDispatch = (dispatch) => {
60+
const mapDispatch = dispatch => {
5761
return {
58-
handleSubmit (evt) {
62+
handleSubmit(evt) {
5963
evt.preventDefault()
6064
const formName = evt.target.name
6165
const email = evt.target.email.value

client/components/navbar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {connect} from 'react-redux'
44
import {Link} from 'react-router-dom'
55
import {logout} from '../store'
66

7-
const Navbar = ({ handleClick, isLoggedIn }) => (
7+
const Navbar = ({handleClick, isLoggedIn}) => (
88
<div>
99
<h1>BOILERMAKER</h1>
1010
<nav>

client/components/user-home.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {connect} from 'react-redux'
55
/**
66
* COMPONENT
77
*/
8-
export const UserHome = (props) => {
8+
export const UserHome = props => {
99
const {email} = props
1010

1111
return (
@@ -18,7 +18,7 @@ export const UserHome = (props) => {
1818
/**
1919
* CONTAINER
2020
*/
21-
const mapState = (state) => {
21+
const mapState = state => {
2222
return {
2323
email: state.user.email
2424
}

client/history.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import createHistory from 'history/createBrowserHistory'
22
import createMemoryHistory from 'history/createMemoryHistory'
33

4-
const history = process.env.NODE_ENV === 'test' ? createMemoryHistory() : createHistory()
4+
const history =
5+
process.env.NODE_ENV === 'test' ? createMemoryHistory() : createHistory()
56

67
export default history

client/routes.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,24 @@ import {me} from './store'
99
* COMPONENT
1010
*/
1111
class Routes extends Component {
12-
componentDidMount () {
12+
componentDidMount() {
1313
this.props.loadInitialData()
1414
}
1515

16-
render () {
16+
render() {
1717
const {isLoggedIn} = this.props
1818

1919
return (
2020
<Switch>
2121
{/* Routes placed here are available to all visitors */}
2222
<Route path="/login" component={Login} />
2323
<Route path="/signup" component={Signup} />
24-
{
25-
isLoggedIn &&
26-
<Switch>
27-
{/* Routes placed here are only available after logging in */}
28-
<Route path="/home" component={UserHome} />
29-
</Switch>
30-
}
24+
{isLoggedIn && (
25+
<Switch>
26+
{/* Routes placed here are only available after logging in */}
27+
<Route path="/home" component={UserHome} />
28+
</Switch>
29+
)}
3130
{/* Displays our Login component as a fallback */}
3231
<Route component={Login} />
3332
</Switch>
@@ -38,17 +37,17 @@ class Routes extends Component {
3837
/**
3938
* CONTAINER
4039
*/
41-
const mapState = (state) => {
40+
const mapState = state => {
4241
return {
4342
// Being 'logged in' for our purposes will be defined has having a state.user that has a truthy id.
4443
// Otherwise, state.user will be an empty object, and state.user.id will be falsey
4544
isLoggedIn: !!state.user.id
4645
}
4746
}
4847

49-
const mapDispatch = (dispatch) => {
48+
const mapDispatch = dispatch => {
5049
return {
51-
loadInitialData () {
50+
loadInitialData() {
5251
dispatch(me())
5352
}
5453
}

client/store/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import {composeWithDevTools} from 'redux-devtools-extension'
55
import user from './user'
66

77
const reducer = combineReducers({user})
8-
const middleware = composeWithDevTools(applyMiddleware(
9-
thunkMiddleware,
10-
createLogger({collapsed: true})
11-
))
8+
const middleware = composeWithDevTools(
9+
applyMiddleware(thunkMiddleware, createLogger({collapsed: true}))
10+
)
1211
const store = createStore(reducer, middleware)
1312

1413
export default store

client/store/user.js

+25-22
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,40 @@ const removeUser = () => ({type: REMOVE_USER})
2121
/**
2222
* THUNK CREATORS
2323
*/
24-
export const me = () =>
25-
dispatch =>
26-
axios.get('/auth/me')
27-
.then(res =>
28-
dispatch(getUser(res.data || defaultUser)))
29-
.catch(err => console.log(err))
24+
export const me = () => dispatch =>
25+
axios
26+
.get('/auth/me')
27+
.then(res => dispatch(getUser(res.data || defaultUser)))
28+
.catch(err => console.log(err))
3029

31-
export const auth = (email, password, method) =>
32-
dispatch =>
33-
axios.post(`/auth/${method}`, { email, password })
34-
.then(res => {
30+
export const auth = (email, password, method) => dispatch =>
31+
axios
32+
.post(`/auth/${method}`, {email, password})
33+
.then(
34+
res => {
3535
dispatch(getUser(res.data))
3636
history.push('/home')
37-
}, authError => { // rare example: a good use case for parallel (non-catch) error handler
37+
},
38+
authError => {
39+
// rare example: a good use case for parallel (non-catch) error handler
3840
dispatch(getUser({error: authError}))
39-
})
40-
.catch(dispatchOrHistoryErr => console.error(dispatchOrHistoryErr))
41+
}
42+
)
43+
.catch(dispatchOrHistoryErr => console.error(dispatchOrHistoryErr))
4144

42-
export const logout = () =>
43-
dispatch =>
44-
axios.post('/auth/logout')
45-
.then(_ => {
46-
dispatch(removeUser())
47-
history.push('/login')
48-
})
49-
.catch(err => console.log(err))
45+
export const logout = () => dispatch =>
46+
axios
47+
.post('/auth/logout')
48+
.then(_ => {
49+
dispatch(removeUser())
50+
history.push('/login')
51+
})
52+
.catch(err => console.log(err))
5053

5154
/**
5255
* REDUCER
5356
*/
54-
export default function (state = defaultUser, action) {
57+
export default function(state = defaultUser, action) {
5558
switch (action.type) {
5659
case GET_USER:
5760
return action.user

0 commit comments

Comments
 (0)