redwoodjs / redwood

The App Framework for Startups
https://redwoodjs.com
MIT License
17.13k stars 979 forks source link

[RFC]: Add Stories, Tests, and Metatags to the Scaffold Generators #6518

Open craineum opened 1 year ago

craineum commented 1 year ago

Summary

After a discussion on the forums, I would like to propose adding stories and tests to the scaffold generators.

Secondarily the scaffolds do not have the Metatags generated for page title.

Motivation

The biggest motivation is to establish good patterns for things that the Redwood generators are providing. While the individual generators create stories and tests, the scaffolds do not. This creates an inconsistency and mixed messaging to users of Redwood, especially early career developers.

Stories and tests are a great way to document the code for future developers to review. Leaving them off I think sends an unintended message.

The Metatags not being included on the scaffolding, I think speaks to a larger issue where the scaffold generators can easily be forgotten when making updates to the other generators.

Detailed proposal

As part of the CLI scaffold generator, they should be updated with stories, tests, and metatags.

Possible implementations

  1. Change the generators in a way that allows the scaffold generator to reuse the other generators.
    • With this implementation scaffolds would always be in sync with stories, tests, metatags, all the things.
    • All the individual generators could be passed things that would be specific to the scaffolding, while keeping the shells the same.
    • This would be a much more invasive change, but I think a more complete answer.
  2. The easier way to handle this would be to add the story and test template files to the scaffold.
    • This could get it done quickly, while still providing the same result in the short term.
    • The downside would be the drift that could happen over time as one generator is changed (you either have to remember to change the scaffold as well or they get out of sync)

Why hasn't this happened already?

There is concern about overwhelming someone by generating a ton of files. Adding stories and tests will basically triple that amount.

  1. Is this a concern?
  2. If it is how could we mitigate it?

Another point of view is that scaffolding is just that, something that is put up quickly which allows us to build something that actually makes sense, and then destroy the scaffolding once the new thing is in place.

  1. Does this ring true for you?
  2. Do you find yourself using scaffolding, or do you build everything yourself from scratch, or maybe use the individual generators?

Are you interested in working on this?

orta commented 1 year ago

One option is to have all of the scaffolds support all these features, but require opting-in by removing:

[generate]
  tests = false
  stories = false

From the redwood.toml which could be default. Personally, I don't use either.

Outside of that I only use all my versions of the templates, and while it can be hard to figure out the occasional breaking change but its been worth it.

dthyresson commented 1 year ago

Other ideas for scaffold improvement:

craineum commented 1 year ago

@dthyresson I mean, if we are putting together a scaffolding wish list... oh yeah

but back on task now...

@orta I like the idea of adding configuration. But to me opting out would be better, that way people know it is there, otherwise it can get overlooked easily. I would rather see people have to choose not to include stories/tests, especially for early career developers.

I am curious if you are generating stories/tests with your custom templates. And what else your custom templates are doing that the default ones are not.

orta commented 1 year ago

I've added my generators to the relay example app: https://github.com/orta/relay-redwood-app-example - I don't use much redwood infra on the web site, and instead use the artsy omakase stack in redwood but a lot of it is about conforming to the additional graphql specs around object identification and pagination

Aye, the default redwood settings today does include stories and tests, that setting I included is what I use to disable it FWIW

techshell commented 1 year ago

What I love about Redwood is enforcing the right pattern of product development - one of which is design led development with storybook. As a new dev - or when building a product - it's very helpful to to able experiment quickly and try things out and scaffold is big time saver for that. However, right now it's a real pain to have to manually go figure out how to get storybook working for the scaffold generated layouts, pages, components and cells OR generate these one by one again using the cli - just to get the storybooks and tests.

I'd argue for a new dev, it's actually more helpful to maintain the expected behaviour that redwood will always add storybooks and tests for you by default ... and have it be clear in the excellent redwood docs :)

My 2c