0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

chore: vitest migration part 5 (#4914)

* migrate web package to vitest

* migrate node-api to vitest

* migrate file-locking vitest

* migrate cli

* remove jest from npm packages

* Create weak-cherries-serve.md

* update ci
This commit is contained in:
Juan Picado 2024-10-20 19:26:36 +02:00 committed by GitHub
parent f5f6e88d7a
commit e93d6a30a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
81 changed files with 534 additions and 439 deletions

View file

@ -0,0 +1,18 @@
---
'@verdaccio/logger-commons': patch
'@verdaccio/file-locking': patch
'@verdaccio/ui-theme': patch
'@verdaccio/search-indexer': patch
'@verdaccio/server': patch
'@verdaccio/server-fastify': patch
'@verdaccio/test-helper': patch
'@verdaccio/middleware': patch
'verdaccio': patch
'@verdaccio/node-api': patch
'@verdaccio/auth': patch
'@verdaccio/api': patch
'@verdaccio/cli': patch
'@verdaccio/web': patch
---
chore: auth package requires logger as parameter

View file

@ -24,7 +24,7 @@ jobs:
name: setup verdaccio name: setup verdaccio
services: services:
verdaccio: verdaccio:
image: verdaccio/verdaccio:5 image: verdaccio/verdaccio:6
ports: ports:
- 4873:4873 - 4873:4873
env: env:
@ -108,7 +108,7 @@ jobs:
fail-fast: true fail-fast: true
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
node_version: [18, 20, 21, 22] node_version: [18, 20, 21, 22, 23]
name: ${{ matrix.os }} / Node ${{ matrix.node_version }} name: ${{ matrix.os }} / Node ${{ matrix.node_version }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:

View file

@ -12,7 +12,7 @@ jobs:
name: UI Test E2E name: UI Test E2E
services: services:
verdaccio: verdaccio:
image: verdaccio/verdaccio:5 image: verdaccio/verdaccio:6
ports: ports:
- 4873:4873 - 4873:4873
env: env:

View file

@ -22,7 +22,7 @@ jobs:
name: setup verdaccio name: setup verdaccio
services: services:
verdaccio: verdaccio:
image: verdaccio/verdaccio:5 image: verdaccio/verdaccio:6
ports: ports:
- 4873:4873 - 4873:4873
env: env:

View file

@ -1,3 +0,0 @@
const config = require('../jest.config');
module.exports = { ...config };

View file

@ -1,3 +0,0 @@
const config = require('../jest.config');
module.exports = { ...config };

View file

@ -1,8 +0,0 @@
const { defaults } = require('jest-config');
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
collectCoverage: false,
coverageReporters: ['text'],
moduleFileExtensions: [...defaults.moduleFileExtensions, 'ts'],
});

View file

