diff --git a/Makefile b/Makefile index 0a615153..25ed2db7 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,29 @@ +PACKAGE_JSONS := package.json +PACKAGE_JSONS += packages/backend/package.json +PACKAGE_JSONS += packages/client/package.json +PACKAGE_JSONS += packages/firefish-js/package.json +PACKAGE_JSONS += packages/megalodon/package.json +PACKAGE_JSONS += packages/sw/package.json + +RUST_DIR := packages/backend/native-utils +CARGO_TOMLS := $(RUST_DIR)/Cargo.toml +CARGO_TOMLS += $(RUST_DIR)/migration/Cargo.toml + + .PHONY: build build: build-image .PHONY: pre-commit -pre-commit: shellcheck regenerate-entities update-index-js rust-lint +pre-commit: shellcheck pnpm-lock.yaml $(RUST_DIR)/Cargo.lock regenerate-entities update-index-js rust-lint + + +pnpm-lock.yaml: pnpm-workspace.yaml $(PACKAGE_JSONS) + pnpm install + + +$(RUST_DIR)/Cargo.lock: $(CARGO_TOMLS) + cd $(RUST_DIR) && cargo update .PHONY: debug @@ -22,13 +42,13 @@ shellcheck: .PHONY: rust-lint rust-lint: - cd packages/backend/native-utils && pnpm run lint + cd $(RUST_DIR) && pnpm run lint .PHONY: regenerate-entities regenerate-entities: pnpm run migrate - cd packages/backend/native-utils && \ + cd $(RUST_DIR) && \ sea-orm-cli generate entity \ --output-dir='src/model/entity' \ --database-url='postgres://firefish:password@localhost:25432/firefish_db' \ @@ -41,16 +61,16 @@ regenerate-entities: sed -i "s/NAPI_EXTRA_ATTR_PLACEHOLDER/$${attribute}/" "$${file}"; \ done sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \ - packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs + $(RUST_DIR)/src/model/entity/sea_orm_active_enums.rs .PHONY: update-index-js update-index-js: pnpm --filter='native-utils' run build:debug - [ -f packages/backend/native-utils/built/index.js ] + [ -f $(RUST_DIR)/built/index.js ] pnpm run format rm neko/index.js - cp packages/backend/native-utils/built/index.js neko/index.js + cp $(RUST_DIR)/built/index.js neko/index.js .PHONY: build-image