component generator: correcting template and thor tasks to account for component status #1229
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.
the problem
while exploring the view components code and learning how it works, how to build components, etc, i ran into some issues with the
component_generator
thor command:component.tt
template. it was hard coded to:alpha
component.tt
yard doc example. status based namespace was missingnav.yml
file was not updated to include the newly generate component. errors out saying supplied flag value not foundthese issues resulted in failure to build or run the view components web app, due to the incorrect or missing status.
the fixes
this PR corrects the issues above with these changes:
component.tt
template to ensure the correct status is used for both alpha and beta states@Example
generated by thecomponent.tt
templatecomponent_generator.thor
file to correct theafter:
setting for inserting the new component into thenav.yml
filewith these changes, i am able to generate a new component with the correct status and namespace, having it update the
nav.yml
file correctly:example output
generate component with no flags:
❯ bundle exec thor component_generator sample_thing create app/components/primer/alpha/sample_thing.rb create app/components/primer/alpha/sample_thing.html.erb create test/components/primer/alpha/sample_thing_test.rb create test/components/previews/alpha/sample_thing_preview.rb insert lib/tasks/docs.rake insert test/components/component_test.rb insert docs/src/@primer/gatsby-theme-doctocat/nav.yml
generate component with status flag:
❯ bundle exec thor component_generator sample_thing --status beta create app/components/primer/beta/sample_thing.rb create app/components/primer/beta/sample_thing.html.erb create test/components/primer/beta/sample_thing_test.rb create test/components/previews/beta/sample_thing_preview.rb insert lib/tasks/docs.rake insert test/components/component_test.rb insert docs/src/@primer/gatsby-theme-doctocat/nav.yml
generate component with status flag and js flag
screenshots
screenshot showing sample thing component in localhost:5400, generated with
--status beta --js
flags. shows the correct status, the correct message in the sidebar telling the developer to edit the nav file, and the correct namespace with running example in the page