2024-01-22 01:29:49 +09:00
|
|
|
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
|
|
|
|
|
2024-01-22 01:34:26 +09:00
|
|
|
RUSTY_STUFF := $(foreach dir, $(RUST_DIR)/src, $(wildcard $(dir)/*))
|
|
|
|
RUSTY_STUFF += $(foreach dir, $(RUST_DIR)/migration/src, $(wildcard $(dir)/*))
|
|
|
|
RUSTY_STUFF += $(CARGO_TOMLS)
|
|
|
|
|
2024-01-22 01:29:49 +09:00
|
|
|
|
2024-01-14 19:48:41 +09:00
|
|
|
.PHONY: build
|
2024-01-14 20:15:05 +09:00
|
|
|
build: build-image
|
2024-01-14 19:48:41 +09:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: pre-commit
|
2024-01-22 01:34:26 +09:00
|
|
|
pre-commit: shellcheck pnpm-lock.yaml $(RUST_DIR)/Cargo.lock regenerate-entities neko/index.js rust-lint
|
2024-01-22 01:29:49 +09:00
|
|
|
|
|
|
|
|
|
|
|
pnpm-lock.yaml: pnpm-workspace.yaml $(PACKAGE_JSONS)
|
|
|
|
pnpm install
|
|
|
|
|
|
|
|
|
|
|
|
$(RUST_DIR)/Cargo.lock: $(CARGO_TOMLS)
|
|
|
|
cd $(RUST_DIR) && cargo update
|
2024-01-14 19:48:41 +09:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: debug
|
|
|
|
debug:
|
|
|
|
pnpm install
|
|
|
|
pnpm run build:debug
|
|
|
|
pnpm run migrate
|
|
|
|
pnpm run start
|
2024-01-10 12:08:13 +09:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: shellcheck
|
|
|
|
shellcheck:
|
|
|
|
shellcheck --external-sources update.sh
|
2024-01-14 20:15:05 +09:00
|
|
|
shellcheck --external-sources neko/update/*
|
2024-01-14 19:48:41 +09:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: rust-lint
|
|
|
|
rust-lint:
|
2024-01-22 01:29:49 +09:00
|
|
|
cd $(RUST_DIR) && pnpm run lint
|
2024-01-14 19:48:41 +09:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: regenerate-entities
|
|
|
|
regenerate-entities:
|
2024-01-19 00:16:13 +09:00
|
|
|
pnpm run migrate
|
2024-01-22 01:29:49 +09:00
|
|
|
cd $(RUST_DIR) && \
|
2024-01-14 19:48:41 +09:00
|
|
|
sea-orm-cli generate entity \
|
|
|
|
--output-dir='src/model/entity' \
|
2024-01-20 05:57:00 +09:00
|
|
|
--database-url='postgres://firefish:password@localhost:25432/firefish_db' \
|
|
|
|
--date-time-crate='chrono' \
|
2024-01-21 02:13:13 +09:00
|
|
|
--model-extra-attributes='NAPI_EXTRA_ATTR_PLACEHOLDER' && \
|
|
|
|
for file in src/model/entity/*; do \
|
|
|
|
base=$$(basename -- "$${file}"); \
|
|
|
|
jsname=$$(printf '%s\n' "$${base%.*}" | perl -pe 's/(^|_)./uc($$&)/ge;s/_//g'); \
|
|
|
|
attribute=$$(printf 'napi_derive::napi(object, js_name = "%s")' "$${jsname}"); \
|
|
|
|
sed -i "s/NAPI_EXTRA_ATTR_PLACEHOLDER/$${attribute}/" "$${file}"; \
|
|
|
|
done
|
2024-01-20 05:57:00 +09:00
|
|
|
sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \
|
2024-01-22 01:29:49 +09:00
|
|
|
$(RUST_DIR)/src/model/entity/sea_orm_active_enums.rs
|
2024-01-14 19:48:41 +09:00
|
|
|
|
2024-01-20 08:33:18 +09:00
|
|
|
|
2024-01-22 01:34:26 +09:00
|
|
|
neko/index.js: $(RUSTY_STUFF)
|
2024-01-14 20:15:05 +09:00
|
|
|
pnpm --filter='native-utils' run build:debug
|
2024-01-22 01:29:49 +09:00
|
|
|
[ -f $(RUST_DIR)/built/index.js ]
|
2024-01-14 20:15:05 +09:00
|
|
|
pnpm run format
|
|
|
|
rm neko/index.js
|
2024-01-22 01:29:49 +09:00
|
|
|
cp $(RUST_DIR)/built/index.js neko/index.js
|
2024-01-14 20:15:05 +09:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: build-image
|
2024-01-14 21:57:23 +09:00
|
|
|
build-image:
|
2024-01-07 07:02:43 +09:00
|
|
|
. neko/update/utils && \
|
|
|
|
buildah build \
|
|
|
|
--no-cache \
|
|
|
|
--platform linux/amd64 \
|
|
|
|
--build-arg "VERSION=$$(version_ci)" \
|
|
|
|
--tag docker.io/naskya/firefish \
|
|
|
|
--tag registry.code.naskya.net/naskya/firefish \
|
|
|
|
--tag "registry.code.naskya.net/naskya/firefish:$$(version_ci | cut -d':' -f2)" \
|
|
|
|
.
|