forked from vis-eyth/bitcraft-bindings
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·25 lines (19 loc) · 1 KB
/
generate.sh
File metadata and controls
executable file
·25 lines (19 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
test -d src/global && rm -r src/global
test -d src/region && rm -r src/region
# global bindings
curl https://bitcraft-early-access.spacetimedb.com/v1/database/bitcraft-live-global/schema?version=9 | jq '{"V9": .}' > schema.json
spacetime generate --module-def schema.json --lang rs --out-dir src/global
rm schema.json
# region bindings
curl https://bitcraft-early-access.spacetimedb.com/v1/database/bitcraft-live-12/schema?version=9 | jq '{"V9": .}' > schema.json
spacetime generate --module-def schema.json --lang rs --out-dir src/region
rm schema.json
# strip message for version
# ST_VER='1\.4\.0'
# ST_REV=''
# find src -name "*.rs" -type f -exec \
# perl -i -0pe "s|\n\n// This was generated using spacetimedb cli version $ST_VER \(commit $ST_REV\)\.||g" {} +
# patch all DbUpdate fields to be pub
perl -i -pe '/pub struct DbUpdate \{/ .. /^\}/ and s/^(\s+)(\w+:[^:])/$1pub $2/' src/global/mod.rs src/region/mod.rs
perl -i -pe "s/^version = .*$/version = \"$(date -u +%Y.%-m.%-d)\"/" Cargo.toml