Skip to content

Commit

Permalink
Copy over only generated types and REST file: index.ts is now custom
Browse files Browse the repository at this point in the history
  • Loading branch information
dib542 committed Jul 22, 2022
1 parent 739bd7a commit bae0b6d
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions scripts/update-generated-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
# use provided source path or a default
DUALITY_CORE_DIRECTORY="${1:-"../duality"}"

# copy files
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/module" \
"src/generated/duality/duality.duality"
# copy type files
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/module/types" \
"src/lib/web3/generated/duality/duality.duality/module"

# copy REST API file
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/module/rest.ts" \
"src/lib/web3/generated/duality/duality.duality/module/rest.ts"

# copy version info
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/package.json" \
"src/generated/duality/duality.duality/package.json"
"src/lib/web3/generated/duality/duality.duality/package.json"

# copy readme info
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/readme.md" \
"src/generated/readme.md"

# TODO: fix Starports terrible code
# the follow code should work in some environment?: https://unix.stackexchange.com/questions/26284/how-can-i-use-sed-to-replace-a-multi-line-string#525524

REPLACE_THIS="let client;\n if (addr) {\n client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry });\n }else{\n client = await SigningStargateClient.offline( wallet, { registry });\n }"
REPLACE_WITH="const client = addr\n ? await SigningStargateClient.connectWithSigner(addr, wallet, { registry })\n : await SigningStargateClient.offline( wallet, { registry });"

sed -z "s/$REPLACE_THIS/$REPLACE_WITH/" -i src/generated/duality/duality.duality/module/index.ts
"src/lib/web3/generated/readme.md"

0 comments on commit bae0b6d

Please sign in to comment.