Skip to content

fix: Windows path compat, move types to devDeps, parameterize SQL#26

Merged
cunoe merged 1 commit intomainfrom
fix/issue-15-16-17-misc-fixes
Mar 31, 2026
Merged

fix: Windows path compat, move types to devDeps, parameterize SQL#26
cunoe merged 1 commit intomainfrom
fix/issue-15-16-17-misc-fixes

Conversation

@cunoe
Copy link
Copy Markdown
Contributor

@cunoe cunoe commented Mar 31, 2026

Closes #15, closes #16, closes #17

Summary

Copy link
Copy Markdown

@leaperone-bot leaperone-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Code Review 🟢

总体评价

这是一个高质量的小修复 PR,三个改动都是正确且有意义的。

✅ Windows 路径兼容 (config-manager.ts)

this.configPath.substring(0, this.configPath.lastIndexOf('/')) 替换为 dirname(this.configPath) 是正确的做法。lastIndexOf('/') 在 Windows 上无法处理 \ 分隔符,而 dirname() 是跨平台的标准方案。

✅ 类型包移至 devDependencies (package.json)

@types/better-sqlite3 是纯类型定义包,仅在编译时使用,移至 devDependencies 是正确的分类。

✅ SQL 参数化查询 (db.ts)

将模板字符串拼接 VALUES (${DatabaseManager.SCHEMA_VERSION}) 改为参数化查询 VALUES (?) + .run(...) 是更安全的写法。虽然此处 SCHEMA_VERSION 是内部常量(非用户输入),不存在实际的 SQL 注入风险,但保持一致的参数化风格是好的编码习惯,也与文件中其他查询的风格保持一致。

📝 小建议(非阻塞)

  • 注意到 main 分支上的 db.ts 仍然是旧代码(使用模板字符串),说明此 PR 确实解决了问题。建议后续考虑为 ConfigManager.save()DatabaseManager 的初始化逻辑增加单元测试,覆盖 Windows 路径场景和 schema 版本升级场景。
  • pnpm-lock.yaml 未在 diff 中出现。如果移动依赖后未重新生成 lockfile,可能导致 CI 安装不一致。建议确认 lockfile 是否已同步更新。

@cunoe cunoe merged commit a0adb06 into main Mar 31, 2026
1 of 2 checks passed
@cunoe cunoe deleted the fix/issue-15-16-17-misc-fixes branch March 31, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL 使用模板字符串拼接 @types/better-sqlite3 应移至 devDependencies Windows 路径兼容问题

2 participants