From 7aa829cfa5b49119edb16c84255ea161f0017ac2 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Tue, 4 Feb 2025 20:22:10 +0800 Subject: [PATCH] refactor: use egg v4 BREAKING CHANGE: only support egg >= 4.0.0 the first app on egg v4 https://github.com/eggjs/egg/issues/3644 --- .eslintrc | 8 ++++---- INTEGRATE.md | 4 ++-- app.ts | 4 ++-- app/common/CryptoUtil.ts | 2 +- app/common/UserUtil.ts | 2 +- app/common/adapter/CacheAdapter.ts | 4 ++-- app/common/adapter/NFSAdapter.ts | 4 ++-- app/common/adapter/NPMRegistry.ts | 2 +- app/common/adapter/binary/BucketBinary.ts | 2 +- .../adapter/binary/ChromeForTestingBinary.ts | 2 +- app/common/adapter/binary/NodePreGypBinary.ts | 2 +- app/common/adapter/binary/PlaywrightBinary.ts | 4 ++-- app/common/aop/AsyncTimer.ts | 2 +- app/common/typing.ts | 6 +++--- app/core/entity/Hook.ts | 2 +- app/core/entity/Task.ts | 4 ++-- app/core/service/BinarySyncerService.ts | 5 ++--- app/core/service/ChangesStreamService.ts | 4 ++-- app/core/service/ProxyCacheService.ts | 8 ++++---- app/core/service/UserService.ts | 2 +- app/infra/AuthAdapter.ts | 2 +- app/infra/NFSClientAdapter.ts | 2 +- app/port/UserRoleManager.ts | 8 +++++++- app/port/controller/BinarySyncController.ts | 2 +- app/port/controller/HomeController.ts | 2 +- .../package/DownloadPackageVersionTar.ts | 2 +- .../package/SavePackageVersionController.ts | 4 ++-- .../controller/package/ShowPackageController.ts | 2 +- .../package/UpdatePackageController.ts | 4 ++-- app/port/middleware/ErrorHandler.ts | 8 ++++---- app/port/schedule/CleanTempDir.ts | 4 ++-- app/port/webauth/WebauthController.ts | 2 +- config/config.unittest.ts | 2 +- config/plugin.ts | 4 ++-- module.d.ts | 2 +- package.json | 17 +++++++++-------- test/.setup.ts | 2 +- test/TestUtil.ts | 14 +++++++------- test/cli/npm/access.test.ts | 2 +- test/cli/npm/install.test.ts | 2 +- test/common/adapter/BugVersionStore.test.ts | 2 +- test/common/adapter/CacheAdapter.test.ts | 2 +- test/common/adapter/NpmRegistry.test.ts | 2 +- test/common/adapter/binary/ApiBinary.test.ts | 2 +- test/common/adapter/binary/BucketBinary.test.ts | 2 +- .../binary/ChromeForTestingBinary.test.ts | 2 +- .../common/adapter/binary/CypressBinary.test.ts | 2 +- .../adapter/binary/EdgedriverBinary.test.ts | 2 +- .../adapter/binary/ElectronBinary.test.ts | 2 +- test/common/adapter/binary/GithubBinary.test.ts | 2 +- .../adapter/binary/ImageminBinary.test.ts | 2 +- test/common/adapter/binary/NodeBinary.test.ts | 2 +- .../adapter/binary/NodePreGypBinary.test.ts | 2 +- test/common/adapter/binary/NwjsBinary.test.ts | 2 +- .../adapter/binary/PlaywrightBinary.test.ts | 2 +- test/common/adapter/binary/PrismaBinary.test.ts | 2 +- .../adapter/binary/PuppeteerBinary.test.ts | 2 +- .../adapter/binary/SqlcipherBinary.test.ts | 2 +- .../changesStream/CnpmcoreChangesStream.test.ts | 2 +- .../CnpmjsorgChangesStream.test.ts | 2 +- .../changesStream/NpmChangesStream.test.ts | 2 +- test/core/event/BugVersionFixHandler.test.ts | 2 +- test/core/event/ChangesStream.test.ts | 2 +- test/core/event/StoreManifest.test.ts | 2 +- .../BinarySyncerService/createTask.test.ts | 2 +- .../BinarySyncerService/executeTask.test.ts | 2 +- .../cleanBugVersionPackageCache.test.ts | 2 +- .../fixPackageBugVersion.test.ts | 2 +- .../fixPackageBugVersions.test.ts | 2 +- test/core/service/ChangesStreamService.test.ts | 2 +- .../service/CreateHookTriggerService.test.ts | 2 +- .../HookManageService/createHook.test.ts | 2 +- .../HookManageService/deleteHook.test.ts | 2 +- .../HookManageService/getHookByOwnerId.test.ts | 2 +- .../HookManageService/updateHook.test.ts | 2 +- test/core/service/HookTriggerService.test.ts | 2 +- .../service/PackageManagerService/block.test.ts | 2 +- .../PackageManagerService/publish.test.ts | 2 +- .../PackageSyncerService/createTask.test.ts | 4 ++-- .../PackageSyncerService/executeTask.test.ts | 4 +++- .../findExecuteTask.test.ts | 2 +- .../getTaskRegistry.test.ts | 2 +- test/core/service/PackageVersionService.test.ts | 2 +- test/core/service/ProxyCacheService.test.ts | 7 ++++--- .../RegistryManagerService/index.test.ts | 2 +- .../service/ScopeManagerService/index.test.ts | 2 +- .../service/TaskService/findExecuteTask.test.ts | 2 +- test/infra/QueueAdapter.test.ts | 2 +- .../AccessController/listCollaborators.test.ts | 2 +- .../AccessController/listPackagesByUser.test.ts | 2 +- .../BinarySyncController/showBinary.test.ts | 2 +- .../ChangesStreamController/listChanges.test.ts | 2 +- .../showPackageDownloads.test.ts | 2 +- .../port/controller/HomeController/cors.test.ts | 2 +- .../port/controller/HomeController/misc.test.ts | 2 +- .../port/controller/HomeController/ping.test.ts | 2 +- .../controller/HomeController/showTotal.test.ts | 2 +- .../PackageBlockController/blockPackage.test.ts | 2 +- .../unblockPackage.test.ts | 2 +- .../createSyncTask.test.ts | 4 ++-- .../PackageSyncController/showSyncTask.test.ts | 2 +- .../showSyncTaskLog.test.ts | 2 +- .../PackageTagController/removeTag.test.ts | 2 +- .../PackageTagController/saveTag.test.ts | 2 +- .../PackageTagController/showTags.test.ts | 2 +- .../listFiles.test.ts | 2 +- .../PackageVersionFileController/raw.test.ts | 2 +- .../PackageVersionFileController/sync.test.ts | 2 +- .../ProxyCacheController/index.test.ts | 2 +- .../controller/RegistryController/index.test.ts | 2 +- .../controller/ScopeController/index.test.ts | 2 +- .../TokenController/createToken.test.ts | 2 +- .../TokenController/listTokens.test.ts | 2 +- .../TokenController/removeToken.test.ts | 2 +- .../UserController/loginOrCreateUser.test.ts | 2 +- .../controller/UserController/logout.test.ts | 2 +- .../UserController/saveProfile.test.ts | 2 +- .../UserController/showProfile.test.ts | 2 +- .../controller/UserController/showUser.test.ts | 2 +- .../UserController/starredByUser.test.ts | 2 +- .../controller/UserController/whoami.test.ts | 2 +- .../port/controller/hook/HookController.test.ts | 2 +- .../DownloadPackageVersionTarController.test.ts | 4 ++-- .../RemovePackageVersionController.test.ts | 2 +- .../SavePackageVersionController.test.ts | 2 +- .../package/SearchPackageController.test.ts | 2 +- .../package/ShowPackageController.test.ts | 2 +- .../ShowPackageVersionController.test.ts | 2 +- .../package/UpdatePackageController.test.ts | 2 +- test/port/middleware/AlwaysAuth.test.ts | 2 +- test/port/middleware/Tracing.test.ts | 2 +- test/port/webauth/webauthController.test.ts | 2 +- test/repository/ChangeRepository.test.ts | 2 +- test/repository/PackageRepository.test.ts | 2 +- test/repository/ProxyCachePepository.test.ts | 4 ++-- test/repository/RegistryRepository.test.ts | 2 +- test/repository/ScopeRepository.test.ts | 2 +- test/repository/SearchRepository.test.ts | 2 +- test/repository/TaskRepository.test.ts | 2 +- test/schedule/ChangesStreamWorker.test.ts | 2 +- .../CheckProxyCacheUpdateWorker.test.ts | 4 ++-- .../CheckRecentlyUpdatedPackages.test.ts | 2 +- test/schedule/CleanTempDir.test.ts | 6 +++--- test/schedule/SyncBinaryWorker.test.ts | 2 +- test/schedule/SyncPackageWorker.test.ts | 2 +- test/schedule/SyncProxyCacheWorker.test.ts | 2 +- test/schedule/TaskTimeoutHandler.test.ts | 2 +- tsconfig.json | 5 +---- tsconfig.prod.json | 1 - 149 files changed, 203 insertions(+), 198 deletions(-) diff --git a/.eslintrc b/.eslintrc index 34ecb4a8..9bcdb468 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,6 @@ { - "extends": "eslint-config-egg/typescript", - "rules": { - - } + "extends": [ + "eslint-config-egg/typescript", + "eslint-config-egg/lib/rules/enforce-node-prefix" + ] } diff --git a/INTEGRATE.md b/INTEGRATE.md index c0c4e426..b9f241a4 100644 --- a/INTEGRATE.md +++ b/INTEGRATE.md @@ -59,7 +59,7 @@ { redis: { enable: true, - package: 'egg-redis', + package: '@eggjs/redis', }, teggOrm: { enable: true, @@ -71,7 +71,7 @@ }, tracer: { enable: true, - package: 'egg-tracer', + package: '@eggjs/tracer', }, typeboxValidate: { enable: true, diff --git a/app.ts b/app.ts index 75014045..fbd3d65c 100644 --- a/app.ts +++ b/app.ts @@ -1,5 +1,5 @@ -import path from 'path'; -import { readFile } from 'fs/promises'; +import path from 'node:path'; +import { readFile } from 'node:fs/promises'; import { Application } from 'egg'; import { ChangesStreamService } from './app/core/service/ChangesStreamService'; diff --git a/app/common/CryptoUtil.ts b/app/common/CryptoUtil.ts index 4e9e7ceb..52942138 100644 --- a/app/common/CryptoUtil.ts +++ b/app/common/CryptoUtil.ts @@ -1,4 +1,4 @@ -import { generateKeyPairSync } from 'crypto'; +import { generateKeyPairSync } from 'node:crypto'; import NodeRSA from 'node-rsa'; // generate rsa key pair diff --git a/app/common/UserUtil.ts b/app/common/UserUtil.ts index 7d94f36b..c77f25a5 100644 --- a/app/common/UserUtil.ts +++ b/app/common/UserUtil.ts @@ -1,4 +1,4 @@ -import crypto from 'crypto'; +import crypto from 'node:crypto'; import base from 'base-x'; import { crc32 } from '@node-rs/crc32'; import * as ssri from 'ssri'; diff --git a/app/common/adapter/CacheAdapter.ts b/app/common/adapter/CacheAdapter.ts index b70fecaa..7f63b3e7 100644 --- a/app/common/adapter/CacheAdapter.ts +++ b/app/common/adapter/CacheAdapter.ts @@ -3,8 +3,8 @@ import { AccessLevel, Inject, } from '@eggjs/tegg'; -// FIXME: egg-redis should use ioredis v5 -// https://github.com/eggjs/egg-redis/issues/35 +// FIXME: @eggjs/redis should use ioredis v5 +// https://github.com/eggjs/redis/issues/35 import type { Redis } from 'ioredis'; const ONE_DAY = 3600 * 24; diff --git a/app/common/adapter/NFSAdapter.ts b/app/common/adapter/NFSAdapter.ts index 37759f37..804f74d0 100644 --- a/app/common/adapter/NFSAdapter.ts +++ b/app/common/adapter/NFSAdapter.ts @@ -1,4 +1,5 @@ -import { Readable } from 'stream'; +import { Readable } from 'node:stream'; +import { IncomingHttpHeaders } from 'node:http'; import { SingletonProto, AccessLevel, @@ -8,7 +9,6 @@ import { Pointcut } from '@eggjs/tegg/aop'; import { EggLogger } from 'egg'; import { AsyncTimer } from '../aop/AsyncTimer'; import { NFSClient } from '../typing'; -import { IncomingHttpHeaders } from 'http'; const INSTANCE_NAME = 'nfsAdapter'; diff --git a/app/common/adapter/NPMRegistry.ts b/app/common/adapter/NPMRegistry.ts index 9c49bb57..a61ad2c7 100644 --- a/app/common/adapter/NPMRegistry.ts +++ b/app/common/adapter/NPMRegistry.ts @@ -1,4 +1,4 @@ -import { setTimeout } from 'timers/promises'; +import { setTimeout } from 'node:timers/promises'; import { ContextProto, AccessLevel, diff --git a/app/common/adapter/binary/BucketBinary.ts b/app/common/adapter/binary/BucketBinary.ts index 3fc13ff4..a6566b1f 100644 --- a/app/common/adapter/binary/BucketBinary.ts +++ b/app/common/adapter/binary/BucketBinary.ts @@ -1,7 +1,7 @@ import { SingletonProto } from '@eggjs/tegg'; import { BinaryType } from '../../enum/Binary'; import binaries, { BinaryName, BinaryTaskConfig } from '../../../../config/binaries'; -import path from 'path'; +import path from 'node:path'; import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary'; @SingletonProto() diff --git a/app/common/adapter/binary/ChromeForTestingBinary.ts b/app/common/adapter/binary/ChromeForTestingBinary.ts index 5d446cf5..d4076b2b 100644 --- a/app/common/adapter/binary/ChromeForTestingBinary.ts +++ b/app/common/adapter/binary/ChromeForTestingBinary.ts @@ -1,4 +1,4 @@ -import { basename } from 'path'; +import { basename } from 'node:path'; import { SingletonProto } from '@eggjs/tegg'; import { BinaryType } from '../../enum/Binary'; import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary'; diff --git a/app/common/adapter/binary/NodePreGypBinary.ts b/app/common/adapter/binary/NodePreGypBinary.ts index ab055b4f..b568bdc7 100644 --- a/app/common/adapter/binary/NodePreGypBinary.ts +++ b/app/common/adapter/binary/NodePreGypBinary.ts @@ -1,7 +1,7 @@ import { SingletonProto } from '@eggjs/tegg'; import { BinaryType } from '../../enum/Binary'; import binaries, { BinaryName } from '../../../../config/binaries'; -import { join } from 'path'; +import { join } from 'node:path'; import { AbstractBinary, FetchResult, BinaryItem, BinaryAdapter } from './AbstractBinary'; @SingletonProto() diff --git a/app/common/adapter/binary/PlaywrightBinary.ts b/app/common/adapter/binary/PlaywrightBinary.ts index bc6fbea2..7df3a534 100644 --- a/app/common/adapter/binary/PlaywrightBinary.ts +++ b/app/common/adapter/binary/PlaywrightBinary.ts @@ -1,7 +1,7 @@ import { AbstractBinary, BinaryAdapter, BinaryItem, FetchResult } from './AbstractBinary'; -import util from 'util'; -import path from 'path'; +import util from 'node:util'; +import path from 'node:path'; import { SingletonProto } from '@eggjs/tegg'; import { BinaryType } from '../../enum/Binary'; diff --git a/app/common/aop/AsyncTimer.ts b/app/common/aop/AsyncTimer.ts index 54325b41..4c779828 100644 --- a/app/common/aop/AsyncTimer.ts +++ b/app/common/aop/AsyncTimer.ts @@ -1,4 +1,4 @@ -import { performance } from 'perf_hooks'; +import { performance } from 'node:perf_hooks'; import { Advice, AdviceContext, IAdvice } from '@eggjs/tegg/aop'; import { Inject } from '@eggjs/tegg'; import { EggLogger } from 'egg'; diff --git a/app/common/typing.ts b/app/common/typing.ts index f257e09a..9d99c6c4 100644 --- a/app/common/typing.ts +++ b/app/common/typing.ts @@ -1,8 +1,8 @@ -import { CnpmcoreConfig } from '../port/config'; -import { Readable } from 'stream'; -import { IncomingHttpHeaders } from 'http'; +import { Readable } from 'node:stream'; +import { IncomingHttpHeaders } from 'node:http'; import { EggContext } from '@eggjs/tegg'; import { estypes } from '@elastic/elasticsearch'; +import { CnpmcoreConfig } from '../port/config'; export interface UploadResult { key: string; diff --git a/app/core/entity/Hook.ts b/app/core/entity/Hook.ts index 443c2650..4624aa4e 100644 --- a/app/core/entity/Hook.ts +++ b/app/core/entity/Hook.ts @@ -1,7 +1,7 @@ import { Entity, EntityData } from './Entity'; import { EasyData, EntityUtil } from '../util/EntityUtil'; import { HookType } from '../../common/enum/Hook'; -import crypto from 'crypto'; +import crypto from 'node:crypto'; export type CreateHookData = Omit, 'enable' | 'latestTaskId'>; diff --git a/app/core/entity/Task.ts b/app/core/entity/Task.ts index d012ddae..d0eee118 100644 --- a/app/core/entity/Task.ts +++ b/app/core/entity/Task.ts @@ -1,5 +1,5 @@ -import os from 'os'; -import path from 'path'; +import os from 'node:os'; +import path from 'node:path'; import { Entity, EntityData } from './Entity'; import { EasyData, EntityUtil } from '../util/EntityUtil'; import { TaskType, TaskState } from '../../common/enum/Task'; diff --git a/app/core/service/BinarySyncerService.ts b/app/core/service/BinarySyncerService.ts index d0c80716..0dd3e0f0 100644 --- a/app/core/service/BinarySyncerService.ts +++ b/app/core/service/BinarySyncerService.ts @@ -1,4 +1,3 @@ -import { rm } from 'fs/promises'; import { AccessLevel, SingletonProto, @@ -8,7 +7,7 @@ import { import { EggHttpClient, } from 'egg'; -import fs from 'fs/promises'; +import fs from 'node:fs/promises'; import { sortBy } from 'lodash'; import binaries, { BinaryName, CategoryName } from '../../../config/binaries'; import { BinaryRepository } from '../../repository/BinaryRepository'; @@ -223,7 +222,7 @@ export class BinarySyncerService extends AbstractService { logs = []; } finally { if (localFile) { - await rm(localFile, { force: true }); + await fs.rm(localFile, { force: true }); } } } diff --git a/app/core/service/ChangesStreamService.ts b/app/core/service/ChangesStreamService.ts index 83508e93..f8f821df 100644 --- a/app/core/service/ChangesStreamService.ts +++ b/app/core/service/ChangesStreamService.ts @@ -1,5 +1,5 @@ -import os from 'os'; -import { setTimeout } from 'timers/promises'; +import os from 'node:os'; +import { setTimeout } from 'node:timers/promises'; import { AccessLevel, SingletonProto, diff --git a/app/core/service/ProxyCacheService.ts b/app/core/service/ProxyCacheService.ts index 755926c1..4d715bed 100644 --- a/app/core/service/ProxyCacheService.ts +++ b/app/core/service/ProxyCacheService.ts @@ -1,6 +1,6 @@ -import { EggHttpClient, HttpClientRequestOptions, HttpClientResponse } from 'egg'; +import { EggHttpClient, HttpClientRequestOptions, HttpClientResponse, Context } from 'egg'; import { ForbiddenError } from 'egg-errors'; -import { SingletonProto, AccessLevel, Inject, EggContext } from '@eggjs/tegg'; +import { SingletonProto, AccessLevel, Inject } from '@eggjs/tegg'; import { BackgroundTaskHelper } from '@eggjs/tegg-background-task'; import { valid as semverValid } from 'semver'; import { AbstractService } from '../../common/AbstractService'; @@ -51,7 +51,7 @@ export class ProxyCacheService extends AbstractService { @Inject() private readonly backgroundTaskHelper:BackgroundTaskHelper; - async getPackageVersionTarResponse(fullname: string, ctx: EggContext): Promise { + async getPackageVersionTarResponse(fullname: string, ctx: Context): Promise { if (this.config.cnpmcore.syncPackageBlockList.includes(fullname)) { throw new ForbiddenError(`stop proxy by block list: ${JSON.stringify(this.config.cnpmcore.syncPackageBlockList)}`); } @@ -244,7 +244,7 @@ export class ProxyCacheService extends AbstractService { await this.nfsAdapter.uploadBytes(storeKey, nfsBytes); } - async getProxyResponse(ctx: Partial, options?: HttpClientRequestOptions): Promise { + async getProxyResponse(ctx: Partial, options?: HttpClientRequestOptions): Promise { const registry = this.npmRegistry.registry; const remoteAuthToken = await this.registryManagerService.getAuthTokenByRegistryHost(registry); const authorization = this.npmRegistry.genAuthorizationHeader(remoteAuthToken); diff --git a/app/core/service/UserService.ts b/app/core/service/UserService.ts index e4987844..fd1f342c 100644 --- a/app/core/service/UserService.ts +++ b/app/core/service/UserService.ts @@ -1,4 +1,4 @@ -import crypto from 'crypto'; +import crypto from 'node:crypto'; import { AccessLevel, SingletonProto, diff --git a/app/infra/AuthAdapter.ts b/app/infra/AuthAdapter.ts index fa82bc6a..84ca2a09 100644 --- a/app/infra/AuthAdapter.ts +++ b/app/infra/AuthAdapter.ts @@ -5,7 +5,7 @@ import { SingletonProto, } from '@eggjs/tegg'; import { Redis } from 'ioredis'; -import { randomUUID } from 'crypto'; +import { randomUUID } from 'node:crypto'; import { AuthClient, AuthUrlResult, userResult } from '../common/typing'; const ONE_DAY = 3600 * 24; diff --git a/app/infra/NFSClientAdapter.ts b/app/infra/NFSClientAdapter.ts index 6a345ab3..2e4df801 100644 --- a/app/infra/NFSClientAdapter.ts +++ b/app/infra/NFSClientAdapter.ts @@ -7,7 +7,7 @@ import { import { EggAppConfig, EggLogger } from 'egg'; import FSClient from 'fs-cnpm'; import { AppendResult, NFSClient, UploadOptions, UploadResult, DownloadOptions } from '../common/typing'; -import { Readable } from 'stream'; +import { Readable } from 'node:stream'; @SingletonProto({ name: 'nfsClient', diff --git a/app/port/UserRoleManager.ts b/app/port/UserRoleManager.ts index cb823443..c0b5da34 100644 --- a/app/port/UserRoleManager.ts +++ b/app/port/UserRoleManager.ts @@ -105,7 +105,7 @@ export class UserRoleManager { }; } this.handleAuthorized = true; - const authorization = ctx.get('authorization'); + const authorization = ctx.get('authorization'); if (!authorization) return null; const authorizedUserAndToken = await this.tokenService.getUserAndToken(authorization); if (!authorizedUserAndToken) { @@ -187,3 +187,9 @@ export class UserRoleManager { return user.name in this.config.cnpmcore.admins; } } + +declare module 'egg' { + export interface Context { + userId?: string; + } +} diff --git a/app/port/controller/BinarySyncController.ts b/app/port/controller/BinarySyncController.ts index 01d896aa..3e3dffda 100644 --- a/app/port/controller/BinarySyncController.ts +++ b/app/port/controller/BinarySyncController.ts @@ -7,7 +7,7 @@ import { EggContext, Inject, } from '@eggjs/tegg'; -import path from 'path'; +import path from 'node:path'; import { NotFoundError } from 'egg-errors'; import { AbstractController } from './AbstractController'; import { BinarySyncerService } from '../../core/service/BinarySyncerService'; diff --git a/app/port/controller/HomeController.ts b/app/port/controller/HomeController.ts index 1c0774a0..95051e2e 100644 --- a/app/port/controller/HomeController.ts +++ b/app/port/controller/HomeController.ts @@ -1,4 +1,4 @@ -import { performance } from 'perf_hooks'; +import { performance } from 'node:perf_hooks'; import { HTTPController, HTTPMethod, diff --git a/app/port/controller/package/DownloadPackageVersionTar.ts b/app/port/controller/package/DownloadPackageVersionTar.ts index 03ddb15c..9117d940 100644 --- a/app/port/controller/package/DownloadPackageVersionTar.ts +++ b/app/port/controller/package/DownloadPackageVersionTar.ts @@ -119,7 +119,7 @@ export class DownloadPackageVersionTarController extends AbstractController { private async getTgzProxyStream(ctx: EggContext, fullname: string, version: string) { const { headers, status, res } = await this.proxyCacheService.getPackageVersionTarResponse(fullname, ctx); ctx.status = status; - ctx.set(headers as { [key: string]: string | string[] }); + ctx.set(headers as Record); ctx.runInBackground(async () => { const task = await this.packageSyncerService.createTask(fullname, { authorIp: ctx.ip, diff --git a/app/port/controller/package/SavePackageVersionController.ts b/app/port/controller/package/SavePackageVersionController.ts index e8214a81..c271f121 100644 --- a/app/port/controller/package/SavePackageVersionController.ts +++ b/app/port/controller/package/SavePackageVersionController.ts @@ -268,9 +268,9 @@ export class SavePackageVersionController extends AbstractController { // forbidden star/unstar request // npm@6: referer: 'star [REDACTED]' // npm@>=7: 'npm-command': 'star' - let command = ctx.get('npm-command'); + let command = ctx.get('npm-command'); if (!command) { - command = ctx.get('referer').split(' ', 1)[0]; + command = ctx.get('referer').split(' ', 1)[0]; } if (command === 'star' || command === 'unstar') { throw new ForbiddenError(`npm ${command} is not allowed`); diff --git a/app/port/controller/package/ShowPackageController.ts b/app/port/controller/package/ShowPackageController.ts index d77db07d..36738ceb 100644 --- a/app/port/controller/package/ShowPackageController.ts +++ b/app/port/controller/package/ShowPackageController.ts @@ -42,7 +42,7 @@ export class ShowPackageController extends AbstractController { try { const cacheEtag = await this.cacheService.getPackageEtag(fullname, isFullManifests); if (!isSync && cacheEtag) { - let requestEtag = ctx.request.get('if-none-match'); + let requestEtag = ctx.request.get('if-none-match'); if (requestEtag.startsWith('W/')) { requestEtag = requestEtag.substring(2); } diff --git a/app/port/controller/package/UpdatePackageController.ts b/app/port/controller/package/UpdatePackageController.ts index 093e6f29..721327a5 100644 --- a/app/port/controller/package/UpdatePackageController.ts +++ b/app/port/controller/package/UpdatePackageController.ts @@ -71,9 +71,9 @@ export class UpdatePackageController extends AbstractController { private getNpmCommand(ctx: EggContext) { // npm@6: referer: 'xxx [REDACTED]' // npm@>=7: 'npm-command': 'xxx' - let npmCommand = ctx.get('npm-command'); + let npmCommand = ctx.get('npm-command'); if (!npmCommand) { - npmCommand = ctx.get('referer').split(' ', 1)[0]; + npmCommand = ctx.get('referer').split(' ', 1)[0]; } return npmCommand; diff --git a/app/port/middleware/ErrorHandler.ts b/app/port/middleware/ErrorHandler.ts index f8c5bf8c..929eb7ec 100644 --- a/app/port/middleware/ErrorHandler.ts +++ b/app/port/middleware/ErrorHandler.ts @@ -10,15 +10,15 @@ export async function ErrorHandler(ctx: EggContext, next: Next) { if (err.name === 'PackageNotFoundError') { if (err.syncPackage) { // create sync task - const syncPacakge = err.syncPackage; + const syncPackage = err.syncPackage; const packageSyncerService = await ctx.getEggObject(PackageSyncerService); - const task = await packageSyncerService.createTask(syncPacakge.fullname, { + const task = await packageSyncerService.createTask(syncPackage.fullname, { authorIp: ctx.ip, authorId: ctx.userId, - tips: `Sync cause by "${syncPacakge.fullname}" missing, request URL "${ctx.href}"`, + tips: `Sync cause by "${syncPackage.fullname}" missing, request URL "${ctx.href}"`, }); ctx.logger.info('[middleware:ErrorHandler][syncPackage] create sync package "%s" task %s', - syncPacakge.fullname, task.taskId); + syncPackage.fullname, task.taskId); } if (err.redirectToSourceRegistry) { // redirect to sourceRegistry diff --git a/app/port/schedule/CleanTempDir.ts b/app/port/schedule/CleanTempDir.ts index 5d74fe14..63a9bd0b 100644 --- a/app/port/schedule/CleanTempDir.ts +++ b/app/port/schedule/CleanTempDir.ts @@ -1,8 +1,8 @@ import { EggAppConfig, EggLogger } from 'egg'; import { CronParams, Schedule, ScheduleType } from '@eggjs/tegg/schedule'; import { Inject } from '@eggjs/tegg'; -import { rm, access } from 'fs/promises'; -import path from 'path'; +import { rm, access } from 'node:fs/promises'; +import path from 'node:path'; import dayjs from '../../common/dayjs'; @Schedule({ diff --git a/app/port/webauth/WebauthController.ts b/app/port/webauth/WebauthController.ts index d4939c7d..a64c1573 100644 --- a/app/port/webauth/WebauthController.ts +++ b/app/port/webauth/WebauthController.ts @@ -15,7 +15,7 @@ import { } from 'egg'; import { Static, Type } from '@sinclair/typebox'; import { ForbiddenError, NotFoundError } from 'egg-errors'; -import { createHash } from 'crypto'; +import { createHash } from 'node:crypto'; import base64url from 'base64url'; import { generateRegistrationOptions, diff --git a/config/config.unittest.ts b/config/config.unittest.ts index 070884da..109f426b 100644 --- a/config/config.unittest.ts +++ b/config/config.unittest.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from 'node:path'; import { EggAppConfig, PowerPartial } from 'egg'; import Mock from '@elastic/elasticsearch-mock'; import { database } from './database'; diff --git a/config/plugin.ts b/config/plugin.ts index ed1630c5..0d826d7e 100644 --- a/config/plugin.ts +++ b/config/plugin.ts @@ -38,7 +38,7 @@ const plugin: EggPlugin = { }, tracer: { enable: true, - package: 'egg-tracer', + package: '@eggjs/tracer', }, typeboxValidate: { enable: true, @@ -46,7 +46,7 @@ const plugin: EggPlugin = { }, redis: { enable: true, - package: 'egg-redis', + package: '@eggjs/redis', }, cors: { enable: true, diff --git a/module.d.ts b/module.d.ts index f1060c40..d41dbda3 100644 --- a/module.d.ts +++ b/module.d.ts @@ -4,4 +4,4 @@ declare module "egg" { export interface EggContextModule { cnpmcoreCore: ContextCnpmcore; } -}; +} diff --git a/package.json b/package.json index 9187ef98..7daea5c4 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "files": [ "dist/**/*" ], + "type": "commonjs", "main": "./dist/app.js", "typings": "./dist/app", "exports": { @@ -74,6 +75,8 @@ "registry" ], "dependencies": { + "@eggjs/redis": "^3.0.0", + "@eggjs/scripts": "^4.0.0", "@eggjs/tegg": "^3.12.0", "@eggjs/tegg-aop-plugin": "^3.12.0", "@eggjs/tegg-background-task": "^3.29.0", @@ -83,6 +86,7 @@ "@eggjs/tegg-orm-plugin": "^3.12.0", "@eggjs/tegg-plugin": "^3.12.0", "@eggjs/tegg-schedule-plugin": "^3.12.0", + "@eggjs/tracer": "^3.0.0", "@eggjs/tsconfig": "^1.0.0", "@elastic/elasticsearch": "^8.8.1", "@fengmk2/tar": "^6.2.0", @@ -93,13 +97,10 @@ "base64url": "^3.0.1", "bson-objectid": "^2.0.1", "dayjs": "^1.10.7", - "egg": "^3.29.0", + "egg": "^4.0.7", "egg-cors": "^3.0.0", "egg-errors": "^2.3.0", - "egg-redis": "^2.4.0", - "egg-scripts": "^3.0.0", "egg-status": "^1.0.0", - "egg-tracer": "^1.1.0", "egg-typebox-validate": "^2.0.0", "egg-view-nunjucks": "^2.3.0", "eggjs-elasticsearch": "^0.0.6", @@ -126,6 +127,8 @@ }, "devDependencies": { "@cnpmjs/npm-cli-login": "^1.1.0", + "@eggjs/bin": "^7.1.0", + "@eggjs/mock": "^6.0.5", "@elastic/elasticsearch-mock": "^2.0.0", "@simplewebauthn/typescript-types": "^7.0.0", "@types/lodash": "^4.14.196", @@ -140,11 +143,9 @@ "@types/ua-parser-js": "^0.7.36", "@types/validate-npm-package-name": "^4.0.2", "coffee": "^5.4.0", - "egg-bin": "^6.0.0", - "egg-mock": "^5.10.4", "eslint": "^8.29.0", - "eslint-config-egg": "^13.0.0", - "typescript": "5.2.2" + "eslint-config-egg": "^14.0.0", + "typescript": "^5.7.3" }, "author": "killagu", "license": "MIT", diff --git a/test/.setup.ts b/test/.setup.ts index 5c8d4798..e4de9994 100644 --- a/test/.setup.ts +++ b/test/.setup.ts @@ -1,4 +1,4 @@ -import { mock } from 'egg-mock/bootstrap'; +import { mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from './TestUtil'; beforeEach(async () => { diff --git a/test/TestUtil.ts b/test/TestUtil.ts index 1cbd41ad..2a4aab8f 100644 --- a/test/TestUtil.ts +++ b/test/TestUtil.ts @@ -1,13 +1,13 @@ -import fs from 'fs/promises'; +import fs from 'node:fs/promises'; // 统一通过 coffee 执行 child_process,获取运行时的一些环境信息 import coffee from 'coffee'; -import { tmpdir } from 'os'; -import { mkdtempSync } from 'fs'; -import { Readable } from 'stream'; +import { tmpdir } from 'node:os'; +import { mkdtempSync } from 'node:fs'; +import { Readable } from 'node:stream'; import mysql from 'mysql2'; import pg from 'pg'; -import path from 'path'; -import crypto from 'crypto'; +import path from 'node:path'; +import crypto from 'node:crypto'; import { cleanUserPrefix, getScopeAndName } from '../app/common/PackageUtil'; import semver from 'semver'; import { PackageJSONType } from '../app/repository/PackageRepository'; @@ -127,7 +127,7 @@ export class TestUtil { static get app() { if (!this._app) { /* eslint @typescript-eslint/no-var-requires: "off" */ - const bootstrap = require('egg-mock/bootstrap'); + const bootstrap = require('@eggjs/mock/bootstrap'); this._app = bootstrap.app; } return this._app; diff --git a/test/cli/npm/access.test.ts b/test/cli/npm/access.test.ts index 016601cb..798f5940 100644 --- a/test/cli/npm/access.test.ts +++ b/test/cli/npm/access.test.ts @@ -1,5 +1,5 @@ import path from 'node:path'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import coffee from 'coffee'; import semver from 'semver'; import { TestUtil } from '../../../test/TestUtil'; diff --git a/test/cli/npm/install.test.ts b/test/cli/npm/install.test.ts index 45857f72..fcb2ec8d 100644 --- a/test/cli/npm/install.test.ts +++ b/test/cli/npm/install.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import path from 'node:path'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import coffee from 'coffee'; import { TestUtil } from '../../../test/TestUtil'; import { npmLogin } from '../CliUtil'; diff --git a/test/common/adapter/BugVersionStore.test.ts b/test/common/adapter/BugVersionStore.test.ts index 09cde263..4255b94e 100644 --- a/test/common/adapter/BugVersionStore.test.ts +++ b/test/common/adapter/BugVersionStore.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { BugVersionStore } from '../../../app/common/adapter/BugVersionStore'; import { BugVersion } from '../../../app/core/entity/BugVersion'; diff --git a/test/common/adapter/CacheAdapter.test.ts b/test/common/adapter/CacheAdapter.test.ts index 4bbabb48..e48a9aa8 100644 --- a/test/common/adapter/CacheAdapter.test.ts +++ b/test/common/adapter/CacheAdapter.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { CacheAdapter } from '../../../app/common/adapter/CacheAdapter'; describe('test/common/adapter/CacheAdapter.test.ts', () => { diff --git a/test/common/adapter/NpmRegistry.test.ts b/test/common/adapter/NpmRegistry.test.ts index 2477ad1b..901ee10c 100644 --- a/test/common/adapter/NpmRegistry.test.ts +++ b/test/common/adapter/NpmRegistry.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { NPMRegistry } from '../../../app/common/adapter/NPMRegistry'; describe('test/common/adapter/CacheAdapter.test.ts', () => { diff --git a/test/common/adapter/binary/ApiBinary.test.ts b/test/common/adapter/binary/ApiBinary.test.ts index 87e32165..4f90f7e1 100644 --- a/test/common/adapter/binary/ApiBinary.test.ts +++ b/test/common/adapter/binary/ApiBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { ApiBinary } from '../../../../app/common/adapter/binary/ApiBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/BucketBinary.test.ts b/test/common/adapter/binary/BucketBinary.test.ts index a24de4fe..48425563 100644 --- a/test/common/adapter/binary/BucketBinary.test.ts +++ b/test/common/adapter/binary/BucketBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { BucketBinary } from '../../../../app/common/adapter/binary/BucketBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/ChromeForTestingBinary.test.ts b/test/common/adapter/binary/ChromeForTestingBinary.test.ts index 4945a4bf..c0990b0b 100644 --- a/test/common/adapter/binary/ChromeForTestingBinary.test.ts +++ b/test/common/adapter/binary/ChromeForTestingBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ChromeForTestingBinary } from '../../../../app/common/adapter/binary/ChromeForTestingBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/CypressBinary.test.ts b/test/common/adapter/binary/CypressBinary.test.ts index b151f417..b3f58215 100644 --- a/test/common/adapter/binary/CypressBinary.test.ts +++ b/test/common/adapter/binary/CypressBinary.test.ts @@ -1,5 +1,5 @@ import assert from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { CypressBinary } from '../../../../app/common/adapter/binary/CypressBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/EdgedriverBinary.test.ts b/test/common/adapter/binary/EdgedriverBinary.test.ts index 33f03bff..2b0d0718 100644 --- a/test/common/adapter/binary/EdgedriverBinary.test.ts +++ b/test/common/adapter/binary/EdgedriverBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { EdgedriverBinary } from '../../../../app/common/adapter/binary/EdgedriverBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/ElectronBinary.test.ts b/test/common/adapter/binary/ElectronBinary.test.ts index 036d3f7f..77e5fc6c 100644 --- a/test/common/adapter/binary/ElectronBinary.test.ts +++ b/test/common/adapter/binary/ElectronBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ElectronBinary } from '../../../../app/common/adapter/binary/ElectronBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/GithubBinary.test.ts b/test/common/adapter/binary/GithubBinary.test.ts index 402aa1ae..cce138ba 100644 --- a/test/common/adapter/binary/GithubBinary.test.ts +++ b/test/common/adapter/binary/GithubBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { GithubBinary } from '../../../../app/common/adapter/binary/GithubBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/ImageminBinary.test.ts b/test/common/adapter/binary/ImageminBinary.test.ts index 389239c4..352e3dbf 100644 --- a/test/common/adapter/binary/ImageminBinary.test.ts +++ b/test/common/adapter/binary/ImageminBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ImageminBinary } from '../../../../app/common/adapter/binary/ImageminBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/NodeBinary.test.ts b/test/common/adapter/binary/NodeBinary.test.ts index 27506a71..970f42aa 100644 --- a/test/common/adapter/binary/NodeBinary.test.ts +++ b/test/common/adapter/binary/NodeBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { NodeBinary } from '../../../../app/common/adapter/binary/NodeBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/NodePreGypBinary.test.ts b/test/common/adapter/binary/NodePreGypBinary.test.ts index bb5ef9b2..9eefa6a7 100644 --- a/test/common/adapter/binary/NodePreGypBinary.test.ts +++ b/test/common/adapter/binary/NodePreGypBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { NodePreGypBinary } from '../../../../app/common/adapter/binary/NodePreGypBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/NwjsBinary.test.ts b/test/common/adapter/binary/NwjsBinary.test.ts index b9b3d0cc..615c275d 100644 --- a/test/common/adapter/binary/NwjsBinary.test.ts +++ b/test/common/adapter/binary/NwjsBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { NwjsBinary } from '../../../../app/common/adapter/binary/NwjsBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/PlaywrightBinary.test.ts b/test/common/adapter/binary/PlaywrightBinary.test.ts index 5d809b3a..d3bd8d6c 100644 --- a/test/common/adapter/binary/PlaywrightBinary.test.ts +++ b/test/common/adapter/binary/PlaywrightBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { PlaywrightBinary } from '../../../../app/common/adapter/binary/PlaywrightBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/PrismaBinary.test.ts b/test/common/adapter/binary/PrismaBinary.test.ts index 3ee5e7fb..94a4c64b 100644 --- a/test/common/adapter/binary/PrismaBinary.test.ts +++ b/test/common/adapter/binary/PrismaBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { PrismaBinary } from '../../../../app/common/adapter/binary/PrismaBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/PuppeteerBinary.test.ts b/test/common/adapter/binary/PuppeteerBinary.test.ts index 19a766f6..2dbb8c8b 100644 --- a/test/common/adapter/binary/PuppeteerBinary.test.ts +++ b/test/common/adapter/binary/PuppeteerBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { PuppeteerBinary } from '../../../../app/common/adapter/binary/PuppeteerBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/SqlcipherBinary.test.ts b/test/common/adapter/binary/SqlcipherBinary.test.ts index e96ca677..98c03712 100644 --- a/test/common/adapter/binary/SqlcipherBinary.test.ts +++ b/test/common/adapter/binary/SqlcipherBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { SqlcipherBinary } from '../../../../app/common/adapter/binary/SqlcipherBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts b/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts index 8c70f9f4..d576f983 100644 --- a/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts +++ b/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ChangesStreamChange } from '../../../../app/common/adapter/changesStream/AbstractChangesStream'; import { CnpmcoreChangesStream } from '../../../../app/common/adapter/changesStream/CnpmcoreChangesStream'; import { RegistryType } from '../../../../app/common/enum/Registry'; diff --git a/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts b/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts index 58d6ecaf..348d407b 100644 --- a/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts +++ b/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ChangesStreamChange } from '../../../../app/common/adapter/changesStream/AbstractChangesStream'; import { CnpmjsorgChangesStream } from '../../../../app/common/adapter/changesStream/CnpmjsorgChangesStream'; import { RegistryType } from '../../../../app/common/enum/Registry'; diff --git a/test/common/adapter/changesStream/NpmChangesStream.test.ts b/test/common/adapter/changesStream/NpmChangesStream.test.ts index 1c674e13..473b9fe0 100644 --- a/test/common/adapter/changesStream/NpmChangesStream.test.ts +++ b/test/common/adapter/changesStream/NpmChangesStream.test.ts @@ -1,6 +1,6 @@ import { Readable, Duplex } from 'node:stream'; import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { ChangesStreamChange } from '../../../../app/common/adapter/changesStream/AbstractChangesStream'; import { NpmChangesStream } from '../../../../app/common/adapter/changesStream/NpmChangesStream'; import { RegistryType } from '../../../../app/common/enum/Registry'; diff --git a/test/core/event/BugVersionFixHandler.test.ts b/test/core/event/BugVersionFixHandler.test.ts index d2c0088a..ea7b5c99 100644 --- a/test/core/event/BugVersionFixHandler.test.ts +++ b/test/core/event/BugVersionFixHandler.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { BUG_VERSIONS } from '../../../app/common/constants'; import { CacheService } from '../../../app/core/service/CacheService'; import { BugVersionFixHandler } from '../../../app/core/event/BugVersionFixHandler'; diff --git a/test/core/event/ChangesStream.test.ts b/test/core/event/ChangesStream.test.ts index b95b18ff..6149b07b 100644 --- a/test/core/event/ChangesStream.test.ts +++ b/test/core/event/ChangesStream.test.ts @@ -1,5 +1,5 @@ import { PackageVersionAddedChangesStreamEvent } from '../../../app/core/event/ChangesStream'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; describe('test/core/event/BugVersionFixHandler.test.ts', () => { let packageVersionAddedChangesStreamEvent: PackageVersionAddedChangesStreamEvent; diff --git a/test/core/event/StoreManifest.test.ts b/test/core/event/StoreManifest.test.ts index 81dfdf9b..2da18748 100644 --- a/test/core/event/StoreManifest.test.ts +++ b/test/core/event/StoreManifest.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; import { getScopeAndName } from '../../../app/common/PackageUtil'; import { PackageRepository } from '../../../app/repository/PackageRepository'; diff --git a/test/core/service/BinarySyncerService/createTask.test.ts b/test/core/service/BinarySyncerService/createTask.test.ts index 5742ed1c..47bf5392 100644 --- a/test/core/service/BinarySyncerService/createTask.test.ts +++ b/test/core/service/BinarySyncerService/createTask.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { BinarySyncerService } from '../../../../app/core/service/BinarySyncerService'; import { BinaryName } from '../../../../config/binaries'; diff --git a/test/core/service/BinarySyncerService/executeTask.test.ts b/test/core/service/BinarySyncerService/executeTask.test.ts index 70e67ece..e4cc8651 100644 --- a/test/core/service/BinarySyncerService/executeTask.test.ts +++ b/test/core/service/BinarySyncerService/executeTask.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BinarySyncerService } from '../../../../app/core/service/BinarySyncerService'; import { Task as TaskModel } from '../../../../app/repository/model/Task'; diff --git a/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts b/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts index 7260a30a..2104bcc0 100644 --- a/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts +++ b/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; import { CacheService } from '../../../../app/core/service/CacheService'; diff --git a/test/core/service/BugVersionService/fixPackageBugVersion.test.ts b/test/core/service/BugVersionService/fixPackageBugVersion.test.ts index a87f38cb..b7d8f82a 100644 --- a/test/core/service/BugVersionService/fixPackageBugVersion.test.ts +++ b/test/core/service/BugVersionService/fixPackageBugVersion.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; import { DistRepository } from '../../../../app/repository/DistRepository'; diff --git a/test/core/service/BugVersionService/fixPackageBugVersions.test.ts b/test/core/service/BugVersionService/fixPackageBugVersions.test.ts index 9a12da92..d1b25fdf 100644 --- a/test/core/service/BugVersionService/fixPackageBugVersions.test.ts +++ b/test/core/service/BugVersionService/fixPackageBugVersions.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; import { BugVersion } from '../../../../app/core/entity/BugVersion'; diff --git a/test/core/service/ChangesStreamService.test.ts b/test/core/service/ChangesStreamService.test.ts index 0f819b11..a7151690 100644 --- a/test/core/service/ChangesStreamService.test.ts +++ b/test/core/service/ChangesStreamService.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import { Readable } from 'node:stream'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; import { ChangesStreamService } from '../../../app/core/service/ChangesStreamService'; import { TaskService } from '../../../app/core/service/TaskService'; diff --git a/test/core/service/CreateHookTriggerService.test.ts b/test/core/service/CreateHookTriggerService.test.ts index 0c2beb95..fa037f34 100644 --- a/test/core/service/CreateHookTriggerService.test.ts +++ b/test/core/service/CreateHookTriggerService.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; import { HookManageService } from '../../../app/core/service/HookManageService'; import { HookType } from '../../../app/common/enum/Hook'; diff --git a/test/core/service/HookManageService/createHook.test.ts b/test/core/service/HookManageService/createHook.test.ts index 32772d71..d8121d89 100644 --- a/test/core/service/HookManageService/createHook.test.ts +++ b/test/core/service/HookManageService/createHook.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; import { HookType } from '../../../../app/common/enum/Hook'; diff --git a/test/core/service/HookManageService/deleteHook.test.ts b/test/core/service/HookManageService/deleteHook.test.ts index f1d394e1..cc08dd1e 100644 --- a/test/core/service/HookManageService/deleteHook.test.ts +++ b/test/core/service/HookManageService/deleteHook.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; import { Hook } from '../../../../app/core/entity/Hook'; diff --git a/test/core/service/HookManageService/getHookByOwnerId.test.ts b/test/core/service/HookManageService/getHookByOwnerId.test.ts index fe06c4dc..ebd5c657 100644 --- a/test/core/service/HookManageService/getHookByOwnerId.test.ts +++ b/test/core/service/HookManageService/getHookByOwnerId.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; import { Hook } from '../../../../app/core/entity/Hook'; diff --git a/test/core/service/HookManageService/updateHook.test.ts b/test/core/service/HookManageService/updateHook.test.ts index 49a52f7e..b215bd8a 100644 --- a/test/core/service/HookManageService/updateHook.test.ts +++ b/test/core/service/HookManageService/updateHook.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; import { Hook } from '../../../../app/core/entity/Hook'; diff --git a/test/core/service/HookTriggerService.test.ts b/test/core/service/HookTriggerService.test.ts index 2ba57f8d..015c17ca 100644 --- a/test/core/service/HookTriggerService.test.ts +++ b/test/core/service/HookTriggerService.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import { HttpClientRequestOptions } from 'egg'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; import { HookManageService } from '../../../app/core/service/HookManageService'; import { HookType } from '../../../app/common/enum/Hook'; diff --git a/test/core/service/PackageManagerService/block.test.ts b/test/core/service/PackageManagerService/block.test.ts index 8efb2072..31b61e16 100644 --- a/test/core/service/PackageManagerService/block.test.ts +++ b/test/core/service/PackageManagerService/block.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageManagerService } from '../../../../app/core/service/PackageManagerService'; diff --git a/test/core/service/PackageManagerService/publish.test.ts b/test/core/service/PackageManagerService/publish.test.ts index adb2b77d..cc7e238d 100644 --- a/test/core/service/PackageManagerService/publish.test.ts +++ b/test/core/service/PackageManagerService/publish.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageManagerService } from '../../../../app/core/service/PackageManagerService'; import { UserService } from '../../../../app/core/service/UserService'; diff --git a/test/core/service/PackageSyncerService/createTask.test.ts b/test/core/service/PackageSyncerService/createTask.test.ts index 9985da57..37daa344 100644 --- a/test/core/service/PackageSyncerService/createTask.test.ts +++ b/test/core/service/PackageSyncerService/createTask.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; -import { setTimeout } from 'timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { setTimeout } from 'node:timers/promises'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { Task } from '../../../../app/core/entity/Task'; diff --git a/test/core/service/PackageSyncerService/executeTask.test.ts b/test/core/service/PackageSyncerService/executeTask.test.ts index c6d076df..b948900f 100644 --- a/test/core/service/PackageSyncerService/executeTask.test.ts +++ b/test/core/service/PackageSyncerService/executeTask.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { PackageManagerService } from '../../../../app/core/service/PackageManagerService'; @@ -1857,6 +1857,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => { status: 500, persist: false, repeats: 3, + data: 'server error', }); mock.error(NPMRegistry.prototype, 'downloadTarball'); mock.data(NPMRegistry.prototype, 'getFullManifests', { @@ -1898,6 +1899,7 @@ describe('test/core/service/PackageSyncerService/executeTask.test.ts', () => { status: 500, persist: false, repeats: 3, + data: 'server error', }); mock.data(NPMRegistry.prototype, 'getFullManifests', { data: { diff --git a/test/core/service/PackageSyncerService/findExecuteTask.test.ts b/test/core/service/PackageSyncerService/findExecuteTask.test.ts index e35c1ac8..8765163f 100644 --- a/test/core/service/PackageSyncerService/findExecuteTask.test.ts +++ b/test/core/service/PackageSyncerService/findExecuteTask.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { Task as TaskModel } from '../../../../app/repository/model/Task'; import { HistoryTask as HistoryTaskModel } from '../../../../app/repository/model/HistoryTask'; diff --git a/test/core/service/PackageSyncerService/getTaskRegistry.test.ts b/test/core/service/PackageSyncerService/getTaskRegistry.test.ts index 8d6ff6df..e451cb73 100644 --- a/test/core/service/PackageSyncerService/getTaskRegistry.test.ts +++ b/test/core/service/PackageSyncerService/getTaskRegistry.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; import { Registry } from '../../../../app/core/entity/Registry'; diff --git a/test/core/service/PackageVersionService.test.ts b/test/core/service/PackageVersionService.test.ts index 99867b44..34583b02 100644 --- a/test/core/service/PackageVersionService.test.ts +++ b/test/core/service/PackageVersionService.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import npa from 'npm-package-arg'; import { Package as PackageModel } from '../../../app/repository/model/Package'; diff --git a/test/core/service/ProxyCacheService.test.ts b/test/core/service/ProxyCacheService.test.ts index 76b3436c..ce2d35d0 100644 --- a/test/core/service/ProxyCacheService.test.ts +++ b/test/core/service/ProxyCacheService.test.ts @@ -1,5 +1,6 @@ -import assert from 'assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import assert from 'node:assert'; +import { app, mock } from '@eggjs/mock/bootstrap'; +import { Context } from 'egg'; import { TestUtil } from '../../TestUtil'; import { ProxyCacheService } from '../../../app/core/service/ProxyCacheService'; import { ProxyCacheRepository } from '../../../app/repository/ProxyCacheRepository'; @@ -22,7 +23,7 @@ describe('test/core/service/ProxyCacheService/index.test.ts', () => { const name = 'cnpmcore-test-sync-blocklist'; mock(app.config.cnpmcore, 'syncPackageBlockList', [ name ]); try { - await proxyCacheService.getPackageVersionTarResponse(name, app.mockContext()); + await proxyCacheService.getPackageVersionTarResponse(name, app.mockContext() as Context); } catch (error) { assert(error.options.message.includes('block list')); } diff --git a/test/core/service/RegistryManagerService/index.test.ts b/test/core/service/RegistryManagerService/index.test.ts index 7f65fbca..4203eec4 100644 --- a/test/core/service/RegistryManagerService/index.test.ts +++ b/test/core/service/RegistryManagerService/index.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; import { RegistryType } from '../../../../app/common/enum/Registry'; import { ScopeManagerService } from '../../../../app/core/service/ScopeManagerService'; diff --git a/test/core/service/ScopeManagerService/index.test.ts b/test/core/service/ScopeManagerService/index.test.ts index 53d05c4b..189419c1 100644 --- a/test/core/service/ScopeManagerService/index.test.ts +++ b/test/core/service/ScopeManagerService/index.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ScopeManagerService } from '../../../../app/core/service/ScopeManagerService'; describe('test/core/service/ScopeManagerService/index.test.ts', () => { diff --git a/test/core/service/TaskService/findExecuteTask.test.ts b/test/core/service/TaskService/findExecuteTask.test.ts index d3d85f18..e152a2e5 100644 --- a/test/core/service/TaskService/findExecuteTask.test.ts +++ b/test/core/service/TaskService/findExecuteTask.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mm } from 'egg-mock/bootstrap'; +import { app, mm } from '@eggjs/mock/bootstrap'; import { TaskService } from '../../../../app/core/service/TaskService'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { TaskState, TaskType } from '../../../../app/common/enum/Task'; diff --git a/test/infra/QueueAdapter.test.ts b/test/infra/QueueAdapter.test.ts index 295c8a2f..fdc19efc 100644 --- a/test/infra/QueueAdapter.test.ts +++ b/test/infra/QueueAdapter.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { RedisQueueAdapter } from '../../app/infra/QueueAdapter'; describe('test/infra/QueueAdapter.test.ts', () => { diff --git a/test/port/controller/AccessController/listCollaborators.test.ts b/test/port/controller/AccessController/listCollaborators.test.ts index 1bfda709..a442af71 100644 --- a/test/port/controller/AccessController/listCollaborators.test.ts +++ b/test/port/controller/AccessController/listCollaborators.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/AccessController/listCollaborators.test.ts', () => { diff --git a/test/port/controller/AccessController/listPackagesByUser.test.ts b/test/port/controller/AccessController/listPackagesByUser.test.ts index 0cf0dd04..92968252 100644 --- a/test/port/controller/AccessController/listPackagesByUser.test.ts +++ b/test/port/controller/AccessController/listPackagesByUser.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/AccessController/listPackagesByUser.test.ts', () => { diff --git a/test/port/controller/BinarySyncController/showBinary.test.ts b/test/port/controller/BinarySyncController/showBinary.test.ts index 3fd9c85f..9aaf70bf 100644 --- a/test/port/controller/BinarySyncController/showBinary.test.ts +++ b/test/port/controller/BinarySyncController/showBinary.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { BinarySyncerService } from '../../../../app/core/service/BinarySyncerService'; import { NodeBinary } from '../../../../app/common/adapter/binary/NodeBinary'; import { SqlcipherBinary } from '../../../../app/common/adapter/binary/SqlcipherBinary'; diff --git a/test/port/controller/ChangesStreamController/listChanges.test.ts b/test/port/controller/ChangesStreamController/listChanges.test.ts index 96e85ff3..fbb05ade 100644 --- a/test/port/controller/ChangesStreamController/listChanges.test.ts +++ b/test/port/controller/ChangesStreamController/listChanges.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/ChangesStreamController/listChanges.test.ts', () => { diff --git a/test/port/controller/DownloadController/showPackageDownloads.test.ts b/test/port/controller/DownloadController/showPackageDownloads.test.ts index 163e8e5c..d1285e06 100644 --- a/test/port/controller/DownloadController/showPackageDownloads.test.ts +++ b/test/port/controller/DownloadController/showPackageDownloads.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import dayjs from '../../../../app/common/dayjs'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/HomeController/cors.test.ts b/test/port/controller/HomeController/cors.test.ts index 37bdeb1d..689159f7 100644 --- a/test/port/controller/HomeController/cors.test.ts +++ b/test/port/controller/HomeController/cors.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; describe('test/port/controller/HomeController/cors.test.ts', () => { describe('CORS', () => { diff --git a/test/port/controller/HomeController/misc.test.ts b/test/port/controller/HomeController/misc.test.ts index dc3f07d0..07acd6cb 100644 --- a/test/port/controller/HomeController/misc.test.ts +++ b/test/port/controller/HomeController/misc.test.ts @@ -1,4 +1,4 @@ -import { app, assert } from 'egg-mock/bootstrap'; +import { app, assert } from '@eggjs/mock/bootstrap'; describe('test/port/controller/HomeController/misc.test.ts', () => { describe('[POST /*] misc()', () => { diff --git a/test/port/controller/HomeController/ping.test.ts b/test/port/controller/HomeController/ping.test.ts index 21a4ab4c..685877b7 100644 --- a/test/port/controller/HomeController/ping.test.ts +++ b/test/port/controller/HomeController/ping.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; describe('test/port/controller/HomeController/ping.test.ts', () => { describe('[GET /-/ping] ping()', () => { diff --git a/test/port/controller/HomeController/showTotal.test.ts b/test/port/controller/HomeController/showTotal.test.ts index 6916074e..9323b592 100644 --- a/test/port/controller/HomeController/showTotal.test.ts +++ b/test/port/controller/HomeController/showTotal.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageVersionDownload } from '../../../../app/repository/model/PackageVersionDownload'; import dayjs from '../../../../app/common/dayjs'; diff --git a/test/port/controller/PackageBlockController/blockPackage.test.ts b/test/port/controller/PackageBlockController/blockPackage.test.ts index 0f377878..aa24637b 100644 --- a/test/port/controller/PackageBlockController/blockPackage.test.ts +++ b/test/port/controller/PackageBlockController/blockPackage.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/PackageBlockController/blockPackage.test.ts', () => { diff --git a/test/port/controller/PackageBlockController/unblockPackage.test.ts b/test/port/controller/PackageBlockController/unblockPackage.test.ts index 4eeca613..996ade5d 100644 --- a/test/port/controller/PackageBlockController/unblockPackage.test.ts +++ b/test/port/controller/PackageBlockController/unblockPackage.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/PackageBlockController/unblockPackage.test.ts', () => { diff --git a/test/port/controller/PackageSyncController/createSyncTask.test.ts b/test/port/controller/PackageSyncController/createSyncTask.test.ts index d76f0827..3de01b95 100644 --- a/test/port/controller/PackageSyncController/createSyncTask.test.ts +++ b/test/port/controller/PackageSyncController/createSyncTask.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; -import { setTimeout } from 'timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { setTimeout } from 'node:timers/promises'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { Task as TaskModel } from '../../../../app/repository/model/Task'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; diff --git a/test/port/controller/PackageSyncController/showSyncTask.test.ts b/test/port/controller/PackageSyncController/showSyncTask.test.ts index 5fec3f87..7d80f3a3 100644 --- a/test/port/controller/PackageSyncController/showSyncTask.test.ts +++ b/test/port/controller/PackageSyncController/showSyncTask.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { TaskRepository } from '../../../../app/repository/TaskRepository'; import { TaskState } from '../../../../app/common/enum/Task'; diff --git a/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts b/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts index 28799681..a37d2514 100644 --- a/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts +++ b/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { TaskRepository } from '../../../../app/repository/TaskRepository'; import { TaskState } from '../../../../app/common/enum/Task'; diff --git a/test/port/controller/PackageTagController/removeTag.test.ts b/test/port/controller/PackageTagController/removeTag.test.ts index 3878aeb1..e5ee76b0 100644 --- a/test/port/controller/PackageTagController/removeTag.test.ts +++ b/test/port/controller/PackageTagController/removeTag.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/PackageTagController/removeTag.test.ts', () => { diff --git a/test/port/controller/PackageTagController/saveTag.test.ts b/test/port/controller/PackageTagController/saveTag.test.ts index 4ec3d15b..efb401ac 100644 --- a/test/port/controller/PackageTagController/saveTag.test.ts +++ b/test/port/controller/PackageTagController/saveTag.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/PackageTagController/saveTag.test.ts', () => { diff --git a/test/port/controller/PackageTagController/showTags.test.ts b/test/port/controller/PackageTagController/showTags.test.ts index fb9f7b3c..4f35c420 100644 --- a/test/port/controller/PackageTagController/showTags.test.ts +++ b/test/port/controller/PackageTagController/showTags.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/PackageTagController/showTags.test.ts', () => { diff --git a/test/port/controller/PackageVersionFileController/listFiles.test.ts b/test/port/controller/PackageVersionFileController/listFiles.test.ts index ed4ec5ba..74793434 100644 --- a/test/port/controller/PackageVersionFileController/listFiles.test.ts +++ b/test/port/controller/PackageVersionFileController/listFiles.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageVersionFileService } from '../../../../app/core/service/PackageVersionFileService'; import { calculateIntegrity } from '../../../../app/common/PackageUtil'; diff --git a/test/port/controller/PackageVersionFileController/raw.test.ts b/test/port/controller/PackageVersionFileController/raw.test.ts index 34966aad..26eaf077 100644 --- a/test/port/controller/PackageVersionFileController/raw.test.ts +++ b/test/port/controller/PackageVersionFileController/raw.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { calculateIntegrity } from '../../../../app/common/PackageUtil'; import { PackageTagChangedSyncPackageVersionFileEvent, PackageTagAddedSyncPackageVersionFileEvent } from '../../../../app/core/event/SyncPackageVersionFile'; diff --git a/test/port/controller/PackageVersionFileController/sync.test.ts b/test/port/controller/PackageVersionFileController/sync.test.ts index dcfc8d4b..09f7cd2d 100644 --- a/test/port/controller/PackageVersionFileController/sync.test.ts +++ b/test/port/controller/PackageVersionFileController/sync.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/PackageVersionFileController/sync.test.ts', () => { diff --git a/test/port/controller/ProxyCacheController/index.test.ts b/test/port/controller/ProxyCacheController/index.test.ts index 0406cae8..b0f738b0 100644 --- a/test/port/controller/ProxyCacheController/index.test.ts +++ b/test/port/controller/ProxyCacheController/index.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; // import { TestUtil } from '../../../../test/TestUtil'; import { DIST_NAMES } from '../../../../app/core/entity/Package'; import { ProxyCache } from '../../../../app/core/entity/ProxyCache'; diff --git a/test/port/controller/RegistryController/index.test.ts b/test/port/controller/RegistryController/index.test.ts index 4f5ee6fd..1a2d0a3f 100644 --- a/test/port/controller/RegistryController/index.test.ts +++ b/test/port/controller/RegistryController/index.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TaskType } from '../../../../app/common/enum/Task'; import { Registry } from '../../../../app/core/entity/Registry'; import { ChangesStreamTaskData } from '../../../../app/core/entity/Task'; diff --git a/test/port/controller/ScopeController/index.test.ts b/test/port/controller/ScopeController/index.test.ts index bc43b7ee..af6474b2 100644 --- a/test/port/controller/ScopeController/index.test.ts +++ b/test/port/controller/ScopeController/index.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { RegistryType } from '../../../../app/common/enum/Registry'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; import { TestUtil } from '../../../TestUtil'; diff --git a/test/port/controller/TokenController/createToken.test.ts b/test/port/controller/TokenController/createToken.test.ts index c8511660..87bb6df2 100644 --- a/test/port/controller/TokenController/createToken.test.ts +++ b/test/port/controller/TokenController/createToken.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import dayjs from 'dayjs'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { Token, TokenType } from '../../../../app/core/entity/Token'; import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; import { UserRepository } from '../../../../app/repository/UserRepository'; diff --git a/test/port/controller/TokenController/listTokens.test.ts b/test/port/controller/TokenController/listTokens.test.ts index ea42ba24..7404955b 100644 --- a/test/port/controller/TokenController/listTokens.test.ts +++ b/test/port/controller/TokenController/listTokens.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import dayjs from 'dayjs'; import { TokenType } from '../../../../app/core/entity/Token'; import { UserService } from '../../../../app/core/service/UserService'; diff --git a/test/port/controller/TokenController/removeToken.test.ts b/test/port/controller/TokenController/removeToken.test.ts index 74488120..da7b0dbf 100644 --- a/test/port/controller/TokenController/removeToken.test.ts +++ b/test/port/controller/TokenController/removeToken.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { Token, TokenType } from '../../../../app/core/entity/Token'; import { UserService } from '../../../../app/core/service/UserService'; import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; diff --git a/test/port/controller/UserController/loginOrCreateUser.test.ts b/test/port/controller/UserController/loginOrCreateUser.test.ts index f37706ed..eb8bf5a5 100644 --- a/test/port/controller/UserController/loginOrCreateUser.test.ts +++ b/test/port/controller/UserController/loginOrCreateUser.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; describe('test/port/controller/UserController/loginOrCreateUser.test.ts', () => { describe('[PUT /-/user/org.couchdb.user::username] loginOrCreateUser()', () => { diff --git a/test/port/controller/UserController/logout.test.ts b/test/port/controller/UserController/logout.test.ts index 8b0188aa..d8f483f5 100644 --- a/test/port/controller/UserController/logout.test.ts +++ b/test/port/controller/UserController/logout.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/UserController/logout.test.ts', () => { diff --git a/test/port/controller/UserController/saveProfile.test.ts b/test/port/controller/UserController/saveProfile.test.ts index 1afa0284..6adf233f 100644 --- a/test/port/controller/UserController/saveProfile.test.ts +++ b/test/port/controller/UserController/saveProfile.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/UserController/saveProfile.test.ts', () => { diff --git a/test/port/controller/UserController/showProfile.test.ts b/test/port/controller/UserController/showProfile.test.ts index d94c8ce3..76eabeb3 100644 --- a/test/port/controller/UserController/showProfile.test.ts +++ b/test/port/controller/UserController/showProfile.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/UserController/showProfile.test.ts', () => { diff --git a/test/port/controller/UserController/showUser.test.ts b/test/port/controller/UserController/showUser.test.ts index 51ab4e9f..afddaf67 100644 --- a/test/port/controller/UserController/showUser.test.ts +++ b/test/port/controller/UserController/showUser.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/UserController/showUser.test.ts', () => { diff --git a/test/port/controller/UserController/starredByUser.test.ts b/test/port/controller/UserController/starredByUser.test.ts index 8cda93b7..54833320 100644 --- a/test/port/controller/UserController/starredByUser.test.ts +++ b/test/port/controller/UserController/starredByUser.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/UserController/starredByUser.test.ts', () => { diff --git a/test/port/controller/UserController/whoami.test.ts b/test/port/controller/UserController/whoami.test.ts index 971e184b..1ad832b7 100644 --- a/test/port/controller/UserController/whoami.test.ts +++ b/test/port/controller/UserController/whoami.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import dayjs from 'dayjs'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/hook/HookController.test.ts b/test/port/controller/hook/HookController.test.ts index a3b71d0a..7f0773f2 100644 --- a/test/port/controller/hook/HookController.test.ts +++ b/test/port/controller/hook/HookController.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; import { Hook } from '../../../../app/core/entity/Hook'; diff --git a/test/port/controller/package/DownloadPackageVersionTarController.test.ts b/test/port/controller/package/DownloadPackageVersionTarController.test.ts index 1fd7abb7..edb7b405 100644 --- a/test/port/controller/package/DownloadPackageVersionTarController.test.ts +++ b/test/port/controller/package/DownloadPackageVersionTarController.test.ts @@ -1,6 +1,6 @@ -import { strict as assert } from 'assert'; +import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { NFSClientAdapter } from '../../../../app/infra/NFSClientAdapter'; import { SyncMode } from '../../../../app/common/constants'; diff --git a/test/port/controller/package/RemovePackageVersionController.test.ts b/test/port/controller/package/RemovePackageVersionController.test.ts index c91a5203..6be1d107 100644 --- a/test/port/controller/package/RemovePackageVersionController.test.ts +++ b/test/port/controller/package/RemovePackageVersionController.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageRepository } from '../../../../app/repository/PackageRepository'; diff --git a/test/port/controller/package/SavePackageVersionController.test.ts b/test/port/controller/package/SavePackageVersionController.test.ts index 97d9ddd3..9152648c 100644 --- a/test/port/controller/package/SavePackageVersionController.test.ts +++ b/test/port/controller/package/SavePackageVersionController.test.ts @@ -1,6 +1,6 @@ import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { ForbiddenError } from 'egg-errors'; import dayjs from 'dayjs'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/package/SearchPackageController.test.ts b/test/port/controller/package/SearchPackageController.test.ts index 63e0967b..5d4398b4 100644 --- a/test/port/controller/package/SearchPackageController.test.ts +++ b/test/port/controller/package/SearchPackageController.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { errors } from '@elastic/elasticsearch'; import { mockES } from '../../../../config/config.unittest'; import { TestUtil } from '../../../TestUtil'; diff --git a/test/port/controller/package/ShowPackageController.test.ts b/test/port/controller/package/ShowPackageController.test.ts index 77dad8d7..1b6580eb 100644 --- a/test/port/controller/package/ShowPackageController.test.ts +++ b/test/port/controller/package/ShowPackageController.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageManifestType, PackageRepository } from '../../../../app/repository/PackageRepository'; import { BugVersion } from '../../../../app/core/entity/BugVersion'; diff --git a/test/port/controller/package/ShowPackageVersionController.test.ts b/test/port/controller/package/ShowPackageVersionController.test.ts index 5857da7c..f7e254a7 100644 --- a/test/port/controller/package/ShowPackageVersionController.test.ts +++ b/test/port/controller/package/ShowPackageVersionController.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersion } from '../../../../app/core/entity/BugVersion'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; diff --git a/test/port/controller/package/UpdatePackageController.test.ts b/test/port/controller/package/UpdatePackageController.test.ts index b7e142f8..a074cc91 100644 --- a/test/port/controller/package/UpdatePackageController.test.ts +++ b/test/port/controller/package/UpdatePackageController.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { RegistryType } from '../../../../app/common/enum/Registry'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/middleware/AlwaysAuth.test.ts b/test/port/middleware/AlwaysAuth.test.ts index 8fc5fdb0..afe8799f 100644 --- a/test/port/middleware/AlwaysAuth.test.ts +++ b/test/port/middleware/AlwaysAuth.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TestUtil } from '../../TestUtil'; describe('test/port/middleware/AlwaysAuth.test.ts', () => { diff --git a/test/port/middleware/Tracing.test.ts b/test/port/middleware/Tracing.test.ts index e649e9ef..e32e4f74 100644 --- a/test/port/middleware/Tracing.test.ts +++ b/test/port/middleware/Tracing.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; describe('test/port/middleware/Tracing.test.ts', () => { it('should set request-id header', async () => { diff --git a/test/port/webauth/webauthController.test.ts b/test/port/webauth/webauthController.test.ts index aef0720c..e41c4f4f 100644 --- a/test/port/webauth/webauthController.test.ts +++ b/test/port/webauth/webauthController.test.ts @@ -1,7 +1,7 @@ import { strict as assert } from 'node:assert'; import crypto from 'node:crypto'; import { basename } from 'node:path'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { AuthAdapter } from '../../../app/infra/AuthAdapter'; import { CacheAdapter } from '../../../app/common/adapter/CacheAdapter'; import { UserService } from '../../../app/core/service/UserService'; diff --git a/test/repository/ChangeRepository.test.ts b/test/repository/ChangeRepository.test.ts index 58fb3972..97e8df8b 100644 --- a/test/repository/ChangeRepository.test.ts +++ b/test/repository/ChangeRepository.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ChangeRepository } from '../../app/repository/ChangeRepository'; import { Change as ChangeModel } from '../../app/repository/model/Change'; diff --git a/test/repository/PackageRepository.test.ts b/test/repository/PackageRepository.test.ts index 2f195f2b..766c1006 100644 --- a/test/repository/PackageRepository.test.ts +++ b/test/repository/PackageRepository.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { PackageRepository } from '../../app/repository/PackageRepository'; import { PackageManagerService } from '../../app/core/service/PackageManagerService'; import { UserService } from '../../app/core/service/UserService'; diff --git a/test/repository/ProxyCachePepository.test.ts b/test/repository/ProxyCachePepository.test.ts index 7ec93dd0..63379d01 100644 --- a/test/repository/ProxyCachePepository.test.ts +++ b/test/repository/ProxyCachePepository.test.ts @@ -1,5 +1,5 @@ -import assert from 'assert'; -import { app } from 'egg-mock/bootstrap'; +import assert from 'node:assert'; +import { app } from '@eggjs/mock/bootstrap'; import { ProxyCacheRepository } from '../../app/repository/ProxyCacheRepository'; import { ProxyCache } from '../../app/core/entity/ProxyCache'; import { DIST_NAMES } from '../../app/core/entity/Package'; diff --git a/test/repository/RegistryRepository.test.ts b/test/repository/RegistryRepository.test.ts index d8ee7b37..a2307569 100644 --- a/test/repository/RegistryRepository.test.ts +++ b/test/repository/RegistryRepository.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { RegistryRepository } from '../../app/repository/RegistryRepository'; import { Registry } from '../../app/core/entity/Registry'; import { RegistryType } from '../../app/common/enum/Registry'; diff --git a/test/repository/ScopeRepository.test.ts b/test/repository/ScopeRepository.test.ts index 9750552f..85b073fc 100644 --- a/test/repository/ScopeRepository.test.ts +++ b/test/repository/ScopeRepository.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { ScopeRepository } from '../../app/repository/ScopeRepository'; import { Scope } from '../../app/core/entity/Scope'; diff --git a/test/repository/SearchRepository.test.ts b/test/repository/SearchRepository.test.ts index 5e84c32e..7caec85a 100644 --- a/test/repository/SearchRepository.test.ts +++ b/test/repository/SearchRepository.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { SearchManifestType, SearchRepository } from '../../app/repository/SearchRepository'; import { mockES } from '../../config/config.unittest'; import { PackageManagerService } from '../../app/core/service/PackageManagerService'; diff --git a/test/repository/TaskRepository.test.ts b/test/repository/TaskRepository.test.ts index 88383ba1..3b010180 100644 --- a/test/repository/TaskRepository.test.ts +++ b/test/repository/TaskRepository.test.ts @@ -1,7 +1,7 @@ import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; import os from 'node:os'; -import { app } from 'egg-mock/bootstrap'; +import { app } from '@eggjs/mock/bootstrap'; import { TaskRepository } from '../../app/repository/TaskRepository'; import { Task as TaskModel } from '../../app/repository/model/Task'; import { ChangesStreamTaskData, Task, TaskData } from '../../app/core/entity/Task'; diff --git a/test/schedule/ChangesStreamWorker.test.ts b/test/schedule/ChangesStreamWorker.test.ts index bac786a3..ebcd85d5 100644 --- a/test/schedule/ChangesStreamWorker.test.ts +++ b/test/schedule/ChangesStreamWorker.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { ChangesStreamService } from '../../app/core/service/ChangesStreamService'; import { TaskService } from '../../app/core/service/TaskService'; import { Task } from '../../app/repository/model/Task'; diff --git a/test/schedule/CheckProxyCacheUpdateWorker.test.ts b/test/schedule/CheckProxyCacheUpdateWorker.test.ts index 20b5e4de..de519fc1 100644 --- a/test/schedule/CheckProxyCacheUpdateWorker.test.ts +++ b/test/schedule/CheckProxyCacheUpdateWorker.test.ts @@ -1,5 +1,5 @@ -import assert from 'assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import assert from 'node:assert'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { SyncMode } from '../../app/common/constants'; import { ProxyCacheRepository } from '../../app/repository/ProxyCacheRepository'; import { ProxyCache } from '../../app/core/entity/ProxyCache'; diff --git a/test/schedule/CheckRecentlyUpdatedPackages.test.ts b/test/schedule/CheckRecentlyUpdatedPackages.test.ts index f94988a8..eb1b1843 100644 --- a/test/schedule/CheckRecentlyUpdatedPackages.test.ts +++ b/test/schedule/CheckRecentlyUpdatedPackages.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { PackageSyncerService } from '../../app/core/service/PackageSyncerService'; import { TestUtil } from '../../test/TestUtil'; diff --git a/test/schedule/CleanTempDir.test.ts b/test/schedule/CleanTempDir.test.ts index 7741d3fd..4bae3606 100644 --- a/test/schedule/CleanTempDir.test.ts +++ b/test/schedule/CleanTempDir.test.ts @@ -1,6 +1,6 @@ -import { mkdir } from 'fs/promises'; -import path from 'path'; -import { app } from 'egg-mock/bootstrap'; +import { mkdir } from 'node:fs/promises'; +import path from 'node:path'; +import { app } from '@eggjs/mock/bootstrap'; import dayjs from '../../app/common/dayjs'; const CleanTempDirPath = require.resolve('../../app/port/schedule/CleanTempDir'); diff --git a/test/schedule/SyncBinaryWorker.test.ts b/test/schedule/SyncBinaryWorker.test.ts index 1725cbed..b00dbb79 100644 --- a/test/schedule/SyncBinaryWorker.test.ts +++ b/test/schedule/SyncBinaryWorker.test.ts @@ -1,4 +1,4 @@ -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { NodeBinary } from '../../app/common/adapter/binary/NodeBinary'; import { TestUtil } from '../../test/TestUtil'; diff --git a/test/schedule/SyncPackageWorker.test.ts b/test/schedule/SyncPackageWorker.test.ts index c800fc4f..1a146ffd 100644 --- a/test/schedule/SyncPackageWorker.test.ts +++ b/test/schedule/SyncPackageWorker.test.ts @@ -1,5 +1,5 @@ import { strict as assert } from 'node:assert'; -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { PackageSyncerService } from '../../app/core/service/PackageSyncerService'; import { TestUtil } from '../../test/TestUtil'; diff --git a/test/schedule/SyncProxyCacheWorker.test.ts b/test/schedule/SyncProxyCacheWorker.test.ts index 42098a06..98ee0b4c 100644 --- a/test/schedule/SyncProxyCacheWorker.test.ts +++ b/test/schedule/SyncProxyCacheWorker.test.ts @@ -1,4 +1,4 @@ -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { SyncMode } from '../../app/common/constants'; import { ProxyCacheRepository } from '../../app/repository/ProxyCacheRepository'; import { ProxyCache } from '../../app/core/entity/ProxyCache'; diff --git a/test/schedule/TaskTimeoutHandler.test.ts b/test/schedule/TaskTimeoutHandler.test.ts index 852b07a5..58d55744 100644 --- a/test/schedule/TaskTimeoutHandler.test.ts +++ b/test/schedule/TaskTimeoutHandler.test.ts @@ -1,4 +1,4 @@ -import { app, mock } from 'egg-mock/bootstrap'; +import { app, mock } from '@eggjs/mock/bootstrap'; import { TaskState } from '../../app/common/enum/Task'; import { PackageSyncerService } from '../../app/core/service/PackageSyncerService'; import { HistoryTask } from '../../app/repository/model/HistoryTask'; diff --git a/tsconfig.json b/tsconfig.json index cb3995cb..8158f514 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,8 +8,5 @@ "declaration": false, "resolveJsonModule": true, "useUnknownInCatchVariables": false, - }, - "exclude": [ - "node_modules" - ], + } } diff --git a/tsconfig.prod.json b/tsconfig.prod.json index 5a4fc1d6..2b2d3b5f 100644 --- a/tsconfig.prod.json +++ b/tsconfig.prod.json @@ -5,7 +5,6 @@ "declaration": true, }, "exclude": [ - "node_modules", "test" ], "include": [