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

Automate component version badges #2656

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alex-ju
Copy link
Member

@alex-ju alex-ju commented Jan 20, 2025

πŸ“Œ Summary

Follow-up on #2613 to automate the removal and addition of version badges for each component.

πŸ› οΈ Detailed description

  • e82ea68 update component changelog script to handle badges
  • e82ea68 as we use gray-matter (a slim wrapper of js-yaml) to read/write the front matter we updated components' front matter to match the standard schema

Outcome

Running the automated script revealed a few instances where the 4.15 badge was missing. Any added or updated badge before 4.15 is removed.

Note

This PR will be updated to match the agreed proposal outlined by @zamoore in the release cycle RFC.

Limitations

The script doesn't generate added or deprecated badges (only updated). When you add a new component (or deprecate one), you have to either update the front matter status when updating the associated docs or change the badge type after running the automated script. These details will be covered in the confluence documentation updates.

πŸ”— External links

Jira ticket: HDS-4299


πŸ’¬ Please consider using conventional comments when reviewing this PR.

using `gray-matter` to manage the front matter read/write and formatting
running `yarn run generate-component-changelog-entries`
@alex-ju alex-ju requested review from a team as code owners January 20, 2025 15:37
Copy link

vercel bot commented Jan 20, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
hds-showcase βœ… Ready (Inspect) Visit Preview Jan 22, 2025 4:10pm
hds-website βœ… Ready (Inspect) Visit Preview Jan 22, 2025 4:10pm

@hashibot-hds hashibot-hds added the docs-website Content updates to the documentation website label Jan 20, 2025
@alex-ju alex-ju changed the title Alex ju/automate component version tags Automate component version badges Jan 20, 2025
Copy link
Contributor

@shleewhite shleewhite left a comment

Choose a reason for hiding this comment

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

Looks good! Just left a couple questions and I think one thing to change.

@@ -1,14 +1,22 @@
---
title: Badge
description: Concise, non-interactive labels that represent metadata.
caption: Concise, non-interactive labels that represent metadata.
description: 'Concise, non-interactive labels that represent metadata.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why do these caption and description have quotes? it seems like most of the others dont.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the deployed site (https://hds-website-git-alex-ju-automate-component-ver-2d7be8-hashicorp.vercel.app/components/badge) seems like it doesn't randomly add the quotes to the page so I guess its fine

Copy link
Member Author

@alex-ju alex-ju Jan 22, 2025

Choose a reason for hiding this comment

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

According to the schema used by js-yaml strings over a certain length are moved to a block (hence the >- notation) and the short ones get wrapped in single quotes to avoid parse errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok! I just noticed that there were places where the file was updated, but caption/description stayed the same (didn't add the quotes) so I thought it was interesting that it only got added 3 times.

ex: Accordion didnt have quotes added around the caption
Screenshot 2025-01-22 at 10 10 58β€―AM

@@ -1,13 +1,18 @@
---
title: Card
description: A block container that provides styling for elevation, border, and background.
caption: A block container that provides styling for elevation, border, and background.
description: 'A block container that provides styling for elevation, border, and background.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question about the quotes here.

@@ -1,19 +1,24 @@
---
title: Table
description: Used to display organized, two-dimensional tabular data.
caption: Used to display organized, two-dimensional tabular data.
description: 'Used to display organized, two-dimensional tabular data.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Another example where the quotes are randomly added.

const indexPath = `${allComponentsPath[componentName]}/index.md`;

if (fs.existsSync(indexPath)) {
// Fetch the index markdown file
Copy link
Contributor

Choose a reason for hiding this comment

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

Really appreciate the comments!

});
};

const cleanComponentFrontMatter = (components) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: I think version needs to be added to the args here? Otherwise I don't see where it is defined.

Copy link
Member Author

Choose a reason for hiding this comment

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

right, yes, I believe I'm missing the second argument here – will update!

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed in 15e50a9 thanks for spotting this!

parsedFrontMatter.data.status = {};
}
if (
parsedFrontMatter.data.status.added !== version &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: going forward, will we still need to manually add the added tag?

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed. either add it manually, or change it from Updated to Added where needed. We can try to add some logic there to distinguish additions from updates, but it's not going to be a clean cut and wasn't sure it's worth the effort.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense! We add stuff much less often.

Copy link
Contributor

@dchyun dchyun left a comment

Choose a reason for hiding this comment

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

Everything working great! Tested it with a few different scenarios and all worked out. Just one comment I left.

parsedFrontMatter.data.status.added !== version &&
parsedFrontMatter.data.status.updated !== version
) {
parsedFrontMatter.data.status.updated = version;
Copy link
Contributor

@dchyun dchyun Jan 22, 2025

Choose a reason for hiding this comment

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

[Suggestion] This would defiantly make the implementation more complicated πŸ˜…, and is probably best raised in the doc, but for patch releases do we want to remove all "updated" badges from a previous minor release?

Just thinking of the situation where we do a minor release, the badges get added, and then we have some need to do a patch release quickly after and the badges get removed before consumers are really even aware they were there.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. Let me think about it, maybe we can prevent this from code rather than docs πŸ€”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-website Content updates to the documentation website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants