From c3512a8aa99e0fa9c9469a60b65c1d90383aad48 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sat, 7 Feb 2026 17:18:36 +0100 Subject: [PATCH] chore(meta): add ck3-tiger linting via Makefile Adds static analysis for CK3 mod files using ck3-tiger. The Makefile downloads the platform-specific binary and persists the CK3 game directory path for validation runs. Targets: make setup, make lint, make clean Config: lords_of_ash/ck3-tiger.conf (English only, hide vanilla) Commit skill updated with pre-commit lint step. Co-Authored-By: Claude Opus 4.6 --- .claude/skills/commit/SKILL.md | 7 ++++ .gitignore | 3 ++ Makefile | 71 ++++++++++++++++++++++++++++++++++ lords_of_ash/ck3-tiger.conf | 8 ++++ 4 files changed, 89 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 lords_of_ash/ck3-tiger.conf diff --git a/.claude/skills/commit/SKILL.md b/.claude/skills/commit/SKILL.md index 4cef41f..005a0cf 100644 --- a/.claude/skills/commit/SKILL.md +++ b/.claude/skills/commit/SKILL.md @@ -132,6 +132,13 @@ both files together as: chore(meta): release v1.1.0 ``` +## Pre-commit Lint + +Before committing, run `make lint` to validate the mod with ck3-tiger. If the +linter reports errors, fix them before committing. Warnings are acceptable but +should be noted in the commit body if relevant. Skip this step if `make lint` +is not set up (i.e., `make setup` has not been run). + ## Staging Rules - Stage files by name — never use `git add -A` or `git add .` diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..551f0d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.env +.lords-of-ash-local.mod +tools/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b720b18 --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +.PHONY: setup lint clean help + +TIGER_VERSION := 1.15.0 +TIGER_BIN := tools/ck3-tiger +ENV_FILE := .env +LOCAL_MOD := .lords-of-ash-local.mod + +-include $(ENV_FILE) + +# Detect platform for binary download +UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) +ifeq ($(UNAME_S),Linux) + TIGER_ARCHIVE := ck3-tiger-linux-v$(TIGER_VERSION).tar.gz +else ifeq ($(UNAME_S),Darwin) + TIGER_ARCHIVE := +else ifneq (,$(findstring MINGW,$(UNAME_S))) + TIGER_ARCHIVE := ck3-tiger-windows-v$(TIGER_VERSION).zip +else ifneq (,$(findstring MSYS,$(UNAME_S))) + TIGER_ARCHIVE := ck3-tiger-windows-v$(TIGER_VERSION).zip +else + TIGER_ARCHIVE := +endif + +TIGER_URL := https://github.com/amtep/tiger/releases/download/v$(TIGER_VERSION)/$(TIGER_ARCHIVE) + +help: ## Show available targets + @grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*##"}; {printf " %-12s %s\n", $$1, $$2}' + +setup: ## Configure ck3-tiger (usage: make setup CK3_GAME_DIR=/path/to/ck3) +ifndef CK3_GAME_DIR + $(error CK3_GAME_DIR is required. Usage: make setup CK3_GAME_DIR=/path/to/ck3) +endif + @test -d "$(CK3_GAME_DIR)/game" || (echo "Error: $(CK3_GAME_DIR)/game not found. Is this the CK3 install directory?" && exit 1) + @echo 'CK3_GAME_DIR=$(CK3_GAME_DIR)' > $(ENV_FILE) + @sed 's|path="mod/lords_of_ash"|path="lords_of_ash"|' lords-of-ash.mod > $(LOCAL_MOD) +ifeq ($(TIGER_ARCHIVE),) + @echo "Warning: no pre-built ck3-tiger binary for $(UNAME_S)/$(UNAME_M)." + @echo "Install manually: cargo install ck3-tiger" +else + @if [ ! -x $(TIGER_BIN) ]; then \ + echo "Downloading ck3-tiger v$(TIGER_VERSION) for $(UNAME_S)..."; \ + mkdir -p tools; \ + curl -fsSL "$(TIGER_URL)" -o "tools/$(TIGER_ARCHIVE)"; \ + case "$(TIGER_ARCHIVE)" in \ + *.tar.gz) tar -xzf "tools/$(TIGER_ARCHIVE)" -C tools;; \ + *.zip) unzip -qo "tools/$(TIGER_ARCHIVE)" -d tools;; \ + esac; \ + mv tools/ck3-tiger-*/ck3-tiger $(TIGER_BIN); \ + rm -rf tools/ck3-tiger-*/ "tools/$(TIGER_ARCHIVE)"; \ + echo "Installed $(TIGER_BIN)"; \ + else \ + echo "ck3-tiger already installed."; \ + fi +endif + @echo "Setup complete. Run 'make lint' to validate the mod." + +lint: ## Run ck3-tiger against the mod + @test -f $(ENV_FILE) || (echo "Run 'make setup CK3_GAME_DIR=/path/to/ck3' first." && exit 1) + @test -f $(LOCAL_MOD) || (echo "Run 'make setup CK3_GAME_DIR=/path/to/ck3' first." && exit 1) + @if [ -x $(TIGER_BIN) ]; then \ + $(TIGER_BIN) --game "$(CK3_GAME_DIR)" $(LOCAL_MOD); \ + elif command -v ck3-tiger >/dev/null 2>&1; then \ + ck3-tiger --game "$(CK3_GAME_DIR)" $(LOCAL_MOD); \ + else \ + echo "ck3-tiger not found. Run 'make setup' or install via 'cargo install ck3-tiger'."; \ + exit 1; \ + fi + +clean: ## Remove generated local files and tools + rm -rf tools $(ENV_FILE) $(LOCAL_MOD) diff --git a/lords_of_ash/ck3-tiger.conf b/lords_of_ash/ck3-tiger.conf new file mode 100644 index 0000000..9ac7797 --- /dev/null +++ b/lords_of_ash/ck3-tiger.conf @@ -0,0 +1,8 @@ +languages = { + check = english +} + +filter = { + show_vanilla = no + show_loaded_mods = no +}