Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
merge master into webpack2 branch (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 authored Oct 29, 2016
1 parent 9d416a0 commit 206f237
Show file tree
Hide file tree
Showing 45 changed files with 375 additions and 534 deletions.
14 changes: 13 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,17 @@
"plugins": [
"transform-runtime",
"meteor-imports"
]
],
"env": {
"coverage": {
"plugins": [
["istanbul", {
"exclude": [
"build/meteor/**/*.js",
"test/**/*.js"
]
}]
]
}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
node_modules
build
errorShots
coverage
.nyc_output
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,37 @@ services:
- docker
env:
DOCKER_COMPOSE_VERSION: 1.8.0
CXX: g++-4.8
DEBUG: crater-util:kill,crater-util:kill:ps,crater:shutdown,crater:logs:browser,smart-restart:supervisor
DUMP_HTTP: 1

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- libgnome-keyring-dev

cache:
directories:
- node_modules

before_install:
# enable more file watches
- echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- npm config set progress false
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- curl https://install.meteor.com/ | sh
- docker run -p 27017:27017 --detach mongo:3.2.8

script:
- npm install popsicle
- npm run lint
- npm run flow
- npm run test:hot-reloading
- npm run coverage
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 2.0.0

(The first version bump. It's time I got better about logging changes.)

Got rid of the `npm run check` script and replaced it with `npm run lint:watch` and `npm run flow:watch` scripts.
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Crater

[![Build Status](https://travis-ci.org/jedwards1211/crater.svg?branch=master)](https://travis-ci.org/jedwards1211/crater)
[![Build Status](https://travis-ci.org/jcoreio/crater.svg?branch=master)](https://travis-ci.org/jcoreio/crater)
[![Coverage Status](https://coveralls.io/repos/github/jcoreio/crater/badge.svg?branch=master)](https://coveralls.io/github/jcoreio/crater?branch=master)

## A new app skeleton for Meteor/React

Expand All @@ -23,6 +24,8 @@ If you can't start over (i.e. switch to [Meatier](https://github.com/mattkrick/m
* redux
* react-router
* react-router-redux
* eslint, eslint-watch
* flow, flow-watch
* Very customizable
* Dockerfile included
* Webdriver.io + Mocha + Chai integration test setup
Expand Down Expand Up @@ -89,6 +92,17 @@ If you want a different folder structure, it's perfectly possible to customize t
See explanation [here](https://github.com/luisherranz/meteor-imports-webpack-plugin#the-bad-things).
A Webpack loader for Spacebars HTML templates could be implemented, but it's not a priority for me.

## react-meteor-data

Currently the Meteor package doesn't work with Crater. As a superior alternative, use the version I published as a true NPM package:
```
npm install --save-dev react-meteor-data react-addons-pure-render-mixin
```
Then import it like this:
```es6
import {ReactMeteorData} from 'react-meteor-data'
```

## Version notes
* **Node**: Tested on the latest Node 4, 5, and 6 in Travis CI. No effort will be made to support Node < 4.4.7.
* **Webpack**: The `master` branch currently works only with Webpack 1. If you want to use Webpack 2, check out the [`webpack2` branch](https://github.com/jedwards1211/crater/tree/webpack2).
Expand All @@ -107,8 +121,6 @@ git checkout webpack2
## Running
Crater doesn't start a Mongo dev database, before running, you must start one by running `mongod` in a separate shell.

**Note: if you're *not* using Node 4, you will need to rebuild the fibers binary for your node version -- see the [Troubleshooting](#troubleshooting) section for more details.**

### Dev mode

*Note*: dev mode only renders a basic page on the server side; only prod mode and the built app render your routes
Expand Down Expand Up @@ -141,6 +153,16 @@ npm run prod
```
And open http://localhost:3000 in your browser.

### Disabling full SSR in prod mode
As neat as it is, full-blown SSR requires more work and you might decide it's not worth it.
To only render an empty HTML document on the server and do everything else on the client, even in production,
set the `DISABLE_FULL_SSR` environment variable:
```
DISABLE_FULL_SSR=1 npm run prod # or npm run build, etc.
```
or look in `webpack/webpack.config.server.js` and uncomment the `DISABLE_FULL_SSR` line inside the
`webpack.DefinePlugin`. If you build bundles this way, there will be no way to turn full SSR back on at runtime.

### Prod Debug mode
```
npm run prod:debug
Expand All @@ -152,10 +174,12 @@ npm run prod:debug-brk
And then go to the usual `node-inspector` URL, which will be printed in the console.

### Eslint/Flow
```
npm run check
```
Starts a `supervisor` watcher that reruns `eslint` and `flow` when you change anything.
The following scripts are available:
- `npm run lint`
- `npm run lint:fix`
- `npm run lint:watch`
- `npm run flow`
- `npm run flow:watch`

### Build
```
Expand Down
45 changes: 33 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@
"prod": "babel-node scripts/prod.js",
"prod:debug": "babel-node scripts/prod-debug.js",
"prod:debug-brk": "babel-node scripts/prod-debug-brk.js",
"pretest": "babel-node scripts/pretest.js",
"test": "babel-node scripts/test.js",
"test:dev": "babel-node scripts/test.js --mochaOpts.grep dev",
"test:prod": "babel-node scripts/test.js --mochaOpts.grep prod",
"test:docker": "babel-node scripts/test.js --mochaOpts.grep docker",
"test": "wdio wdio.conf.js",
"test:hot-reloading": "wdio wdio.conf.js --mochaOpts.grep \"hot reloading\"",
"coverage": "BABEL_ENV=coverage nyc --reporter=lcov --reporter=text npm test",
"test:dev": "wdio wdio.conf.js --mochaOpts.grep dev",
"test:prod": "wdio wdio.conf.js --mochaOpts.grep prod",
"test:docker": "wdio wdio.conf.js --mochaOpts.grep docker",
"build:docker": "babel-node scripts/build-docker.js",
"docker": "babel-node scripts/docker.js",
"flow": "flow",
"flow:0": "flow status; exit 0",
"flow:watch": "flow-watch --watch flowlib/ --watch scripts/ --watch src/ --watch test/ --watch webpack/ --watch .flowconfig",
"lint": "eslint *.js src scripts test util webpack",
"lint:0": "eslint *.js src scripts test util webpack; exit 0",
"lint:fix": "eslint --fix *.js src scripts test util webpack",
"check": "supervisor -q -n exit -w .flowconfig,.eslintrc,.babelrc,scripts,src,test,util,webpack -e flowconfig,eslintrc,babelrc,node,js -x babel-node scripts/check.js"
"lint:watch": "esw -w *.js src scripts test util webpack"
},
"dependencies": {
"babel-runtime": "^6.11.6",
"bcrypt": "^0.8.7",
"es6-promisify": "^5.0.0",
"debug": "^2.2.0",
"express": "^4.14.0",
"immutable": "^3.8.1",
"meteor-node-stubs": "~0.2.0",
Expand All @@ -48,11 +49,13 @@
"description": "Meteor(/React) app skeleton that runs your app code with pure Webpack/Babel instead of isobuild",
"devDependencies": {
"assets-webpack-plugin": "^3.4.0",
"async-child-process": "^1.0.0",
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-eslint": "^7.0.0",
"babel-loader": "^6.2.5",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-istanbul": "^2.0.3",
"babel-plugin-meteor-imports": "^1.0.3",
"babel-plugin-transform-runtime": "^6.12.0",
"babel-preset-es2015": "^6.14.0",
Expand All @@ -62,6 +65,8 @@
"babel-preset-stage-1": "^6.13.0",
"babel-register": "^6.14.0",
"chai": "^3.5.0",
"coveralls": "^2.11.14",
"crater-util": "^1.1.7",
"cross-spawn": "^4.0.0",
"css-loader": "^0.25.0",
"dotenv": "^2.0.0",
Expand All @@ -71,32 +76,36 @@
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-flowtype": "^2.17.1",
"eslint-plugin-react": "^6.2.1",
"eslint-watch": "^2.1.14",
"extract-text-webpack-plugin": "^2.0.0-beta.4",
"file-loader": "^0.9.0",
"flow-bin": "^0.33.0",
"flow-watch": "^1.0.0",
"glob": "^7.0.6",
"happypack": "^2.2.1",
"http-proxy": "^1.14.0",
"istanbul": "^0.4.5",
"json-loader": "^0.5.4",
"json-string-loader": "^1.0.0",
"meteor-imports-webpack-plugin": "^2.0.0-beta.2",
"mkdirp": "^0.5.1",
"mocha": "^3.0.2",
"node-inspector": "^0.12.8",
"nyc": "^8.3.2",
"phantomjs-prebuilt": "^2.1.12",
"postcss-loader": "^0.13.0",
"postcss-modules-values": "^1.2.2",
"pre-commit": "^1.1.3",
"progress-bar-webpack-plugin": "^1.9.0",
"raw-loader": "^0.5.1",
"react-hot-loader": "^3.0.0-beta.2",
"redux-logger": "^2.6.1",
"rimraf": "^2.5.4",
"smart-restart": "^1.0.0",
"smart-restart": "^1.1.1",
"style-loader": "^0.13.1",
"supervisor": "^0.11.0",
"terminate": "^1.0.8",
"url-loader": "^0.5.7",
"wdio-mocha-framework": "^0.4.0",
"wdio-phantomjs-service": "^0.2.2",
"wdio-spec-reporter": "0.0.3",
"webdriverio": "^4.2.11",
"webpack": "^2.1.0-beta.25",
Expand All @@ -118,5 +127,17 @@
"bugs": {
"url": "https://github.com/jedwards1211/crater/issues"
},
"homepage": "https://github.com/jedwards1211/crater#readme"
"homepage": "https://github.com/jedwards1211/crater#readme",
"nyc": {
"include": [
"src/**/*.js",
"scripts/**/*.js"
],
"sourceMap": false,
"instrument": false
},
"pre-commit": [
"lint",
"flow"
]
}
4 changes: 2 additions & 2 deletions scripts/build-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// @flow

import path from 'path'
import asyncScript from './util/asyncScript'
import isNewerThan from './util/isNewerThan'
import asyncScript from 'crater-util/lib/asyncScript'
import isNewerThan from 'crater-util/lib/isNewerThan'
import webpack from 'webpack'
import webpackConfig from '../webpack/webpack.config.prod'
import promisify from 'es6-promisify'
Expand Down
8 changes: 4 additions & 4 deletions scripts/build-docker.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env babel-node
// @flow

import asyncScript from './util/asyncScript'
import execAsync from './util/execAsync'
import spawnAsync from './util/spawnAsync'
import asyncScript from 'crater-util/lib/asyncScript'
import execAsync from 'crater-util/lib/execAsync'
import spawnAsync from 'crater-util/lib/spawnAsync'
import path from 'path'
import build from './build'
import buildDir from '../buildDir'
Expand All @@ -13,7 +13,7 @@ const root = path.resolve(__dirname, '..')
process.on('SIGINT', (): any => process.exit(1))

const opts = {
cwd: path.resolve(__dirname, '..'),
cwd: root,
stdio: 'inherit'
}

Expand Down
6 changes: 3 additions & 3 deletions scripts/build-meteor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import path from 'path'
import glob from 'glob'
import rimraf from 'rimraf'
import mkdirp from 'mkdirp'
import asyncScript from './util/asyncScript'
import isNewerThan from './util/isNewerThan'
import spawnAsync from './util/spawnAsync'
import asyncScript from 'crater-util/lib/asyncScript'
import isNewerThan from 'crater-util/lib/isNewerThan'
import spawnAsync from 'crater-util/lib/spawnAsync'
import promisify from 'es6-promisify'
import buildDir from '../buildDir'

Expand Down
6 changes: 3 additions & 3 deletions scripts/build-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import path from 'path'
import mkdirp from 'mkdirp'
import asyncScript from './util/asyncScript'
import isNewerThan from './util/isNewerThan'
import spawnAsync from './util/spawnAsync'
import asyncScript from 'crater-util/lib/asyncScript'
import isNewerThan from 'crater-util/lib/isNewerThan'
import spawnAsync from 'crater-util/lib/spawnAsync'
import webpack from 'webpack'
import webpackConfig from '../webpack/webpack.config.server'
import promisify from 'es6-promisify'
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env babel-node
// @flow

import asyncScript from './util/asyncScript'
import asyncScript from 'crater-util/lib/asyncScript'
import buildMeteor from './build-meteor'
import buildServer from './build-server'
import buildClient from './build-client'
Expand Down
15 changes: 0 additions & 15 deletions scripts/check.js

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/debug-brk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @flow

import start from './start'
import spawn from './util/spawn'
import spawn from 'crater-util/lib/spawn'
import path from 'path'

process.on('SIGINT', (): any => process.exit(1))
Expand Down
2 changes: 1 addition & 1 deletion scripts/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @flow

import start from './start'
import spawn from './util/spawn'
import spawn from 'crater-util/lib/spawn'
import path from 'path'

process.on('SIGINT', (): any => process.exit(1))
Expand Down
13 changes: 13 additions & 0 deletions scripts/devServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import express from 'express'
import webpackConfig from '../webpack/webpack.config.dev'
import createDebug from 'debug'

const shutdownDebug = createDebug('crater:shutdown')

if (process.env.USE_DOTENV) require('dotenv').config()
const {PORT} = process.env
Expand All @@ -25,3 +28,13 @@ const server = app.listen(webpackConfig.devServer.port)
server.on('upgrade', (req: Object, socket: any, head: any): any => proxy.ws(req, socket, head, { target }))

console.log(`Dev server is listening on http://0.0.0.0:${webpackConfig.devServer.port}`)

function shutdown() {
shutdownDebug('got signal, shutting down')
server.close()
process.exit(0)
}

process.on('SIGINT', shutdown)
process.on('SIGTERM', shutdown)

Loading

0 comments on commit 206f237

Please sign in to comment.