From c30f0e09add996b9d1b2ca0a9a37deae3a22921e Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 24 Dec 2020 13:31:36 +0100 Subject: [PATCH] Removed build form gitignore, added build command --- .gitignore | 1 - .../cli/cpl_cli/commands/build/app.py | 47 +++++++++++++++++++ .../cli/cpl_cli/commands/build/build.py | 23 +++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/sh_edraft/cli/cpl_cli/commands/build/app.py create mode 100644 src/sh_edraft/cli/cpl_cli/commands/build/build.py diff --git a/.gitignore b/.gitignore index 13d1490a..309949bc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ __pycache__/ # Distribution / packaging .Python -build/ develop-eggs/ dist/ downloads/ diff --git a/src/sh_edraft/cli/cpl_cli/commands/build/app.py b/src/sh_edraft/cli/cpl_cli/commands/build/app.py new file mode 100644 index 00000000..84577e8c --- /dev/null +++ b/src/sh_edraft/cli/cpl_cli/commands/build/app.py @@ -0,0 +1,47 @@ +from typing import Optional + +from sh_edraft.configuration.base.configuration_base import ConfigurationBase +from sh_edraft.hosting.application_host import ApplicationHost +from sh_edraft.hosting.base.application_base import ApplicationBase +from sh_edraft.logging.logger import Logger +from sh_edraft.logging.base.logger_base import LoggerBase +from sh_edraft.publishing.publisher import Publisher +from sh_edraft.publishing.base.publisher_base import PublisherBase +from sh_edraft.service.providing.base.service_provider_base import ServiceProviderBase + + +class BuildApp(ApplicationBase): + + def __init__(self): + ApplicationBase.__init__(self) + + self._app_host: Optional[ApplicationHost] = None + self._services: Optional[ServiceProviderBase] = None + self._configuration: Optional[ConfigurationBase] = None + self._logger: Optional[LoggerBase] = None + self._publisher: Optional[PublisherBase] = None + + def create_application_host(self): + self._app_host = ApplicationHost() + self._configuration = self._app_host.configuration + self._services = self._app_host.services + + def create_configuration(self): + self._configuration.add_json_file(f'build.json') + + def create_services(self): + # Add and create logger + self._services.add_singleton(LoggerBase, Logger) + self._logger = self._services.get_service(LoggerBase) + + # Add and create publisher + self._services.add_singleton(PublisherBase, Publisher) + self._publisher: Publisher = self._services.get_service(PublisherBase) + + def main(self): + self._logger.header(f'{self._configuration.environment.application_name}:') + self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}') + self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}') + self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}') + self._publisher.create() + self._publisher.build() diff --git a/src/sh_edraft/cli/cpl_cli/commands/build/build.py b/src/sh_edraft/cli/cpl_cli/commands/build/build.py new file mode 100644 index 00000000..f22eb436 --- /dev/null +++ b/src/sh_edraft/cli/cpl_cli/commands/build/build.py @@ -0,0 +1,23 @@ +from sh_edraft.cli.command.base.command_base import CommandBase +from sh_edraft.cli.cpl_cli.commands.build.app import BuildApp +from sh_edraft.console.console import Console + + +class Build(CommandBase): + + def __init__(self): + CommandBase.__init__(self) + self._app = BuildApp() + + self._aliases.append('-b') + self._aliases.append('-B') + + def run(self, args: list[str]): + if len(args) > 0: + Console.error(f'Invalid arguments {args}') + Console.error('Run \'cpl help\'') + + self._app.create_application_host() + self._app.create_configuration() + self._app.create_services() + self._app.main()