function initFiles() { var file; // initial setup of .git repositories for test packages file = filesPath.join("test-package-1"); OS.command("cd " + file.valueOf() + "; git init; git add . ; git commit -m 'base' ; git tag v0.1.0"); file = filesPath.join("test-package-2"); OS.command("cd " + file.valueOf() + "; git init; git add . ; git commit -m 'base' ; git tag v0.1.0"); }
ProgramBuilder.prototype.buildPackage = function(sourcePackage, options) { var buildBasePath = this.targetPackage.getBuildPath().join("raw"), buildPackage = PACKAGE.Package(buildBasePath, this.targetPackage.getLocator()); var builder = PACKAGE_BUILDER.PackageBuilder(); builder.setTarget("raw"); builder.setSourcePackage(sourcePackage); builder.setTargetPackage(buildPackage); try { builder.triggerBuild(options); } catch(e) { // sanity check before nuking build directory if(buildBasePath.exists() && buildBasePath.join("package.json").exists()) { print("NUKING: " + buildBasePath); OS.command("rm -Rf " + buildBasePath); } throw e; } }
ProgramBuilder.prototype.build = function(buildOptions) { var rawBuildPath = this.rawPackage.getPath(), targetBasePath = this.targetPackage.getPath(), sourcePath, targetPath, command; targetPath = targetBasePath.join("lib"); targetPath.mkdirs(); [ "packages/lib-php/lib", "packages/wildfire/lib" ].forEach(function(path) { sourcePath = rawBuildPath.join(path); command = "rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" " + sourcePath + "/* " + targetPath; print(command); OS.command(command); }); targetPath = targetBasePath.join("examples"); targetPath.mkdirs(); sourcePath = this.sourcePackage.getPath().join("examples"); command = "rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" --exclude \"- .tmp_*/\" " + sourcePath + "/* " + targetPath; print(command); OS.command(command); rawBuildPath.join("package.json").copy(targetBasePath.join("package.json")); }
Program.prototype.clean = function() { var buildPath = this.getBuildPath(); if(buildPath.exists()) { // basic sanity check before we delete the previous build if(buildPath.join("raw", "package.json").exists()) { OS.command("rm -Rf " + buildPath.valueOf()); } } }
function compress(/*String*/ aCode, /*String*/ FIXME) { // FIXME: figure out why this doesn't work on Windows/Cygwin //var tmpFile = java.io.File.createTempFile("OBJJC", ""); var tmpFile = new java.io.File(FIXME + ".tmp"); tmpFile.deleteOnExit(); tmpFile = tmpFile.getAbsolutePath(); FILE.write(tmpFile, aCode, { charset:"UTF-8" }); return OS.command(["java", "-Dfile.encoding=UTF-8", "-classpath", [RHINO_PATH, SHRINKSAFE_PATH].join(":"), "org.dojotoolkit.shrinksafe.Main", tmpFile]); }
revisions.forEach(function(revision) { if(revision!="*") { if(!workspace.isBranched() || workspace.getBranchName()==revision) { var key = [url, name, revision, "@"]; if(sources.spec.has(key)) { // mapping already found // ensure existing path exists, if not update with new path if(!FILE.Path(sources.spec.get(key).path).exists()) { sources.spec.set(key, { "path": pkg.getPath().valueOf() }) } } else { // mapping not found - create it sources.spec.set(key, { "path": pkg.getPath().valueOf() }) } // now that the mappings are updated we need to // check the packages to ensure there are no hard directories // where there should be links var path = packagePath.join(revision); if(path.exists()) { if(path.isLink()) { path.remove(); } else { OS.command("rm -Rf " + path); } } path.dirname().mkdirs(); pkg.getPath().symlink(path); } } });
Platform.prototype.destroy = function() { // NOTE: This removes all local traces of the platform. OS.command("rm -Rf " + this.getPath()); }
exports.testBasicRegistration = function() { var file, rev; tusk.command("pinf --db " + tmpDBPath + " register-namespace http://127.0.0.1:8080/test@pinf.org/public/"); tusk.command("pinf --db " + tmpDBPath + " register-package test@pinf.org/public " + filesPath.join("test-package-1").valueOf()); ASSERT.deepEqual( JSON.decode(filesPath.join("test-package-1", "package.json").read()), { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-1/", "name": "test-package-1" } ); file = filesPath.join("test-package-1"); OS.command("cd " + file.valueOf() + "; git add . ; git commit -m 'registered' ; git tag v0.2.0"); tusk.command("pinf --db " + tmpDBPath + " announce-release " + file.valueOf()); file = filesPath.join("test-package-2"); OS.command("cd " + file.valueOf() + "; git branch test; git checkout test"); tusk.command("pinf --db " + tmpDBPath + " register-package test@pinf.org/public " + filesPath.join("test-package-2").valueOf()); file = filesPath.join("test-package-2"); OS.command("cd " + file.valueOf() + "; git add . ; git commit -m 'registered'"); tusk.command("pinf --db " + tmpDBPath + " announce-release --branch test " + file.valueOf()); rev = GIT.Git(file).getLatestRevisionForBranch("test"); ASSERT.deepEqual( JSON.decode(HTTP.read("http://127.0.0.1:8080/test@pinf.org/public/catalog.json").decodeToString()), { "uid": "http://127.0.0.1:8080/test@pinf.org/public/catalog.json", "packages": { "test-package-1": { "0": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-1/", "name": "test-package-1", "version": "0.2.0" } }, "test-package-2": { "test": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-2/", "name": "test-package-2", "version": "0.0.0rev-" + rev } } } } ); ASSERT.deepEqual( JSON.decode(HTTP.read("http://127.0.0.1:8080/test@pinf.org/public/test-package-1/").decodeToString()), { "name": "test-package-1", "versions": { "0": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-1/", "name": "test-package-1", "version": "0.2.0" } } } ); ASSERT.deepEqual( JSON.decode(HTTP.read("http://127.0.0.1:8080/test@pinf.org/public/test-package-2/").decodeToString()), { "name": "test-package-2", "branches": { "test": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-2/", "name": "test-package-2", "version": "0.0.0rev-" + rev } } } ); file = filesPath.join("test-package-5"); tusk.command("pinf --db " + tmpDBPath + " register-package test@pinf.org/public " + file.valueOf()); tusk.command("pinf --db " + tmpDBPath + " announce-release --branch master " + file.valueOf()); rev = GIT.Git(file).getLatestRevisionForBranch("master"); ASSERT.deepEqual( JSON.decode(HTTP.read("http://127.0.0.1:8080/test@pinf.org/public/test-package-5/").decodeToString()), { "name": "test-package-5", "branches": { "master": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-5/", "name": "test-package-5", "repositories": [ { "type": "git", "url": "git://github.com/cadorn/pinf.git", "path": "packages/cli/tests/registry-server/_files/test-package-5", "raw": "http://github.com/cadorn/pinf/raw/{rev}/packages/cli/tests/registry-server/_files/test-package-5/{path}", "download": { "type": "zip", "url": "http://github.com/cadorn/pinf/zipball/{rev}/" } } ], "version": "0.0.0rev-" + rev } } } ); tusk.command("pinf --db " + tmpDBPath + " register-namespace http://127.0.0.1:8080/test@pinf.org/public/subset/"); tusk.command("pinf --db " + tmpDBPath + " register-package --name renamed-test-package-5 test@pinf.org/public/subset http://127.0.0.1:8080/test@pinf.org/public/test-package-5/"); ASSERT.deepEqual( JSON.decode(HTTP.read("http://127.0.0.1:8080/test@pinf.org/public/subset/catalog.json").decodeToString()), { "uid": "http://127.0.0.1:8080/test@pinf.org/public/subset/catalog.json", "packages": { "renamed-test-package-5": { "*": { "name": "test-package-5", "repositories": [ { "type": "git", "url": "git://github.com/cadorn/pinf.git", "path": "packages/cli/tests/registry-server/_files/test-package-5", "raw": "http://github.com/cadorn/pinf/raw/{rev}/packages/cli/tests/registry-server/_files/test-package-5/{path}", "download": { "type": "zip", "url": "http://github.com/cadorn/pinf/zipball/{rev}/" } } ] }, "master": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-5/", "name": "test-package-5", "repositories": [ { "type": "git", "url": "git://github.com/cadorn/pinf.git", "path": "packages/cli/tests/registry-server/_files/test-package-5", "raw": "http://github.com/cadorn/pinf/raw/{rev}/packages/cli/tests/registry-server/_files/test-package-5/{path}", "download": { "type": "zip", "url": "http://github.com/cadorn/pinf/zipball/{rev}/" } } ], "version": "0.0.0rev-" + rev } } } } ); file = filesPath.join("test-package-1"); OS.command("cd " + file.valueOf() + "; git tag v0.2.1rc1"); tusk.command("pinf --db " + tmpDBPath + " announce-release " + file.valueOf()); ASSERT.deepEqual( JSON.decode(HTTP.read("http://127.0.0.1:8080/test@pinf.org/public/test-package-1/").decodeToString()), { "name": "test-package-1", "versions": { "0": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-1/", "name": "test-package-1", "version": "0.2.0" }, "0.2.1rc": { "uid": "http://127.0.0.1:8080/test@pinf.org/public/test-package-1/", "name": "test-package-1", "version": "0.2.1rc1" } } } ); resetFiles({"skipUIDRemoval": true}); }
].forEach(function(name) { file = filesPath.join(name, ".git"); OS.command("rm -Rf " + file.valueOf()); });
var FILE = require("file"); var HTTP = require("http"); var GIT = require("git", "github.com/cadorn/util/raw/master/lib-js"); var filesPath = FILE.Path(module.path).dirname().join("_files"); // setup var tusk = TUSK.Tusk().activate(), seaPath = tusk.getSea().getPath(); var tmpDBPath = seaPath.join("build", "cli", "test", "db"); if(tmpDBPath.exists()) { OS.command("rm -Rf " + tmpDBPath); } tmpDBPath.mkdirs(); resetFiles(); initFiles(); exports.testBasicRegistration = function() { var file, rev; tusk.command("pinf --db " + tmpDBPath + " register-namespace http://127.0.0.1:8080/test@pinf.org/public/");
].forEach(function(path) { sourcePath = rawBuildPath.join(path); command = "rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" " + sourcePath + "/* " + targetPath; print(command); OS.command(command); });