Compare commits

..

5 Commits

Author SHA1 Message Date
cc76227199 Moved hosted service base
All checks were successful
Test before pr merge / test-lint (pull_request) Successful in 10s
Build on push / prepare (push) Successful in 13s
Build on push / query (push) Successful in 24s
Build on push / core (push) Successful in 25s
Build on push / dependency (push) Successful in 18s
Build on push / cli (push) Successful in 24s
Build on push / application (push) Successful in 18s
Build on push / mail (push) Successful in 19s
Build on push / database (push) Successful in 23s
Build on push / translation (push) Successful in 26s
Build on push / auth (push) Successful in 17s
Build on push / api (push) Successful in 22s
2025-10-22 11:40:25 +02:00
dfbb0a8c1f Updated cpl structure model json handling
All checks were successful
Test before pr merge / test-lint (pull_request) Successful in 7s
Build on push / prepare (push) Successful in 12s
Build on push / query (push) Successful in 19s
Build on push / core (push) Successful in 19s
Build on push / cli (push) Successful in 19s
Build on push / dependency (push) Successful in 19s
Build on push / database (push) Successful in 16s
Build on push / application (push) Successful in 17s
Build on push / translation (push) Successful in 19s
Build on push / mail (push) Successful in 22s
Build on push / auth (push) Successful in 15s
Build on push / api (push) Successful in 15s
2025-10-19 20:17:17 +02:00
472aba5990 Removed ws with_parents
All checks were successful
Test before pr merge / test-lint (pull_request) Successful in 7s
Build on push / prepare (push) Successful in 10s
Build on push / query (push) Successful in 19s
Build on push / core (push) Successful in 22s
Build on push / cli (push) Successful in 16s
Build on push / dependency (push) Successful in 19s
Build on push / mail (push) Successful in 17s
Build on push / application (push) Successful in 21s
Build on push / translation (push) Successful in 20s
Build on push / database (push) Successful in 21s
Build on push / auth (push) Successful in 19s
Build on push / api (push) Successful in 15s
2025-10-19 20:03:43 +02:00
9c75008c9f Add cpl-mail project
All checks were successful
Test before pr merge / test-lint (pull_request) Successful in 8s
Build on push / prepare (push) Successful in 10s
Build on push / query (push) Successful in 18s
Build on push / core (push) Successful in 19s
Build on push / dependency (push) Successful in 19s
Build on push / cli (push) Successful in 24s
Build on push / mail (push) Successful in 17s
Build on push / translation (push) Successful in 16s
Build on push / database (push) Successful in 21s
Build on push / application (push) Successful in 21s
Build on push / auth (push) Successful in 15s
Build on push / api (push) Successful in 15s
2025-10-19 20:03:43 +02:00
df2c2b5b56 Workspace check project existence
All checks were successful
Test before pr merge / test-lint (pull_request) Successful in 6s
Build on push / prepare (push) Successful in 11s
Build on push / query (push) Successful in 19s
Build on push / core (push) Successful in 19s
Build on push / dependency (push) Successful in 19s
Build on push / cli (push) Successful in 19s
Build on push / application (push) Successful in 16s
Build on push / translation (push) Successful in 17s
Build on push / database (push) Successful in 20s
Build on push / mail (push) Successful in 20s
Build on push / auth (push) Successful in 15s
Build on push / api (push) Successful in 16s
2025-10-19 19:56:59 +02:00
16 changed files with 62 additions and 43 deletions

View File

