diff --git a/Makefile b/Makefile index bbeeb47..12ad0f2 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index c2fb903..a6e0272 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,33 @@ -#[burnchart v3](http://radekstepan.com/burnchart) - -A [React](http://facebook.github.io/react/) app utilizing a [Flux](http://facebook.github.io/flux/) architecture. - -- 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`) +#[burnchart](http://radekstepan.com/burnchart) ##Quickstart +```bash +$ npm install burnchart -g +$ burnchart --port 8080 +# burnchart/3.0.0 started on port 8080 +``` + +##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 -###v3.0.0 -- switch to React & Flux architecture \ No newline at end of file +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: + +``` +[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 +``` \ No newline at end of file diff --git a/bin/burnchart.js b/bin/burnchart.js new file mode 100755 index 0000000..4d8c77c --- /dev/null +++ b/bin/burnchart.js @@ -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); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..d4f16af --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + + +
+ + + diff --git a/package.json b/package.json index 1efc495..0f9aa0d 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,20 @@ { "name": "burnchart", "version": "3.0.0-alpha", + "bin": { + "burnchart": "./bin/burnchart.js" + }, + "scripts": { + "start": "make start", + "test": "make test" + }, "dependencies": { - "async": "^1.5.2", - "classnames": "^2.2.3", - "d3": "^3.5.12", - "d3-tip": "^0.6.7", - "deep-diff": "^0.3.3", - "firebase": "^2.3.2", - "lesshat": "^3.0.2", - "lodash": "^3.10.1", - "lscache": "^1.0.5", - "marked": "^0.3.5", - "moment": "^2.11.1", - "normalize.less": "^1.0.0", - "object-assign": "^4.0.1", - "object-path": "^0.9.2", - "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" + "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", @@ -31,12 +22,30 @@ "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", - "superstatic": "^4.0.1", + "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", "uglify-js": "^2.6.1", "watch": "^0.17.1", "watch-less": "0.0.4", @@ -45,7 +54,5 @@ "repository": { "type": "git", "url": "git://github.com/radekstepan/burnchart.git" - }, - "private": true, - "license": "LicenseRef-LICENSE" + } }