Skip to content

feat: optimize changelog check for package.json changes - #84

Merged
cryptodev-2s merged 10 commits into
mainfrom
feat/optimize-changelog-package-analysis
Jul 11, 2025
Merged

feat: optimize changelog check for package.json changes#84
cryptodev-2s merged 10 commits into
mainfrom
feat/optimize-changelog-package-analysis

Conversation

@cryptodev-2s

@cryptodev-2scryptodev-2s commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

Description

This PR significantly improves the changelog check workflow by optimizing package.json change detection, adding support for skipping changelog requirements in common scenarios, and implementing smart changelog section detection for release PRs.

🎯 Enhanced Skip Logic

  • Version-only changes: Skip when only the version field is modified
  • Dev dependency-only changes: Skip when only devDependencies are modified
  • Combined changes: Skip when changes are only version + dev dependencies
  • Release PR detection: When version changes are detected, look for changelog entries in the corresponding version section

Fixes

Examples

Will be skipped (no changelog required):

// Version only"version": "1.0.0"→ "1.0.1"// Dev dependencies only "devDependencies": { "jest": "^27.5.1"→ "^27.5.2" }
// Version + dev dependencies"version": "1.0.0"→ "1.0.1""devDependencies": { "jest": "^27.5.1"→ "^27.5.2" }

Will require changelog:

// Regular dependencies"dependencies": { "lodash": "^4.0.0"→ "^4.1.0" }
// Scripts, main, types, etc."main": "index.js"→ "dist/index.js"

@cryptodev-2scryptodev-2s self-assigned this Jul 9, 2025
@cryptodev-2s
cryptodev-2s requested a review from a teamJuly 9, 2025 14:00
cursor[bot]

This comment was marked as outdated.

- Skip changelog when only version, dev dependencies, or both are changed
@cryptodev-2s
cryptodev-2sforce-pushed the feat/optimize-changelog-package-analysis branch from 17753c4 to 654b094CompareJuly 9, 2025 14:10
cursor[bot]

This comment was marked as outdated.

@mcmiremcmire 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.

I think this looks correct, but I had some suggestions for simplifying the changes.

Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts
Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts
Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts Outdated
cursor[bot]

This comment was marked as outdated.

@cryptodev-2s
cryptodev-2s requested a review from mcmireJuly 9, 2025 21:47
cursor[bot]

This comment was marked as outdated.

@socket-security

socket-securityBot commented Jul 10, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

DiffPackageSupply Chain
Security
VulnerabilityQualityMaintenanceLicense
Updated@​types/​semver@​7.3.13 ⏵ 7.7.01001007277100
Updatedsemver@​7.5.4 ⏵ 7.7.2100+1100100+187100

View full report

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts Outdated
@cryptodev-2s
cryptodev-2s requested a review from mcmireJuly 10, 2025 16:50
cursor[bot]

This comment was marked as outdated.

@mcmiremcmire 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 few more things I noticed, but I tested this out and everything else looks good.

Comment threadsrc/changelog-check.ts Outdated
Comment threadsrc/changelog-check.ts
Comment threadsrc/changelog-check.ts
cursor[bot]

This comment was marked as outdated.

@cryptodev-2s
cryptodev-2s requested a review from mcmireJuly 11, 2025 21:37

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Package.json Parsing Fails on Duplicate Lines

The getDevDependencyLines function incorrectly classifies changes within package.json files. It uses findIndex to locate change lines in the full diff output, which always returns the first occurrence. If the same line content appears multiple times (e.g., a dependency change in both dependencies and devDependencies), the function misidentifies its true position. This leads to an incorrect determination of whether a change is within the devDependencies section, potentially causing erroneous changelog requirements (e.g., requiring an entry for a pure dev dependency update) or incorrectly skipping other changes.

src/changelog-check.ts#L150-L163

// Check which nonVersionLines fall within devDependencies sections
for(constchangeLineofnonVersionLines){
constlineIndex=allLines.findIndex((line)=>line===changeLine);
if(lineIndex!==-1){
// Check if this line falls within any devDependencies section
constisInDevDeps=
lineIndex>=devDependencySectionStart&&
lineIndex<=devDependencySectionEnd;
if(isInDevDeps){
devDependencyLines.push(changeLine);
}
}
}

Fix in CursorFix in Web


Bug: Version Parsing Errors Cause Script Crash

The isVersionDowngrade function does not handle errors when creating SemVer objects from oldVersion or newVersion. If these version strings are invalid semantic versions, the SemVer constructor throws an unhandled exception, crashing the script. This bypasses the error handling in the calling analyzePackageJsonChanges function.

src/changelog-check.ts#L174-L180

*/
constisVersionDowngrade=(
oldVersion: string,
newVersion: string,
): boolean=>{
returnnewSemVer(newVersion).compare(newSemVer(oldVersion))<0;
};

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@mcmiremcmire 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.

LGTM!

@cryptodev-2s
cryptodev-2s merged commit fc6fe1a into mainJul 11, 2025
19 checks passed
@cryptodev-2s
cryptodev-2s deleted the feat/optimize-changelog-package-analysis branch July 11, 2025 22:00
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants

@cryptodev-2s@mcmire@metamaskbot