-
Notifications
You must be signed in to change notification settings - Fork 3
/
check.sh
executable file
·47 lines (40 loc) · 1.36 KB
/
check.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
cd $PROJECT_ROOT
echo "--- DATABASE ---"
echo "Checking if SQL queries are prepared..."
if [ ! -d "types/.sqlx" ] || [ ! -n "$(ls -A "types/.sqlx")" ]; then
echo "Prepared queries not present. run 'dev-generate-types'."
exit 1
fi
echo "Checking if SQL types are up to date..."
if $(cd types && cargo sqlx prepare --check -- -p dailp &>/dev/null); then
echo "Generating SQL types..."
cd types
cargo sqlx prepare -- -p dailp &>/dev/null || exit 1
cd $PROJECT_ROOT
fi
echo "--- SERVER ---"
echo "Formatting Rust code..."
cargo fmt &>/dev/null
echo "Checking back-end for errors..."
export SQLX_OFFLINE=true
cargo check &>/dev/null ||
(echo "Back-end build failed, run 'cargo check' for details." && exit 1)
echo "Generating GraphQL schema..."
cargo run --bin dailp-graphql-schema &>/dev/null ||
(echo "GraphQL server build failed, run 'cargo check' for details." && exit 1)
echo "--- WEBSITE ---"
cd website
echo "Formatting TypeScript code..."
yarn prettier --write --config package.json src &>/dev/null
echo "Generating Typescript types for GraphQL queries..."
yarn generate
echo "Checking website for errors..."
yarn tsc || exit 1
echo "--- FINAL CHECKS ---"
cd $PROJECT_ROOT
echo "Checking documentation and formatting..."
./.git-hooks/pre-commit || exit 1
echo
echo "--- NEXT STEPS ---"
echo "Please stage relevant automatic changes"