From 067ced422c85fb0af0c7f480e2e16f2afaad6879 Mon Sep 17 00:00:00 2001 From: matthiasmatt Date: Thu, 21 Mar 2024 12:07:56 +0100 Subject: [PATCH 1/3] feat: add justfile target to generate ts --- justfile | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/justfile b/justfile index 757808e..7111483 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,7 @@ workspaces := "./packages" # workspaces := "./packages ./core" +set dotenv-load # Displays available recipes by running `just -l`. setup: #!/usr/bin/env bash @@ -90,12 +91,47 @@ tidy-update: build-update just tidy gen-schema: - #!/usr/bin/env bash - for dir in contracts/*/; do - dir_name=$(basename $dir) - - echo "Generating schema for $dir" - cd $dir - cargo schema - mv ./schema ../../schema/$dir_name - done \ No newline at end of file + #!/usr/bin/env bash + initial_dir=$PWD + for dir in contracts/*; do + dir_name=$(basename $dir) + echo "Generating schema for $dir_name..." + + # Change to the contract directory + if cd $dir; then + # Check if 'cargo schema' can be run successfully + if cargo schema; then + # Move back to the initial directory + cd $initial_dir + # Create target schema directory if it doesn't exist + mkdir -p schema/$dir_name + # Move the generated schema to the target directory + if ! mv $dir/schema schema/$dir_name; then + echo "Failed to move schema directory for $dir_name." + fi + else + cd $initial_dir + fi + else + echo "Failed to change directory to $dir." + fi + done + + +gen-ts: + #!/usr/bin/env bash + just gen-schema + + SCHEMA_DIR="./schema" + TS_OUT_DIR="./dist" + mkdir -p $TS_OUT_DIR + for schema_path in $(find $SCHEMA_DIR -name schema -type d | grep -v "^./schema$"); do + contract_name=$(basename $(dirname $schema_path)) + echo "Generating TypeScript for $contract_name..." + cosmwasm-ts-codegen generate \ + --plugin client \ + --schema $schema_path \ + --out $TS_OUT_DIR/$contract_name \ + --name $contract_name \ + --no-bundle + done From 7402a3d857142adacb226c64fea8a3fc1319448c Mon Sep 17 00:00:00 2001 From: matthiasmatt Date: Thu, 21 Mar 2024 14:51:31 +0100 Subject: [PATCH 2/3] wip: add ci/cd --- .github/workflows/publish-ts.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/publish-ts.yml diff --git a/.github/workflows/publish-ts.yml b/.github/workflows/publish-ts.yml new file mode 100644 index 0000000..771c65c --- /dev/null +++ b/.github/workflows/publish-ts.yml @@ -0,0 +1,28 @@ +name: Publish TypeScript Code + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: "14" + + - name: Install Dependencies + run: npm install -g @cosmwasm/ts-codegen + + - name: Generate TypeScript Clients + run: just gen-ts + + - name: Publish TypeScript Code + run: | + rsync -avz ./dist/ user@your-deployment-server:/path/to/app.nibiru.fi/ts + env: + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} From a9a2bfffc8f0f8125b0edf9a008dee812d3fe5ef Mon Sep 17 00:00:00 2001 From: matthiasmatt Date: Thu, 21 Mar 2024 15:48:39 +0100 Subject: [PATCH 3/3] fix: remove ci and add doc --- .github/workflows/publish-ts.yml | 28 ---------------------------- justfile | 2 +- 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 .github/workflows/publish-ts.yml diff --git a/.github/workflows/publish-ts.yml b/.github/workflows/publish-ts.yml deleted file mode 100644 index 771c65c..0000000 --- a/.github/workflows/publish-ts.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Publish TypeScript Code - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: "14" - - - name: Install Dependencies - run: npm install -g @cosmwasm/ts-codegen - - - name: Generate TypeScript Clients - run: just gen-ts - - - name: Publish TypeScript Code - run: | - rsync -avz ./dist/ user@your-deployment-server:/path/to/app.nibiru.fi/ts - env: - DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} diff --git a/justfile b/justfile index 7111483..943bb8f 100644 --- a/justfile +++ b/justfile @@ -117,7 +117,7 @@ gen-schema: fi done - +# Generate schema for all contracts and generate TypeScript code gen-ts: #!/usr/bin/env bash just gen-schema