mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
cosmwasm-stargate: Update scripts for ts-proto
This commit is contained in:
parent
3a6cf02c8b
commit
1b3be09c31
@ -31,8 +31,8 @@
|
||||
"move-types": "shx rm -rf ./types/* && shx mv build/types/* ./types && rm -rf ./types/testdata ./types/*.spec.d.ts ./types/*/*.spec.d.ts",
|
||||
"format-types": "prettier --write --loglevel warn \"./types/**/*.d.ts\"",
|
||||
"prebuild": "shx rm -rf ./build",
|
||||
"build": "tsc && shx mkdir -p build/codec/generated && shx cp ./src/codec/generated/*.js ./build/codec/generated",
|
||||
"postbuild": "shx mkdir -p ./build/types/codec/generated && shx cp ./src/codec/generated/*.d.ts ./build/types/codec/generated && yarn move-types && yarn format-types",
|
||||
"build": "tsc && shx cp -R ./src/codec ./build/ && shx mkdir -p ./build/types/codec && shx cp -R ./src/codec ./build/types/",
|
||||
"postbuild": "yarn move-types && yarn format-types",
|
||||
"build-or-skip": "[ -n \"$SKIP_BUILD\" ] || yarn build",
|
||||
"test-node": "node jasmine-testrunner.js",
|
||||
"test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox",
|
||||
@ -42,9 +42,8 @@
|
||||
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js",
|
||||
"preget-proto": "shx rm -rf proto",
|
||||
"get-proto": "WASM_REF=v0.14.0 COSMOS_REF=v0.40.0 ./scripts/get-proto.sh",
|
||||
"predefine-proto": "./scripts/predefine-proto.sh",
|
||||
"define-proto": "./scripts/define-proto.sh",
|
||||
"postdefine-proto": "prettier --write \"src/codec/generated/codecimpl.*\""
|
||||
"postdefine-proto": "prettier --write \"src/codec/**/*.ts\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/cosmwasm-launchpad": "^0.24.0-alpha.22",
|
||||
|
@ -2,15 +2,23 @@
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
|
||||
TMP_DIR="./tmp"
|
||||
JS_SOURCE_FILE="$TMP_DIR/codecimpl.js"
|
||||
DEFINITIONS_FILE="$TMP_DIR/codecimpl.d.ts"
|
||||
OUTPUT_DIR="./src/codec/generated/"
|
||||
ROOT_PROTO_DIR="./proto"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/proto"
|
||||
THIRD_PARTY_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/third_party/proto"
|
||||
WASMD_PROTO_DIR="$ROOT_PROTO_DIR/cosmwasm/wasmd"
|
||||
OUT_DIR="./src/codec/"
|
||||
|
||||
yarn pbts "$JS_SOURCE_FILE" -o "$DEFINITIONS_FILE"
|
||||
# Remove comments after using them for the .d.ts
|
||||
# Note "When input files are specified on the command line, tsconfig.json files are ignored." (https://www.typescriptlang.org/docs/handbook/tsconfig-json.html)
|
||||
yarn tsc --removeComments --target es2017 --module commonjs --outDir "$OUTPUT_DIR" --allowJs "$JS_SOURCE_FILE"
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
cp "$DEFINITIONS_FILE" "$OUTPUT_DIR"
|
||||
rm "$DEFINITIONS_FILE" "$JS_SOURCE_FILE"
|
||||
protoc \
|
||||
--plugin="$(yarn bin protoc-gen-ts_proto)" \
|
||||
--ts_proto_out="$OUT_DIR" \
|
||||
--proto_path="$COSMOS_PROTO_DIR" \
|
||||
--proto_path="$THIRD_PARTY_PROTO_DIR" \
|
||||
--proto_path="$WASMD_PROTO_DIR" \
|
||||
--ts_proto_opt="esModuleInterop=true,forceLong=long,useOptionals=true" \
|
||||
"$WASMD_PROTO_DIR/x/wasm/internal/types/types.proto" \
|
||||
"$WASMD_PROTO_DIR/x/wasm/internal/types/query.proto" \
|
||||
"$WASMD_PROTO_DIR/x/wasm/internal/types/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/base/v1beta1/coin.proto" \
|
||||
"$COSMOS_PROTO_DIR/cosmos/base/query/v1beta1/pagination.proto"
|
||||
|
@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
|
||||
GENERATED_DIR="./tmp"
|
||||
ROOT_PROTO_DIR="./proto"
|
||||
WASM_PROTO_DIR="$ROOT_PROTO_DIR/cosmwasm/wasmd/x/wasm"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/cosmos/cosmos-sdk/proto/cosmos"
|
||||
|
||||
mkdir -p "$GENERATED_DIR"
|
||||
# Can't use --sparse for some reason. Seems related to https://github.com/protobufjs/protobuf.js/issues/1165
|
||||
yarn pbjs \
|
||||
-t static-module \
|
||||
--es6 \
|
||||
-w commonjs \
|
||||
-o "$GENERATED_DIR/codecimpl.js" \
|
||||
--no-beautify \
|
||||
--no-delimited \
|
||||
--no-verify \
|
||||
--no-convert \
|
||||
--force-long \
|
||||
"$WASM_PROTO_DIR/internal/types/query.proto" \
|
||||
"$WASM_PROTO_DIR/internal/types/tx.proto" \
|
||||
"$WASM_PROTO_DIR/internal/types/types.proto" \
|
||||
"$COSMOS_PROTO_DIR/base/v1beta1/coin.proto" \
|
||||
"$COSMOS_PROTO_DIR/base/query/v1beta1/pagination.proto"
|
||||
|
||||
# Work around https://github.com/protobufjs/protobuf.js/issues/1477
|
||||
# shellcheck disable=SC2016
|
||||
sed -i "" -e 's/^const \$root =.*$/const \$root = {};/' "$GENERATED_DIR/codecimpl.js"
|
Loading…
x
Reference in New Issue
Block a user