Skip to content

Commit

Permalink
serve through npm, dev and gh-pages; closes #106
Browse files Browse the repository at this point in the history
  • Loading branch information
radekstepan committed Jan 26, 2016
1 parent d4653f8 commit e9f6116
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 32 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ BROWSERIFY = ./node_modules/.bin/browserify
UGLIFY = ./node_modules/.bin/uglifyjs
CLEANCSS = ./node_modules/.bin/cleancss
MOCHA = ./node_modules/.bin/mocha
SERVER = ./node_modules/.bin/superstatic
BIN = ./bin/burnchart.js

MOCHA-OPTS = --compilers js:babel-register --ui exports --timeout 5000 --bail

serve:
${SERVER} --port 8080
start:
${BIN}

start-dev:
${BIN} --dev

watch-js: build-js
${WATCHIFY} -e -s burnchart ./src/js/index.jsx -t babelify -o public/js/bundle.js -d -v
Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
#[burnchart v3](http://radekstepan.com/burnchart)
#[burnchart](http://radekstepan.com/burnchart)

A [React](http://facebook.github.io/react/) app utilizing a [Flux](http://facebook.github.io/flux/) architecture.
##Quickstart

- EventEmitter listeners can use RegExp paths thus allowing the use of namespaces
- routing resets the whole UI between page changes and so Components are easier to reason about (`componentDidMount`)
```bash
$ npm install burnchart -g
$ burnchart --port 8080
# burnchart/3.0.0 started on port 8080
```

##Quickstart
##Development

To run your local version of the app, install all the NPM dependencies, watch the source files in one window, and start the static file server in the other in `--dev` mode.

```bash
$ nvm use
$ npm install
$ make watch
$ npm start
# Server started on port 8080
$ make start --dev
# burnchart/3.0.0 (dev) started on port 8080
```

##Changelog
###GitHub Pages

To serve the app from GitHub Pages that are in sync with master branch, add these two lines to `.git/config`, in the `[remote "origin"]` section:

###v3.0.0
- switch to React & Flux architecture
```
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:user/repo.git
push = +refs/heads/master:refs/heads/gh-pages
push = +refs/heads/master:refs/heads/master
```
64 changes: 64 additions & 0 deletions bin/burnchart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env node
var Args = require('argparse').ArgumentParser,
clrs = require('colors/safe'),
stat = require('node-static'),
path = require('path'),
http = require('http'),
exec = require('child_process').exec,
pakg = require('../package.json'),
fs = require('fs');

var parser = new Args({
version: pakg.version
});

parser.addArgument(
[ '-p', '--port' ],
{
'help': 'Specify port number to start app on',
'defaultValue': 8080,
'type': 'int'
}
);
parser.addArgument(
[ '-d', '--dev' ],
{
'help': 'Development mode, unminified builds are served',
'nargs': 0
}
);

var args = parser.parseArgs();

var opts = {
'serverInfo': 'burnchart/' + pakg.version
};

var dir = path.resolve(__dirname, '../');

var pub = new stat.Server(dir, opts);

// Be ready to serve unminified builds.
var index = fs.readFileSync(dir + '/index.html', 'utf8');
index = index.replace(/bundle\.min/gm, 'bundle');

var server = http.createServer(function(req, res) {
req.addListener('end', function() {
// Serve a custom index file in dev mode.
if (args.dev && req.url == '/') {
res.writeHead(200, {
'Content-Length': index.length,
'Content-Type': 'text/html'
});
res.end(index);
} else {
pub.serve(req, res);
}
}).resume();
}).listen(args.port);

server.on('listening', function() {
var addr = server.address();
var dev = args.dev ? ' (' + clrs.bold('dev') + ')' : '';
console.log('burnchart/' + pakg.version + dev + ' started on port ' + addr.port);
});
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="public/css/bundle.min.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="app" />
<script type="text/javascript" src="public/js/bundle.min.js"></script>
</body>
</html>
45 changes: 26 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
{
"name": "burnchart",
"version": "3.0.0-alpha",
"bin": {
"burnchart": "./bin/burnchart.js"
},
"scripts": {
"start": "make start",
"test": "make test"
},
"dependencies": {
"argparse": "^1.0.4",
"colors": "^1.1.2",
"node-static": "^0.7.7"
},
"devDependencies": {
"async": "^1.5.2",
"babel": "^6.3.26",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-register": "^6.4.3",
"babelify": "^7.2.0",
"browserify": "^13.0.0",
"chai": "^3.4.1",
"classnames": "^2.2.3",
"clean-css": "^3.4.9",
"coffeeify": "^2.0.1",
"d3": "^3.5.12",
"d3-tip": "^0.6.7",
"deep-diff": "^0.3.3",
"firebase": "^2.3.2",
"less": "^2.5.3",
"lesshat": "^3.0.2",
"lodash": "^3.10.1",
"lscache": "^1.0.5",
"marked": "^0.3.5",
"mocha": "^2.3.4",
"moment": "^2.11.1",
"normalize.less": "^1.0.0",
"object-assign": "^4.0.1",
"object-path": "^0.9.2",
"proxyquire": "^1.7.3",
"react": "^0.14.6",
"react-addons-css-transition-group": "^0.14.6",
"react-mini-router": "^2.0.0",
"semver": "^5.1.0",
"sortedindex-compare": "0.0.1",
"superagent": "^1.6.1"
},
"devDependencies": {
"babel": "^6.3.26",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-register": "^6.4.3",
"babelify": "^7.2.0",
"browserify": "^13.0.0",
"chai": "^3.4.1",
"clean-css": "^3.4.9",
"coffeeify": "^2.0.1",
"less": "^2.5.3",
"mocha": "^2.3.4",
"proxyquire": "^1.7.3",
"superstatic": "^4.0.1",
"superagent": "^1.6.1",
"uglify-js": "^2.6.1",
"watch": "^0.17.1",
"watch-less": "0.0.4",
Expand All @@ -45,7 +54,5 @@
"repository": {
"type": "git",
"url": "git://github.com/radekstepan/burnchart.git"
},
"private": true,
"license": "LicenseRef-LICENSE"
}
}

0 comments on commit e9f6116

Please sign in to comment.