2023-02-08 09:57:40 +00:00
|
|
|
import json
|
2023-02-08 10:22:55 +00:00
|
|
|
from enum import Enum
|
2023-02-08 09:57:40 +00:00
|
|
|
|
|
|
|
def init_project():
|
|
|
|
# validate_values()
|
|
|
|
version = Version('package.json')
|
|
|
|
version.parse()
|
|
|
|
|
|
|
|
def prepare_release():
|
|
|
|
pass
|
|
|
|
|
|
|
|
def release_in_git():
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Version():
|
|
|
|
|
2023-02-08 10:22:55 +00:00
|
|
|
class ReleaseLevel(Enum):
|
|
|
|
SNAPSHOT = 0
|
|
|
|
PATCH = 1
|
|
|
|
MINOR = 2
|
|
|
|
MAJOR = 3
|
|
|
|
|
2023-02-08 09:57:40 +00:00
|
|
|
def __init__(self, config_file_path):
|
|
|
|
self.version = "0.0.0"
|
|
|
|
self.config_file_path = config_file_path
|
|
|
|
print('init project')
|
|
|
|
|
|
|
|
def parse(self):
|
2023-02-08 10:22:55 +00:00
|
|
|
if self.config_file_path.split('.')[-1] == 'json':
|
2023-02-08 09:57:40 +00:00
|
|
|
self.__parse_json()
|
|
|
|
|
|
|
|
def __parse_json(self):
|
|
|
|
with open(self.config_file_path, 'r') as json_file:
|
|
|
|
json_data = json.load(json_file)
|
2023-02-08 10:22:55 +00:00
|
|
|
self.version = json_data['version']
|
|
|
|
|
|
|
|
def increment(self, level: ReleaseLevel):
|
|
|
|
match level:
|
|
|
|
case ReleaseLevel.SNAPSHOT:
|
|
|
|
if "-SNAPSHOT" not in self.version
|
|
|
|
self.version = self.version + "-SNAPSHOT"
|
|
|
|
case ReleaseLevel.PATCH:
|
|
|
|
pass
|
|
|
|
case ReleaseLevel.MINOR:
|
|
|
|
pass
|
|
|
|
case ReleaseLevel.MAJOR:
|
|
|
|
pass
|
2023-02-08 09:57:40 +00:00
|
|
|
|
|
|
|
def get():
|
|
|
|
pass
|