fix: backup existing config files before overwriting#119
fix: backup existing config files before overwriting#119kieranklaassen merged 1 commit intoEveryInc:mainfrom
Conversation
|
@kieranklaassen this bit me. I figured it may be good to save others the same frustration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b67848fc27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/utils/files.ts
Outdated
| if (!(await pathExists(filePath))) return null | ||
|
|
||
| const timestamp = new Date().toISOString().replace(/[:.]/g, "-") | ||
| const backupPath = `${filePath}.bak.${timestamp}` | ||
| await fs.copyFile(filePath, backupPath) |
There was a problem hiding this comment.
Allow overwrite when backup copy lacks perms
The new backupFile always runs fs.copyFile when a config exists. copyFile needs read access to the source file and write access to the parent directory; if a config is writable but not readable (or the directory is not writable for new files), the backup throws and the install/convert aborts even though overwriting the config would have succeeded before. This introduces a regression for restrictive-permission setups (e.g., write-only config files or read-only directories), where the CLI now fails before writing the new config.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
If the directory isn't writable, the script already fails when writing prompts/skills before reaching the config backup. The only edge case this blocks is write-only config files, which is feels exceedingly rare. Made it best-effort anyway, backup failures are now silently ignored.
Before writing config.toml (Codex) or opencode.json (OpenCode), the CLI attempts to create a timestamped backup of any existing config file. This prevents accidental data loss when users have customized configs. Backup is best-effort - if it fails (e.g., unusual permissions), the install continues without blocking. Backup files are named: config.toml.bak.2026-01-23T21-16-40-065Z
b67848f to
c151ec8
Compare
|
OHH TYTY! |
kieranklaassen
left a comment
There was a problem hiding this comment.
Nice safety improvement, TY!
- Add `sync` command to sync ~/.claude/ personal config to OpenCode/Codex (EveryInc#123) - Backup existing config files before overwriting (EveryInc#119) - Remove worktree creation confirmation prompt (EveryInc#144) - Fix .git file detection in worktrees (use -e instead of -d) (EveryInc#159) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Before writing config.toml (Codex) or opencode.json (OpenCode), the CLI attempts to create a timestamped backup of any existing config file. This prevents accidental data loss when users have customized configs. Backup is best-effort - if it fails (e.g., unusual permissions), the install continues without blocking. Backup files are named: config.toml.bak.2026-01-23T21-16-40-065Z
Summary
backupFile()utility that creates timestamped backups before overwritingconfig.tomlbefore writing (Codex target)opencode.jsonbefore writing (OpenCode target)config.toml.bak.2026-01-23T21-16-40-065ZContext
When running
bunx @every-env/compound-plugin install compound-engineering --to codex, the CLI overwrites~/.codex/config.tomlwithout warning, which can destroy user customizations.Test plan
🤖 Generated with Claude Code