Add script to set version number

This commit is contained in:
Brandon Tilley 2013-12-28 13:09:12 -08:00
parent 50b283aa5e
commit 5a140ab914
2 changed files with 48 additions and 3 deletions

View File

@ -4,7 +4,9 @@
"main": "dist/planetaryjs.min.js", "main": "dist/planetaryjs.min.js",
"description": "Awesome interactive globes for the web", "description": "Awesome interactive globes for the web",
"homepage": "http://planetaryjs.com", "homepage": "http://planetaryjs.com",
"authors": [ "Brandon Tilley <brandon@brandontilley.com>" ], "authors": [
"Brandon Tilley <brandon@brandontilley.com>"
],
"license": "MIT", "license": "MIT",
"ignore": [ "ignore": [
".git", ".git",
@ -21,8 +23,10 @@
"topojson": "1.x" "topojson": "1.x"
}, },
"keywords": [ "keywords": [
"globe", "globes", "globe",
"planet", "planets", "globes",
"planet",
"planets",
"d3", "d3",
"topojson" "topojson"
] ]

41
script/set-version Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env node
var fs = require('fs');
var spawn = require('child_process').spawn;
var type = process.argv[2];
var version = process.argv[3];
var name = process.argv[4]
if ("stable" !== type && "unstable" !== type) {
console.log("You must specify 'stable' or 'unstable' version type.");
process.exit(1);
}
if (!version) {
console.log("You must specify a version.");
process.exit(1);
}
if (version[0] === 'v') {
version = version.replace(/^v/, '');
}
var package = require("../package.json");
var bower = require("../bower.json");
var site = require("../site/public/download/_data.json");
package.version = version;
bower.version = version;
site[type].latest = site[type].latest || {};
site[type].latest.version = "v" + version;
if (name) site[type].latest.name = name;
fs.writeFileSync('package.json', JSON.stringify(package, null, ' ') + "\n");
fs.writeFileSync('bower.json', JSON.stringify(bower, null, ' ') + "\n");
fs.writeFileSync('site/public/download/_data.json', JSON.stringify(site, null, ' ') + "\n");
spawn('npm', ['run', 'build']);
console.log("Tasks:\n\n - Update CHANGELOG.md\n - Regenerate site");