refactor, split to two versions - cli and service

This commit is contained in:
Jev
2026-05-25 23:28:24 +02:00
parent 79d86961e3
commit 7188b20797
14 changed files with 335 additions and 69 deletions
+37 -1
View File
@@ -10,10 +10,21 @@ source init.sh
## Usage
{%- if cookiecutter.project_type == "cli" %}
```bash
{{ cookiecutter.project_slug }} --help
{{ cookiecutter.project_slug }} hello
```
{%- else %}
```bash
python -m {{ cookiecutter.package_name }} # run the poller loop
python -m {{ cookiecutter.package_name }} --once # single cycle (cron/tests)
```
Configuration is read from the environment (`LOG_LEVEL`, `POLL_INTERVAL`); see
`.env.example`. Put the polling/handling logic in `poll_once` / `handle` in
`src/{{ cookiecutter.package_name }}/service.py`.
{%- endif %}
## Development
@@ -21,5 +32,30 @@ source init.sh
uv run invoke lint
uv run invoke test
uv run invoke format
uv run invoke ci # lint + test in Docker
uv run invoke ci # lint + test
```
## Versioning
The git tag is the single source of truth (via `hatch-vcs`); the version is
derived at build time — never edited in `pyproject.toml`.
```bash
uv run invoke bump patch # creates tag vX.Y.Z
git push origin vX.Y.Z
```
{%- if cookiecutter.project_type == "service" %}
## Deployment
Ships a self-contained image; no registry required — the image is copied to the
target over SSH.
```bash
uv run invoke build-image # build {{ cookiecutter.project_slug }}:<version>
uv run invoke deploy # build + docker save | ssh + restart compose
```
Edit `VPS`, `REMOTE_DIR`, and `SERVICE` constants in `tasks.py` and the
`docker-compose.yml` on the target host to match your setup.
{%- endif %}