Skip to content
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

component generator: correcting template and thor tasks to account for component status #1229

Merged
merged 3 commits into from
Jul 27, 2022
Merged

component generator: correcting template and thor tasks to account for component status #1229

merged 3 commits into from
Jul 27, 2022

Conversation

mxriverlynn
Copy link
Contributor

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:

  • the component status was not set correctly by the component.tt template. it was hard coded to :alpha
  • the component namespace was not set correctly in the component.tt yard doc example. status based namespace was missing
  • the gatsby nav.yml file was not updated to include the newly generate component. errors out saying supplied flag value not found

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

  • update component.tt template to ensure the correct status is used for both alpha and beta states
  • update the module/namespace used in the @Example generated by the component.tt template
  • corrects the component_generator.thor file to correct the after: setting for inserting the new component into the nav.yml file

with 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

❯ bundle exec thor component_generator sample_thing --status beta --js

      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/system/beta/sample_thing_test.rb
      create  demo/test/components/previews/primer/beta/sample_thing_preview.rb
      create  test/components/previews/beta/sample_thing_preview.rb
      insert  lib/tasks/docs.rake
      insert  lib/tasks/docs.rake
      insert  test/components/component_test.rb
      insert  docs/src/@primer/gatsby-theme-doctocat/nav.yml
      create  app/components/primer/beta/sample_thing.ts
      append  app/components/primer/primer.ts

         run  yarn add js from "."
yarn add v1.22.19
[1/4] 🔍  Resolving packages...
...

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

image

@mxriverlynn mxriverlynn requested review from a team and camertron July 27, 2022 15:07
@changeset-bot
Copy link

changeset-bot bot commented Jul 27, 2022

🦋 Changeset detected

Latest commit: 55199d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I just ran into this problem yesterday, like you read my mind. 💜

@jonrohan jonrohan merged commit 5631d28 into primer:main Jul 27, 2022
@primer-css primer-css mentioned this pull request Jul 27, 2022
@mxriverlynn mxriverlynn deleted the component_generator_status_corrections branch July 27, 2022 17:15
krhkt pushed a commit that referenced this pull request Sep 1, 2022
…r component status (#1229)

* ensuring the component template has the correct status and status module

* correcting component_generator insertion into nav.yml file

* Create good-needles-fix.md

Co-authored-by: Jon Rohan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants