Skip to content

fix(devbox): auto-detect install flag from root package.json#4

Merged
ilterugur merged 1 commit into
mainfrom
feat/devbox-add-detect-package-json
Jun 20, 2026
Merged

fix(devbox): auto-detect install flag from root package.json#4
ilterugur merged 1 commit into
mainfrom
feat/devbox-add-detect-package-json

Conversation

@ilterugur

Copy link
Copy Markdown
Owner

Problem

devbox add always emitted install: true for a new project entry. When the target repo has no root package.json (an Ansible/shell toolkit — claude-devbox itself, for example), the projects role's bun install step then fails with:

error: Bun could not find a package.json file to install from

…which breaks the playbook run until the entry is hand-edited to install: false.

Fix

  • detectProject already resolves the repo root (git rev-parse --show-toplevel); it now also sets install from existsSync(<root>/package.json).
  • projectEntry emits the matching line + comment:
    • install: true # run \bun install` after clone`
    • install: false # no package.json at repo root — nothing to install
  • Preview (DEVBOX_DRYRUN) and --write both flow through projectEntry, so the dry-run output reflects the detected value with no extra change.

No new override flag — none existed, and auto-detection covers the case.

Tests (TDD, RED→GREEN)

  • projectEntry: split into explicit install: true / install: false cases.
  • detectProject: two integration tests against throwaway git repos (with/without package.json).
  • bun test80/80 pass; bun run typecheck → clean.

Verify

DEVBOX_DRYRUN=1 devbox add   # from a repo with no root package.json
# → install: false # no package.json at repo root — nothing to install

Docs

docs/multi-project.md updated in the devbox add and Projects sections.

🤖 Generated with Claude Code

`devbox add` always emitted `install: true`, so adding a non-Node repo (an
Ansible/shell toolkit like claude-devbox itself) made the projects role's
`bun install` fail with "could not find a package.json file", breaking the
playbook run until the entry was hand-edited.

detectProject now auto-detects `install` from a root package.json and
projectEntry emits the matching line + comment. Preview and --write both flow
through projectEntry, so the dry-run output reflects it. Adds projectEntry
true/false tests and detectProject integration tests (throwaway git repos
with/without package.json); documents the behavior in docs/multi-project.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 20, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes devbox add so new project entries don’t default to install: true when the target repo isn’t a Bun project. It auto-detects whether to run bun install by checking for a root package.json, preventing playbook failures for repos like Ansible/shell toolkits.

Changes:

  • Extend detectProject to set install based on <repo-root>/package.json existence.
  • Update projectEntry to emit install: true/false with an explanatory inline comment.
  • Add/adjust tests for projectEntry and integration-style tests for detectProject, and update multi-project documentation accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
docs/multi-project.md Documents that install: is auto-detected from a root package.json and explains the install: false behavior.
clients/devbox/src/add.ts Adds install detection and makes YAML emission reflect the detected value with clearer comments.
clients/devbox/src/add.test.ts Adds test coverage for install rendering and repo-root auto-detection behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ilterugur ilterugur merged commit d81ab94 into main Jun 20, 2026
1 check passed
@ilterugur ilterugur deleted the feat/devbox-add-detect-package-json branch June 20, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants