From fd2d30ee7f50cb21214d5f96059a6e244940f388 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Fri, 21 Oct 2022 12:45:46 +0200 Subject: [PATCH] Added set version tool #70 --- kdb-bot/cpl-workspace.json | 12 +- kdb-bot/src/bot/__init__.py | 2 +- kdb-bot/src/bot/bot.json | 4 +- kdb-bot/src/bot_api/__init__.py | 2 +- kdb-bot/src/bot_api/abc/__init__.py | 2 +- kdb-bot/src/bot_api/bot-api.json | 8 +- kdb-bot/src/bot_api/configuration/__init__.py | 2 +- kdb-bot/src/bot_api/controller/__init__.py | 2 +- .../bot_api/controller/discord/__init__.py | 2 +- kdb-bot/src/bot_api/event/__init__.py | 2 +- kdb-bot/src/bot_api/exception/__init__.py | 2 +- kdb-bot/src/bot_api/filter/__init__.py | 2 +- .../src/bot_api/filter/discord/__init__.py | 2 +- kdb-bot/src/bot_api/logging/__init__.py | 2 +- kdb-bot/src/bot_api/mail/__init__.py | 2 +- kdb-bot/src/bot_api/model/__init__.py | 2 +- kdb-bot/src/bot_api/model/discord/__init__.py | 2 +- kdb-bot/src/bot_api/route/__init__.py | 2 +- kdb-bot/src/bot_api/service/__init__.py | 2 +- kdb-bot/src/bot_api/transformer/__init__.py | 2 +- kdb-bot/src/bot_core/__init__.py | 2 +- kdb-bot/src/bot_core/abc/__init__.py | 2 +- kdb-bot/src/bot_core/bot-core.json | 8 +- .../src/bot_core/configuration/__init__.py | 2 +- .../src/bot_core/core_extension/__init__.py | 2 +- kdb-bot/src/bot_core/events/__init__.py | 2 +- kdb-bot/src/bot_core/helper/__init__.py | 2 +- kdb-bot/src/bot_core/logging/__init__.py | 2 +- kdb-bot/src/bot_core/pipes/__init__.py | 2 +- kdb-bot/src/bot_core/service/__init__.py | 2 +- kdb-bot/src/bot_data/__init__.py | 2 +- kdb-bot/src/bot_data/abc/__init__.py | 2 +- kdb-bot/src/bot_data/bot-data.json | 8 +- kdb-bot/src/bot_data/migration/__init__.py | 2 +- kdb-bot/src/bot_data/model/__init__.py | 2 +- kdb-bot/src/bot_data/service/__init__.py | 2 +- kdb-bot/src/modules/admin/__init__.py | 2 +- kdb-bot/src/modules/admin/command/__init__.py | 2 +- kdb-bot/src/modules/auto_role/__init__.py | 2 +- .../src/modules/auto_role/command/__init__.py | 2 +- .../src/modules/auto_role/events/__init__.py | 2 +- .../src/modules/auto_role/helper/__init__.py | 2 +- kdb-bot/src/modules/base/__init__.py | 2 +- kdb-bot/src/modules/base/abc/__init__.py | 2 +- kdb-bot/src/modules/base/command/__init__.py | 2 +- .../modules/base/configuration/__init__.py | 2 +- kdb-bot/src/modules/base/events/__init__.py | 2 +- kdb-bot/src/modules/base/service/__init__.py | 2 +- kdb-bot/src/modules/boot_log/__init__.py | 2 +- .../boot_log/configuration/__init__.py | 2 +- kdb-bot/src/modules/database/__init__.py | 2 +- kdb-bot/src/modules/moderator/__init__.py | 2 +- .../src/modules/moderator/command/__init__.py | 2 +- kdb-bot/src/modules/permission/__init__.py | 2 +- .../src/modules/permission/abc/__init__.py | 2 +- .../permission/configuration/__init__.py | 2 +- .../src/modules/permission/events/__init__.py | 2 +- .../modules/permission/service/__init__.py | 2 +- kdb-bot/tools/set_version/__init__.py | 26 ++++ kdb-bot/tools/set_version/application.py | 111 ++++++++++++++++++ kdb-bot/tools/set_version/git_service.py | 18 +++ kdb-bot/tools/set_version/main.py | 14 +++ kdb-bot/tools/set_version/set-version.json | 45 +++++++ kdb-bot/tools/set_version/startup.py | 31 +++++ .../set_version/version_setter_service.py | 57 +++++++++ 65 files changed, 380 insertions(+), 68 deletions(-) create mode 100644 kdb-bot/tools/set_version/__init__.py create mode 100644 kdb-bot/tools/set_version/application.py create mode 100644 kdb-bot/tools/set_version/git_service.py create mode 100644 kdb-bot/tools/set_version/main.py create mode 100644 kdb-bot/tools/set_version/set-version.json create mode 100644 kdb-bot/tools/set_version/startup.py create mode 100644 kdb-bot/tools/set_version/version_setter_service.py diff --git a/kdb-bot/cpl-workspace.json b/kdb-bot/cpl-workspace.json index 161c6a0fc5..1234c92b76 100644 --- a/kdb-bot/cpl-workspace.json +++ b/kdb-bot/cpl-workspace.json @@ -13,12 +13,22 @@ "moderator": "src/modules/moderator/moderator.json", "permission": "src/modules/permission/permission.json", "bot-api": "src/bot_api/bot-api.json", - "post-build": "tools/post_build/post-build.json" + "post-build": "tools/post_build/post-build.json", + "set-version": "tools/set_version/set-version.json" }, "Scripts": { + + "sv": "cpl set-version", + "set-version": "cpl run set-version $ARGS; echo '';", + + "pre-build": "cpl set-version $ARGS", "post-build": "cpl run post-build", + + "pre-prod": "cpl build", "prod": "export KDB_ENVIRONMENT=production; export KDB_NAME=KDB-Prod; cpl start;", + "pre-stage": "cpl build", "stage": "export KDB_ENVIRONMENT=staging; export KDB_NAME=KDB-Stage; cpl start;", + "pre-dev": "cpl build", "dev": "export KDB_ENVIRONMENT=development; export KDB_NAME=KDB-Dev; cpl start;", "build-docker": "cpl b; docker-compose down; docker build -t kdb:kdb .", "compose": "docker-compose up -d", diff --git a/kdb-bot/src/bot/__init__.py b/kdb-bot/src/bot/__init__.py index bec166fa4a..0c8ff3e30c 100644 --- a/kdb-bot/src/bot/__init__.py +++ b/kdb-bot/src/bot/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot' +__title__ = 'kdb-bot.bot' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot/bot.json b/kdb-bot/src/bot/bot.json index dcd4efc0ed..36270e64d3 100644 --- a/kdb-bot/src/bot/bot.json +++ b/kdb-bot/src/bot/bot.json @@ -4,7 +4,7 @@ "Version": { "Major": "0", "Minor": "3", - "Micro": "0" + "Micro": "dev70" }, "Author": "Sven Heidemann", "AuthorEmail": "sven.heidemann@sh-edraft.de", @@ -23,7 +23,7 @@ "Flask==2.2.2", "Flask-Classful==0.14.2", "Flask-Cors==3.0.10", - "PyJWT==2.5.0", + "PyJWT==2.6.0", "waitress==2.1.2", "Flask-SocketIO==5.3.1", "eventlet==0.33.1", diff --git a/kdb-bot/src/bot_api/__init__.py b/kdb-bot/src/bot_api/__init__.py index 6029ae84f4..1ae60cdf54 100644 --- a/kdb-bot/src/bot_api/__init__.py +++ b/kdb-bot/src/bot_api/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api' +__title__ = 'kdb-bot.bot_api' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/abc/__init__.py b/kdb-bot/src/bot_api/abc/__init__.py index 25aa13fe09..4e6ad15ffb 100644 --- a/kdb-bot/src/bot_api/abc/__init__.py +++ b/kdb-bot/src/bot_api/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.abc' +__title__ = 'kdb-bot.bot_api.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/bot-api.json b/kdb-bot/src/bot_api/bot-api.json index 07d272dd5d..f82b3711ab 100644 --- a/kdb-bot/src/bot_api/bot-api.json +++ b/kdb-bot/src/bot_api/bot-api.json @@ -2,9 +2,9 @@ "ProjectSettings": { "Name": "bot-api", "Version": { - "Major": "1", - "Minor": "0", - "Micro": "0" + "Major": "0", + "Minor": "3", + "Micro": "dev70" }, "Author": "", "AuthorEmail": "", @@ -16,7 +16,7 @@ "LicenseName": "", "LicenseDescription": "", "Dependencies": [ - "cpl-core==2022.10.0.post6" + "cpl-core==2022.10.0.post7" ], "DevDependencies": [ "cpl-cli==2022.10.0" diff --git a/kdb-bot/src/bot_api/configuration/__init__.py b/kdb-bot/src/bot_api/configuration/__init__.py index 823f5a2b5a..65e30bbbe9 100644 --- a/kdb-bot/src/bot_api/configuration/__init__.py +++ b/kdb-bot/src/bot_api/configuration/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.configuration' +__title__ = 'kdb-bot.bot_api.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/controller/__init__.py b/kdb-bot/src/bot_api/controller/__init__.py index e70854052b..29949d9917 100644 --- a/kdb-bot/src/bot_api/controller/__init__.py +++ b/kdb-bot/src/bot_api/controller/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.controller' +__title__ = 'kdb-bot.bot_api.controller' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/controller/discord/__init__.py b/kdb-bot/src/bot_api/controller/discord/__init__.py index 48cb2fccb7..9bed518294 100644 --- a/kdb-bot/src/bot_api/controller/discord/__init__.py +++ b/kdb-bot/src/bot_api/controller/discord/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.controller.discord' +__title__ = 'kdb-bot.bot_api.controller.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/event/__init__.py b/kdb-bot/src/bot_api/event/__init__.py index 0627d7cf16..2f298c8378 100644 --- a/kdb-bot/src/bot_api/event/__init__.py +++ b/kdb-bot/src/bot_api/event/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.event' +__title__ = 'kdb-bot.bot_api.event' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/exception/__init__.py b/kdb-bot/src/bot_api/exception/__init__.py index 4db4fc25be..f1a78bfe8a 100644 --- a/kdb-bot/src/bot_api/exception/__init__.py +++ b/kdb-bot/src/bot_api/exception/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.exception' +__title__ = 'kdb-bot.bot_api.exception' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/filter/__init__.py b/kdb-bot/src/bot_api/filter/__init__.py index 0b898bd27c..4760b1a610 100644 --- a/kdb-bot/src/bot_api/filter/__init__.py +++ b/kdb-bot/src/bot_api/filter/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.filter' +__title__ = 'kdb-bot.bot_api.filter' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/filter/discord/__init__.py b/kdb-bot/src/bot_api/filter/discord/__init__.py index 1f6d5f55df..f6eba3b66a 100644 --- a/kdb-bot/src/bot_api/filter/discord/__init__.py +++ b/kdb-bot/src/bot_api/filter/discord/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.filter.discord' +__title__ = 'kdb-bot.bot_api.filter.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/logging/__init__.py b/kdb-bot/src/bot_api/logging/__init__.py index 7575e63361..6270db5cfb 100644 --- a/kdb-bot/src/bot_api/logging/__init__.py +++ b/kdb-bot/src/bot_api/logging/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.logging' +__title__ = 'kdb-bot.bot_api.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/mail/__init__.py b/kdb-bot/src/bot_api/mail/__init__.py index 4f792fb4db..71f15d4b6f 100644 --- a/kdb-bot/src/bot_api/mail/__init__.py +++ b/kdb-bot/src/bot_api/mail/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.mail' +__title__ = 'kdb-bot.bot_api.mail' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/model/__init__.py b/kdb-bot/src/bot_api/model/__init__.py index 47a3f826c7..4ae9845294 100644 --- a/kdb-bot/src/bot_api/model/__init__.py +++ b/kdb-bot/src/bot_api/model/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.model' +__title__ = 'kdb-bot.bot_api.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/model/discord/__init__.py b/kdb-bot/src/bot_api/model/discord/__init__.py index a7bbccf9f2..8420026094 100644 --- a/kdb-bot/src/bot_api/model/discord/__init__.py +++ b/kdb-bot/src/bot_api/model/discord/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.model.discord' +__title__ = 'kdb-bot.bot_api.model.discord' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/route/__init__.py b/kdb-bot/src/bot_api/route/__init__.py index 7225cfad0d..19ac2b01f5 100644 --- a/kdb-bot/src/bot_api/route/__init__.py +++ b/kdb-bot/src/bot_api/route/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.route' +__title__ = 'kdb-bot.bot_api.route' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/service/__init__.py b/kdb-bot/src/bot_api/service/__init__.py index 1e2fd6a5b9..d04440b4ce 100644 --- a/kdb-bot/src/bot_api/service/__init__.py +++ b/kdb-bot/src/bot_api/service/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.service' +__title__ = 'kdb-bot.bot_api.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_api/transformer/__init__.py b/kdb-bot/src/bot_api/transformer/__init__.py index a1915e9f11..39ba080991 100644 --- a/kdb-bot/src/bot_api/transformer/__init__.py +++ b/kdb-bot/src/bot_api/transformer/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_api.transformer' +__title__ = 'kdb-bot.bot_api.transformer' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/__init__.py b/kdb-bot/src/bot_core/__init__.py index 9d27fa5529..9841e5dffe 100644 --- a/kdb-bot/src/bot_core/__init__.py +++ b/kdb-bot/src/bot_core/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core' +__title__ = 'kdb-bot.bot_core' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/abc/__init__.py b/kdb-bot/src/bot_core/abc/__init__.py index e8949ac9e1..7110d4011b 100644 --- a/kdb-bot/src/bot_core/abc/__init__.py +++ b/kdb-bot/src/bot_core/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.abc' +__title__ = 'kdb-bot.bot_core.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/bot-core.json b/kdb-bot/src/bot_core/bot-core.json index 5d1641db8a..d61ed8f203 100644 --- a/kdb-bot/src/bot_core/bot-core.json +++ b/kdb-bot/src/bot_core/bot-core.json @@ -2,9 +2,9 @@ "ProjectSettings": { "Name": "bot-core", "Version": { - "Major": "1", - "Minor": "0", - "Micro": "0" + "Major": "0", + "Minor": "3", + "Micro": "dev70" }, "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.10.0" + "cpl-core>=0.3.dev70" ], "DevDependencies": [ "cpl-cli==2022.10.0" diff --git a/kdb-bot/src/bot_core/configuration/__init__.py b/kdb-bot/src/bot_core/configuration/__init__.py index 3e2d80ffb1..a5ee2523e6 100644 --- a/kdb-bot/src/bot_core/configuration/__init__.py +++ b/kdb-bot/src/bot_core/configuration/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.configuration' +__title__ = 'kdb-bot.bot_core.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/core_extension/__init__.py b/kdb-bot/src/bot_core/core_extension/__init__.py index f6d56342f5..d57f385a7f 100644 --- a/kdb-bot/src/bot_core/core_extension/__init__.py +++ b/kdb-bot/src/bot_core/core_extension/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.core_extension' +__title__ = 'kdb-bot.bot_core.core_extension' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/events/__init__.py b/kdb-bot/src/bot_core/events/__init__.py index 3ea3777d7a..96895fc823 100644 --- a/kdb-bot/src/bot_core/events/__init__.py +++ b/kdb-bot/src/bot_core/events/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.events' +__title__ = 'kdb-bot.bot_core.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/helper/__init__.py b/kdb-bot/src/bot_core/helper/__init__.py index e6122ab2b2..01d2b92d00 100644 --- a/kdb-bot/src/bot_core/helper/__init__.py +++ b/kdb-bot/src/bot_core/helper/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.helper' +__title__ = 'kdb-bot.bot_core.helper' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/logging/__init__.py b/kdb-bot/src/bot_core/logging/__init__.py index 7c415dfff7..121e23050e 100644 --- a/kdb-bot/src/bot_core/logging/__init__.py +++ b/kdb-bot/src/bot_core/logging/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.logging' +__title__ = 'kdb-bot.bot_core.logging' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/pipes/__init__.py b/kdb-bot/src/bot_core/pipes/__init__.py index 345eea8d3d..23e49dbf7c 100644 --- a/kdb-bot/src/bot_core/pipes/__init__.py +++ b/kdb-bot/src/bot_core/pipes/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.pipes' +__title__ = 'kdb-bot.bot_core.pipes' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_core/service/__init__.py b/kdb-bot/src/bot_core/service/__init__.py index 2e659d24d8..b0005488be 100644 --- a/kdb-bot/src/bot_core/service/__init__.py +++ b/kdb-bot/src/bot_core/service/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_core.service' +__title__ = 'kdb-bot.bot_core.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_data/__init__.py b/kdb-bot/src/bot_data/__init__.py index 6ac4b954df..ec9965a3c0 100644 --- a/kdb-bot/src/bot_data/__init__.py +++ b/kdb-bot/src/bot_data/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_data' +__title__ = 'kdb-bot.bot_data' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_data/abc/__init__.py b/kdb-bot/src/bot_data/abc/__init__.py index e312030cd9..e4b50fa80c 100644 --- a/kdb-bot/src/bot_data/abc/__init__.py +++ b/kdb-bot/src/bot_data/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_data.abc' +__title__ = 'kdb-bot.bot_data.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_data/bot-data.json b/kdb-bot/src/bot_data/bot-data.json index 3177e285a3..28a4657af2 100644 --- a/kdb-bot/src/bot_data/bot-data.json +++ b/kdb-bot/src/bot_data/bot-data.json @@ -2,9 +2,9 @@ "ProjectSettings": { "Name": "bot-data", "Version": { - "Major": "1", - "Minor": "0", - "Micro": "0" + "Major": "0", + "Minor": "3", + "Micro": "dev70" }, "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.10.0" + "cpl-core>=0.3.dev70" ], "DevDependencies": [ "cpl-cli==2022.10.0" diff --git a/kdb-bot/src/bot_data/migration/__init__.py b/kdb-bot/src/bot_data/migration/__init__.py index b8443711a6..f5d5a90ec1 100644 --- a/kdb-bot/src/bot_data/migration/__init__.py +++ b/kdb-bot/src/bot_data/migration/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_data.migration' +__title__ = 'kdb-bot.bot_data.migration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_data/model/__init__.py b/kdb-bot/src/bot_data/model/__init__.py index ba35160cfe..7e52dfbd82 100644 --- a/kdb-bot/src/bot_data/model/__init__.py +++ b/kdb-bot/src/bot_data/model/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_data.model' +__title__ = 'kdb-bot.bot_data.model' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/bot_data/service/__init__.py b/kdb-bot/src/bot_data/service/__init__.py index 6ed3776925..5afb4cec25 100644 --- a/kdb-bot/src/bot_data/service/__init__.py +++ b/kdb-bot/src/bot_data/service/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'bot_data.service' +__title__ = 'kdb-bot.bot_data.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/admin/__init__.py b/kdb-bot/src/modules/admin/__init__.py index fa637ebcab..8cc2ed2982 100644 --- a/kdb-bot/src/modules/admin/__init__.py +++ b/kdb-bot/src/modules/admin/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.admin' +__title__ = 'kdb-bot.modules.admin' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/admin/command/__init__.py b/kdb-bot/src/modules/admin/command/__init__.py index 4ca82ff598..40eb7ad381 100644 --- a/kdb-bot/src/modules/admin/command/__init__.py +++ b/kdb-bot/src/modules/admin/command/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.admin.command' +__title__ = 'kdb-bot.modules.admin.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/auto_role/__init__.py b/kdb-bot/src/modules/auto_role/__init__.py index bb9a5a5fc3..04d0d6f6f5 100644 --- a/kdb-bot/src/modules/auto_role/__init__.py +++ b/kdb-bot/src/modules/auto_role/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.auto_role' +__title__ = 'kdb-bot.modules.auto_role' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/auto_role/command/__init__.py b/kdb-bot/src/modules/auto_role/command/__init__.py index 580fe9f104..4e8fe60f41 100644 --- a/kdb-bot/src/modules/auto_role/command/__init__.py +++ b/kdb-bot/src/modules/auto_role/command/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.auto_role.command' +__title__ = 'kdb-bot.modules.auto_role.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/auto_role/events/__init__.py b/kdb-bot/src/modules/auto_role/events/__init__.py index 727f90b8b6..c9ddef274c 100644 --- a/kdb-bot/src/modules/auto_role/events/__init__.py +++ b/kdb-bot/src/modules/auto_role/events/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.auto_role.events' +__title__ = 'kdb-bot.modules.auto_role.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/auto_role/helper/__init__.py b/kdb-bot/src/modules/auto_role/helper/__init__.py index c0d58dcd01..92ab88fbdb 100644 --- a/kdb-bot/src/modules/auto_role/helper/__init__.py +++ b/kdb-bot/src/modules/auto_role/helper/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.auto_role.helper' +__title__ = 'kdb-bot.modules.auto_role.helper' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/__init__.py b/kdb-bot/src/modules/base/__init__.py index e3cb6607c5..c878d8b145 100644 --- a/kdb-bot/src/modules/base/__init__.py +++ b/kdb-bot/src/modules/base/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base' +__title__ = 'kdb-bot.modules.base' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/abc/__init__.py b/kdb-bot/src/modules/base/abc/__init__.py index a5b10a343d..d8ad631192 100644 --- a/kdb-bot/src/modules/base/abc/__init__.py +++ b/kdb-bot/src/modules/base/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.abc' +__title__ = 'kdb-bot.modules.base.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/command/__init__.py b/kdb-bot/src/modules/base/command/__init__.py index 4ba0eba952..b060bbae50 100644 --- a/kdb-bot/src/modules/base/command/__init__.py +++ b/kdb-bot/src/modules/base/command/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.command' +__title__ = 'kdb-bot.modules.base.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/configuration/__init__.py b/kdb-bot/src/modules/base/configuration/__init__.py index bd2cc24d26..bca2570f16 100644 --- a/kdb-bot/src/modules/base/configuration/__init__.py +++ b/kdb-bot/src/modules/base/configuration/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.configuration' +__title__ = 'kdb-bot.modules.base.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/events/__init__.py b/kdb-bot/src/modules/base/events/__init__.py index 04f7a3718a..fb12966b28 100644 --- a/kdb-bot/src/modules/base/events/__init__.py +++ b/kdb-bot/src/modules/base/events/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.events' +__title__ = 'kdb-bot.modules.base.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/base/service/__init__.py b/kdb-bot/src/modules/base/service/__init__.py index 92e0c81639..fc95d72808 100644 --- a/kdb-bot/src/modules/base/service/__init__.py +++ b/kdb-bot/src/modules/base/service/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.base.service' +__title__ = 'kdb-bot.modules.base.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/boot_log/__init__.py b/kdb-bot/src/modules/boot_log/__init__.py index e5cc21aa32..2d58c54ca7 100644 --- a/kdb-bot/src/modules/boot_log/__init__.py +++ b/kdb-bot/src/modules/boot_log/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.boot_log' +__title__ = 'kdb-bot.modules.boot_log' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/boot_log/configuration/__init__.py b/kdb-bot/src/modules/boot_log/configuration/__init__.py index 0d76108eaf..ac3884e2f1 100644 --- a/kdb-bot/src/modules/boot_log/configuration/__init__.py +++ b/kdb-bot/src/modules/boot_log/configuration/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.boot_log.configuration' +__title__ = 'kdb-bot.modules.boot_log.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/database/__init__.py b/kdb-bot/src/modules/database/__init__.py index 0615d2a1d1..6fe6101e50 100644 --- a/kdb-bot/src/modules/database/__init__.py +++ b/kdb-bot/src/modules/database/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.database' +__title__ = 'kdb-bot.modules.database' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/moderator/__init__.py b/kdb-bot/src/modules/moderator/__init__.py index 1b8e00d30b..f74162c368 100644 --- a/kdb-bot/src/modules/moderator/__init__.py +++ b/kdb-bot/src/modules/moderator/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.moderator' +__title__ = 'kdb-bot.modules.moderator' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/moderator/command/__init__.py b/kdb-bot/src/modules/moderator/command/__init__.py index e392b8ea45..4dcdcdba1a 100644 --- a/kdb-bot/src/modules/moderator/command/__init__.py +++ b/kdb-bot/src/modules/moderator/command/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.moderator.command' +__title__ = 'kdb-bot.modules.moderator.command' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/permission/__init__.py b/kdb-bot/src/modules/permission/__init__.py index f14bcd24c0..e715f23965 100644 --- a/kdb-bot/src/modules/permission/__init__.py +++ b/kdb-bot/src/modules/permission/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.permission' +__title__ = 'kdb-bot.modules.permission' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/permission/abc/__init__.py b/kdb-bot/src/modules/permission/abc/__init__.py index 220dde0db6..f61139c2bc 100644 --- a/kdb-bot/src/modules/permission/abc/__init__.py +++ b/kdb-bot/src/modules/permission/abc/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.permission.abc' +__title__ = 'kdb-bot.modules.permission.abc' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/permission/configuration/__init__.py b/kdb-bot/src/modules/permission/configuration/__init__.py index 1de588132f..8642f7d35b 100644 --- a/kdb-bot/src/modules/permission/configuration/__init__.py +++ b/kdb-bot/src/modules/permission/configuration/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.permission.configuration' +__title__ = 'kdb-bot.modules.permission.configuration' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/permission/events/__init__.py b/kdb-bot/src/modules/permission/events/__init__.py index 117b3b8b21..a7b9c3165f 100644 --- a/kdb-bot/src/modules/permission/events/__init__.py +++ b/kdb-bot/src/modules/permission/events/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.permission.events' +__title__ = 'kdb-bot.modules.permission.events' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/src/modules/permission/service/__init__.py b/kdb-bot/src/modules/permission/service/__init__.py index 8d6d28f103..f085417d94 100644 --- a/kdb-bot/src/modules/permission/service/__init__.py +++ b/kdb-bot/src/modules/permission/service/__init__.py @@ -11,7 +11,7 @@ Discord bot for the Keksdose discord Server """ -__title__ = 'modules.permission.service' +__title__ = 'kdb-bot.modules.permission.service' __author__ = 'Sven Heidemann' __license__ = 'MIT' __copyright__ = 'Copyright (c) 2022 sh-edraft.de' diff --git a/kdb-bot/tools/set_version/__init__.py b/kdb-bot/tools/set_version/__init__.py new file mode 100644 index 0000000000..ef7b39f659 --- /dev/null +++ b/kdb-bot/tools/set_version/__init__.py @@ -0,0 +1,26 @@ +# -*- 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) 2022 sh-edraft.de +:license: MIT, see LICENSE for more details. + +""" + +__title__ = 'set_version' +__author__ = 'Sven Heidemann' +__license__ = 'MIT' +__copyright__ = 'Copyright (c) 2022 sh-edraft.de' +__version__ = '2022.7.0' + +from collections import namedtuple + + +# imports: + +VersionInfo = namedtuple('VersionInfo', 'major minor micro') +version_info = VersionInfo(major='2022', minor='7', micro='0') diff --git a/kdb-bot/tools/set_version/application.py b/kdb-bot/tools/set_version/application.py new file mode 100644 index 0000000000..e722a272d0 --- /dev/null +++ b/kdb-bot/tools/set_version/application.py @@ -0,0 +1,111 @@ +import os +import traceback + +from cpl_cli.configuration import ProjectSettings +from cpl_core.utils import String + +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): + + 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): + self._configuration.parse_console_arguments(self._services) + + def main(self): + Console.write_line('Set versions:') + + args = self._configuration.additional_arguments + version = {} + branch = "" + suffix = "" + force = False + if '--force' in args: + args.remove('--force') + force = True + + 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 not found', traceback.format_exc()) + return + + try: + if branch.startswith('#'): + self._configuration.add_json_file(self._workspace.projects[self._workspace.default_project], optional=False, output=False) + ps: ProjectSettings = self._configuration.get_configuration(ProjectSettings) + + version[VersionSettingsNameEnum.major.value] = ps.version.major + version[VersionSettingsNameEnum.minor.value] = ps.version.minor + version[VersionSettingsNameEnum.micro.value] = f'dev{branch.split("#")[1]}' + else: + version[VersionSettingsNameEnum.major.value] = branch.split('.')[0] + version[VersionSettingsNameEnum.minor.value] = branch.split('.')[1] + if len(branch.split('.')) == 2: + version[VersionSettingsNameEnum.micro.value] = f'0{suffix}' + else: + version[VersionSettingsNameEnum.micro.value] = f'{branch.split(".")[2]}{suffix}' + except Exception as e: + Console.error(f'Branch {branch} does not contain valid version') + return + + diff_paths = [] + for file in self._git_service.get_diff_files(): + if 'kdb-bot/src' in file: + file = file.replace('kdb-bot/src', '') + + if file.startswith('tools') or 'kdb-web/src' in file: + continue + + if '/' in file: + file = file.split('/')[1] + else: + file = os.path.basename(os.path.dirname(file)) + + if file in diff_paths: + continue + + diff_paths.append(file) + + try: + skipped = [] + for project in self._workspace.projects: + if project not in diff_paths and String.convert_to_snake_case(project) not in diff_paths and not force: + # Console.write_line(f'Skipping {project} due to missing changes') + skipped.append(project) + continue + + Console.write_line(f'Set dependencies {self._version_pipe.transform(version)} for {project}') + self._version_setter.set_dependencies(self._workspace.projects[project], version, 'Dependencies', skipped=skipped) + self._version_setter.set_dependencies(self._workspace.projects[project], version, 'DevDependencies', skipped=skipped) + + 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 diff --git a/kdb-bot/tools/set_version/git_service.py b/kdb-bot/tools/set_version/git_service.py new file mode 100644 index 0000000000..c46b52d099 --- /dev/null +++ b/kdb-bot/tools/set_version/git_service.py @@ -0,0 +1,18 @@ +import os + +from cpl_core.environment import ApplicationEnvironmentABC +from git import Repo + + +class GitService: + + def __init__(self, env: ApplicationEnvironmentABC): + self._env = env + self._repo = Repo(os.path.abspath(os.path.join(env.working_directory, '../'))) + + def get_active_branch_name(self) -> str: + branch = self._repo.active_branch + return branch.name + + def get_diff_files(self) -> list[str]: + return [item.a_path for item in self._repo.index.diff(None)] diff --git a/kdb-bot/tools/set_version/main.py b/kdb-bot/tools/set_version/main.py new file mode 100644 index 0000000000..71943f4380 --- /dev/null +++ b/kdb-bot/tools/set_version/main.py @@ -0,0 +1,14 @@ +from cpl_core.application import ApplicationBuilder + +from set_version.application import Application +from set_version.startup import Startup + + +def main(): + app_builder = ApplicationBuilder(Application) + app_builder.use_startup(Startup) + app_builder.build().run() + + +if __name__ == '__main__': + main() diff --git a/kdb-bot/tools/set_version/set-version.json b/kdb-bot/tools/set_version/set-version.json new file mode 100644 index 0000000000..678b796ab4 --- /dev/null +++ b/kdb-bot/tools/set_version/set-version.json @@ -0,0 +1,45 @@ +{ + "ProjectSettings": { + "Name": "set-version", + "Version": { + "Major": "1", + "Minor": "0", + "Micro": "0" + }, + "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": "2022", + "CopyrightName": "sh-edraft.de", + "LicenseName": "MIT", + "LicenseDescription": "MIT, see LICENSE for more details.", + "Dependencies": [ + "cpl-core==2022.10.0.post7", + "GitPython==3.1.27" + ], + "DevDependencies": [ + "cpl-cli==2022.10.0" + ], + "PythonVersion": ">=3.10.4", + "PythonPath": {}, + "Classifiers": [] + }, + "BuildSettings": { + "ProjectType": "console", + "SourcePath": "", + "OutputPath": "../../dist", + "Main": "set_version.main", + "EntryPoint": "set-version", + "IncludePackageData": false, + "Included": [], + "Excluded": [ + "*/__pycache__", + "*/logs", + "*/tests" + ], + "PackageData": {}, + "ProjectReferences": [] + } +} \ No newline at end of file diff --git a/kdb-bot/tools/set_version/startup.py b/kdb-bot/tools/set_version/startup.py new file mode 100644 index 0000000000..609ef33723 --- /dev/null +++ b/kdb-bot/tools/set_version/startup.py @@ -0,0 +1,31 @@ +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): + + def __init__(self): + 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_singleton(GitService) + services.add_transient(VersionSetterService) + + return services.build_service_provider() diff --git a/kdb-bot/tools/set_version/version_setter_service.py b/kdb-bot/tools/set_version/version_setter_service.py new file mode 100644 index 0000000000..d00a0c080e --- /dev/null +++ b/kdb-bot/tools/set_version/version_setter_service.py @@ -0,0 +1,57 @@ +import json +import os +from string import ascii_letters + +from cpl_core.environment import ApplicationEnvironmentABC +from cpl_core.utils import String + + +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, key: str, skipped=None): + project_json = self._read_file(file) + if key not in project_json['ProjectSettings']: + project_json['ProjectSettings'][key] = [] + + dependencies = project_json['ProjectSettings'][key] + new_deps = [] + for dependency in dependencies: + if not dependency.startswith('cpl-'): + new_deps.append(dependency) + continue + + dep_version = dependency.split('=')[1] + dep_name = dependency.split('=')[0] + if dep_name[len(dep_name)-1] not in ascii_letters: + dep_name = dep_name[:len(dep_name)-1] + + if skipped is not None and (dep_name in skipped or String.convert_to_snake_case(dep_name) in skipped) or dep_version == '': + new_deps.append(dependency) + continue + + new_deps.append(dependency.replace(dep_version, f'{version["Major"]}.{version["Minor"]}.{version["Micro"]}')) + + project_json['ProjectSettings'][key] = new_deps + self._write_file(file, project_json)