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

Mc 2517 sql query update #927

Merged
merged 5 commits into from
Oct 30, 2023
Merged

Mc 2517 sql query update #927

merged 5 commits into from
Oct 30, 2023

Conversation

micahchiang
Copy link
Contributor

@micahchiang micahchiang commented Oct 27, 2023

Chromatic

https://mc-2517-sql-query-update--60f9b557105290003b387cd5.chromatic.com

Description

Closes department-of-veterans-affairs/vets-design-system-documentation#2157

This pull request addresses two needs in our design system dashboard cli:

  1. It adds a new column to our SQL query, uswds, which represents the total count where a component is using the uswds prop.
  2. It fixes a gotcha where the cli was only accounting for single line, single use imports, not multiline imports. The implication here is that react binding usages were being under counted.

For a little more context, checkout the slack conversation here

Testing done

Locally against search results in vets-website.

Using VaTextInput as an example:

New regex properly matching search result count in vets-website

image

image

Old regex on main branch, only matching single line imports

image

Screenshot from 2023-10-27 10-00-49

Screenshots

Example of old regex not matching multiline imports

Screenshot from 2023-10-25 12-36-18

Example of new regex matching multiline imports properly

Screenshot from 2023-10-25 12-46-55

Acceptance criteria

  • Bugs have been fixed

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@micahchiang micahchiang added the ignore-for-release Used if you want to ignore the PR in the generated release notes label Oct 27, 2023
@micahchiang micahchiang requested a review from a team as a code owner October 27, 2023 17:07
Comment on lines +71 to +76
function incrementUswdsCount(componentName) {
if (!data[componentName].uswds) {
data[componentName].uswds = 0;
}
data[componentName].uswds++;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the same thing as incrementCount but specifically for the uswds property only

Comment on lines +117 to +132
uswdsComponents.forEach(i => {
i.matches.forEach(m => {
const componentName = m[1];
if (componentName) {
incrementUswdsCount(componentName);

// If the component is not yet in the collection, initialize it as an empty array
if (!instancesByComponent[componentName])
instancesByComponent[componentName] = [];

// Only include the app path if it hasn't already been included previously
if (!instancesByComponent[componentName].includes(i.path))
instancesByComponent[componentName].push(i.path);
}
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does a count of the queried uswds components. I couldn't think of an easy way to modify the first query that returns vwComponents, so the query just runs again.

search(readFile(match.path), componentRegex)
);
// First item will be the import match, second will be a string of component names
const componentNames = m[1];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally m[1] was assuming a single string. With the new regex, even if it is just a single string like VaTextInput, we're transforming it to an array to handle the cases where there are more than one import. See the jsdoc comment above the function for a broader explanation.

@@ -171,6 +215,7 @@ function findComponents(searchStrings) {
let vwWebComponents;
let contentBuildWC;
let vwComponents;
const uswdsV3Components = [...search(vwModules, wcUswds3Regex)];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't think of a good way to search for vw components and keep track of the uswds prop "in place", so just decided to search explicitly for them separately.

@micahchiang micahchiang merged commit 68304c5 into main Oct 30, 2023
6 checks passed
@micahchiang micahchiang deleted the mc-2517-sql-query-update branch October 30, 2023 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-for-release Used if you want to ignore the PR in the generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create report with data with use of v3 version of the components.
2 participants