diff --git a/Makefile b/Makefile index fbb3398e..709ce0b9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +T := dev/make_virtual_target + PACKAGE_JSONS := package.json PACKAGE_JSONS += packages/backend/package.json PACKAGE_JSONS += packages/client/package.json @@ -13,19 +15,28 @@ RUSTY_STUFF := $(foreach dir, $(RUST_DIR)/src, $(wildcard $(dir)/*)) RUSTY_STUFF += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*)) RUSTY_STUFF += $(CARGO_TOMLS) +MIGRATIONS := $(foreach dir, packages/backend/migration, $(wildcard $(dir)/*)) +MIGRATIONS += $(foreach dir, packages/backend/migration-neko, $(wildcard $(dir)/*)) +MIGRATIONS += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*)) + +UPDATE_SCRIPTS := update.sh +UPDATE_SCRIPTS += $(foreach dir, neko/update, $(wildcard $(dir)/*)) + .PHONY: build build: build-image .PHONY: pre-commit -pre-commit: shellcheck pnpm-lock.yaml $(RUST_DIR)/Cargo.lock regenerate-entities neko/index.js rust-lint +pre-commit: shellcheck update-lockfiles regenerate-entities neko/index.js rust-lint +.PHONY: update-lockfiles +update-lockfiles: pnpm-lock.yaml $(RUST_DIR)/Cargo.lock + pnpm-lock.yaml: pnpm-workspace.yaml $(PACKAGE_JSONS) pnpm install - $(RUST_DIR)/Cargo.lock: $(CARGO_TOMLS) cd $(RUST_DIR) && cargo update @@ -39,18 +50,25 @@ debug: .PHONY: shellcheck -shellcheck: - shellcheck --external-sources update.sh - shellcheck --external-sources neko/update/* +shellcheck: $(T)/shellcheck + +$(T)/shellcheck: $(UPDATE_SCRIPTS) + shellcheck --external-sources $^ + touch $@ .PHONY: rust-lint -rust-lint: +rust-lint: $(T)/rust-lint + +$(T)/rust-lint: cd $(RUST_DIR) && pnpm run lint + touch $@ .PHONY: regenerate-entities -regenerate-entities: +regenerate-entities: $(T)/regenerate-entities + +$(T)/regenerate-entities: $(MIGRATIONS) pnpm run migrate cd $(RUST_DIR) && \ sea-orm-cli generate entity \ @@ -66,6 +84,7 @@ regenerate-entities: done sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \ $(RUST_DIR)/src/model/entity/sea_orm_active_enums.rs + touch $@ neko/index.js: $(RUSTY_STUFF) diff --git a/dev/make_virtual_target/.gitignore b/dev/make_virtual_target/.gitignore new file mode 100644 index 00000000..5e7d2734 --- /dev/null +++ b/dev/make_virtual_target/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore