fix(build): distinguish wrong cwd from missing build strategy#382
Merged
Conversation
detectBuildConfig threw the same 'No build strategy detected' message whether the cwd had no package.json at all or had one with no recognised build. The first case (user one dir above their project, e.g. after `dot mod`) is the common failure and the message sent them to the wrong fix. Split it: when package.json is absent, name the directory and point the user at it (cd in, or --dir <path>); keep the original message for a present-but-unrecognised package.json. Thread an optional projectDir through DetectInput (populated by loadDetectInput) so the error can name the directory while detect.ts stays pure.
Contributor
E2E Test Pass · ❌ FAILTag:
Sentry traces: view spans for this run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
dot build/dot deploythrew the same error —No build strategy detected. Add a "build" script to package.json, or install vite/next/typescript.— in two unrelated situations:package.jsonat all (user is one directory above their project, e.g. randot modthendot buildfrom the parent).package.jsonbut no recognised build strategy.Case 1 is the common real-world failure (it generated false "app is missing a build script" bug reports), and the message pointed at the wrong fix — editing a
package.jsonthat isn't there.Change
detectBuildConfignow splits the two cases:package.json:No package.json found in <dir>. Are you in your project directory? cd into it first, or point the command at it with --dir <path>.package.jsonpresent but unrecognised: unchanged.To name the directory while keeping
src/utils/build/detect.tspure (no I/O), an optionalprojectDiris threaded throughDetectInputand populated byloadDetectInput— so bothdot buildanddot deployget the named-directory message for free. The message references the existing--dir <path>flag (the positional-arg suggestion from the issue, #3, is intentionally out of scope here).Scope
This addresses suggestion #1 of #191. Suggestions #2 (
dot modnext-step footer) and the audit's--questhint are already shipped onmain; #3 (positional arg) is deliberately not included.Tests
package.json, directory name interpolated into the message, clean fallback when noprojectDiris known (no leakedundefined/ double space), and a regression lock that the present-but-unrecognised case keeps the original message.pnpm format:check,pnpm lint:license,pnpm typecheck,pnpm test(945 passing) all green.Refs #191