diff --git a/Makefile b/Makefile index 55aadcffe91e9..a8f6611433cc2 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ LOCALE ?= en_US -all: \ +GENERATED_FILES = \ d3.js \ d3.min.js \ - component.json \ - package.json + component.json + +all: $(GENERATED_FILES) .PHONY: clean all test @@ -22,7 +23,9 @@ src/time/format-localized.js: src/locale.js src/time/format-locale.js d3.js: $(shell node_modules/.bin/smash --list src/d3.js) @rm -f $@ - node_modules/.bin/smash src/d3.js | node_modules/.bin/uglifyjs - -b indent-level=2 -o $@ + node_modules/.bin/smash src/d3.js \ + | sed 's/[[:<:]]VERSION[[:>:]]/"$(shell ./version)"/' \ + | node_modules/.bin/uglifyjs - -b indent-level=2 -o $@ @chmod a-w $@ d3.min.js: d3.js @@ -34,10 +37,5 @@ component.json: src/component.js d3.js node src/component.js > $@ @chmod a-w $@ -package.json: src/package.js d3.js - @rm -f $@ - node src/package.js > $@ - @chmod a-w $@ - clean: - rm -f d3*.js package.json component.json + rm -f $(GENERATED_FILES) diff --git a/src/component.js b/src/component.js index 79b83c875e86c..0c252fb247c0d 100644 --- a/src/component.js +++ b/src/component.js @@ -1,8 +1,6 @@ -var d3 = require("../index"); - console.log(JSON.stringify({ "name": "d3", - "version": d3.version, + "version": require("../package.json").version, "main": "index-browserify.js", "scripts": ["index-browserify.js", "d3.js"] }, null, 2)); diff --git a/src/package.js b/src/package.js deleted file mode 100644 index e2c6b592341b3..0000000000000 --- a/src/package.js +++ /dev/null @@ -1,55 +0,0 @@ -var d3 = require("../index"); - -console.log(JSON.stringify({ - "name": "d3", - "version": d3.version, - "description": "A small, free JavaScript library for manipulating documents based on data.", - "keywords": [ - "dom", - "w3c", - "visualization", - "svg", - "animation", - "canvas" - ], - "homepage": "http://d3js.org", - "author": { - "name": "Mike Bostock", - "url": "http://bost.ocks.org/mike" - }, - "contributors": [ - { - "name": "Jason Davies", - "url": "http://jasondavies.com" - } - ], - "repository": { - "type": "git", - "url": "https://github.com/mbostock/d3.git" - }, - "main": "index.js", - "browserify": "index-browserify.js", - "jam": { - "main": "d3.js", - "shim": { - "exports": "d3" - } - }, - "dependencies": { - "jsdom": "~0.5.3" - }, - "devDependencies": { - "smash": "~0.0.8", - "uglify-js": "git://github.com/mishoo/UglifyJS2.git#3bd7ca9961125b39dcd54d2182cb72bd1ca6006e", - "vows": "0.7.x" - }, - "scripts": { - "test": "node_modules/.bin/vows" - }, - "licenses": [ - { - "type": "BSD", - "url": "https://github.com/mbostock/d3/blob/master/LICENSE" - } - ] -}, null, 2)); diff --git a/src/start.js b/src/start.js index 109f9c88379f0..1a2e175ced33d 100644 --- a/src/start.js +++ b/src/start.js @@ -1,2 +1,2 @@ d3 = (function(){ - var d3 = {version: "3.1.5"}; // semver + var d3 = {version: VERSION}; // semver diff --git a/test/load.js b/test/load.js index 2ca595244180a..aba1082ae0b40 100644 --- a/test/load.js +++ b/test/load.js @@ -1,14 +1,15 @@ process.env.TZ = "America/Los_Angeles"; var smash = require("smash"), - jsdom = require("jsdom"); + jsdom = require("jsdom"), + version = require("../package.json").version; require("./XMLHttpRequest"); module.exports = function() { var files = [].slice.call(arguments).map(function(d) { return "src/" + d; }), expression = "d3", - sandbox = null; + sandbox = {VERSION: version}; files.unshift("src/start"); files.push("src/end"); @@ -34,6 +35,7 @@ module.exports = function() { }; sandbox = { + VERSION: version, console: console, XMLHttpRequest: XMLHttpRequest, document: document, diff --git a/version b/version new file mode 100755 index 0000000000000..f9b72693eecca --- /dev/null +++ b/version @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +console.log(require("./package.json").version);