102 lines
2.9 KiB
Makefile
102 lines
2.9 KiB
Makefile
set dotenv-load := true
|
|
# development environment file
|
|
set dotenv-filename := "./public/database/.env.generated"
|
|
|
|
DEFAULT_SIMULATE_ARGS := "--agent-dockerfile-path=../agent/Dockerfile"
|
|
|
|
cli *args:
|
|
cd apps/cli && \
|
|
if [ -n "{{args}}" ]; then \
|
|
cargo run -- {{args}}; \
|
|
else \
|
|
cargo run; \
|
|
fi
|
|
|
|
simulate *args:
|
|
cd apps/container && \
|
|
if [ -n "{{args}}" ]; then \
|
|
cargo run --bin container-simulate -- {{args}}; \
|
|
else \
|
|
cargo run --bin container-simulate -- {{DEFAULT_SIMULATE_ARGS}}; \
|
|
fi
|
|
|
|
# Usage: (following SeaORM migration commands)
|
|
# init: Initialize migration directory
|
|
# generate: Generate a new migration file
|
|
# up: Apply all pending migrations
|
|
# up -n 10: Apply 10 pending migrations
|
|
# down: Rollback last applied migration
|
|
# down -n 10: Rollback last 10 applied migrations
|
|
# status: Check the status of all migrations
|
|
# fresh: Drop all tables from the database, then reapply all migrations
|
|
# refresh: Rollback all applied migrations, then reapply all migrations
|
|
# reset: Rollback all applied migrations
|
|
migrate *args:
|
|
cd public/migration && \
|
|
if [ -n "{{args}}" ]; then \
|
|
cargo run -- {{args}}; \
|
|
else \
|
|
cargo run; \
|
|
fi
|
|
|
|
generate-entity:
|
|
# delegate to cli
|
|
just cli db:migrate_and_generate --output-path ../../public/database/src/generated/entities
|
|
|
|
generate-openapi:
|
|
# Generate OpenAPI spec
|
|
cd apps/api && \
|
|
cargo run -- generate:openapi --output-path ./swagger.json
|
|
# Generate API client for frontend
|
|
cd apps/frontend && \
|
|
pnpm generate:openapi
|
|
# Generate API client for agent
|
|
cd apps/agent && \
|
|
cargo run -- generate-openapi --output swagger.json
|
|
|
|
generate-agent-client:
|
|
# Generate API client for agent
|
|
pnpm openapi-generator-cli generate \
|
|
-g rust --skip-validate-spec \
|
|
-o ./public/agent-client -i ./apps/agent/swagger.json \
|
|
--additional-properties=library=reqwest-trait \
|
|
--additional-properties=mockall=true \
|
|
--additional-properties=packageName=agent_client \
|
|
--additional-properties=packageVersion=0.1.0 \
|
|
--additional-properties=supportAsync=true \
|
|
--additional-properties=supportMultipleResponses=true \
|
|
--additional-properties=topLevelApiClient=true \
|
|
--additional-properties=useSingleRequestParameter=true
|
|
# format generated code
|
|
cd public/agent-client && \
|
|
cargo fmt
|
|
# append lint allows/forbids to the end of Cargo.toml to disable warnings in generated code and forbid unsafe code
|
|
cd public/agent-client && \
|
|
echo '\n[lints.clippy]\nall = "allow"\n[lints.rust]\nunsafe_code = "forbid"\n' >> Cargo.toml
|
|
|
|
generate-all: generate-entity generate-openapi generate-agent-client
|
|
|
|
build-frontend:
|
|
# build frontend assets
|
|
cd apps/frontend && \
|
|
pnpm build
|
|
|
|
build-backend:
|
|
# build backend server
|
|
cd apps/api && \
|
|
cargo build --release
|
|
|
|
build-docker:
|
|
cd apps/agent && \
|
|
docker build -t yanpm/agent:latest .
|
|
|
|
build-apps: build-frontend build-backend
|
|
|
|
act *args:
|
|
if [ -n "{{args}}" ]; then \
|
|
act {{args}} --artifact-server-path /tmp/artifacts; \
|
|
else \
|
|
act; \
|
|
fi
|
|
|