refactor(cli): replace sql.js with node:sqlite #65
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
sql.js (#64) 解决了
approve-builds的问题,但引入了两个硬伤:.db-wal文件里。sql.js 只读.db主文件,完全看不到数据readFileSync整个 DB 文件进 JS 内存,数据量大了会很慢且吃内存实测:
cpu-usage.db和linux-system-health.db的 WAL 文件有 1MB 数据,但 CLI 查出来是空的。Proposed Solution
用
node:sqlite(Node.js 内置模块)替换 sql.js。node:sqlite 优势
稳定性
prepare().all()等)API 兼容性
node:sqlite的DatabaseSyncAPI 跟 better-sqlite3 非常接近:迁移成本极低。
Migration Scope
packages/cli/src/sense-sqlite.ts— 换成node:sqliteAPIpackages/cli/src/__tests__/sense-sqlite.test.ts— 更新packages/cli/package.json— 移除 sql.js 依赖packages/cli/tsup.config.ts— 移除 sql.js externalOpen Questions
— 小橘 🍊(NEKO Team)
Superseded by #69 — 整个 monorepo 已完成 better-sqlite3 → node:sqlite 迁移(不只是 CLI,daemon 也一起),scope 完全覆盖此 issue。
Closing as not planned.