Improved new project templates & publish 2021.4.2.dev1
This commit is contained in:
@@ -15,7 +15,7 @@ __title__ = 'sh_cpl.cpl_cli'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -29,4 +29,4 @@ from .main import main
|
||||
from .startup import Startup
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -28,4 +28,4 @@ from .publish_service import PublishService
|
||||
from .version_service import VersionService
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -20,7 +20,7 @@ from cpl_cli.templates.new.console.license import LicenseTemplate
|
||||
from cpl_cli.templates.new.console.readme_py import ReadmeTemplate
|
||||
from cpl_cli.templates.new.console.src.application import ApplicationTemplate
|
||||
from cpl_cli.templates.new.console.src.main import MainWithApplicationHostAndStartupTemplate, \
|
||||
MainWithoutApplicationHostTemplate, MainWithApplicationHostTemplate
|
||||
MainWithoutApplicationBaseTemplate, MainWithApplicationBaseTemplate, MainWithDependencyInjection
|
||||
from cpl_cli.templates.new.console.src.startup import StartupTemplate
|
||||
from cpl_cli.templates.new.console.src.tests.init import TestsInitTemplate
|
||||
from cpl_cli.templates.template_file_abc import TemplateFileABC
|
||||
@@ -133,27 +133,26 @@ class NewService(CommandABC):
|
||||
|
||||
return project_path
|
||||
|
||||
def _get_project_informations(self):
|
||||
def _get_project_information(self):
|
||||
"""
|
||||
Gets project informations from user
|
||||
Gets project information's from user
|
||||
:return:
|
||||
"""
|
||||
result = Console.read('Do you want to use application host? (y/n) ')
|
||||
result = Console.read('Do you want to use application base? (y/n) ')
|
||||
if result.lower() == 'y':
|
||||
self._use_application_api = True
|
||||
|
||||
if self._use_application_api:
|
||||
result = Console.read('Do you want to use startup? (y/n) ')
|
||||
if result.lower() == 'y':
|
||||
self._use_startup = True
|
||||
result = Console.read('Do you want to use service providing? (y/n) ')
|
||||
if result.lower() == 'y':
|
||||
self._use_service_providing = True
|
||||
|
||||
if self._use_application_api:
|
||||
result = Console.read('Do you want to use startup? (y/n) ')
|
||||
if result.lower() == 'y':
|
||||
self._use_startup = True
|
||||
|
||||
Console.set_foreground_color(ForegroundColorEnum.default)
|
||||
|
||||
# else:
|
||||
# result = Console.read('Do you want to use service providing? (y/n) ')
|
||||
# if result.lower() == 'y':
|
||||
# self._use_service_providing = True
|
||||
|
||||
def _build_project_dir(self, project_path: str):
|
||||
"""
|
||||
Builds the project files
|
||||
@@ -172,15 +171,20 @@ class NewService(CommandABC):
|
||||
ReadmeTemplate(),
|
||||
TestsInitTemplate()
|
||||
]
|
||||
|
||||
if self._use_application_api:
|
||||
templates.append(ApplicationTemplate())
|
||||
|
||||
if self._use_startup:
|
||||
templates.append(StartupTemplate())
|
||||
templates.append(MainWithApplicationHostAndStartupTemplate())
|
||||
else:
|
||||
templates.append(MainWithApplicationHostTemplate())
|
||||
templates.append(MainWithApplicationBaseTemplate())
|
||||
else:
|
||||
templates.append(MainWithoutApplicationHostTemplate())
|
||||
if self._use_service_providing:
|
||||
templates.append(MainWithDependencyInjection())
|
||||
else:
|
||||
templates.append(MainWithoutApplicationBaseTemplate())
|
||||
|
||||
for template in templates:
|
||||
Console.spinner(
|
||||
@@ -225,7 +229,7 @@ class NewService(CommandABC):
|
||||
if path is None:
|
||||
return
|
||||
|
||||
self._get_project_informations()
|
||||
self._get_project_information()
|
||||
try:
|
||||
self._build_project_dir(path)
|
||||
except Exception as e:
|
||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -28,4 +28,4 @@ from .version_settings import VersionSettings
|
||||
from .version_settings_name_enum import VersionSettingsNameEnum
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
@@ -24,4 +24,4 @@ from .publisher_abc import PublisherABC
|
||||
from .publisher_service import PublisherService
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.build'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.generate'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -11,7 +11,7 @@ class ApplicationTemplate(TemplateFileABC):
|
||||
self._name = 'application.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import ApplicationABC, ApplicationRuntimeABC
|
||||
from cpl.application import ApplicationABC
|
||||
from cpl.configuration import ConfigurationABC
|
||||
from cpl.console import Console
|
||||
from cpl.dependency_injection import ServiceProviderABC
|
||||
@@ -19,8 +19,8 @@ class ApplicationTemplate(TemplateFileABC):
|
||||
|
||||
class Application(ApplicationABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, runtime, services)
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
ApplicationABC.__init__(self, config, services)
|
||||
|
||||
def configure(self):
|
||||
pass
|
||||
|
@@ -40,7 +40,7 @@ class MainWithApplicationHostAndStartupTemplate(TemplateFileABC):
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithApplicationHostTemplate(TemplateFileABC):
|
||||
class MainWithApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
@@ -75,7 +75,7 @@ class MainWithApplicationHostTemplate(TemplateFileABC):
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithoutApplicationHostTemplate(TemplateFileABC):
|
||||
class MainWithoutApplicationBaseTemplate(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
@@ -105,3 +105,49 @@ class MainWithoutApplicationHostTemplate(TemplateFileABC):
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
||||
|
||||
class MainWithDependencyInjection(TemplateFileABC):
|
||||
|
||||
def __init__(self):
|
||||
TemplateFileABC.__init__(self)
|
||||
|
||||
self._name = 'main.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.configuration import Configuration, ConfigurationABC
|
||||
from cpl.console import Console
|
||||
from cpl.dependency_injection import ServiceCollection, ServiceProviderABC
|
||||
|
||||
|
||||
def configure_configuration() -> ConfigurationABC:
|
||||
config = Configuration()
|
||||
return config
|
||||
|
||||
|
||||
def configure_services(config: ConfigurationABC) -> ServiceProviderABC:
|
||||
services = ServiceCollection(config)
|
||||
return services.build_service_provider()
|
||||
|
||||
|
||||
def main():
|
||||
config = configure_configuration()
|
||||
provider = configure_services(config)
|
||||
Console.write_line('Hello World')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
""")
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def path(self) -> str:
|
||||
return self._path
|
||||
|
||||
@property
|
||||
def value(self) -> str:
|
||||
return self._value
|
||||
|
@@ -11,18 +11,18 @@ class StartupTemplate(TemplateFileABC):
|
||||
self._name = 'startup.py'
|
||||
self._path = 'src/'
|
||||
self._value = textwrap.dedent("""\
|
||||
from cpl.application import ApplicationRuntimeABC, StartupABC
|
||||
from cpl.application import StartupABC
|
||||
from cpl.configuration import ConfigurationABC
|
||||
from cpl.dependency_injection import ServiceProviderABC
|
||||
|
||||
|
||||
class Startup(StartupABC):
|
||||
|
||||
def __init__(self, config: ConfigurationABC, runtime: ApplicationRuntimeABC, services: ServiceProviderABC):
|
||||
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
||||
StartupABC.__init__(self)
|
||||
|
||||
self._configuration = config
|
||||
self._application_runtime = runtime
|
||||
self._environment = self._configuration.environment
|
||||
self._services = services
|
||||
|
||||
def configure_configuration(self) -> ConfigurationABC:
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.new.console.src.tests'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
@@ -15,11 +15,11 @@ __title__ = 'cpl_cli.templates.publish'
|
||||
__author__ = 'Sven Heidemann'
|
||||
__license__ = 'MIT'
|
||||
__copyright__ = 'Copyright (c) 2020 - 2021 sh-edraft.de'
|
||||
__version__ = '2021.4.2'
|
||||
__version__ = '2021.4.2.dev1'
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
# imports:
|
||||
|
||||
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02')
|
||||
version_info = VersionInfo(major='2021', minor='04', micro='02.dev1')
|
||||
|
Reference in New Issue
Block a user