-
Notifications
You must be signed in to change notification settings - Fork 86
Add --local-dev flag to delete config and database in current directory
#70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughAdds a Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@cmd/bbctl/delete.go`:
- Around line 57-65: The current --local-dev flow uses os.Getwd() (localDev) and
then deletes files matched by isLocalBridgeFile, which can remove unrelated
config/SQLite files if run from the wrong directory; update the delete command
(around localDev, os.Getwd(), and the isLocalBridgeFile usage) to add a safety
guard: verify the target directory is a bbctl bridge directory (e.g., check for
a specific marker/config file or expected bridge files), and if verification
fails require an explicit confirmation flag or interactive confirmation that
prints the absolute paths and file list to be deleted before proceeding; ensure
the code path that sets bridgeDir and the subsequent deletion logic exits unless
the verification/confirmation succeeds.
🧹 Nitpick comments (1)
cmd/bbctl/delete.go (1)
129-129: Usefilepath.Joinfor filesystem paths.Line 129 uses
path.Joinwhich is intended for forward-slash-separated paths like URLs. Sinceos.Remove()is a filesystem operation, usefilepath.Joininstead to properly handle OS-specific path separators and Windows semantics.♻️ Proposed fix
-import "path" +// path import removed; using filepath.Join for filesystem paths ... - err := os.Remove(path.Join(bridgeDir, item.Name())) + err := os.Remove(filepath.Join(bridgeDir, item.Name()))
| localDev := ctx.Bool("local-dev") | ||
| if localDev { | ||
| bridgeDir, err = os.Getwd() | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get working directory: %w", err) | ||
| } | ||
| } else { | ||
| bridgeDir = filepath.Join(dataDir, bridge) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Local-dev deletion can wipe unrelated data in the current directory.
--local-dev targets os.Getwd() and isLocalBridgeFile matches any config.yaml or *.db*. If the command is run from the wrong directory, unrelated config/SQLite files can be removed. Consider adding a stronger guard (e.g., validate the directory is a bbctl bridge dir or include the absolute path + file list in an explicit confirmation before deletion).
💡 Possible safety guard (example)
- err = survey.AskOne(&survey.Confirm{Message: fmt.Sprintf("Are you sure you want to permanently delete %s?", bridge)}, &confirmation)
+ confirmMsg := fmt.Sprintf("Are you sure you want to permanently delete %s?", bridge)
+ if localDev {
+ confirmMsg = fmt.Sprintf(
+ "Are you sure you want to permanently delete %s and remove local data in %s?",
+ bridge, bridgeDir,
+ )
+ }
+ err = survey.AskOne(&survey.Confirm{Message: confirmMsg}, &confirmation)Also applies to: 103-133
🤖 Prompt for AI Agents
In `@cmd/bbctl/delete.go` around lines 57 - 65, The current --local-dev flow uses
os.Getwd() (localDev) and then deletes files matched by isLocalBridgeFile, which
can remove unrelated config/SQLite files if run from the wrong directory; update
the delete command (around localDev, os.Getwd(), and the isLocalBridgeFile
usage) to add a safety guard: verify the target directory is a bbctl bridge
directory (e.g., check for a specific marker/config file or expected bridge
files), and if verification fails require an explicit confirmation flag or
interactive confirmation that prints the absolute paths and file list to be
deleted before proceeding; ensure the code path that sets bridgeDir and the
subsequent deletion logic exits unless the verification/confirmation succeeds.
--local-dev flag to delete config and database in current directory
No description provided.