1
0
Fork 1
mirror of https://example.com synced 2024-11-22 14:26:40 +09:00

dev: run make recipes only when needed

This commit is contained in:
naskya 2024-01-22 01:50:35 +09:00
parent 7d5e062a21
commit 79be37ea47
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
2 changed files with 30 additions and 7 deletions

View file

@ -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)

4
dev/make_virtual_target/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore