feat(preset): add build and publish tasks

This commit is contained in:
2023-03-21 23:49:56 +03:00
parent 34dcb5a991
commit dd2aea32b8
5 changed files with 37 additions and 4 deletions
+2 -2
View File
@@ -32,9 +32,9 @@ class Entry:
def show(self): def show(self):
self._logger.info(f"{self}") self._logger.info(f"{self}")
for task_name, commands in self._tasks.items(): for task_name, commands in self._tasks.items():
self._logger.debug(f" {task_name}") self._logger.info(f" {task_name}")
for command in commands: for command in commands:
self._logger.trace(f" {command}") self._logger.debug(f" {command}")
def run_task(self, task_name: str): def run_task(self, task_name: str):
if task_name == "show": if task_name == "show":
+12 -1
View File
@@ -3,7 +3,7 @@ from typing import Any, Optional
from ..core import Pipe from ..core import Pipe
__all__ = ("GetPipe",) __all__ = ("GetPipe", "KeyPipe")
class GetPipe(Pipe[dict, Any]): class GetPipe(Pipe[dict, Any]):
@@ -19,3 +19,14 @@ class GetPipe(Pipe[dict, Any]):
if result: if result:
result = result.get(key) result = result.get(key)
return result return result
class KeyPipe(Pipe[dict, Any]):
type = "key"
def __init__(self, keyindex: Optional[str]):
self._keyindex = int(keyindex) if keyindex else 0
def apply(self, value: dict, basepath: Path) -> Optional[Any]:
keys = list(value.keys())
return keys[self._keyindex]
@@ -13,6 +13,14 @@ commands = ["npm install --legacy-peer-deps"]
conditions = ["file(node_modules/jest)"] conditions = ["file(node_modules/jest)"]
commands = ["npx jest"] commands = ["npx jest"]
[presets.nodejs.tasks.build.npm]
conditions = ["file(package.json) | get(scripts.build)"]
commands = ["npm run build"]
[presets.nodejs.tasks.publish.npm]
conditions = ["file(package.json) | get(scripts.publish)"]
commands = ["npm run publish"]
[presets.nodejs.tasks.clean.node_modules] [presets.nodejs.tasks.clean.node_modules]
conditions = ["file(node_modules)"] conditions = ["file(node_modules)"]
commands = ["rm -rf node_modules"] commands = ["rm -rf node_modules"]
@@ -8,6 +8,20 @@ conditions = [
variables.python_version = "file(pyproject.toml) | get(tool.poetry.dependencies.python) | search((\\d.\\d))" variables.python_version = "file(pyproject.toml) | get(tool.poetry.dependencies.python) | search((\\d.\\d))"
commands = ["poetry env use {python_version}", "poetry install"] commands = ["poetry env use {python_version}", "poetry install"]
[presets.python.tasks.build.poetry]
conditions = [
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
]
commands = ["poetry build"]
[presets.python.tasks.publish.poetry]
conditions = [
"file(pyproject.toml) | get(build-system.build-backend) | equal(poetry.core.masonry.api)",
"file(poetry.toml)",
]
variables.python_repository = "file(poetry.toml) | get(repositories) | key(0)"
commands = ["poetry publish -r {python_repository}"]
[presets.python.tasks.test.pytest] [presets.python.tasks.test.pytest]
conditions = ["file(.venv/bin/pytest)"] conditions = ["file(.venv/bin/pytest)"]
commands = [".venv/bin/pytest -p no:warnings"] commands = [".venv/bin/pytest -p no:warnings"]
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "project-manager" name = "project-manager"
version = "0.1.0" version = "0.1.1"
description = "" description = ""
authors = ["shmyga <shmyga.z@gmail.com>"] authors = ["shmyga <shmyga.z@gmail.com>"]
readme = "README.md" readme = "README.md"