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
Copy link
Copy Markdown
Contributor

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

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-2s cryptodev-2s self-assigned this Jul 9, 2025
@cryptodev-2s cryptodev-2s requested a review from a team July 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-2s force-pushed the feat/optimize-changelog-package-analysis branch from 17753c4 to 654b094 Compare July 9, 2025 14:10
cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

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 thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts
Comment thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts
Comment thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts Outdated
cursor[bot]

This comment was marked as outdated.

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

This comment was marked as outdated.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jul 10, 2025

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
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 thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts Outdated
@cryptodev-2s cryptodev-2s requested a review from mcmire July 10, 2025 16:50
cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

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 thread src/changelog-check.ts Outdated
Comment thread src/changelog-check.ts
Comment thread src/changelog-check.ts
cursor[bot]

This comment was marked as outdated.

@cryptodev-2s cryptodev-2s requested a review from mcmire July 11, 2025 21:37
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 (const changeLine of nonVersionLines) {
const lineIndex = allLines.findIndex((line) => line === changeLine);
if (lineIndex !== -1) {
// Check if this line falls within any devDependencies section
const isInDevDeps =
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

*/
const isVersionDowngrade = (
oldVersion: string,
newVersion: string,
): boolean => {
return new SemVer(newVersion).compare(new SemVer(oldVersion)) < 0;
};

Fix in CursorFix in Web


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

Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

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 main Jul 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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants