Skip to content

feat: add npm engine constraint properties - #1507

Open
CAOShurong wants to merge 3 commits into
CycloneDX:mainfrom
CAOShurong:codex/1506-node-engine-constraints
Open

feat: add npm engine constraint properties#1507
CAOShurong wants to merge 3 commits into
CycloneDX:mainfrom
CAOShurong:codex/1506-node-engine-constraints

Conversation

@CAOShurong

Copy link
Copy Markdown

Description

Populate Component.properties from the string-valued entries in a Node
package manifest's engines object. Each entry uses the existing CycloneDX
npm property taxonomy name
cdx:npm:package:constraint:engine:<name>.

Malformed non-string engine constraints are ignored, consistent with the
builder's defensive handling of other package manifest fields.

Fixes issue: #1506

Verification

  • npm run test:node (4,166 passing)
  • npm run test:lint
  • npm run test:standard
  • npm run test:dependencies
  • npm run build:node
  • npm run build:web
  • npx tsc -b ./tsconfig.d.json
  • npm pack --ignore-scripts, followed by installation into a clean directory
    and runtime checks for valid constraints, malformed values, and a missing
    package name

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: OpenAI Codex
    • LLMs and versions: GPT-5
    • Prompts: Inspect issue #1506 and the repository contribution rules; implement only the required npm engine constraint properties; add positive and malformed-input regression coverage; run build, lint, full tests, package, and clean-install runtime verification.

Affirmation

Populate CycloneDX npm taxonomy properties from package.json engine constraints and ignore malformed non-string values.

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

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
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

read-the-docs-community Bot commented Aug 14, 2026

Copy link
Copy Markdown

Documentation build overview

📚 CycloneDX JavaScript Library | 🛠️ Build #34077654 | 📁 Comparing e328805 against latest (a573fd8)

  🔍 Preview build  

2 files changed
± changelog.html
± index.html

import type { ExternalReferenceFactory } from './factories'
import type { NodePackageJson } from './types'

function makeEngineProperties (engines: unknown): PropertyRepository {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please move this inside the ComponentBuilder

externalReferences: new ExternalReferenceRepository(externalReferences),
group,
licenses,
properties,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

properties at the bottom

)
],
[
'ignore malformed engine constraints',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pleasse also adda test case where the malformed engines is an array, and one for where it is null, and one where it is a string.

Comment thread HISTORY.md
Comment thread HISTORY.md Outdated
Co-authored-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@CAOShurong

Copy link
Copy Markdown
Author

Both review requests are now in place at exact head dee02ea:

  • makeEngineProperties moved inside ComponentBuilder and the generated properties are passed at the bottom of the component options.
  • Added regression cases where malformed engines is an array, null and a string (plus the existing non-string-constraint case).

Verification on this head: 8 focused ComponentBuilder tests, 4,155 full node tests, tsc noEmit, eslint, knip dependency checks, node/web/declaration builds, and a real installed-dist probe covering valid, array, null, string and missing engines all pass. CI is now running on the updated head.

Thanks for the review and for applying the HISTORY.md suggestion.

…malformed engines

Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong
CAOShurong force-pushed the codex/1506-node-engine-constraints branch from dee02ea to e328805 Compare August 15, 2026 04:21
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.

2 participants