Skip to content

Commit bd167ae

Browse files
committed
Update all the things
1 parent 584ced5 commit bd167ae

File tree

8 files changed

+1538
-2204
lines changed

8 files changed

+1538
-2204
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["@babel/preset-react"]
2+
"presets": ["@babel/preset-react"],
3+
"plugins": ["@babel/plugin-transform-modules-commonjs"]
34
}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12
1+
13

browser/app.jsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
const React = require('react')
1+
import React from 'react'
2+
import PropTypes from 'prop-types'
3+
4+
export default class App extends React.Component {
5+
static get propTypes() {
6+
return {
7+
apiUrl: PropTypes.string,
8+
}
9+
}
210

3-
module.exports = class App extends React.Component {
411
constructor(props) {
5-
super(props);
6-
this.state = {user: ''};
12+
super(props)
13+
this.state = {user: ''}
714

8-
this.handleNameChange = this.handleNameChange.bind(this);
9-
this.fetchTodos = this.fetchTodos.bind(this);
15+
this.handleNameChange = this.handleNameChange.bind(this)
16+
this.fetchTodos = this.fetchTodos.bind(this)
1017
}
1118

1219
handleNameChange(event) {
13-
this.setState({user: event.target.value});
20+
this.setState({user: event.target.value})
1421
}
1522

1623
async fetchTodos(event) {
@@ -33,7 +40,7 @@ module.exports = class App extends React.Component {
3340
return this.state.todos
3441
?
3542
<>
36-
<h1>{this.state.user}'s TODOs</h1>
43+
<h1>{this.state.user}&apos;s TODOs</h1>
3744
<ul>
3845
{this.state.todos.map((todo, n) => <li key={n}>{todo.title}</li>)}
3946
</ul>

browser/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import React from 'react'
22
import ReactDOM from 'react-dom'
33
import App from './app'
44

5-
ReactDOM.render(<App apiUrl={window.location.href}/>, document.body)
5+
ReactDOM.render(<App apiUrl={window.location.href}/>, document.querySelector('main'))

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,35 @@
44
"start": "./scripts/start.sh",
55
"postinstall": "electron-rebuild",
66
"dev": "nf start",
7-
"test": "electron-mocha -r @babel/register --color --renderer ./test/*Spec.js",
7+
"test": "electron-mocha -r @babel/register --no-timeout --color --renderer ./test/*Spec.js",
88
"lint": "eslint $(git ls-files | grep -E '\\.js$')",
99
"build": "webpack",
1010
"heroku-postbuild": "npm run build",
1111
"watch-assets": "yarn build --watch"
1212
},
1313
"dependencies": {
1414
"@babel/core": "latest",
15-
"@babel/preset-react": "^7.0.0",
15+
"@babel/preset-react": "latest",
1616
"babel-loader": "latest",
17-
"electron-rebuild": "^1.8.4",
18-
"eslint-plugin-react": "^7.13.0",
17+
"electron-rebuild": "latest",
18+
"eslint-plugin-react": "latest",
1919
"express": "latest",
2020
"morgan": "latest",
21-
"react": "^16.8.6",
22-
"react-dom": "^16.8.6",
23-
"sqlite3": "^4.0.8",
21+
"react": "latest",
22+
"react-dom": "latest",
23+
"sqlite3": "latest",
2424
"webpack": "latest",
2525
"webpack-cli": "latest",
2626
"webpack-manifest-plugin": "latest"
2727
},
2828
"devDependencies": {
29-
"@babel/register": "^7.4.4",
29+
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
30+
"@babel/register": "latest",
3031
"browser-monkey": "latest",
3132
"chai": "latest",
3233
"chokidar": "latest",
33-
"electron": "^4",
34-
"electron-mocha": "^7",
34+
"electron": "latest",
35+
"electron-mocha": "latest",
3536
"eslint": "latest",
3637
"foreman": "latest",
3738
"mocha": "latest",

server/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const http = require('http')
22
const express = require('express')
3-
const morgan = require('morgan')
43
const loadManifest = require('./loadManifest')
54
const sqlite3 = require('sqlite3')
65
const LiveReload = require('./liveReload')
@@ -18,6 +17,7 @@ function renderIndexHtml () {
1817
<title>TODOs</title>
1918
</head>
2019
<body>
20+
<main></main>
2121
${scripts.map(url => `<script type="text/javascript" src="/dist/${url}"></script>`).join('\n')}
2222
</body>
2323
</html>
@@ -26,7 +26,6 @@ function renderIndexHtml () {
2626

2727
module.exports = function () {
2828
const app = express()
29-
app.use(morgan('dev'))
3029

3130
app.get('/api/todos/:user', (req, res) => {
3231
const db = new sqlite3.Database(process.env.DB || process.cwd() + '/app.db')

test/todosSpec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const {existsSync, unlinkSync} = require('fs')
2-
const ReactDOM = require('react-dom')
3-
const React = require('react')
4-
const createMonkey = require('browser-monkey/create')
5-
const createTestDiv = require('browser-monkey/lib/createTestDiv')
6-
const {Database} = require('sqlite3')
7-
const App = require('../browser/app')
8-
const createServer = require('../server/app')
1+
import {existsSync, unlinkSync} from 'fs'
2+
import ReactDOM from 'react-dom'
3+
import React from 'react'
4+
import createMonkey from 'browser-monkey/create'
5+
import createTestDiv from 'browser-monkey/lib/createTestDiv'
6+
import {Database} from 'sqlite3'
7+
import createServer from '../server/app'
8+
import App from '../browser/app'
99

1010
let dbPath = process.env.DB = process.cwd() + '/test/test.db'
1111

@@ -58,7 +58,7 @@ describe('todos app', () => {
5858
})
5959

6060
context('user does not exist', () => {
61-
it('shows a message', async () => {
61+
it('shows a "not found" message', async () => {
6262
await page.find('input[name=user]').typeIn('Bob')
6363
await page.click('Fetch TODOs')
6464
await page.shouldHave({text: "Could not find Bob's TODOs"})

0 commit comments

Comments
 (0)