#!/usr/bin/env just --justfile
# Copyright 2025 Vantage Compute Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

uv := require("uv")

project_dir := justfile_directory()
package_name := "vantage_agent"
test_path := "tests"

export PY_COLORS := "1"
export PYTHONBREAKPOINT := "pdb.set_trace"

uv_run := "uv run --frozen --extra dev"

[private]
default:
    @just help

# Install the project's dependencies
[group("dev")]
install:
    uv sync --all-extras

# Regenerate uv.lock
[group("dev")]
lock:
    uv lock --no-cache

# Upgrade uv.lock with the latest dependencies
[group("dev")]
upgrade:
    uv lock --upgrade

# Build the package
[group("dev")]
build: lock
    uv build --no-cache

# Run the unit tests
[group("test")]
test: install
    {{uv_run}} pytest

# Lint the project using ruff
[group("lint")]
lint: install
    {{uv_run}} ruff check {{package_name}} {{test_path}}

# Format the code using ruff
[group("lint")]
fmt: install
    {{uv_run}} ruff format {{package_name}} {{test_path}}

# Run the quality assurance check
[group("test")]
qa: lint test
    @echo "All tests pass! Ready for deployment"

# Clean all files/folders created by the project
[group("dev")]
clean:
    @find . -iname '*.pyc' -delete
    @find . -iname '*.pyo' -delete
    @find . -iname '*~' -delete
    @find . -iname '*.swp' -delete
    @find . -iname '__pycache__' -delete
    @find . -iname '.zip' -delete
    @find . -iname '.mypy_cache' -delete
    @find . -iname '..venv' -delete
    @rm -rf .pytest_cache

# Show available commands
[group("help")]
help:
    @just --list
