2022.6.15 - set-version #81

Merged
edraft merged 19 commits from 2022.6.15 into 2022.6 2022-05-25 19:10:35 +02:00
59 changed files with 330 additions and 158 deletions

View File

@ -1,70 +1,74 @@
{
"WorkspaceSettings": {
"DefaultProject": "cpl_cli",
"DefaultProject": "cpl-cli",
"Projects": {
"cpl_core": "src/cpl_core/cpl_core.json",
"cpl_cli": "src/cpl_cli/cpl_cli.json",
"cpl_query": "src/cpl_query/cpl_query.json",
"cpl-core": "src/cpl_core/cpl-core.json",
"cpl-cli": "src/cpl_cli/cpl-cli.json",
"cpl-query": "src/cpl_query/cpl-query.json",
"set-version": "tools/set_version/set-version.json"
},
"Scripts": {
"hello-world": "echo 'Hello World'",
"sv": "cpl set-version",
"set-version": "echo 'Set versions for all projects'; cpl run set-version; echo '';",
"set-version": "cpl run set-version $ARGS; echo '';",
"docs-build": "echo 'Build Documentation'; cd docs/; sphinx-apidoc -o source/ ../src/cpl_core; sphinx-apidoc -o source/ ../src/cpl_query; make clean; make html; rm source/cpl_query.tests.rst;",
"db": "cpl build-docs",
"docs-open": "xdg-open $PWD/docs/build/html/index.html &",
"do": "cpl docs-open",
"pre-build-all": "cpl sv",
"build-all": "cpl build-cli; cpl build-core; cpl build-query;",
"ba": "cpl build-all",
"build-cli": "echo 'Build cpl_cli'; cd ./src/cpl_cli; cpl build; cd ../../;",
"build-core": "echo 'Build cpl_core'; cd ./src/cpl_core; cpl build; cd ../../;",
"build-query": "echo 'Build cpl_query'; cd ./src/cpl_query; cpl build; cd ../../;",
"pre-build-all": "cpl sv $ARGS",
"build-all": "cpl build-cli; cpl build-core; cpl build-query; cpl build-set-version",
"ba": "cpl build-all $ARGS",
"build-cli": "echo 'Build cpl-cli'; cd ./src/cpl_cli; cpl build; cd ../../;",
"build-core": "echo 'Build cpl-core'; cd ./src/cpl_core; cpl build; cd ../../;",
"build-query": "echo 'Build cpl-query'; cd ./src/cpl_query; cpl build; cd ../../;",
"build-set-version": "echo 'Build set-version'; cd ./tools/set_version; cpl build; cd ../../;",
"pre-publish-all": "cpl sv",
"pre-publish-all": "cpl sv $ARGS",
"publish-all": "cpl publish-cli; cpl publish-core; cpl publish-query;",
"pa": "cpl build-all",
"publish-cli": "echo 'Publish cpl_cli'; cd ./src/cpl_cli; cpl publish; cd ../../;",
"publish-core": "echo 'Publish cpl_core'; cd ./src/cpl_core; cpl publish; cd ../../;",
"pa": "cpl build-all $ARGS",
"publish-cli": "echo 'Publish cpl-cli'; cd ./src/cpl_cli; cpl publish; cd ../../;",
"publish-core": "echo 'Publish cpl-core'; cd ./src/cpl_core; cpl publish; cd ../../;",
"publish-query": "echo 'Publish cpl_query'; cd ./src/cpl_query; cpl publish; cd ../../;",
"upload-prod-cli": "echo 'PROD Upload cpl_cli'; cpl upl-prod-cli;",
"upload-prod-cli": "echo 'PROD Upload cpl-cli'; cpl upl-prod-cli;",
"upl-prod-cli": "twine upload -r pip.sh-edraft.de dist/cpl-cli/publish/setup/*",
"upload-prod-core": "echo 'PROD Upload cpl_core'; cpl upl-prod-core;",
"upload-prod-core": "echo 'PROD Upload cpl-core'; cpl upl-prod-core;",
"upl-prod-core": "twine upload -r pip.sh-edraft.de dist/cpl-core/publish/setup/*",
"upload-prod-query": "echo 'PROD Upload cpl_query'; cpl upl-prod-query;",
"upl-prod-query": "twine upload -r pip.sh-edraft.de dist/cpl-query/publish/setup/*",
"upload-exp-cli": "echo 'EXP Upload cpl_cli'; cpl upl-exp-cli;",
"upload-exp-cli": "echo 'EXP Upload cpl-cli'; cpl upl-exp-cli;",
"upl-exp-cli": "twine upload -r pip-exp.sh-edraft.de dist/cpl-cli/publish/setup/*",
"upload-exp-core": "echo 'EXP Upload cpl_core'; cpl upl-exp-core;",
"upload-exp-core": "echo 'EXP Upload cpl-core'; cpl upl-exp-core;",
"upl-exp-core": "twine upload -r pip-exp.sh-edraft.de dist/cpl-core/publish/setup/*",
"upload-exp-query": "echo 'EXP Upload cpl_query'; cpl upl-exp-query;",
"upl-exp-query": "twine upload -r pip-exp.sh-edraft.de dist/cpl-query/publish/setup/*",
"upload-dev-cli": "echo 'DEV Upload cpl_cli'; cpl upl-dev-cli;",
"upload-dev-cli": "echo 'DEV Upload cpl-cli'; cpl upl-dev-cli;",
"upl-dev-cli": "twine upload -r pip-dev.sh-edraft.de dist/cpl-cli/publish/setup/*",
"upload-dev-core": "echo 'DEV Upload cpl_core'; cpl upl-dev-core;",
"upload-dev-core": "echo 'DEV Upload cpl-core'; cpl upl-dev-core;",
"upl-dev-core": "twine upload -r pip-dev.sh-edraft.de dist/cpl-core/publish/setup/*",
"upload-dev-query": "echo 'DEV Upload cpl_query'; cpl upl-dev-query;",
"upl-dev-query": "twine upload -r pip-dev.sh-edraft.de dist/cpl-query/publish/setup/*",
"pre-deploy-prod": "cpl sv $ARGS",
"deploy-prod": "cpl deploy-prod-cli; cpl deploy-prod-core; cpl deploy-prod-query;",
"dp": "cpl deploy-prod",
"dp": "cpl deploy-prod $ARGS",
"deploy-prod-cli": "cpl publish-cli; cpl upload-prod-cli",
"deploy-prod-core": "cpl publish-core; cpl upload-prod-core",
"deploy-prod-query": "cpl publish-query; cpl upload-prod-query",
"pre-deploy-exp": "cpl sv $ARGS",
"deploy-exp": "cpl deploy-exp-cli; cpl deploy-exp-core; cpl deploy-exp-query;",
"de": "cpl deploy-exp",
"de": "cpl deploy-exp $ARGS",
"deploy-exp-cli": "cpl publish-cli; cpl upload-exp-cli",
"deploy-exp-core": "cpl publish-core; cpl upload-exp-core",
"deploy-exp-query": "cpl publish-query; cpl upload-exp-query",
"pre-deploy-dev": "cpl sv $ARGS",
"deploy-dev": "cpl deploy-dev-cli; cpl deploy-dev-core; cpl deploy-dev-query;",
"dd": "cpl deploy-dev",
"dd": "cpl deploy-dev $ARGS",
"deploy-dev-cli": "cpl publish-cli; cpl upload-dev-cli",
"deploy-dev-core": "cpl publish-core; cpl upload-dev-core",
"deploy-dev-query": "cpl publish-query; cpl upload-dev-query"

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -27,4 +27,4 @@ from .main import main
from .startup import Startup
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.build'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.generate'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.console.source.tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.name'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.new.library.source.tests'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli._templates.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -1,5 +1,5 @@
{
"CLI": {
"PipPath": "https://pip.sh-edraft.de"
"PipPath": "https://pip-dev.sh-edraft.de"
}
}

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
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='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -35,7 +35,15 @@ class CustomScriptService(CommandABC):
if script != cmd:
continue
command = self._workspace.scripts[script]
command = ''
external_args = self._config.get_configuration('ARGS')
if external_args is not None:
command += f'ARGS="{external_args}";'
command += self._workspace.scripts[script]
env_vars = os.environ
env_vars['CPL_ARGS'] = " ".join(args)
try:
subprocess.run(command, shell=True if os.name == 'posix' else None)
except Exception as e:

View File

@ -137,7 +137,7 @@ class GenerateService(CommandABC):
rel_path = '/'.join(parts[:-1])
class_name = parts[len(parts) - 1]
if 'src' not in rel_path:
if 'src' not in rel_path and not os.path.exists(os.path.join(self._env.working_directory, rel_path)):
rel_path = f'src/{rel_path}'
template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path)
@ -192,6 +192,7 @@ class GenerateService(CommandABC):
if schematic is None:
self._help('Usage: cpl generate <schematic> [options]')
Console.write_line()
sys.exit()
name = value
@ -204,4 +205,5 @@ class GenerateService(CommandABC):
else:
self._help('Usage: cpl generate <schematic> [options]')
Console.write_line()
sys.exit()

View File

@ -38,7 +38,7 @@ class InstallService(CommandABC):
self._build_settings = build_settings
self._project_settings = project_settings
self._cli_settings = cli_settings
self._is_simulation = False
self._is_virtual = False
@ -53,7 +53,7 @@ class InstallService(CommandABC):
Arguments:
package The package to install
""")
def _wait(self, t: int, *args, source: str = None, stdout=None, stderr=None):
time.sleep(t)
@ -77,7 +77,7 @@ class InstallService(CommandABC):
Console.spinner(
f'Installing: {dependency}',
Pip.install if not self._is_virtual else self._wait, dependency if not self._is_virtual else 2,
source=self._cli_settings.pip_path if 'sh_cpl' in dependency else None,
source=self._cli_settings.pip_path if 'cpl-' in dependency else None,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text_foreground_color=ForegroundColorEnum.green,
@ -140,13 +140,13 @@ class InstallService(CommandABC):
Console.spinner(
f'Installing: {package}',
Pip.install if not self._is_virtual else self._wait, package if not self._is_virtual else 2,
source=self._cli_settings.pip_path if 'sh_cpl' in package else None,
source=self._cli_settings.pip_path if 'cpl-' in package else None,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text_foreground_color=ForegroundColorEnum.green,
spinner_foreground_color=ForegroundColorEnum.cyan
)
if self._is_virtual:
new_package = name
else:
@ -177,7 +177,7 @@ class InstallService(CommandABC):
ProjectSettings.__name__: SettingsHelper.get_project_settings_dict(self._project_settings),
BuildSettings.__name__: SettingsHelper.get_build_settings_dict(self._build_settings)
}
with open(os.path.join(self._env.working_directory, self._project_file), 'w') as project_file:
project_file.write(json.dumps(config, indent=2))
project_file.close()
@ -194,7 +194,7 @@ class InstallService(CommandABC):
self._is_virtual = True
args.remove('virtual')
Console.write_line('Running in virtual mode:')
if 'simulate' in args:
self._is_simulation = True
args.remove('simulate')

View File

@ -99,7 +99,7 @@ class NewService(CommandABC):
ProjectSettingsNameEnum.license_name.value: '',
ProjectSettingsNameEnum.license_description.value: '',
ProjectSettingsNameEnum.dependencies.value: [
f'sh_cpl-core>={version.parse(cpl_core.__version__)}'
f'cpl-core>={version.parse(cpl_core.__version__)}'
],
ProjectSettingsNameEnum.python_version.value: f'>={sys.version.split(" ")[0]}',
ProjectSettingsNameEnum.python_path.value: {

View File

@ -86,11 +86,7 @@ class RunService(CommandABC):
:param args:
:return:
"""
if len(args) > 1:
Error.error(f'Unexpected argument(s): {", ".join(args)}')
sys.exit()
if len(args) == 1:
if len(args) >= 1:
self._set_project_by_args(args[0])
args.remove(args[0])

View File

@ -73,7 +73,7 @@ class UpdateService(CommandABC):
'--upgrade',
'--upgrade-strategy',
'eager',
source=self._cli_settings.pip_path if 'sh_cpl' in name else None,
source=self._cli_settings.pip_path if 'cpl-' in name else None,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -30,4 +30,4 @@ from .workspace_settings import WorkspaceSettings
from .workspace_settings_name_enum import WorkspaceSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "14.dev1"
"Micro": "15.dev6"
},
"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.14.dev1"
"cpl-core>=2022.6.15.dev6"
],
"PythonVersion": ">=3.10",
"PythonPath": {},

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.live_server'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_cli.publish'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
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='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.source_creator'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -74,7 +74,7 @@ class StartupArgumentExtension(StartupExtensionABC):
.add_console_argument(ArgumentTypeEnum.Variable, '', 'abc', ['a', 'A'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'class', ['c', 'C'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'enum', ['e', 'E'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'pipes', ['p', 'P'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'pipe', ['p', 'P'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'service', ['s', 'S'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'settings', ['st', 'ST'], ' ') \
.add_console_argument(ArgumentTypeEnum.Variable, '', 'thread', ['t', 'T'], ' ') \

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_cli.validators'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_core'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.application'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -28,4 +28,4 @@ from .startup_abc import StartupABC
from .startup_extension_abc import StartupExtensionABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -34,4 +34,4 @@ from .validator_abc import ValidatorABC
from .variable_argument import VariableArgument
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.console'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -27,4 +27,4 @@ from .foreground_color_enum import ForegroundColorEnum
from .spinner_thread import SpinnerThread
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "14.dev1"
"Micro": "15.dev6"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.database'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -25,4 +25,4 @@ from .database_settings import DatabaseSettings
from .table_abc import TableABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.database.connection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -24,4 +24,4 @@ from .database_connection import DatabaseConnection
from .database_connection_abc import DatabaseConnectionABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.database.context'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -24,4 +24,4 @@ from .database_context import DatabaseContext
from .database_context_abc import DatabaseContextABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.dependency_injection'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -30,4 +30,4 @@ from .service_provider import ServiceProvider
from .service_provider_abc import ServiceProviderABC
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -1,6 +1,7 @@
from typing import Union, Type, Callable, Optional
from cpl_core.configuration.configuration_abc import ConfigurationABC
from cpl_core.console import Console
from cpl_core.database.context.database_context_abc import DatabaseContextABC
from cpl_core.database.database_settings import DatabaseSettings
from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC
@ -10,6 +11,7 @@ from cpl_core.dependency_injection.service_provider import ServiceProvider
from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC
from cpl_core.logging.logger_abc import LoggerABC
from cpl_core.logging.logger_service import Logger
from cpl_core.pipes.pipe_abc import PipeABC
class ServiceCollection(ServiceCollectionABC):
@ -53,6 +55,10 @@ class ServiceCollection(ServiceCollectionABC):
def add_logging(self):
self.add_singleton(LoggerABC, Logger)
def add_pipes(self):
for pipe in PipeABC.__subclasses__():
self.add_transient(PipeABC, pipe)
def add_singleton(self, service_type: Union[type, object], service: Union[type, object] = None):
self._add_descriptor_by_lifetime(service_type, ServiceLifetimeEnum.singleton, service)
return self

View File

@ -30,6 +30,11 @@ class ServiceCollectionABC(ABC):
r"""Adds the CPL internal logger"""
pass
@abstractmethod
def add_pipes(self):
r"""Adds the CPL internal pipes as transient"""
pass
@abstractmethod
def add_transient(self, service_type: Type, service: Callable = None) -> 'ServiceCollectionABC':
r"""Adds a service with transient lifetime

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.environment'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -25,4 +25,4 @@ from .environment_name_enum import EnvironmentNameEnum
from .application_environment import ApplicationEnvironment
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.logging'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -27,4 +27,4 @@ from .logging_settings import LoggingSettings
from .logging_settings_name_enum import LoggingSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.mailing'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -27,4 +27,4 @@ from .email_client_settings import EMailClientSettings
from .email_client_settings_name_enum import EMailClientSettingsNameEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.pipes'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -29,4 +29,4 @@ from .to_camel_case_pipe import ToCamelCasePipe
from .to_snake_case_pipe import ToSnakeCasePipe
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -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]}'

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.time'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -24,4 +24,4 @@ from .time_format_settings import TimeFormatSettings
from .time_format_settings_names_enum import TimeFormatSettingsNamesEnum
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_core.utils'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -25,4 +25,4 @@ from .string import String
from .pip import Pip
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_query'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -15,11 +15,11 @@ __title__ = 'cpl_query._query'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "2022",
"Minor": "6",
"Micro": "14.dev1"
"Micro": "15.dev6"
},
"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.14.dev1"
"cpl-core>=2022.6.15.dev6"
],
"PythonVersion": ">=3.10",
"PythonPath": {},

View File

@ -15,7 +15,7 @@ __title__ = 'cpl_query.extension'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6.14.dev1'
__version__ = '2022.6.15.dev6'
from collections import namedtuple
@ -27,4 +27,4 @@ from .ordered_iterable_abc import OrderedIterableABC
from .ordered_iterable import OrderedIterable
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='14.dev1')
version_info = VersionInfo(major='2022', minor='6', micro='15.dev6')

View File

@ -1 +1,25 @@
# -*- coding: utf-8 -*-
"""
set-version CPL internal tool to set version from branch name
~~~~~~~~~~~~~~~~~~~
CPL internal tool to set version from branch name
:copyright: (c) 2020 - 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'set_version'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2020 - 2022 sh-edraft.de'
__version__ = '2022.6'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='2022', minor='6', micro='None')

View File

@ -1,7 +1,14 @@
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
import traceback
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
class Application(ApplicationABC):
@ -9,8 +16,52 @@ class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
self._workspace: WorkspaceSettings = config.get_configuration(WorkspaceSettings)
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):
pass
self._configuration.parse_console_arguments(self._services)
def main(self):
Console.write_line('Hello World from tools')
Console.write_line('Set versions:')
args = self._configuration.additional_arguments
version = {}
branch = ""
suffix = ""
if len(args) > 1:
Console.error(f'Unexpected argument(s): {", ".join(args[1:])}')
return
if len(args) == 1:
suffix = f'.{args[0]}'
try:
branch = self._git_service.get_active_branch_name()
Console.write_line(f'Found branch: {branch}')
except Exception as e:
Console.error('Branch could not be found', traceback.format_exc())
return
try:
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
try:
for project in self._workspace.projects:
Console.write_line(f'Set dependencies {self._version_pipe.transform(version)} for {project}')
self._version_setter.set_dependencies(self._workspace.projects[project], version)
if not project.startswith('cpl'):
continue
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())
return

View File

@ -1,15 +0,0 @@
{
"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": "logs/",
"Filename": "log_$start_time.log",
"ConsoleLogLevel": "ERROR",
"FileLogLevel": "WARN"
}
}

View File

@ -0,0 +1,18 @@
import os
from cpl_core.environment import ApplicationEnvironmentABC
class GitService:
def __init__(self, env: ApplicationEnvironmentABC):
self._env = env
def get_active_branch_name(self) -> str:
head_dir = os.path.join(self._env.working_directory, '.git/HEAD')
with open(head_dir, 'r') as f:
content = f.read().splitlines()
for line in content:
if line[0:4] == "ref:":
return line.partition("refs/heads/")[2]

View File

@ -2,26 +2,24 @@
"ProjectSettings": {
"Name": "set-version",
"Version": {
"Major": "0",
"Minor": "0",
"Micro": "0"
"Major": "2022",
"Minor": "6",
"Micro": ""
},
"Author": "",
"AuthorEmail": "",
"Description": "",
"LongDescription": "",
"URL": "",
"CopyrightDate": "",
"CopyrightName": "",
"LicenseName": "",
"LicenseDescription": "",
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",
"Description": "CPL internal tool to set version from branch name",
"LongDescription": "CPL internal tool to set version from branch name",
"URL": "https://www.sh-edraft.de",
"CopyrightDate": "2020 - 2022",
"CopyrightName": "sh-edraft.de",
"LicenseName": "MIT",
"LicenseDescription": "MIT, see LICENSE for more details.",
"Dependencies": [
"sh_cpl-core>=2022.6.1.dev4"
"cpl-core>=2022.6.15.dev6"
],
"PythonVersion": ">=3.10.4",
"PythonPath": {
"linux": ""
},
"PythonPath": {},
"Classifiers": []
},
"BuildSettings": {

View File

@ -1,7 +1,13 @@
import os
from cpl_cli.configuration import WorkspaceSettings
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
class Startup(StartupABC):
@ -10,7 +16,16 @@ class Startup(StartupABC):
StartupABC.__init__(self)
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
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)
return configuration
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
services.add_pipes()
services.add_transient(GitService)
services.add_transient(VersionSetterService)
return services.build_service_provider()

View File

@ -0,0 +1,46 @@
import json
import os
from cpl_core.console import Console
from cpl_core.environment import ApplicationEnvironmentABC
class VersionSetterService:
def __init__(self, env: ApplicationEnvironmentABC):
self._env = env
def _read_file(self, file: str) -> dict:
project_json = {}
with open(os.path.join(self._env.working_directory, file), 'r', encoding='utf-8') as f:
# load json
project_json = json.load(f)
f.close()
return project_json
def _write_file(self, file: str, project_json: dict):
with open(os.path.join(self._env.working_directory, file), 'w', encoding='utf-8') as f:
f.write(json.dumps(project_json, indent=2))
f.close()
def set_version(self, file: str, version: dict):
project_json = self._read_file(file)
project_json['ProjectSettings']['Version'] = version
self._write_file(file, project_json)
def set_dependencies(self, file: str, version: dict):
project_json = self._read_file(file)
dependencies = project_json['ProjectSettings']['Dependencies']
new_deps = []
for dependency in dependencies:
if not dependency.startswith('cpl-'):
new_deps.append(dependency)
continue
dep_version = dependency.split('=')[1]
new_deps.append(dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}'))
project_json['ProjectSettings']['Dependencies'] = new_deps
self._write_file(file, project_json)