fix: version-bump.mjs #157
Open
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.
This fixes two issue:
npm versionprocess, theprocess.env.npm_package_versionis not set and then theversionproperty frommanifest.jsonwill get removed. The script should fail with an error iftargetVersioncannot be determined.versions.jsonfile does not seem to get updated, the new version does not get added to the property list/dictionary.Generated message below:
Changes made:
Added validation for
targetVersion: The script now checks ifprocess.env.npm_package_versionis set. If not, it prints an error message and exits with status code 1. This prevents the script from removing the version property from manifest.json when run outside thenpm versioncontext.Fixed the versions.json update logic: Changed from
if (!Object.values(versions).includes(minAppVersion))toif (!versions[targetVersion]). The original logic was checking if the minAppVersion VALUE existed anywhere in the versions dictionary, which was incorrect. The fix now properly checks if the targetVersion KEY already exists in the versions object, ensuring new versions are added correctly.Both fixes are minimal and maintain the script's simplicity. The script will now:
npm version