Phase 1: Populate reusedCode from USWDS and CMS Design System dependencies#125
Conversation
|
Thank you, will get to this soon. Also making @sachin-panayil as a reviewer too since he is the primary maintainer of this tool! |
natalialuzuriaga
left a comment
There was a problem hiding this comment.
A minor structural change where we would likeurl field in a reusedCode object to be the repository URL.
Otherwise amazing work with this!!! This type of automation will make a huge difference with agency's being able to track code reuse which is the core purpose of the SHARE IT Act.
| } | ||
|
|
||
| // keeps existing entries (manual edits) and appends detected ones, de-duped by name and URL | ||
| export function mergeReusedCode( |
There was a problem hiding this comment.
The merge logic LGTM! Just flagging this for Sachin because this is related to #31, so this may overlap/affect this work
There was a problem hiding this comment.
There was a problem hiding this comment.
this logic is fine and doesnt affect that ticket, ty for the heads up tho!
058f5f9 to
e7efdaf
Compare
sachin-panayil
left a comment
There was a problem hiding this comment.
this looks great and handled extremely well! i just have one question/suggestion about importing the function in main but after that gets responded to, i will go ahead and approve 👍
| return entries; | ||
| } | ||
|
|
||
| async function readManifest(filepath: string): Promise<string | null> { |
There was a problem hiding this comment.
not a direct change needed rn but this makes me wonder that we should change the original readFile function to be async
There was a problem hiding this comment.
I think readFile is already async since it returns a Promise<string>? We could possibly add async keyword to make it more clear?
| }); | ||
| }); | ||
|
|
||
| describe("parsePackageJSON", () => { |
| } | ||
|
|
||
| // keeps existing entries (manual edits) and appends detected ones, de-duped by name and URL | ||
| export function mergeReusedCode( |
There was a problem hiding this comment.
this logic is fine and doesnt affect that ticket, ty for the heads up tho!
natalialuzuriaga
left a comment
There was a problem hiding this comment.
Amazing job with Phase 1 of this ticket!! This is a very solid foundation for the work you'll do in the later phases! Flagged a potential refactor as the list grows bigger but that can be addressed in the later phrases
| "@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, |
There was a problem hiding this comment.
Awesome, what I was looking for!
| 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", | ||
| }; |
There was a problem hiding this comment.
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 ReusedCodeEntry object for each dependency may not scale well (too much repetition, must know aliases, hard to sort through data) so flagging that maybe there is a different way to go about this for Phase 2/3?
There was a problem hiding this comment.
I agree! The per-entry approach won't scale well as the list grows.
This will change in Phase 2:
- The dependency data moves into its own module, separate from the lookup logic.
- Lookup falls back to the npm scope, so
@uswds/*resolves off a single entry instead of listing every alias individually.
Thanks for flagging this!
|
@sachin-panayil Ready for review made requested changes |
e7efdaf to
dce6eff
Compare
Problem
The
reusedCodefield, which lists government software a project reuses, is left empty by the generator and has to be filled in by hand.Solution
Detect government-made dependencies from
package.jsonandrequirements.txtand populatereusedCodeautomatically.src/gov-dependencies.ts— curated map of gov dependencies; Phase 1 covers USWDS and the CMS Design Systemhelper.ts—detectReusedCodematches manifest deps against the map, andmergeReusedCodemerges them into existing entries while keeping manual edits and avoiding duplicates on re-rungetMetaDatainmain.tsScope
This PR is Phase 1: USWDS and the CMS Design System. Phase 2 grows the list using federal npm orgs, CISA
.govdata, keywords, and SBOMs. Phase 3 cross-checks against the federal source-code inventory.Test Plan
npm testandnpm run lintpass. Added unit tests for parsing, detection, alias de-duplication, and merge.Related: #124