Giter Site home page Giter Site logo

Comments (11)

cannikin avatar cannikin commented on July 30, 2024 2

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.

cannikin avatar cannikin commented on July 30, 2024 1

@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.

cannikin avatar cannikin commented on July 30, 2024 1

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.

chris-hailstorm avatar chris-hailstorm commented on July 30, 2024

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.

ybakos avatar ybakos commented on July 30, 2024

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.

thedavidprice avatar thedavidprice commented on July 30, 2024

@cannikin Ok to close this one out?

from redwood.

thedavidprice avatar thedavidprice commented on July 30, 2024

@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.

jtoar avatar jtoar commented on July 30, 2024

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.

Josh-Walker-GM avatar Josh-Walker-GM commented on July 30, 2024

@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:

const tasks = new Listr(
[
{
title: `Generating ${componentName} files...`,
task: async () => {
const f = await filesFn(options)
return writeFilesTask(f, { overwriteExisting: options.force })
},
},
...includeAdditionalTasks(options),
],
{
rendererOptions: { collapse: false },
exitOnError: true,
renderer: options.verbose && 'verbose',
}
)
Perhaps it might not be a lot of work to implement this feature, assuming the destroy commands can revert.

from redwood.

cannikin avatar cannikin commented on July 30, 2024

from redwood.

Josh-Walker-GM avatar Josh-Walker-GM commented on July 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.