mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-28 16:45:11 +08:00
added dpd push [host]
This commit is contained in:
114
bin/dpd
114
bin/dpd
@@ -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') || {};
|
||||
|
||||
Reference in New Issue
Block a user