From 1fe186cc4a243ac32831c97188cf91e55c33673c Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 8 Feb 2023 12:14:53 +0100 Subject: [PATCH] WIP conversion issues --- devops_test.py | 39 ++++++++++++++++++++++++++++++--------- package.json | 30 +++++++++++++++--------------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/devops_test.py b/devops_test.py index a0aa37f..2958295 100644 --- a/devops_test.py +++ b/devops_test.py @@ -5,7 +5,7 @@ def init_project(): # validate_values() version = Version('package.json') version.parse() - version.increment(ReleaseLevel.PATCH) + version.increment(ReleaseLevel.MAJOR) print(version.get()) def prepare_release(): @@ -37,19 +37,40 @@ class Version(): self.version = json_data['version'] def increment(self, level: ReleaseLevel): - match level: - case ReleaseLevel.SNAPSHOT: - if "-SNAPSHOT" not in self.version: + + if level is ReleaseLevel.SNAPSHOT: + if "-SNAPSHOT" not in self.version: 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('.') patch_version = int(split_version[ReleaseLevel.PATCH.value]) - self.version = split_version[:ReleaseLevel.PATCH.value] + str(patch_version + 1) - print(self.version) + self.version = ".".join(split_version[:ReleaseLevel.PATCH.value]) + "." + str(patch_version + 1) + 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: - 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: return self.version \ No newline at end of file diff --git a/package.json b/package.json index 03f0a3e..c582f21 100644 --- a/package.json +++ b/package.json @@ -2,32 +2,32 @@ "name": "dummy", "description": "Generate c4k yaml for a jitsi deployment.", "author": "meissa GmbH", - "version": "1.3.2", + "version": "1.3.2-SNAPSHOT", "homepage": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi#readme", "repository": "https://www.npmjs.com/package/c4k-jitsi", "license": "APACHE2", "main": "c4k-jitsi.js", "bin": { - "c4k-jitsi": "./c4k-jitsi.js" + "c4k-jitsi": "./c4k-jitsi.js" }, "keywords": [ - "cljs", - "jitsi", - "k8s", - "c4k", - "deployment", - "yaml", - "convention4kubernetes" + "cljs", + "jitsi", + "k8s", + "c4k", + "deployment", + "yaml", + "convention4kubernetes" ], "bugs": { - "url": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi/issues" + "url": "https://gitlab.com/domaindrivenarchitecture/c4k-jitsi/issues" }, "dependencies": { - "js-base64": "^3.6.1", - "js-yaml": "^4.0.0" + "js-base64": "^3.6.1", + "js-yaml": "^4.0.0" }, "devDependencies": { - "shadow-cljs": "^2.11.18", - "source-map-support": "^0.5.19" + "shadow-cljs": "^2.11.18", + "source-map-support": "^0.5.19" } - } \ No newline at end of file +} \ No newline at end of file