mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
adding package version to remote repository
This commit is contained in:
parent
0173c55ead
commit
c8bb68a4aa
3 changed files with 47 additions and 6 deletions
|
@ -98,10 +98,37 @@ Storage.prototype.add_package = function(name, metadata, callback) {
|
|||
}
|
||||
|
||||
//
|
||||
// TODO: badly documented
|
||||
// Add a new version of package {name} to a system
|
||||
//
|
||||
// Function uploads a new package version to all uplinks with write access
|
||||
// and if everything succeeded it adds it locally.
|
||||
//
|
||||
// TODO: if a package is uploaded to uplink1, but upload to uplink2 fails,
|
||||
// we report failure, but package is not removed from uplink1. This might
|
||||
// require manual intervention.
|
||||
//
|
||||
// Used storages: local (write) && uplinks (proxy_publish, write)
|
||||
//
|
||||
Storage.prototype.add_version = function(name, version, metadata, tag, callback) {
|
||||
this.local.add_version(name, version, metadata, tag, callback);
|
||||
var self = this;
|
||||
|
||||
var uplinks = [];
|
||||
for (var i in self.uplinks) {
|
||||
if (self.config.proxy_publish(name, i)) {
|
||||
uplinks.push(self.uplinks[i]);
|
||||
}
|
||||
}
|
||||
async.map(uplinks, function(up, cb) {
|
||||
up.add_version(name, version, metadata, tag, cb);
|
||||
}, function(err, results) {
|
||||
if (err) {
|
||||
return callback(new UError({
|
||||
status: 503,
|
||||
msg: 'can\'t upload to one of the uplinks, refuse to publish'
|
||||
}));
|
||||
}
|
||||
self.local.add_version(name, version, metadata, tag, callback);
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -39,7 +39,7 @@ Storage.prototype.can_fetch_url = function(url) {
|
|||
|
||||
Storage.prototype.add_package = function(name, metadata, callback) {
|
||||
request({
|
||||
url: this.config.url + '/' + name,
|
||||
url: this.config.url + '/' + escape(name),
|
||||
headers: {
|
||||
'User-Agent': this.ua,
|
||||
},
|
||||
|
@ -56,7 +56,21 @@ Storage.prototype.add_package = function(name, metadata, callback) {
|
|||
}
|
||||
|
||||
Storage.prototype.add_version = function(name, version, metadata, tag, callback) {
|
||||
throw new Error('unimplemented');
|
||||
request({
|
||||
url: this.config.url + '/' + escape(name) + '/' + escape(version) + '/-tag/' + escape(tag),
|
||||
headers: {
|
||||
'User-Agent': this.ua,
|
||||
},
|
||||
method: 'PUT',
|
||||
ca: this.ca,
|
||||
json: metadata,
|
||||
}, function(err, res, body) {
|
||||
if (err) return callback(err);
|
||||
if (!(res.statusCode >= 200 && res.statusCode < 300)) {
|
||||
return callback(new Error('bad status code: ' + res.statusCode));
|
||||
}
|
||||
callback(null, body);
|
||||
});
|
||||
}
|
||||
|
||||
Storage.prototype.add_tarball = function(name, filename) {
|
||||
|
@ -65,7 +79,7 @@ Storage.prototype.add_tarball = function(name, filename) {
|
|||
|
||||
Storage.prototype.get_package = function(name, callback) {
|
||||
request({
|
||||
url: this.config.url + '/' + name,
|
||||
url: this.config.url + '/' + escape(name),
|
||||
json: true,
|
||||
headers: {
|
||||
'User-Agent': this.ua,
|
||||
|
|
|
@ -12,7 +12,7 @@ ex['starting servers'] = function(cb) {
|
|||
function start(dir, conf) {
|
||||
count++;
|
||||
rimraf(dir, function() {
|
||||
var f = fork('../bin/sinopia', ['-c', conf]);;//, {silent: true});
|
||||
var f = fork('../bin/sinopia', ['-c', conf], {silent: true});
|
||||
forks.push(f);
|
||||
f.on('message', function(msg) {
|
||||
if ('sinopia_started' in msg) {
|
||||
|
|
Loading…
Add table
Reference in a new issue