mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-27 22:59:51 -05:00
Fixed refresh issue
This commit is contained in:
parent
5a98db9589
commit
2901e619cb
5 changed files with 38 additions and 33 deletions
|
@ -18,10 +18,11 @@
|
|||
npm adduser --registry {{ baseUrl }}
|
||||
</code>
|
||||
|
||||
{{#each locals}}
|
||||
{{#each packages}}
|
||||
<article>
|
||||
<h2>{{ name }} <small>v{{ version }}</small></h2>
|
||||
<div>By: {{ _npmUser.name }}</div>
|
||||
<h3>{{ name }} <small>v{{ version }}</small></h3>
|
||||
<div>User: {{ _npmUser.name }}</div>
|
||||
<p>{{ description }}</p>
|
||||
</article>
|
||||
{{/each}}
|
||||
</body>
|
||||
|
|
35
lib/index.js
35
lib/index.js
|
@ -127,27 +127,13 @@ module.exports = function(config_hash) {
|
|||
app.get('/', can('access'), function(req, res, next) {
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
|
||||
var locals = localList.get();
|
||||
var getPackage = function(i) {
|
||||
storage.get_package(locals[i], function(err, info) {
|
||||
var latest = info['dist-tags'].latest;
|
||||
|
||||
locals[i] = info.versions[latest];
|
||||
|
||||
if(i < locals.length - 1) {
|
||||
getPackage(i + 1);
|
||||
}
|
||||
else {
|
||||
res.send(template({
|
||||
name: "Sinopia",
|
||||
locals: locals,
|
||||
baseUrl: req.protocol + '://' + req.get('host') + '/'
|
||||
}));
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getPackage(0);
|
||||
storage.get_local(function(err, packages) {
|
||||
res.send(template({
|
||||
name: "Sinopia",
|
||||
packages: packages,
|
||||
baseUrl: req.protocol + '://' + req.get('host') + '/'
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: anonymous user?
|
||||
|
@ -215,13 +201,6 @@ module.exports = function(config_hash) {
|
|||
})
|
||||
})
|
||||
|
||||
app.put('/-/user/:org_couchdb_user', function(req, res, next) {
|
||||
res.status(409)
|
||||
return res.send({
|
||||
error: 'registration is not implemented',
|
||||
})
|
||||
})
|
||||
|
||||
app.put('/-/user/:org_couchdb_user/-rev/*', function(req, res, next) {
|
||||
if (req.remoteUser == null) {
|
||||
res.status(403)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var fs = require('fs'),
|
||||
listFilePath = './local-list.json';
|
||||
var fs = require('fs')
|
||||
, listFilePath = './local-list.json';
|
||||
|
||||
var LocalList = function() {
|
||||
if(fs.existsSync(listFilePath)) {
|
||||
|
|
|
@ -6,6 +6,7 @@ var async = require('async')
|
|||
, mystreams = require('./streams')
|
||||
, utils = require('./utils')
|
||||
, Logger = require('./logger')
|
||||
, localList = require('./local-list');
|
||||
|
||||
//
|
||||
// Implements Storage interface
|
||||
|
@ -320,6 +321,29 @@ Storage.prototype.get_package = function(name, options, callback) {
|
|||
})
|
||||
}
|
||||
|
||||
Storage.prototype.get_local = function(callback) {
|
||||
var self = this
|
||||
, locals = localList.get()
|
||||
, packages = [];
|
||||
|
||||
var getPackage = function(i) {
|
||||
self.get_package(locals[i], function(err, info) {
|
||||
var latest = info['dist-tags'].latest;
|
||||
|
||||
packages.push(info.versions[latest]);
|
||||
|
||||
if(err || i >= locals.length - 1) {
|
||||
callback(err, packages);
|
||||
}
|
||||
else {
|
||||
getPackage(i + 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
getPackage(0);
|
||||
};
|
||||
|
||||
// function fetches package information from uplinks and synchronizes it with local data
|
||||
// if package is available locally, it MUST be provided in pkginfo
|
||||
// returns callback(err, result, uplink_errors)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
"express": "3.4.x",
|
||||
"handlebars": "^2.0.0-alpha.2",
|
||||
"js-yaml": ">= 3.0.1",
|
||||
"lunr": "^0.5.2",
|
||||
"minimatch": ">= 0.2.14",
|
||||
"mkdirp": ">= 0.3.5",
|
||||
"request": ">= 2.31.0",
|
||||
|
|
Loading…
Add table
Reference in a new issue