Browse files

remote tracking

  • Loading branch information...
1 parent b9fc1d6 commit 4b08fce0bae3cb66d398b72bc2d50543124d00c3 @substack committed Feb 28, 2012
View
0 bin/deploy.js 100644 → 100755
File mode changed.
View
0 bin/drone.js 100644 → 100755
File mode changed.
View
0 bin/hub.js 100644 → 100755
File mode changed.
View
0 bin/list.js 100644 → 100755
File mode changed.
View
0 bin/monitor.js 100644 → 100755
File mode changed.
View
38 bin/remote.js 100644 → 100755
@@ -1 +1,37 @@
-// todo: like git remote to save the --hub and --secret
+#!/usr/bin/env node
+var argv = require('optimist').argv;
+var git = require('../lib/git');
+
+var fs = require('fs');
+var path = require('path');
+
+var gitDir = git.dir();
+var fleetFile = gitDir + '/fleet.json';
+
+var remote = {};
+if (path.existsSync(fleetFile)) {
+ remote = JSON.parse(fs.readFileSync(fleetFile));
+}
+
+function save () {
+ fs.writeFileSync(fleetFile, JSON.stringify(remote, undefined, 2) + '\n');
+}
+
+var cmd = argv._[0];
+
+if (cmd === 'add') {
+ var name = argv._[1] || 'default';
+ remote[name] = { hub : argv.hub, secret : argv.secret };
+ save();
+}
+else if (cmd === 'rm') {
+ var name = argv._[1] || 'default';
+ delete remote[name];
+ save();
+}
+else if (cmd === 'ls' || cmd === 'list') {
+ console.log(JSON.stringify(remote, undefined, 2));
+}
+else {
+ console.error('Usage: fleet remote (add|rm|ls)');
+}
View
0 bin/router.js 100644 → 100755
File mode changed.
View
0 bin/spawn.js 100644 → 100755
File mode changed.
View
9 lib/git.js
@@ -29,11 +29,16 @@ exports.push = function push (remote, branch, cb) {
};
exports.repoName = function () {
- var ps = process.cwd().split('/');
+ var dir = exports.dir()
+ return dir.split('/').slice(-1)[0];
+};
+
+exports.dir = function (cwd) {
+ var ps = (cwd || process.cwd()).split('/');
for (var i = ps.length; i > 0; i--) {
var dir = ps.slice(0, i).join('/');
if (path.existsSync(dir + '/.git')) {
- return dir.split('/').slice(-1)[0];
+ return dir;
}
}
};
View
4 package.json
@@ -9,6 +9,7 @@
"main" : "index.js",
"bin" : {
"fleet" : "bin/command.sh",
+ "fleet-remote" : "bin/remote.js",
"fleet-deploy" : "bin/deploy.js",
"fleet-drone" : "bin/drone.js",
"fleet-hub" : "bin/hub.js",
@@ -34,7 +35,8 @@
"propagit" : "~0.4.1",
"seaport" : "~0.4.0",
"optimist" : "~0.3.1",
- "bouncy" : "~1.1.1"
+ "bouncy" : "~1.1.1",
+ "mkdirp" : "~0.3.0"
},
"devDependencies" : {
"tap" : "0.0.x"

0 comments on commit 4b08fce

Please sign in to comment.