Add a central version.json file. Change package building to insert version, revision, and timestamp. Auto-push tags.

This commit is contained in:
Tom Robinson
2010-03-08 15:10:08 -08:00
parent 6dbb4eedb7
commit c53bff288a
10 changed files with 122 additions and 23 deletions
+5 -1
View File
@@ -8,7 +8,7 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
if (!FILE.isFile(aFilename)) if (!FILE.isFile(aFilename))
return; return;
var buildFilename = FILE.join($BUILD_CONFIGURATION_DIR, "CommonJS", "cappuccino", aFilename); var buildFilename = FILE.join($BUILD_CJS_CAPPUCCINO, aFilename);
filedir (buildFilename, [aFilename], function () filedir (buildFilename, [aFilename], function ()
{ {
@@ -27,3 +27,7 @@ new FileList("**/*").exclude("Jakefile").forEach(function(aFilename)
task ("build", buildFilename); task ("build", buildFilename);
CLOBBER.include(buildFilename); CLOBBER.include(buildFilename);
}); });
task ("build", function() {
setPackageMetadata(FILE.join($BUILD_CJS_CAPPUCCINO, "package.json"));
});
+23
View File
@@ -0,0 +1,23 @@
var FILE = require("file");
var sprintf = require("printf").sprintf;
var pkg = null;
function getPackage() {
if (!pkg)
pkg = JSON.parse(FILE.path(module.path).dirname().dirname().join("package.json").read({ charset : "UTF-8" }));
return pkg;
}
exports.version = function() { return getPackage()["version"]; }
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
exports.fullVersionString = function() {
return sprintf("cappuccino %s (%04d-%02d-%02d %s)",
exports.version(),
exports.timestamp().getUTCFullYear(),
exports.timestamp().getUTCMonth()+1,
exports.timestamp().getUTCDate(),
exports.revision().slice(0,6)
);
}
-1
View File
@@ -4,7 +4,6 @@
"description": "Cappuccino module", "description": "Cappuccino module",
"keywords": ["objective-j", "objj", "objective j", "capp", "cappuccino"], "keywords": ["objective-j", "objj", "objective j", "capp", "cappuccino"],
"author": "280 North, Inc. (http://280north.com/)", "author": "280 North, Inc. (http://280north.com/)",
"version": "0.8.0",
"objj-frameworks": ["Frameworks"], "objj-frameworks": ["Frameworks"],
"objj-debug-frameworks": ["Frameworks/Debug"], "objj-debug-frameworks": ["Frameworks/Debug"],
"contributors": [ "contributors": [
+30 -18
View File
@@ -280,21 +280,23 @@ task("push-objective-j", function() {
function pushPackage(path, remote, branch) function pushPackage(path, remote, branch)
{ {
branch = branch || "master"; branch = branch || "master";
var pushPackagesPath = FILE.path(".push-package")
pushPackagesPath.mkdirs();
var packagePath = pushPackagesPath.join(remote.replace(/[^\w]/g, "_"));
stream.print("Pushing \0blue(" + path + "\0) to "+branch+" of \0blue(" + remote + "\0)"); stream.print("Pushing \0blue(" + path + "\0) to "+branch+" of \0blue(" + remote + "\0)");
FILE.mkdirs(".push-package"); if (packagePath.isDirectory())
OS.system(buildCmd([["cd", packagePath], ["git", "fetch"]]));
var pushPackageDir = FILE.join(".push-package", remote.replace(/[^\w]/g, "_"));
if (FILE.exists(pushPackageDir))
OS.system(buildCmd([["cd", pushPackageDir], ["git", "fetch"]]));
else else
OS.system(["git", "clone", remote, pushPackageDir]); OS.system(["git", "clone", remote, packagePath]);
if (OS.system(buildCmd([["cd", pushPackageDir], ["git", "checkout", "origin/"+branch]]))) { if (OS.system(buildCmd([["cd", packagePath], ["git", "checkout", "origin/"+branch]]))) {
if (OS.system(buildCmd([ if (OS.system(buildCmd([
["cd", pushPackageDir], ["cd", packagePath],
["git", "symbolic-ref", "HEAD", "refs/heads/"+branch], ["git", "symbolic-ref", "HEAD", "refs/heads/"+branch],
["rm", ".git/index"], ["rm", ".git/index"],
["git", "clean", "-fdx"] ["git", "clean", "-fdx"]
@@ -302,20 +304,30 @@ function pushPackage(path, remote, branch)
throw "pushPackage failed"; throw "pushPackage failed";
} }
if (OS.system("cd "+OS.enquote(pushPackageDir)+" && git rm --ignore-unmatch -r * && rm -rf *")) if (OS.system("cd "+OS.enquote(packagePath)+" && git rm --ignore-unmatch -r * && rm -rf *"))
throw "pushPackage failed"; throw "pushPackage failed";
if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(pushPackageDir)+"/.")) if (OS.system("cp -R "+OS.enquote(path)+"/* "+OS.enquote(packagePath)+"/."))
throw "pushPackage failed"; throw "pushPackage failed";
OS.system(buildCmd([ var pkg = JSON.parse(packagePath.join("package.json").read({ charset : "UTF-8" }));
["cd", pushPackageDir],
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
var cmd = [
["cd", packagePath],
["git", "add", "."], ["git", "add", "."],
["git", "commit", "-m", "Pushed on " + new Date()] ["git", "commit", "-m", "version="+pkg.version+"; revision="+pkg["cappuccino-revision"]+"; timestamp="+pkg["cappuccino-timestamp"]+";"]
])); ];
if (pkg["cappuccino-revision"])
cmd.push(["git", "tag", "rev-"+pkg["cappuccino-revision"].slice(0,6)]);
OS.system(buildCmd(cmd));
if (OS.system(buildCmd([ if (OS.system(buildCmd([
["cd", pushPackageDir], ["cd", packagePath],
["git", "push", "origin", "HEAD:"+branch] ["git", "push", "--tags", "origin", "HEAD:"+branch]
]))) ])))
throw "pushPackage failed"; throw "pushPackage failed";
} }
+30 -1
View File
@@ -1,5 +1,7 @@
var FILE = require("file"); var FILE = require("file");
var sprintf = require("printf").sprintf;
var window = exports.window = require("browser/window"); var window = exports.window = require("browser/window");
if (system.engine === "rhino") if (system.engine === "rhino")
@@ -7,7 +9,7 @@ if (system.engine === "rhino")
window.__parent__ = null; window.__parent__ = null;
window.__proto__ = global; window.__proto__ = global;
} }
// setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc // setup OBJJ_HOME, OBJJ_INCLUDE_PATHS, etc
window.OBJJ_HOME = exports.OBJJ_HOME = FILE.resolve(module.path, ".."); window.OBJJ_HOME = exports.OBJJ_HOME = FILE.resolve(module.path, "..");
@@ -77,6 +79,12 @@ exports.run = function(args)
// copy the args since we're going to modify them // copy the args since we're going to modify them
var argv = args.slice(1); var argv = args.slice(1);
if (argv[0] === "--version")
{
print(exports.fullVersionString());
return;
}
while (argv.length && argv[0].indexOf('-I') === 0) while (argv.length && argv[0].indexOf('-I') === 0)
OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().substr(2).split(':')); OBJJ_INCLUDE_PATHS.unshift.apply(OBJJ_INCLUDE_PATHS, argv.shift().substr(2).split(':'));
} }
@@ -178,5 +186,26 @@ exports.make_narwhal_factory = function(path)
} // end "with" } // end "with"
var pkg = null;
function getPackage() {
if (!pkg)
pkg = JSON.parse(FILE.path(module.path).dirname().dirname().join("package.json").read({ charset : "UTF-8" }));
return pkg;
}
exports.version = function() { return getPackage()["version"]; }
exports.revision = function() { return getPackage()["cappuccino-revision"]; }
exports.timestamp = function() { return new Date(getPackage()["cappuccino-timestamp"]); }
exports.fullVersionString = function() {
return sprintf("objective-j %s (%04d-%02d-%02d %s)",
exports.version(),
exports.timestamp().getUTCFullYear(),
exports.timestamp().getUTCMonth()+1,
exports.timestamp().getUTCDate(),
exports.revision().slice(0,6)
);
}
if (require.main == module.id) if (require.main == module.id)
exports.run(system.args); exports.run(system.args);
-1
View File
@@ -5,7 +5,6 @@
"description": "Objective-J and Cappuccino module", "description": "Objective-J and Cappuccino module",
"keywords": ["objective-j", "objj", "objective j", "cappuccino"], "keywords": ["objective-j", "objj", "objective j", "cappuccino"],
"author": "280 North, Inc. (http://280north.com/)", "author": "280 North, Inc. (http://280north.com/)",
"version": "0.8.0",
"contributors": [ "contributors": [
"Francisco Tolmasky (http://tolmasky.com/)", "Francisco Tolmasky (http://tolmasky.com/)",
"Ross Boucher (http://rossboucher.com/)", "Ross Boucher (http://rossboucher.com/)",
+4
View File
@@ -87,6 +87,10 @@ new FileList("CommonJS/**/*").forEach(function(aFilename)
CLOBBER.include(buildFilename); CLOBBER.include(buildFilename);
}); });
task ("build", function() {
setPackageMetadata(FILE.join($BUILD_CJS_OBJECTIVE_J, "package.json"));
});
$BUILD_CJS_OBJECTIVE_J_FRAMEWORK = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J"); $BUILD_CJS_OBJECTIVE_J_FRAMEWORK = FILE.join($BUILD_CJS_OBJECTIVE_J, "Frameworks", "Objective-J");
filedir($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function() filedir($BUILD_CJS_OBJECTIVE_J_FRAMEWORK, function()
+1 -1
View File
@@ -22,7 +22,7 @@ function main(args)
switch (argument) switch (argument)
{ {
case "version": case "version":
case "--version": return print("capp version 0.8.0"); case "--version": return print(require("cappuccino").fullVersionString());
case "-h": case "-h":
case "--help": return printUsage(); case "--help": return printUsage();
+26
View File
@@ -2,6 +2,7 @@ var SYSTEM = require("system");
var FILE = require("file"); var FILE = require("file");
var OS = require("os"); var OS = require("os");
var UTIL = require("util"); var UTIL = require("util");
var stream = require("term").stream;
var requiresSudo = false; var requiresSudo = false;
@@ -288,6 +289,31 @@ global.symlink_executable = function(source)
FILE.symlink(relative, destination); FILE.symlink(relative, destination);
} }
function getCappuccinoVersion() {
var versionFile = FILE.path(module.path).dirname().join("version.json");
return JSON.parse(versionFile.read({ charset : "UTF-8" })).version;
}
global.setPackageMetadata = function(packagePath) {
var pkg = JSON.parse(FILE.read(packagePath, { charset : "UTF-8" }));
var p = OS.popen(["git", "rev-parse", "--verify", "HEAD"]);
if (p.wait() === 0) {
var sha = p.stdout.read().split("\n")[0];
if (sha.length === 40)
pkg["cappuccino-revision"] = sha;
}
pkg["cappuccino-timestamp"] = new Date().getTime();
pkg["version"] = getCappuccinoVersion();
stream.print(" Version: \0purple(" + pkg["version"] + "\0)");
stream.print(" Revision: \0purple(" + pkg["cappuccino-revision"] + "\0)");
stream.print(" Timestamp: \0purple(" + pkg["cappuccino-timestamp"] + "\0)");
FILE.write(packagePath, JSON.stringify(pkg, null, 4), { charset : "UTF-8" });
}
global.subtasks = function(subprojects, taskNames) global.subtasks = function(subprojects, taskNames)
{ {
taskNames.forEach(function(aTaskName) taskNames.forEach(function(aTaskName)
+3
View File
@@ -0,0 +1,3 @@
{
"version": "0.8.0"
}