@@ -3,7 +3,7 @@
"projects": [ "projects": [
"src/cli/cpl.project.json", "src/cli/cpl.project.json",
"src/core/cpl.project.json", "src/core/cpl.project.json",
"test/cpl.project.json" "src/mail/cpl.project.json"
], ],
"defaultProject": "cpl-cli", "defaultProject": "cpl-cli",
"scripts": { "scripts": {

View File

@@ -75,9 +75,3 @@ class Application(ApplicationABC):
test_settings1 = Configuration.get(TestSettings) test_settings1 = Configuration.get(TestSettings)
Console.write_line(test_settings1.value) Console.write_line(test_settings1.value)
# self.test_send_mail() # self.test_send_mail()
x = 0
while x < 500:
Console.write_line("Running...")
x += 1
await asyncio.sleep(5)

View File

@@ -1,11 +1,13 @@
from application import Application from application import Application
from cpl.application import ApplicationBuilder from cpl.application import ApplicationBuilder
from cpl.core.console import Console
from test_extension import TestExtension from test_extension import TestExtension
from startup import Startup from startup import Startup
from test_startup_extension import TestStartupExtension from test_startup_extension import TestStartupExtension
def main(): def main():
Console.write_line("\n\n--- Application Starting ---\n")
app_builder = ApplicationBuilder(Application) app_builder = ApplicationBuilder(Application)
app_builder.with_startup(Startup) app_builder.with_startup(Startup)
app_builder.with_extension(TestStartupExtension) app_builder.with_extension(TestStartupExtension)

View File

@@ -22,22 +22,6 @@ class ApplicationABC(ABC):
Contains instances of prepared objects Contains instances of prepared objects
""" """
@classmethod
def extend(cls, name: str | Callable, func: Callable[[Self], Self]):
r"""Extend the Application with a custom method
Parameters:
name: :class:`str`
Name of the method
func: :class:`Callable[[Self], Self]`
Function that takes the Application as a parameter and returns it
"""
if callable(name):
name = name.__name__
setattr(cls, name, func)
return cls
@abstractmethod @abstractmethod
def __init__( def __init__(
self, services: ServiceProvider, loaded_modules: set[TModule], required_modules: list[str | object] = None self, services: ServiceProvider, loaded_modules: set[TModule], required_modules: list[str | object] = None

View File

@@ -4,7 +4,7 @@ from typing import Callable
from cpl.core.property import classproperty from cpl.core.property import classproperty
from cpl.dependency.context import get_provider, use_root_provider from cpl.dependency.context import get_provider, use_root_provider
from cpl.dependency.service_collection import ServiceCollection from cpl.dependency.service_collection import ServiceCollection
from cpl.dependency.hosted.startup_task import StartupTask from cpl.core.service.startup_task import StartupTask
class Host: class Host:
@@ -86,10 +86,9 @@ class Host:
func(*args, **kwargs) func(*args, **kwargs)
except (KeyboardInterrupt, asyncio.CancelledError): except (KeyboardInterrupt, asyncio.CancelledError):
pass pass
finally:
await cls._stop_all()
cls.get_loop().run_until_complete(runner()) cls.get_loop().run_until_complete(runner())
cls.get_loop().run_until_complete(cls.wait_for_all())
@classmethod @classmethod
def run(cls, func: Callable, *args, **kwargs): def run(cls, func: Callable, *args, **kwargs):

View File

@@ -31,7 +31,7 @@ def init(target: str, name: str, verbose: bool = False):
if target in ["workspace", "ws"]: if target in ["workspace", "ws"]:
workspace = Structure.init_workspace("./", name or click.prompt("Workspace name", default="my-workspace")) workspace = Structure.init_workspace("./", name or click.prompt("Workspace name", default="my-workspace"))
elif target in PROJECT_TYPES: elif target in PROJECT_TYPES:
workspace = Structure.find_workspace_in_path(Path(name or "./").parent, with_parents=True) workspace = Structure.find_workspace_in_path(Path(name or "./").parent)
project = Structure.init_project( project = Structure.init_project(
"./", name or click.prompt("Project name", default=f"my-{target}"), target, workspace, verbose=verbose "./", name or click.prompt("Project name", default=f"my-{target}"), target, workspace, verbose=verbose
) )

View File

@@ -44,7 +44,7 @@ def new(type: str, name: str, in_name: str | None, project: list[str] | None, ve
path = Path(workspace.path).parent / Path(project[1]).parent path = Path(workspace.path).parent / Path(project[1]).parent
project_name = Path(project[1]).stem project_name = Path(project[1]).stem
workspace = Structure.find_workspace_in_path(path, with_parents=False) workspace = Structure.find_workspace_in_path(path)
if workspace is None: if workspace is None:
Console.error("No workspace found. Please run 'cpl init workspace' first.") Console.error("No workspace found. Please run 'cpl init workspace' first.")
raise SystemExit(1) raise SystemExit(1)

View File

@@ -11,9 +11,13 @@ T = TypeVar("T", bound="CPLStructureModel")
class CPLStructureModel: class CPLStructureModel:
def __init__(self, path: Optional[str] = None): def __init__(self, path: Optional[str] = None, ignore_fields: Optional[List[str]] = None):
self._path = path self._path = path
self._ignore = {"_ignore", "_path"}
if ignore_fields is not None:
self._ignore.update(ignore_fields)
@property @property
def path(self) -> Optional[str]: def path(self) -> Optional[str]:
return self._path return self._path
@@ -68,7 +72,7 @@ class CPLStructureModel:
def to_json(self) -> Dict[str, Any]: def to_json(self) -> Dict[str, Any]:
result: Dict[str, Any] = {} result: Dict[str, Any] = {}
for key, value in self.__dict__.items(): for key, value in self.__dict__.items():
if not key.startswith("_") or key == "_path": if not key.startswith("_") or key in self._ignore:
continue continue
out_key = _self_or_cls_snake_to_camel(key[1:]) out_key = _self_or_cls_snake_to_camel(key[1:])

View File

@@ -1,3 +1,4 @@
from pathlib import Path
from typing import Optional, List, Dict from typing import Optional, List, Dict
from cpl.cli.model.cpl_structure_model import CPLStructureModel from cpl.cli.model.cpl_structure_model import CPLStructureModel
@@ -23,11 +24,25 @@ class Workspace(CPLStructureModel):
default_project: Optional[str], default_project: Optional[str],
scripts: Dict[str, str], scripts: Dict[str, str],
): ):
CPLStructureModel.__init__(self, path) CPLStructureModel.__init__(self, path, ["_actual_projects", "_project_names"])
self._name = name self._name = name
self._projects = projects self._projects = projects
self._default_project = default_project self._default_project = default_project
self._actual_projects = []
self._project_names = []
for project in projects:
if Path(project).is_dir() or not Path(project).exists():
raise ValueError(f"Project path '{project}' does not exist or is a directory.")
p = Project.from_file(project)
self._actual_projects.append(p)
self._project_names.append(p.name)
if default_project is not None and default_project not in self._project_names:
raise ValueError(f"Default project '{default_project}' not found in workspace projects.")
self._scripts = scripts self._scripts = scripts
@property @property
@@ -48,11 +63,11 @@ class Workspace(CPLStructureModel):
@property @property
def actual_projects(self) -> List[Project]: def actual_projects(self) -> List[Project]:
return [Project.from_file(p) for p in self._projects] return self._actual_projects
@property @property
def project_names(self) -> List[str]: def project_names(self) -> List[str]:
return [Project.from_file(p).name for p in self._projects] return self._project_names
@property @property
def default_project(self) -> Optional[str]: def default_project(self) -> Optional[str]:

View File

@@ -32,11 +32,9 @@ class Structure:
} }
@staticmethod @staticmethod
def find_workspace_in_path(path: Path, with_parents=False) -> Workspace | None: def find_workspace_in_path(path: Path) -> Workspace | None:
current_path = path.resolve() current_path = path.resolve()
paths = [current_path] paths = [current_path, *current_path.parents]
if with_parents:
paths.extend(current_path.parents)
for parent in paths: for parent in paths:
workspace_file = parent / "cpl.workspace.json" workspace_file = parent / "cpl.workspace.json"
@@ -84,7 +82,7 @@ class Structure:
return Project.from_file(path) return Project.from_file(path)
workspace = Structure.find_workspace_in_path(path.parent, with_parents=True) workspace = Structure.find_workspace_in_path(path.parent)
if workspace is None: if workspace is None:
raise RuntimeError("No workspace found. Please run 'cpl init workspace' first.") raise RuntimeError("No workspace found. Please run 'cpl init workspace' first.")

View File

@@ -3,7 +3,7 @@ from abc import ABC, abstractmethod
from datetime import datetime from datetime import datetime
from cpl.core.time.cron import Cron from cpl.core.time.cron import Cron
from cpl.dependency.hosted import HostedService from cpl.core.service import HostedService
class CronjobABC(HostedService, ABC): class CronjobABC(HostedService, ABC):

View File

@@ -7,7 +7,7 @@ from cpl.database.model.migration import Migration
from cpl.database.model.server_type import ServerType, ServerTypes from cpl.database.model.server_type import ServerType, ServerTypes
from cpl.database.schema.executed_migration import ExecutedMigration from cpl.database.schema.executed_migration import ExecutedMigration
from cpl.database.schema.executed_migration_dao import ExecutedMigrationDao from cpl.database.schema.executed_migration_dao import ExecutedMigrationDao
from cpl.dependency.hosted import StartupTask from cpl.core.service import StartupTask
class MigrationService(StartupTask): class MigrationService(StartupTask):

View File

@@ -1,7 +1,7 @@
from cpl.database.abc.data_seeder_abc import DataSeederABC from cpl.database.abc.data_seeder_abc import DataSeederABC
from cpl.database.logger import DBLogger from cpl.database.logger import DBLogger
from cpl.dependency import ServiceProvider from cpl.dependency import ServiceProvider
from cpl.dependency.hosted import StartupTask from cpl.core.service import StartupTask
class SeederService(StartupTask): class SeederService(StartupTask):

View File

@@ -5,7 +5,7 @@ from cpl.core.errors import module_dependency_error
from cpl.core.log.logger_abc import LoggerABC from cpl.core.log.logger_abc import LoggerABC
from cpl.core.typing import T, Service from cpl.core.typing import T, Service
from cpl.core.utils.cache import Cache from cpl.core.utils.cache import Cache
from cpl.dependency.hosted.startup_task import StartupTask from cpl.core.service.startup_task import StartupTask
from cpl.dependency.module.module import Module from cpl.dependency.module.module import Module
from cpl.dependency.service_descriptor import ServiceDescriptor from cpl.dependency.service_descriptor import ServiceDescriptor
from cpl.dependency.service_lifetime import ServiceLifetimeEnum from cpl.dependency.service_lifetime import ServiceLifetimeEnum

View File

@@ -2,7 +2,7 @@ from typing import Type
from cpl.core.configuration import ConfigurationModelABC from cpl.core.configuration import ConfigurationModelABC
from cpl.core.typing import T from cpl.core.typing import T
from cpl.dependency.hosted import StartupTask from cpl.core.service import StartupTask
from cpl.dependency.module.module import Module from cpl.dependency.module.module import Module
TModule = Type[Module] TModule = Type[Module]

23
src/mail/cpl.project.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "cpl-mail",
"version": "0.1.0",
"type": "library",
"license": "",
"author": "",
"description": "",
"homepage": "",
"keywords": [],
"dependencies": {
"cpl-core": "~2024.7.0"
},
"devDependencies": {
"cpl-cli": ">2024.7.0"
},
"references": [],
"main": null,
"directory": "./",
"build": {
"include": [],
"exclude": []
}
}