0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

chore: update deps (#2056)

* chore: update deps

* chore: update eslint

* chore: update deps types
This commit is contained in:
Juan Picado 2021-01-16 10:40:43 +01:00
parent 96ba927917
commit eab3007939
26 changed files with 2236 additions and 1578 deletions

View file

@ -43,6 +43,8 @@
"jest/no-test-callback": 0,
"jest/expect-expect": 0,
"jest/no-try-expect": 0,
"jest/no-done-callback": "off",
"jest/no-conditional-expect": "off",
"keyword-spacing": "off",
"no-tabs": "off",
"no-useless-escape": "off",

View file

@ -14,107 +14,107 @@
"url": "https://opencollective.com/verdaccio"
},
"devDependencies": {
"@babel/cli": "7.12.1",
"@babel/core": "7.12.3",
"@babel/node": "7.12.6",
"@babel/cli": "7.12.10",
"@babel/core": "7.12.10",
"@babel/node": "7.12.10",
"@babel/plugin-proposal-class-properties": "7.12.1",
"@babel/plugin-proposal-decorators": "7.12.1",
"@babel/plugin-proposal-decorators": "7.12.12",
"@babel/plugin-proposal-export-namespace-from": "7.12.1",
"@babel/plugin-proposal-function-sent": "7.12.1",
"@babel/plugin-proposal-json-strings": "7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.12.1",
"@babel/plugin-proposal-numeric-separator": "7.12.5",
"@babel/plugin-proposal-numeric-separator": "7.12.7",
"@babel/plugin-proposal-object-rest-spread": "7.12.1",
"@babel/plugin-proposal-optional-chaining": "7.12.1",
"@babel/plugin-proposal-optional-chaining": "7.12.7",
"@babel/plugin-proposal-throw-expressions": "7.12.1",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-syntax-import-meta": "7.10.4",
"@babel/plugin-transform-async-to-generator": "7.12.1",
"@babel/plugin-transform-classes": "7.12.1",
"@babel/plugin-transform-runtime": "7.12.1",
"@babel/plugin-transform-runtime": "7.12.10",
"@babel/polyfill": "7.12.1",
"@babel/preset-env": "7.12.1",
"@babel/preset-react": "7.12.5",
"@babel/preset-typescript": "7.12.1",
"@babel/register": "7.12.1",
"@babel/preset-env": "7.12.11",
"@babel/preset-react": "7.12.10",
"@babel/preset-typescript": "7.12.7",
"@babel/register": "7.12.10",
"@babel/runtime": "7.12.5",
"@changesets/changelog-github": "^0.2.7",
"@changesets/cli": "^2.12.0",
"@changesets/changelog-github": "^0.2.8",
"@changesets/cli": "^2.13.0",
"@changesets/get-dependents-graph": "^1.1.3",
"@commitlint/cli": "8.3.5",
"@commitlint/config-conventional": "8.2.0",
"@octokit/rest": "17.0.0",
"@types/async": "3.2.3",
"@types/async": "3.2.5",
"@types/autosuggest-highlight": "3.1.1",
"@types/express": "4.17.6",
"@types/http-errors": "1.6.3",
"@types/jest": "^26.0.19",
"@types/lodash": "4.14.165",
"@types/mime": "2.0.2",
"@types/http-errors": "1.8.0",
"@types/jest": "^26.0.20",
"@types/js-base64": "3.0.0",
"@types/lodash": "4.14.167",
"@types/lowdb": "^1.0.9",
"@types/mime": "2.0.2",
"@types/minimatch": "3.0.3",
"@types/node": "^14.14.7",
"@types/semver": "7.2.0",
"@types/supertest": "2.0.9",
"@types/autosuggest-highlight": "3.1.0",
"@types/js-base64": "3.0.0",
"@types/react": "16.14.2",
"@types/react-autosuggest": "10.0.1",
"@types/react-dom": "^16.9.10",
"@types/react-router-dom": "5.1.6",
"@types/react-virtualized": "9.21.10",
"@types/request": "2.48.5",
"@types/semver": "7.3.4",
"@types/supertest": "2.0.10",
"@types/testing-library__jest-dom": "^5.9.5",
"@types/validator": "13.1.1",
"@types/webpack": "^4.41.25",
"@types/validator": "13.1.3",
"@types/webpack": "^4.41.26",
"@types/webpack-env": "1.16.0",
"@typescript-eslint/eslint-plugin": "4.10.0",
"@typescript-eslint/parser": "4.10.0",
"@typescript-eslint/eslint-plugin": "4.13.0",
"@typescript-eslint/parser": "4.13.0",
"@verdaccio/types": "workspace:*",
"@verdaccio/ui-theme": "workspace:*",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"babel-jest": "26.6.3",
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-emotion": "10.0.33",
"codecov": "3.6.1",
"babel-plugin-emotion": "11.0.0",
"codecov": "3.8.1",
"concurrently": "^5.3.0",
"core-js": "^3.6.5",
"cross-env": "7.0.2",
"core-js": "^3.8.2",
"cross-env": "7.0.3",
"detect-secrets": "1.0.6",
"eslint": "7.5.0",
"eslint": "7.18.0",
"eslint-config-google": "0.14.0",
"eslint-config-prettier": "6.10.0",
"eslint-plugin-babel": "5.3.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "23.8.0",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-react": "7.20.6",
"eslint-plugin-react-hooks": "4.1.0",
"eslint-plugin-simple-import-sort": "5.0.2",
"eslint-plugin-verdaccio": "8.4.2",
"eslint-config-prettier": "7.1.0",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.1.3",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-react": "7.22.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-verdaccio": "9.6.1",
"fs-extra": "8.1.0",
"get-stdin": "7.0.0",
"husky": "2.7.0",
"in-publish": "2.0.0",
"in-publish": "2.0.1",
"jest": "26.6.3",
"jest-environment-jsdom": "26.6.2",
"jest-environment-jsdom-global": "^2.0.4",
"jest-environment-node": "26.6.2",
"jest-fetch-mock": "3.0.3",
"jest-junit": "11.0.1",
"kleur": "3.0.3",
"kleur": "4.1.3",
"lint-staged": "8.2.1",
"nock": "12.0.3",
"nodemon": "^2.0.7",
"npm-run-all": "4.1.5",
"nodemon": "^2.0.6",
"prettier": "2.0.5",
"prettier": "2.2.1",
"rimraf": "3.0.2",
"selfsigned": "1.10.7",
"selfsigned": "1.10.8",
"standard-version": "8.0.0",
"supertest": "4.0.2",
"ts-node": "^9.0.0",
"typescript": "^4.0.5",
"verdaccio": "^4.8.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"verdaccio": "^4.10.0",
"verdaccio-audit": "workspace:*",
"verdaccio-auth-memory": "workspace:*",
"verdaccio-htpasswd": "workspace:*",

View file

@ -48,11 +48,10 @@ export default function (route: Router, auth: IAuth, storage: IStorageHandler):
tag_package_version
);
route.delete('/-/package/:package/dist-tags/:tag', can('publish'), function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.delete(
'/-/package/:package/dist-tags/:tag',
can('publish'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const tags = {};
tags[req.params.tag] = null;
storage.mergeTags(req.params.package, tags, function (err: VerdaccioError): $NextFunctionVer {
@ -64,13 +63,13 @@ export default function (route: Router, auth: IAuth, storage: IStorageHandler):
ok: API_MESSAGE.TAG_REMOVED,
});
});
});
}
);
route.get('/-/package/:package/dist-tags', can('access'), function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.get(
'/-/package/:package/dist-tags',
can('access'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
storage.getPackage({
name: req.params.package,
uplinksLook: true,
@ -83,16 +82,17 @@ export default function (route: Router, auth: IAuth, storage: IStorageHandler):
next(info[DIST_TAGS]);
},
});
});
}
);
route.post('/-/package/:package/dist-tags', can('publish'), function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
storage.mergeTags(req.params.package, req.body, function (
err: VerdaccioError
): $NextFunctionVer {
route.post(
'/-/package/:package/dist-tags',
can('publish'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
storage.mergeTags(
req.params.package,
req.body,
function (err: VerdaccioError): $NextFunctionVer {
if (err) {
return next(err);
}
@ -100,6 +100,8 @@ export default function (route: Router, auth: IAuth, storage: IStorageHandler):
return next({
ok: API_MESSAGE.TAG_UPDATED,
});
});
});
}
);
}
);
}