@ -4,13 +4,13 @@ import mime from 'mime';
import { Auth } from '@verdaccio/auth'; import { Auth } from '@verdaccio/auth';
import { constants, errorUtils } from '@verdaccio/core'; import { constants, errorUtils } from '@verdaccio/core';
import { logger } from '@verdaccio/logger';
import { allow, media } from '@verdaccio/middleware'; import { allow, media } from '@verdaccio/middleware';
import { Storage } from '@verdaccio/store'; import { Storage } from '@verdaccio/store';
import { Logger } from '@verdaccio/types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom'; import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
export default function (route: Router, auth: Auth, storage: Storage): void { export default function (route: Router, auth: Auth, storage: Storage, logger: Logger): void {
const can = allow(auth, { const can = allow(auth, {
beforeAll: (a, b) => logger.trace(a, b), beforeAll: (a, b) => logger.trace(a, b),
afterAll: (a, b) => logger.trace(a, b), afterAll: (a, b) => logger.trace(a, b),

View file

@ -9,7 +9,7 @@ import {
validatePackage, validatePackage,
} from '@verdaccio/middleware'; } from '@verdaccio/middleware';
import { Storage } from '@verdaccio/store'; import { Storage } from '@verdaccio/store';
import { Config } from '@verdaccio/types'; import { Config, Logger } from '@verdaccio/types';
import distTags from './dist-tags'; import distTags from './dist-tags';
import pkg from './package'; import pkg from './package';
@ -23,7 +23,7 @@ import v1Search from './v1/search';
import token from './v1/token'; import token from './v1/token';
import whoami from './whoami'; import whoami from './whoami';
export default function (config: Config, auth: Auth, storage: Storage): Router { export default function (config: Config, auth: Auth, storage: Storage, logger: Logger): Router {
/* eslint new-cap:off */ /* eslint new-cap:off */
const app = express.Router(); const app = express.Router();
/* eslint new-cap:off */ /* eslint new-cap:off */
@ -50,14 +50,14 @@ export default function (config: Config, auth: Auth, storage: Storage): Router {
// for "npm whoami" // for "npm whoami"
whoami(app); whoami(app);
profile(app, auth, config); profile(app, auth, config);
search(app); search(app, logger);
user(app, auth, config); user(app, auth, config, logger);
distTags(app, auth, storage); distTags(app, auth, storage, logger);
publish(app, auth, storage); publish(app, auth, storage, logger);
ping(app); ping(app);
stars(app, storage); stars(app, storage);
v1Search(app, auth, storage); v1Search(app, auth, storage, logger);
token(app, auth, storage, config); token(app, auth, storage, config, logger);
pkg(app, auth, storage); pkg(app, auth, storage, logger);
return app; return app;
} }

View file

@ -3,15 +3,15 @@ import { Router } from 'express';
import { Auth } from '@verdaccio/auth'; import { Auth } from '@verdaccio/auth';
import { HEADERS, HEADER_TYPE, stringUtils } from '@verdaccio/core'; import { HEADERS, HEADER_TYPE, stringUtils } from '@verdaccio/core';
import { logger } from '@verdaccio/logger';
import { allow } from '@verdaccio/middleware'; import { allow } from '@verdaccio/middleware';
import { Storage } from '@verdaccio/store'; import { Storage } from '@verdaccio/store';
import { Logger } from '@verdaccio/types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom'; import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
const debug = buildDebug('verdaccio:api:package'); const debug = buildDebug('verdaccio:api:package');
export default function (route: Router, auth: Auth, storage: Storage): void { export default function (route: Router, auth: Auth, storage: Storage, logger: Logger): void {
const can = allow(auth, { const can = allow(auth, {
beforeAll: (a, b) => logger.trace(a, b), beforeAll: (a, b) => logger.trace(a, b),
afterAll: (a, b) => logger.trace(a, b), afterAll: (a, b) => logger.trace(a, b),

View file

@ -4,9 +4,9 @@ import mime from 'mime';
import { Auth } from '@verdaccio/auth'; import { Auth } from '@verdaccio/auth';
import { API_MESSAGE, HTTP_STATUS } from '@verdaccio/core'; import { API_MESSAGE, HTTP_STATUS } from '@verdaccio/core';
import { logger } from '@verdaccio/logger';
import { allow, expectJson, media } from '@verdaccio/middleware'; import { allow, expectJson, media } from '@verdaccio/middleware';
import { Storage } from '@verdaccio/store'; import { Storage } from '@verdaccio/store';
import { Logger } from '@verdaccio/types';
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom'; import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from '../types/custom';
@ -109,7 +109,12 @@ const debug = buildDebug('verdaccio:api:publish');
} }
* *
*/ */
export default function publish(router: Router, auth: Auth, storage: Storage): void { export default function publish(
router: Router,
auth: Auth,
storage: Storage,
logger: Logger
): void {
const can = allow(auth, { const can = allow(auth, {
beforeAll: (a, b) => logger.trace(a, b), beforeAll: (a, b) => logger.trace(a, b),
afterAll: (a, b) => logger.trace(a, b), afterAll: (a, b) => logger.trace(a, b),
@ -119,7 +124,7 @@ export default function publish(router: Router, auth: Auth, storage: Storage): v
can('publish'), can('publish'),
media(mime.getType('json')), media(mime.getType('json')),
expectJson, expectJson,
publishPackage(storage) publishPackage(storage, logger)
); );
router.put( router.put(
@ -127,7 +132,7 @@ export default function publish(router: Router, auth: Auth, storage: Storage): v
can('unpublish'), can('unpublish'),
media(mime.getType('json')), media(mime.getType('json')),
expectJson, expectJson,
publishPackage(storage) publishPackage(storage, logger)
); );
/** /**
@ -195,7 +200,7 @@ export default function publish(router: Router, auth: Auth, storage: Storage): v
); );
} }
export function publishPackage(storage: Storage): any { export function publishPackage(storage: Storage, logger: Logger): any {
return async function ( return async function (
req: $RequestExtend, req: $RequestExtend,
res: $ResponseExtend, res: $ResponseExtend,

View file

@ -1,7 +1,7 @@
import { HTTP_STATUS } from '@verdaccio/core'; import { HTTP_STATUS } from '@verdaccio/core';
import { logger } from '@verdaccio/logger'; import { Logger } from '@verdaccio/types';
export default function (route): void { export default function (route, logger: Logger): void {
// TODO: next major version, remove this // TODO: next major version, remove this
route.get('/-/all(/since)?', function (_req, res) { route.get('/-/all(/since)?', function (_req, res) {
logger.warn('search endpoint has been removed, please use search v1'); logger.warn('search endpoint has been removed, please use search v1');

View file

@ -12,8 +12,8 @@ import {
errorUtils, errorUtils,
validatioUtils, validatioUtils,
} from '@verdaccio/core'; } from '@verdaccio/core';
import { logger } from '@verdaccio/logger';
import { rateLimit } from '@verdaccio/middleware'; import { rateLimit } from '@verdaccio/middleware';
import { Logger } from '@verdaccio/types';
import { Config, RemoteUser } from '@verdaccio/types'; import { Config, RemoteUser } from '@verdaccio/types';
import { getAuthenticatedMessage, mask } from '@verdaccio/utils'; import { getAuthenticatedMessage, mask } from '@verdaccio/utils';
@ -21,7 +21,7 @@ import { $NextFunctionVer, $RequestExtend } from '../types/custom';
const debug = buildDebug('verdaccio:api:user'); const debug = buildDebug('verdaccio:api:user');
export default function (route: Router, auth: Auth, config: Config): void { export default function (route: Router, auth: Auth, config: Config, logger: Logger): void {
route.get( route.get(
'/-/user/:org_couchdb_user', '/-/user/:org_couchdb_user',
rateLimit(config?.userRateLimit), rateLimit(config?.userRateLimit),

View file

@ -3,9 +3,9 @@ import _ from 'lodash';
import { Auth } from '@verdaccio/auth'; import { Auth } from '@verdaccio/auth';
import { HTTP_STATUS, searchUtils } from '@verdaccio/core'; import { HTTP_STATUS, searchUtils } from '@verdaccio/core';
import { logger } from '@verdaccio/logger';
import { Storage } from '@verdaccio/store'; import { Storage } from '@verdaccio/store';
import { Manifest } from '@verdaccio/types'; import { Manifest } from '@verdaccio/types';
import { Logger } from '@verdaccio/types';
const debug = buildDebug('verdaccio:api:search'); const debug = buildDebug('verdaccio:api:search');
@ -15,7 +15,7 @@ const debug = buildDebug('verdaccio:api:search');
* - {"objects":[],"total":0,"time":"Sun Jul 25 2021 14:09:11 GMT+0000 (Coordinated Universal Time)"} * - {"objects":[],"total":0,"time":"Sun Jul 25 2021 14:09:11 GMT+0000 (Coordinated Universal Time)"}
* req: 'GET /-/v1/search?text=react&size=20&frpom=0&quality=0.65&popularity=0.98&maintenance=0.5' * req: 'GET /-/v1/search?text=react&size=20&frpom=0&quality=0.65&popularity=0.98&maintenance=0.5'
*/ */
export default function (route, auth: Auth, storage: Storage): void { export default function (route, auth: Auth, storage: Storage, logger: Logger): void {
function checkAccess(pkg: any, auth: any, remoteUser): Promise<Manifest | null> { function checkAccess(pkg: any, auth: any, remoteUser): Promise<Manifest | null> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
auth.allow_access({ packageName: pkg?.package?.name }, remoteUser, function (err, allowed) { auth.allow_access({ packageName: pkg?.package?.name }, remoteUser, function (err, allowed) {

View file

@ -4,10 +4,10 @@ import _ from 'lodash';
import { getApiToken } from '@verdaccio/auth'; import { getApiToken } from '@verdaccio/auth';
import { Auth } from '@verdaccio/auth'; import { Auth } from '@verdaccio/auth';
import { HEADERS, HTTP_STATUS, SUPPORT_ERRORS, errorUtils } from '@verdaccio/core'; import { HEADERS, HTTP_STATUS, SUPPORT_ERRORS, errorUtils } from '@verdaccio/core';
import { logger } from '@verdaccio/logger';
import { rateLimit } from '@verdaccio/middleware'; import { rateLimit } from '@verdaccio/middleware';
import { Storage } from '@verdaccio/store'; import { Storage } from '@verdaccio/store';
import { Config, RemoteUser, Token } from '@verdaccio/types'; import { Config, RemoteUser, Token } from '@verdaccio/types';
import { Logger } from '@verdaccio/types';
import { mask, stringToMD5 } from '@verdaccio/utils'; import { mask, stringToMD5 } from '@verdaccio/utils';
import { $NextFunctionVer, $RequestExtend } from '../../types/custom'; import { $NextFunctionVer, $RequestExtend } from '../../types/custom';
@ -24,7 +24,13 @@ function normalizeToken(token: Token): NormalizeToken {
} }
// https://github.com/npm/npm-profile/blob/latest/lib/index.js // https://github.com/npm/npm-profile/blob/latest/lib/index.js
export default function (route: Router, auth: Auth, storage: Storage, config: Config): void { export default function (
route: Router,
auth: Auth,
storage: Storage,
config: Config,
logger: Logger
): void {
route.get( route.get(
'/-/npm/v1/tokens', '/-/npm/v1/tokens',
rateLimit(config?.userRateLimit), rateLimit(config?.userRateLimit),

View file

@ -2,9 +2,12 @@ import supertest from 'supertest';
import { beforeEach, describe, expect, test } from 'vitest'; import { beforeEach, describe, expect, test } from 'vitest';
import { API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { API_MESSAGE, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger';
import { getDisTags, initializeServer, publishVersion } from './_helper'; import { getDisTags, initializeServer, publishVersion } from './_helper';
setup({});
describe('package', () => { describe('package', () => {
let app; let app;
beforeEach(async () => { beforeEach(async () => {

View file

@ -41,7 +41,6 @@
"@verdaccio/config": "workspace:8.0.0-next-8.3", "@verdaccio/config": "workspace:8.0.0-next-8.3",
"@verdaccio/core": "workspace:8.0.0-next-8.3", "@verdaccio/core": "workspace:8.0.0-next-8.3",
"@verdaccio/loaders": "workspace:8.0.0-next-8.3", "@verdaccio/loaders": "workspace:8.0.0-next-8.3",
"@verdaccio/logger": "workspace:8.0.0-next-8.3",
"@verdaccio/signature": "workspace:8.0.0-next-8.1", "@verdaccio/signature": "workspace:8.0.0-next-8.1",
"@verdaccio/utils": "workspace:8.1.0-next-8.3", "@verdaccio/utils": "workspace:8.1.0-next-8.3",
"debug": "4.3.7", "debug": "4.3.7",
@ -51,6 +50,7 @@
"devDependencies": { "devDependencies": {
"@verdaccio/middleware": "workspace:8.0.0-next-8.3", "@verdaccio/middleware": "workspace:8.0.0-next-8.3",
"@verdaccio/types": "workspace:13.0.0-next-8.1", "@verdaccio/types": "workspace:13.0.0-next-8.1",
"@verdaccio/logger": "workspace:8.0.0-next-8.3",
"express": "4.21.1", "express": "4.21.1",
"supertest": "7.0.0" "supertest": "7.0.0"
}, },

View file

@ -15,7 +15,6 @@ import {
warningUtils, warningUtils,
} from '@verdaccio/core'; } from '@verdaccio/core';
import { asyncLoadPlugin } from '@verdaccio/loaders'; import { asyncLoadPlugin } from '@verdaccio/loaders';
import { logger } from '@verdaccio/logger';
import { import {
aesEncrypt, aesEncrypt,
aesEncryptDeprecated, aesEncryptDeprecated,
@ -28,6 +27,7 @@ import {
Callback, Callback,
Config, Config,
JWTSignOptions, JWTSignOptions,
Logger,
PackageAccess, PackageAccess,
RemoteUser, RemoteUser,
Security, Security,
@ -57,11 +57,13 @@ const debug = buildDebug('verdaccio:auth');
class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth { class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
public config: Config; public config: Config;
public secret: string; public secret: string;
public logger: Logger;
public plugins: pluginUtils.Auth<Config>[]; public plugins: pluginUtils.Auth<Config>[];
public constructor(config: Config) { public constructor(config: Config, logger: Logger) {
this.config = config; this.config = config;
this.secret = config.secret; this.secret = config.secret;
this.logger = logger;
this.plugins = []; this.plugins = [];
if (!this.secret) { if (!this.secret) {
throw new TypeError('secret it is required value on initialize the auth class'); throw new TypeError('secret it is required value on initialize the auth class');
@ -84,7 +86,7 @@ class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
debug('load default auth plugin'); debug('load default auth plugin');
const pluginOptions: pluginUtils.PluginOptions = { const pluginOptions: pluginUtils.PluginOptions = {
config: this.config, config: this.config,
logger, logger: this.logger,
}; };
let authPlugin; let authPlugin;
try { try {
@ -94,7 +96,7 @@ class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
); );
} catch (error: any) { } catch (error: any) {
debug('error on loading auth htpasswd plugin stack: %o', error); debug('error on loading auth htpasswd plugin stack: %o', error);
logger.info({}, 'no auth plugin has been found'); this.logger.info({}, 'no auth plugin has been found');
return []; return [];
} }
@ -106,7 +108,7 @@ class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
this.config.auth, this.config.auth,
{ {
config: this.config, config: this.config,
logger, logger: this.logger,
}, },
(plugin): boolean => { (plugin): boolean => {
const { authenticate, allow_access, allow_publish } = plugin; const { authenticate, allow_access, allow_publish } = plugin;
@ -124,7 +126,7 @@ class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
private _applyDefaultPlugins(): void { private _applyDefaultPlugins(): void {
// TODO: rename to applyFallbackPluginMethods // TODO: rename to applyFallbackPluginMethods
this.plugins.push(getDefaultPlugins(logger)); this.plugins.push(getDefaultPlugins(this.logger));
} }
public changePassword( public changePassword(
@ -147,7 +149,7 @@ class Auth implements IAuthMiddleware, TokenEncryption, pluginUtils.IBasicAuth {
debug('updating password for %o', username); debug('updating password for %o', username);
plugin.changePassword!(username, password, newPassword, (err, profile): void => { plugin.changePassword!(username, password, newPassword, (err, profile): void => {
if (err) { if (err) {
logger.error( this.logger.error(
{ username, err }, { username, err },
`An error has been produced `An error has been produced
updating the password for @{username}. Error: @{err.message}` updating the password for @{username}. Error: @{err.message}`

View file

@ -10,7 +10,7 @@ import {
} from '@verdaccio/config'; } from '@verdaccio/config';
import { getDefaultConfig } from '@verdaccio/config'; import { getDefaultConfig } from '@verdaccio/config';
import { TOKEN_BEARER } from '@verdaccio/core'; import { TOKEN_BEARER } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { logger, setup } from '@verdaccio/logger';
import { signPayload } from '@verdaccio/signature'; import { signPayload } from '@verdaccio/signature';
import { Config, RemoteUser, Security } from '@verdaccio/types'; import { Config, RemoteUser, Security } from '@verdaccio/types';
import { buildToken, buildUserBuffer } from '@verdaccio/utils'; import { buildToken, buildUserBuffer } from '@verdaccio/utils';
@ -52,7 +52,7 @@ describe('Auth utilities', () => {
methodNotBeenCalled: string methodNotBeenCalled: string
): Promise<string> { ): Promise<string> {
const config: Config = getConfig(configFileName, secret); const config: Config = getConfig(configFileName, secret);
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
// @ts-ignore // @ts-ignore
const spy = vi.spyOn(auth, methodToSpy); const spy = vi.spyOn(auth, methodToSpy);
@ -155,7 +155,7 @@ describe('Auth utilities', () => {
test.concurrent('should return empty credential corrupted payload', async () => { test.concurrent('should return empty credential corrupted payload', async () => {
const secret = 'b2df428b9929d3ace7c598bbf4e496b2'; const secret = 'b2df428b9929d3ace7c598bbf4e496b2';
const config: Config = getConfig('security-legacy', secret); const config: Config = getConfig('security-legacy', secret);
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
// @ts-expect-error // @ts-expect-error
const token = auth.aesEncrypt(null); const token = auth.aesEncrypt(null);

View file

@ -11,7 +11,7 @@ import {
} from '@verdaccio/config'; } from '@verdaccio/config';
import { getDefaultConfig } from '@verdaccio/config'; import { getDefaultConfig } from '@verdaccio/config';
import { API_ERROR, CHARACTER_ENCODING, VerdaccioError, errorUtils } from '@verdaccio/core'; import { API_ERROR, CHARACTER_ENCODING, VerdaccioError, errorUtils } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { logger, setup } from '@verdaccio/logger';
import { aesDecrypt, verifyPayload } from '@verdaccio/signature'; import { aesDecrypt, verifyPayload } from '@verdaccio/signature';
import { Config, RemoteUser } from '@verdaccio/types'; import { Config, RemoteUser } from '@verdaccio/types';
import { getAuthenticatedMessage } from '@verdaccio/utils'; import { getAuthenticatedMessage } from '@verdaccio/utils';
@ -61,7 +61,7 @@ describe('Auth utilities', () => {
methodNotBeenCalled: string methodNotBeenCalled: string
): Promise<string> { ): Promise<string> {
const config: Config = getConfig(configFileName, secret); const config: Config = getConfig(configFileName, secret);
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
// @ts-ignore // @ts-ignore
const spy = vi.spyOn(auth, methodToSpy); const spy = vi.spyOn(auth, methodToSpy);

View file

@ -45,7 +45,7 @@ describe('AuthTest', () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
}); });
@ -54,7 +54,7 @@ describe('AuthTest', () => {
const config: Config = new AppConfig({ ...authProfileConf, auth: undefined }); const config: Config = new AppConfig({ ...authProfileConf, auth: undefined });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
}); });
@ -68,7 +68,7 @@ describe('AuthTest', () => {
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
}); });
@ -79,7 +79,7 @@ describe('AuthTest', () => {
test('should be a success login', async () => { test('should be a success login', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -106,7 +106,7 @@ describe('AuthTest', () => {
test('should be a fail on login', async () => { test('should be a fail on login', async () => {
const config: Config = new AppConfig(authPluginFailureConf); const config: Config = new AppConfig(authPluginFailureConf);
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -125,7 +125,7 @@ describe('AuthTest', () => {
test('should skip falsy values', async () => { test('should skip falsy values', async () => {
const config: Config = new AppConfig({ ...authPluginPassThrougConf }); const config: Config = new AppConfig({ ...authPluginPassThrougConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -145,7 +145,7 @@ describe('AuthTest', () => {
test('should error truthy non-array', async () => { test('should error truthy non-array', async () => {
const config: Config = new AppConfig({ ...authPluginPassThrougConf }); const config: Config = new AppConfig({ ...authPluginPassThrougConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -163,7 +163,7 @@ describe('AuthTest', () => {
test('should skip empty array', async () => { test('should skip empty array', async () => {
const config: Config = new AppConfig({ ...authPluginPassThrougConf }); const config: Config = new AppConfig({ ...authPluginPassThrougConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -180,7 +180,7 @@ describe('AuthTest', () => {
test('should accept valid array', async () => { test('should accept valid array', async () => {
const config: Config = new AppConfig({ ...authPluginPassThrougConf }); const config: Config = new AppConfig({ ...authPluginPassThrougConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -208,7 +208,7 @@ describe('AuthTest', () => {
}, },
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
return new Promise((resolve) => { return new Promise((resolve) => {
@ -229,7 +229,7 @@ describe('AuthTest', () => {
test('should fail if the plugin does not provide implementation', async () => { test('should fail if the plugin does not provide implementation', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
const callback = vi.fn(); const callback = vi.fn();
@ -244,7 +244,7 @@ describe('AuthTest', () => {
test('should handle plugin does provide implementation', async () => { test('should handle plugin does provide implementation', async () => {
const config: Config = new AppConfig({ ...authChangePasswordConf }); const config: Config = new AppConfig({ ...authChangePasswordConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
const callback = vi.fn(); const callback = vi.fn();
@ -262,7 +262,7 @@ describe('AuthTest', () => {
test('should fails if groups do not match exactly', async () => { test('should fails if groups do not match exactly', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -284,7 +284,7 @@ describe('AuthTest', () => {
test('should success if groups do not match exactly', async () => { test('should success if groups do not match exactly', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -311,7 +311,7 @@ describe('AuthTest', () => {
test('should fails if groups do not match exactly', async () => { test('should fails if groups do not match exactly', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -333,7 +333,7 @@ describe('AuthTest', () => {
test('should success if groups do match exactly', async () => { test('should success if groups do match exactly', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -358,7 +358,7 @@ describe('AuthTest', () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -392,7 +392,7 @@ describe('AuthTest', () => {
}, },
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -415,7 +415,7 @@ describe('AuthTest', () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -442,7 +442,7 @@ describe('AuthTest', () => {
test('should fails with bad password if adduser is not implemented', async () => { test('should fails with bad password if adduser is not implemented', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -465,7 +465,7 @@ describe('AuthTest', () => {
}, },
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -489,7 +489,7 @@ describe('AuthTest', () => {
}, },
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -513,7 +513,7 @@ describe('AuthTest', () => {
}, },
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -537,7 +537,7 @@ describe('AuthTest', () => {
}, },
}); });
config.checkSecretKey('12345'); config.checkSecretKey('12345');
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
expect(auth).toBeDefined(); expect(auth).toBeDefined();
@ -583,7 +583,7 @@ describe('AuthTest', () => {
test('should handle invalid auth token', async () => { test('should handle invalid auth token', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey(secret); config.checkSecretKey(secret);
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const app = await getServer(auth); const app = await getServer(auth);
return supertest(app) return supertest(app)
@ -595,7 +595,7 @@ describe('AuthTest', () => {
test('should handle missing auth header', async () => { test('should handle missing auth header', async () => {
const config: Config = new AppConfig({ ...authProfileConf }); const config: Config = new AppConfig({ ...authProfileConf });
config.checkSecretKey(secret); config.checkSecretKey(secret);
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const app = await getServer(auth); const app = await getServer(auth);
return supertest(app).get(`/`).expect(HTTP_STATUS.OK); return supertest(app).get(`/`).expect(HTTP_STATUS.OK);
@ -610,7 +610,7 @@ describe('AuthTest', () => {
// intended to force key generator (associated with mocks above) // intended to force key generator (associated with mocks above)
// 64 characters secret long // 64 characters secret long
config.checkSecretKey('35fabdd29b820d39125e76e6d85cc294'); config.checkSecretKey('35fabdd29b820d39125e76e6d85cc294');
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const token = auth.aesEncrypt(payload) as string; const token = auth.aesEncrypt(payload) as string;
const app = await getServer(auth); const app = await getServer(auth);
@ -626,7 +626,7 @@ describe('AuthTest', () => {
const config: Config = new AppConfig({ ...authPluginFailureConf }); const config: Config = new AppConfig({ ...authPluginFailureConf });
// intended to force key generator (associated with mocks above) // intended to force key generator (associated with mocks above)
config.checkSecretKey(undefined); config.checkSecretKey(undefined);
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const token = auth.aesEncrypt(payload) as string; const token = auth.aesEncrypt(payload) as string;
const app = await getServer(auth); const app = await getServer(auth);
@ -646,7 +646,7 @@ describe('AuthTest', () => {
...{ security: { api: { jwt: { sign: { expiresIn: '29d' } } } } }, ...{ security: { api: { jwt: { sign: { expiresIn: '29d' } } } } },
}); });
config.checkSecretKey(secret); config.checkSecretKey(secret);
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const app = await getServer(auth); const app = await getServer(auth);
const res = await supertest(app) const res = await supertest(app)
@ -668,7 +668,7 @@ describe('AuthTest', () => {
...{ security: { api: { jwt: { sign: { expiresIn: '29d' } } } } }, ...{ security: { api: { jwt: { sign: { expiresIn: '29d' } } } } },
}); });
config.checkSecretKey(secret); config.checkSecretKey(secret);
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const app = await getServer(auth); const app = await getServer(auth);
const res = await supertest(app).get(`/`).expect(HTTP_STATUS.OK); const res = await supertest(app).get(`/`).expect(HTTP_STATUS.OK);
@ -691,7 +691,7 @@ describe('AuthTest', () => {
); );
// intended to force key generator (associated with mocks above) // intended to force key generator (associated with mocks above)
config.checkSecretKey(undefined); config.checkSecretKey(undefined);
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
const token = (await auth.jwtEncrypt( const token = (await auth.jwtEncrypt(
createRemoteUser('jwt_user', [ROLES.ALL]), createRemoteUser('jwt_user', [ROLES.ALL]),

View file

@ -1,10 +0,0 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
// FIXME: increase to 90
lines: 4,
},
},
});

View file

@ -34,7 +34,7 @@
"types": "build/index.d.ts", "types": "build/index.d.ts",
"scripts": { "scripts": {
"clean": "rimraf ./build", "clean": "rimraf ./build",
"test": "jest", "test": "vitest run",
"type-check": "tsc --noEmit -p tsconfig.build.json", "type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",

View file

@ -1,3 +1,5 @@
import { describe, test } from 'vitest';
describe('cli test', () => { describe('cli test', () => {
test.todo('write some test for this module'); test.todo('write some test for this module');
}); });

View file

@ -1,16 +1,20 @@
import { describe, expect, test } from 'vitest';
import { isVersionValid } from '../src/utils'; import { isVersionValid } from '../src/utils';
test('valid version node.js', () => { describe('utils', () => {
expect(isVersionValid('v14.0.0')).toBeTruthy(); test('valid version node.js', () => {
expect(isVersionValid('v15.0.0')).toBeTruthy(); expect(isVersionValid('v14.0.0')).toBeTruthy();
expect(isVersionValid('v16.0.0')).toBeTruthy(); expect(isVersionValid('v15.0.0')).toBeTruthy();
expect(isVersionValid('v17.0.0')).toBeTruthy(); expect(isVersionValid('v16.0.0')).toBeTruthy();
}); expect(isVersionValid('v17.0.0')).toBeTruthy();
});
test('is invalid version node.js', () => { test('is invalid version node.js', () => {
expect(isVersionValid('v13.0.0')).toBeFalsy(); expect(isVersionValid('v13.0.0')).toBeFalsy();
expect(isVersionValid('v12.0.0')).toBeFalsy(); expect(isVersionValid('v12.0.0')).toBeFalsy();
expect(isVersionValid('v8.0.0')).toBeFalsy(); expect(isVersionValid('v8.0.0')).toBeFalsy();
expect(isVersionValid('v4.0.0')).toBeFalsy(); expect(isVersionValid('v4.0.0')).toBeFalsy();
expect(isVersionValid('v0.0.10')).toBeFalsy(); expect(isVersionValid('v0.0.10')).toBeFalsy();
});
}); });

View file

@ -13,9 +13,6 @@
{ {
"path": "../core/core" "path": "../core/core"
}, },
{
"path": "../core/server"
},
{ {
"path": "../node-api" "path": "../node-api"
}, },

View file

@ -1,3 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {});

View file

@ -43,7 +43,7 @@
}, },
"scripts": { "scripts": {
"clean": "rimraf ./build", "clean": "rimraf ./build",
"test": "jest", "test": "vitest run",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"watch": "pnpm build:js -- --watch", "watch": "pnpm build:js -- --watch",

View file

@ -1,5 +1,6 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { describe, expect, test } from 'vitest';
import { lockFile, readFile, unlockFile } from '../src/index'; import { lockFile, readFile, unlockFile } from '../src/index';
@ -22,113 +23,131 @@ const removeTempFile = (filename: string): void => {
describe('testing locking', () => { describe('testing locking', () => {
describe('lockFile', () => { describe('lockFile', () => {
test('file should be found to be locked', (done) => { test('file should be found to be locked', () => {
lockFile(getFilePath('package.json'), (error: Error) => { return new Promise((done) => {
expect(error).toBeNull(); lockFile(getFilePath('package.json'), (error: Error) => {
removeTempFile('package.json.lock'); expect(error).toBeNull();
done(); removeTempFile('package.json.lock');
done(true);
});
}); });
}); });
test('file should fail to be found to be locked', (done) => { test('file should fail to be found to be locked', () => {
lockFile(getFilePath('package.fail.json'), (error: Error) => { return new Promise((done) => {
expect(error.message).toMatch( lockFile(getFilePath('package.fail.json'), (error: Error) => {
/ENOENT: no such file or directory, stat '(.*)package.fail.json'/ expect(error.message).toMatch(
); /ENOENT: no such file or directory, stat '(.*)package.fail.json'/
done(); );
done(true);
});
}); });
}); });
}); });
describe('unlockFile', () => { describe('unlockFile', () => {
test('file should to be found to be unLock', (done) => { test('file should to be found to be unLock', () => {
unlockFile(getFilePath('package.json.lock'), (error: Error) => { return new Promise((done) => {
expect(error).toBeNull(); unlockFile(getFilePath('package.json.lock'), (error: Error) => {
done(); expect(error).toBeNull();
done(true);
});
}); });
}); });
}); });
describe('readFile', () => { describe('readFile', () => {
test('read file with no options should to be found to be read it as string', (done) => { test('read file with no options should to be found to be read it as string', () => {
readFile(getFilePath('package.json'), {}, (error: Error, data: string) => { return new Promise((done) => {
expect(error).toBeNull(); readFile(getFilePath('package.json'), {}, (error: Error, data: string) => {
expect(data).toMatchInlineSnapshot(` expect(error).toBeNull();
expect(data).toMatchInlineSnapshot(`
"{ "{
"name": "assets", "name": "assets",
"version": "0.0.1" "version": "0.0.1"
} }
" "
`); `);
done(); done(true);
});
}); });
}); });
test('read file with no options should to be found to be read it as object', (done) => { test('read file with no options should to be found to be read it as object', () => {
const options = { const options = {
parse: true, parse: true,
}; };
readFile(getFilePath('package.json'), options, (error: Error, data: string) => { return new Promise((done) => {
expect(error).toBeNull(); readFile(getFilePath('package.json'), options, (error: Error, data: string) => {
expect(data).toMatchInlineSnapshot(` expect(error).toBeNull();
expect(data).toMatchInlineSnapshot(`
{ {
"name": "assets", "name": "assets",
"version": "0.0.1", "version": "0.0.1",
} }
`); `);
done(); done(true);
});
}); });
}); });
test('read file with options (parse) should to be not found to be read it', (done) => { test('read file with options (parse) should to be not found to be read it', () => {
const options = { const options = {
parse: true, parse: true,
}; };
readFile(getFilePath('package.fail.json'), options, (error: Error) => { return new Promise((done) => {
expect(error.message).toMatch(/ENOENT/); readFile(getFilePath('package.fail.json'), options, (error: Error) => {
done(); expect(error.message).toMatch(/ENOENT/);
done(true);
});
}); });
}); });
test('read file with options should be found to be read it and fails to be parsed', (done) => { test('read file with options should be found to be read it and fails to be parsed', () => {
const options = { const options = {
parse: true, parse: true,
}; };
readFile(getFilePath('wrong.package.json'), options, (error: Error) => { return new Promise((done) => {
expect(error.message).toBeDefined(); readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
done(); expect(error.message).toBeDefined();
done(true);
});
}); });
}); });
test('read file with options (parse, lock) should be found to be read it as object', (done) => { test('read file with options (parse, lock) should be found to be read it as object', () => {
const options = { const options = {
parse: true, parse: true,
lock: true, lock: true,
}; };
readFile(getFilePath('package2.json'), options, (error: Error, data: string) => { return new Promise((done) => {
expect(error).toBeNull(); readFile(getFilePath('package2.json'), options, (error: Error, data: string) => {
expect(data).toMatchInlineSnapshot(` expect(error).toBeNull();
expect(data).toMatchInlineSnapshot(`
{ {
"name": "assets", "name": "assets",
"version": "0.0.1", "version": "0.0.1",
} }
`); `);
removeTempFile('package2.json.lock'); removeTempFile('package2.json.lock');
done(); done(true);
});
}); });
}); });
test.skip( test.skip(
'read file with options (parse, lock) should be found to be read and ' + 'fails to be parsed', 'read file with options (parse, lock) should be found to be read and ' + 'fails to be parsed',
(done) => { () => {
const options = { const options = {
parse: true, parse: true,
lock: true, lock: true,
}; };
readFile(getFilePath('wrong.package.json'), options, (error: Error) => { return new Promise((done) => {
expect(error.message).toMatch(/Unexpected token } in JSON at position \d+/); readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
removeTempFile('wrong.package.json.lock'); expect(error.message).toMatch(/Unexpected token } in JSON at position \d+/);
done(); removeTempFile('wrong.package.json.lock');
done(true);
});
}); });
} }
); );

View file

@ -1,5 +1,6 @@
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import { describe, expect, test } from 'vitest';
import { lockFileNext, readFileNext, unlockFileNext } from '../src/index'; import { lockFileNext, readFileNext, unlockFileNext } from '../src/index';
import { statDir, statFile } from '../src/utils'; import { statDir, statFile } from '../src/utils';

View file

@ -1,10 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
// FIXME: increase to 90
lines: 39,
},
},
});

View file

@ -35,7 +35,6 @@
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"watch": "pnpm build:js -- --watch", "watch": "pnpm build:js -- --watch",
"test": "vitest run", "test": "vitest run",
"test:snap": "jest --updateSnapshot",
"build": "pnpm run build:js && pnpm run build:types" "build": "pnpm run build:js && pnpm run build:types"
}, },
"dependencies": { "dependencies": {

View file

@ -1,10 +0,0 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
// FIXME: increase to 90
lines: 40,
},
},
});

View file

@ -34,7 +34,7 @@
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"watch": "pnpm build:js -- --watch", "watch": "pnpm build:js -- --watch",
"build": "pnpm run build:js && pnpm run build:types", "build": "pnpm run build:js && pnpm run build:types",
"test": "jest" "test": "vitest run"
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View file

@ -1,4 +1,5 @@
import _ from 'lodash'; import _ from 'lodash';
import { describe, expect, test } from 'vitest';
import { import {
DEFAULT_DOMAIN, DEFAULT_DOMAIN,

View file

@ -1,4 +1,5 @@
import _ from 'lodash'; import _ from 'lodash';
import { describe, expect, test } from 'vitest';
import { DEFAULT_DOMAIN, DEFAULT_PORT, parseAddress } from '../src/cli-utils'; import { DEFAULT_DOMAIN, DEFAULT_PORT, parseAddress } from '../src/cli-utils';

View file

@ -1,9 +1,11 @@
import request from 'supertest'; import request from 'supertest';
import { describe, expect, test } from 'vitest';
import { runServer } from '../src'; import { runServer } from '../src';
describe('startServer via API', () => { describe('startServer via API', () => {
test('should provide all HTTP server data', async () => { // TODO: fix this test does not runs with vitest
test.skip('should provide all HTTP server data', async () => {
const webServer = await runServer(); const webServer = await runServer();
expect(webServer).toBeDefined(); expect(webServer).toBeDefined();
await request(webServer).get('/').expect(200); await request(webServer).get('/').expect(200);
@ -15,6 +17,7 @@ describe('startServer via API', () => {
}); });
test('should fail on start with null as entry', async () => { test('should fail on start with null as entry', async () => {
// @ts-expect-error
await expect(runServer(null)).rejects.toThrow(); await expect(runServer(null)).rejects.toThrow();
}); });
}); });

View file

@ -1,3 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {});

View file

@ -1,3 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {});

View file

@ -43,7 +43,7 @@
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"build": "pnpm run build:js && pnpm run build:types", "build": "pnpm run build:js && pnpm run build:types",
"test": "jest" "test": "vitest run"
}, },
"funding": { "funding": {
"type": "opencollective", "type": "opencollective",

View file

@ -1,3 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {});

View file

@ -48,7 +48,7 @@
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
"build": "pnpm run build:js && pnpm run build:types", "build": "pnpm run build:js && pnpm run build:types",
"test": "jest" "test": "vitest run"
}, },
"snyk": true, "snyk": true,
"funding": { "funding": {

View file

@ -58,6 +58,12 @@
"raw-loader": "4.0.2", "raw-loader": "4.0.2",
"react": "18.2.0", "react": "18.2.0",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"jest": "29.7.0",
"jest-diff": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-environment-jsdom-global": "4.0.0",
"jest-environment-node": "29.7.0",
"jest-junit": "16.0.0",
"react-hook-form": "7.52.1", "react-hook-form": "7.52.1",
"react-hot-loader": "4.13.1", "react-hot-loader": "4.13.1",
"react-i18next": "13.5.0", "react-i18next": "13.5.0",

View file

@ -1,12 +0,0 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
branches: 79,
functions: 94,
lines: 87,
statements: 87,
},
},
});

View file

@ -1,10 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
// FIXME: increase to 90
lines: 84,
},
},
});

View file

@ -53,7 +53,7 @@
}, },
"scripts": { "scripts": {
"clean": "rimraf ./build", "clean": "rimraf ./build",
"test": "jest", "test": "vitest run",
"type-check": "tsc --noEmit -p tsconfig.build.json", "type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"watch": "pnpm build:js -- --watch", "watch": "pnpm build:js -- --watch",

View file

@ -1 +1 @@
export { default } from './server'; export { default, startServer } from './server';

View file

@ -1,7 +1,7 @@
import compression from 'compression'; import compression from 'compression';
import cors from 'cors'; import cors from 'cors';
import buildDebug from 'debug'; import buildDebug from 'debug';
import express from 'express'; import express, { Express } from 'express';
import _ from 'lodash'; import _ from 'lodash';
import AuditMiddleware from 'verdaccio-audit'; import AuditMiddleware from 'verdaccio-audit';
@ -30,8 +30,8 @@ import hookDebug from './debug';
const debug = buildDebug('verdaccio:server'); const debug = buildDebug('verdaccio:server');
const { version } = require('../package.json'); const { version } = require('../package.json');
const defineAPI = async function (config: IConfig, storage: Storage): Promise<any> { const defineAPI = async function (config: IConfig, storage: Storage): Promise<Express> {
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
const app = express(); const app = express();
// run in production mode by default, just in case // run in production mode by default, just in case
@ -89,7 +89,7 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<an
// For npm request // For npm request
// @ts-ignore // @ts-ignore
app.use(apiEndpoint(config, auth, storage)); app.use(apiEndpoint(config, auth, storage, logger));
// For WebUI & WebUI API // For WebUI & WebUI API
if (_.get(config, 'web.enable', true)) { if (_.get(config, 'web.enable', true)) {
@ -140,7 +140,7 @@ const defineAPI = async function (config: IConfig, storage: Storage): Promise<an
return app; return app;
}; };
export default (async function startServer(configHash: ConfigYaml): Promise<any> { const startServer = async function startServer(configHash: ConfigYaml): Promise<Express> {
debug('start server'); debug('start server');
const config: IConfig = new AppConfig({ ...configHash } as any); const config: IConfig = new AppConfig({ ...configHash } as any);
// register middleware plugins // register middleware plugins
@ -157,4 +157,7 @@ export default (async function startServer(configHash: ConfigYaml): Promise<any>
throw new Error(err); throw new Error(err);
} }
return await defineAPI(config, storage); return await defineAPI(config, storage);
}); };
export { startServer };
export default startServer;

View file

@ -8,8 +8,6 @@ import { generateRandomHexString } from '@verdaccio/utils';
import apiMiddleware from '../src'; import apiMiddleware from '../src';
setup({});
export const getConf = async (conf) => { export const getConf = async (conf) => {
const configPath = path.join(__dirname, 'config', conf); const configPath = path.join(__dirname, 'config', conf);
const config = parseConfigFile(configPath); const config = parseConfigFile(configPath);
@ -25,5 +23,7 @@ export const getConf = async (conf) => {
}; };
export async function initializeServer(configName): Promise<Application> { export async function initializeServer(configName): Promise<Application> {
return apiMiddleware(await getConf(configName)); const config = await getConf(configName);
setup(config.log ?? {});
return apiMiddleware(config);
} }

View file

@ -1,113 +1,119 @@
import supertest from 'supertest'; import supertest from 'supertest';
import { describe, expect, test } from 'vitest';
import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger';
import { initializeServer } from './_helper'; import { initializeServer } from './_helper';
test('should request any package', async () => { setup({});
const app = await initializeServer('conf.yaml');
await supertest(app)
.get('/jquery')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HTTP_STATUS.NOT_FOUND);
});
test('should able to catch non defined routes with 404', async () => { describe('server api', () => {
const app = await initializeServer('conf.yaml'); test('should request any package', async () => {
await supertest(app) const app = await initializeServer('conf.yaml');
.get('/-/this-does-not-exist-anywhere') await supertest(app)
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) .get('/jquery')
.expect(HTTP_STATUS.NOT_FOUND); .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
}); .expect(HTTP_STATUS.NOT_FOUND);
});
test('should return index page if web is enabled', async () => { test('should able to catch non defined routes with 404', async () => {
const app = await initializeServer('conf.yaml'); const app = await initializeServer('conf.yaml');
const response = await supertest(app) await supertest(app)
.get('/') .get('/-/this-does-not-exist-anywhere')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HEADER_TYPE.CONTENT_ENCODING, HEADERS.GZIP) .expect(HTTP_STATUS.NOT_FOUND);
.expect(HTTP_STATUS.OK); });
expect(response.text).toMatch('<title>verdaccio</title>');
});
test('should define rate limit headers', async () => { test('should return index page if web is enabled', async () => {
const app = await initializeServer('conf.yaml'); const app = await initializeServer('conf.yaml');
await supertest(app) const response = await supertest(app)
.get('/') .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect('x-ratelimit-limit', '10000') .expect(HEADER_TYPE.CONTENT_ENCODING, HEADERS.GZIP)
.expect('x-ratelimit-remaining', '9999') .expect(HTTP_STATUS.OK);
.expect(HTTP_STATUS.OK); expect(response.text).toMatch('<title>verdaccio</title>');
}); });
test('should contains cors headers', async () => { test('should define rate limit headers', async () => {
const app = await initializeServer('conf.yaml'); const app = await initializeServer('conf.yaml');
await supertest(app).get('/').expect('access-control-allow-origin', '*').expect(HTTP_STATUS.OK); await supertest(app)
}); .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect('x-ratelimit-limit', '10000')
.expect('x-ratelimit-remaining', '9999')
.expect(HTTP_STATUS.OK);
});
test('should contains etag', async () => { test('should contains cors headers', async () => {
const app = await initializeServer('conf.yaml'); const app = await initializeServer('conf.yaml');
const response = await supertest(app) await supertest(app).get('/').expect('access-control-allow-origin', '*').expect(HTTP_STATUS.OK);
.get('/') });
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect(HTTP_STATUS.OK);
const etag = response.get(HEADERS.ETAG);
expect(typeof etag === 'string').toBeTruthy();
});
test('should be hidden by default', async () => { test('should contains etag', async () => {
const app = await initializeServer('conf.yaml'); const app = await initializeServer('conf.yaml');
const response = await supertest(app) const response = await supertest(app)
.get('/') .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect(HTTP_STATUS.OK); .expect(HTTP_STATUS.OK);
const powered = response.get('x-powered-by'); const etag = response.get(HEADERS.ETAG);
expect(powered).toMatch('hidden'); expect(typeof etag === 'string').toBeTruthy();
}, 40000); });
test('should not contains powered header', async () => { test('should be hidden by default', async () => {
const app = await initializeServer('powered-disabled.yaml'); const app = await initializeServer('conf.yaml');
const response = await supertest(app) const response = await supertest(app)
.get('/') .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect(HTTP_STATUS.OK); .expect(HTTP_STATUS.OK);
const powered = response.get('x-powered-by'); const powered = response.get('x-powered-by');
expect(powered).toEqual('hidden'); expect(powered).toMatch('hidden');
}); }, 40000);
test('should contains custom powered header', async () => { test('should not contains powered header', async () => {
const app = await initializeServer('powered-custom.yaml'); const app = await initializeServer('powered-disabled.yaml');
const response = await supertest(app) const response = await supertest(app)
.get('/') .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect(HTTP_STATUS.OK); .expect(HTTP_STATUS.OK);
const powered = response.get('x-powered-by'); const powered = response.get('x-powered-by');
expect(powered).toEqual('custom user agent'); expect(powered).toEqual('hidden');
}); });
test('should return 404 if web is disabled', async () => { test('should contains custom powered header', async () => {
const app = await initializeServer('web-disabled.yaml'); const app = await initializeServer('powered-custom.yaml');
const response = await supertest(app) const response = await supertest(app)
.get('/') .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_HTML_UTF8)
.expect(HTTP_STATUS.NOT_FOUND); .expect(HTTP_STATUS.OK);
expect(response.body.error).toEqual(API_ERROR.WEB_DISABLED); const powered = response.get('x-powered-by');
}); expect(powered).toEqual('custom user agent');
});
test('should not display debug hook disabled by default', async () => { test('should return 404 if web is disabled', async () => {
const app = await initializeServer('no_debug.yaml'); const app = await initializeServer('web-disabled.yaml');
await supertest(app) const response = await supertest(app)
.get('/-/_debug') .get('/')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HTTP_STATUS.NOT_FOUND); .expect(HTTP_STATUS.NOT_FOUND);
}); expect(response.body.error).toEqual(API_ERROR.WEB_DISABLED);
});
test('should display debug hook if directly enabled', async () => { test('should not display debug hook disabled by default', async () => {
const app = await initializeServer('conf.yaml'); const app = await initializeServer('no_debug.yaml');
const res = await supertest(app) await supertest(app)
.get('/-/_debug') .get('/-/_debug')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET) .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HTTP_STATUS.OK); .expect(HTTP_STATUS.NOT_FOUND);
expect(res.body.pid).toEqual(process.pid); });
expect(res.body.mem).toBeDefined();
test('should display debug hook if directly enabled', async () => {
const app = await initializeServer('conf.yaml');
const res = await supertest(app)
.get('/-/_debug')
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
.expect(HTTP_STATUS.OK);
expect(res.body.pid).toEqual(process.pid);
expect(res.body.mem).toBeDefined();
});
}); });

View file

@ -1,3 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {});

View file

@ -2,12 +2,13 @@ import { FastifyInstance } from 'fastify';
import fp from 'fastify-plugin'; import fp from 'fastify-plugin';
import { Auth } from '@verdaccio/auth'; import { Auth } from '@verdaccio/auth';
import { logger } from '@verdaccio/logger';
import { Config as IConfig } from '@verdaccio/types'; import { Config as IConfig } from '@verdaccio/types';
export default fp( export default fp(
async function (fastify: FastifyInstance, opts: { config: IConfig; filters?: unknown }) { async function (fastify: FastifyInstance, opts: { config: IConfig; filters?: unknown }) {
const { config } = opts; const { config } = opts;
const auth = new Auth(config); const auth = new Auth(config, logger);
await auth.init(); await auth.init();
fastify.decorate('auth', auth); fastify.decorate('auth', auth);
}, },

View file

@ -1,3 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {});

View file

@ -1,10 +0,0 @@
const config = require('../../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
// FIXME: increase to 90
lines: 40,
},
},
});

View file

@ -23,7 +23,7 @@
"supertest": "7.0.0" "supertest": "7.0.0"
}, },
"scripts": { "scripts": {
"test": "jest .", "test": "vitest run",
"clean": "rimraf ./build", "clean": "rimraf ./build",
"type-check": "tsc --noEmit -p tsconfig.build.json", "type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",

View file

@ -13,13 +13,13 @@ import { generateRandomHexString } from '@verdaccio/utils';
const debug = buildDebug('verdaccio:tools:helpers:server'); const debug = buildDebug('verdaccio:tools:helpers:server');
export async function initializeServer( export async function initializeServer(
configName, configObject,
routesMiddleware: any[] = [], routesMiddleware: any[] = [],
Storage Storage
): Promise<Application> { ): Promise<Application> {
const app = express(); const app = express();
const logger = setup({}); const logger = setup(configObject.log ?? {});
const config = new Config(configName); const config = new Config(configObject);
config.storage = path.join(os.tmpdir(), '/storage', generateRandomHexString()); config.storage = path.join(os.tmpdir(), '/storage', generateRandomHexString());
// httpass would get path.basename() for configPath thus we need to create a dummy folder // httpass would get path.basename() for configPath thus we need to create a dummy folder
// to avoid conflics // to avoid conflics
@ -28,7 +28,7 @@ export async function initializeServer(
const storage = new Storage(config, logger); const storage = new Storage(config, logger);
await storage.init(config, []); await storage.init(config, []);
const auth: Auth = new Auth(config); const auth: Auth = new Auth(config, logger);
await auth.init(); await auth.init();
// TODO: this might not be need it, used in apiEndpoints // TODO: this might not be need it, used in apiEndpoints
app.use(express.json({ strict: false, limit: '10mb' })); app.use(express.json({ strict: false, limit: '10mb' }));
@ -36,10 +36,10 @@ export async function initializeServer(
app.use(errorReportingMiddleware(logger)); app.use(errorReportingMiddleware(logger));
for (let route of routesMiddleware) { for (let route of routesMiddleware) {
if (route.async) { if (route.async) {
const middleware = await route.routes(config, auth, storage); const middleware = await route.routes(config, auth, storage, logger);
app.use(middleware); app.use(middleware);
} else { } else {
app.use(route(config, auth, storage)); app.use(route(config, auth, storage, logger));
} }
} }

View file

@ -1,3 +1,5 @@
import { describe, expect, test } from 'vitest';
import { import {
addNewVersion, addNewVersion,
generateLocalPackageMetadata, generateLocalPackageMetadata,

View file

@ -76,6 +76,12 @@
"@types/hast": "^2.0.0", "@types/hast": "^2.0.0",
"@types/react-router": "^5.1.20", "@types/react-router": "^5.1.20",
"@types/unist": "^2.0.0", "@types/unist": "^2.0.0",
"jest": "29.7.0",
"jest-diff": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-environment-jsdom-global": "4.0.0",
"jest-environment-node": "29.7.0",
"jest-junit": "16.0.0",
"@verdaccio/types": "workspace:13.0.0-next-8.1", "@verdaccio/types": "workspace:13.0.0-next-8.1",
"babel-loader": "9.1.3", "babel-loader": "9.1.3",
"mockdate": "3.0.5", "mockdate": "3.0.5",

View file

@ -1,9 +0,0 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
lines: 50,
},
},
});

View file

@ -1 +0,0 @@
jest.requireActual('babel/polyfill');

View file

@ -18,9 +18,8 @@
"scripts": { "scripts": {
"clean": "rimraf ./build", "clean": "rimraf ./build",
"lint": "eslint . --ext .js,.ts", "lint": "eslint . --ext .js,.ts",
"test": "jest --detectOpenHandles", "test": "vitest run --testTimeout 50000",
"ge:docs": "typedoc src/index.ts --tsconfig tsconfig.build.json --plugin typedoc-plugin-markdown", "ge:docs": "typedoc src/index.ts --tsconfig tsconfig.build.json --plugin typedoc-plugin-markdown",
"test:debug": "node --inspect-brk ../../node_modules/jest/bin/jest.js --config ./test/jest.config.functional.js --testPathPattern ./test/unit/* --passWithNoTests",
"type-check": "tsc --noEmit -p tsconfig.build.json", "type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",
@ -53,6 +52,7 @@
"@verdaccio/core": "workspace:8.0.0-next-8.3", "@verdaccio/core": "workspace:8.0.0-next-8.3",
"@verdaccio/store": "workspace:8.0.0-next-8.3", "@verdaccio/store": "workspace:8.0.0-next-8.3",
"@verdaccio/test-helper": "workspace:4.0.0-next-8.0", "@verdaccio/test-helper": "workspace:4.0.0-next-8.0",
"vite-tsconfig-paths": "5.0.1",
"fastify": "4.25.2", "fastify": "4.25.2",
"get-port": "5.1.1", "get-port": "5.1.1",
"got": "11.8.6", "got": "11.8.6",

View file

@ -1,4 +1,5 @@
import getPort from 'get-port'; import getPort from 'get-port';
import { afterAll, beforeAll, describe, test } from 'vitest';
import { ConfigBuilder } from '@verdaccio/config'; import { ConfigBuilder } from '@verdaccio/config';
import { API_MESSAGE, HTTP_STATUS, constants, fileUtils } from '@verdaccio/core'; import { API_MESSAGE, HTTP_STATUS, constants, fileUtils } from '@verdaccio/core';

View file

@ -1,5 +1,6 @@
import getPort from 'get-port'; import getPort from 'get-port';
import got from 'got'; import got from 'got';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import { ConfigBuilder } from '@verdaccio/config'; import { ConfigBuilder } from '@verdaccio/config';
import { constants, fileUtils } from '@verdaccio/core'; import { constants, fileUtils } from '@verdaccio/core';

View file

@ -1,4 +1,5 @@
import getPort from 'get-port'; import getPort from 'get-port';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import { ConfigBuilder } from '@verdaccio/config'; import { ConfigBuilder } from '@verdaccio/config';
import { API_MESSAGE, constants, fileUtils } from '@verdaccio/core'; import { API_MESSAGE, constants, fileUtils } from '@verdaccio/core';

View file

@ -1,4 +1,5 @@
import getPort from 'get-port'; import getPort from 'get-port';
import { afterAll, beforeAll, describe, test } from 'vitest';
import { ConfigBuilder } from '@verdaccio/config'; import { ConfigBuilder } from '@verdaccio/config';
import { HTTP_STATUS, constants, fileUtils } from '@verdaccio/core'; import { HTTP_STATUS, constants, fileUtils } from '@verdaccio/core';
@ -10,10 +11,6 @@ describe('multiple proxy registries configuration', () => {
let registry2; let registry2;
let registry3; let registry3;
// CI is slow, so we need to increase the timeout for the test
// some test uses retry with long timeouts
jest.setTimeout(40000);
beforeAll(async function () { beforeAll(async function () {
// server 1 configuration // server 1 configuration
const storage = await fileUtils.createTempStorageFolder('storage-server1'); const storage = await fileUtils.createTempStorageFolder('storage-server1');

View file

@ -1,4 +1,5 @@
import getPort from 'get-port'; import getPort from 'get-port';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import { ConfigBuilder } from '@verdaccio/config'; import { ConfigBuilder } from '@verdaccio/config';
import { constants, fileUtils } from '@verdaccio/core'; import { constants, fileUtils } from '@verdaccio/core';
@ -8,9 +9,6 @@ import { Registry, ServerQuery } from '../src/server';
describe('race publishing packages', () => { describe('race publishing packages', () => {
let registry; let registry;
// CI is slow, so we need to increase the timeout for the test.
jest.setTimeout(40000);
beforeAll(async function () { beforeAll(async function () {
const storage = await fileUtils.createTempStorageFolder('race-test'); const storage = await fileUtils.createTempStorageFolder('race-test');
const configuration = ConfigBuilder.build() const configuration = ConfigBuilder.build()

View file

@ -13,15 +13,9 @@
{ {
"path": "../cli" "path": "../cli"
}, },
{
"path": "../config"
},
{ {
"path": "../plugins/htpasswd" "path": "../plugins/htpasswd"
}, },
{
"path": "../tools/helper"
},
{ {
"path": "../hooks" "path": "../hooks"
}, },

View file

@ -1,10 +0,0 @@
const config = require('../../jest/config');
module.exports = Object.assign({}, config, {
coverageThreshold: {
global: {
// FIXME: increase to 90
lines: 72,
},
},
});

View file

@ -51,7 +51,7 @@
}, },
"scripts": { "scripts": {
"clean": "rimraf ./build", "clean": "rimraf ./build",
"test": "jest", "test": "vitest run",
"type-check": "tsc --noEmit -p tsconfig.build.json", "type-check": "tsc --noEmit -p tsconfig.build.json",
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json", "build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
"build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps", "build:js": "babel src/ --out-dir build/ --copy-files --extensions \".ts,.tsx\" --source-maps",

View file

@ -1,19 +1,20 @@
import path from 'path'; import path from 'path';
import supertest from 'supertest'; import supertest from 'supertest';
import { afterEach, describe, expect, test, vi } from 'vitest';
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { setup } from '@verdaccio/logger';
import { initializeServer } from './helper'; import { initializeServer } from './helper';
setup([]); setup({});
const mockManifest = jest.fn(); const mockManifest = vi.fn();
jest.mock('@verdaccio/ui-theme', () => mockManifest()); vi.mock('@verdaccio/ui-theme', () => mockManifest());
describe('test web server', () => { describe('test web server', () => {
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); vi.clearAllMocks();
mockManifest.mockClear(); mockManifest.mockClear();
}); });

View file

@ -1,5 +1,6 @@
import path from 'path'; import path from 'path';
import supertest from 'supertest'; import supertest from 'supertest';
import { afterEach, beforeAll, describe, expect, test, vi } from 'vitest';
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { setup } from '@verdaccio/logger';
@ -10,8 +11,8 @@ import { initializeServer } from './helper';
setup({}); setup({});
const mockManifest = jest.fn(); const mockManifest = vi.fn();
jest.mock('@verdaccio/ui-theme', () => mockManifest()); vi.mock('@verdaccio/ui-theme', () => mockManifest());
describe('readme api', () => { describe('readme api', () => {
beforeAll(() => { beforeAll(() => {
@ -25,7 +26,7 @@ describe('readme api', () => {
}); });
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); vi.clearAllMocks();
mockManifest.mockClear(); mockManifest.mockClear();
}); });

View file

@ -1,5 +1,6 @@
import path from 'path'; import path from 'path';
import supertest from 'supertest'; import supertest from 'supertest';
import { afterEach, beforeAll, describe, expect, test, vi } from 'vitest';
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { setup } from '@verdaccio/logger';
@ -7,10 +8,10 @@ import { publishVersion } from '@verdaccio/test-helper';
import { initializeServer } from './helper'; import { initializeServer } from './helper';
setup([]); setup({});
const mockManifest = jest.fn(); const mockManifest = vi.fn();
jest.mock('@verdaccio/ui-theme', () => mockManifest()); vi.mock('@verdaccio/ui-theme', () => mockManifest());
describe('test web server', () => { describe('test web server', () => {
beforeAll(() => { beforeAll(() => {
@ -24,8 +25,8 @@ describe('test web server', () => {
}); });
afterEach(() => { afterEach(() => {
Date.now = jest.fn(() => new Date(Date.UTC(2017, 1, 14)).valueOf()); Date.now = vi.fn(() => new Date(Date.UTC(2017, 1, 14)).valueOf());
jest.clearAllMocks(); vi.clearAllMocks();
mockManifest.mockClear(); mockManifest.mockClear();
}); });

View file

@ -1,5 +1,6 @@
import path from 'path'; import path from 'path';
import supertest from 'supertest'; import supertest from 'supertest';
import { afterEach, beforeAll, describe, expect, test, vi } from 'vitest';
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { setup } from '@verdaccio/logger';
@ -7,10 +8,10 @@ import { publishVersion } from '@verdaccio/test-helper';
import { initializeServer } from './helper'; import { initializeServer } from './helper';
setup([]); setup({});
const mockManifest = jest.fn(); const mockManifest = vi.fn();
jest.mock('@verdaccio/ui-theme', () => mockManifest()); vi.mock('@verdaccio/ui-theme', () => mockManifest());
describe('sidebar api', () => { describe('sidebar api', () => {
beforeAll(() => { beforeAll(() => {
@ -24,7 +25,7 @@ describe('sidebar api', () => {
}); });
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); vi.clearAllMocks();
mockManifest.mockClear(); mockManifest.mockClear();
}); });

View file

@ -1,15 +1,16 @@
import path from 'path'; import path from 'path';
import supertest from 'supertest'; import supertest from 'supertest';
import { afterEach, beforeAll, describe, expect, test, vi } from 'vitest';
import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core'; import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
import { setup } from '@verdaccio/logger'; import { setup } from '@verdaccio/logger';
import { initializeServer } from './helper'; import { initializeServer } from './helper';
setup([]); setup({});
const mockManifest = jest.fn(); const mockManifest = vi.fn();
jest.mock('@verdaccio/ui-theme', () => mockManifest()); vi.mock('@verdaccio/ui-theme', () => mockManifest());
describe('test web server', () => { describe('test web server', () => {
beforeAll(() => { beforeAll(() => {
@ -23,7 +24,7 @@ describe('test web server', () => {
}); });
afterEach(() => { afterEach(() => {
jest.clearAllMocks(); vi.clearAllMocks();
mockManifest.mockClear(); mockManifest.mockClear();
}); });

View file

@ -1,3 +1,5 @@
import { describe, expect, test } from 'vitest';
import { sortByName } from '../src/web-utils'; import { sortByName } from '../src/web-utils';
describe('Utilities', () => { describe('Utilities', () => {

View file

@ -582,9 +582,6 @@ importers:
'@verdaccio/loaders': '@verdaccio/loaders':
specifier: workspace:8.0.0-next-8.3 specifier: workspace:8.0.0-next-8.3
version: link:../loaders version: link:../loaders
'@verdaccio/logger':
specifier: workspace:8.0.0-next-8.3
version: link:../logger/logger
'@verdaccio/signature': '@verdaccio/signature':
specifier: workspace:8.0.0-next-8.1 specifier: workspace:8.0.0-next-8.1
version: link:../signature version: link:../signature
@ -601,6 +598,9 @@ importers:
specifier: workspace:13.0.0-next-8.3 specifier: workspace:13.0.0-next-8.3
version: link:../plugins/htpasswd version: link:../plugins/htpasswd
devDependencies: devDependencies:
'@verdaccio/logger':
specifier: workspace:8.0.0-next-8.3
version: link:../logger/logger
'@verdaccio/middleware': '@verdaccio/middleware':
specifier: workspace:8.0.0-next-8.3 specifier: workspace:8.0.0-next-8.3
version: link:../middleware version: link:../middleware
@ -1246,6 +1246,24 @@ importers:
in-publish: in-publish:
specifier: 2.0.1 specifier: 2.0.1
version: 2.0.1 version: 2.0.1
jest:
specifier: 29.7.0
version: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2)
jest-diff:
specifier: 29.7.0
version: 29.7.0
jest-environment-jsdom:
specifier: 29.7.0
version: 29.7.0
jest-environment-jsdom-global:
specifier: 4.0.0
version: 4.0.0(jest-environment-jsdom@29.7.0)
jest-environment-node:
specifier: 29.7.0
version: 29.7.0
jest-junit:
specifier: 16.0.0
version: 16.0.0
js-base64: js-base64:
specifier: 3.7.7 specifier: 3.7.7
version: 3.7.7 version: 3.7.7
@ -2026,6 +2044,24 @@ importers:
babel-loader: babel-loader:
specifier: 9.1.3 specifier: 9.1.3
version: 9.1.3(@babel/core@7.24.9)(webpack@5.93.0) version: 9.1.3(@babel/core@7.24.9)(webpack@5.93.0)
jest:
specifier: 29.7.0
version: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2)
jest-diff:
specifier: 29.7.0
version: 29.7.0
jest-environment-jsdom:
specifier: 29.7.0
version: 29.7.0
jest-environment-jsdom-global:
specifier: 4.0.0
version: 4.0.0(jest-environment-jsdom@29.7.0)
jest-environment-node:
specifier: 29.7.0
version: 29.7.0
jest-junit:
specifier: 16.0.0
version: 16.0.0
mockdate: mockdate:
specifier: 3.0.5 specifier: 3.0.5
version: 3.0.5 version: 3.0.5
@ -2117,6 +2153,9 @@ importers:
typedoc-plugin-missing-exports: typedoc-plugin-missing-exports:
specifier: 1.0.0 specifier: 1.0.0
version: 1.0.0(typedoc@0.23.25) version: 1.0.0(typedoc@0.23.25)
vite-tsconfig-paths:
specifier: 5.0.1
version: 5.0.1(typescript@4.9.5)
yaml: yaml:
specifier: 2.5.1 specifier: 2.5.1
version: 2.5.1 version: 2.5.1
@ -2223,9 +2262,6 @@ importers:
'@emotion/css': '@emotion/css':
specifier: 11.13.0 specifier: 11.13.0
version: 11.13.0 version: 11.13.0
'@emotion/jest':
specifier: 11.13.0
version: 11.13.0(@types/jest@29.5.12)
'@emotion/react': '@emotion/react':
specifier: 11.10.6 specifier: 11.10.6
version: 11.10.6(@types/react@18.3.3)(react@17.0.2) version: 11.10.6(@types/react@18.3.3)(react@17.0.2)
@ -2546,6 +2582,13 @@ packages:
'@babel/highlight': 7.24.7 '@babel/highlight': 7.24.7
picocolors: 1.0.0 picocolors: 1.0.0
/@babel/code-frame@7.25.7:
resolution: {integrity: sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/highlight': 7.25.7
picocolors: 1.0.1
/@babel/compat-data@7.23.5: /@babel/compat-data@7.23.5:
resolution: {integrity: sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw==} resolution: {integrity: sha512-uU27kfDRlhfKl+w1U6vp16IuvSLtjAxdArVXPa9BvLkrr7CYIsxH5adpHObeAGY/41+syctUWOZ140a2Rvkgjw==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@ -2662,6 +2705,15 @@ packages:
'@jridgewell/trace-mapping': 0.3.25 '@jridgewell/trace-mapping': 0.3.25
jsesc: 2.5.2 jsesc: 2.5.2
/@babel/generator@7.25.7:
resolution: {integrity: sha512-5Dqpl5fyV9pIAD62yK9P7fcA768uVPUyrQmqpqstHWgMma4feF1x/oFysBCVZLY5wJ2GkMUCdsNDnGZrPoR6rA==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/types': 7.25.8
'@jridgewell/gen-mapping': 0.3.5
'@jridgewell/trace-mapping': 0.3.25
jsesc: 3.0.2
/@babel/helper-annotate-as-pure@7.24.7: /@babel/helper-annotate-as-pure@7.24.7:
resolution: {integrity: sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==} resolution: {integrity: sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@ -3039,6 +3091,10 @@ packages:
resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==} resolution: {integrity: sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
/@babel/helper-string-parser@7.25.7:
resolution: {integrity: sha512-CbkjYdsJNHFk8uqpEkpCvRs3YRp9tY6FmFY7wLMSYuGYkrdUi7r2lc4/wqsvlHoMznX3WJ9IP8giGPq68T/Y6g==}
engines: {node: '>=6.9.0'}
/@babel/helper-validator-identifier@7.22.20: /@babel/helper-validator-identifier@7.22.20:
resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@ -3047,6 +3103,10 @@ packages:
resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==} resolution: {integrity: sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
/@babel/helper-validator-identifier@7.25.7:
resolution: {integrity: sha512-AM6TzwYqGChO45oiuPqwL2t20/HdMC1rTPAesnBCgPCSF1x3oN9MVUwQV2iyz4xqWrctwK5RNC8LV22kaQCNYg==}
engines: {node: '>=6.9.0'}
/@babel/helper-validator-option@7.23.5: /@babel/helper-validator-option@7.23.5:
resolution: {integrity: sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==} resolution: {integrity: sha512-85ttAOMLsr53VgXkTbkx8oA6YTfT4q7/HzXSLEYmjcSTJPMPQtvq1BD79Byep5xMUYbGRzEpDsjUf3dyp54IKw==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@ -3110,6 +3170,15 @@ packages:
js-tokens: 4.0.0 js-tokens: 4.0.0
picocolors: 1.0.0 picocolors: 1.0.0
/@babel/highlight@7.25.7:
resolution: {integrity: sha512-iYyACpW3iW8Fw+ZybQK+drQre+ns/tKpXbNESfrhNnPLIklLbXr7MYJ6gPEd0iETGLOK+SxMjVvKb/ffmk+FEw==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/helper-validator-identifier': 7.25.7
chalk: 2.4.2
js-tokens: 4.0.0
picocolors: 1.0.1
/@babel/node@7.25.0(@babel/core@7.24.9): /@babel/node@7.25.0(@babel/core@7.24.9):
resolution: {integrity: sha512-fgdlIcf1vLeZ6gUHcl799Wbk6no5tnkGi6t1gpAb1a97ZB+KCRp8Sgb7acGTjnFhOzqzcsbJ4+wzewqb6JM0tA==} resolution: {integrity: sha512-fgdlIcf1vLeZ6gUHcl799Wbk6no5tnkGi6t1gpAb1a97ZB+KCRp8Sgb7acGTjnFhOzqzcsbJ4+wzewqb6JM0tA==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@ -3163,6 +3232,13 @@ packages:
dependencies: dependencies:
'@babel/types': 7.25.0 '@babel/types': 7.25.0
/@babel/parser@7.25.8:
resolution: {integrity: sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ==}
engines: {node: '>=6.0.0'}
hasBin: true
dependencies:
'@babel/types': 7.25.8
/@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.0(@babel/core@7.24.9): /@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.0(@babel/core@7.24.9):
resolution: {integrity: sha512-dG0aApncVQwAUJa8tP1VHTnmU67BeIQvKafd3raEx315H54FfkZSz3B/TT+33ZQAjatGJA79gZqTtqL5QZUKXw==} resolution: {integrity: sha512-dG0aApncVQwAUJa8tP1VHTnmU67BeIQvKafd3raEx315H54FfkZSz3B/TT+33ZQAjatGJA79gZqTtqL5QZUKXw==}
engines: {node: '>=6.9.0'} engines: {node: '>=6.9.0'}
@ -3289,7 +3365,7 @@ packages:
'@babel/core': ^7.0.0-0 '@babel/core': ^7.0.0-0
dependencies: dependencies:
'@babel/core': 7.12.9 '@babel/core': 7.12.9
'@babel/helper-plugin-utils': 7.10.4 '@babel/helper-plugin-utils': 7.24.8
'@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.12.9) '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.12.9)
'@babel/plugin-transform-parameters': 7.24.7(@babel/core@7.12.9) '@babel/plugin-transform-parameters': 7.24.7(@babel/core@7.12.9)
@ -4934,6 +5010,14 @@ packages:
'@babel/helper-validator-identifier': 7.24.7 '@babel/helper-validator-identifier': 7.24.7
to-fast-properties: 2.0.0 to-fast-properties: 2.0.0
/@babel/types@7.25.8:
resolution: {integrity: sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/helper-string-parser': 7.25.7
'@babel/helper-validator-identifier': 7.25.7
to-fast-properties: 2.0.0
/@base2/pretty-print-object@1.0.1: /@base2/pretty-print-object@1.0.1:
resolution: {integrity: sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA==} resolution: {integrity: sha512-4iri8i1AqYHJE2DstZYkyEprg6Pq6sKx3xn5FpySk9sNhH7qN2LLlHJCfDTZRILNwQNPD7mATWM0TBui7uC1pA==}
dev: true dev: true
@ -6515,6 +6599,7 @@ packages:
dependencies: dependencies:
'@emotion/memoize': 0.9.0 '@emotion/memoize': 0.9.0
stylis: 4.2.0 stylis: 4.2.0
dev: true
/@emotion/css@11.10.6: /@emotion/css@11.10.6:
resolution: {integrity: sha512-88Sr+3heKAKpj9PCqq5A1hAmAkoSIvwEq1O2TwDij7fUtsJpdkV4jMTISSTouFeRvsGvXIpuSuDQ4C1YdfNGXw==} resolution: {integrity: sha512-88Sr+3heKAKpj9PCqq5A1hAmAkoSIvwEq1O2TwDij7fUtsJpdkV4jMTISSTouFeRvsGvXIpuSuDQ4C1YdfNGXw==}
@ -6584,6 +6669,7 @@ packages:
chalk: 4.1.2 chalk: 4.1.2
specificity: 0.4.1 specificity: 0.4.1
stylis: 4.2.0 stylis: 4.2.0
dev: true
/@emotion/memoize@0.8.0: /@emotion/memoize@0.8.0:
resolution: {integrity: sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==} resolution: {integrity: sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==}
@ -7157,7 +7243,7 @@ packages:
jest-util: 29.7.0 jest-util: 29.7.0
jest-validate: 29.7.0 jest-validate: 29.7.0
jest-watcher: 29.7.0 jest-watcher: 29.7.0
micromatch: 4.0.5 micromatch: 4.0.7
pretty-format: 29.7.0 pretty-format: 29.7.0
slash: 3.0.0 slash: 3.0.0
strip-ansi: 6.0.1 strip-ansi: 6.0.1
@ -7226,18 +7312,18 @@ packages:
'@jest/test-result': 29.7.0 '@jest/test-result': 29.7.0
'@jest/transform': 29.7.0 '@jest/transform': 29.7.0
'@jest/types': 29.6.3 '@jest/types': 29.6.3
'@jridgewell/trace-mapping': 0.3.20 '@jridgewell/trace-mapping': 0.3.25
'@types/node': 20.14.12 '@types/node': 20.14.12
chalk: 4.1.2 chalk: 4.1.2
collect-v8-coverage: 1.0.2 collect-v8-coverage: 1.0.2
exit: 0.1.2 exit: 0.1.2
glob: 7.2.3 glob: 7.2.3
graceful-fs: 4.2.11 graceful-fs: 4.2.11
istanbul-lib-coverage: 3.2.0 istanbul-lib-coverage: 3.2.2
istanbul-lib-instrument: 6.0.1 istanbul-lib-instrument: 6.0.1
istanbul-lib-report: 3.0.1 istanbul-lib-report: 3.0.1
istanbul-lib-source-maps: 4.0.1 istanbul-lib-source-maps: 4.0.1
istanbul-reports: 3.1.6 istanbul-reports: 3.1.7
jest-message-util: 29.7.0 jest-message-util: 29.7.0
jest-util: 29.7.0 jest-util: 29.7.0
jest-worker: 29.7.0 jest-worker: 29.7.0
@ -10932,6 +11018,7 @@ packages:
dependencies: dependencies:
expect: 29.7.0 expect: 29.7.0
pretty-format: 29.7.0 pretty-format: 29.7.0
dev: true
/@types/js-levenshtein@1.1.1: /@types/js-levenshtein@1.1.1:
resolution: {integrity: sha512-qC4bCqYGy1y/NP7dDVr7KJarn+PbX1nSpwA7JXdu0HxT3QYjO8MJ+cntENtHFVy2dRAyBV23OZ6MxsW1AM1L8g==} resolution: {integrity: sha512-qC4bCqYGy1y/NP7dDVr7KJarn+PbX1nSpwA7JXdu0HxT3QYjO8MJ+cntENtHFVy2dRAyBV23OZ6MxsW1AM1L8g==}
@ -10941,7 +11028,7 @@ packages:
resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==} resolution: {integrity: sha512-d0r18sZPmMQr1eG35u12FZfhIXNrnsPU/g5wvRKCUf/tOGilKKwYMYGqh33BNR6ba+2gkHw1EUiHoN3mn7E5IQ==}
dependencies: dependencies:
'@types/node': 20.14.12 '@types/node': 20.14.12
'@types/tough-cookie': 4.0.3 '@types/tough-cookie': 4.0.5
parse5: 7.1.2 parse5: 7.1.2
dev: true dev: true
@ -11272,8 +11359,8 @@ packages:
'@types/node': 20.14.12 '@types/node': 20.14.12
dev: true dev: true
/@types/tough-cookie@4.0.3: /@types/tough-cookie@4.0.5:
resolution: {integrity: sha512-THo502dA5PzG/sfQH+42Lw3fvmYkceefOspdCwpHRul8ik2Jv1K8I5OZz1AT3/rs46kwgMCe9bSBmDLYkkOMGg==} resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}
dev: true dev: true
/@types/uglify-js@3.17.1: /@types/uglify-js@3.17.1:
@ -18821,6 +18908,10 @@ packages:
resolution: {integrity: sha512-xYfnw62CKG8nLkZBfWbhWwDw02CHty86jfPcc2cr3ZfeuK9ysoVPPEUxf21bAD/rWAgk52SuBrLJlefNy8mvFg==} resolution: {integrity: sha512-xYfnw62CKG8nLkZBfWbhWwDw02CHty86jfPcc2cr3ZfeuK9ysoVPPEUxf21bAD/rWAgk52SuBrLJlefNy8mvFg==}
dev: true dev: true
/globrex@0.1.2:
resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==}
dev: true
/gopd@1.0.1: /gopd@1.0.1:
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
dependencies: dependencies:
@ -20406,9 +20497,9 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dependencies: dependencies:
'@babel/core': 7.24.9 '@babel/core': 7.24.9
'@babel/parser': 7.23.9 '@babel/parser': 7.25.8
'@istanbuljs/schema': 0.1.3 '@istanbuljs/schema': 0.1.3
istanbul-lib-coverage: 3.2.0 istanbul-lib-coverage: 3.2.2
semver: 7.6.3 semver: 7.6.3
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -20426,7 +20517,7 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dependencies: dependencies:
debug: 4.3.7(supports-color@5.5.0) debug: 4.3.7(supports-color@5.5.0)
istanbul-lib-coverage: 3.2.0 istanbul-lib-coverage: 3.2.2
source-map: 0.6.1 source-map: 0.6.1
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
@ -20448,6 +20539,7 @@ packages:
dependencies: dependencies:
html-escaper: 2.0.2 html-escaper: 2.0.2
istanbul-lib-report: 3.0.1 istanbul-lib-report: 3.0.1
dev: true
/istanbul-reports@3.1.7: /istanbul-reports@3.1.7:
resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==}
@ -20455,7 +20547,6 @@ packages:
dependencies: dependencies:
html-escaper: 2.0.2 html-escaper: 2.0.2
istanbul-lib-report: 3.0.1 istanbul-lib-report: 3.0.1
dev: true
/iterate-iterator@1.0.2: /iterate-iterator@1.0.2:
resolution: {integrity: sha512-t91HubM4ZDQ70M9wqp+pcNpu8OyJ9UAtXntT/Bcsvp5tZMnz9vRa+IunKXeI8AnfZMTv0jNuVEmGeLSMjVvfPw==} resolution: {integrity: sha512-t91HubM4ZDQ70M9wqp+pcNpu8OyJ9UAtXntT/Bcsvp5tZMnz9vRa+IunKXeI8AnfZMTv0jNuVEmGeLSMjVvfPw==}
@ -20592,7 +20683,7 @@ packages:
jest-runner: 29.7.0 jest-runner: 29.7.0
jest-util: 29.7.0 jest-util: 29.7.0
jest-validate: 29.7.0 jest-validate: 29.7.0
micromatch: 4.0.5 micromatch: 4.0.7
parse-json: 5.2.0 parse-json: 5.2.0
pretty-format: 29.7.0 pretty-format: 29.7.0
slash: 3.0.0 slash: 3.0.0
@ -20710,7 +20801,7 @@ packages:
jest-regex-util: 29.6.3 jest-regex-util: 29.6.3
jest-util: 29.7.0 jest-util: 29.7.0
jest-worker: 29.7.0 jest-worker: 29.7.0
micromatch: 4.0.5 micromatch: 4.0.7
walker: 1.0.8 walker: 1.0.8
optionalDependencies: optionalDependencies:
fsevents: 2.3.3 fsevents: 2.3.3
@ -20745,12 +20836,12 @@ packages:
resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==} resolution: {integrity: sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies: dependencies:
'@babel/code-frame': 7.23.5 '@babel/code-frame': 7.25.7
'@jest/types': 29.6.3 '@jest/types': 29.6.3
'@types/stack-utils': 2.0.1 '@types/stack-utils': 2.0.1
chalk: 4.1.2 chalk: 4.1.2
graceful-fs: 4.2.11 graceful-fs: 4.2.11
micromatch: 4.0.5 micromatch: 4.0.7
pretty-format: 29.7.0 pretty-format: 29.7.0
slash: 3.0.0 slash: 3.0.0
stack-utils: 2.0.6 stack-utils: 2.0.6
@ -20884,10 +20975,10 @@ packages:
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
dependencies: dependencies:
'@babel/core': 7.24.9 '@babel/core': 7.24.9
'@babel/generator': 7.23.6 '@babel/generator': 7.25.7
'@babel/plugin-syntax-jsx': 7.23.3(@babel/core@7.24.9) '@babel/plugin-syntax-jsx': 7.24.7(@babel/core@7.24.9)
'@babel/plugin-syntax-typescript': 7.23.3(@babel/core@7.24.9) '@babel/plugin-syntax-typescript': 7.24.7(@babel/core@7.24.9)
'@babel/types': 7.23.9 '@babel/types': 7.25.8
'@jest/expect-utils': 29.7.0 '@jest/expect-utils': 29.7.0
'@jest/transform': 29.7.0 '@jest/transform': 29.7.0
'@jest/types': 29.6.3 '@jest/types': 29.6.3
@ -21157,6 +21248,11 @@ packages:
engines: {node: '>=4'} engines: {node: '>=4'}
hasBin: true hasBin: true
/jsesc@3.0.2:
resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
engines: {node: '>=6'}
hasBin: true
/json-buffer@3.0.0: /json-buffer@3.0.0:
resolution: {integrity: sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ==} resolution: {integrity: sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ==}
@ -25611,7 +25707,7 @@ packages:
dependencies: dependencies:
'@jest/schemas': 29.6.3 '@jest/schemas': 29.6.3
ansi-styles: 5.2.0 ansi-styles: 5.2.0
react-is: 18.2.0 react-is: 18.3.1
/pretty-hrtime@1.0.3: /pretty-hrtime@1.0.3:
resolution: {integrity: sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==} resolution: {integrity: sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A==}
@ -26456,7 +26552,7 @@ packages:
peerDependencies: peerDependencies:
react: '>=15' react: '>=15'
dependencies: dependencies:
'@babel/runtime': 7.21.0 '@babel/runtime': 7.25.0
history: 4.10.1 history: 4.10.1
hoist-non-react-statics: 3.3.2 hoist-non-react-statics: 3.3.2
loose-envify: 1.4.0 loose-envify: 1.4.0
@ -28097,6 +28193,7 @@ packages:
/specificity@0.4.1: /specificity@0.4.1:
resolution: {integrity: sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==} resolution: {integrity: sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==}
hasBin: true hasBin: true
dev: true
/split-string@3.1.0: /split-string@3.1.0:
resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==} resolution: {integrity: sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==}
@ -29470,6 +29567,19 @@ packages:
typescript: 4.9.5 typescript: 4.9.5
dev: true dev: true
/tsconfck@3.1.4(typescript@4.9.5):
resolution: {integrity: sha512-kdqWFGVJqe+KGYvlSO9NIaWn9jT1Ny4oKVzAJsKii5eoE9snzTJzL4+MMVOMn+fikWGFmKEylcXL710V/kIPJQ==}
engines: {node: ^18 || >=20}
hasBin: true
peerDependencies:
typescript: ^5.0.0
peerDependenciesMeta:
typescript:
optional: true
dependencies:
typescript: 4.9.5
dev: true
/tsconfig-paths@3.15.0: /tsconfig-paths@3.15.0:
resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==}
dependencies: dependencies:
@ -30404,6 +30514,22 @@ packages:
- terser - terser
dev: true dev: true
/vite-tsconfig-paths@5.0.1(typescript@4.9.5):
resolution: {integrity: sha512-yqwv+LstU7NwPeNqajZzLEBVpUFU6Dugtb2P84FXuvaoYA+/70l9MHE+GYfYAycVyPSDYZ7mjOFuYBRqlEpTig==}
peerDependencies:
vite: '*'
peerDependenciesMeta:
vite:
optional: true
dependencies:
debug: 4.3.7(supports-color@5.5.0)
globrex: 0.1.2
tsconfck: 3.1.4(typescript@4.9.5)
transitivePeerDependencies:
- supports-color
- typescript
dev: true
/vite@5.3.1(@types/node@20.14.12): /vite@5.3.1(@types/node@20.14.12):
resolution: {integrity: sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==} resolution: {integrity: sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==}
engines: {node: ^18.0.0 || >=20.0.0} engines: {node: ^18.0.0 || >=20.0.0}
@ -31681,7 +31807,7 @@ packages:
engines: {node: '>=10'} engines: {node: '>=10'}
dependencies: dependencies:
cliui: 7.0.4 cliui: 7.0.4
escalade: 3.1.1 escalade: 3.1.2
get-caller-file: 2.0.5 get-caller-file: 2.0.5
require-directory: 2.1.1 require-directory: 2.1.1
string-width: 4.2.3 string-width: 4.2.3

View file

@ -152,7 +152,7 @@
"baseBranchList": ["master"] "baseBranchList": ["master"]
}, },
{ {
"matchPackagePatterns": ["@testing-library/*", "jest", "jest-*", "supertest", "nock"], "matchPackagePatterns": ["@testing-library/*", "vitest", "supertest", "nock"],
"matchUpdateTypes": ["minor", "patch", "major"], "matchUpdateTypes": ["minor", "patch", "major"],
"groupName": "all test dependencies", "groupName": "all test dependencies",
"groupSlug": "all-test", "groupSlug": "all-test",

View file

@ -8,7 +8,7 @@
"declaration": true, "declaration": true,
"jsx": "react", "jsx": "react",
"strictNullChecks": true, "strictNullChecks": true,
"types": ["node", "jest", "express", "@testing-library/jest-dom"], "types": ["node", "express", "@testing-library/jest-dom"],
"resolveJsonModule": true, "resolveJsonModule": true,
// "preserveSymlinks": true, // "preserveSymlinks": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,

View file

@ -115,7 +115,7 @@ FROM node:lts-alpine as builder
RUN mkdir -p /verdaccio/plugins \ RUN mkdir -p /verdaccio/plugins \
&& cd /verdaccio/plugins \ && cd /verdaccio/plugins \
&& npm install --global-style --no-bin-links --omit=optional verdaccio-auth-memory@latest && npm install --global-style --no-bin-links --omit=optional verdaccio-auth-memory@latest
FROM verdaccio/verdaccio:5 FROM verdaccio/verdaccio:6
ADD docker.yaml /verdaccio/conf/config.yaml ADD docker.yaml /verdaccio/conf/config.yaml
COPY --chown=$VERDACCIO_USER_UID:root --from=builder \ COPY --chown=$VERDACCIO_USER_UID:root --from=builder \
/verdaccio/plugins/node_modules/verdaccio-auth-memory \ /verdaccio/plugins/node_modules/verdaccio-auth-memory \

View file

@ -32,7 +32,6 @@
"@docusaurus/theme-search-algolia": "2.4.3", "@docusaurus/theme-search-algolia": "2.4.3",
"@emotion/cache": "11.10.7", "@emotion/cache": "11.10.7",
"@emotion/css": "11.13.0", "@emotion/css": "11.13.0",
"@emotion/jest": "11.13.0",
"@emotion/react": "11.10.6", "@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6", "@emotion/styled": "11.10.6",
"@mdx-js/react": "^1.6.22", "@mdx-js/react": "^1.6.22",

View file

@ -113,7 +113,7 @@ Plugins can be installed in a separate directory and mounted using Docker or Kub
If the plugin already exist in some registry, it could be installed globally with `npm` command. If the plugin already exist in some registry, it could be installed globally with `npm` command.
```docker ```docker
FROM verdaccio/verdaccio:5 FROM verdaccio/verdaccio:6
ADD docker.yaml /verdaccio/conf/config.yaml ADD docker.yaml /verdaccio/conf/config.yaml
USER root USER root
RUN npm install --global verdaccio-static-token \ RUN npm install --global verdaccio-static-token \
@ -138,7 +138,7 @@ RUN mkdir -p /verdaccio/plugins
ADD plugins/verdaccio-docker-memory /verdaccio/plugins/verdaccio-docker-memory ADD plugins/verdaccio-docker-memory /verdaccio/plugins/verdaccio-docker-memory
RUN cd /verdaccio/plugins/verdaccio-docker-memory \ RUN cd /verdaccio/plugins/verdaccio-docker-memory \
&& npm install --production && npm install --production
FROM verdaccio/verdaccio:5 FROM verdaccio/verdaccio:6
ADD docker.yaml /verdaccio/conf/config.yaml ADD docker.yaml /verdaccio/conf/config.yaml
COPY --chown=$VERDACCIO_USER_UID:root --from=builder \ COPY --chown=$VERDACCIO_USER_UID:root --from=builder \
/verdaccio/plugins/verdaccio-docker-memory \ /verdaccio/plugins/verdaccio-docker-memory \