diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d042c9..c59855d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,9 @@ jobs: - name: Validate XML run: make validate + - name: Check translations + run: make check-translations + - name: Build catalog run: make build diff --git a/.gitignore b/.gitignore index cea53e0..f1180ae 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ Thumbs.db # Python __pycache__/ *.pyc +.pytest_cache/ diff --git a/Makefile b/Makefile index 2b250b3..3bb2620 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build clean validate test all schemas schema-validate lint +.PHONY: build clean validate test all schemas schema-validate lint check-translations DIST := dist SRC := src @@ -21,14 +21,17 @@ endif uv run x4cat extract "$(X4_GAME_DIR)" -o $(SCHEMAS) -g '*.xsd' @echo "Schemas extracted to $(SCHEMAS)/" +schema-validate: + uv run pytest tests/test_mod.py::TestSchema -q + lint: ifndef X4_GAME_DIR $(error X4_GAME_DIR not set — e.g. make lint X4_GAME_DIR="/path/to/X4 Foundations") endif uv run x4cat validate-diff "$(X4_GAME_DIR)" $(SRC) -schema-validate: - uv run pytest tests/test_mod.py::TestSchema -q +check-translations: + uv run x4cat validate-translations $(SRC) validate: uv run pytest tests/test_mod.py::TestValidate -q diff --git a/README.md b/README.md index 0dbb10c..5f8ab29 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Proof of concept [X4: Foundations](https://wiki.egosoft.com/X4%20Foundations%20Wiki/Modding%20Support/) extension mod template. -Uses [x4cat](https://github.com/meethune/x4cat) to pack mod files into `.cat/.dat` catalogs and validate diff patches. +Uses [x4cat](https://github.com/meethune/x4cat) to pack mod files into `.cat/.dat` catalogs, generate and validate diff patches, and manage translations. See the [x4cat documentation](https://meethune.github.io/x4cat/) for full reference. ## Structure @@ -13,6 +13,8 @@ src/ — Mod files (packed into catalog) aiscripts/ — AI behavior scripts libraries/ — Library XML diff patches dist/ — Build output (do not commit) +base/ — Extracted base files for xmldiff workflow (do not commit) +modified/ — Modified files for xmldiff workflow (do not commit) schemas/ — XSD schemas extracted from game (do not commit) tests/ — Build validation tests ``` @@ -47,18 +49,33 @@ x4cat xmldiff --base ./base/libraries/wares.xml \ # 4. Validate your patches against the game make lint X4_GAME_DIR="/path/to/X4 Foundations" -# 5. Build and test +# 5. Validate translations +make check-translations + +# 6. Build and test make all ``` +Or use scaffolding to generate boilerplate: + +```bash +# Scaffold a new ware +x4cat scaffold ware --id mymod_fuel --name "Super Fuel" --price-avg 500 -o src/ + +# Scaffold equipment by cloning an existing asset +x4cat scaffold equipment --id mymod_engine_macro --name "Fast Engine" \ + --clone-from engine_arg_s_allround_01_mk1_macro -o src/ +``` + ## Build ```bash -make all # validate, build, test -make build # pack src/ into dist/ext_01.cat + copy content.xml -make validate # XML well-formedness + structural checks -make test # full test suite (includes build verification) -make clean # remove dist/ +make all # validate, build, test +make build # pack src/ into dist/ext_01.cat + copy content.xml +make validate # XML well-formedness + structural checks +make check-translations # validate text references against t/*.xml +make test # full test suite (includes build verification) +make clean # remove dist/ ``` ## Diff patch linting @@ -70,8 +87,13 @@ the base game files they target: make lint X4_GAME_DIR="/path/to/X4 Foundations" ``` -Reports mismatches with file path, line number, and the failing XPath. -Skipped gracefully when no diff patches exist in `src/`. +## Conflict checking + +Check your mod against another mod for overlapping diff patches: + +```bash +x4cat check-conflicts src/ /path/to/other_mod/src/ +``` ## Schema validation diff --git a/src/libraries/.gitkeep b/src/libraries/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/uv.lock b/uv.lock index 5f48264..6ab3717 100644 --- a/uv.lock +++ b/uv.lock @@ -149,4 +149,4 @@ wheels = [ [[package]] name = "x4cat" version = "0.1.0" -source = { git = "https://github.com/meethune/x4cat.git#b0e17e142f05ef56aa4859b5d253d317a307b9b7" } +source = { git = "https://github.com/meethune/x4cat.git#0d0b5640d19c4b2738b11593d274086fceca6fa0" }