Skip to content

feat(config): recognize devbox.jsonc as a config filename (#2602) - #2950

Open
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-4lsa9z
Open

feat(config): recognize devbox.jsonc as a config filename (#2602)#2950
mikeland73 wants to merge 1 commit into
mainfrom
claude/focused-goldberg-4lsa9z

Conversation

@mikeland73

Copy link
Copy Markdown
Contributor

Summary

Fixes #2602 (cc @gjoseph92).

devbox.json is parsed as JSONC and supports comments, but editors and GitHub diffs treat comments in a .json file as syntax errors and highlight them in red. This PR lets users name their config devbox.jsonc so standard tooling highlights it correctly — with no per-repo files.associations or .gitattributes workarounds.

Changes (all in internal/devconfig):

  • Add configfile.AltName ("devbox.jsonc") and configfile.ValidNames, and search both names during directory discovery. devbox.json is listed first, so it still wins when a directory happens to contain both files — existing projects are unaffected.
  • Make SaveTo preserve the config's original filename via a new FileName() helper, so devbox add (and anything else that rewrites the config) writes back to devbox.jsonc instead of silently creating a stray devbox.json. Configs with no on-disk path (e.g. pulled from a URL) still default to devbox.json.

Discovery is centralized in searchDir, which already looped over a list of candidate filenames, so the change is small and localized.

How was it tested?

go build ./... and go vet ./internal/devconfig/... pass. Added unit tests:

  • TestJSONCConfig (internal/devconfig/config_test.go): Open and Find discover devbox.jsonc; devbox.json wins when both exist; saving writes back to devbox.jsonc without creating a devbox.json.
  • TestFileName / TestSaveToPreservesFileName (internal/devconfig/configfile/file_test.go): FileName() maps each path to the right basename and falls back to devbox.json; SaveTo writes the expected filename.

All new and pre-existing internal/devconfig tests pass, except two TestFindError permission cases that also fail on unmodified main when the suite runs as root (root bypasses 0o000); they are unrelated to this change.

Community Contribution License

All community contributions in this pull request are licensed to the project
maintainers under the terms of the
Apache 2 License.

By creating this pull request, I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 License as stated in
the
Community Contribution License.


🤖 Generated with Claude Code

https://claude.ai/code/session_01554vf5pDDVmFCcAadatBea


Generated by Claude Code

devbox.json is parsed as JSONC and supports comments, but editors and
GitHub diffs flag comments in a .json file as syntax errors. Allow users
to name their config devbox.jsonc so standard tooling highlights it
correctly, without any per-repo configuration.

- Add configfile.AltName ("devbox.jsonc") and configfile.ValidNames, and
  search both names during directory discovery (devbox.json wins when
  both are present, preserving existing behavior).
- Make SaveTo preserve the config's original filename via a new
  FileName() helper so `devbox add` and friends write back to
  devbox.jsonc instead of creating a stray devbox.json. Configs without
  an on-disk path (e.g. pulled from a URL) still default to devbox.json.

Closes #2602
Copilot AI lite review requested due to automatic review settings August 16, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support devbox.jsonc for better editor & diff highlighting

3 participants