fix(github): write package.json and package-lock.json with a trailing newline when bumping the version - #53
Open
bwp91 wants to merge 2 commits into
Open
fix(github): write package.json and package-lock.json with a trailing newline when bumping the version#53bwp91 wants to merge 2 commits into
bwp91 wants to merge 2 commits into
Conversation
… newline when bumping the version
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the Homebridge organization’s npm release version-bump scripts so that rewritten package.json and package-lock.json end with a trailing newline, matching npm’s output and avoiding eol-last lint failures that can break prepublishOnly publish steps.
Changes:
- Update all version-bump scripts to write
package.jsonwith a final\n. - Update all version-bump scripts to write
package-lock.jsonwith a final\n. - Add inline comments explaining why the newline is required (eslint
eol-lastcompatibility).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| .github/scripts/npm-version-script-esm-auto.js | Writes both manifests with a trailing newline after version updates. |
| .github/scripts/npm-version-script-auto.cjs | Writes both manifests with a trailing newline after version updates. |
| .github/npm-version-script.js | Writes both manifests with a trailing newline after version updates. |
| .github/npm-version-script-esm.js | Writes both manifests with a trailing newline after version updates. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The release version-bump scripts write both manifests with
JSON.stringify, which does not end with a newline. npm writes both files with one, so the file the workflow leaves behind differs from the file in the repo by a missing final newline.That is enough to break a release. In a repo whose
prepublishOnlyruns lint over the whole tree,eslintreaches the rewrittenpackage.jsonand fails:Both
august-yaleandrainbirdfailed this way on 2 August. Build, lint and the GitHub release step all passed and onlypublishfailed, so no tag or release was created and nothing reached npm — the releases simply did not happen.All four scripts that bump a version had it, so all four are fixed, for
package-lock.jsonas well aspackage.json:.github/npm-version-script-esm.js— the one the currentrelease.ymldownloads and runs.github/npm-version-script.js.github/scripts/npm-version-script-esm-auto.js.github/scripts/npm-version-script-auto.cjsVerified by running the patched scripts against a real checkout rather than by inspection: the version bumps exactly as before, both files come out ending in a newline and still parse as JSON, and the resulting
package.jsonpasses the sameeslint --max-warnings=0that rejected it in CI.Only repos that lint their whole tree during
prepublishOnlywere affected. The plugins keep their version in the repo and do not run these scripts on a stable release.🤖 Generated with Claude Code