fix(cli): friendly error when package.json is missing#3935
Conversation
🦋 Changeset detectedLatest commit: 128db32 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR improves error messaging when ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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 |
Running
trigger dev(or any command that runs the package update check) in a directory without apackage.jsoncrashed with a rawCannot find matching package.jsonstack trace. This is becausegetPackageJsonthrows before the existingif (!packageJson)guard can run, so the guard was dead code.Now it exits cleanly with an actionable message instead — telling the user to run from their project root, or to
npm init -yandtrigger.dev initif they haven't set up a project yet. The fix catches the throw at the call site inupdateTriggerPackages;getPackageJsonitself is unchanged (changing its return type rippled type errors into other callers).Tested e2e via
trigger update(same code path): nopackage.json→ clean message + exit 1,package.jsonpresent → update check runs as before, version mismatch → still aborts as before.