lemmy-js-client/copy_generated_types_from_lemmy.sh
Dessalines c1545659b2
Upgrading to use ts-rs 10.0.0 (#394)
* Upgrading to use ts-ns 10.0.0

* Adding no_comments_only
2024-11-07 12:07:49 -05:00

39 lines
956 B
Bash
Executable file

#!/bin/bash
# Remove the old types
rm -rf src/types/*
# Remove the old bindings
pushd ../lemmy/crates
rm -rf **/bindings
popd
# First re-generate the types by running cargo test on lemmy
pushd ../lemmy
cargo test --workspace export_bindings
cd crates
# Copy them over to the types folder
cp api_common/bindings/* ../../lemmy-js-client/src/types/
cp db_schema/bindings/* ../../lemmy-js-client/src/types/
cp db_views/bindings/* ../../lemmy-js-client/src/types/
cp db_views_actor/bindings/* ../../lemmy-js-client/src/types/
cp db_views_moderator/bindings/* ../../lemmy-js-client/src/types/
cp utils/bindings/* ../../lemmy-js-client/src/types/
popd
# Remove the Sensitive type
rm src/types/Sensitive.ts
# Change all the bigints to numbers
find src/types -type f -name '*.ts' -exec sed -i 's/bigint/number/g' {} +
# on MacOS:
# find src/types -type f -name '*.ts' -exec sed -i '' -e 's/bigint/number/g' {} \;
node putTypesInIndex.js
prettier -w src