View file

@ -41,11 +41,10 @@ export default function (
): void {
const can = allow(auth);
// TODO: anonymous user?
route.get('/:package/:version?', can('access'), function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.get(
'/:package/:version?',
can('access'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
debug('init package by version');
const name = req.params.package;
const getPackageMetaCallback = function (err, metadata: Package): void {
@ -96,21 +95,24 @@ export default function (
req,
callback: getPackageMetaCallback,
});
});
}
);
route.get('/:scopedPackage/-/:scope/:filename', can('access'), function (
req: $RequestExtend,
res: $ResponseExtend
): void {
route.get(
'/:scopedPackage/-/:scope/:filename',
can('access'),
function (req: $RequestExtend, res: $ResponseExtend): void {
const { scopedPackage, filename } = req.params;
downloadStream(scopedPackage, filename, storage, req, res);
});
}
);
route.get('/:package/-/:filename', can('access'), function (
req: $RequestExtend,
res: $ResponseExtend
): void {
route.get(
'/:package/-/:filename',
can('access'),
function (req: $RequestExtend, res: $ResponseExtend): void {
downloadStream(req.params.package, req.params.filename, storage, req, res);
});
}
);
}

View file

@ -2,11 +2,10 @@ import { Router } from 'express';
import { $RequestExtend, $ResponseExtend, $NextFunctionVer } from '../types/custom';
export default function (route: Router): void {
route.get('/-/ping', function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
) {
route.get(
'/-/ping',
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
next({});
});
}
);
}

