diff --git a/src/cpl_cli/cpl_cli.json b/src/cpl_cli/cpl_cli.json index 05756abe..7aab7d34 100644 --- a/src/cpl_cli/cpl_cli.json +++ b/src/cpl_cli/cpl_cli.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "15.dev4" + "Micro": "15" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,7 +16,7 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=2022.6.15.dev4" + "cpl-core>=2022.6.15" ], "PythonVersion": ">=3.10", "PythonPath": {}, diff --git a/src/cpl_core/cpl_core.json b/src/cpl_core/cpl_core.json index 678c0f87..bf3aac9e 100644 --- a/src/cpl_core/cpl_core.json +++ b/src/cpl_core/cpl_core.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "15.dev4" + "Micro": "15" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", diff --git a/src/cpl_core/pipes/version_pipe.py b/src/cpl_core/pipes/version_pipe.py new file mode 100644 index 00000000..de116d33 --- /dev/null +++ b/src/cpl_core/pipes/version_pipe.py @@ -0,0 +1,14 @@ +from cpl_cli.configuration import VersionSettingsNameEnum +from cpl_core.pipes.pipe_abc import PipeABC + + +class VersionPipe(PipeABC): + + def __init__(self): pass + + def transform(self, value: dict, *args): + for atr in VersionSettingsNameEnum: + if atr.value not in value: + raise KeyError(atr.value) + + return f'{value[VersionSettingsNameEnum.major.value]}.{value[VersionSettingsNameEnum.minor.value]}.{value[VersionSettingsNameEnum.micro.value]}' diff --git a/src/cpl_query/cpl_query.json b/src/cpl_query/cpl_query.json index 77978a3c..0292ec12 100644 --- a/src/cpl_query/cpl_query.json +++ b/src/cpl_query/cpl_query.json @@ -4,7 +4,7 @@ "Version": { "Major": "2022", "Minor": "6", - "Micro": "15.dev4" + "Micro": "15" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -16,7 +16,7 @@ "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", "Dependencies": [ - "cpl-core>=2022.6.15.dev4" + "cpl-core>=2022.6.15" ], "PythonVersion": ">=3.10", "PythonPath": {}, diff --git a/tools/set_version/application.py b/tools/set_version/application.py index a8ee362d..9cae3296 100644 --- a/tools/set_version/application.py +++ b/tools/set_version/application.py @@ -1,10 +1,12 @@ import traceback -from cpl_cli.configuration import WorkspaceSettings -from cpl_core.application import ApplicationABC -from cpl_core.configuration import ConfigurationABC -from cpl_core.console import Console -from cpl_core.dependency_injection import ServiceProviderABC +from cpl_cli.configuration.version_settings_name_enum import VersionSettingsNameEnum +from cpl_cli.configuration.workspace_settings import WorkspaceSettings +from cpl_core.application.application_abc import ApplicationABC +from cpl_core.configuration.configuration_abc import ConfigurationABC +from cpl_core.console.console import Console +from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC +from cpl_core.pipes.version_pipe import VersionPipe from set_version.git_service import GitService from set_version.version_setter_service import VersionSetterService @@ -18,6 +20,7 @@ class Application(ApplicationABC): self._git_service: GitService = self._services.get_service(GitService) self._version_setter: VersionSetterService = self._services.get_service(VersionSetterService) + self._version_pipe: VersionPipe = self._services.get_service(VersionPipe) def configure(self): self._configuration.parse_console_arguments(self._services) @@ -43,9 +46,9 @@ class Application(ApplicationABC): return try: - version['Major'] = branch.split('.')[0] - version['Minor'] = branch.split('.')[1] - version['Micro'] = f'{branch.split(".")[2]}{suffix}' + version[VersionSettingsNameEnum.major.value] = branch.split('.')[0] + version[VersionSettingsNameEnum.minor.value] = branch.split('.')[1] + version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}' except Exception as e: Console.error(f'Branch {branch} does not contain valid version') return @@ -55,7 +58,7 @@ class Application(ApplicationABC): if not project.startswith('cpl'): continue - Console.write_line(f'Set version {version["Major"]}.{version["Minor"]}.{version["Micro"]} for {project}') + Console.write_line(f'Set version {self._version_pipe.transform(version)} for {project}') self._version_setter.set_version(self._workspace.projects[project], version) except Exception as e: Console.error('Version could not be set', traceback.format_exc()) diff --git a/tools/set_version/set-version.json b/tools/set_version/set-version.json index c04df303..a7c570a1 100644 --- a/tools/set_version/set-version.json +++ b/tools/set_version/set-version.json @@ -16,7 +16,7 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "sh_cpl-core>=2022.6.1.dev4" + "sh_cpl-core>=2022.6.15.dev4" ], "PythonVersion": ">=3.10.4", "PythonPath": { diff --git a/tools/set_version/startup.py b/tools/set_version/startup.py index 7e4701d5..ec9c6cf2 100644 --- a/tools/set_version/startup.py +++ b/tools/set_version/startup.py @@ -5,6 +5,7 @@ from cpl_core.application import StartupABC from cpl_core.configuration import ConfigurationABC from cpl_core.dependency_injection import ServiceProviderABC, ServiceCollectionABC from cpl_core.environment import ApplicationEnvironment +from cpl_core.pipes.version_pipe import VersionPipe from set_version.git_service import GitService from set_version.version_setter_service import VersionSetterService @@ -25,5 +26,6 @@ class Startup(StartupABC): def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC: services.add_transient(GitService) services.add_transient(VersionSetterService) + services.add_transient(VersionPipe) return services.build_service_provider()