added dpd push [host]

This commit is contained in:
Ritchie Martori
2012-05-10 19:54:43 -07:00
parent 9578f8c0d9
commit 5e1523a299

114
bin/dpd
View File

@@ -349,6 +349,36 @@ function downloadFiles(host, resource, fn) {
})
}
function pull(host, fn) {
var l = loader(fn);
startMongod(function (err, mongoPort) {
local
.use('http://localhost:2403')
.storage(getStorageUrl(mongoPort))
.listen(function () {
resources(client.use(sanitizeHost(host)), function (resource) {
if(resource.type === 'Static') {
l.add();
downloadFiles(host, resource, l.tic);
}
delete resource._id;
l.add();
// clone resource
local.use('/resources').del({path: resource.path}, function (err, res) {
local.use('/resources').post(resource, function (err, res) {
l.tic();
});
});
});
})
;
})
}
/**
* Async Loader Utility
*/
@@ -438,37 +468,38 @@ program
sh.cd(name);
addRemote(host);
var l = loader(function () {
pull(host, function () {
process.exit();
config('clone', host);
})
})
;
program
.command('pull [host]')
.description(' - add a remote host and pull down all its resources and files into a new directory')
.action(function (host) {
function use(host) {
if(!host) return cancel('no remote found! add one with `dpd remote` or specify one `dpd push myapp.com`');
pull(host, function () {
process.exit();
config('clone', host);
})
}
startMongod(function (err, mongoPort) {
local
.use('http://localhost:2403')
.storage(getStorageUrl(mongoPort))
.listen(function () {
resources(client.use(sanitizeHost(host)), function (resource) {
if(resource.type === 'Static') {
l.add();
downloadFiles(host, resource, l.tic);
}
delete resource._id;
l.add();
// clone resource
local.use('/resources').del({path: resource.path}, function (err, res) {
local.use('/resources').post(resource, function (err, res) {
l.tic();
});
});
});
})
;
})
var remotes = config('remotes') || {};
if(host) {
use(host);
} else if(Object.keys(remotes).length > 1) {
console.log('more than one remote found... you must specify one of the following hosts');
program.choose(Object.keys(remotes), function (i) {
use(Object.keys(remotes)[i]);
});
} else {
use(Object.keys(remotes)[0]);
}
})
;
@@ -478,9 +509,36 @@ program
.action(function (host) {
function use(host) {
if(!host) return cancel('no remote found! add one with `dpd remote` or specify one `dpd push myapp.com`');
pushTo(client.use(sanitizeHost(host)), function () {
var l = loader(function () {
console.log(host, 'is now up to date');
});
var remote = client.use(sanitizeHost(host));
startMongod(function (err, mongoPort) {
local
.use('http://localhost:2403')
.storage(getStorageUrl(mongoPort))
.listen(function () {
resources(local, function (resource) {
delete resource._id;
l.add();
// clone resource
remote.use('/resources').del({path: resource.path}, function (err, res) {
remote.use('/resources').post(resource, function (err, res) {
l.tic();
});
});
});
})
;
})
l.add();
pushTo(remote, function () {
l.tic();
});
}
var remotes = config('remotes') || {};