mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
Fix eslint issues, add jsdoc
This commit is contained in:
parent
09c60e68e0
commit
acfd865bb0
4 changed files with 29 additions and 8 deletions
|
@ -1,7 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let Path = require('path');
|
const Path = require('path');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requires a module.
|
||||||
|
* @param {*} path the module's path
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
function try_load(path) {
|
function try_load(path) {
|
||||||
try {
|
try {
|
||||||
return require(path);
|
return require(path);
|
||||||
|
@ -13,6 +18,17 @@ function try_load(path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a plugin following the rules
|
||||||
|
* - First try to load from the internal directory plugins (which will disappear soon or later).
|
||||||
|
* - A seccond attempt from node_modules, in case to have multiple match as for instance verdaccio-ldap
|
||||||
|
* and sinopia-ldap. All verdaccio prefix will have preferences.
|
||||||
|
* @param {*} config a reference of the configuration settings
|
||||||
|
* @param {*} plugin_configs
|
||||||
|
* @param {*} params a set of params to initialise the plugin
|
||||||
|
* @param {*} sanity_check callback that check the shape that should fulfill the plugin
|
||||||
|
* @return {Array} list of plugins
|
||||||
|
*/
|
||||||
function load_plugins(config, plugin_configs, params, sanity_check) {
|
function load_plugins(config, plugin_configs, params, sanity_check) {
|
||||||
let plugins = Object.keys(plugin_configs || {}).map(function(p) {
|
let plugins = Object.keys(plugin_configs || {}).map(function(p) {
|
||||||
let plugin;
|
let plugin;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint no-invalid-this: "off" */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const lunr = require('lunr');
|
const lunr = require('lunr');
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint prefer-rest-params: "off" */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// see https://secure.flickr.com/photos/girliemac/sets/72157628409467125
|
// see https://secure.flickr.com/photos/girliemac/sets/72157628409467125
|
||||||
|
|
|
@ -97,23 +97,25 @@ function filter_tarball_urls(pkg, req, config) {
|
||||||
if (!req.headers.host) {
|
if (!req.headers.host) {
|
||||||
return _url;
|
return _url;
|
||||||
}
|
}
|
||||||
let filename = URL.parse(_url).pathname.replace(/^.*\//, '');
|
const filename = URL.parse(_url).pathname.replace(/^.*\//, '');
|
||||||
let result;
|
let result;
|
||||||
if (config.url_prefix != null) {
|
if (config.url_prefix != null) {
|
||||||
result = config.url_prefix.replace(/\/$/, '');
|
result = config.url_prefix.replace(/\/$/, '');
|
||||||
} else {
|
} else {
|
||||||
result = req.protocol + '://' + req.headers.host;
|
result = `${req.protocol}://${req.headers.host}`;
|
||||||
}
|
}
|
||||||
return `${result}/${pkg.name.replace(/\//g, '%2f')}/-/${filename}`;
|
return `${result}/${pkg.name.replace(/\//g, '%2f')}/-/${filename}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let ver in pkg.versions) {
|
for (let ver in pkg.versions) {
|
||||||
let dist = pkg.versions[ver].dist;
|
if (Object.prototype.hasOwnProperty.call(pkg.versions, ver)) {
|
||||||
|
const dist = pkg.versions[ver].dist;
|
||||||
if (dist != null && dist.tarball != null) {
|
if (dist != null && dist.tarball != null) {
|
||||||
// dist.__verdaccio_orig_tarball = dist.tarball
|
// dist.__verdaccio_orig_tarball = dist.tarball
|
||||||
dist.tarball = filter(dist.tarball);
|
dist.tarball = filter(dist.tarball);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +229,6 @@ function semver_sort(array) {
|
||||||
*/
|
*/
|
||||||
function normalize_dist_tags(data) {
|
function normalize_dist_tags(data) {
|
||||||
let sorted;
|
let sorted;
|
||||||
|
|
||||||
if (!data['dist-tags'].latest) {
|
if (!data['dist-tags'].latest) {
|
||||||
// overwrite latest with highest known version based on semver sort
|
// overwrite latest with highest known version based on semver sort
|
||||||
sorted = module.exports.semver_sort(Object.keys(data.versions));
|
sorted = module.exports.semver_sort(Object.keys(data.versions));
|
||||||
|
|
Loading…
Reference in a new issue