Add --skip-package-file option.

This commit is contained in:
Jonathan Bernard
2025-07-17 13:16:05 -05:00
parent 7aebd02140
commit 25a657ea2d
2 changed files with 28 additions and 6 deletions
+27 -5
View File
@@ -22,6 +22,25 @@ Options:
bump. Valid options are: 'major', 'minor', 'patch', bump. Valid options are: 'major', 'minor', 'patch',
'prerelease', 'buildmetadata', and 'last'. Defaults 'prerelease', 'buildmetadata', and 'last'. Defaults
to 'last' to 'last'
--skip-package-file Don't write changes to the package file (*.nimble or
package.json). This is useful mostly in temporary
circumstances where you want to update other source
files without updating the package file. Be careful
in these cases, however, as update_version uses the
current version (as reported in the package file) as
the canonical version. When updating versions in
other source files, update_version ignores lines that
do not match the current version. Consider the
following:
update_version set 1.0.4 file1.nim, file2.nim --skip-package-file # works
update_version set 1.0.0 file1.nim, file2.nim --skip-package-file # fails
The second command will *not* rewrite the version
strings in file1.nim and file2.nim because the
versions in those files (1.0.4) do not match what is
in the package.
Details: Details:
bump bump
@@ -66,7 +85,7 @@ Details:
Node: ^\s*export\s+const\s+\S*VERSION\S*\s*=\s*"(<old-version>)"\s*;?$ Node: ^\s*export\s+const\s+\S*VERSION\S*\s*=\s*"(<old-version>)"\s*;?$
""" """
const UV_VERSION = "1.1.0" const UV_VERSION = "1.2.0"
type type
LangType* = enum lNim, lNode LangType* = enum lNim, lNode
@@ -313,7 +332,8 @@ when isMainModule:
let part = parseSemverPart(partName) let part = parseSemverPart(partName)
pkg.version = incrementSemverPart(pkg.version, part) pkg.version = incrementSemverPart(pkg.version, part)
writePackage(pkg) if not args["--skip-package-file"]:
writePackage(pkg)
for filePath in args["<src-file>"]: for filePath in args["<src-file>"]:
replaceVersionInFile(Path(filePath), pkg, oldVersion) replaceVersionInFile(Path(filePath), pkg, oldVersion)
@@ -333,7 +353,8 @@ when isMainModule:
for filePath in args["<src-file>"]: for filePath in args["<src-file>"]:
replaceVersionInFile(Path(filePath), pkg, oldVersion) replaceVersionInFile(Path(filePath), pkg, oldVersion)
writePackage(pkg) if not args["--skip-package-file"]:
writePackage(pkg)
echo pkg.version echo pkg.version
elif args["get"]: echo pkg.version elif args["get"]: echo pkg.version
@@ -349,8 +370,9 @@ when isMainModule:
let isCorrect = stdin.readLine let isCorrect = stdin.readLine
acceptNewVersion = "yes".startsWith(isCorrect.toLower) acceptNewVersion = "yes".startsWith(isCorrect.toLower)
echo "Updating version definition in " & $pkg.file if not args["--skip-package-file"]:
writePackage(pkg) echo "Updating version definition in " & $pkg.file
writePackage(pkg)
for filePath in args["<src-file>"]: for filePath in args["<src-file>"]:
echo "Updating version definition in " & $filePath echo "Updating version definition in " & $filePath
+1 -1
View File
@@ -1,6 +1,6 @@
# Package # Package
version = "1.1.0" version = "1.2.0"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Small util to update version consistently for nim and node packages." description = "Small util to update version consistently for nim and node packages."
license = "MIT" license = "MIT"