0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

Merge remote-tracking branch 'origin/master' into 4.x

# Conflicts:
#	src/api/web/endpoint/package.js
#	src/lib/storage.js
#	src/lib/up-storage.js
#	src/utils/user.js
This commit is contained in:
Juan Picado @jotadeveloper 2019-01-20 09:55:24 +01:00
commit 5a8d92f5f9
No known key found for this signature in database
GPG key ID: 18AC54485952D158
5 changed files with 14 additions and 10 deletions

View file

@ -7,6 +7,7 @@ import _ from 'lodash';
import { addScope, addGravatarSupport, deleteProperties, sortByName, parseReadme } from '../../../lib/utils'; import { addScope, addGravatarSupport, deleteProperties, sortByName, parseReadme } from '../../../lib/utils';
import { allow } from '../../middleware'; import { allow } from '../../middleware';
import { DIST_TAGS, HEADER_TYPE, HEADERS, HTTP_STATUS } from '../../../lib/constants'; import { DIST_TAGS, HEADER_TYPE, HEADERS, HTTP_STATUS } from '../../../lib/constants';
import logger from '../../../lib/logger';
import type { Router } from 'express'; import type { Router } from 'express';
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types'; import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types';
import type { Config } from '@verdaccio/types'; import type { Config } from '@verdaccio/types';
@ -44,6 +45,7 @@ function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth,
permissions.push(pkg); permissions.push(pkg);
} }
} catch (err) { } catch (err) {
logger.logger.error({ name: pkg.name, error: err }, 'permission process for @{name} has failed: @{error}');
throw err; throw err;
} }
} }

View file

@ -642,7 +642,7 @@ class LocalStorage implements IStorage {
const { packages } = this.config; const { packages } = this.config;
if (packages) { if (packages) {
const listPackagesConf = Object.keys(packages || {}); const listPackagesConf = Object.keys(packages);
listPackagesConf.map(pkg => { listPackagesConf.map(pkg => {
if (packages[pkg].storage) { if (packages[pkg].storage) {

View file

@ -322,17 +322,20 @@ class Storage implements IStorageHandler {
); );
lstream.on('error', function(err) { lstream.on('error', function(err) {
self.logger.error({ err: err }, 'uplink error: @{err.message}'); self.logger.error({ err: err }, 'uplink error: @{err.message}');
cb(), (cb = function() {}); cb();
cb = function() {};
}); });
lstream.on('end', function() { lstream.on('end', function() {
cb(), (cb = function() {}); cb();
cb = function() {};
}); });
stream.abort = function() { stream.abort = function() {
if (lstream.abort) { if (lstream.abort) {
lstream.abort(); lstream.abort();
} }
cb(), (cb = function() {}); cb();
cb = function() {};
}; };
}, },
// executed after all series // executed after all series
@ -411,7 +414,7 @@ class Storage implements IStorageHandler {
const upLinks = []; const upLinks = [];
const hasToLookIntoUplinks = _.isNil(options.uplinksLook) || options.uplinksLook; const hasToLookIntoUplinks = _.isNil(options.uplinksLook) || options.uplinksLook;
if (!packageInfo || packageInfo === null) { if (!packageInfo) {
exists = false; exists = false;
packageInfo = generatePackageTemplate(name); packageInfo = generatePackageTemplate(name);
} }

View file

@ -145,7 +145,7 @@ class ProxyStorage implements IProxy {
let error; let error;
const responseLength = err ? 0 : body.length; const responseLength = err ? 0 : body.length;
// $FlowFixMe // $FlowFixMe
processBody(err, body); processBody();
logActivity(); logActivity();
// $FlowFixMe // $FlowFixMe
cb(err, res, body); cb(err, res, body);
@ -552,7 +552,7 @@ class ProxyStorage implements IProxy {
// https://github.com/rlidwka/sinopia/issues/254 // https://github.com/rlidwka/sinopia/issues/254
// //
if (this.proxy === false) { if (this.proxy === false) {
headers['X-Forwarded-For'] = (req && req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'] + ', ' : '') + req.connection.remoteAddress; headers['X-Forwarded-For'] = (req.headers['x-forwarded-for'] ? req.headers['x-forwarded-for'] + ', ' : '') + req.connection.remoteAddress;
} }
} }

View file

@ -34,11 +34,10 @@ export const GENERIC_AVATAR: string = `
* Generate gravatar url from email address * Generate gravatar url from email address
*/ */
export function generateGravatarUrl(email: string = '', online: boolean = true): string { export function generateGravatarUrl(email: string = '', online: boolean = true): string {
let emailCopy = email;
if (online) { if (online) {
if (_.isString(email) && _.size(email) > 0) { if (_.isString(email) && _.size(email) > 0) {
emailCopy = email.trim().toLocaleLowerCase(); email = email.trim().toLocaleLowerCase();
const emailMD5 = stringToMD5(emailCopy); const emailMD5 = stringToMD5(email);
return `https://www.gravatar.com/avatar/${emailMD5}`; return `https://www.gravatar.com/avatar/${emailMD5}`;
} }
return GENERIC_AVATAR; return GENERIC_AVATAR;