feat(env): isolate dev/release symlinks with getEnvAwareName#1364
feat(env): isolate dev/release symlinks with getEnvAwareName#1364
Conversation
Introduce getEnvAwareName() in src/common/appEnv.ts to centralise the dev/release suffix logic. Dev builds now use ~/.aionui-dev and ~/.aionui-config-dev instead of sharing ~/.aionui and ~/.aionui-config with release builds. Previously, alternating between dev and release would cause ensureCliSafeSymlink to detect a target mismatch, delete the existing symlink and recreate it, so the two environments would clobber each other's symlinks. Each environment now owns its own symlink name. Files changed: - src/common/appEnv.ts: new helper getEnvAwareName(baseName) - src/process/utils.ts: getDataPath / getConfigPath use getEnvAwareName - src/extensions/constants.ts: getUserExtensionsDir uses getEnvAwareName - src/extensions/statePersistence.ts: resolveStatesFile uses getEnvAwareName - tests/unit/extensions/extensionLoader.test.ts: add electron mock and update expected paths to .aionui-dev
Code Review:feat(env): isolate dev/release symlinks with getEnvAwareName (#1364)变更概述本 PR 新增 方案评估结论:✅ 方案合理 将环境判断逻辑抽象为单一函数并统一应用于所有路径构造点,是正确的 DRY 做法,与项目现有架构(main process + extensions 都使用 Electron 问题清单🟡 MEDIUM —
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🟡 MEDIUM | src/common/appEnv.ts |
缺少单元测试,release 分支未覆盖 |
| 2 | 🔵 LOW | vitest.config.ts:52 |
appEnv.ts 未加入 coverage.include |
| 3 | 🔵 LOW | src/extensions/statePersistence.ts:28 |
JSDoc 注释路径描述未更新 |
结论
getEnvAwareName 抽象干净。建议补充 appEnv.ts 的单元测试(特别是 release 分支)并更新 coverage.include,处理后可合并。
本报告由本地 /pr-review 命令生成,包含完整项目上下文,无截断限制。
On Windows, resolveForComparison skipped fs.realpathSync entirely, so symlinks pointing outside allowed directories were not caught by isPathAllowed. Move the realpathSync call to operate on the raw input path before pathApi.resolve(), making symlink safety checks consistent across all platforms. Also add unit tests for common/appEnv and include appEnv.ts in coverage tracking, plus update the statePersistence JSDoc to reflect both release and dev storage paths.
Summary
src/common/appEnv.tswithgetEnvAwareName(baseName)to centralise dev/release suffix logic — dev builds append-dev, release builds are unchanged~/.aionui-dev/~/.aionui-config-devinstead of sharing~/.aionui/~/.aionui-configwith release builds, preventing the two environments from clobbering each other's symlinks when alternating startupgetEnvAwareNameconsistently across all three call sites:getDataPath,getConfigPath,getUserExtensionsDir, andresolveStatesFileTest plan
bun run test— all 589 tests passbunx tsc --noEmit— no type errorsbun run lint— no lint errors~/.aionui-devsymlink points to.../AionUi-Dev/aionui~/.aionui-config-devsymlink points to.../AionUi-Dev/config~/.aionuiand~/.aionui-configare not created or modified by dev build~/.aionuiand~/.aionui-configare unaffected by previous dev run