feat(catalog): separate generated production and local test authority
The launcher previously defaulted to fixtures and production generation used the source database directly. Generate a separate database and manifest set from package directories, validating staged output with the application loader before installation. Keep strict selection by default, with independent opt-ins for missing games and package version overrides in the copied database. Share database filtering and staging with the fixture publisher, and include source metadata and generation modes in the publication cache. Make normal runs consume existing production authority. Add an explicit local test recipe with separate resources, app settings, and a compiled startup game directory. Build-time gates exclude local authority from production and require Tauri development mode. Document the generation and launch workflows. Clear generated catalog copies before Tauri copies the selected resource tree so mode switches and reduced catalogs cannot retain stale manifests. Watch the copied files to repair deletion and preserve prior output mtimes only when the bytes are unchanged, allowing subsequent builds to become fresh. Test Plan: - `just fmt` -- passed. - `just clippy` -- passed with warnings denied. - `just test` -- workspace tests passed using fixture authority. - `just frontend-test` -- 94 passed. - `python3 -m unittest discover -s tools -p 'test_catalog_source_cache.py'` -- 4 passed. - `git diff --cached --check` -- passed. - Interactive GUI launches and production bundles were not exercised.
This commit is contained in:
1 parent
ab0c95b80f
commit
6b65a66465
21 files changed
+1777
-273
No files matched your search
@@ -8,12 +8,20 @@ default: run
|
||||
|
||||
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"
|
||||
PRODUCTION_CATALOG_SOURCE := "crates/lanspread-tauri-deno-ts/src-tauri/game.db"
|
||||
PRODUCTION_CATALOG_ROOT := "crates/lanspread-tauri-deno-ts/src-tauri/production-catalog"
|
||||
PRODUCTION_CATALOG_DB := PRODUCTION_CATALOG_ROOT / "game.db"
|
||||
PRODUCTION_MANIFEST_ROOT := PRODUCTION_CATALOG_ROOT / "manifests"
|
||||
CATALOG_CACHE_STAMP := ".lanspread/catalog-cache/production.json"
|
||||
LOCAL_CATALOG_ROOT := "crates/lanspread-tauri-deno-ts/src-tauri/local-catalog"
|
||||
LOCAL_CATALOG_DB := LOCAL_CATALOG_ROOT / "game.db"
|
||||
LOCAL_MANIFEST_ROOT := LOCAL_CATALOG_ROOT / "manifests"
|
||||
LOCAL_CATALOG_CACHE_STAMP := ".lanspread/catalog-cache/local.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")
|
||||
CATALOG_MISSING_MODE := env_var_or_default("LANSPREAD_CATALOG_MISSING_MODE", "")
|
||||
CATALOG_VERSION_MODE := env_var_or_default("LANSPREAD_CATALOG_VERSION_MODE", "")
|
||||
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"
|
||||
|
||||
@@ -21,30 +29,34 @@ setup:
|
||||
cargo install tauri-cli
|
||||
cd crates/lanspread-tauri-deno-ts && deno install --frozen=true
|
||||
|
||||
run:
|
||||
if [ -n "$GAMES_DIR" ]; then \
|
||||
just run-production "$GAMES_DIR"; \
|
||||
else \
|
||||
just run-fixture; \
|
||||
fi
|
||||
run: catalog-check-production
|
||||
cargo tauri dev --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.production.conf.json --release
|
||||
|
||||
run-fixture: fixture-catalog-check
|
||||
{{ TAURI_FIXTURE_ENV }} cargo tauri dev --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.dev.conf.json --release
|
||||
|
||||
run-production GAMES_DIR:
|
||||
just catalog-generate-production "$GAMES_DIR"
|
||||
run-production GAMES_DIR MODE_1="" MODE_2="":
|
||||
just catalog-generate-production "$GAMES_DIR" "$MODE_1" "$MODE_2"
|
||||
just catalog-check-production
|
||||
cargo tauri dev --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.production.conf.json --release
|
||||
|
||||
# Build a separate test authority from these local games and select their folder.
|
||||
run-local GAMES_DIR:
|
||||
@local_games_dir="$(cd -- "$GAMES_DIR" && pwd -P)" && \
|
||||
echo "LOCAL TEST MODE: $local_games_dir (separate local catalog; development build only)" && \
|
||||
just catalog-generate-local "$local_games_dir" && \
|
||||
LANSPREAD_USE_LOCAL_CATALOG=1 LANSPREAD_LOCAL_GAMES_DIR="$local_games_dir" \
|
||||
cargo tauri dev --config crates/lanspread-tauri-deno-ts/src-tauri/tauri.local.conf.json --release
|
||||
|
||||
build:
|
||||
just build-production "$GAMES_DIR"
|
||||
just build-production "$GAMES_DIR" "$CATALOG_MISSING_MODE" "$CATALOG_VERSION_MODE"
|
||||
|
||||
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="":
|
||||
build-production GAMES_DIR="" MODE_1="" MODE_2="":
|
||||
if [ -n "$GAMES_DIR" ]; then \
|
||||
just catalog-generate-production "$GAMES_DIR"; \
|
||||
just catalog-generate-production "$GAMES_DIR" "$MODE_1" "$MODE_2"; \
|
||||
else \
|
||||
just catalog-check-production; \
|
||||
fi
|
||||
@@ -148,30 +160,68 @@ catalog-check-production:
|
||||
--manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \
|
||||
--all
|
||||
|
||||
# Generate the complete production authority from PACKAGES_DIR/<game_id>/.
|
||||
catalog-generate-production PACKAGES_DIR:
|
||||
@if [ "$CATALOG_FORCE" = "1" ] || ! python3 tools/catalog_source_cache.py check \
|
||||
# Generate production authority from PACKAGES_DIR/<game_id>/.
|
||||
# Pass allow-missing-games and/or allow-version-mismatch as explicit modes.
|
||||
catalog-generate-production PACKAGES_DIR MODE_1="" MODE_2="":
|
||||
@set --; \
|
||||
for mode in "$MODE_1" "$MODE_2"; do \
|
||||
case "$mode" in \
|
||||
"") ;; \
|
||||
allow-missing-games) set -- "$@" --allow-missing-games ;; \
|
||||
allow-version-mismatch) set -- "$@" --allow-version-mismatch ;; \
|
||||
*) echo "mode must be allow-missing-games or allow-version-mismatch" >&2; exit 2 ;; \
|
||||
esac; \
|
||||
done; \
|
||||
if [ "$CATALOG_FORCE" = "1" ] || ! python3 tools/catalog_source_cache.py check \
|
||||
--stamp {{ CATALOG_CACHE_STAMP }} \
|
||||
--packages-dir "$PACKAGES_DIR" \
|
||||
--catalog-db {{ PRODUCTION_CATALOG_DB }} \
|
||||
--source-catalog-db {{ PRODUCTION_CATALOG_SOURCE }} \
|
||||
--manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \
|
||||
--unrar "$CATALOG_UNRAR"; then \
|
||||
cargo run --release -p lanspread-compat --bin lanspread-catalog-publisher -- generate \
|
||||
--catalog-db {{ PRODUCTION_CATALOG_DB }} \
|
||||
--unrar "$CATALOG_UNRAR" "$@"; then \
|
||||
cargo run --release -p lanspread-compat --bin lanspread-production-catalog -- \
|
||||
--source-catalog-db {{ PRODUCTION_CATALOG_SOURCE }} \
|
||||
--packages-dir "$PACKAGES_DIR" \
|
||||
--manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \
|
||||
--output-dir {{ PRODUCTION_CATALOG_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 }} \
|
||||
--source-catalog-db {{ PRODUCTION_CATALOG_SOURCE }} \
|
||||
--manifests-dir {{ PRODUCTION_MANIFEST_ROOT }} \
|
||||
--unrar "$CATALOG_UNRAR"; \
|
||||
--unrar "$CATALOG_UNRAR" "$@"; \
|
||||
else \
|
||||
echo "catalog generation skipped: source metadata matches {{ CATALOG_CACHE_STAMP }}"; \
|
||||
fi
|
||||
|
||||
# Local test authority never overwrites the generated production catalog.
|
||||
catalog-generate-local PACKAGES_DIR:
|
||||
@if [ "$CATALOG_FORCE" = "1" ] || ! python3 tools/catalog_source_cache.py check \
|
||||
--stamp {{ LOCAL_CATALOG_CACHE_STAMP }} \
|
||||
--packages-dir "$PACKAGES_DIR" \
|
||||
--catalog-db {{ LOCAL_CATALOG_DB }} \
|
||||
--source-catalog-db {{ PRODUCTION_CATALOG_SOURCE }} \
|
||||
--manifests-dir {{ LOCAL_MANIFEST_ROOT }} \
|
||||
--unrar "$CATALOG_UNRAR" --allow-missing-games --allow-version-mismatch; then \
|
||||
cargo run --release -p lanspread-compat --bin lanspread-production-catalog -- \
|
||||
--source-catalog-db {{ PRODUCTION_CATALOG_SOURCE }} \
|
||||
--packages-dir "$PACKAGES_DIR" \
|
||||
--output-dir {{ LOCAL_CATALOG_ROOT }} \
|
||||
--unrar "$CATALOG_UNRAR" \
|
||||
--allow-missing-games --allow-version-mismatch && \
|
||||
python3 tools/catalog_source_cache.py record \
|
||||
--stamp {{ LOCAL_CATALOG_CACHE_STAMP }} \
|
||||
--packages-dir "$PACKAGES_DIR" \
|
||||
--catalog-db {{ LOCAL_CATALOG_DB }} \
|
||||
--source-catalog-db {{ PRODUCTION_CATALOG_SOURCE }} \
|
||||
--manifests-dir {{ LOCAL_MANIFEST_ROOT }} \
|
||||
--unrar "$CATALOG_UNRAR" --allow-missing-games --allow-version-mismatch; \
|
||||
else \
|
||||
echo "local catalog generation skipped: source metadata matches {{ LOCAL_CATALOG_CACHE_STAMP }}"; \
|
||||
fi
|
||||
|
||||
# Regenerate one game in an already complete production authority.
|
||||
catalog-generate-production-game PACKAGES_DIR GAME_ID:
|
||||
cargo run -p lanspread-compat --bin lanspread-catalog-publisher -- generate \
|
||||
|
||||
Reference in new issue
Block a user