-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgenerate-bindings
executable file
·45 lines (30 loc) · 2.48 KB
/
generate-bindings
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
#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/.common"
BASEDIR="$(dirname "${BASH_SOURCE[0]}")"
# Generate types
FOLDER_PATH="$BASEDIR/../services/headless-lms/"
RELATIVE_PATH=$(realpath --relative-to="$(pwd)" "$FOLDER_PATH")
run_command cd "$RELATIVE_PATH" || exit
run_command env SQLX_OFFLINE=1 cargo test --features ts_rs --lib ts_binding_generator
# Fix formatting
run_command sed -i '1s;^;// ###########################################\n// ## This file is autogenerated by running ## \n// ## "bin/generate-bindings" in the root ##\n// ## folder of this repo ##\n// ## ##\n// ## Do not edit this file by hand. ##\n// ###########################################\n\n;' ../../shared-module/packages/common/src/bindings.ts
run_command npm run eslint:format-bindings
# Go back from headless-lms to the root directory
run_command cd ../..
if [ -f "./shared-module/packages/common/src/bindings.guard.ts" ]; then
run_command rm ./shared-module/packages/common/src/bindings.guard.ts
fi
run_command npx ts-auto-guard --export-all --paths ./shared-module/packages/common/src/bindings.ts --project shared-module/packages/common/tsconfig.json
run_command sed -i '1s;^;/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n;' shared-module/packages/common/src/bindings.guard.ts
run_command npx eslint --fix shared-module/packages/common/src/bindings.ts shared-module/packages/common/src/bindings.guard.ts
if [ -f "./shared-module/packages/common/src/exercise-service-protocol-types.guard.ts" ]; then
run_command rm ./shared-module/packages/common/src/exercise-service-protocol-types.guard.ts
fi
run_command npx ts-auto-guard --export-all --paths ./shared-module/packages/common/src/exercise-service-protocol-types.ts --project shared-module/packages/common/tsconfig.json
run_command sed -i '1s;^;/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\n\n;' shared-module/packages/common/src/exercise-service-protocol-types.guard.ts
run_command npx eslint --fix shared-module/packages/common/src/exercise-service-protocol-types.guard.ts
# Post-update for shared module
run_command npm run postinstall
echo ""
echo -e "${GREEN}✅ The files ${CURSIVE}bindings.ts${RESET_EVERYTHING}${GREEN} and ${CURSIVE}bindings.guard.ts${RESET_EVERYTHING}${GREEN} have been generated in the shared module.${RESET_EVERYTHING}"