Improved publish process
This commit is contained in:
parent
3374ffe8db
commit
9e3c631ac4
65
src/build.json
Normal file
65
src/build.json
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"TimeFormatSettings": {
|
||||||
|
"DateFormat": "%Y-%m-%d",
|
||||||
|
"TimeFormat": "%H:%M:%S",
|
||||||
|
"DateTimeFormat": "%Y-%m-%d %H:%M:%S.%f",
|
||||||
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
|
},
|
||||||
|
"LoggingSettings": {
|
||||||
|
"Path": "../build/logs/",
|
||||||
|
"Filename": "log_$start_time.log",
|
||||||
|
"ConsoleLogLevel": "INFO",
|
||||||
|
"FileLogLevel": "TRACE"
|
||||||
|
},
|
||||||
|
"PublishSettings": {
|
||||||
|
"SourcePath": "./",
|
||||||
|
"DistPath": "../build/dist",
|
||||||
|
"Templates": [
|
||||||
|
{
|
||||||
|
"TemplatePath": "../publish_templates/all_template.txt",
|
||||||
|
"Name": "all",
|
||||||
|
"Description": "",
|
||||||
|
"LongDescription": "",
|
||||||
|
"CopyrightDate": "2020",
|
||||||
|
"CopyrightName": "sh-edraft.de",
|
||||||
|
"LicenseName": "MIT",
|
||||||
|
"LicenseDescription": ", see LICENSE for more details.",
|
||||||
|
"Title": "",
|
||||||
|
"Author": "Sven Heidemann",
|
||||||
|
"Version": {
|
||||||
|
"Major": 2020,
|
||||||
|
"Minor": 12,
|
||||||
|
"Micro": 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"TemplatePath": "../publish_templates/all_template.txt",
|
||||||
|
"Name": "sh_edraft",
|
||||||
|
"Description": "common python library",
|
||||||
|
"LongDescription": "Library to share common classes and models used at sh-edraft.de",
|
||||||
|
"CopyrightDate": "2020",
|
||||||
|
"CopyrightName": "sh-edraft.de",
|
||||||
|
"LicenseName": "MIT",
|
||||||
|
"LicenseDescription": ", see LICENSE for more details.",
|
||||||
|
"Title": "",
|
||||||
|
"Author": "Sven Heidemann",
|
||||||
|
"Version": {
|
||||||
|
"Major": 2020,
|
||||||
|
"Minor": 12,
|
||||||
|
"Micro": 9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"IncludedFiles": [
|
||||||
|
"../LICENSE",
|
||||||
|
"../README.md",
|
||||||
|
"../requirements.txt",
|
||||||
|
"sh_edraft/cli/cpl_cli/templates"
|
||||||
|
],
|
||||||
|
"ExcludedFiles": [
|
||||||
|
"./tests",
|
||||||
|
"./tests_dev"
|
||||||
|
],
|
||||||
|
"TemplateEnding": "_template.txt"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_edraft.cli.command
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:copyright: (c) 2020 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'sh_edraft.cli.command'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||||
|
__version__ = '2020.12.9'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_edraft.cli.command.base
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:copyright: (c) 2020 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'sh_edraft.cli.command.base'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||||
|
__version__ = '2020.12.9'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_edraft.cli.cpl_cli
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:copyright: (c) 2020 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'sh_edraft.cli.cpl_cli'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||||
|
__version__ = '2020.12.9'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
@ -2,49 +2,21 @@ import sys
|
|||||||
import traceback
|
import traceback
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from sh_edraft.cli.cpl_cli.commands.build import Build
|
from sh_edraft.cli.cpl_cli.commands.build.build import Build
|
||||||
from sh_edraft.cli.cpl_cli.commands.help import Help
|
from sh_edraft.cli.cpl_cli.commands.help import Help
|
||||||
from sh_edraft.cli.cpl_cli.commands.new import New
|
from sh_edraft.cli.cpl_cli.commands.new import New
|
||||||
from sh_edraft.cli.cpl_cli.commands.version import Version
|
from sh_edraft.cli.cpl_cli.commands.version import Version
|
||||||
from sh_edraft.cli.interpreter.interpreter import Interpreter
|
from sh_edraft.cli.interpreter.interpreter import Interpreter
|
||||||
from sh_edraft.configuration.base import ConfigurationBase
|
|
||||||
from sh_edraft.console.console import Console
|
from sh_edraft.console.console import Console
|
||||||
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.service_provider import ServiceProviderBase
|
|
||||||
|
|
||||||
|
|
||||||
class CLI(ApplicationBase):
|
class CLI:
|
||||||
|
|
||||||
def __init__(self):
|
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._interpreter = Interpreter()
|
self._interpreter = Interpreter()
|
||||||
|
|
||||||
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'project.json')
|
|
||||||
|
|
||||||
def create_services(self):
|
|
||||||
self._services.add_singleton(LoggerBase, Logger)
|
|
||||||
self._logger = self._services.get_service(LoggerBase)
|
|
||||||
self._services.add_singleton(PublisherBase, Publisher)
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self._interpreter.add_command(Build(self._services, self._configuration))
|
self._interpreter.add_command(Build())
|
||||||
self._interpreter.add_command(Help())
|
self._interpreter.add_command(Help())
|
||||||
self._interpreter.add_command(New())
|
self._interpreter.add_command(New())
|
||||||
self._interpreter.add_command(Version())
|
self._interpreter.add_command(Version())
|
||||||
@ -61,9 +33,6 @@ class CLI(ApplicationBase):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
cli = CLI()
|
cli = CLI()
|
||||||
cli.create_application_host()
|
|
||||||
cli.create_configuration()
|
|
||||||
cli.create_services()
|
|
||||||
cli.setup()
|
cli.setup()
|
||||||
cli.main()
|
cli.main()
|
||||||
|
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_edraft.cli.cpl_cli.commands
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:copyright: (c) 2020 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'sh_edraft.cli.cpl_cli.commands'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||||
|
__version__ = '2020.12.9'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
@ -1,26 +0,0 @@
|
|||||||
from sh_edraft.cli.command.base.command_base import CommandBase
|
|
||||||
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
|
|
||||||
from sh_edraft.console.console import Console
|
|
||||||
from sh_edraft.publishing.publisher import Publisher
|
|
||||||
from sh_edraft.publishing.base.publisher_base import PublisherBase
|
|
||||||
from sh_edraft.service.providing.service_provider import ServiceProviderBase
|
|
||||||
|
|
||||||
|
|
||||||
class Build(CommandBase):
|
|
||||||
|
|
||||||
def __init__(self, services: ServiceProviderBase, config: ConfigurationBase):
|
|
||||||
CommandBase.__init__(self)
|
|
||||||
self._services = services
|
|
||||||
self._config = config
|
|
||||||
|
|
||||||
self._aliases.append('-b')
|
|
||||||
self._aliases.append('-B')
|
|
||||||
self._publisher: Publisher = self._services.get_service(PublisherBase)
|
|
||||||
|
|
||||||
def run(self, args: list[str]):
|
|
||||||
if len(args) > 0:
|
|
||||||
Console.error(f'Invalid arguments {args}')
|
|
||||||
Console.error('Run \'cpl help\'')
|
|
||||||
|
|
||||||
self._publisher.create()
|
|
||||||
self._publisher.publish()
|
|
@ -6,14 +6,14 @@
|
|||||||
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
"DateTimeLogFormat": "%Y-%m-%d_%H-%M-%S"
|
||||||
},
|
},
|
||||||
"LoggingSettings": {
|
"LoggingSettings": {
|
||||||
"Path": "logs/",
|
"Path": "build/logs/",
|
||||||
"Filename": "log_$start_time.log",
|
"Filename": "log_$start_time.log",
|
||||||
"ConsoleLogLevel": "INFO",
|
"ConsoleLogLevel": "INFO",
|
||||||
"FileLogLevel": "TRACE"
|
"FileLogLevel": "INFO"
|
||||||
},
|
},
|
||||||
"PublishSettings": {
|
"PublishSettings": {
|
||||||
"SourcePath": "../",
|
"SourcePath": "./",
|
||||||
"DistPath": "../../../../dist",
|
"DistPath": "build/dist",
|
||||||
"Templates": [],
|
"Templates": [],
|
||||||
"IncludedFiles": [],
|
"IncludedFiles": [],
|
||||||
"ExcludedFiles": [],
|
"ExcludedFiles": [],
|
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
sh_edraft.cli.interpreter
|
||||||
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:copyright: (c) 2020 sh-edraft.de
|
||||||
|
:license: MIT, see LICENSE for more details.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
__title__ = 'sh_edraft.cli.interpreter'
|
||||||
|
__author__ = 'Sven Heidemann'
|
||||||
|
__license__ = 'MIT'
|
||||||
|
__copyright__ = 'Copyright (c) 2020 sh-edraft.de'
|
||||||
|
__version__ = '2020.12.9'
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
# imports:
|
||||||
|
|
||||||
|
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
|
||||||
|
version_info = VersionInfo(major=2020, minor=12, micro=9)
|
@ -48,7 +48,7 @@ class Logger(LoggerBase):
|
|||||||
try:
|
try:
|
||||||
# check if log file path exists
|
# check if log file path exists
|
||||||
if not os.path.exists(self._path):
|
if not os.path.exists(self._path):
|
||||||
os.mkdir(self._path)
|
os.makedirs(self._path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._fatal_console(__name__, 'Cannot create log dir', ex=e)
|
self._fatal_console(__name__, 'Cannot create log dir', ex=e)
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ class Publisher(PublisherBase):
|
|||||||
self._logger: LoggerBase = logger
|
self._logger: LoggerBase = logger
|
||||||
self._publish_settings: PublishSettings = publish_settings
|
self._publish_settings: PublishSettings = publish_settings
|
||||||
|
|
||||||
|
self._included_files: list[str] = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source_path(self) -> str:
|
def source_path(self) -> str:
|
||||||
return self._publish_settings.source_path
|
return self._publish_settings.source_path
|
||||||
@ -53,10 +55,31 @@ class Publisher(PublisherBase):
|
|||||||
|
|
||||||
def _read_source_path(self):
|
def _read_source_path(self):
|
||||||
self._logger.trace(__name__, f'Started {__name__}._read_source_path')
|
self._logger.trace(__name__, f'Started {__name__}._read_source_path')
|
||||||
|
included_files = self._publish_settings.included_files
|
||||||
|
for included in included_files:
|
||||||
|
if os.path.isdir(included):
|
||||||
|
self._publish_settings.included_files.remove(included)
|
||||||
|
|
||||||
|
for r, d, f in os.walk(included):
|
||||||
|
for file in f:
|
||||||
|
file_path = os.path.join(self._publish_settings.source_path, r, file)
|
||||||
|
if os.path.isfile(file_path):
|
||||||
|
self._included_files.append(file_path)
|
||||||
|
else:
|
||||||
|
self._logger.fatal(__name__, f'File not found: {file}')
|
||||||
|
|
||||||
for r, d, f in os.walk(self._publish_settings.source_path):
|
for r, d, f in os.walk(self._publish_settings.source_path):
|
||||||
for file in f:
|
for file in f:
|
||||||
if file.endswith('.py') or file in self._publish_settings.included_files:
|
is_file_excluded = False
|
||||||
self._publish_settings.included_files.append(os.path.join(r, file))
|
if os.path.join(r, file) in self._publish_settings.excluded_files:
|
||||||
|
is_file_excluded = True
|
||||||
|
else:
|
||||||
|
for excluded in self._publish_settings.excluded_files:
|
||||||
|
if os.path.join(r, file).__contains__(excluded):
|
||||||
|
is_file_excluded = True
|
||||||
|
|
||||||
|
if not is_file_excluded and file.endswith('.py') or file in self._publish_settings.included_files:
|
||||||
|
self._included_files.append(os.path.join(r, file))
|
||||||
|
|
||||||
self._logger.trace(__name__, f'Stopped {__name__}._read_source_path')
|
self._logger.trace(__name__, f'Stopped {__name__}._read_source_path')
|
||||||
|
|
||||||
@ -109,7 +132,7 @@ class Publisher(PublisherBase):
|
|||||||
def _write_templates(self):
|
def _write_templates(self):
|
||||||
self._logger.trace(__name__, f'Started {__name__}._write_templates')
|
self._logger.trace(__name__, f'Started {__name__}._write_templates')
|
||||||
for template in self._publish_settings.templates:
|
for template in self._publish_settings.templates:
|
||||||
for file in self._publish_settings.included_files:
|
for file in self._included_files:
|
||||||
if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files:
|
if os.path.basename(file) == '__init__.py' and file not in self._publish_settings.excluded_files:
|
||||||
template_name = template.name
|
template_name = template.name
|
||||||
if template.name == 'all' or template.name == '':
|
if template.name == 'all' or template.name == '':
|
||||||
@ -167,7 +190,7 @@ class Publisher(PublisherBase):
|
|||||||
if self._publish_settings.dist_path.endswith('/'):
|
if self._publish_settings.dist_path.endswith('/'):
|
||||||
dist_path = dist_path[:len(dist_path) - 1]
|
dist_path = dist_path[:len(dist_path) - 1]
|
||||||
|
|
||||||
for file in self._publish_settings.included_files:
|
for file in self._included_files:
|
||||||
is_file_excluded = False
|
is_file_excluded = False
|
||||||
if file in self._publish_settings.excluded_files:
|
if file in self._publish_settings.excluded_files:
|
||||||
is_file_excluded = True
|
is_file_excluded = True
|
||||||
|
Loading…
Reference in New Issue
Block a user