Permalink
Browse files

Automate setting version number on js and docs

Use:
* make build
* make docs OR make test-docs

closes gh-8
  • Loading branch information...
1 parent 6dda4e8 commit aba806622f8588aa9f469ece5e778aeedf636f33 @paularmstrong paularmstrong committed Dec 13, 2012
Showing with 29 additions and 17 deletions.
  1. +10 −3 Makefile
  2. +3 −0 docs.json
  3. +1 −0 docs/index.html
  4. +1 −1 docs/layouts/master.html
  5. +2 −2 docs/less/header.less
  6. +4 −0 docs/less/master.less
  7. +3 −6 package.json
  8. +5 −5 scripts/wrap-start.js
View
13 Makefile
@@ -1,7 +1,8 @@
SHA := $(shell git rev-parse HEAD)
THIS_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+VERSION := $(shell npm ls | grep "xcharts@" | grep -Eo "[0-9]*\.[0-9]*\.[0-9]*")
NODE_PATH = node_modules/.bin
-JS_COMPILER = $(NODE_PATH)/uglifyjs
+JS_COMPILER = $(NODE_PATH)/uglifyjs --comments="license"
JS_BEAUTIFIER = $(NODE_PATH)/uglifyjs -b -i 2 -nm -ns
CSS_COMPILER = $(NODE_PATH)/lessc --strict-imports
CSS_MINIFIER = $(CSS_COMPILER) --yui-compress
@@ -17,6 +18,7 @@ all:
pre-build:
@mkdir -p build
+ @sed -i.bak 's/v[0-9]*\.[0-9]*\.[0-9]*/v${VERSION}/' scripts/wrap-start.js
build: pre-build \
build/xcharts.js \
@@ -26,6 +28,7 @@ build: pre-build \
build/LICENSE \
build/README.md
@tar -czf xcharts-build.tar.gz build/
+ @find ./ -name "*.bak" -delete
.INTERMEDIATE build/xcharts.js: \
scripts/wrap-start.js \
@@ -86,7 +89,11 @@ reporter='dot'
test: build
@node_modules/.bin/mocha-phantomjs test/test.html --reporter ${reporter}
-docs: clean build
+pre-docs: clean build
+ @sed -i.bak 's/v[0-9]*\.[0-9]*\.[0-9]*/v${VERSION}/' docs.json
+ @rm docs.json.bak
+
+docs: pre-docs
@node_modules/.bin/lessc --yui-compress --include-path=docs/less docs/less/master.less docs/css/master.css
@node_modules/.bin/still docs -o ${TMP} -i "layouts" -i "json" -i "less" -i "macro"
@cp node_modules/d3/d3.v2.min.js ${TMP}/js/d3.v2.min.js
@@ -102,7 +109,7 @@ docs: clean build
@git checkout ${THIS_BRANCH}
port = 3000
-test-docs:
+test-docs: pre-docs
@node_modules/.bin/still-server docs/ -p ${port} -o
.PHONY: lint test clean docs test-docs
View
3 docs.json
@@ -0,0 +1,3 @@
+{
+ "version": "v0.1.1"
+}
View
1 docs/index.html
@@ -22,6 +22,7 @@
<li class="span4 download"><a target="_blank" href="{{ baseurl }}/xcharts-build.tar.gz" class="btn cta">Download xCharts.js</a></li>
<li class="span4"><a href="{{ baseurl }}/docs/">Documentation</a></li>
</ul>
+<p class="opts">Current Version: {{ version }}</p>
<script>
(function () {
View
2 docs/layouts/master.html
@@ -37,7 +37,7 @@ <h2 class="tenxerLogo"><a href="https://www.tenxer.com"><img src="{{ baseurl }}/
<h3>a D3-based library for building custom charts and graphs</h3>
</hgroup>
- <nav>
+ <nav data-version="{{ version }}">
<ul>
<li{% if current_page == 'index' %} class="current"{% endif %}>
<a href="{{ baseurl }}/">download</a>
View
4 docs/less/header.less
@@ -94,11 +94,11 @@
.box-shadow(inset 0 1px 4px fade(#000, 20%));
}
&:after {
- content: 'tenXer • xCharts';
+ content: "xCharts " attr(data-version);
position: absolute;
right: @quarterGutter;
bottom: 0;
- color: @colorLightweight;
+ color: @colorWelterweight;
}
}
}
View
4 docs/less/master.less
@@ -18,12 +18,16 @@
}
.opts {
+ text-align: center;
list-style: none;
margin: 0;
line-height: @gutter * 1.25;
:first-child {
text-align: right;
}
+ :last-child {
+ text-align: left;
+ }
.btn {
width: 100%;
text-align: center;
View
9 package.json
@@ -5,7 +5,8 @@
"main": "build/xcharts.js",
"homepage": "http://tenxer.github.com/xcharts/",
"scripts": {
- "test": "make lint && make test"
+ "test": "make lint && make test",
+ "prepublish": "make && make clean && make build"
},
"repository": {
"type": "git",
@@ -30,17 +31,13 @@
"devDependencies": {
"underscore": "~1.4.3",
"less": "~1.3.1",
- "uglify-js": "~2.2.1",
+ "uglify-js": "~2.2.2",
"nodelint": "~0.6",
"mocha": "~1.6",
"expect.js": "~0.1",
"d3": "~2.10.1",
"still": "*",
"swig": "*",
"mocha-phantomjs": "~1.0"
- },
- "scripts": {
- "test": "make lint && make test",
- "prepublish": "make && make clean && make build"
}
}
View
10 scripts/wrap-start.js
@@ -1,8 +1,8 @@
-/**
- * xCharts 0.1.4 Copyright (c) 2012, tenXer, Inc. All Rights Reserved.
- * Available via the MIT license.
- * see: http://github.com/tenxer/xCharts for details
- */
+/*!
+xCharts v0.1.1 Copyright (c) 2012, tenXer, Inc. All Rights Reserved.
+@license MIT license. http://github.com/tenXer/xcharts for details
+*/
+
(function () {
var xChart,

0 comments on commit aba8066

Please sign in to comment.