View file

@ -241,9 +241,10 @@ export function publishPackage(storage: IStorageHandler, config: Config, auth: I
// at this point document is either created or existed before
const [firstAttachmentKey] = Object.keys(_attachments);
createTarball(Path.basename(firstAttachmentKey), _attachments[firstAttachmentKey], function (
error
) {
createTarball(
Path.basename(firstAttachmentKey),
_attachments[firstAttachmentKey],
function (error) {
debug('creating a tarball %o', firstAttachmentKey);
if (error) {
debug('error on create a tarball for %o with error %o', packageName, error.message);
@ -275,7 +276,10 @@ export function publishPackage(storage: IStorageHandler, config: Config, auth: I
`${metadataCopy.name}@${versionToPublish}`
);
} catch (error) {
debug('error on notify add a new tag %o', `${metadataCopy.name}@${versionToPublish}`);
debug(
'error on notify add a new tag %o',
`${metadataCopy.name}@${versionToPublish}`
);
logger.error({ error }, 'notify batch service has failed: @{error}');
}
@ -284,7 +288,8 @@ export function publishPackage(storage: IStorageHandler, config: Config, auth: I
return next({ ok: okMessage, success: true });
});
});
});
}
);
};
if (isPublishablePackage(req.body) === false && isObject(req.body.users)) {

View file

@ -15,11 +15,9 @@ import { $RequestExtend, $NextFunctionVer } from '../types/custom';
const debug = buildDebug('verdaccio:api:user');
export default function (route: Router, auth: IAuth, config: Config): void {
route.get('/-/user/:org_couchdb_user', function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
): void {
route.get(
'/-/user/:org_couchdb_user',
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
debug('verifying user');
const message = getAuthenticatedMessage(req.remote_user.name);
debug('user authenticated message %o', message);
@ -27,29 +25,30 @@ export default function (route: Router, auth: IAuth, config: Config): void {
next({
ok: message,
});
});
}
);
route.put('/-/user/:org_couchdb_user/:_rev?/:revision?', function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
): void {
route.put(
'/-/user/:org_couchdb_user/:_rev?/:revision?',
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
const { name, password } = req.body;
debug('login or adduser');
const remoteName = req.remote_user.name;
if (_.isNil(remoteName) === false && _.isNil(name) === false && remoteName === name) {
debug('login: no remote user detected');
auth.authenticate(name, password, async function callbackAuthenticate(
err,
user
): Promise<void> {
auth.authenticate(
name,
password,
async function callbackAuthenticate(err, user): Promise<void> {
if (err) {
logger.trace(
{ name, err },
'authenticating for user @{username} failed. Error: @{err.message}'
);
return next(ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD));
return next(
ErrorCode.getCode(HTTP_STATUS.UNAUTHORIZED, API_ERROR.BAD_USERNAME_PASSWORD)
);
}
const restoredRemoteUser: RemoteUser = createRemoteUser(name, user.groups || []);
@ -68,7 +67,8 @@ export default function (route: Router, auth: IAuth, config: Config): void {
ok: message,
token,
});
});
}
);
} else {
if (validatePassword(password) === false) {
debug('adduser: invalid password');
@ -106,16 +106,16 @@ export default function (route: Router, auth: IAuth, config: Config): void {
});
});
}
});
}
);
route.delete('/-/user/token/*', function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
): void {
route.delete(
'/-/user/token/*',
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
res.status(HTTP_STATUS.OK);
next({
ok: API_MESSAGE.LOGGED_OUT,
});
});
}
);
}

