-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cli): Allow common custom scaffold template files #11755
base: main
Are you sure you want to change the base?
Conversation
I like this addition. I just want to spend some time thinking about what unit tests, if any, can be added |
thanks @Tobbe I gave it some though, but couldn't come up with any, so I thought better to ask the team. Also, this is "user land", and a somewhat "advanced" scenario, so they've already strayed out of the path, and have accepted that they're pretty much on their own, since they ejected the generators. It's me, I'm "they" 😅 |
@esteban-url I added some tests. Please take a look and edit/add as you see fit. Another thing I realized is that now when you run |
…and update file count in tests
@Tobbe I've added the templates for tests, stories and mocks, I probably went a little (a lot?) beyond what you wanted tho. It now generates initial tests/mocks/stories when you run the scaffold generator itself. do let me know what you think. I feel like it's a great addition 😁, but I'll leave the default option as it, so if you want to get those files generated you need to pass in |
@@ -436,6 +437,7 @@ const modelRelatedVariables = (model) => { | |||
editableColumns, | |||
listFormattersImports, | |||
formattersImports, | |||
relations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adds the convenience of having the relations info available in the template, so the user can access it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include this in the templates we ship with? Otherwise I'm afraid no one will realize this is available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a dummy inclusion in the NamesCell.tsx.template
In the QUERY it adds the object for the relationship
authorId
author {
id
# Add the author fields you need here
}
I thought I would include the type and fields, but it doesn't, not sure of it makes much sense.
I'll circle back, i might be better to include the schema object. will investigate
typescript = false, | ||
tailwind = false, | ||
force = false, | ||
nestScaffoldByModel, | ||
stories, | ||
serviceTests = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this preserves the current operation mode, but because the DEFAULT_CONFIG (packages/project-config/src/config.ts) sets tests = true
the fixtures of the test-project change. We can either unify the tests
flag, keep tests
for the service and use componentTests
for the component tests. I think unifying the flag makes the most sense, but it might be a breaking change. @Tobbe Please advice,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this correctly I think we should have the scaffold generator generate tests and stories by default. It should also respect the https://docs.redwoodjs.com/docs/app-configuration-redwood-toml#generate
settings in redwood.toml so that users can turn test and story generation off on a global level. And also the --no-tests
and --no-stories
cli flags for the scaffold generator
@esteban-url Can you please take a look at the failing CI test? |
This PR fixes #11754 by adding the ability to generate test, stories and mock files when custom scaffold templates are in use.
Right now these files are not supported/generated even if a template file is there. This PR will allow a dev to define their own test, stories and mock templates for components and/or pages and have the
yarn rw g scaffold [model]
command correctly generate it for them.Please let me know what you think of it and/or it any testing is required.
Thanks!