1
0

chore: 清理项目冗余文件和构建中间产物

删除根目录 index.ts(与 start 脚本重复)、移除 package.json 中无效的 module 字段、构建成功后自动清理 .build/ 目录
This commit is contained in:
2026-05-09 15:21:42 +08:00
parent 8121be38cd
commit f723ecb1b5
4 changed files with 11 additions and 3 deletions

View File

@@ -1 +0,0 @@
import "./src/server/dev.ts";

View File

@@ -27,7 +27,7 @@
- **THEN** 生成的嵌入资源模块 SHALL 保持语义一致且不依赖文件系统遍历顺序
### Requirement: 单 executable 输出
生产构建 SHALL 输出一个 standalone executable其中包含 Bun 后端、必要 server 依赖和构建后的前端资源。
生产构建 SHALL 输出一个 standalone executable其中包含 Bun 后端、必要 server 依赖和构建后的前端资源。构建成功后 SHALL 自动清理中间产物目录(`.build/`),构建失败时 SHALL 保留中间产物以便排查。
#### Scenario: 在目标机器运行 executable
- **WHEN** 生成的 executable 在兼容目标平台上运行
@@ -41,6 +41,14 @@
- **WHEN** 生成的 executable 启动,且浏览器打开前端根路径
- **THEN** 页面 SHALL 展示同一个 executable 进程中 `/api/demo` 返回的数据
#### Scenario: 构建成功后清理中间产物
- **WHEN** 生产构建成功完成并输出 executable
- **THEN** 系统 SHALL 自动删除 `.build/` 目录及其所有内容
#### Scenario: 构建失败时保留中间产物
- **WHEN** 生产构建在任意步骤失败前端构建、中间产物生成、Bun 编译)
- **THEN** `.build/` 目录 SHALL 保留在磁盘上以供排查
### Requirement: 外部运行时配置
executable MUST 将环境相关运行时配置保留在嵌入的前端和 server bundle 之外。

View File

@@ -1,6 +1,5 @@
{
"name": "gateway-checker",
"module": "src/server/dev.ts",
"type": "module",
"private": true,
"scripts": {

View File

@@ -52,6 +52,8 @@ if (!result.success) {
console.log(`Built executable: ${executablePath}`);
await rm(buildDir, { recursive: true, force: true });
async function listFiles(directory: string): Promise<string[]> {
const entries = await readdir(directory, { withFileTypes: true });
const files = await Promise.all(