0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
This commit is contained in:
Juan Picado 2024-08-05 07:27:21 +02:00
parent 9790875741
commit f775e05772
7 changed files with 47 additions and 47 deletions

View file

@ -14,7 +14,7 @@ class Search {
public readonly uplinks: ProxyInstanceList;
public readonly logger: Logger;
constructor(config: Config, logger: Logger) {
this.logger = logger.child({ module: 'proxy' });
this.logger = logger;
this.uplinks = setupUpLinks(config, this.logger);
}

View file

@ -23,7 +23,7 @@ class LocalStorage {
public constructor(config: Config, logger: Logger) {
debug('local storage created');
this.logger = logger.child({ sub: 'fs' });
this.logger = logger;
this.config = config;
// @ts-expect-error
this.storagePlugin = null;

View file

@ -104,7 +104,7 @@ class Storage {
private searchService: Search;
public constructor(config: Config, logger: Logger) {
this.config = config;
this.logger = logger.child({ module: 'storage' });
this.logger = logger;
this.uplinks = setupUpLinks(config, this.logger);
this.searchService = new Search(config, this.logger);
this.filters = null;

View file

@ -17,7 +17,7 @@ import {
getConfig,
} from './helpers';
setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const logger = setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const fakeHost = 'localhost:4873';
@ -74,7 +74,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -119,7 +119,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const ac = new AbortController();
setTimeout(() => {
@ -164,7 +164,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
// create a package
const bodyNewManifest1 = generatePackageMetadata(pkgName, '1.0.0');
@ -253,7 +253,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest1 = generatePackageMetadata(pkgName, '1.0.0');
const bodyNewManifest2 = generatePackageMetadata(pkgName, '1.0.0');
@ -290,7 +290,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -320,7 +320,7 @@ describe('storage', () => {
const mockDate = '2018-01-14T11:17:40.712Z';
MockDate.set(mockDate);
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -367,7 +367,7 @@ describe('storage', () => {
const mockDate = '2018-01-14T11:17:40.712Z';
MockDate.set(mockDate);
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
// publish new package
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -441,7 +441,7 @@ describe('storage', () => {
describe('star', () => {
test.each([['foo']])('star package %s', async (pkgName) => {
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -474,7 +474,7 @@ describe('storage', () => {
const mockDate = '2018-01-14T11:17:40.712Z';
MockDate.set(mockDate);
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -516,7 +516,7 @@ describe('storage', () => {
const mockDate = '2018-01-14T11:17:40.712Z';
MockDate.set(mockDate);
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -555,7 +555,7 @@ describe('storage', () => {
test.each([['foo']])('should unstar a package %s', async (pkgName) => {
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -592,7 +592,7 @@ describe('storage', () => {
test.each([['foo']])('should handle missing username %s', async (pkgName) => {
const config = getConfig('deprecate.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -621,7 +621,7 @@ describe('storage', () => {
['foo', 'publishWithOwnerAndCheck.yaml'],
])('new package %s, %s (anonymous)', async (pkgName, configFile) => {
const config = getConfig(configFile);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {
@ -643,7 +643,7 @@ describe('storage', () => {
['foo', 'publishWithOwnerAndCheck.yaml'],
])('new package %s, %s (logged in)', async (pkgName, configFile) => {
const config = getConfig(configFile);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const owner = { name: 'fooUser', email: '' };
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -668,7 +668,7 @@ describe('storage', () => {
['foo', 'publishWithOwnerAndCheck.yaml'],
])('add/remove owner %s, %s', async (pkgName, configFile) => {
const config = getConfig(configFile);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const firstOwner = { name: 'fooUser', email: '' };
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -728,7 +728,7 @@ describe('storage', () => {
['foo', 'publishWithOwnerAndCheck.yaml'],
])('should fail removing last owner %s, %s', async (pkgName, configFile) => {
const config = getConfig(configFile);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
const owner = 'fooUser';
@ -756,7 +756,7 @@ describe('storage', () => {
'ok to publish as non-owner without check %s, %s',
async (pkgName, configFile) => {
const config = getConfig(configFile);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
const owner = 'fooUser';
@ -786,7 +786,7 @@ describe('storage', () => {
'should fail publishing as non-owner with check %s, %s',
async (pkgName, configFile) => {
const config = getConfig(configFile);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
const owner = 'fooUser';
@ -823,7 +823,7 @@ describe('storage', () => {
storage: generateRandomStorage(),
})
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
await expect(storage.getLocalDatabase()).resolves.toHaveLength(0);
});
@ -843,7 +843,7 @@ describe('storage', () => {
},
url: '/',
});
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const manifest = generatePackageMetadata('foo');
const ac = new AbortController();
@ -881,7 +881,7 @@ describe('storage', () => {
},
url: '/',
});
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const manifest = generatePackageMetadata('foo');
@ -930,7 +930,7 @@ describe('storage', () => {
test('ok to remove package as non-owner without check', async () => {
const config = getConfig('publishWithOwnerDefault.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const owner = 'fooUser';
const options = { ...defaultRequestOptions, username: owner };
@ -969,7 +969,7 @@ describe('storage', () => {
test('should fail as non-owner with check', async () => {
const config = getConfig('publishWithOwnerAndCheck.yaml');
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const owner = 'fooUser';
const options = { ...defaultRequestOptions, username: owner };

View file

@ -11,7 +11,7 @@ import { Manifest } from '@verdaccio/types';
import { Storage } from '../src';
import { configExample, generateRandomStorage, getConfig } from './helpers';
setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const logger = setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const pluginsPartialsFolder = path.join(__dirname, './fixtures/plugins');
@ -33,7 +33,7 @@ describe('storage plugin', () => {
})
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
await expect(storage.getLocalDatabase()).resolves.toHaveLength(1);
});
@ -55,7 +55,7 @@ describe('storage plugin', () => {
storage: generateRandomStorage(),
})
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
await storage.updateManifest(bodyNewManifest, {

View file

@ -14,7 +14,7 @@ import { Storage } from '../src';
import manifestFooRemoteNpmjs from './fixtures/manifests/foo-npmjs.json';
import { configExample, generateRandomStorage } from './helpers';
setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const logger = setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const fooManifest = generatePackageMetadata('foo', '1.0.0');
@ -44,7 +44,7 @@ describe('storage', () => {
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
await expect(
storage.syncUplinksMetadata(fooManifest.name, null, {
@ -68,7 +68,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
await expect(
storage.syncUplinksMetadata(fooManifest.name, null, {
@ -89,7 +89,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const [manifest] = await storage.syncUplinksMetadata(fooManifest.name, fooManifest, {
retry: { limit: 0 },
@ -111,7 +111,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const [response] = await storage.syncUplinksMetadata(fooManifest.name, fooManifest);
@ -152,7 +152,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const [response] = await storage.syncUplinksMetadata(fooManifest.name, null);
@ -174,7 +174,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const [response] = await storage.syncUplinksMetadata(fooManifest.name, fooManifest);
@ -198,7 +198,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const [response] = await storage.syncUplinksMetadata(fooManifest.name, fooManifest, {
@ -227,7 +227,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
const [response] = await storage.syncUplinksMetadata('foo', null, {

View file

@ -15,7 +15,7 @@ import { Manifest } from '@verdaccio/types';
import { Storage } from '../src';
import { configExample, defaultRequestOptions, generateRandomStorage } from './helpers';
setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const logger = setup({ type: 'stdout', format: 'pretty', level: 'trace' });
const fakeHost = 'localhost:4873';
@ -35,7 +35,7 @@ describe('storage', () => {
storage: generateRandomStorage(),
})
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
storage.init(config).then(() => {
const ac = new AbortController();
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -75,7 +75,7 @@ describe('storage', () => {
storage: generateRandomStorage(),
})
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
storage.init(config).then(() => {
const abort = new AbortController();
storage
@ -115,7 +115,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
storage.init(config).then(() => {
const abort = new AbortController();
storage
@ -158,7 +158,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
storage.init(config).then(() => {
const ac = new AbortController();
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -221,7 +221,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
storage.init(config).then(() => {
const req = httpMocks.createRequest({
method: 'GET',
@ -274,7 +274,7 @@ describe('storage', () => {
__dirname
)
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
storage.init(config).then(() => {
const ac = new AbortController();
const bodyNewManifest = generatePackageMetadata(pkgName, '1.0.0');
@ -321,7 +321,7 @@ describe('storage', () => {
storage: generateRandomStorage(),
})
);
const storage = new Storage(config);
const storage = new Storage(config, logger);
await storage.init(config);
await expect(storage.removeTarball('foo', 'foo-1.0.0.tgz', 'rev', username)).rejects.toThrow(
API_ERROR.NO_PACKAGE