build.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. # Load and export variables from root .env file into shell environment
  6. set -a
  7. . ../.env
  8. set +a
  9. # Install codegen tools (outside of workspaces to avoid @polkadot/api conflicts)
  10. yarn --cwd codegen install
  11. yarn clean
  12. yarn codegen:noinstall
  13. yarn typegen # if this fails try to run this command outside of yarn workspaces
  14. # TS4 useUnknownInCatchVariables is not compatible with auto-generated code
  15. # i.bak is used for Mac compatibility
  16. sed -i.bak '/\"compilerOptions\"\:\ {/a \ \ \ \ "useUnknownInCatchVariables": false,' ./generated/graphql-server/tsconfig.json
  17. rm ./generated/graphql-server/tsconfig.json.bak
  18. # Type assertions are no longer needed for createTypeUnsafe in @polkadot/api 5.9.1 (and they break the build)
  19. # Here we're relpacing createTypeUnsafe<Assertions>(...params) to createTypeUnsafe(...params) in all generated types:
  20. find ./mappings/generated -type f -print0 | xargs -0 sed -i.bak -r 's/createTypeUnsafe<[^(]+[(]/createTypeUnsafe(/g'
  21. find ./mappings/generated -type f -iname "*.bak" -print0 | xargs -0 rm -f
  22. # We run yarn again to ensure graphql-server dependencies are installed
  23. # and are inline with root workspace resolutions
  24. yarn
  25. yarn workspace query-node codegen
  26. yarn workspace query-node build
  27. yarn workspace query-node-mappings build