1
0
Files
DiAL/scripts/clean.ts
lanyuanxiaoyao ccd16a583e feat: 跨平台发布打包,支持 7 个目标平台交叉编译和 tar.gz 分发
- 新增 scripts/release.ts,支持 7 个编译目标(linux/darwin/windows + musl 变体)
- 从 build.ts 提取共享构建逻辑到 build-common.ts,现有 build 行为不变
- 使用 tar-stream + node:zlib 创建 tar.gz,精确控制 Unix 权限位
- SHA256 校验和文件格式兼容 sha256sum -c
- 支持 --target 参数选择特定平台编译
- 新增 devDependency: tar-stream、@types/tar-stream
- 更新 README.md 和 DEVELOPMENT.md 文档
- 同步 openspec specs
2026-05-20 23:24:36 +08:00

31 lines
1.1 KiB
TypeScript

import { rm } from "node:fs/promises";
import { resolve } from "node:path";
const root = resolve(import.meta.dir, "..");
const dirs: Array<{ desc: string; path: string }> = [
{ desc: "构建产物", path: "dist" },
{ desc: "Bun 构建缓存", path: ".build" },
{ desc: "Playwright 测试报告", path: "playwright-report" },
{ desc: "测试结果", path: "test-results" },
{ desc: "发布产物", path: "dist/release" },
];
const filePatterns: Array<{ desc: string; glob: string }> = [{ desc: "Bun 构建临时文件", glob: ".*.bun-build" }];
for (const { desc, path } of dirs) {
const full = resolve(root, path);
await rm(full, { force: true, recursive: true });
console.log(`已清理 ${desc}: ${path}`);
}
for (const { desc, glob } of filePatterns) {
const entries = await Array.fromAsync(new Bun.Glob(glob).scan({ cwd: root, dot: true }));
if (entries.length === 0) continue;
for (const entry of entries) {
const full = resolve(root, entry);
await rm(full, { force: true, recursive: true });
console.log(`已清理 ${desc}: ${entry}`);
}
}