Comments (11)
We do have a --force
option that will overwrite files if they exist!
I've actually got a fix for this specific problem (it will just skip scaffold.css
if it already exists) waiting in a PR.
Ideally we want a more interactive Do you want to overwrite? (y/n/a)
for each file but that's for the future!
from redwood.
@thedavidprice This was meant to be a feature/enhancement issue but turned into a bug report. haha I think this IS a feature we want at some point: right now if a generator fails for some reason you'll have half the files created and half not.
from redwood.
Hmmm, good question. I'm not sure what happens if some of the files don't exist when you run the destroy command, but it would be pretty ironic if then that blew up! But in theory it does know how to undo everything that the generate command did...
I can try to test this out at some point but it may be a few days until I get around to it!
from redwood.
ENVIRONMENT
$ yarn rw --version
0.0.1-alpha.31
OBSERVATION
Running the Posts generation example from the tutorial, only some files are generated:
$ yarn rw g scaffold post
❯ Generating scaffold files...
✔ Writing `./api/src/graphql/posts.sdl.js`...
✔ Writing `./api/src/services/posts/posts.js`...
✔ Writing `./api/src/services/posts/posts.mdx`...
✔ Writing `./api/src/services/posts/posts.test.js`...
✖ Writing `./web/src/scaffold.css`...
→ /Users/chris/proj/aw-redwood/aw/web/src/scaffold.css already exists.
Writing `./web/src/layouts/PostsLayout/PostsLayout.js`...
Writing `./web/src/pages/EditPostPage/EditPostPage.js`...
Writing `./web/src/pages/PostPage/PostPage.js`...
Writing `./web/src/pages/PostsPage/PostsPage.js`...
Writing `./web/src/pages/NewPostPage/NewPostPage.js`...
Writing `./web/src/components/EditPostCell/EditPostCell.js`...
Writing `./web/src/components/Post/Post.js`...
Writing `./web/src/components/PostCell/PostCell.js`...
Writing `./web/src/components/PostForm/PostForm.js`...
Writing `./web/src/components/Posts/Posts.js`...
Writing `./web/src/components/PostsCell/PostsCell.js`...
Writing `./web/src/components/NewPost/NewPost.js`...
Adding scaffold routes...
Adding scaffold asset imports...
✨ Done in 1.20s.
One file already existed from a prior run (=> me not cleaning everything up). The step with "X" (Writing ./web/src/scaffold.css
...) failed because the file already existed. The files that were generated before the "X" do exist on disk -- but aren't useful because they depend on files that come later. The files that follow the "X" do not exist on disk, although the CLI output does say "Writing ..." and no per-line error message.
SUGGESTION
Possibly an --overwrite
flag to allow clobber of previous generation runs.
Some form of all-or-nothing generation (with awareness of --overwrite
) would be best. Hard to diagnose and fix either a partial generation (1st gen) or partial overwrite (2nd/later gen).
from redwood.
Additional feedback FWIW.
Assuming yarn rw g scaffold foo
will be run many times, it will always fail after the first run, due to the existence of scaffold.css
, leaving the debris of an incomplete scaffold generation.
from redwood.
@cannikin Ok to close this one out?
from redwood.
@cannikin do you think the Destroy command covers this feature? It's not 1-to-1, but maybe this feature could leverage Destroy -- e.g. if error occurs it would prompt to run cleanup via Destroy.
from redwood.
An update on this: the presence of scaffold.css
doesn't cause the command to blow up anymore. To reproduce this, generate a scaffold and delete most of the files, leaving just one of the ones that's generated later.
from redwood.
@cannikin Do think there still interest in this? I do think it would be good to rollback on an error by default.
Take #6840 as a recent example of when it would have been much clearer to the user an error occurred if we'd have rolled back and we wouldn't have ended up in a broken state.
If the destroy commands know how to revert the changes of the associated generate command then it might be possible just to add a listr2 rollback task. This addition of the rollback would probably only need to occur when the helper function:
redwood/packages/cli/src/commands/generate/helpers.js
Lines 206 to 222 in 2bc3a54
from redwood.
from redwood.
Excellent that's what I was hoping to learn, if these destroy commands were working well and if they were the preferred direction forward. Since they don't seem to be loved I might have a think about how it could be done with as minimal a change to the current generators as possible and without relying on these destroy commands. Thanks!
from redwood.
Related Issues (20)
- [Bug]: Docs search is broken HOT 3
- [Bug?]: yarn rw upgrade for 7.7.1 error HOT 6
- [Bug]: Scenario files in a __tests__ directory throws error in Jest HOT 3
- [Bug?]: Docker compose errors with graphql fragments HOT 8
- [Bug?]: Dev server builds break after multiple consecutive filesystem saves HOT 5
- [RFC]: Remove default UserExample model in newly generated Redwood app
- [Background jobs] Generators
- [Bug?]: Trusted Documents does not work with Realtime. HOT 7
- [Feature]: ESLint flat config support for @redwoodjs/eslint-config HOT 2
- [Bug?]: corepack enable does nothing on fresh clone (yarn stays on v1.x) HOT 1
- [Feature]: ESLint flat config support for @redwoodjs/eslint-plugin HOT 1
- [Bug?]: Deploy to Vercel breaks all server functions (500 errors with cryptic messages) HOT 9
- [Bug?]: yarn rw setup server-file fails with js but works with ts HOT 5
- Multiple RW apps all use the same debug port
- Syntax check `package.json` for dual ESM+CJS support in `@redwoodjs/auth`
- [Bug?]: cannot set bodyLimit using server.ts HOT 2
- [Bug?]: Clarify impact on database file location with prisma multi file schema HOT 1
- [Bug]: Flaky dbAuth test in framework tests
- [RWUploads] Spike prisma extensions and if its possible to detect a specific model
- [RWUploads] Spike Prisma single table inheritance
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redwood.