Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Oct 15, 2024
1 parent 456dfed commit 5df8ba6
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions duties.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
from __future__ import annotations

import json

from duty import duty


ENV_PREFIX = "uv run "

PARAMS = ["--disable-pip-version-check", "--outdated", "--format=json"]
UPDATE_CMD = f"""{ENV_PREFIX}python -m pip list {" ".join(PARAMS)}"""


@duty(capture=False)
def build(ctx, *args: str):
"""Build a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}mknodes build{args_str}")
ctx.run(f"uv run mknodes build{args_str}")


@duty(capture=False)
def serve(ctx, *args: str):
"""Serve a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}mknodes serve{args_str}")
ctx.run(f"uv run mknodes serve{args_str}")


@duty(capture=False)
def test(ctx, *args: str):
"""Serve a MkNodes page."""
args_str = " " + " ".join(args) if args else ""
ctx.run(f"{ENV_PREFIX}pytest{args_str}")
ctx.run(f"uv run pytest{args_str}")


@duty(capture=False)
Expand All @@ -38,19 +30,10 @@ def clean(ctx):
ctx.run("git clean -dfX")


@duty
def update(ctx, *args: str):
@duty(capture=False)
def update(ctx):
"""Update all environment packages using pip directly."""
args_str = " " + " ".join(args) if args else ""
reqs = ctx.run(UPDATE_CMD + args_str)
packages = [x["name"] for x in json.loads(reqs)]
if packages:
pkgs = " ".join(packages)
print(f"Packages to update: {pkgs}")
ctx.run(f"{ENV_PREFIX}python -m pip install -U {pkgs}{args_str}", capture=False)
else:
print("No packages to update!")
ctx.run(f"{ENV_PREFIX}python -m pip install -e .", capture=False)
ctx.run("uv sync --all-extras")


@duty(capture=False)
Expand Down

0 comments on commit 5df8ba6

Please sign in to comment.