Add config.json support for database path configuration (bd-163)
- Create internal/configfile package for config.json handling - bd init now creates .beads/config.json with database, version, and jsonl_export fields - Database discovery checks config.json first, falls back to beads.db - Update .gitignore to not ignore config.json (part of repo state) - Update test to expect beads.db and config.json - Backward compatible with existing beads.db-only setups
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/internal/configfile"
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
)
|
||||
|
||||
@@ -104,8 +105,9 @@ bd.sock
|
||||
db.sqlite
|
||||
bd.db
|
||||
|
||||
# Keep JSONL exports (source of truth for git)
|
||||
# Keep JSONL exports and config (source of truth for git)
|
||||
!*.jsonl
|
||||
!config.json
|
||||
`
|
||||
if err := os.WriteFile(gitignorePath, []byte(gitignoreContent), 0600); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to create .gitignore: %v\n", err)
|
||||
@@ -139,6 +141,15 @@ bd.db
|
||||
// Non-fatal - continue anyway
|
||||
}
|
||||
|
||||
// Create config.json for explicit configuration
|
||||
if useLocalBeads {
|
||||
cfg := configfile.DefaultConfig(Version)
|
||||
if err := cfg.Save(localBeadsDir); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Warning: failed to create config.json: %v\n", err)
|
||||
// Non-fatal - continue anyway
|
||||
}
|
||||
}
|
||||
|
||||
// Check if git has existing issues to import (fresh clone scenario)
|
||||
issueCount, jsonlPath := checkGitForIssues()
|
||||
if issueCount > 0 {
|
||||
|
||||
4
cmd/bd/testdata/init.txt
vendored
4
cmd/bd/testdata/init.txt
vendored
@@ -1,7 +1,8 @@
|
||||
# Test bd init command
|
||||
bd init --prefix test
|
||||
stdout 'initialized successfully'
|
||||
exists .beads/test.db
|
||||
exists .beads/beads.db
|
||||
exists .beads/config.json
|
||||
exists .beads/.gitignore
|
||||
grep '^\*\.db$' .beads/.gitignore
|
||||
grep '^\*\.db-journal$' .beads/.gitignore
|
||||
@@ -11,3 +12,4 @@ grep '^daemon\.log$' .beads/.gitignore
|
||||
grep '^daemon\.pid$' .beads/.gitignore
|
||||
grep '^bd\.sock$' .beads/.gitignore
|
||||
grep '^!\*\.jsonl$' .beads/.gitignore
|
||||
grep '^!config\.json$' .beads/.gitignore
|
||||
|
||||
Reference in New Issue
Block a user