PLUGIN_ID := beaver-calendar
ASSETS    := manifest.json main.js styles.css versions.json

.PHONY: install zip _build

_build:
	npm install --silent
	npm run build

install: _build
	@test -n "$(VAULT)" || (echo "set VAULT=<path-to-vault>" >&2; exit 1)
	@test -d "$(VAULT)/.obsidian" || (echo "no .obsidian dir at $(VAULT)" >&2; exit 1)
	@target="$(VAULT)/.obsidian/plugins/$(PLUGIN_ID)"; \
	 mkdir -p "$$target"; \
	 cp $(ASSETS) "$$target/"; \
	 echo "installed → $$target"

zip: _build
	@version=$$(node -p "require('./manifest.json').version"); \
	 out="$(PLUGIN_ID)-$$version.zip"; \
	 rm -f "$$out"; \
	 zip -q -j "$$out" $(ASSETS); \
	 echo "wrote $$out"
