mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: add space in curly braces -> object-curly-spacing (#1035)
* refactor: allowed spaces between brackets * chore: update bundle size max
This commit is contained in:
parent
af0b22aba9
commit
d504d28dc4
54 changed files with 333 additions and 369 deletions
|
@ -4,7 +4,7 @@
|
|||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"requirePragma": true,
|
||||
"bracketSpacing": false,
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"trailingComma": "es5",
|
||||
"semi": true,
|
||||
|
|
|
@ -229,7 +229,7 @@
|
|||
},
|
||||
{
|
||||
"path": "./build/**/*.js",
|
||||
"maxSize": "5.50 kB"
|
||||
"maxSize": "5.90 kB"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import type {$Application} from 'express';
|
||||
import type {$ResponseExtend, $RequestExtend, $NextFunctionVer} from '../../../types';
|
||||
import type { $Application } from 'express';
|
||||
import type { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../../../types';
|
||||
|
||||
export default (app: $Application, selfPath: string) => {
|
||||
// Hook for tests only
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import mime from 'mime';
|
||||
import _ from 'lodash';
|
||||
import {media, allow} from '../../middleware';
|
||||
import {DIST_TAGS} from '../../../lib/utils';
|
||||
import type {Router} from 'express';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler} from '../../../../types';
|
||||
import {API_MESSAGE, HTTP_STATUS} from '../../../lib/constants';
|
||||
import { media, allow } from '../../middleware';
|
||||
import { DIST_TAGS } from '../../../lib/utils';
|
||||
import type { Router } from 'express';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types';
|
||||
import { API_MESSAGE, HTTP_STATUS } from '../../../lib/constants';
|
||||
|
||||
export default function(route: Router, auth: IAuth, storage: IStorageHandler) {
|
||||
const can = allow(auth);
|
||||
|
@ -26,7 +25,7 @@ export default function(route: Router, auth: IAuth, storage: IStorageHandler) {
|
|||
return next(err);
|
||||
}
|
||||
res.status(HTTP_STATUS.CREATED);
|
||||
return next({ok: API_MESSAGE.TAG_ADDED});
|
||||
return next({ ok: API_MESSAGE.TAG_ADDED });
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import {allow} from '../../middleware';
|
||||
import {DIST_TAGS, convertDistRemoteToLocalTarballUrls, getVersion, ErrorCode} from '../../../lib/utils';
|
||||
import {HEADERS} from '../../../lib/constants';
|
||||
import type {Router} from 'express';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler} from '../../../../types';
|
||||
import { allow } from '../../middleware';
|
||||
import { DIST_TAGS, convertDistRemoteToLocalTarballUrls, getVersion, ErrorCode } from '../../../lib/utils';
|
||||
import { HEADERS } from '../../../lib/constants';
|
||||
import type { Router } from 'express';
|
||||
import type { Config } from '@verdaccio/types';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types';
|
||||
|
||||
export default function(route: Router, auth: IAuth, storage: IStorageHandler, config: Config) {
|
||||
const can = allow(auth);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import type {Router} from 'express';
|
||||
import type {$RequestExtend, $ResponseExtend, $NextFunctionVer} from '../../../../types';
|
||||
import type { Router } from 'express';
|
||||
import type { $RequestExtend, $ResponseExtend, $NextFunctionVer } from '../../../../types';
|
||||
|
||||
export default function(route: Router) {
|
||||
route.get('/-/ping', function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import Path from 'path';
|
||||
import mime from 'mime';
|
||||
|
||||
import {API_MESSAGE, HEADERS} from '../../../lib/constants';
|
||||
import {DIST_TAGS, validateMetadata, isObject, ErrorCode} from '../../../lib/utils';
|
||||
import {media, expectJson, allow} from '../../middleware';
|
||||
import {notify} from '../../../lib/notify';
|
||||
import { API_MESSAGE, HEADERS } from '../../../lib/constants';
|
||||
import { DIST_TAGS, validateMetadata, isObject, ErrorCode } from '../../../lib/utils';
|
||||
import { media, expectJson, allow } from '../../middleware';
|
||||
import { notify } from '../../../lib/notify';
|
||||
|
||||
import type {Router} from 'express';
|
||||
import type {Config, Callback} from '@verdaccio/types';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler} from '../../../../types';
|
||||
import type { Router } from 'express';
|
||||
import type { Config, Callback } from '@verdaccio/types';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types';
|
||||
import logger from '../../../lib/logger';
|
||||
|
||||
export default function(router: Router, auth: IAuth, storage: IStorageHandler, config: Config) {
|
||||
|
@ -105,11 +104,11 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
|||
try {
|
||||
await notify(metadata, config, req.remote_user, `${metadata.name}@${versionToPublish}`);
|
||||
} catch (err) {
|
||||
logger.logger.error({err}, 'notify batch service has failed: @{err}');
|
||||
logger.logger.error({ err }, 'notify batch service has failed: @{err}');
|
||||
}
|
||||
|
||||
res.status(201);
|
||||
return next({ok: ok_message, success: true});
|
||||
return next({ ok: ok_message, success: true });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -144,7 +143,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
|||
return next(err);
|
||||
}
|
||||
res.status(201);
|
||||
return next({ok: API_MESSAGE.PKG_REMOVED});
|
||||
return next({ ok: API_MESSAGE.PKG_REMOVED });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -155,7 +154,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
|||
return next(err);
|
||||
}
|
||||
res.status(201);
|
||||
return next({ok: API_MESSAGE.TARBALL_REMOVED});
|
||||
return next({ ok: API_MESSAGE.TARBALL_REMOVED });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -200,7 +199,7 @@ export default function(router: Router, auth: IAuth, storage: IStorageHandler, c
|
|||
res: $ResponseExtend,
|
||||
next: $NextFunctionVer
|
||||
) {
|
||||
const {version, tag} = req.params;
|
||||
const { version, tag } = req.params;
|
||||
const name = req.params.package;
|
||||
|
||||
storage.addVersion(name, version, req.body, tag, function(err) {
|
||||
|
|
|
@ -56,7 +56,7 @@ export default function(route, auth, storage) {
|
|||
res.write('{"_updated":' + 99999);
|
||||
}
|
||||
|
||||
let stream = storage.search(req.query.startkey || 0, {req: req});
|
||||
let stream = storage.search(req.query.startkey || 0, { req: req });
|
||||
|
||||
stream.on('data', function each(pkg) {
|
||||
processing_pkgs++;
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import Cookies from 'cookies';
|
||||
|
||||
import {ErrorCode} from '../../../lib/utils';
|
||||
import {API_MESSAGE, HTTP_STATUS} from '../../../lib/constants';
|
||||
import {createSessionToken, getApiToken, getAuthenticatedMessage} from '../../../lib/auth-utils';
|
||||
import { ErrorCode } from '../../../lib/utils';
|
||||
import { API_MESSAGE, HTTP_STATUS } from '../../../lib/constants';
|
||||
import { createSessionToken, getApiToken, getAuthenticatedMessage } from '../../../lib/auth-utils';
|
||||
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import type {$Response, Router} from 'express';
|
||||
import type {$RequestExtend, $ResponseExtend, $NextFunctionVer, IAuth} from '../../../../types';
|
||||
import type { Config } from '@verdaccio/types';
|
||||
import type { $Response, Router } from 'express';
|
||||
import type { $RequestExtend, $ResponseExtend, $NextFunctionVer, IAuth } from '../../../../types';
|
||||
|
||||
export default function(route: Router, auth: IAuth, config: Config) {
|
||||
route.get('/-/user/:org_couchdb_user', function(req: $RequestExtend, res: $Response, next: $NextFunctionVer) {
|
||||
|
@ -24,7 +23,7 @@ export default function(route: Router, auth: IAuth, config: Config) {
|
|||
});
|
||||
|
||||
route.put('/-/user/:org_couchdb_user/:_rev?/:revision?', async function(req: $RequestExtend, res: $Response, next: $NextFunctionVer) {
|
||||
const {name, password} = req.body;
|
||||
const { name, password } = req.body;
|
||||
|
||||
if (_.isNil(req.remote_user.name) === false) {
|
||||
const token = name && password ? await getApiToken(auth, config, req.remote_user, password) : undefined;
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import type {$Response, Router} from 'express';
|
||||
import type {$RequestExtend, $NextFunctionVer} from '../../../../types';
|
||||
import type { $Response, Router } from 'express';
|
||||
import type { $RequestExtend, $NextFunctionVer } from '../../../../types';
|
||||
|
||||
export default function(route: Router) {
|
||||
route.get(
|
||||
'/whoami',
|
||||
(req: $RequestExtend, res: $Response, next: $NextFunctionVer): void => {
|
||||
if (req.headers.referer === 'whoami') {
|
||||
next({username: req.remote_user.name});
|
||||
next({ username: req.remote_user.name });
|
||||
} else {
|
||||
next('route');
|
||||
}
|
||||
|
@ -22,7 +21,7 @@ export default function(route: Router) {
|
|||
route.get(
|
||||
'/-/whoami',
|
||||
(req: $RequestExtend, res: $Response, next: $NextFunctionVer): mixed => {
|
||||
next({username: req.remote_user.name});
|
||||
next({ username: req.remote_user.name });
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import type {IAuth, IStorageHandler} from '../../../types';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import type { IAuth, IStorageHandler } from '../../../types';
|
||||
import type { Config } from '@verdaccio/types';
|
||||
|
||||
import express from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
|
@ -17,7 +16,7 @@ import publish from './api/publish';
|
|||
import search from './api/search';
|
||||
import pkg from './api/package';
|
||||
|
||||
const {match, validateName, validatePackage, encodeScopePackage, anti_loop} = require('../middleware');
|
||||
const { match, validateName, validatePackage, encodeScopePackage, anti_loop } = require('../middleware');
|
||||
|
||||
export default function(config: Config, auth: IAuth, storage: IStorageHandler) {
|
||||
/* eslint new-cap:off */
|
||||
|
@ -42,7 +41,7 @@ export default function(config: Config, auth: IAuth, storage: IStorageHandler) {
|
|||
app.param('anything', match(/.*/));
|
||||
|
||||
app.use(auth.apiJWTmiddleware());
|
||||
app.use(bodyParser.json({strict: false, limit: config.max_body_size || '10mb'}));
|
||||
app.use(bodyParser.json({ strict: false, limit: config.max_body_size || '10mb' }));
|
||||
app.use(anti_loop(config));
|
||||
// encode / in a scoped package name to be matched as a single parameter in routes
|
||||
app.use(encodeScopePackage);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import express from 'express';
|
||||
import compression from 'compression';
|
||||
|
@ -13,15 +12,15 @@ import loadPlugin from '../lib/plugin-loader';
|
|||
import hookDebug from './debug';
|
||||
import Auth from '../lib/auth';
|
||||
import apiEndpoint from './endpoint';
|
||||
import {ErrorCode} from '../lib/utils';
|
||||
import {API_ERROR, HTTP_STATUS} from '../lib/constants';
|
||||
import { ErrorCode } from '../lib/utils';
|
||||
import { API_ERROR, HTTP_STATUS } from '../lib/constants';
|
||||
import AppConfig from '../lib/config';
|
||||
import webAPI from './web/api';
|
||||
import web from './web';
|
||||
|
||||
import type {$Application} from 'express';
|
||||
import type {$ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, IAuth} from '../../types';
|
||||
import type {Config as IConfig, IPluginMiddleware} from '@verdaccio/types';
|
||||
import type { $Application } from 'express';
|
||||
import type { $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, IAuth } from '../../types';
|
||||
import type { Config as IConfig, IPluginMiddleware } from '@verdaccio/types';
|
||||
|
||||
const LoggerApp = require('../lib/logger');
|
||||
const Middleware = require('./middleware');
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import {validateName as utilValidateName, validatePackage as utilValidatePackage, isObject, ErrorCode} from '../lib/utils';
|
||||
import {API_ERROR, HEADER_TYPE, HEADERS, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER} from '../lib/constants';
|
||||
import {stringToMD5} from '../lib/crypto-utils';
|
||||
import type {$ResponseExtend, $RequestExtend, $NextFunctionVer, IAuth} from '../../types';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import { validateName as utilValidateName, validatePackage as utilValidatePackage, isObject, ErrorCode } from '../lib/utils';
|
||||
import { API_ERROR, HEADER_TYPE, HEADERS, HTTP_STATUS, TOKEN_BASIC, TOKEN_BEARER } from '../lib/constants';
|
||||
import { stringToMD5 } from '../lib/crypto-utils';
|
||||
import type { $ResponseExtend, $RequestExtend, $NextFunctionVer, IAuth } from '../../types';
|
||||
import type { Config } from '@verdaccio/types';
|
||||
|
||||
const Logger = require('../lib/logger');
|
||||
|
||||
|
@ -167,7 +166,7 @@ export function final(body: any, req: $RequestExtend, res: $ResponseExtend, next
|
|||
|
||||
export function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
// logger
|
||||
req.log = Logger.logger.child({sub: 'in'});
|
||||
req.log = Logger.logger.child({ sub: 'in' });
|
||||
|
||||
let _auth = req.headers.authorization;
|
||||
if (_.isNil(_auth) === false) {
|
||||
|
@ -180,7 +179,7 @@ export function log(req: $RequestExtend, res: $ResponseExtend, next: $NextFuncti
|
|||
}
|
||||
|
||||
req.url = req.originalUrl;
|
||||
req.log.info({req: req, ip: req.ip}, "@{ip} requested '@{req.method} @{req.url}'");
|
||||
req.log.info({ req: req, ip: req.ip }, "@{ip} requested '@{req.method} @{req.url}'");
|
||||
req.originalUrl = req.url;
|
||||
|
||||
if (_.isNil(_auth) === false) {
|
||||
|
@ -261,16 +260,16 @@ export function errorReportingMiddleware(req: $RequestExtend, res: $ResponseExte
|
|||
if (err.status && err.status >= HTTP_STATUS.BAD_REQUEST && err.status < 600) {
|
||||
if (_.isNil(res.headersSent) === false) {
|
||||
res.status(err.status);
|
||||
next({error: err.message || API_ERROR.UNKNOWN_ERROR});
|
||||
next({ error: err.message || API_ERROR.UNKNOWN_ERROR });
|
||||
}
|
||||
} else {
|
||||
Logger.logger.error({err: err}, 'unexpected error: @{!err.message}\n@{err.stack}');
|
||||
Logger.logger.error({ err: err }, 'unexpected error: @{!err.message}\n@{err.stack}');
|
||||
if (!res.status || !res.send) {
|
||||
Logger.logger.error('this is an error in express.js, please report this');
|
||||
res.destroy();
|
||||
} else if (!res.headersSent) {
|
||||
res.status(HTTP_STATUS.INTERNAL_ERROR);
|
||||
next({error: API_ERROR.INTERNAL_SERVER_ERROR});
|
||||
next({ error: API_ERROR.INTERNAL_SERVER_ERROR });
|
||||
} else {
|
||||
// socket should be already closed
|
||||
}
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import {Router} from 'express';
|
||||
import { Router } from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
import addUserAuthApi from './endpoint/user';
|
||||
import addPackageWebApi from './endpoint/package';
|
||||
import addSearchWebApi from './endpoint/search';
|
||||
|
||||
import Search from '../../lib/search';
|
||||
import {match, validateName, validatePackage, securityIframe} from '../middleware';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import type {IAuth, IStorageHandler} from '../../../types';
|
||||
import { match, validateName, validatePackage, securityIframe } from '../middleware';
|
||||
import type { Config } from '@verdaccio/types';
|
||||
import type { IAuth, IStorageHandler } from '../../../types';
|
||||
|
||||
const route = Router(); /* eslint new-cap: 0 */
|
||||
|
||||
|
@ -33,7 +32,7 @@ export default function(config: Config, auth: IAuth, storage: IStorageHandler) {
|
|||
route.param('version', validateName);
|
||||
route.param('anything', match(/.*/));
|
||||
|
||||
route.use(bodyParser.urlencoded({extended: false}));
|
||||
route.use(bodyParser.urlencoded({ extended: false }));
|
||||
route.use(auth.webUIJWTmiddleware());
|
||||
route.use(securityIframe);
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import {addScope, addGravatarSupport, deleteProperties, sortByName, DIST_TAGS, parseReadme} from '../../../lib/utils';
|
||||
import {allow} from '../../middleware';
|
||||
import type {Router} from 'express';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage} from '../../../../types';
|
||||
import { addScope, addGravatarSupport, deleteProperties, sortByName, DIST_TAGS, parseReadme } from '../../../lib/utils';
|
||||
import { allow } from '../../middleware';
|
||||
import type { Router } from 'express';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler, $SidebarPackage } from '../../../../types';
|
||||
|
||||
function addPackageWebApi(route: Router, storage: IStorageHandler, auth: IAuth) {
|
||||
const can = allow(auth);
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import Search from '../../../lib/search';
|
||||
import {DIST_TAGS} from '../../../lib/utils';
|
||||
import type {Router} from 'express';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler} from '../../../../types';
|
||||
import { DIST_TAGS } from '../../../lib/utils';
|
||||
import type { Router } from 'express';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer, IStorageHandler } from '../../../../types';
|
||||
|
||||
function addSearchWebApi(route: Router, storage: IStorageHandler, auth: IAuth) {
|
||||
// Search package
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
import { HTTP_STATUS } from '../../../lib/constants';
|
||||
|
||||
import {HTTP_STATUS} from '../../../lib/constants';
|
||||
|
||||
import type {Router} from 'express';
|
||||
import type {Config, RemoteUser, JWTSignOptions} from '@verdaccio/types';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer} from '../../../../types';
|
||||
import {ErrorCode} from '../../../lib/utils';
|
||||
import {getSecurity} from '../../../lib/auth-utils';
|
||||
import type { Router } from 'express';
|
||||
import type { Config, RemoteUser, JWTSignOptions } from '@verdaccio/types';
|
||||
import type { IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../../../../types';
|
||||
import { ErrorCode } from '../../../lib/utils';
|
||||
import { getSecurity } from '../../../lib/auth-utils';
|
||||
|
||||
function addUserAuthApi(route: Router, auth: IAuth, config: Config) {
|
||||
route.post('/login', function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
const {username, password} = req.body;
|
||||
const { username, password } = req.body;
|
||||
|
||||
auth.authenticate(username, password, async (err, user: RemoteUser) => {
|
||||
if (err) {
|
||||
|
|
|
@ -11,9 +11,9 @@ import express from 'express';
|
|||
|
||||
import * as Utils from '../../lib/utils';
|
||||
import Search from '../../lib/search';
|
||||
import {HEADERS, HTTP_STATUS, WEB_TITLE} from '../../lib/constants';
|
||||
import { HEADERS, HTTP_STATUS, WEB_TITLE } from '../../lib/constants';
|
||||
|
||||
const {securityIframe} = require('../middleware');
|
||||
const { securityIframe } = require('../middleware');
|
||||
/* eslint new-cap:off */
|
||||
const env = require('../../config/env');
|
||||
const templatePath = path.join(env.DIST_PATH, '/index.html');
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const APP_ROOT = path.resolve(__dirname, '../../');
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import {convertPayloadToBase64, ErrorCode} from './utils';
|
||||
import {API_ERROR, HTTP_STATUS, ROLES, TIME_EXPIRATION_7D, TOKEN_BASIC, TOKEN_BEARER, CHARACTER_ENCODING} from './constants';
|
||||
import { convertPayloadToBase64, ErrorCode } from './utils';
|
||||
import { API_ERROR, HTTP_STATUS, ROLES, TIME_EXPIRATION_7D, TOKEN_BASIC, TOKEN_BEARER, CHARACTER_ENCODING } from './constants';
|
||||
|
||||
import type {RemoteUser, Package, Callback, Config, Security, APITokenOptions, JWTOptions} from '@verdaccio/types';
|
||||
import type {CookieSessionToken, IAuthWebUI, AuthMiddlewarePayload, AuthTokenHeader, BasicPayload} from '../../types';
|
||||
import {aesDecrypt, verifyPayload} from './crypto-utils';
|
||||
import type { RemoteUser, Package, Callback, Config, Security, APITokenOptions, JWTOptions } from '@verdaccio/types';
|
||||
import type { CookieSessionToken, IAuthWebUI, AuthMiddlewarePayload, AuthTokenHeader, BasicPayload } from '../../types';
|
||||
import { aesDecrypt, verifyPayload } from './crypto-utils';
|
||||
|
||||
/**
|
||||
* Create a RemoteUser object
|
||||
|
@ -42,7 +41,7 @@ export function createAnonymousRemoteUser(): RemoteUser {
|
|||
|
||||
export function allow_action(action: string) {
|
||||
return function(user: RemoteUser, pkg: Package, callback: Callback) {
|
||||
const {name, groups} = user;
|
||||
const { name, groups } = user;
|
||||
const hasPermission = pkg[action].some(group => name === group || groups.includes(group));
|
||||
|
||||
if (hasPermission) {
|
||||
|
@ -115,7 +114,7 @@ export function buildUserBuffer(name: string, password: string) {
|
|||
}
|
||||
|
||||
export function isAESLegacy(security: Security): boolean {
|
||||
const {legacy, jwt} = security.api;
|
||||
const { legacy, jwt } = security.api;
|
||||
|
||||
return _.isNil(legacy) === false && _.isNil(jwt) && legacy === true;
|
||||
}
|
||||
|
@ -130,7 +129,7 @@ export async function getApiToken(auth: IAuthWebUI, config: Config, remoteUser:
|
|||
});
|
||||
} else {
|
||||
// i am wiling to use here _.isNil but flow does not like it yet.
|
||||
const {jwt} = security.api;
|
||||
const { jwt } = security.api;
|
||||
|
||||
if (jwt && jwt.sign) {
|
||||
return await auth.jwtEncrypt(remoteUser, jwt.sign);
|
||||
|
@ -146,7 +145,7 @@ export function parseAuthTokenHeader(authorizationHeader: string): AuthTokenHead
|
|||
const parts = authorizationHeader.split(' ');
|
||||
const [scheme, token] = parts;
|
||||
|
||||
return {scheme, token};
|
||||
return { scheme, token };
|
||||
}
|
||||
|
||||
export function parseBasicPayload(credentials: string): BasicPayload {
|
||||
|
@ -158,11 +157,11 @@ export function parseBasicPayload(credentials: string): BasicPayload {
|
|||
const user: string = credentials.slice(0, index);
|
||||
const password: string = credentials.slice(index + 1);
|
||||
|
||||
return {user, password};
|
||||
return { user, password };
|
||||
}
|
||||
|
||||
export function parseAESCredentials(authorizationHeader: string, secret: string) {
|
||||
const {scheme, token} = parseAuthTokenHeader(authorizationHeader);
|
||||
const { scheme, token } = parseAuthTokenHeader(authorizationHeader);
|
||||
|
||||
// basic is deprecated and should not be enforced
|
||||
if (scheme.toUpperCase() === TOKEN_BASIC.toUpperCase()) {
|
||||
|
@ -215,7 +214,7 @@ export function getMiddlewareCredentials(security: Security, secret: string, aut
|
|||
|
||||
return parsedCredentials;
|
||||
} else {
|
||||
const {scheme, token} = parseAuthTokenHeader(authorizationHeader);
|
||||
const { scheme, token } = parseAuthTokenHeader(authorizationHeader);
|
||||
|
||||
if (_.isString(token) && scheme.toUpperCase() === TOKEN_BEARER.toUpperCase()) {
|
||||
return verifyJWTPayload(token, secret);
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
import {API_ERROR, TOKEN_BASIC, TOKEN_BEARER} from './constants';
|
||||
import { API_ERROR, TOKEN_BASIC, TOKEN_BEARER } from './constants';
|
||||
import loadPlugin from '../lib/plugin-loader';
|
||||
import {aesEncrypt, signPayload} from './crypto-utils';
|
||||
import { aesEncrypt, signPayload } from './crypto-utils';
|
||||
import {
|
||||
getDefaultPlugins,
|
||||
getMiddlewareCredentials,
|
||||
|
@ -21,12 +20,12 @@ import {
|
|||
parseBasicPayload,
|
||||
createRemoteUser,
|
||||
} from './auth-utils';
|
||||
import {convertPayloadToBase64, ErrorCode} from './utils';
|
||||
import {getMatchedPackagesSpec} from './config-utils';
|
||||
import { convertPayloadToBase64, ErrorCode } from './utils';
|
||||
import { getMatchedPackagesSpec } from './config-utils';
|
||||
|
||||
import type {Config, Logger, Callback, IPluginAuth, RemoteUser, JWTSignOptions, Security} from '@verdaccio/types';
|
||||
import type {$Response, NextFunction} from 'express';
|
||||
import type {$RequestExtend, IAuth} from '../../types';
|
||||
import type { Config, Logger, Callback, IPluginAuth, RemoteUser, JWTSignOptions, Security } from '@verdaccio/types';
|
||||
import type { $Response, NextFunction } from 'express';
|
||||
import type { $RequestExtend, IAuth } from '../../types';
|
||||
|
||||
const LoggerApi = require('./logger');
|
||||
|
||||
|
@ -38,7 +37,7 @@ class Auth implements IAuth {
|
|||
|
||||
constructor(config: Config) {
|
||||
this.config = config;
|
||||
this.logger = LoggerApi.logger.child({sub: 'auth'});
|
||||
this.logger = LoggerApi.logger.child({ sub: 'auth' });
|
||||
this.secret = config.secret;
|
||||
this.plugins = this._loadPlugin(config);
|
||||
this._applyDefaultPlugins();
|
||||
|
@ -51,7 +50,7 @@ class Auth implements IAuth {
|
|||
};
|
||||
|
||||
return loadPlugin(config, config.auth, pluginOptions, (plugin: IPluginAuth) => {
|
||||
const {authenticate, allow_access, allow_publish} = plugin;
|
||||
const { authenticate, allow_access, allow_publish } = plugin;
|
||||
|
||||
return authenticate || allow_access || allow_publish;
|
||||
});
|
||||
|
@ -71,10 +70,10 @@ class Auth implements IAuth {
|
|||
return next();
|
||||
}
|
||||
|
||||
self.logger.trace({username}, 'authenticating @{username}');
|
||||
self.logger.trace({ username }, 'authenticating @{username}');
|
||||
plugin.authenticate(username, password, function(err, groups) {
|
||||
if (err) {
|
||||
self.logger.trace({username, err}, 'authenticating for user @{username} failed. Error: @{err.message}');
|
||||
self.logger.trace({ username, err }, 'authenticating for user @{username} failed. Error: @{err.message}');
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
|
@ -95,7 +94,7 @@ class Auth implements IAuth {
|
|||
throw new TypeError(API_ERROR.BAD_FORMAT_USER_GROUP);
|
||||
}
|
||||
|
||||
self.logger.trace({username, groups}, 'authentication for user @{username} was successfully. Groups: @{groups}');
|
||||
self.logger.trace({ username, groups }, 'authentication for user @{username} was successfully. Groups: @{groups}');
|
||||
return cb(err, createRemoteUser(username, groups));
|
||||
}
|
||||
next();
|
||||
|
@ -106,7 +105,7 @@ class Auth implements IAuth {
|
|||
add_user(user: string, password: string, cb: Callback) {
|
||||
let self = this;
|
||||
let plugins = this.plugins.slice(0);
|
||||
this.logger.trace({user}, 'add user @{user}');
|
||||
this.logger.trace({ user }, 'add user @{user}');
|
||||
|
||||
(function next() {
|
||||
let plugin = plugins.shift();
|
||||
|
@ -120,11 +119,11 @@ class Auth implements IAuth {
|
|||
// p.add_user() execution
|
||||
plugin[method](user, password, function(err, ok) {
|
||||
if (err) {
|
||||
self.logger.trace({user, err}, 'the user @{user} could not being added. Error: @{err}');
|
||||
self.logger.trace({ user, err }, 'the user @{user} could not being added. Error: @{err}');
|
||||
return cb(err);
|
||||
}
|
||||
if (ok) {
|
||||
self.logger.trace({user}, 'the user @{user} has been added');
|
||||
self.logger.trace({ user }, 'the user @{user} has been added');
|
||||
return self.authenticate(user, password, cb);
|
||||
}
|
||||
next();
|
||||
|
@ -139,9 +138,9 @@ class Auth implements IAuth {
|
|||
allow_access(packageName: string, user: RemoteUser, callback: Callback) {
|
||||
let plugins = this.plugins.slice(0);
|
||||
// $FlowFixMe
|
||||
let pkg = Object.assign({name: packageName}, getMatchedPackagesSpec(packageName, this.config.packages));
|
||||
let pkg = Object.assign({ name: packageName }, getMatchedPackagesSpec(packageName, this.config.packages));
|
||||
const self = this;
|
||||
this.logger.trace({packageName}, 'allow access for @{packageName}');
|
||||
this.logger.trace({ packageName }, 'allow access for @{packageName}');
|
||||
|
||||
(function next() {
|
||||
const plugin = plugins.shift();
|
||||
|
@ -152,12 +151,12 @@ class Auth implements IAuth {
|
|||
|
||||
plugin.allow_access(user, pkg, function(err, ok: boolean) {
|
||||
if (err) {
|
||||
self.logger.trace({packageName, err}, 'forbidden access for @{packageName}. Error: @{err.message}');
|
||||
self.logger.trace({ packageName, err }, 'forbidden access for @{packageName}. Error: @{err.message}');
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
self.logger.trace({packageName}, 'allowed access for @{packageName}');
|
||||
self.logger.trace({ packageName }, 'allowed access for @{packageName}');
|
||||
return callback(null, ok);
|
||||
}
|
||||
|
||||
|
@ -173,8 +172,8 @@ class Auth implements IAuth {
|
|||
let plugins = this.plugins.slice(0);
|
||||
const self = this;
|
||||
// $FlowFixMe
|
||||
let pkg = Object.assign({name: packageName}, getMatchedPackagesSpec(packageName, this.config.packages));
|
||||
this.logger.trace({packageName}, 'allow publish for @{packageName}');
|
||||
let pkg = Object.assign({ name: packageName }, getMatchedPackagesSpec(packageName, this.config.packages));
|
||||
this.logger.trace({ packageName }, 'allow publish for @{packageName}');
|
||||
|
||||
(function next() {
|
||||
const plugin = plugins.shift();
|
||||
|
@ -185,12 +184,12 @@ class Auth implements IAuth {
|
|||
|
||||
plugin.allow_publish(user, pkg, (err, ok: boolean) => {
|
||||
if (err) {
|
||||
self.logger.trace({packageName}, 'forbidden publish for @{packageName}');
|
||||
self.logger.trace({ packageName }, 'forbidden publish for @{packageName}');
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
self.logger.trace({packageName}, 'allowed publish for @{packageName}');
|
||||
self.logger.trace({ packageName }, 'allowed publish for @{packageName}');
|
||||
return callback(null, ok);
|
||||
}
|
||||
next(); // cb(null, false) causes next plugin to roll
|
||||
|
@ -221,7 +220,7 @@ class Auth implements IAuth {
|
|||
// in case auth header does not exist we return anonymous function
|
||||
req.remote_user = createAnonymousRemoteUser();
|
||||
|
||||
const {authorization} = req.headers;
|
||||
const { authorization } = req.headers;
|
||||
if (_.isNil(authorization)) {
|
||||
return next();
|
||||
}
|
||||
|
@ -232,7 +231,7 @@ class Auth implements IAuth {
|
|||
}
|
||||
|
||||
const security: Security = getSecurity(this.config);
|
||||
const {secret} = this.config;
|
||||
const { secret } = this.config;
|
||||
|
||||
if (isAESLegacy(security)) {
|
||||
this.logger.trace('api middleware using legacy auth token');
|
||||
|
@ -245,11 +244,11 @@ class Auth implements IAuth {
|
|||
}
|
||||
|
||||
_handleJWTAPIMiddleware(req: $RequestExtend, security: Security, secret: string, authorization: string, next: Function) {
|
||||
const {scheme, token} = parseAuthTokenHeader(authorization);
|
||||
const { scheme, token } = parseAuthTokenHeader(authorization);
|
||||
if (scheme.toUpperCase() === TOKEN_BASIC.toUpperCase()) {
|
||||
// this should happen when client tries to login with an existing user
|
||||
const credentials = convertPayloadToBase64(token).toString();
|
||||
const {user, password} = (parseBasicPayload(credentials): any);
|
||||
const { user, password } = (parseBasicPayload(credentials): any);
|
||||
this.authenticate(user, password, (err, user) => {
|
||||
if (!err) {
|
||||
req.remote_user = user;
|
||||
|
@ -276,7 +275,7 @@ class Auth implements IAuth {
|
|||
_handleAESMiddleware(req: $RequestExtend, security: Security, secret: string, authorization: string, next: Function) {
|
||||
const credentials: any = getMiddlewareCredentials(security, secret, authorization);
|
||||
if (credentials) {
|
||||
const {user, password} = credentials;
|
||||
const { user, password } = credentials;
|
||||
this.authenticate(user, password, (err, user) => {
|
||||
if (!err) {
|
||||
req.remote_user = user;
|
||||
|
@ -316,7 +315,7 @@ class Auth implements IAuth {
|
|||
return _next();
|
||||
};
|
||||
|
||||
const {authorization} = req.headers;
|
||||
const { authorization } = req.headers;
|
||||
if (_.isNil(authorization)) {
|
||||
return next();
|
||||
}
|
||||
|
@ -338,7 +337,7 @@ class Auth implements IAuth {
|
|||
}
|
||||
|
||||
if (credentials) {
|
||||
const {name, groups} = credentials;
|
||||
const { name, groups } = credentials;
|
||||
// $FlowFixMe
|
||||
req.remote_user = createRemoteUser(name, groups);
|
||||
} else {
|
||||
|
@ -350,7 +349,7 @@ class Auth implements IAuth {
|
|||
}
|
||||
|
||||
async jwtEncrypt(user: RemoteUser, signOptions: JWTSignOptions): string {
|
||||
const {real_groups} = user;
|
||||
const { real_groups } = user;
|
||||
const payload: RemoteUser = {
|
||||
...user,
|
||||
group: real_groups && real_groups.length ? real_groups : undefined,
|
||||
|
|
19
src/lib/bootstrap.js
vendored
19
src/lib/bootstrap.js
vendored
|
@ -1,10 +1,9 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import {assign, isObject, isFunction} from 'lodash';
|
||||
import { assign, isObject, isFunction } from 'lodash';
|
||||
import URL from 'url';
|
||||
import fs from 'fs';
|
||||
import http from 'http';
|
||||
|
@ -12,11 +11,11 @@ import https from 'https';
|
|||
// $FlowFixMe
|
||||
import constants from 'constants';
|
||||
import endPointAPI from '../api/index';
|
||||
import {getListListenAddresses, resolveConfigPath} from './cli/utils';
|
||||
import {API_ERROR, certPem, csrPem, keyPem} from './constants';
|
||||
import { getListListenAddresses, resolveConfigPath } from './cli/utils';
|
||||
import { API_ERROR, certPem, csrPem, keyPem } from './constants';
|
||||
|
||||
import type {Callback} from '@verdaccio/types';
|
||||
import type {$Application} from 'express';
|
||||
import type { Callback } from '@verdaccio/types';
|
||||
import type { $Application } from 'express';
|
||||
|
||||
const logger = require('./logger');
|
||||
|
||||
|
@ -114,7 +113,7 @@ function handleHTTPS(app, configPath, config) {
|
|||
return https.createServer(httpsOptions, app);
|
||||
} catch (err) {
|
||||
// catch errors related to certificate loading
|
||||
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');
|
||||
logger.logger.fatal({ err: err }, 'cannot create server: @{err.message}');
|
||||
process.exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ function listenDefaultCallback(webServer: $Application, addr: any, pkgName: stri
|
|||
})
|
||||
// $FlowFixMe
|
||||
.on('error', function(err) {
|
||||
logger.logger.fatal({err: err}, 'cannot create server: @{err.message}');
|
||||
logger.logger.fatal({ err: err }, 'cannot create server: @{err.message}');
|
||||
process.exit(2);
|
||||
});
|
||||
|
||||
|
@ -154,4 +153,4 @@ function listenDefaultCallback(webServer: $Application, addr: any, pkgName: stri
|
|||
);
|
||||
}
|
||||
|
||||
export {startVerdaccio, listenDefaultCallback};
|
||||
export { startVerdaccio, listenDefaultCallback };
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import path from 'path';
|
||||
|
||||
import {parseAddress} from '../utils';
|
||||
import {DEFAULT_PORT} from '../constants';
|
||||
import { parseAddress } from '../utils';
|
||||
import { DEFAULT_PORT } from '../constants';
|
||||
|
||||
const logger = require('../logger');
|
||||
|
||||
|
@ -44,7 +43,7 @@ export function getListListenAddresses(argListen: string, configListen: mixed) {
|
|||
|
||||
if (!parsedAddr) {
|
||||
logger.logger.warn(
|
||||
{addr: addr},
|
||||
{ addr: addr },
|
||||
'invalid address - @{addr}, we expect a port (e.g. "4873"),' + ' host:port (e.g. "localhost:4873") or full url' + ' (e.g. "http://localhost:4873/")'
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import fs from 'fs';
|
||||
import _ from 'lodash';
|
||||
import Path from 'path';
|
||||
import logger from './logger';
|
||||
import mkdirp from 'mkdirp';
|
||||
|
||||
import {folderExists, fileExists} from './utils';
|
||||
import {CHARACTER_ENCODING} from './constants';
|
||||
import { folderExists, fileExists } from './utils';
|
||||
import { CHARACTER_ENCODING } from './constants';
|
||||
|
||||
const CONFIG_FILE = 'config.yaml';
|
||||
const XDG = 'xdg';
|
||||
|
@ -58,7 +57,7 @@ function readDefaultConfig() {
|
|||
|
||||
function createConfigFolder(configLocation) {
|
||||
mkdirp.sync(Path.dirname(configLocation.path));
|
||||
logger.logger.info({file: configLocation.path}, 'Creating default config file in @{file}');
|
||||
logger.logger.info({ file: configLocation.path }, 'Creating default config file in @{file}');
|
||||
}
|
||||
|
||||
function updateStorageLinks(configLocation, defaultConfig) {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
import _ from 'lodash';
|
||||
import assert from 'assert';
|
||||
import minimatch from 'minimatch';
|
||||
|
||||
import {ErrorCode} from './utils';
|
||||
import { ErrorCode } from './utils';
|
||||
|
||||
import type {PackageList, UpLinksConfList} from '@verdaccio/types';
|
||||
import type {MatchedPackage} from '../../types';
|
||||
import type { PackageList, UpLinksConfList } from '@verdaccio/types';
|
||||
import type { MatchedPackage } from '../../types';
|
||||
|
||||
const BLACKLIST = {
|
||||
all: true,
|
||||
|
@ -108,10 +108,10 @@ export function getMatchedPackagesSpec(pkgName: string, packages: PackageList):
|
|||
}
|
||||
|
||||
export function normalisePackageAccess(packages: PackageList): PackageList {
|
||||
const normalizedPkgs: PackageList = {...packages};
|
||||
const normalizedPkgs: PackageList = { ...packages };
|
||||
// add a default rule for all packages to make writing plugins easier
|
||||
if (_.isNil(normalizedPkgs['**'])) {
|
||||
normalizedPkgs['**'] = {access: [], publish: []};
|
||||
normalizedPkgs['**'] = { access: [], publish: [] };
|
||||
}
|
||||
|
||||
for (let pkg in packages) {
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import assert from 'assert';
|
||||
|
||||
import {generateRandomHexString} from './crypto-utils';
|
||||
import {getMatchedPackagesSpec, normalisePackageAccess, sanityCheckUplinksProps, uplinkSanityCheck} from './config-utils';
|
||||
import {getUserAgent, isObject} from './utils';
|
||||
import {APP_ERROR} from './constants';
|
||||
import { generateRandomHexString } from './crypto-utils';
|
||||
import { getMatchedPackagesSpec, normalisePackageAccess, sanityCheckUplinksProps, uplinkSanityCheck } from './config-utils';
|
||||
import { getUserAgent, isObject } from './utils';
|
||||
import { APP_ERROR } from './constants';
|
||||
|
||||
import type {PackageList, Config as AppConfig, Security, Logger} from '@verdaccio/types';
|
||||
import type { PackageList, Config as AppConfig, Security, Logger } from '@verdaccio/types';
|
||||
|
||||
import type {MatchedPackage, StartUpConfig} from '../../types';
|
||||
import type { MatchedPackage, StartUpConfig } from '../../types';
|
||||
|
||||
const LoggerApi = require('./logger');
|
||||
const strategicConfigProps = ['uplinks', 'packages'];
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import {createDecipher, createCipher, createHash, pseudoRandomBytes} from 'crypto';
|
||||
import { createDecipher, createCipher, createHash, pseudoRandomBytes } from 'crypto';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
import type {JWTSignOptions, RemoteUser} from '@verdaccio/types';
|
||||
import type { JWTSignOptions, RemoteUser } from '@verdaccio/types';
|
||||
|
||||
export const defaultAlgorithm = 'aes192';
|
||||
export const defaultTarballHashAlgorithm = 'sha1';
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
/* eslint prefer-rest-params: 0 */
|
||||
|
||||
import assert from 'assert';
|
||||
import UrlNode from 'url';
|
||||
import _ from 'lodash';
|
||||
// $FlowFixMe
|
||||
import {ErrorCode, isObject, getLatestVersion, tagVersion, validateName, DIST_TAGS} from './utils';
|
||||
import { ErrorCode, isObject, getLatestVersion, tagVersion, validateName, DIST_TAGS } from './utils';
|
||||
import {
|
||||
generatePackageTemplate,
|
||||
normalizePackage,
|
||||
|
@ -23,16 +22,16 @@ import {
|
|||
DEFAULT_REVISION,
|
||||
pkgFileName,
|
||||
} from './storage-utils';
|
||||
import {createTarballHash} from './crypto-utils';
|
||||
import {prepareSearchPackage} from './storage-utils';
|
||||
import { createTarballHash } from './crypto-utils';
|
||||
import { prepareSearchPackage } from './storage-utils';
|
||||
import loadPlugin from '../lib/plugin-loader';
|
||||
import LocalDatabase from '@verdaccio/local-storage';
|
||||
import {UploadTarball, ReadTarball} from '@verdaccio/streams';
|
||||
import type {Package, Config, MergeTags, Version, DistFile, Callback, Logger} from '@verdaccio/types';
|
||||
import type {ILocalData, IPackageStorage} from '@verdaccio/local-storage';
|
||||
import type {IUploadTarball, IReadTarball} from '@verdaccio/streams';
|
||||
import type {IStorage, StringValue} from '../../types';
|
||||
import {API_ERROR} from './constants';
|
||||
import { UploadTarball, ReadTarball } from '@verdaccio/streams';
|
||||
import type { Package, Config, MergeTags, Version, DistFile, Callback, Logger } from '@verdaccio/types';
|
||||
import type { ILocalData, IPackageStorage } from '@verdaccio/local-storage';
|
||||
import type { IUploadTarball, IReadTarball } from '@verdaccio/streams';
|
||||
import type { IStorage, StringValue } from '../../types';
|
||||
import { API_ERROR } from './constants';
|
||||
|
||||
/**
|
||||
* Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).
|
||||
|
@ -43,7 +42,7 @@ class LocalStorage implements IStorage {
|
|||
logger: Logger;
|
||||
|
||||
constructor(config: Config, logger: Logger) {
|
||||
this.logger = logger.child({sub: 'fs'});
|
||||
this.logger = logger.child({ sub: 'fs' });
|
||||
this.config = config;
|
||||
this.localData = this._loadStorage(config, logger);
|
||||
}
|
||||
|
@ -190,7 +189,7 @@ class LocalStorage implements IStorage {
|
|||
}
|
||||
|
||||
if (change) {
|
||||
this.logger.debug({name}, 'updating package @{name} info');
|
||||
this.logger.debug({ name }, 'updating package @{name} info');
|
||||
this._writePackage(name, packageLocalJson, function(err) {
|
||||
callback(err, packageLocalJson);
|
||||
});
|
||||
|
@ -335,7 +334,7 @@ class LocalStorage implements IStorage {
|
|||
(localData, cb) => {
|
||||
for (let version in localData.versions) {
|
||||
if (_.isNil(incomingPkg.versions[version])) {
|
||||
this.logger.info({name: name, version: version}, 'unpublishing @{name}@@{version}');
|
||||
this.logger.info({ name: name, version: version }, 'unpublishing @{name}@@{version}');
|
||||
|
||||
delete localData.versions[version];
|
||||
delete localData.time[version];
|
||||
|
@ -586,7 +585,7 @@ class LocalStorage implements IStorage {
|
|||
* @return {Function}
|
||||
*/
|
||||
search(startKey: string, options: any) {
|
||||
const stream = new ReadTarball({objectMode: true});
|
||||
const stream = new ReadTarball({ objectMode: true });
|
||||
|
||||
this._searchEachPackage(
|
||||
(item, cb) => {
|
||||
|
@ -653,7 +652,7 @@ class LocalStorage implements IStorage {
|
|||
storages[this.config.storage] = true;
|
||||
}
|
||||
|
||||
const {packages} = this.config;
|
||||
const { packages } = this.config;
|
||||
|
||||
if (packages) {
|
||||
const listPackagesConf = Object.keys(packages || {});
|
||||
|
@ -721,7 +720,7 @@ class LocalStorage implements IStorage {
|
|||
* @return {Object} Error instance
|
||||
*/
|
||||
_internalError(err: string, file: string, message: string) {
|
||||
this.logger.error({err: err, file: file}, `${message} @{file}: @{!err.message}`);
|
||||
this.logger.error({ err: err, file: file }, `${message} @{file}: @{!err.message}`);
|
||||
|
||||
return ErrorCode.getInternalError();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const chalk = require('chalk');
|
|||
const Utils = require('./utils');
|
||||
const pkgJSON = require('../../package.json');
|
||||
const _ = require('lodash');
|
||||
const {format} = require('date-fns');
|
||||
const { format } = require('date-fns');
|
||||
|
||||
/**
|
||||
* Match the level based on buyan severity scale
|
||||
|
@ -43,7 +43,7 @@ class VerdaccioRotatingFileStream extends Logger.RotatingFileStream {
|
|||
// We depend on mv so that this is there
|
||||
write(obj) {
|
||||
const msg = fillInMsgTemplate(obj.msg, obj, false);
|
||||
super.write(JSON.stringify({...obj, msg}, Logger.safeCycles()) + '\n');
|
||||
super.write(JSON.stringify({ ...obj, msg }, Logger.safeCycles()) + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class VerdaccioRotatingFileStream extends Logger.RotatingFileStream {
|
|||
function setup(logs) {
|
||||
let streams = [];
|
||||
if (logs == null) {
|
||||
logs = [{type: 'stdout', format: 'pretty', level: 'http'}];
|
||||
logs = [{ type: 'stdout', format: 'pretty', level: 'http' }];
|
||||
}
|
||||
|
||||
logs.forEach(function(target) {
|
||||
|
@ -78,7 +78,7 @@ function setup(logs) {
|
|||
{},
|
||||
// Defaults can be found here: https://github.com/trentm/node-bunyan#stream-type-rotating-file
|
||||
target.options || {},
|
||||
{path: target.path, level}
|
||||
{ path: target.path, level }
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -95,7 +95,7 @@ function setup(logs) {
|
|||
let destinationIsTTY = false;
|
||||
if (target.type === 'file') {
|
||||
// destination stream
|
||||
destination = require('fs').createWriteStream(target.path, {flags: 'a', encoding: 'utf8'});
|
||||
destination = require('fs').createWriteStream(target.path, { flags: 'a', encoding: 'utf8' });
|
||||
destination.on('error', function(err) {
|
||||
stream.emit('error', err);
|
||||
});
|
||||
|
@ -119,7 +119,7 @@ function setup(logs) {
|
|||
} else {
|
||||
stream.write = obj => {
|
||||
const msg = fillInMsgTemplate(obj.msg, obj, destinationIsTTY);
|
||||
destination.write(`${JSON.stringify({...obj, msg}, Logger.safeCycles())}\n`);
|
||||
destination.write(`${JSON.stringify({ ...obj, msg }, Logger.safeCycles())}\n`);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import semver from 'semver';
|
||||
import _ from 'lodash';
|
||||
import {DIST_TAGS} from './utils';
|
||||
import { DIST_TAGS } from './utils';
|
||||
|
||||
import type {Package} from '@verdaccio/types';
|
||||
import type { Package } from '@verdaccio/types';
|
||||
|
||||
/**
|
||||
* Function gets a local info and an info from uplinks and tries to merge it
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import Handlebars from 'handlebars';
|
||||
import _ from 'lodash';
|
||||
|
||||
import {notifyRequest} from './notify-request';
|
||||
import { notifyRequest } from './notify-request';
|
||||
|
||||
export function handleNotify(metadata, notifyEntry, publisherInfo, publishedPackage) {
|
||||
let regex;
|
||||
|
@ -20,7 +20,7 @@ export function handleNotify(metadata, notifyEntry, publisherInfo, publishedPack
|
|||
|
||||
// don't override 'publisher' if package.json already has that
|
||||
if (!metadata.publisher) {
|
||||
metadata = {...metadata, publishedPackage, publisher: publisherInfo};
|
||||
metadata = { ...metadata, publishedPackage, publisher: publisherInfo };
|
||||
}
|
||||
const content = template(metadata);
|
||||
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
import isNil from 'lodash/isNil';
|
||||
import logger from '../logger';
|
||||
import request from 'request';
|
||||
import {HTTP_STATUS} from '../constants';
|
||||
import { HTTP_STATUS } from '../constants';
|
||||
|
||||
export function notifyRequest(options, content) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(options, function(err, response, body) {
|
||||
if (err || response.statusCode >= HTTP_STATUS.BAD_REQUEST) {
|
||||
const errorMessage = isNil(err) ? response.body : err.message;
|
||||
logger.logger.error({errorMessage}, 'notify service has thrown an error: @{errorMessage}');
|
||||
logger.logger.error({ errorMessage }, 'notify service has thrown an error: @{errorMessage}');
|
||||
|
||||
reject(errorMessage);
|
||||
} else {
|
||||
logger.logger.info({content}, 'A notification has been shipped: @{content}');
|
||||
logger.logger.info({ content }, 'A notification has been shipped: @{content}');
|
||||
if (isNil(body) === false) {
|
||||
const bodyResolved = isNil(body) === false ? body : null;
|
||||
|
||||
logger.logger.debug({body}, ' body: @{body}');
|
||||
logger.logger.debug({ body }, ' body: @{body}');
|
||||
return resolve(bodyResolved);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import Path from 'path';
|
||||
import _ from 'lodash';
|
||||
import logger from './logger';
|
||||
import type {Config} from '@verdaccio/types';
|
||||
import {MODULE_NOT_FOUND} from './constants';
|
||||
import type { Config } from '@verdaccio/types';
|
||||
import { MODULE_NOT_FOUND } from './constants';
|
||||
|
||||
/**
|
||||
* Requires a module.
|
||||
|
@ -91,12 +90,12 @@ export default function loadPlugin<T>(config: Config, pluginConfigs: any = {}, p
|
|||
}
|
||||
|
||||
if (plugin === null) {
|
||||
logger.logger.error({content: pluginId}, 'plugin not found. try npm install verdaccio-@{content}');
|
||||
logger.logger.error({ content: pluginId }, 'plugin not found. try npm install verdaccio-@{content}');
|
||||
throw Error('"' + pluginId + '" plugin not found\ntry "npm install verdaccio-' + pluginId + '"');
|
||||
}
|
||||
|
||||
if (!isValid(plugin)) {
|
||||
logger.logger.error({content: pluginId}, "@{content} doesn't look like a valid plugin");
|
||||
logger.logger.error({ content: pluginId }, "@{content} doesn't look like a valid plugin");
|
||||
throw Error('"' + pluginId + '" doesn\'t look like a valid plugin');
|
||||
}
|
||||
/* eslint new-cap:off */
|
||||
|
@ -104,10 +103,10 @@ export default function loadPlugin<T>(config: Config, pluginConfigs: any = {}, p
|
|||
/* eslint new-cap:off */
|
||||
|
||||
if (plugin === null || !sanityCheck(plugin)) {
|
||||
logger.logger.error({content: pluginId}, "@{content} doesn't look like a valid plugin");
|
||||
logger.logger.error({ content: pluginId }, "@{content} doesn't look like a valid plugin");
|
||||
throw Error('"' + pluginId + '" doesn\'t look like a valid plugin');
|
||||
}
|
||||
logger.logger.warn({content: pluginId}, 'Plugin successfully loaded: @{content}');
|
||||
logger.logger.warn({ content: pluginId }, 'Plugin successfully loaded: @{content}');
|
||||
return plugin;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import lunrMutable from 'lunr-mutable-indexes';
|
||||
import type {Version} from '@verdaccio/types';
|
||||
import type {IStorageHandler, IWebSearch} from '../../types';
|
||||
import type { Version } from '@verdaccio/types';
|
||||
import type { IStorageHandler, IWebSearch } from '../../types';
|
||||
/**
|
||||
* Handle the search Indexer.
|
||||
*/
|
||||
|
@ -20,10 +19,10 @@ class Search implements IWebSearch {
|
|||
constructor() {
|
||||
/* eslint no-invalid-this: "off" */
|
||||
this.index = lunrMutable(function() {
|
||||
this.field('name', {boost: 10});
|
||||
this.field('description', {boost: 4});
|
||||
this.field('author', {boost: 6});
|
||||
this.field('keywords', {boost: 7});
|
||||
this.field('name', { boost: 10 });
|
||||
this.field('description', { boost: 4 });
|
||||
this.field('author', { boost: 6 });
|
||||
this.field('keywords', { boost: 7 });
|
||||
this.field('version');
|
||||
this.field('readme');
|
||||
});
|
||||
|
@ -40,7 +39,7 @@ class Search implements IWebSearch {
|
|||
return query === '*'
|
||||
? this.storage.localStorage.localData.get(items => {
|
||||
items.map(function(pkg) {
|
||||
return {ref: pkg, score: 1};
|
||||
return { ref: pkg, score: 1 };
|
||||
});
|
||||
})
|
||||
: this.index.search(`*${query}*`);
|
||||
|
@ -66,7 +65,7 @@ class Search implements IWebSearch {
|
|||
* @param {*} name the id element
|
||||
*/
|
||||
remove(name: string) {
|
||||
this.index.remove({id: name});
|
||||
this.index.remove({ id: name });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import {ErrorCode, isObject, normalizeDistTags, DIST_TAGS, semverSort} from './utils';
|
||||
import { ErrorCode, isObject, normalizeDistTags, DIST_TAGS, semverSort } from './utils';
|
||||
import Search from './search';
|
||||
import {generateRandomHexString} from '../lib/crypto-utils';
|
||||
import { generateRandomHexString } from '../lib/crypto-utils';
|
||||
|
||||
import type {Package, Version, Author} from '@verdaccio/types';
|
||||
import type {IStorage} from '../../types';
|
||||
import {API_ERROR, HTTP_STATUS} from './constants';
|
||||
import type { Package, Version, Author } from '@verdaccio/types';
|
||||
import type { IStorage } from '../../types';
|
||||
import { API_ERROR, HTTP_STATUS } from './constants';
|
||||
|
||||
const pkgFileName = 'package.json';
|
||||
const fileExist: string = 'EEXISTS';
|
||||
|
@ -200,7 +199,7 @@ export function prepareSearchPackage(data: Package, time: mixed) {
|
|||
const pkg: any = {
|
||||
name: version.name,
|
||||
description: version.description,
|
||||
[DIST_TAGS]: {latest},
|
||||
[DIST_TAGS]: { latest },
|
||||
maintainers: version.maintainers || [version.author].filter(Boolean),
|
||||
author: version.author,
|
||||
repository: version.repository,
|
||||
|
@ -212,11 +211,11 @@ export function prepareSearchPackage(data: Package, time: mixed) {
|
|||
time: {
|
||||
modified: time,
|
||||
},
|
||||
versions: {[latest]: 'latest'},
|
||||
versions: { [latest]: 'latest' },
|
||||
};
|
||||
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
|
||||
export {generatePackageTemplate, normalizePackage, generateRevision, getLatestReadme, cleanUpReadme, fileExist, noSuchFile, pkgFileName};
|
||||
export { generatePackageTemplate, normalizePackage, generateRevision, getLatestReadme, cleanUpReadme, fileExist, noSuchFile, pkgFileName };
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import assert from 'assert';
|
||||
import async from 'async';
|
||||
import Stream from 'stream';
|
||||
import ProxyStorage from './up-storage';
|
||||
import Search from './search';
|
||||
import {API_ERROR, HTTP_STATUS} from './constants';
|
||||
import { API_ERROR, HTTP_STATUS } from './constants';
|
||||
import LocalStorage from './local-storage';
|
||||
import {ReadTarball} from '@verdaccio/streams';
|
||||
import {checkPackageLocal, publishPackage, checkPackageRemote, cleanUpLinksRef, mergeUplinkTimeIntoLocal, generatePackageTemplate} from './storage-utils';
|
||||
import {setupUpLinks, updateVersionsHiddenUpLink} from './uplink-util';
|
||||
import {mergeVersions} from './metadata-utils';
|
||||
import {ErrorCode, normalizeDistTags, validateMetadata, isObject, DIST_TAGS} from './utils';
|
||||
import type {IStorage, IProxy, IStorageHandler, ProxyList, StringValue} from '../../types';
|
||||
import type {Versions, Package, Config, MergeTags, Version, DistFile, Callback, Logger} from '@verdaccio/types';
|
||||
import type {IReadTarball, IUploadTarball} from '@verdaccio/streams';
|
||||
import {hasProxyTo} from './config-utils';
|
||||
import { ReadTarball } from '@verdaccio/streams';
|
||||
import { checkPackageLocal, publishPackage, checkPackageRemote, cleanUpLinksRef, mergeUplinkTimeIntoLocal, generatePackageTemplate } from './storage-utils';
|
||||
import { setupUpLinks, updateVersionsHiddenUpLink } from './uplink-util';
|
||||
import { mergeVersions } from './metadata-utils';
|
||||
import { ErrorCode, normalizeDistTags, validateMetadata, isObject, DIST_TAGS } from './utils';
|
||||
import type { IStorage, IProxy, IStorageHandler, ProxyList, StringValue } from '../../types';
|
||||
import type { Versions, Package, Config, MergeTags, Version, DistFile, Callback, Logger } from '@verdaccio/types';
|
||||
import type { IReadTarball, IUploadTarball } from '@verdaccio/streams';
|
||||
import { hasProxyTo } from './config-utils';
|
||||
|
||||
const LoggerApi = require('../lib/logger');
|
||||
|
||||
|
@ -241,7 +240,7 @@ class Storage implements IStorageHandler {
|
|||
});
|
||||
|
||||
savestream.on('error', function(err) {
|
||||
self.logger.warn({err: err, fileName: file}, 'error saving file @{fileName}: @{err.message}\n@{err.stack}');
|
||||
self.logger.warn({ err: err, fileName: file }, 'error saving file @{fileName}: @{err.message}\n@{err.stack}');
|
||||
if (savestream) {
|
||||
savestream.abort();
|
||||
}
|
||||
|
@ -274,7 +273,7 @@ class Storage implements IStorageHandler {
|
|||
return options.callback(err);
|
||||
}
|
||||
|
||||
this._syncUplinksMetadata(options.name, data, {req: options.req}, function getPackageSynUpLinksCallback(err, result: Package, uplinkErrors) {
|
||||
this._syncUplinksMetadata(options.name, data, { req: options.req }, function getPackageSynUpLinksCallback(err, result: Package, uplinkErrors) {
|
||||
if (err) {
|
||||
return options.callback(err);
|
||||
}
|
||||
|
@ -304,7 +303,7 @@ class Storage implements IStorageHandler {
|
|||
search(startkey: string, options: any) {
|
||||
let self = this;
|
||||
// stream to write a tarball
|
||||
let stream: any = new Stream.PassThrough({objectMode: true});
|
||||
let stream: any = new Stream.PassThrough({ objectMode: true });
|
||||
|
||||
async.eachSeries(
|
||||
Object.keys(this.uplinks),
|
||||
|
@ -318,10 +317,10 @@ class Storage implements IStorageHandler {
|
|||
// join streams
|
||||
lstream.pipe(
|
||||
stream,
|
||||
{end: false}
|
||||
{ end: false }
|
||||
);
|
||||
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() {});
|
||||
});
|
||||
lstream.on('end', function() {
|
||||
|
@ -344,10 +343,10 @@ class Storage implements IStorageHandler {
|
|||
};
|
||||
lstream.pipe(
|
||||
stream,
|
||||
{end: true}
|
||||
{ end: true }
|
||||
);
|
||||
lstream.on('error', function(err) {
|
||||
self.logger.error({err: err}, 'search error: @{err.message}');
|
||||
self.logger.error({ err: err }, 'search error: @{err.message}');
|
||||
stream.end();
|
||||
});
|
||||
}
|
||||
|
@ -380,7 +379,7 @@ class Storage implements IStorageHandler {
|
|||
|
||||
packages.push(version);
|
||||
} else {
|
||||
self.logger.warn({package: locals[itemPkg]}, 'package @{package} does not have a "latest" tag?');
|
||||
self.logger.warn({ package: locals[itemPkg] }, 'package @{package} does not have a "latest" tag?');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import zlib from 'zlib';
|
||||
import JSONStream from 'JSONStream';
|
||||
import _ from 'lodash';
|
||||
import request from 'request';
|
||||
import Stream from 'stream';
|
||||
import URL from 'url';
|
||||
import {parseInterval, isObject, ErrorCode, buildToken} from './utils';
|
||||
import {ReadTarball} from '@verdaccio/streams';
|
||||
import {ERROR_CODE, TOKEN_BASIC, TOKEN_BEARER, HEADERS, HTTP_STATUS, API_ERROR, HEADER_TYPE, CHARACTER_ENCODING} from './constants';
|
||||
import type {Config, UpLinkConf, Callback, Headers, Logger} from '@verdaccio/types';
|
||||
import type {IProxy} from '../../types';
|
||||
import { parseInterval, isObject, ErrorCode, buildToken } from './utils';
|
||||
import { ReadTarball } from '@verdaccio/streams';
|
||||
import { ERROR_CODE, TOKEN_BASIC, TOKEN_BEARER, HEADERS, HTTP_STATUS, API_ERROR, HEADER_TYPE, CHARACTER_ENCODING } from './constants';
|
||||
import type { Config, UpLinkConf, Callback, Headers, Logger } from '@verdaccio/types';
|
||||
import type { IProxy } from '../../types';
|
||||
|
||||
const LoggerApi = require('./logger');
|
||||
const encode = function(thing) {
|
||||
|
@ -65,7 +64,7 @@ class ProxyStorage implements IProxy {
|
|||
this.failed_requests = 0;
|
||||
this.userAgent = mainConfig.user_agent;
|
||||
this.ca = config.ca;
|
||||
this.logger = LoggerApi.logger.child({sub: 'out'});
|
||||
this.logger = LoggerApi.logger.child({ sub: 'out' });
|
||||
this.server_id = mainConfig.server_id;
|
||||
|
||||
this.url = URL.parse(this.config.url);
|
||||
|
@ -187,7 +186,7 @@ class ProxyStorage implements IProxy {
|
|||
self.logger.warn(
|
||||
{
|
||||
err: err || undefined, // if error is null/false change this to undefined so it wont log
|
||||
request: {method: method, url: uri},
|
||||
request: { method: method, url: uri },
|
||||
level: 35, // http
|
||||
status: res != null ? res.statusCode : 'ERR',
|
||||
error: error,
|
||||
|
@ -278,7 +277,7 @@ class ProxyStorage implements IProxy {
|
|||
* @private
|
||||
*/
|
||||
_setAuth(headers: any) {
|
||||
const {auth} = this.config;
|
||||
const { auth } = this.config;
|
||||
|
||||
if (_.isNil(auth) || headers['authorization']) {
|
||||
return headers;
|
||||
|
@ -494,7 +493,7 @@ class ProxyStorage implements IProxy {
|
|||
* @return {Stream}
|
||||
*/
|
||||
search(options: any) {
|
||||
const transformStream: any = new Stream.PassThrough({objectMode: true});
|
||||
const transformStream: any = new Stream.PassThrough({ objectMode: true });
|
||||
const requestStream: stream$Readable = this.request({
|
||||
uri: options.req.url,
|
||||
req: options.req,
|
||||
|
@ -650,7 +649,7 @@ class ProxyStorage implements IProxy {
|
|||
if (noProxyItem[0] !== '.') noProxyItem = '.' + noProxyItem;
|
||||
if (hostname.lastIndexOf(noProxyItem) === hostname.length - noProxyItem.length) {
|
||||
if (this.proxy) {
|
||||
this.logger.debug({url: this.url.href, rule: noProxyItem}, 'not using proxy for @{url}, excluded by @{rule} rule');
|
||||
this.logger.debug({ url: this.url.href, rule: noProxyItem }, 'not using proxy for @{url}, excluded by @{rule} rule');
|
||||
// $FlowFixMe
|
||||
this.proxy = false;
|
||||
}
|
||||
|
@ -663,7 +662,7 @@ class ProxyStorage implements IProxy {
|
|||
if (_.isString(this.proxy) === false) {
|
||||
delete this.proxy;
|
||||
} else {
|
||||
this.logger.debug({url: this.url.href, proxy: this.proxy}, 'using proxy @{proxy} for @{url}');
|
||||
this.logger.debug({ url: this.url.href, proxy: this.proxy }, 'using proxy @{proxy} for @{url}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import request from 'request';
|
||||
import semver from 'semver';
|
||||
import chalk from 'chalk';
|
||||
import _ from 'lodash';
|
||||
|
||||
import {UPDATE_BANNER, DEFAULT_REGISTRY, HTTP_STATUS} from './constants';
|
||||
import { UPDATE_BANNER, DEFAULT_REGISTRY, HTTP_STATUS } from './constants';
|
||||
|
||||
const VERDACCIO_LATEST_REGISTRY_URL = `${DEFAULT_REGISTRY}/verdaccio/latest`;
|
||||
|
||||
|
@ -47,7 +46,7 @@ export function verdaccioUpdateBanner(pkgVersion: string) {
|
|||
if (!error && response.statusCode === HTTP_STATUS.OK && response.body) {
|
||||
// In case, NPM does not returns version, keeping version equals to
|
||||
// verdaccio version.
|
||||
const {version = pkgVersion} = JSON.parse(response.body);
|
||||
const { version = pkgVersion } = JSON.parse(response.body);
|
||||
const releaseType = semver.diff(version, pkgVersion);
|
||||
|
||||
if (releaseType && semver.gt(version, pkgVersion)) {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import ProxyStorage from './up-storage';
|
||||
import type {Versions, Config} from '@verdaccio/types';
|
||||
import type {IProxy, ProxyList} from '../../types';
|
||||
import type { Versions, Config } from '@verdaccio/types';
|
||||
import type { IProxy, ProxyList } from '../../types';
|
||||
|
||||
/**
|
||||
* Set up the Up Storage for each link.
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import _ from 'lodash';
|
||||
import fs from 'fs';
|
||||
import assert from 'assert';
|
||||
|
@ -13,13 +12,13 @@ import URL from 'url';
|
|||
import createError from 'http-errors';
|
||||
import marked from 'marked';
|
||||
|
||||
import {HTTP_STATUS, API_ERROR, DEFAULT_PORT, DEFAULT_DOMAIN, DEFAULT_PROTOCOL, CHARACTER_ENCODING, HEADERS} from './constants';
|
||||
import {generateGravatarUrl, GRAVATAR_DEFAULT} from '../utils/user';
|
||||
import { HTTP_STATUS, API_ERROR, DEFAULT_PORT, DEFAULT_DOMAIN, DEFAULT_PROTOCOL, CHARACTER_ENCODING, HEADERS } from './constants';
|
||||
import { generateGravatarUrl, GRAVATAR_DEFAULT } from '../utils/user';
|
||||
|
||||
import type {Package} from '@verdaccio/types';
|
||||
import type {$Request} from 'express';
|
||||
import type {StringValue} from '../../types';
|
||||
import {normalizeContributors} from './storage-utils';
|
||||
import type { Package } from '@verdaccio/types';
|
||||
import type { $Request } from 'express';
|
||||
import type { StringValue } from '../../types';
|
||||
import { normalizeContributors } from './storage-utils';
|
||||
|
||||
const Logger = require('./logger');
|
||||
const pkginfo = require('pkginfo')(module); // eslint-disable-line no-unused-vars
|
||||
|
@ -258,7 +257,7 @@ export function semverSort(listVersions: Array<string>): string[] {
|
|||
return listVersions
|
||||
.filter(function(x) {
|
||||
if (!semver.parse(x, true)) {
|
||||
Logger.logger.warn({ver: x}, 'ignoring bad version @{ver}');
|
||||
Logger.logger.warn({ ver: x }, 'ignoring bad version @{ver}');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -436,7 +435,7 @@ export function deleteProperties(propertiesToDelete: Array<string>, objectItem:
|
|||
}
|
||||
|
||||
export function addGravatarSupport(pkgInfo: Object): Object {
|
||||
const pkgInfoCopy = {...pkgInfo};
|
||||
const pkgInfoCopy = { ...pkgInfo };
|
||||
const author = _.get(pkgInfo, 'latest.author', null);
|
||||
const contributors = normalizeContributors(_.get(pkgInfo, 'latest.contributors', []));
|
||||
const maintainers = _.get(pkgInfo, 'latest.maintainers', []);
|
||||
|
@ -495,7 +494,7 @@ export function parseReadme(packageName: string, readme: string): string {
|
|||
}
|
||||
|
||||
// logs readme not found error
|
||||
Logger.logger.error({packageName}, '@{packageName}: No readme found');
|
||||
Logger.logger.error({ packageName }, '@{packageName}: No readme found');
|
||||
|
||||
return marked('ERROR: No README data found!');
|
||||
}
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import FileCopy from '@material-ui/icons/FileCopy';
|
||||
import Tooltip from '@material-ui/core/Tooltip/index';
|
||||
|
||||
import type {Node} from 'react';
|
||||
import {IProps} from './interfaces';
|
||||
import type { Node } from 'react';
|
||||
import { IProps } from './interfaces';
|
||||
|
||||
import {ClipBoardCopy, ClipBoardCopyText, CopyIcon} from './styles';
|
||||
import { ClipBoardCopy, ClipBoardCopyText, CopyIcon } from './styles';
|
||||
|
||||
const copyToClipBoardUtility = (str: string) => (event: SyntheticEvent<HTMLElement>) => {
|
||||
event.preventDefault();
|
||||
|
@ -28,7 +29,7 @@ const copyToClipBoardUtility = (str: string) => (event: SyntheticEvent<HTMLEleme
|
|||
}
|
||||
};
|
||||
|
||||
const CopyToClipBoard = ({text}: IProps): Node => (
|
||||
const CopyToClipBoard = ({ text }: IProps): Node => (
|
||||
<ClipBoardCopy>
|
||||
<ClipBoardCopyText>{text}</ClipBoardCopyText>
|
||||
<Tooltip title="Copy to Clipboard" disableFocusListener>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @flow
|
||||
*/
|
||||
|
||||
import React, {Component} from 'react';
|
||||
import React, { Component } from 'react';
|
||||
import Button from '@material-ui/core/Button/index';
|
||||
import IconButton from '@material-ui/core/IconButton/index';
|
||||
import MenuItem from '@material-ui/core/MenuItem/index';
|
||||
|
@ -13,15 +13,15 @@ import Help from '@material-ui/icons/Help';
|
|||
import Tooltip from '@material-ui/core/Tooltip/index';
|
||||
import AccountCircle from '@material-ui/icons/AccountCircle';
|
||||
|
||||
import {getRegistryURL} from '../../utils/url';
|
||||
import { getRegistryURL } from '../../utils/url';
|
||||
import Link from '../Link';
|
||||
import Logo from '../Logo';
|
||||
import CopyToClipBoard from '../CopyToClipBoard/index';
|
||||
import RegistryInfoDialog from '../RegistryInfoDialog';
|
||||
|
||||
import type {Node} from 'react';
|
||||
import {IProps, IState} from './interfaces';
|
||||
import {Wrapper, InnerWrapper} from './styles';
|
||||
import type { Node } from 'react';
|
||||
import { IProps, IState } from './interfaces';
|
||||
import { Wrapper, InnerWrapper } from './styles';
|
||||
|
||||
class Header extends Component<IProps, IState> {
|
||||
handleLoggedInMenu: Function;
|
||||
|
@ -109,7 +109,7 @@ class Header extends Component<IProps, IState> {
|
|||
}
|
||||
|
||||
renderRightSide(): Node {
|
||||
const {username = ''} = this.props;
|
||||
const { username = '' } = this.props;
|
||||
const installationLink = 'https://verdaccio.org/docs/en/installation';
|
||||
return (
|
||||
<div>
|
||||
|
@ -138,8 +138,8 @@ class Header extends Component<IProps, IState> {
|
|||
* render popover menu
|
||||
*/
|
||||
renderMenu(): Node {
|
||||
const {handleLogout} = this.props;
|
||||
const {anchorEl} = this.state;
|
||||
const { handleLogout } = this.props;
|
||||
const { anchorEl } = this.state;
|
||||
const open = Boolean(anchorEl);
|
||||
return (
|
||||
<React.Fragment>
|
||||
|
@ -169,8 +169,8 @@ class Header extends Component<IProps, IState> {
|
|||
}
|
||||
|
||||
renderInfoDialog(): Node {
|
||||
const {scope} = this.props;
|
||||
const {openInfoDialog, registryUrl} = this.state;
|
||||
const { scope } = this.props;
|
||||
const { openInfoDialog, registryUrl } = this.state;
|
||||
return (
|
||||
<RegistryInfoDialog open={openInfoDialog} onClose={this.handleCloseRegistryInfoDialog}>
|
||||
<div>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
export interface IProps {
|
||||
username?: string;
|
||||
handleLogout: Function;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @flow
|
||||
*/
|
||||
|
||||
import styled, {css} from 'react-emotion';
|
||||
import styled, { css } from 'react-emotion';
|
||||
import AppBar from '@material-ui/core/AppBar/index';
|
||||
import Toolbar from '@material-ui/core/Toolbar/index';
|
||||
import colors from '../../utils/styles/colors';
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
/* @flow */
|
||||
|
||||
import React from 'react';
|
||||
import type {Node} from 'react';
|
||||
import {IProps} from './interfaces';
|
||||
import type { Node } from 'react';
|
||||
import { IProps } from './interfaces';
|
||||
|
||||
const Link = ({children, to = '#', blank = false, ...props}: IProps): Node => (
|
||||
const Link = ({ children, to = '#', blank = false, ...props }: IProps): Node => (
|
||||
<a href={to} target={blank ? '_blank' : '_self'} {...props}>
|
||||
{children}
|
||||
</a>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
/* @flow */
|
||||
|
||||
export interface IProps {
|
||||
children?: React.Node;
|
||||
to?: string;
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
// @flow
|
||||
|
||||
import React from 'react';
|
||||
import Dialog from '@material-ui/core/Dialog/index';
|
||||
import DialogActions from '@material-ui/core/DialogActions/index';
|
||||
import Button from '@material-ui/core/Button/index';
|
||||
import {Title, Content} from './styles';
|
||||
import { Title, Content } from './styles';
|
||||
|
||||
import type {Node} from 'react';
|
||||
import type { Node } from 'react';
|
||||
|
||||
import {IProps} from './interfaces';
|
||||
import { IProps } from './interfaces';
|
||||
|
||||
const RegistryInfoDialog = ({open = false, children, onClose}: IProps): Node => (
|
||||
const RegistryInfoDialog = ({ open = false, children, onClose }: IProps): Node => (
|
||||
<Dialog id="registryInfo--dialog-container" open={open} onClose={onClose}>
|
||||
<Title disableTypography>Register Info</Title>
|
||||
<Content>{children}</Content>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
/* @flow */
|
||||
|
||||
import type {Node} from 'react';
|
||||
import type { Node } from 'react';
|
||||
|
||||
export interface IProps {
|
||||
children: Node;
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
/**
|
||||
* @prettier
|
||||
* @flow
|
||||
*/
|
||||
|
||||
/* @flow */
|
||||
|
||||
import styled from 'react-emotion';
|
||||
import DialogTitle from '@material-ui/core/DialogTitle/index';
|
||||
import DialogContent from '@material-ui/core/DialogContent/index';
|
||||
import colors from '../../utils/styles/colors';
|
||||
import {fontSize} from '../../utils/styles/sizes';
|
||||
import { fontSize } from '../../utils/styles/sizes';
|
||||
|
||||
export const Title = styled(DialogTitle)`
|
||||
&& {
|
||||
|
|
|
@ -10,7 +10,7 @@ describe('/ (Verdaccio Page)', () => {
|
|||
// this might be increased based on the delays included in all test
|
||||
jest.setTimeout(200000);
|
||||
|
||||
const clickElement = async function(selector, options = {button: 'middle', delay: 100}) {
|
||||
const clickElement = async function(selector, options = { button: 'middle', delay: 100 }) {
|
||||
const button = await page.$(selector);
|
||||
await button.focus();
|
||||
await button.click(options);
|
||||
|
@ -34,14 +34,14 @@ describe('/ (Verdaccio Page)', () => {
|
|||
expect(userInput).not.toBeNull();
|
||||
const passInput = await signInDialog.$('#login--form-password');
|
||||
expect(passInput).not.toBeNull();
|
||||
await userInput.type('test', {delay: 100});
|
||||
await passInput.type('test', {delay: 100});
|
||||
await userInput.type('test', { delay: 100 });
|
||||
await passInput.type('test', { delay: 100 });
|
||||
await passInput.dispose();
|
||||
// click on log in
|
||||
const loginButton = await page.$('#login--form-submit');
|
||||
expect(loginButton).toBeDefined();
|
||||
await loginButton.focus();
|
||||
await loginButton.click({delay: 100});
|
||||
await loginButton.click({ delay: 100 });
|
||||
await page.waitFor(500);
|
||||
};
|
||||
|
||||
|
@ -100,8 +100,8 @@ describe('/ (Verdaccio Page)', () => {
|
|||
|
||||
it('should logout an user', async () => {
|
||||
// we assume the user is logged already
|
||||
await clickElement('#header--button-account', {clickCount: 1, delay: 2000});
|
||||
await clickElement('#header--button-logout', {clickCount: 1, delay: 200});
|
||||
await clickElement('#header--button-account', { clickCount: 1, delay: 2000 });
|
||||
await clickElement('#header--button-logout', { clickCount: 1, delay: 200 });
|
||||
await page.waitFor(1000);
|
||||
await evaluateSignIn();
|
||||
});
|
||||
|
@ -132,7 +132,7 @@ describe('/ (Verdaccio Page)', () => {
|
|||
const packagesList = await getPackages();
|
||||
const packageItem = packagesList[0];
|
||||
await packageItem.focus();
|
||||
await packageItem.click({clickCount: 1, delay: 200});
|
||||
await packageItem.click({ clickCount: 1, delay: 200 });
|
||||
await page.waitFor(1000);
|
||||
const readmeText = await page.evaluate(() => document.querySelector('.markdown-body').textContent);
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
* This file includes global settings for the JEST environment.
|
||||
*/
|
||||
import 'raf/polyfill';
|
||||
import {configure} from 'enzyme';
|
||||
import { configure } from 'enzyme';
|
||||
import Adapter from 'enzyme-adapter-react-16';
|
||||
|
||||
configure({adapter: new Adapter()});
|
||||
configure({ adapter: new Adapter() });
|
||||
|
||||
global.__APP_VERSION__ = '1.0.0';
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {shallow} from 'enzyme';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import CopyToClipBoard from '../../../../src/webui/components/CopyToClipBoard';
|
||||
import {CopyIcon} from '../../../../src/webui/components/CopyToClipBoard/styles';
|
||||
import { CopyIcon } from '../../../../src/webui/components/CopyToClipBoard/styles';
|
||||
|
||||
describe('<CopyToClipBoard /> component', () => {
|
||||
let wrapper;
|
||||
|
@ -34,7 +34,7 @@ describe('<CopyToClipBoard /> component', () => {
|
|||
addRange: () => {},
|
||||
}));
|
||||
|
||||
const {document, getSelection} = global;
|
||||
const { document, getSelection } = global;
|
||||
|
||||
wrapper.find(CopyIcon).simulate('click', event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {mount} from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
import Header from '../../../../src/webui/components/Header';
|
||||
|
||||
describe('<Header /> component with logged in state', () => {
|
||||
|
@ -22,13 +22,13 @@ describe('<Header /> component with logged in state', () => {
|
|||
});
|
||||
|
||||
test('should load the component in logged in state', () => {
|
||||
const state = {openInfoDialog: false, registryUrl: 'http://localhost'};
|
||||
const state = { openInfoDialog: false, registryUrl: 'http://localhost' };
|
||||
expect(wrapper.state()).toEqual(state);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('handleLoggedInMenu: set anchorEl to html element value in state', () => {
|
||||
const {handleLoggedInMenu} = wrapper.instance();
|
||||
const { handleLoggedInMenu } = wrapper.instance();
|
||||
|
||||
// creates a sample menu
|
||||
const div = document.createElement('div');
|
||||
|
@ -58,31 +58,31 @@ describe('<Header /> component with logged out state', () => {
|
|||
});
|
||||
|
||||
test('should load the component in logged out state', () => {
|
||||
const state = {openInfoDialog: false, registryUrl: 'http://localhost'};
|
||||
const state = { openInfoDialog: false, registryUrl: 'http://localhost' };
|
||||
expect(wrapper.state()).toEqual(state);
|
||||
expect(wrapper.html()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('handleLoggedInMenuClose: set anchorEl value to null in state', () => {
|
||||
const {handleLoggedInMenuClose} = wrapper.instance();
|
||||
const { handleLoggedInMenuClose } = wrapper.instance();
|
||||
handleLoggedInMenuClose();
|
||||
expect(wrapper.state('anchorEl')).toBeNull();
|
||||
});
|
||||
|
||||
test('handleOpenRegistryInfoDialog: set openInfoDialog to be truthy in state', () => {
|
||||
const {handleOpenRegistryInfoDialog} = wrapper.instance();
|
||||
const { handleOpenRegistryInfoDialog } = wrapper.instance();
|
||||
handleOpenRegistryInfoDialog();
|
||||
expect(wrapper.state('openInfoDialog')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('handleCloseRegistryInfoDialog: set openInfoDialog to be falsy in state', () => {
|
||||
const {handleCloseRegistryInfoDialog} = wrapper.instance();
|
||||
const { handleCloseRegistryInfoDialog } = wrapper.instance();
|
||||
handleCloseRegistryInfoDialog();
|
||||
expect(wrapper.state('openInfoDialog')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('handleToggleLogin: close/open popover menu', () => {
|
||||
const {handleToggleLogin} = wrapper.instance();
|
||||
const { handleToggleLogin } = wrapper.instance();
|
||||
handleToggleLogin();
|
||||
expect(wrapper.state('anchorEl')).toBeNull();
|
||||
expect(props.toggleLoginModal).toHaveBeenCalled();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {mount} from 'enzyme';
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
import LoginModal from '../../../../src/webui/components/Login';
|
||||
|
||||
|
@ -69,7 +69,7 @@ describe('<LoginModal />', () => {
|
|||
onSubmit: () => {},
|
||||
};
|
||||
const wrapper = mount(<LoginModal {...props} />);
|
||||
const {setCredentials} = wrapper.instance();
|
||||
const { setCredentials } = wrapper.instance();
|
||||
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
|
@ -90,7 +90,7 @@ describe('<LoginModal />', () => {
|
|||
const instance = wrapper.instance();
|
||||
|
||||
instance.submitCredentials = jest.fn();
|
||||
const {validateCredentials, setCredentials, submitCredentials} = instance;
|
||||
const { validateCredentials, setCredentials, submitCredentials } = instance;
|
||||
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
|
@ -112,7 +112,7 @@ describe('<LoginModal />', () => {
|
|||
};
|
||||
|
||||
const wrapper = mount(<LoginModal {...props} />);
|
||||
const {setCredentials, submitCredentials} = wrapper.instance();
|
||||
const { setCredentials, submitCredentials } = wrapper.instance();
|
||||
expect(setCredentials('username', eventUsername)).toBeUndefined();
|
||||
expect(wrapper.state('form').username.value).toEqual('xyz');
|
||||
|
||||
|
|
Loading…
Reference in a new issue