Skip to content

Phase 1: Populate reusedCode from USWDS and CMS Design System dependencies#125

Merged
haseebmalik18 merged 1 commit into
DSACMS:devfrom
haseebmalik18:DSACMS/haseeb/reusedCodeFromDependencies
Jul 10, 2026
Merged

Phase 1: Populate reusedCode from USWDS and CMS Design System dependencies#125
haseebmalik18 merged 1 commit into
DSACMS:devfrom
haseebmalik18:DSACMS/haseeb/reusedCodeFromDependencies

Conversation

@haseebmalik18

Copy link
Copy Markdown
Collaborator

Problem

The reusedCode field, 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.json and requirements.txt and populate reusedCode automatically.

  • src/gov-dependencies.ts — curated map of gov dependencies; Phase 1 covers USWDS and the CMS Design System
  • helper.tsdetectReusedCode matches manifest deps against the map, and mergeReusedCode merges them into existing entries while keeping manual edits and avoiding duplicates on re-run
  • wired into getMetaData in main.ts

Scope

This PR is Phase 1: USWDS and the CMS Design System. Phase 2 grows the list using federal npm orgs, CISA .gov data, keywords, and SBOMs. Phase 3 cross-checks against the federal source-code inventory.

Test Plan

npm test and npm run lint pass. Added unit tests for parsing, detection, alias de-duplication, and merge.

Related: #124

@haseebmalik18 haseebmalik18 changed the title populate reusedCode with detected USWDS and CMS Design System depende… Populate reusedCode with detected USWDS and CMS Design System dependencies Jun 30, 2026
@haseebmalik18 haseebmalik18 changed the title Populate reusedCode with detected USWDS and CMS Design System dependencies Phase 1: Populate reusedCode from dependency files Jun 30, 2026
@haseebmalik18 haseebmalik18 changed the title Phase 1: Populate reusedCode from dependency files Phase 1: Populate reusedCode from USWDS and CMS Design System dependencies Jun 30, 2026
@haseebmalik18

Copy link
Copy Markdown
Collaborator Author

@natalialuzuriaga

@natalialuzuriaga

natalialuzuriaga commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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 natalialuzuriaga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread src/gov-dependencies.ts Outdated
Comment thread src/gov-dependencies.ts Outdated
Comment thread src/gov-dependencies.ts Outdated
Comment thread src/helper.ts
}

// keeps existing entries (manual edits) and appends detected ones, de-duped by name and URL
export function mergeReusedCode(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The merge logic LGTM! Just flagging this for Sachin because this is related to #31, so this may overlap/affect this work

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this logic is fine and doesnt affect that ticket, ty for the heads up tho!

Comment thread src/__tests__/unit/helper.test.ts Outdated

@sachin-panayil sachin-panayil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 👍

Comment thread src/helper.ts
return entries;
}

async function readManifest(filepath: string): Promise<string | null> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not a direct change needed rn but this makes me wonder that we should change the original readFile function to be async

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

verbose testing 💯

Comment thread src/helper.ts
}

// keeps existing entries (manual edits) and appends detected ones, de-duped by name and URL
export function mergeReusedCode(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this logic is fine and doesnt affect that ticket, ty for the heads up tho!

Comment thread src/main.ts Outdated

@natalialuzuriaga natalialuzuriaga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread src/gov-dependencies.ts
Comment on lines +40 to +45
"@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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome, what I was looking for!

Comment thread src/gov-dependencies.ts
Comment on lines +7 to +35
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",
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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:

  • 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!

@haseebmalik18

Copy link
Copy Markdown
Collaborator Author

@sachin-panayil Ready for review made requested changes

@haseebmalik18
haseebmalik18 force-pushed the DSACMS/haseeb/reusedCodeFromDependencies branch from e7efdaf to dce6eff Compare July 10, 2026 17:29

@sachin-panayil sachin-panayil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@haseebmalik18
haseebmalik18 merged commit 724746f into DSACMS:dev Jul 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants