env-plugin 0.5.9 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/bin/index.js +8 -2
  2. package/dist/Container.js +18 -0
  3. package/dist/PostProxyServer.js +33 -6
  4. package/dist/client/assets/element-plus-aWS7wRSd.js.gz +0 -0
  5. package/dist/client/assets/index-CBMR4n-V.js.gz +0 -0
  6. package/dist/client/assets/index-a3AJbcK4.css.gz +0 -0
  7. package/dist/client/assets/vue-uvJWWccw.js.gz +0 -0
  8. package/dist/client/index.html +4 -4
  9. package/dist/controllers/DevServerController.js +27 -2
  10. package/dist/controllers/EnvController.js +61 -3
  11. package/dist/controllers/ImportExportController.js +43 -0
  12. package/dist/controllers/RequestLogController.js +33 -0
  13. package/dist/controllers/SystemSettingController.js +43 -0
  14. package/dist/index.js +5 -0
  15. package/dist/repositories/DevServerRepo.js +14 -3
  16. package/dist/repositories/EnvRepo.js +12 -5
  17. package/dist/repositories/PasswordRepo.js +5 -3
  18. package/dist/repositories/RouteRuleRepo.js +5 -3
  19. package/dist/repositories/SystemSettingRepo.js +42 -0
  20. package/dist/repositories/database.js +12 -0
  21. package/dist/routes/index.js +196 -26
  22. package/dist/service/DevServerService.js +26 -2
  23. package/dist/service/EnvService.js +101 -0
  24. package/dist/service/ImportExportService.js +333 -0
  25. package/dist/service/PasswordService.js +8 -7
  26. package/dist/service/PreProxyServer.js +105 -12
  27. package/dist/service/RequestLogService.js +69 -0
  28. package/dist/service/RouteRuleService.js +14 -14
  29. package/dist/service/SystemSettingService.js +90 -0
  30. package/dist/types/index.js +3 -0
  31. package/dist/types/shared/DevServerItem.js +14 -1
  32. package/dist/types/shared/EnvItem.js +19 -0
  33. package/dist/types/shared/ImportExport.js +55 -0
  34. package/dist/types/shared/RequestLog.js +28 -0
  35. package/dist/types/shared/SystemSetting.js +18 -0
  36. package/dist/utils/asyncHandler.js +12 -0
  37. package/dist/utils/resourceType.js +42 -0
  38. package/dist/utils/routeBuilder.js +19 -0
  39. package/package.json +18 -5
  40. package/templates/inject/envm-switcher.js +1418 -0
  41. package/dist/client/assets/element-plus-ketO_xfq.js.gz +0 -0
  42. package/dist/client/assets/index-C-jtdEqj.js.gz +0 -0
  43. package/dist/client/assets/index-Crqzm-vz.css.gz +0 -0
  44. package/dist/client/assets/vue-BGFZjnqd.js.gz +0 -0
@@ -1,4 +1,5 @@
1
1
  import { v4 as uuidv4 } from "uuid";
2
+ import { AppError } from "../utils/errors.js";
2
3
  /**
3
4
  * 路由规则服务类
4
5
  * 负责处理与路由规则相关的核心业务逻辑,包括路由规则的增删改查等操作
@@ -39,7 +40,7 @@ class RouteRuleService {
39
40
  * 1. 校验输入参数合法性 2. 检查目标环境是否存在 3. 生成唯一ID 4. 保存
40
41
  * @param routeRuleItem - 待添加的路由规则信息(不含ID)
41
42
  * @returns 新创建的路由规则
42
- * @throws {Error} 当输入参数不合法或目标环境不存在时抛出
43
+ * @throws {AppError} 当输入参数不合法或目标环境不存在时抛出
43
44
  */
44
45
  handleAdd(routeRuleItem) {
45
46
  const { envId, pathPrefix, targetEnvId } = routeRuleItem;
@@ -47,16 +48,16 @@ class RouteRuleService {
47
48
  if (targetEnvId) {
48
49
  const targetEnv = this.envRepo.findOneById(targetEnvId);
49
50
  if (!targetEnv) {
50
- throw new Error(`添加失败,目标环境【${targetEnvId}】不存在`);
51
+ throw new AppError(`添加失败,目标环境【${targetEnvId}】不存在`);
51
52
  }
52
53
  }
53
54
  // 目标环境不能为空
54
55
  if (!targetEnvId) {
55
- throw new Error("添加失败,目标环境不能为空");
56
+ throw new AppError("添加失败,目标环境不能为空");
56
57
  }
57
58
  // 检查是否已存在相同路径前缀的规则(同一环境下)
58
59
  if (this.routeRuleRepo.existsByEnvIdAndPathPrefix(envId, pathPrefix)) {
59
- throw new Error(`添加失败,该环境下已存在路径前缀【${pathPrefix}】的规则`);
60
+ throw new AppError(`添加失败,该环境下已存在路径前缀【${pathPrefix}】的规则`);
60
61
  }
61
62
  // 生成唯一ID并组装完整路由规则信息
62
63
  const now = new Date().toISOString();
@@ -75,33 +76,32 @@ class RouteRuleService {
75
76
  * 1. 校验输入参数 2. 检查规则是否存在 3. 检查目标环境是否存在 4. 执行更新
76
77
  * @param routeRuleItem - 包含待更新路由规则ID及字段的对象
77
78
  * @returns 更新后的路由规则
78
- * @throws {Error} 当输入参数不合法或规则/目标环境不存在时抛出
79
+ * @throws {AppError} 当输入参数不合法或规则/目标环境不存在时抛出
79
80
  */
80
81
  handleUpdate(routeRuleItem) {
81
82
  const { id, targetEnvId } = routeRuleItem;
82
83
  // 检查路由规则是否存在
83
84
  const existingRule = this.routeRuleRepo.findOneById(id);
84
85
  if (!existingRule) {
85
- throw new Error(`更新失败,路由规则【${id}】不存在`);
86
+ throw new AppError(`更新失败,路由规则【${id}】不存在`);
86
87
  }
87
- // 判断是否需要清空目标环境
88
- const shouldClearTarget = targetEnvId === "" || targetEnvId === undefined;
89
- if (shouldClearTarget) {
88
+ // 判断是否需要清空目标环境(只有明确发送空字符串时才清空)
89
+ if (targetEnvId === "") {
90
90
  // 清空目标环境
91
91
  routeRuleItem.targetEnvId = "";
92
92
  }
93
- else if (targetEnvId !== existingRule.targetEnvId) {
93
+ else if (targetEnvId !== undefined && targetEnvId !== existingRule.targetEnvId) {
94
94
  // 更新了目标环境,检查目标环境是否存在
95
95
  const targetEnv = this.envRepo.findOneById(targetEnvId);
96
96
  if (!targetEnv) {
97
- throw new Error(`更新失败,目标环境【${targetEnvId}】不存在`);
97
+ throw new AppError(`更新失败,目标环境【${targetEnvId}】不存在`);
98
98
  }
99
99
  }
100
100
  // 如果更新了路径前缀,检查是否与其他规则冲突
101
101
  if (routeRuleItem.pathPrefix &&
102
102
  routeRuleItem.pathPrefix !== existingRule.pathPrefix) {
103
103
  if (this.routeRuleRepo.existsByEnvIdAndPathPrefix(existingRule.envId, routeRuleItem.pathPrefix)) {
104
- throw new Error(`更新失败,该环境下已存在路径前缀【${routeRuleItem.pathPrefix}】的规则`);
104
+ throw new AppError(`更新失败,该环境下已存在路径前缀【${routeRuleItem.pathPrefix}】的规则`);
105
105
  }
106
106
  }
107
107
  // 添加更新时间
@@ -115,14 +115,14 @@ class RouteRuleService {
115
115
  * 删除指定路由规则
116
116
  * 1. 校验输入参数 2. 检查规则是否存在 3. 执行删除操作
117
117
  * @param routeRuleItem - 包含待删除路由规则ID的对象
118
- * @throws {Error} 当输入参数不合法或规则不存在时抛出
118
+ * @throws {AppError} 当输入参数不合法或规则不存在时抛出
119
119
  */
120
120
  handleDelete(routeRuleItem) {
121
121
  const { id } = routeRuleItem;
122
122
  // 检查路由规则是否存在
123
123
  const existingRule = this.routeRuleRepo.findOneById(id);
124
124
  if (!existingRule) {
125
- throw new Error(`删除失败,路由规则【${id}】不存在`);
125
+ throw new AppError(`删除失败,路由规则【${id}】不存在`);
126
126
  }
127
127
  // 执行删除
128
128
  this.routeRuleRepo.delete(routeRuleItem);
@@ -0,0 +1,90 @@
1
+ import { SystemSettingRepo } from "../repositories/SystemSettingRepo.js";
2
+ /**
3
+ * 模块级内存缓存:系统设置开关的单一事实来源。
4
+ *
5
+ * - 注入资源开关默认关闭(false)
6
+ * - 请求日志记录开关默认暂停(false)
7
+ *
8
+ * 这些函数必须纯内存同步、不访问 getDatabase(),否则会破坏
9
+ * PreProxyServer 集成测试(该测试未初始化数据库)。
10
+ */
11
+ let injectEnabled = false;
12
+ let logEnabled = false;
13
+ /**
14
+ * 获取注入资源开关状态(纯内存、同步,供 PreProxyServer 直接使用)
15
+ * @returns 是否开启注入资源
16
+ */
17
+ export function getInjectEnabled() {
18
+ return injectEnabled;
19
+ }
20
+ /**
21
+ * 获取请求日志记录开关状态(纯内存、同步,供 RequestLogService 直接使用)
22
+ * @returns 是否开启请求日志记录
23
+ */
24
+ export function getLogEnabled() {
25
+ return logEnabled;
26
+ }
27
+ /**
28
+ * 系统设置服务
29
+ * 负责系统设置的读取与更新,通过 Repository 实现持久化
30
+ */
31
+ class SystemSettingService {
32
+ constructor(repo = new SystemSettingRepo()) {
33
+ this.repo = repo;
34
+ }
35
+ /**
36
+ * 获取注入资源开关状态
37
+ * @returns 是否开启注入资源
38
+ */
39
+ getInjectEnabled() {
40
+ return injectEnabled;
41
+ }
42
+ /**
43
+ * 获取请求日志记录开关状态
44
+ * @returns 是否开启请求日志记录
45
+ */
46
+ getLogEnabled() {
47
+ return logEnabled;
48
+ }
49
+ /**
50
+ * 更新注入资源开关状态
51
+ * @param value - 是否开启注入资源
52
+ */
53
+ setInjectEnabled(value) {
54
+ injectEnabled = value;
55
+ this.persist();
56
+ }
57
+ /**
58
+ * 更新请求日志记录开关状态
59
+ * @param value - 是否开启请求日志记录
60
+ */
61
+ setLogEnabled(value) {
62
+ logEnabled = value;
63
+ this.persist();
64
+ }
65
+ /**
66
+ * 初始化:从数据库读取持久化值同步到内存缓存。
67
+ * 数据库就绪后调用(在 index.ts 的 startDatabase 之后)。
68
+ * 空库时 seed 默认记录(注入关闭、日志暂停)。
69
+ */
70
+ init() {
71
+ const existing = this.repo.getGlobal();
72
+ if (existing) {
73
+ injectEnabled = existing.injectEnabled;
74
+ // 兼容旧数据:早期版本可能没有 logEnabled 字段
75
+ logEnabled = existing.logEnabled ?? false;
76
+ }
77
+ else {
78
+ injectEnabled = false;
79
+ logEnabled = false;
80
+ this.persist();
81
+ }
82
+ }
83
+ /**
84
+ * 将当前内存状态持久化到数据库(全量写入)
85
+ */
86
+ persist() {
87
+ this.repo.upsert({ id: "global", injectEnabled, logEnabled });
88
+ }
89
+ }
90
+ export { SystemSettingService };
@@ -3,3 +3,6 @@ export * from "./shared/DevServerItem.js";
3
3
  export * from "./shared/EnvmConfig.js";
4
4
  export * from "./shared/RouteRule.js";
5
5
  export * from "./shared/Password.js";
6
+ export * from "./shared/RequestLog.js";
7
+ export * from "./shared/ImportExport.js";
8
+ export * from "./shared/SystemSetting.js";
@@ -24,11 +24,24 @@ export const BaseDevServerSchema = z.object({
24
24
  */
25
25
  devServerUrl: z.string().describe("开发服务器地址"),
26
26
  });
27
+ /**
28
+ * 开发服务器排序Schema
29
+ * 用于保存排序顺序
30
+ */
31
+ export const DevServerSortSchema = z.object({
32
+ orders: z.array(z.object({
33
+ id: z.string(),
34
+ sortOrder: z.number(),
35
+ })),
36
+ });
27
37
  /**
28
38
  * 完整开发服务器模型Schema
29
39
  * 合并了主键和基础信息,用于创建完整的开发服务器模型
30
40
  */
31
- export const DevServerModelSchema = DevServerPrimarySchema.extend(BaseDevServerSchema.shape);
41
+ export const DevServerModelSchema = DevServerPrimarySchema.extend({
42
+ ...BaseDevServerSchema.shape,
43
+ sortOrder: z.number().optional().default(0),
44
+ });
32
45
  /**
33
46
  * 新增开发服务器Schema
34
47
  * 用于创建新开发服务器时的参数验证,不需要提供id(由系统生成)
@@ -27,6 +27,7 @@ export const EnvItemBaseSchema = z.object({
27
27
  .describe("环境绑定的开发服务器ID"),
28
28
  homePage: z.string().optional().describe("环境首页"),
29
29
  status: z.enum(["running", "stopped"]).optional(),
30
+ sortOrder: z.number().optional().describe("排序顺序"),
30
31
  });
31
32
  /**
32
33
  * 完整环境模型Schema
@@ -55,3 +56,21 @@ export const EnvUpdateSchema = EnvPrimarySchema.extend(EnvItemBaseSchema.partial
55
56
  * 用于查询环境信息时的参数验证,只需要提供环境id
56
57
  */
57
58
  export const EnvQuerySchema = EnvPrimarySchema;
59
+ /**
60
+ * 环境排序Schema
61
+ * 用于保存排序顺序
62
+ */
63
+ export const EnvSortSchema = z.object({
64
+ orders: z.array(z.object({
65
+ id: z.string(),
66
+ sortOrder: z.number(),
67
+ })),
68
+ });
69
+ /**
70
+ * 环境切换Schema
71
+ * 用于切换环境时的参数验证
72
+ */
73
+ export const EnvSwitchSchema = z.object({
74
+ currentEnvId: z.string().describe("当前环境ID"),
75
+ targetEnvId: z.string().describe("目标环境ID"),
76
+ });
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ // ---- 导出数据子 Schema ----
3
+ /** 导出的开发服务器(不含 id,通过 devServerUrl 做跨安装匹配) */
4
+ export const ExportDevServerSchema = z.object({
5
+ name: z.string(),
6
+ devServerUrl: z.string(),
7
+ description: z.string().optional(),
8
+ });
9
+ /** 导出的路由规则(targetEnvId 转为 targetEnvApiBaseUrl 做跨安装引用) */
10
+ export const ExportRouteRuleSchema = z.object({
11
+ pathPrefix: z.string().min(1),
12
+ targetEnvApiBaseUrl: z.string().optional(),
13
+ description: z.string().optional(),
14
+ enabled: z.boolean().optional().default(true),
15
+ });
16
+ /** 导出的密码 */
17
+ export const ExportPasswordSchema = z.object({
18
+ name: z.string().min(1),
19
+ username: z.string().min(1),
20
+ password: z.string().min(1),
21
+ description: z.string().optional(),
22
+ isDefault: z.boolean().optional().default(false),
23
+ });
24
+ /** 导出的环境(包含关联的 routeRules 和 passwords) */
25
+ export const ExportEnvSchema = z.object({
26
+ apiBaseUrl: z.string(),
27
+ port: z.number().int().min(1).max(65535),
28
+ name: z.string().optional(),
29
+ description: z.string().optional(),
30
+ devServerUrl: z.string().optional(),
31
+ homePage: z.string().optional(),
32
+ routeRules: z.array(ExportRouteRuleSchema).optional().default([]),
33
+ passwords: z.array(ExportPasswordSchema).optional().default([]),
34
+ });
35
+ // ---- 顶层导出文件 Schema ----
36
+ export const EXPORT_VERSION = "1.0.0";
37
+ export const ExportDataSchema = z.object({
38
+ version: z.literal(EXPORT_VERSION),
39
+ exportedAt: z.string(),
40
+ encrypted: z.boolean().optional().default(false),
41
+ devServers: z.array(ExportDevServerSchema).optional().default([]),
42
+ envs: z.array(ExportEnvSchema),
43
+ });
44
+ // ---- 导入/导出请求 Schema ----
45
+ export const ExportRequestSchema = z.object({
46
+ /** 要导出的环境 ID 列表;为空则导出全部 */
47
+ envIds: z.array(z.string()).optional(),
48
+ /** 加密密码;提供则对 passwords 中的 password 字段做 AES 加密 */
49
+ encryptPassword: z.string().optional(),
50
+ });
51
+ export const ImportRequestSchema = z.object({
52
+ data: ExportDataSchema,
53
+ conflictStrategy: z.enum(["skip", "overwrite"]).optional().default("skip"),
54
+ decryptPassword: z.string().optional(),
55
+ });
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ /** 资源类型(参考 Chrome DevTools Network 面板分类) */
3
+ export const ResourceTypeSchema = z.enum([
4
+ "fetch", // Fetch/XHR
5
+ "document", // 文档
6
+ "stylesheet", // CSS
7
+ "script", // JS
8
+ "font", // 字体
9
+ "image", // 图片
10
+ "media", // 媒体
11
+ "manifest", // 清单
12
+ "websocket", // 套接字
13
+ "wasm", // Wasm
14
+ "other", // 其他
15
+ ]);
16
+ /** 单条请求日志 */
17
+ export const RequestLogEntrySchema = z.object({
18
+ id: z.string().describe("唯一标识(uuid)"),
19
+ timestamp: z.number().describe("请求开始时间戳(ms)"),
20
+ method: z.string().describe("HTTP 方法(GET/POST/PUT/DELETE 等)"),
21
+ url: z.string().describe("请求 URL 路径"),
22
+ statusCode: z.number().describe("HTTP 响应状态码"),
23
+ duration: z.number().describe("请求耗时(ms)"),
24
+ matchedRule: z.string().describe("命中的路由规则 pathPrefix,或 'default'"),
25
+ resourceType: ResourceTypeSchema.describe("资源类型"),
26
+ envId: z.string().describe("所属环境 ID"),
27
+ envName: z.string().describe("环境名称"),
28
+ });
@@ -0,0 +1,18 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * 系统设置模型Schema
4
+ * 全局单例设置(id 固定为 "global")。
5
+ */
6
+ export const SystemSettingModelSchema = z.object({
7
+ id: z.literal("global").describe("全局设置唯一标识"),
8
+ injectEnabled: z.boolean().describe("是否开启注入资源功能"),
9
+ logEnabled: z.boolean().describe("是否开启请求日志记录"),
10
+ });
11
+ /**
12
+ * 更新系统设置Schema
13
+ * 用于更新系统设置时的参数验证(全量更新)
14
+ */
15
+ export const SystemSettingUpdateSchema = z.object({
16
+ injectEnabled: z.boolean().describe("是否开启注入资源功能"),
17
+ logEnabled: z.boolean().describe("是否开启请求日志记录"),
18
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 包装 async Express 路由处理器,使 rejected promise 自动转发到 next()。
3
+ * 这样 Express 的 globalErrorHandler 可以统一捕获异步错误,无需在每个 Controller 方法中手动 try/catch。
4
+ *
5
+ * @example
6
+ * router.post("/start", toDTO(EnvPrimarySchema), asyncHandler(controller.handleStartServer));
7
+ */
8
+ export const asyncHandler = (fn) => {
9
+ return (req, res, next) => {
10
+ Promise.resolve(fn(req, res, next)).catch(next);
11
+ };
12
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * 根据命中规则、响应 Content-Type 和请求 URL 判断资源类型。
3
+ *
4
+ * 分类参考 Chrome DevTools Network 面板:
5
+ * - 命中路由规则的请求视为 API 请求(Fetch/XHR)
6
+ * - 其余按 Content-Type 归类,URL 扩展名作为兜底
7
+ *
8
+ * @param matchedRule 命中的路由规则 pathPrefix,'default' 表示未命中
9
+ * @param contentType 响应头 Content-Type(可能为数组)
10
+ * @param url 请求 URL 路径
11
+ */
12
+ export function classifyResourceType(matchedRule, contentType, url) {
13
+ // 命中路由规则 → API 请求(Fetch/XHR)
14
+ if (matchedRule !== "default")
15
+ return "fetch";
16
+ const ct = (Array.isArray(contentType) ? contentType[0] : contentType || "").toLowerCase();
17
+ const path = url.toLowerCase();
18
+ if (ct.includes("wasm") || path.endsWith(".wasm"))
19
+ return "wasm";
20
+ if (ct.includes("manifest+json") ||
21
+ path.endsWith("manifest.json") ||
22
+ path.endsWith(".webmanifest"))
23
+ return "manifest";
24
+ if (ct.includes("font") || /\.(woff2?|ttf|otf|eot)$/.test(path))
25
+ return "font";
26
+ if (ct.startsWith("image/") ||
27
+ /\.(png|jpe?g|gif|svg|webp|ico|avif)$/.test(path))
28
+ return "image";
29
+ if (ct.startsWith("video/") || ct.startsWith("audio/"))
30
+ return "media";
31
+ if (ct.includes("text/css") || path.endsWith(".css"))
32
+ return "stylesheet";
33
+ if (ct.includes("javascript") ||
34
+ ct.includes("ecmascript") ||
35
+ /\.(m?js)$/.test(path))
36
+ return "script";
37
+ if (ct.includes("text/html") ||
38
+ path.endsWith(".html") ||
39
+ path.endsWith(".htm"))
40
+ return "document";
41
+ return "other";
42
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 将 RouteDefinition 数组批量注册到 Router 上。
3
+ * 返回 Router 本身以支持链式调用。
4
+ *
5
+ * @example
6
+ * const router = Router();
7
+ * registerRoutes(router, [
8
+ * { method: "get", path: "/list", handler: ctrl.getList },
9
+ * { method: "post", path: "/add", middleware: [toDTO(Schema)], handler: ctrl.add },
10
+ * ]);
11
+ * return router;
12
+ */
13
+ export function registerRoutes(router, definitions) {
14
+ for (const { method, path, handler, middleware } of definitions) {
15
+ const handlers = middleware ? [...middleware, handler] : [handler];
16
+ router[method](path, ...handlers);
17
+ }
18
+ return router;
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "env-plugin",
3
- "version": "0.5.9",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "description": "A dev env plugin that integrates an Express server with request proxying capabilities.",
6
6
  "keywords": [
@@ -20,7 +20,7 @@
20
20
  "import": "./dist/Plugin.js"
21
21
  }
22
22
  },
23
- "author": "lcn",
23
+ "author": "lumos934",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "commander": "^13.1.0",
@@ -28,7 +28,7 @@
28
28
  "dotenv": "^17.1.0",
29
29
  "express": "^4.21.2",
30
30
  "express-static-gzip": "^2.2.0",
31
- "http-proxy-middleware": "^3.0.3",
31
+ "http-proxy-middleware": "^3.0.5",
32
32
  "lokijs": "^1.5.12",
33
33
  "minimatch": "^10.2.4",
34
34
  "pino": "^9.9.0",
@@ -45,12 +45,17 @@
45
45
  "@types/express": "^4.17.23",
46
46
  "@types/lokijs": "^1.5.14",
47
47
  "@types/set-cookie-parser": "^2.4.10",
48
+ "@types/supertest": "^7.2.1",
48
49
  "@types/uuid": "^10.0.0",
49
50
  "@types/ws": "^8.18.0",
51
+ "@vitest/coverage-v8": "^4.1.10",
52
+ "@vitest/ui": "4.1.10",
50
53
  "globals": "^17.3.0",
51
54
  "nodemon": "^3.1.9",
55
+ "supertest": "^7.2.2",
52
56
  "tsx": "^4.20.3",
53
- "typescript": "^5.8.2"
57
+ "typescript": "^5.8.2",
58
+ "vitest": "^4.1.10"
54
59
  },
55
60
  "bugs": {
56
61
  "url": "https://github.com/lumos934/env-plugin/issues"
@@ -73,6 +78,14 @@
73
78
  "scripts": {
74
79
  "dev": "cross-env NODE_ENV=development tsx watch --tsconfig tsconfig.dev.json -- ./bin/index.ts",
75
80
  "build": "tsc -p tsconfig.build.json",
76
- "lint": "eslint ./src"
81
+ "lint": "eslint ./src",
82
+ "test": "vitest run",
83
+ "test:watch": "vitest",
84
+ "test:coverage": "vitest run --coverage",
85
+ "test:ui": "vitest --ui",
86
+ "test:ui:coverage": "vitest --ui --coverage",
87
+ "test:coverage:open": "vitest run --coverage && npx opener coverage/index.html",
88
+ "test:e2e": "vitest run test/e2e",
89
+ "test:e2e:watch": "vitest test/e2e"
77
90
  }
78
91
  }