feat: use jinja

This commit is contained in:
2026-08-05 11:00:45 +03:00
parent 705ff503d0
commit d062447e6d
21 changed files with 204 additions and 376 deletions
+29 -9
View File
@@ -1,16 +1,36 @@
[presets.docker]
conditions = ["file(Dockerfile)"]
conditions = ["{{ 'Dockerfile' | file }}"]
variables.docker_name = "{{ 'pyproject.toml' | read | get('project.name') or 'package.json' | read | get('name') }}"
variables.docker_version = "{{ 'pyproject.toml' | read | get('project.version') or 'package.json' | read | get('version') }}"
variables.docker_repo = "{{ '.env' | read | get('DOCKER_REPO') }}"
variables.docker_group = "{{ '.env' | read | get('DOCKER_GROUP') }}"
variables.docker_image = "{{ docker_group }}/{{ docker_name }}"
variables.docker_tag = "{{ '.env' | read | get('DOCKER_TAG') or 'latest' }}"
# build
[presets.docker.tasks.build.default]
variables.docker_target = "file(.env) | get(DOCKER_PROJECTS)"
variables.docker_name = "file(pyproject.toml) | get(project.name)"
variables.docker_group = "file(.env) | get(DOCKER_GROUP)"
commands = ["docker build -t {{ docker_image }} . -f Dockerfile"]
# publish version
[presets.docker.tasks.publish.version]
conditions = ["{{ docker_version }}"]
commands = [
# "docker build --target {docker_target} -t {docker_group}/{docker_name} . -f Dockerfile",
"docker build -t {docker_group}/{docker_name} . -f Dockerfile",
"docker tag {{ docker_image }} {{ docker_repo }}/{{ docker_image }}:{{ docker_version }}",
"docker push {{ docker_repo }}/{{ docker_image }}:{{ docker_version }}",
]
# publish
[presets.docker.tasks.publish.default]
commands = ["docker publish"]
# publish tag
[presets.docker.tasks.publish.tag]
conditions = ["{{ docker_tag }}"]
commands = [
"docker tag {{ docker_image }} {{ docker_repo }}/{{ docker_image }}:{{ docker_tag }}",
"docker push {{ docker_repo }}/{{ docker_image }}:{{ docker_tag }}",
]
# save
[presets.docker.tasks.save.default]
variables.docker_output = "./dist"
commands = [
"mkdir -p {{ docker_output }}",
"docker save --output {{ docker_output }}/{{ docker_name }}-{{ docker_version }}.tar {{ docker_image }}",
]
+7 -7
View File
@@ -1,26 +1,26 @@
[presets.nodejs]
conditions = ["file(package.json)"]
conditions = ["{{ 'package.json' | file }}"]
[presets.nodejs.tasks.setup.npm]
conditions = ["file(package-lock.json)"]
conditions = ["{{ 'package-lock.json' | file }}"]
commands = ["npm install-clean"]
[presets.nodejs.tasks.setup.npm-legacy]
conditions = ["file(package-lock.json) | not"]
conditions = ["{{ not ('package-lock.json' | file) }}"]
commands = ["npm install"]
[presets.nodejs.tasks.test.jest]
conditions = ["file(node_modules/jest)"]
conditions = ["{{ 'node_modules/jest' | file }}"]
commands = ["npx jest"]
[presets.nodejs.tasks.build.npm]
conditions = ["file(package.json) | get(scripts.build)"]
conditions = ["{{ 'package.json' | read | get('scripts.build') }}"]
commands = ["npm run build"]
[presets.nodejs.tasks.publish.npm]
conditions = ["file(package.json) | get(scripts.publish)"]
conditions = ["{{ 'package.json' | read | get('scripts.publish') }}"]
commands = ["npm run publish"]
[presets.nodejs.tasks.clean.node_modules]
conditions = ["file(node_modules)"]
conditions = ["{{ 'node_modules' | file }}"]
commands = ["rm -rf node_modules"]
+17 -23
View File
@@ -1,61 +1,55 @@
[presets.python]
conditions = ["file(pyproject.toml)"]
conditions = ["{{ 'pyproject.toml' | file }}"]
variables.python_poetry = "{{ 'pyproject.toml' | read | get('build-system.build-backend') == 'poetry.core.masonry.api' }}"
# setup
[presets.python.tasks.setup.poetry]
conditions = [
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
]
variables.python_version = "file(pyproject.toml) | get(project.requires-python) | search((\\d+.\\d+))"
commands = [
"poetry env use {python_version}",
"poetry install",
]
conditions = ["{{ python_poetry }}"]
variables.python_version = "{{ 'pyproject.toml' | read | get('project.requires-python') | search('(\\d+.\\d+)') }}"
commands = ["poetry env use {{ python_version }}", "poetry install"]
# build
[presets.python.tasks.build.poetry]
conditions = [
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
]
conditions = ["{{ python_poetry }}"]
commands = ["poetry build"]
# publish
[presets.python.tasks.publish.poetry]
conditions = [
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
"file(poetry.toml) | get(repositories)",
"{{ python_poetry }}",
"{{ 'poetry.toml' | read | get('repositories') }}",
]
variables.python_repository = "file(poetry.toml) | get(repositories) | key(0)"
commands = ["poetry publish -r {python_repository}"]
variables.python_repository = "{{ 'poetry.toml' | read | get('repositories') | key(0) }}"
commands = ["poetry publish -r {{ python_repository }}"]
# test
[presets.python.tasks.test.pytest]
conditions = ["file(.venv/bin/pytest)"]
conditions = ["{{ '.venv/bin/pytest' | file }}"]
commands = [".venv/bin/python -m pytest"]
# lint
[presets.python.tasks.lint.pylint]
conditions = ["file(.venv/bin/pylint)"]
conditions = ["{{ '.venv/bin/pylint' | file }}"]
commands = [".venv/bin/pylint ./"]
[presets.python.tasks.lint.isort]
conditions = ["file(.venv/bin/isort)"]
conditions = ["{{ '.venv/bin/isort' | file }}"]
commands = [".venv/bin/isort --profile black --check-only ./"]
[presets.python.tasks.lint.black]
conditions = ["file(.venv/bin/black)"]
conditions = ["{{ '.venv/bin/black' | file }}"]
commands = [".venv/bin/black --check --diff ./"]
# format
[presets.python.tasks.format.isort]
conditions = ["file(.venv/bin/isort)"]
conditions = ["{{ '.venv/bin/isort' | file }}"]
commands = [".venv/bin/isort --profile black ./"]
[presets.python.tasks.format.black]
conditions = ["file(.venv/bin/black)"]
conditions = ["{{ '.venv/bin/isort' | file }}"]
commands = [".venv/bin/black ./"]
# clean
[presets.python.tasks.clean.venv]
conditions = ["file(.venv)"]
conditions = ["{{ '.venv' | file }}"]
commands = ["rm -rf .venv"]