knoc-plugin-template/README.md
phil dfc088718a
All checks were successful
/ build (push) Successful in 4s
Update README.md
2025-05-28 17:22:08 +00:00

81 lines
No EOL
1.6 KiB
Markdown

# Template for Knoc plugins
## Entry points
It has 4 standard entry points, defined in `pyproject.toml`:
* CLI
* workflow
* api
* settings
## CI
It has a Forgejo CI build action, defined in `.forgejo/actions/build.yaml`.
## Usage
Just replace `foo` by the name of the plugin below.
With `fish`:
```fish
set NAME foo
set PNAME knoc_$NAME
set DNAME (echo $NAME | tr "_" "-")
```
or with bash:
```bash
NAME=foo
PNAME=knoc_$NAME
DNAME=$(echo $NAME | tr "_" "-")
```
Then:
```fish
git clone https://code.philo.ydns.eu/K-Net/knoc-plugin-template.git $DNAME
cd $DNAME
rm -rf .git
mv src/knoc_plugin_template src/$NAME
sed "s/plugin_template/$NAME/" -i pyproject.toml
sed "s/knoc-plugin-template/$DNAME/" -i pyproject.toml
sed "s/plugin_template/$NAME/" -i src/$PNAME/api.py
sed "s/plugin_template/$NAME/" -i src/$PNAME/cli.py
sed "s/plugin_template/$NAME/" -i src/$PNAME/settings.py
sed "s/plugin_template/$NAME/" -i src/$PNAME/workflows.py
uv venv
git init
```
Then, with `fish`:
```fish
. .venv/bin/activate.fish
uv sync
```
Or `bash`:
```bash
. .venv/bin/activate
uv sync
```
=> The package is ready.
In a *knoc* development environment:
```fish
uv pip install -e ../$DNAME
knoc # Should display the new plugin's CLI tool
```
Finally, create a repo with the same name in the central repo (*forgejo*) and the git upstream.
*Forgejo* inits repo with a branch `main` to it might be useful to run:
```fish
git branch -m master main
```
, edit, commit, tag, push.
To add the plugin in a production image, add the name to the `PLUGIN` variable of the CI build tool, and deploy.