Skip to content

feat(contrib): populate component tags from npm keywords - #1511

Draft
CAOShurong wants to merge 1 commit into
CycloneDX:mainfrom
CAOShurong:codex/add-component-tags
Draft

feat(contrib): populate component tags from npm keywords#1511
CAOShurong wants to merge 1 commit into
CycloneDX:mainfrom
CAOShurong:codex/add-component-tags

Conversation

@CAOShurong

Copy link
Copy Markdown
Contributor

Closes #1055

Summary

Adds tags support to the Component model and populates it from the npm package.json keywords property in Contrib.FromNodePackageJson.Builders.ComponentBuilder, serialising tags in both JSON and XML for CycloneDX 1.6 and later (tags were introduced in CycloneDX 1.6).

Changes

  • src/models/component.ts: added optional tags?: string[] to Component and OptionalComponentProperties
  • src/contrib/fromNodePackageJson/types.ts: added keywords?: string[] to NodePackageJson
  • src/contrib/fromNodePackageJson/builders.ts: ComponentBuilder.makeComponent now maps data.keywords (string or string[] form) into tags
  • src/spec/_protocol.ts + src/spec/consts.ts: added supportsComponentTags, gated to CycloneDX 1.6 and 1.7
  • src/serialize/json/normalize.ts + types.ts: emit tags in JSON output for 1.6+
  • src/serialize/xml/normalize.ts: emit <tags><tag>..</tag></tags> in XML output for 1.6+
  • tests/integration/.../ComponentBuilder.node.test.js: full case now includes keywords and expects the resulting tags
  • HISTORY.md: unreleased note

Verification

  • tsc --noEmit clean
  • eslint clean on changed files
  • Full test suite: 4155 passing, 4 pending, 0 failing
  • Manual node checks confirm JSON outputs "tags":["alpha","beta"] and XML outputs <tags><tag>alpha</tag><tag>beta</tag></tags> for spec 1.7, and tags is absent for 1.5 and earlier.

Fills component.tags from the npm package.json keywords property in
ComponentBuilder, and serialises tags in both JSON and XML for CycloneDX
1.6 and later (tags were introduced in 1.6).

- Add optional tags to the Component model and JSON/XML serialisation
- Add supportsComponentTags to the spec protocol, gated to 1.6+

Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong
CAOShurong requested a review from a team as a code owner August 21, 2026 21:14
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CycloneDX JavaScript Library | 🛠️ Build #34178772 | 📁 Comparing 75a7f06 against latest (ed03365)

  🔍 Preview build  

2 files changed
± changelog.html
± index.html

@jkowalleck
jkowalleck marked this pull request as draft August 24, 2026 12:47
@jkowalleck

Copy link
Copy Markdown
Member

Not considering this PR, unless you clearly state the use of AI
as of the PR template - https://github.com/CycloneDX/cyclonedx-javascript-library/blob/main/.github/PULL_REQUEST_TEMPLATE.md

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.

feat: ComponentBuilder populate tags based on keywords

2 participants