2024-04-07 05:23:37 +02:00
|
|
|
recursive_wildcard = $(foreach d, $(wildcard $(1:=/*)), $(call recursive_wildcard, $d, $2) $(filter $(subst *, %, $2), $d))
|
|
|
|
|
|
|
|
SRC := Cargo.toml
|
|
|
|
SRC += $(call recursive_wildcard, src, *)
|
|
|
|
|
|
|
|
|
2024-03-22 17:39:12 +01:00
|
|
|
.PHONY: regenerate-entities
|
|
|
|
regenerate-entities:
|
|
|
|
sea-orm-cli generate entity \
|
2024-04-13 12:49:31 +02:00
|
|
|
--output-dir='src/model/entity' \
|
|
|
|
--database-url='postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@localhost:25432/$(POSTGRES_DB)' \
|
|
|
|
--date-time-crate='chrono' \
|
2024-04-06 21:58:43 +02: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 'cfg_attr(feature = "napi", napi_derive::napi(object, js_name = "%s", use_nullable = true))' "$${jsname}"); \
|
|
|
|
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#[cfg_attr(not(feature = "napi"), derive(Clone))]\n#[cfg_attr(feature = "napi", napi_derive::napi)]/' \
|
|
|
|
src/model/entity/sea_orm_active_enums.rs
|
2024-04-11 23:55:39 +02:00
|
|
|
cargo fmt --all --
|
2024-03-22 18:01:37 +01:00
|
|
|
|
2024-04-12 04:59:44 +02:00
|
|
|
.PHONY: update-index
|
|
|
|
update-index: index.js index.d.ts
|
|
|
|
|
|
|
|
index.js index.d.ts: $(SRC)
|
2024-03-22 18:01:37 +01:00
|
|
|
NODE_OPTIONS='--max_old_space_size=3072' pnpm run build:debug
|
2024-04-12 04:59:44 +02:00
|
|
|
[ -f built/index.js ] && [ -f built/index.d.ts ]
|
|
|
|
rm --force index.js index.d.ts
|
2024-03-22 18:01:37 +01:00
|
|
|
cp built/index.js index.js
|
2024-04-12 04:59:44 +02:00
|
|
|
cp built/index.d.ts index.d.ts
|
|
|
|
sed -i 's/^ \*r"/ */g' index.d.ts
|