fix(cli): dry run prints one honest list, and the real run admits routes - #3617
Merged
Merged
Conversation
`wheels generate scaffold Post ... --dry-run` printed three contradicting
things at once:
Dry run — nothing will be written.
Scaffolding Post...
create model: Post.cfc <- reads as "written"
... ten create lines ...
Scaffold complete! Next steps:
1. Run migrations: wheels migrate latest <- migrate what?
Would create:
/private/tmp/dr/app/app/models/Post.cfc <- absolute, root repeated
Nothing was written (that part was correct), but the output said otherwise
and the trailing advice was nonsense for a dry run.
printCreated() is the single choke point for all 30 generator call sites,
so gating it on $isDryRun() fixes every generator at once — model,
controller, migration and scaffold alike. The scaffold's `modify` lines
and the "Next steps" block are gated the same way.
The list is now headed "Would write:", not "Would create:", because it
legitimately contains paths that would be MODIFIED — a --belongsTo
scaffold rewrites the parent model, controller and show view. Calling
those "created" was wrong. Paths print relative to the project so the
root isn't repeated on every line.
Separately, the dry run exposed an inversion: it listed config/routes.cfm
while the REAL run rewrote that file without a word. updateRoutes() has
always returned whether it changed the file; the caller discarded it.
Scaffold now records it in results.routes — deliberately NOT in
results.modified, because config/routes.cfm is a shared project file
rather than a per-model artifact and the 17 parent-wiring specs assert
the exact contents of `modified` — and Module.cfc reports it as
`modify routes: config/routes.cfm`.
Verified on a throwaway app: dry run lists 11 project-relative paths and
writes nothing; the real run lists the same 10 creates plus the routes
modification; the two outputs correspond. A --belongsTo dry run lists the
parent files in the would-write list and leaves them byte-unchanged.
CLI suite: 1375 pass, 0 error. The 4 remaining DbCommandSpec failures are
environmental — they expect Wheels.ServerNotRunning and a live app was on
8080. On a clean port they pass.
Signed-off-by: Peter Amiri <peter@alurium.com>
Beat 2's dry-run step promised "eleven Would create lines". The heading is now Would write (the list includes files that would be modified), and the card calls out config/routes.cfm appearing in it — which the real run now reports as a modification rather than editing silently. Signed-off-by: Peter Amiri <peter@alurium.com>
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.
wheels generate scaffold Post … --dry-runprinted three contradicting things at once:Nothing was written (that part was correct), but the output said otherwise and the trailing advice was nonsense for a dry run.
Fix
printCreated()is the single choke point for all 30 generator call sites, so gating it on$isDryRun()fixes every generator at once — model, controller, migration and scaffold alike. The scaffold'smodifylines and the "Next steps" block are gated the same way.The list is headed
Would write:, notWould create:, because it legitimately contains paths that would be modified — a--belongsToscaffold rewrites the parent model, controller and show view. Paths are now project-relative.The inversion the dry run exposed
The dry run listed
config/routes.cfmwhile the real run rewrote that file without a word.updateRoutes()has always returned whether it changed the file; the caller discarded the value.Scaffoldnow records it inresults.routes— deliberately notresults.modified, becauseconfig/routes.cfmis a shared project file rather than a per-model artifact, and the 17 parent-wiring specs assert the exact contents ofmodified.Module.cfcreports it asmodify routes: config/routes.cfm.Verified
modify routes: config/routes.cfm--belongsTodry runCLI suite: 1375 pass, 0 error. The 4 remaining
DbCommandSpecfailures are environmental — they expectWheels.ServerNotRunningand a live app was on 8080; on a clean port they pass.