View file

@ -31,11 +31,9 @@ export default function (route: Router, auth: IAuth): void {
};
}
route.get('/-/npm/v1/user', function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
): void {
route.get(
'/-/npm/v1/user',
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
if (_.isNil(req.remote_user.name) === false) {
return next(buildProfile(req.remote_user.name));
}
@ -44,13 +42,12 @@ export default function (route: Router, auth: IAuth): void {
return next({
message: API_ERROR.MUST_BE_LOGGED,
});
});
}
);
route.post('/-/npm/v1/user', function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
): void {
route.post(
'/-/npm/v1/user',
function (req: $RequestExtend, res: Response, next: $NextFunctionVer): void {
if (_.isNil(req.remote_user.name)) {
res.status(HTTP_STATUS.UNAUTHORIZED);
return next({
@ -86,9 +83,12 @@ export default function (route: Router, auth: IAuth): void {
}
);
} else if (_.isNil(tfa) === false) {
return next(ErrorCode.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPORT_ERRORS.TFA_DISABLED));
return next(
ErrorCode.getCode(HTTP_STATUS.SERVICE_UNAVAILABLE, SUPPORT_ERRORS.TFA_DISABLED)
);
} else {
return next(ErrorCode.getCode(HTTP_STATUS.INTERNAL_ERROR, APP_ERROR.PROFILE_ERROR));
}
});
}
);
}

View file

@ -28,11 +28,9 @@ export default function (
storage: IStorageHandler,
config: Config
): void {
route.get('/-/npm/v1/tokens', async function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
) {
route.get(
'/-/npm/v1/tokens',
async function (req: $RequestExtend, res: Response, next: $NextFunctionVer) {
const { name } = req.remote_user;
if (_.isNil(name) === false) {
@ -54,13 +52,12 @@ export default function (
}
}
return next(ErrorCode.getUnauthorized());
});
}
);
route.post('/-/npm/v1/tokens', function (
req: $RequestExtend,
res: Response,
next: $NextFunctionVer
) {
route.post(
'/-/npm/v1/tokens',
function (req: $RequestExtend, res: Response, next: $NextFunctionVer) {
const { password, readonly, cidr_whitelist } = req.body;
const { name } = req.remote_user;
@ -124,7 +121,8 @@ export default function (
return next(ErrorCode.getCode(HTTP_STATUS.INTERNAL_ERROR, error.message));
}
});
});
}
);
route.delete(
'/-/npm/v1/tokens/token/:tokenKey',

View file

@ -35,7 +35,7 @@ export const statfile = (name: string): Promise<Error | null> => {
};
export const lockfile = (name: string): Promise<unknown> => {
return new Promise((resolve): void => {
return new Promise<void>((resolve): void => {
const lockOpts = {
// time (ms) to wait when checking for stale locks
wait: 1000,

View file

@ -172,10 +172,10 @@ export function allow(auth: IAuth): Function {
{ action, user: remote?.name },
`[middleware/allow][@{action}] allow for @{user}`
);
auth['allow_' + action]({ packageName, packageVersion }, remote, function (
error,
allowed
): void {
auth['allow_' + action](
{ packageName, packageVersion },
remote,
function (error, allowed): void {
req.resume();
if (error) {
next(error);
@ -186,7 +186,8 @@ export function allow(auth: IAuth): Function {
// cb(err) or cb(null, true), so this should never happen
throw ErrorCode.getInternalError(API_ERROR.PLUGIN_ERROR);
}
});
}
);
};
};
}

View file

@ -215,7 +215,7 @@ export default class Server implements IServerBridge {
}, 20);
});
return new Promise(function (resolve, reject) {
return new Promise<void>(function (resolve, reject) {
promise
.then(function () {
reject(Error('no error'));

View file

@ -171,7 +171,7 @@ export default class S3Database implements IPluginStorage<S3Config> {
// Create/write database file to s3
private async _sync(): Promise<void> {
await new Promise((resolve, reject): void => {
await new Promise<void>((resolve, reject): void => {
const { bucket, keyPrefix } = this.config;
this.logger.debug(
{ keyPrefix, bucket },

View file

@ -315,7 +315,7 @@ export default class S3PackageManager implements ILocalPackageManager {
Object.assign({}, baseS3Params, { Body: uploadStream })
);
// NOTE: there's a managedUpload.promise, but it doesn't seem to work
const promise = new Promise((resolve): void => {
const promise = new Promise<void>((resolve): void => {
this.logger.debug('s3: [S3PackageManager writeTarball managedUpload] send');
managedUpload.send((err, data) => {
if (err) {

View file

@ -6,11 +6,11 @@ import { Route as ReactRouterDomRoute, Switch, Router } from 'react-router-dom';
import AppContext from './AppContext';
import loadable from './utils/loadable';
const NotFound = loadable(() =>
import(/* webpackChunkName: "NotFound" */ 'verdaccio-ui/components/NotFound')
const NotFound = loadable(
() => import(/* webpackChunkName: "NotFound" */ 'verdaccio-ui/components/NotFound')
);
const VersionContextProvider = loadable(() =>
import(/* webpackChunkName: "Provider" */ '../pages/Version/VersionContextProvider')
const VersionContextProvider = loadable(
() => import(/* webpackChunkName: "Provider" */ '../pages/Version/VersionContextProvider')
);
const VersionPage = loadable(() => import(/* webpackChunkName: "Version" */ '../pages/Version'));
const HomePage = loadable(() => import(/* webpackChunkName: "Home" */ '../pages/home'));

View file

@ -8,8 +8,8 @@ import { TabPosition } from './tabs';
const Versions = loadable(() => import(/* webpackChunkName: "Versions" */ './Versions'));
const UpLinks = loadable(() => import(/* webpackChunkName: "UpLinks" */ './UpLinks'));
const Dependencies = loadable(() =>
import(/* webpackChunkName: "Dependencies" */ './Dependencies')
const Dependencies = loadable(
() => import(/* webpackChunkName: "Dependencies" */ './Dependencies')
);
interface Props {

View file

@ -3,7 +3,6 @@ import dayjs from 'dayjs';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import relativeTime from 'dayjs/plugin/relativeTime';
import i18next from 'i18next';
import isObject from 'lodash/isObject';
import isString from 'lodash/isString';
import { Time } from '../../types/packageMeta';
@ -24,9 +23,7 @@ export function formatLicense(license: any): string | undefined {
return license;
}
// @ts-ignore
if (license && isObject(license) && license.type) {
// @ts-ignore
if (license?.type) {
return license.type;
}
@ -50,9 +47,7 @@ export function formatRepository(repository: any): string | null {
return repository;
}
// @ts-ignore
if (repository && isObject(repository) && repository.url) {
// @ts-ignore
if (repository?.url) {
return repository.url;
}

View file

@ -4,11 +4,9 @@ import { $ResponseExtend, $RequestExtend, $NextFunctionVer } from '../../types/c
export default (app: Application, configPath: string): void => {
// Hook for tests only
app.get('/-/_debug', function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
app.get(
'/-/_debug',
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const doGarbabeCollector = _.isNil(global.gc) === false;
if (doGarbabeCollector) {
@ -23,5 +21,6 @@ export default (app: Application, configPath: string): void => {
mem: process.memoryUsage(),
gc: doGarbabeCollector,
});
});
}
);
};

View file

@ -54,14 +54,13 @@ const defineAPI = function (config: IConfig, storage: IStorageHandler): any {
app.use(compression());
app.get('/favicon.ico', function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
app.get(
'/favicon.ico',
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
req.url = '/-/static/favicon.png';
next();
});
}
);
// Hook for tests only
if (config._debug) {

View file

@ -154,7 +154,7 @@ export function cleanUpLinksRef(keepUpLinkData: boolean, result: Package): Packa
* @param {*} localStorage
*/
export function checkPackageLocal(name: string, localStorage: IStorage): Promise<any> {
return new Promise((resolve, reject): void => {
return new Promise<void>((resolve, reject): void => {
localStorage.getPackageMetadata(name, (err, results): void => {
if (!isNil(err) && err.status !== HTTP_STATUS.NOT_FOUND) {
return reject(err);
@ -168,7 +168,7 @@ export function checkPackageLocal(name: string, localStorage: IStorage): Promise
}
export function publishPackage(name: string, metadata: any, localStorage: IStorage): Promise<any> {
return new Promise((resolve, reject): void => {
return new Promise<void>((resolve, reject): void => {
localStorage.addPackage(name, metadata, (err, latest): void => {
if (!_.isNull(err)) {
return reject(err);
@ -185,7 +185,7 @@ export function checkPackageRemote(
isAllowPublishOffline: boolean,
syncMetadata: Function
): Promise<any> {
return new Promise((resolve, reject): void => {
return new Promise<void>((resolve, reject): void => {
syncMetadata(name, null, {}, (err, packageJsonLocal, upLinksErrors): void => {
// something weird
if (err && err.status !== HTTP_STATUS.NOT_FOUND) {

View file

@ -486,10 +486,9 @@ class Storage {
const packages: Version[] = [];
const getPackage = function (itemPkg): void {
self.localStorage.getPackageMetadata(locals[itemPkg], function (
err,
pkgMetadata: Package
): void {
self.localStorage.getPackageMetadata(
locals[itemPkg],
function (err, pkgMetadata: Package): void {
if (_.isNil(err)) {
const latest = pkgMetadata[DIST_TAGS].latest;
if (latest && pkgMetadata.versions[latest]) {
@ -517,7 +516,8 @@ class Storage {
} else {
getPackage(itemPkg + 1);
}
});
}
);
};
if (locals.length) {

View file

@ -384,7 +384,7 @@ describe('LocalStorage', () => {
stream.done();
});
test('should fails on add a duplicated new tarball ', (done) => {
test('should fails on add a duplicated new tarball', (done) => {
const tarballData = JSON.parse(readMetadata('addTarball'));
const stream = storage.addTarball(pkgName, tarballName);
stream.on('error', (err: VerdaccioError) => {

View file

@ -53,11 +53,9 @@ function addPackageWebApi(
});
// Get list of all visible package
route.get('/packages', function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.get(
'/packages',
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
storage.getLocalDatabase(async function (err, packages): Promise<void> {
if (err) {
throw err;
@ -104,14 +102,14 @@ function addPackageWebApi(
next(sortByName(await processPackages(packages), order));
});
});
}
);
// Get package readme
route.get('/package/readme/(@:scope/)?:package/:version?', can('access'), function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.get(
'/package/readme/(@:scope/)?:package/:version?',
can('access'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const packageName = req.params.scope
? addScope(req.params.scope, req.params.package)
: req.params.package;
@ -133,13 +131,13 @@ function addPackageWebApi(
}
},
});
});
}
);
route.get('/sidebar/(@:scope/)?:package', can('access'), function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.get(
'/sidebar/(@:scope/)?:package',
can('access'),
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const packageName: string = req.params.scope
? addScope(req.params.scope, req.params.package)
: req.params.package;
@ -176,7 +174,8 @@ function addPackageWebApi(
}
},
});
});
}
);
}
export default addPackageWebApi;

View file

@ -8,11 +8,9 @@ import { $ResponseExtend, $RequestExtend, $NextFunctionVer } from './package';
function addSearchWebApi(route: Router, storage: IStorageHandler, auth: IAuth): void {
// Search package
route.get('/search/:anything', function (
req: $RequestExtend,
res: $ResponseExtend,
next: $NextFunctionVer
): void {
route.get(
'/search/:anything',
function (req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer): void {
const results: any = SearchInstance.query(req.params.anything);
// FUTURE: figure out here the correct type
const packages: any[] = [];
@ -23,16 +21,17 @@ function addSearchWebApi(route: Router, storage: IStorageHandler, auth: IAuth):
uplinksLook: false,
callback: (err, entry: Package): void => {
if (!err && entry) {
auth.allow_access({ packageName: entry.name }, req.remote_user, function (
err,
allowed
): void {
auth.allow_access(
{ packageName: entry.name },
req.remote_user,
function (err, allowed): void {
if (err || !allowed) {
return;
}
packages.push(entry.versions[entry[DIST_TAGS].latest]);
});
}
);
}
if (i >= results.length - 1) {
@ -49,7 +48,8 @@ function addSearchWebApi(route: Router, storage: IStorageHandler, auth: IAuth):
} else {
next([]);
}
});
}
);
}
export default addSearchWebApi;

View file

@ -32,11 +32,9 @@ function addUserAuthApi(route: Router, auth: IAuth, config: Config): void {
);
});
route.put('/reset_password', function (
req: Request,
res: Response,
next: $NextFunctionVer
): void {
route.put(
'/reset_password',
function (req: Request, res: Response, next: $NextFunctionVer): void {
if (_.isNil(req.remote_user.name)) {
res.status(HTTP_STATUS.UNAUTHORIZED);
return next({
@ -61,7 +59,8 @@ function addUserAuthApi(route: Router, auth: IAuth, config: Config): void {
} else {
return next(ErrorCode.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));
}
});
}
);
}
export default addUserAuthApi;

File diff suppressed because it is too large Load diff