WIP conversion issues

This commit is contained in:
erik 2023-02-08 12:14:53 +01:00
parent c1928b8c44
commit 1fe186cc4a
2 changed files with 45 additions and 24 deletions

View file

@ -5,7 +5,7 @@ def init_project():
# validate_values() # validate_values()
version = Version('package.json') version = Version('package.json')
version.parse() version.parse()
version.increment(ReleaseLevel.PATCH) version.increment(ReleaseLevel.MAJOR)
print(version.get()) print(version.get())
def prepare_release(): def prepare_release():
@ -37,19 +37,40 @@ class Version():
self.version = json_data['version'] self.version = json_data['version']
def increment(self, level: ReleaseLevel): def increment(self, level: ReleaseLevel):
match level:
case ReleaseLevel.SNAPSHOT: if level is ReleaseLevel.SNAPSHOT:
if "-SNAPSHOT" not in self.version: if "-SNAPSHOT" not in self.version:
self.version = self.version + "-SNAPSHOT" self.version = self.version + "-SNAPSHOT"
else:
# convert array to int
# e.g. patch index +1
# convert back to str
# join
split_versiont = split_version.
match level:
case ReleaseLevel.PATCH: case ReleaseLevel.PATCH:
self.version = self.version.replace("-SNAPSHOT", "")
split_version = self.version.split('.') split_version = self.version.split('.')
patch_version = int(split_version[ReleaseLevel.PATCH.value]) patch_version = int(split_version[ReleaseLevel.PATCH.value])
self.version = split_version[:ReleaseLevel.PATCH.value] + str(patch_version + 1) self.version = ".".join(split_version[:ReleaseLevel.PATCH.value]) + "." + str(patch_version + 1)
print(self.version)
case ReleaseLevel.MINOR: case ReleaseLevel.MINOR:
pass self.version = self.version.replace("-SNAPSHOT", "")
split_version = self.version.split('.')
minor_version = int(split_version[ReleaseLevel.MINOR.value])
self.version = ".".join(split_version[:ReleaseLevel.MINOR.value]) + "." + str(minor_version + 1) + ".0"
case ReleaseLevel.MAJOR: case ReleaseLevel.MAJOR:
pass self.version = self.version.replace("-SNAPSHOT", "")
split_version = self.version.split('.')
major_version = int(split_version[ReleaseLevel.MAJOR.value])
self.version = "".join(split_version[:ReleaseLevel.MAJOR.value]) + str(major_version + 1) + ".0" + ".0"
def get(self) -> str: def get(self) -> str:
return self.version return self.version

View file

@ -2,7 +2,7 @@
"name": "dummy", "name": "dummy",
"description": "Generate c4k yaml for a jitsi deployment.", "description": "Generate c4k yaml for a jitsi deployment.",
"author": "meissa GmbH", "author": "meissa GmbH",
"version": "1.3.2", "version": "1.3.2-SNAPSHOT",
"homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi#readme", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi#readme",
"repository": "https://www.npmjs.com/package/c4k-jitsi", "repository": "https://www.npmjs.com/package/c4k-jitsi",
"license": "APACHE2", "license": "APACHE2",
@ -30,4 +30,4 @@
"shadow-cljs": "^2.11.18", "shadow-cljs": "^2.11.18",
"source-map-support": "^0.5.19" "source-map-support": "^0.5.19"
} }
} }