diff --git a/packages/core/local-storage/tests/__mocks__/Logger.ts b/packages/core/local-storage/tests/__mocks__/Logger.ts deleted file mode 100644 index 14822a7de..000000000 --- a/packages/core/local-storage/tests/__mocks__/Logger.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Logger } from '@verdaccio/types'; - -const logger: Logger = { - warn: jest.fn(), - error: jest.fn(), - // fatal: jest.fn(), - info: jest.fn(), - debug: jest.fn(), - child: jest.fn(), - http: jest.fn(), - trace: jest.fn(), -}; - -export default logger; diff --git a/packages/core/local-storage/tests/local-database.test.ts b/packages/core/local-storage/tests/local-database.test.ts index 0f929a88e..6e12600bc 100644 --- a/packages/core/local-storage/tests/local-database.test.ts +++ b/packages/core/local-storage/tests/local-database.test.ts @@ -2,7 +2,7 @@ import path from 'path'; import { dirSync } from 'tmp-promise'; -import { IPluginStorage, PluginOptions } from '@verdaccio/types'; +import { IPluginStorage, Logger, PluginOptions } from '@verdaccio/types'; import LocalDatabase, { ERROR_DB_LOCKED } from '../src/local-database'; @@ -16,8 +16,15 @@ jest.mock('../src/fs', () => ({ writeFilePromise: () => mockWrite(), })); -// FIXME: remove this mocks imports -import logger from './__mocks__/Logger'; +const logger: Logger = { + error: jest.fn(), + info: jest.fn(), + debug: jest.fn(), + child: jest.fn(), + warn: jest.fn(), + http: jest.fn(), + trace: jest.fn(), +}; // @ts-expect-error const optionsPlugin: PluginOptions<{}> = { diff --git a/packages/core/local-storage/tests/local-fs.test.ts b/packages/core/local-storage/tests/local-fs.test.ts index b58c47ec4..5d8413b91 100644 --- a/packages/core/local-storage/tests/local-fs.test.ts +++ b/packages/core/local-storage/tests/local-fs.test.ts @@ -2,18 +2,25 @@ import path from 'path'; import fs from 'fs'; import { dirSync } from 'tmp-promise'; -import { ILocalPackageManager, Package } from '@verdaccio/types'; +import { ILocalPackageManager, Logger, Package } from '@verdaccio/types'; import LocalDriver, { fileExist, fSError, noSuchFile, resourceNotAvailable } from '../src/local-fs'; -// FIXME: remove this mocks imports -// eslint-disable-next-line jest/no-mocks-import -import logger from './__mocks__/Logger'; import pkg from './__fixtures__/pkg'; let localTempStorage: string; const pkgFileName = 'package.json'; +const logger: Logger = { + error: jest.fn(), + info: jest.fn(), + debug: jest.fn(), + child: jest.fn(), + warn: jest.fn(), + http: jest.fn(), + trace: jest.fn(), +}; + describe('Local FS test', () => { let tmpFolder; beforeAll(() => { diff --git a/packages/core/local-storage/tests/token.test.ts b/packages/core/local-storage/tests/token.test.ts index 65027d39f..0f1025cbe 100644 --- a/packages/core/local-storage/tests/token.test.ts +++ b/packages/core/local-storage/tests/token.test.ts @@ -2,12 +2,19 @@ import fs from 'fs'; import path from 'path'; import { dirSync } from 'tmp-promise'; -import { Token } from '@verdaccio/types'; +import { Logger, Token } from '@verdaccio/types'; import LocalDatabase from '../src/local-database'; -// FIXME: remove this mocks imports -import logger from './__mocks__/Logger'; +const logger: Logger = { + error: jest.fn(), + info: jest.fn(), + debug: jest.fn(), + child: jest.fn(), + warn: jest.fn(), + http: jest.fn(), + trace: jest.fn(), +}; describe('Local Database', () => { let tmpFolder; diff --git a/packages/core/local-storage/tests/utils.test.ts b/packages/core/local-storage/tests/utils.test.ts index 5e33fe2bd..04da75bc8 100644 --- a/packages/core/local-storage/tests/utils.test.ts +++ b/packages/core/local-storage/tests/utils.test.ts @@ -1,13 +1,20 @@ import path from 'path'; +import { Logger } from '@verdaccio/types'; import * as readFile from '../src/fs'; import { findPackages, _dbGenPath } from '../src/utils'; import { loadPrivatePackages } from '../src/pkg-utils'; import { noSuchFile } from '../src/local-fs'; -// FIXME: remove this mocks imports -// eslint-disable-next-line jest/no-mocks-import -import logger from './__mocks__/Logger'; +const logger: Logger = { + error: jest.fn(), + info: jest.fn(), + debug: jest.fn(), + child: jest.fn(), + warn: jest.fn(), + http: jest.fn(), + trace: jest.fn(), +}; describe('Utitlies', () => { const loadDb = (name): string => path.join(__dirname, '__fixtures__/databases', `${name}.json`); diff --git a/packages/middleware/src/middleware-utils.ts b/packages/middleware/src/middleware-utils.ts index ad9dc6960..2d17d2197 100644 --- a/packages/middleware/src/middleware-utils.ts +++ b/packages/middleware/src/middleware-utils.ts @@ -4,7 +4,7 @@ * @returns {String} */ export function getVersionFromTarball(name: string): string | void { - // FIXME: we know the regex is valid, but we should improve this part as ts suggest - // @ts-ignore - return /.+-(\d.+)\.tgz/.test(name) ? name.match(/.+-(\d.+)\.tgz/)[1] : undefined; + const groups = name.match(/.+-(\d.+)\.tgz/); + + return groups !== null ? groups[1] : undefined; }