-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
Signed-off-by: Micah Chiang <[email protected]>
Signed-off-by: Micah Chiang <[email protected]>
Signed-off-by: Micah Chiang <[email protected]>
function incrementUswdsCount(componentName) { | ||
if (!data[componentName].uswds) { | ||
data[componentName].uswds = 0; | ||
} | ||
data[componentName].uswds++; | ||
} |
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.
Does the same thing as incrementCount but specifically for the uswds property only
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); | ||
} | ||
}); | ||
}); |
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.
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]; |
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.
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)]; |
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 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.
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:
uswds
, which represents the total count where a component is using the uswds prop.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
Old regex on main branch, only matching single line imports
Screenshots
Example of old regex not matching multiline imports
Example of new regex matching multiline imports properly
Acceptance criteria
Definition of done