2022-05-25 16:43:28 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
from cpl_cli.configuration import WorkspaceSettings
|
2022-05-25 13:43:16 +02:00
|
|
|
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
|
2022-05-25 16:43:28 +02:00
|
|
|
from set_version.git_service import GitService
|
|
|
|
from set_version.version_setter_service import VersionSetterService
|
2022-05-25 13:43:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Startup(StartupABC):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
StartupABC.__init__(self)
|
|
|
|
|
|
|
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
2022-05-25 16:43:28 +02:00
|
|
|
configuration.add_json_file('cpl-workspace.json', optional=True, output=False)
|
|
|
|
if configuration.get_configuration(WorkspaceSettings) is None:
|
|
|
|
environment.set_working_directory(os.path.join(environment.working_directory, '../../'))
|
|
|
|
configuration.add_json_file('cpl-workspace.json', optional=False, output=False)
|
|
|
|
|
2022-05-25 13:43:16 +02:00
|
|
|
return configuration
|
|
|
|
|
|
|
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
2022-05-25 16:43:28 +02:00
|
|
|
services.add_transient(GitService)
|
|
|
|
services.add_transient(VersionSetterService)
|
|
|
|
|
2022-05-25 13:43:16 +02:00
|
|
|
return services.build_service_provider()
|