mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
refactor: Remove some FIXME annotations (#2465)
* refactor: Remove the @ts-ignore in middleware-utils * refactor: Remove __mocks__ imports in local-storage package Co-authored-by: Juan Picado <juanpicado19@gmail.com>
This commit is contained in:
parent
61add32bff
commit
b261741ef6
6 changed files with 44 additions and 30 deletions
|
@ -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;
|
|
@ -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<{}> = {
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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`);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue