diff --git a/justfile b/justfile index 032517d..afd5909 100644 --- a/justfile +++ b/justfile @@ -8,7 +8,10 @@ FIXTURE_CATALOG_SOURCE := "crates/lanspread-tauri-deno-ts/src-tauri/game.db" FIXTURE_CATALOG_ROOT := "crates/lanspread-peer-cli/catalogs" PRODUCTION_CATALOG_DB := "crates/lanspread-tauri-deno-ts/src-tauri/game.db" PRODUCTION_MANIFEST_ROOT := "crates/lanspread-tauri-deno-ts/src-tauri/manifests" +CATALOG_CACHE_STAMP := ".lanspread/catalog-cache/production.json" CATALOG_UNRAR := env_var_or_default("LANSPREAD_UNRAR", "crates/lanspread-tauri-deno-ts/src-tauri/binaries/unrar-x86_64-unknown-linux-gnu") +GAMES_DIR := env_var_or_default("LANSPREAD_GAMES_DIR", "") +CATALOG_FORCE := env_var_or_default("LANSPREAD_CATALOG_FORCE", "0") TAURI_DEV_CONFIG := '{"bundle":{"resources":{"../../lanspread-peer-cli/catalogs/default/game.db":"game.db","../../lanspread-peer-cli/catalogs/default/manifests/":"manifests/","assets/*":"assets/"}}}' TAURI_FIXTURE_ENV := "LANSPREAD_USE_FIXTURE_CATALOG=1" @@ -16,12 +19,35 @@ setup: cargo install tauri-cli cd crates/lanspread-tauri-deno-ts && deno install --frozen=true -run: fixture-catalog-check +run: + if [ -n "{{ GAMES_DIR }}" ]; then \ + just run-production "{{ GAMES_DIR }}"; \ + else \ + just run-fixture; \ + fi + +run-fixture: fixture-catalog-check {{ TAURI_FIXTURE_ENV }} cargo tauri dev --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.dev.conf.json --release -build: fixture-catalog-check +run-production GAMES_DIR: + just catalog-generate-production "{{ GAMES_DIR }}" + just catalog-check-production + cargo tauri dev --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.production.conf.json --release + +build: + just build-production "{{ GAMES_DIR }}" + +build-fixture: fixture-catalog-check {{ TAURI_FIXTURE_ENV }} cargo tauri build --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.dev.conf.json --no-bundle #-- --profile dev +build-production GAMES_DIR="": + if [ -n "{{ GAMES_DIR }}" ]; then \ + just catalog-generate-production "{{ GAMES_DIR }}"; \ + else \ + just catalog-check-production; \ + fi + cargo tauri build --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.production.conf.json --no-bundle -- --profile production + bundle: catalog-check-production cargo tauri build --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.production.conf.json -- --profile production @@ -112,12 +138,27 @@ catalog-check-production: # Generate the complete production authority from PACKAGES_DIR//. catalog-generate-production PACKAGES_DIR: - cargo run -p lanspread-compat --bin lanspread-catalog-publisher -- generate \ - --catalog-db {{ PRODUCTION_CATALOG_DB }} \ + @if [ "{{ CATALOG_FORCE }}" = "1" ] || ! python3 tools/catalog_source_cache.py check \ + --stamp {{ CATALOG_CACHE_STAMP }} \ --packages-dir "{{ PACKAGES_DIR }}" \ + --catalog-db {{ PRODUCTION_CATALOG_DB }} \ --manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \ - --unrar "{{ CATALOG_UNRAR }}" \ - --all + --unrar "{{ CATALOG_UNRAR }}"; then \ + cargo run -p lanspread-compat --bin lanspread-catalog-publisher -- generate \ + --catalog-db {{ PRODUCTION_CATALOG_DB }} \ + --packages-dir "{{ PACKAGES_DIR }}" \ + --manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \ + --unrar "{{ CATALOG_UNRAR }}" \ + --all && \ + python3 tools/catalog_source_cache.py record \ + --stamp {{ CATALOG_CACHE_STAMP }} \ + --packages-dir "{{ PACKAGES_DIR }}" \ + --catalog-db {{ PRODUCTION_CATALOG_DB }} \ + --manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \ + --unrar "{{ CATALOG_UNRAR }}"; \ + else \ + echo "catalog generation skipped: source metadata matches {{ CATALOG_CACHE_STAMP }}"; \ + fi # Regenerate one game in an already complete production authority. catalog-generate-production-game PACKAGES_DIR GAME_ID: