tidy-svc:
    awk '/use \(/,/\)/ {if ($1 != "use" && $1 != ")") print $1} /use [^\(]/ {print $2}' go.work | xargs -I {} sh -c 'cd "{}" && echo "Tidying {}..." && go mod tidy'
    go work edit -json | grep -o '"DiskPath": "[^"]*' | cut -d'"' -f4 | xargs -I {} sh -c 'cd "{}" && go fmt ./...'

tidy-web:
    bunx prettier --write .

build:
    npm run build
    cd services/pathfinder && GOCACHE=/tmp/gapmind-go-cache go build -buildvcs=false -o pathfinder .
    cd services/replica && GOCACHE=/tmp/gapmind-go-cache go build -buildvcs=false -o replica .
    cd services/orchestra && GOCACHE=/tmp/gapmind-go-cache go build -buildvcs=false -o orchestra .
    cd services/dht && GOCACHE=/tmp/gapmind-go-cache go build -buildvcs=false -o dht .

deploy config='services/orchestra/orchestra.json': build
    services/orchestra/orchestra -config {{config}}

sync config='services/orchestra/orchestra.json': build
    services/orchestra/orchestra -config {{config}} sync

nuke *ARGS: build
    services/orchestra/orchestra -config services/orchestra/orchestra.json nuke {{ARGS}}