-
Notifications
You must be signed in to change notification settings - Fork 5
Phase 1: Populate reusedCode from USWDS and CMS Design System dependencies #125
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| export interface ReusedCodeEntry { | ||
| name: string; | ||
| URL: string; | ||
| } | ||
|
|
||
| // each dependency gets its own entry with the repository URL where the source code is hosted | ||
| export const USWDS: ReusedCodeEntry = { | ||
| name: "U.S. Web Design System (USWDS)", | ||
| URL: "https://github.com/uswds/uswds", | ||
| }; | ||
|
|
||
| export const USWDS_COMPILE: ReusedCodeEntry = { | ||
| name: "USWDS Compile", | ||
| URL: "https://github.com/uswds/uswds-compile", | ||
| }; | ||
|
|
||
| export const CMS_DESIGN_SYSTEM: ReusedCodeEntry = { | ||
| name: "CMS Design System", | ||
| URL: "https://github.com/CMSgov/design-system", | ||
| }; | ||
|
|
||
| export const CMS_DS_HEALTHCARE_GOV: ReusedCodeEntry = { | ||
| name: "CMS Design System - HealthCare.gov", | ||
| URL: "https://github.com/CMSgov/design-system/tree/main/packages/ds-healthcare-gov", | ||
| }; | ||
|
|
||
| export const CMS_DS_MEDICARE_GOV: ReusedCodeEntry = { | ||
| name: "CMS Design System - Medicare.gov", | ||
| URL: "https://github.com/CMSgov/design-system/tree/main/packages/ds-medicare-gov", | ||
| }; | ||
|
|
||
| export const CMS_DS_CMS_GOV: ReusedCodeEntry = { | ||
| name: "CMS Design System - CMS.gov", | ||
| URL: "https://github.com/CMSgov/design-system/tree/main/packages/ds-cms-gov", | ||
| }; | ||
|
Comment on lines
+7
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Phase 1 this fits our needs as we have a short well-curated list! As our list of fed software dependencies grows (I can forsee this list going into the 100s), this approach of creating
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree! The per-entry approach won't scale well as the list grows. This will change in Phase 2:
Thanks for flagging this! |
||
|
|
||
| // keys are lowercased package names; each maps to its own unique entry | ||
| export const GOV_DEPENDENCIES: Record<string, ReusedCodeEntry> = { | ||
| uswds: USWDS, | ||
| "@uswds/uswds": USWDS, | ||
| "@uswds/compile": USWDS_COMPILE, | ||
| "@cmsgov/design-system": CMS_DESIGN_SYSTEM, | ||
| "@cmsgov/ds-healthcare-gov": CMS_DS_HEALTHCARE_GOV, | ||
| "@cmsgov/ds-medicare-gov": CMS_DS_MEDICARE_GOV, | ||
| "@cmsgov/ds-cms-gov": CMS_DS_CMS_GOV, | ||
|
Comment on lines
+40
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome, what I was looking for! |
||
| }; | ||
|
|
||
| // npm names are lowercase and Python names are case-insensitive, so lowercasing suffices to match | ||
| export function normalizePackageName(name: string): string { | ||
| return name.trim().toLowerCase(); | ||
| } | ||
|
|
||
| export function lookupGovDependency(name: string): ReusedCodeEntry | undefined { | ||
| // hasOwn guard so names like "constructor"/"__proto__" don't match inherited members | ||
| const key = normalizePackageName(name); | ||
| return Object.hasOwn(GOV_DEPENDENCIES, key) | ||
| ? GOV_DEPENDENCIES[key] | ||
| : undefined; | ||
| } | ||
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.
verbose testing 💯