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"
case ReleaseLevel.PATCH: else:
# convert array to int
# e.g. patch index +1
# convert back to str
# join
split_versiont = split_version.
match level:
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,32 +2,32 @@
"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",
"main": "c4k-jitsi.js", "main": "c4k-jitsi.js",
"bin": { "bin": {
"c4k-jitsi": "./c4k-jitsi.js" "c4k-jitsi": "./c4k-jitsi.js"
}, },
"keywords": [ "keywords": [
"cljs", "cljs",
"jitsi", "jitsi",
"k8s", "k8s",
"c4k", "c4k",
"deployment", "deployment",
"yaml", "yaml",
"convention4kubernetes" "convention4kubernetes"
], ],
"bugs": { "bugs": {
"url": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi/issues" "url": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi/issues"
}, },
"dependencies": { "dependencies": {
"js-base64": "^3.6.1", "js-base64": "^3.6.1",
"js-yaml": "^4.0.0" "js-yaml": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"shadow-cljs": "^2.11.18", "shadow-cljs": "^2.11.18",
"source-map-support": "^0.5.19" "source-map-support": "^0.5.19"
} }
} }