From 8ee9b9465f44f0f2eb3a7d7bcadcac4983b27c39 Mon Sep 17 00:00:00 2001 From: Aber Date: Wed, 21 Jun 2023 15:32:21 +0100 Subject: [PATCH 01/18] feat: update npm commands for Githun Actions CI --- clients/js/package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clients/js/package.json b/clients/js/package.json index c9c9ecd887..032431ff7c 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -19,7 +19,9 @@ "check": "tsc --noEmit", "docs": "npx tsx src/doc.ts", "prepublishOnly": "npm run check", - "test": "echo \"Error: no test specified\" && exit 1" + "make": "make install", + "test": "npm run make && jest --config jest.config.json", + "test-ci": "jest --config jest.config.json --verbose --forceExit" }, "author": "Wormhole Contributors", "license": "Apache-2.0", @@ -68,4 +70,4 @@ "copy-dir": "^1.3.0", "typescript": "^4.6" } -} +} \ No newline at end of file From 916ff2b5c84bd28d36f58441fb64e4365c33c296 Mon Sep 17 00:00:00 2001 From: Aber Date: Wed, 21 Jun 2023 16:21:19 +0100 Subject: [PATCH 02/18] feat: add worm cli github actions --- .github/workflows/worm-cli.yml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/worm-cli.yml diff --git a/.github/workflows/worm-cli.yml b/.github/workflows/worm-cli.yml new file mode 100644 index 0000000000..079ade533a --- /dev/null +++ b/.github/workflows/worm-cli.yml @@ -0,0 +1,42 @@ +name: Worm CLI + +on: + workflow_dispatch: + pull_request: + push: + branches: [main] + +jobs: + worm-cli: + runs-on: ubuntu-20.04 + strategy: + matrix: + node-version: [16.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Install + working-directory: ./clients/js + run: | + npm ci + + - name: build worm CLI (Makefile) + working-directory: ./clients/js + run: | + npm run make + + - name: Run tests + working-directory: ./clients/js + run: | + npm run test-ci + + - name: Review tests HTML report + working-directory: ./clients/js + run: | + echo "Visit Worm CLI test report here: $HTML_TEST_REPORT_PATH" + env: + HTML_TEST_REPORT_PATH: ./html-report/worm-cli-tests-report.html # This is relative to working-directory From 22053fcd8248bc443d32d30d1938ed5a5c02a80f Mon Sep 17 00:00:00 2001 From: Aber Date: Wed, 21 Jun 2023 18:36:48 +0100 Subject: [PATCH 03/18] feat: save HTML test report as artifact --- .github/workflows/worm-cli.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/worm-cli.yml b/.github/workflows/worm-cli.yml index 079ade533a..7d8b8cdbb8 100644 --- a/.github/workflows/worm-cli.yml +++ b/.github/workflows/worm-cli.yml @@ -34,9 +34,8 @@ jobs: run: | npm run test-ci - - name: Review tests HTML report - working-directory: ./clients/js - run: | - echo "Visit Worm CLI test report here: $HTML_TEST_REPORT_PATH" - env: - HTML_TEST_REPORT_PATH: ./html-report/worm-cli-tests-report.html # This is relative to working-directory + - name: Save HTML report as artifact + uses: actions/upload-artifact@v2 + with: + name: worm-cli-test-report + path: ./clients/js/html-report/worm-cli-tests-report.html From f8077af96776656377b36c69086dda5522b58734 Mon Sep 17 00:00:00 2001 From: Aber Date: Wed, 21 Jun 2023 19:29:41 +0100 Subject: [PATCH 04/18] chore: update github action, show report correctly --- .github/workflows/worm-cli.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/worm-cli.yml b/.github/workflows/worm-cli.yml index 7d8b8cdbb8..1a0074289c 100644 --- a/.github/workflows/worm-cli.yml +++ b/.github/workflows/worm-cli.yml @@ -38,4 +38,5 @@ jobs: uses: actions/upload-artifact@v2 with: name: worm-cli-test-report - path: ./clients/js/html-report/worm-cli-tests-report.html + # Must save entire folder as artifact to preview report as HTML + path: ./clients/js/html-report/ From 1413a051e9d0216fca7e88f0bb041983b7165ced Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Fri, 23 Jun 2023 16:25:11 +0100 Subject: [PATCH 05/18] fix: add missing CommandModule type --- clients/js/src/cmds/Yargs.ts | 4 +++- clients/js/src/cmds/info/index.ts | 17 +++++++++-------- clients/js/src/main.ts | 15 ++++++++------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/clients/js/src/cmds/Yargs.ts b/clients/js/src/cmds/Yargs.ts index 242338ffaf..65d4471abf 100644 --- a/clients/js/src/cmds/Yargs.ts +++ b/clients/js/src/cmds/Yargs.ts @@ -1,4 +1,4 @@ -import yargs from "yargs"; +import yargs, { CommandModule } from "yargs"; export class Yargs { yargs: typeof yargs; @@ -16,3 +16,5 @@ export class Yargs { } export type YargsAddCommandsFn = (y: typeof yargs) => typeof yargs; + +export type YargsCommandModule = CommandModule; diff --git a/clients/js/src/cmds/info/index.ts b/clients/js/src/cmds/info/index.ts index 0517a1c4e8..826c501d40 100644 --- a/clients/js/src/cmds/info/index.ts +++ b/clients/js/src/cmds/info/index.ts @@ -1,4 +1,4 @@ -import yargs from "yargs"; +import yargs, { CommandModule } from "yargs"; import * as chainId from "./chainId"; import * as contract from "./contract"; import * as emitter from "./emitter"; @@ -6,17 +6,18 @@ import * as origin from "./origin"; import * as registrations from "./registrations"; import * as rpc from "./rpc"; import * as wrapped from "./wrapped"; +import { YargsCommandModule } from "../Yargs"; export const command = "info"; export const desc = "Contract, chain, rpc and address information utilities"; // Imports modules logic from root commands, more info here -> https://github.com/yargs/yargs/blob/main/docs/advanced.md#providing-a-command-module export const builder = (y: typeof yargs) => y - .command(chainId) - .command(contract) - .command(emitter) - .command(origin) - .command(registrations) - .command(rpc) - .command(wrapped); + .command(chainId as unknown as YargsCommandModule) + .command(contract as unknown as YargsCommandModule) + .command(emitter as unknown as YargsCommandModule) + .command(origin as unknown as YargsCommandModule) + .command(registrations as unknown as YargsCommandModule) + .command(rpc as unknown as YargsCommandModule) + .command(wrapped as unknown as YargsCommandModule); export const handler = () => {}; diff --git a/clients/js/src/main.ts b/clients/js/src/main.ts index 2447995336..b5448bba26 100644 --- a/clients/js/src/main.ts +++ b/clients/js/src/main.ts @@ -18,6 +18,7 @@ import * as sui from "./cmds/sui"; import * as transfer from "./cmds/transfer"; import * as verifyVaa from "./cmds/verifyVaa"; import * as status from "./cmds/status"; +import { YargsCommandModule } from "./cmds/Yargs"; // Note: When adding another subcommand here, please be sure to also include it // in the `cmds` array in `docs.ts` so it is properly documented. @@ -25,17 +26,17 @@ yargs(hideBin(process.argv)) // https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts // can't use `.commandDir` because bundling + tree-shaking .command(aptos) - .command(editVaa) + .command(editVaa as unknown as YargsCommandModule) .command(evm) .command(generate) .command(info) .command(near) - .command(parse) - .command(recover) - .command(submit) + .command(parse as unknown as YargsCommandModule) + .command(recover as unknown as YargsCommandModule) + .command(submit as unknown as YargsCommandModule) .command(sui) - .command(transfer) - .command(verifyVaa) - .command(status) + .command(transfer as unknown as YargsCommandModule) + .command(verifyVaa as unknown as YargsCommandModule) + .command(status as unknown as YargsCommandModule) .strict() .demandCommand().argv; From c65cd13fbc4c801905e012ac5e622247740f655f Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Fri, 23 Jun 2023 16:31:42 +0100 Subject: [PATCH 06/18] chore: rm unused import --- clients/js/src/cmds/info/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/js/src/cmds/info/index.ts b/clients/js/src/cmds/info/index.ts index 826c501d40..108d735380 100644 --- a/clients/js/src/cmds/info/index.ts +++ b/clients/js/src/cmds/info/index.ts @@ -1,4 +1,4 @@ -import yargs, { CommandModule } from "yargs"; +import yargs from "yargs"; import * as chainId from "./chainId"; import * as contract from "./contract"; import * as emitter from "./emitter"; From c8f47597f77c68f3639a37901943cbb7c9f9caef Mon Sep 17 00:00:00 2001 From: Alber Erre Date: Mon, 3 Jul 2023 07:16:21 +0100 Subject: [PATCH 07/18] fix: override auto-detected locale by OS system --- clients/js/src/doc.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/clients/js/src/doc.ts b/clients/js/src/doc.ts index fc95704a95..3486b03015 100644 --- a/clients/js/src/doc.ts +++ b/clients/js/src/doc.ts @@ -1,5 +1,4 @@ import * as fs from "fs"; - import yargs from "yargs"; // Side effects are here to trigger before the afflicted libraries' on-import warnings can be emitted. // It is also imported so that it can side-effect without being tree-shaken. @@ -18,14 +17,17 @@ import * as sui from "./cmds/sui"; import * as verifyVaa from "./cmds/verifyVaa"; import * as status from "./cmds/status"; - const MD_TAG = ""; async function getHelpText(cmd: any): Promise { // Note that `yargs` is called as a function to produce a fresh copy. - // Otherwise the imported module is effectively a singleton where state from + // Otherwise the imported module is effectively a singleton where state from // other commands is accumulated from repeat calls. - return await cmd.builder(yargs()).scriptName(`worm ${cmd.command}`).getHelp(); + return await cmd + .builder(yargs()) + .scriptName(`worm ${cmd.command}`) + .locale("en") //NOTE: needed to override auto-detected locale from the user’s operating system + .getHelp(); } (async function () { @@ -41,14 +43,15 @@ async function getHelpText(cmd: any): Promise { submit, sui, verifyVaa, - status + status, ]; const helpOutputs: Buffer[] = []; for (const cmd of cmds) { const helpText = await getHelpText(cmd); - helpOutputs.push(Buffer.from(` + helpOutputs.push( + Buffer.from(`
${cmd.command} @@ -56,11 +59,10 @@ async function getHelpText(cmd: any): Promise { ${helpText} \`\`\`
-`)) +`) + ); } - - const f = fs.readFileSync("README.md"); const startIdx = f.indexOf(MD_TAG, 0); const stopIdx = f.indexOf(MD_TAG, startIdx + 1); @@ -68,7 +70,7 @@ ${helpText} const head = f.subarray(0, startIdx + MD_TAG.length); const tail = f.subarray(stopIdx, f.length); - const content = Buffer.concat([head, ...helpOutputs, tail]) + const content = Buffer.concat([head, ...helpOutputs, tail]); - fs.writeFileSync("README.md", content.toString()) + fs.writeFileSync("README.md", content.toString()); })(); From 9d27611ab73abf3a4c9d3236e46933c7dbdeaf67 Mon Sep 17 00:00:00 2001 From: Alber Erre Date: Tue, 4 Jul 2023 15:01:59 +0100 Subject: [PATCH 08/18] feat: infere command modules on doc.ts & main.ts --- clients/js/src/doc.ts | 31 +++--------------------------- clients/js/src/main.ts | 43 ++++++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 46 deletions(-) diff --git a/clients/js/src/doc.ts b/clients/js/src/doc.ts index 3486b03015..fb3bfcd6b7 100644 --- a/clients/js/src/doc.ts +++ b/clients/js/src/doc.ts @@ -3,19 +3,7 @@ import yargs from "yargs"; // Side effects are here to trigger before the afflicted libraries' on-import warnings can be emitted. // It is also imported so that it can side-effect without being tree-shaken. import "./side-effects"; -// https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs -import * as aptos from "./cmds/aptos"; -import * as editVaa from "./cmds/editVaa"; -import * as evm from "./cmds/evm"; -import * as generate from "./cmds/generate"; -import * as info from "./cmds/info"; -import * as near from "./cmds/near"; -import * as parse from "./cmds/parse"; -import * as recover from "./cmds/recover"; -import * as submit from "./cmds/submit"; -import * as sui from "./cmds/sui"; -import * as verifyVaa from "./cmds/verifyVaa"; -import * as status from "./cmds/status"; +import { CLI_COMMAND_MODULES } from "./main"; const MD_TAG = ""; @@ -26,25 +14,12 @@ async function getHelpText(cmd: any): Promise { return await cmd .builder(yargs()) .scriptName(`worm ${cmd.command}`) - .locale("en") //NOTE: needed to override auto-detected locale from the user’s operating system + .locale("en") //NOTE: 'locale' needed to override auto-detected locale from the user’s operating system .getHelp(); } (async function () { - const cmds = [ - aptos, - editVaa, - evm, - generate, - info, - near, - parse, - recover, - submit, - sui, - verifyVaa, - status, - ]; + const cmds = CLI_COMMAND_MODULES; const helpOutputs: Buffer[] = []; for (const cmd of cmds) { diff --git a/clients/js/src/main.ts b/clients/js/src/main.ts index b5448bba26..16c0ca28a9 100644 --- a/clients/js/src/main.ts +++ b/clients/js/src/main.ts @@ -20,23 +20,30 @@ import * as verifyVaa from "./cmds/verifyVaa"; import * as status from "./cmds/status"; import { YargsCommandModule } from "./cmds/Yargs"; -// Note: When adding another subcommand here, please be sure to also include it -// in the `cmds` array in `docs.ts` so it is properly documented. -yargs(hideBin(process.argv)) +export const CLI_COMMAND_MODULES = [ + aptos, + editVaa, + evm, + generate, + info, + near, + parse, + recover, + submit, + sui, + transfer, + verifyVaa, + status, +] as YargsCommandModule[]; + +const yargsCLI = yargs(hideBin(process.argv)); + +// Build CLI commands dinamically from CLI_COMMAND_MODULES list +CLI_COMMAND_MODULES.forEach((cmd) => { // https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts // can't use `.commandDir` because bundling + tree-shaking - .command(aptos) - .command(editVaa as unknown as YargsCommandModule) - .command(evm) - .command(generate) - .command(info) - .command(near) - .command(parse as unknown as YargsCommandModule) - .command(recover as unknown as YargsCommandModule) - .command(submit as unknown as YargsCommandModule) - .command(sui) - .command(transfer as unknown as YargsCommandModule) - .command(verifyVaa as unknown as YargsCommandModule) - .command(status as unknown as YargsCommandModule) - .strict() - .demandCommand().argv; + yargsCLI.command(cmd); +}); + +// run yargs CLI +yargsCLI.strict().demandCommand().argv; From b98eec91d7ad6fb8e293942f155d079ca8270a31 Mon Sep 17 00:00:00 2001 From: Alber Erre Date: Tue, 4 Jul 2023 16:07:25 +0100 Subject: [PATCH 09/18] feat: command args accepts an array of modules --- clients/js/src/cmds/Yargs.ts | 2 +- clients/js/src/main.ts | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/clients/js/src/cmds/Yargs.ts b/clients/js/src/cmds/Yargs.ts index 65d4471abf..93d431dda0 100644 --- a/clients/js/src/cmds/Yargs.ts +++ b/clients/js/src/cmds/Yargs.ts @@ -17,4 +17,4 @@ export class Yargs { export type YargsAddCommandsFn = (y: typeof yargs) => typeof yargs; -export type YargsCommandModule = CommandModule; +export type YargsCommandModule = CommandModule<{}, any>; diff --git a/clients/js/src/main.ts b/clients/js/src/main.ts index 16c0ca28a9..793590c47e 100644 --- a/clients/js/src/main.ts +++ b/clients/js/src/main.ts @@ -34,16 +34,10 @@ export const CLI_COMMAND_MODULES = [ transfer, verifyVaa, status, -] as YargsCommandModule[]; +]; -const yargsCLI = yargs(hideBin(process.argv)); - -// Build CLI commands dinamically from CLI_COMMAND_MODULES list -CLI_COMMAND_MODULES.forEach((cmd) => { - // https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts - // can't use `.commandDir` because bundling + tree-shaking - yargsCLI.command(cmd); -}); - -// run yargs CLI -yargsCLI.strict().demandCommand().argv; +yargs(hideBin(process.argv)) + // Build CLI commands dinamically from CLI_COMMAND_MODULES list + .command(CLI_COMMAND_MODULES as YargsCommandModule[]) + .strict() + .demandCommand().argv; From 98b0319df638fb6815a47ecd8f5cef5080ea9801 Mon Sep 17 00:00:00 2001 From: Alber Erre Date: Tue, 4 Jul 2023 22:51:41 +0100 Subject: [PATCH 10/18] fix: cmds must be outside main, breaks otherwise --- clients/js/src/cmds/index.ts | 30 ++++++++++++++++++++++++++++++ clients/js/src/main.ts | 31 +------------------------------ 2 files changed, 31 insertions(+), 30 deletions(-) create mode 100644 clients/js/src/cmds/index.ts diff --git a/clients/js/src/cmds/index.ts b/clients/js/src/cmds/index.ts new file mode 100644 index 0000000000..07d7bd899b --- /dev/null +++ b/clients/js/src/cmds/index.ts @@ -0,0 +1,30 @@ +// https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs +import * as aptos from "./aptos"; +import * as editVaa from "./editVaa"; +import * as evm from "./evm"; +import * as generate from "./generate"; +import * as info from "./info"; +import * as near from "./near"; +import * as parse from "./parse"; +import * as recover from "./recover"; +import * as submit from "./submit"; +import * as sui from "./sui"; +import * as transfer from "./transfer"; +import * as verifyVaa from "./verifyVaa"; +import * as status from "./status"; + +export const CLI_COMMAND_MODULES = [ + aptos, + editVaa, + evm, + generate, + info, + near, + parse, + recover, + submit, + sui, + transfer, + verifyVaa, + status, +]; diff --git a/clients/js/src/main.ts b/clients/js/src/main.ts index 793590c47e..c698f4b78a 100644 --- a/clients/js/src/main.ts +++ b/clients/js/src/main.ts @@ -4,37 +4,8 @@ import { hideBin } from "yargs/helpers"; // Side effects are here to trigger before the afflicted libraries' on-import warnings can be emitted. // It is also imported so that it can side-effect without being tree-shaken. import "./side-effects"; -// https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs -import * as aptos from "./cmds/aptos"; -import * as editVaa from "./cmds/editVaa"; -import * as evm from "./cmds/evm"; -import * as generate from "./cmds/generate"; -import * as info from "./cmds/info"; -import * as near from "./cmds/near"; -import * as parse from "./cmds/parse"; -import * as recover from "./cmds/recover"; -import * as submit from "./cmds/submit"; -import * as sui from "./cmds/sui"; -import * as transfer from "./cmds/transfer"; -import * as verifyVaa from "./cmds/verifyVaa"; -import * as status from "./cmds/status"; import { YargsCommandModule } from "./cmds/Yargs"; - -export const CLI_COMMAND_MODULES = [ - aptos, - editVaa, - evm, - generate, - info, - near, - parse, - recover, - submit, - sui, - transfer, - verifyVaa, - status, -]; +import { CLI_COMMAND_MODULES } from "./cmds"; yargs(hideBin(process.argv)) // Build CLI commands dinamically from CLI_COMMAND_MODULES list From d80a53c9a4d556fd97463ca35286c7d720036dfe Mon Sep 17 00:00:00 2001 From: Alber Erre Date: Tue, 4 Jul 2023 22:57:18 +0100 Subject: [PATCH 11/18] fix: import CLI_COMMAND_MODULES outside of main --- clients/js/src/doc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/js/src/doc.ts b/clients/js/src/doc.ts index fb3bfcd6b7..7d78aaf833 100644 --- a/clients/js/src/doc.ts +++ b/clients/js/src/doc.ts @@ -3,7 +3,7 @@ import yargs from "yargs"; // Side effects are here to trigger before the afflicted libraries' on-import warnings can be emitted. // It is also imported so that it can side-effect without being tree-shaken. import "./side-effects"; -import { CLI_COMMAND_MODULES } from "./main"; +import { CLI_COMMAND_MODULES } from "./cmds"; const MD_TAG = ""; From b39c548a994bc57705d339909dba42f7bb2f9385 Mon Sep 17 00:00:00 2001 From: Alber Erre Date: Tue, 4 Jul 2023 22:58:23 +0100 Subject: [PATCH 12/18] chore: add missing transfer command from README --- clients/js/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/clients/js/README.md b/clients/js/README.md index dae3c5bc24..ff699c6735 100644 --- a/clients/js/README.md +++ b/clients/js/README.md @@ -298,6 +298,33 @@ Options: ``` +
+ transfer + +```sh +Options: + --help Show help [boolean] + --version Show version number [boolean] + --src-chain source chain + [required] [choices: "solana", "ethereum", "terra", "bsc", "polygon", + "avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala", + "klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective", + "osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet", + "xpla", "btc", "base", "sei", "wormchain", "sepolia"] + --dst-chain destination chain + [required] [choices: "solana", "ethereum", "terra", "bsc", "polygon", + "avalanche", "oasis", "algorand", "aurora", "fantom", "karura", "acala", + "klaytn", "celo", "near", "moonbeam", "neon", "terra2", "injective", + "osmosis", "sui", "aptos", "arbitrum", "optimism", "gnosis", "pythnet", + "xpla", "btc", "base", "sei", "wormchain", "sepolia"] + --dst-addr destination address [string] [required] + --token-addr token address [string] [default: native token] + --amount token amount [string] [required] + -n, --network Network [required] [choices: "mainnet", "testnet", "devnet"] + --rpc RPC endpoint [string] +``` +
+
verify-vaa From 7eb8a7443d7b2915a3dd62e8f5dc75cc8715f5a7 Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Sun, 9 Jul 2023 10:14:01 +0100 Subject: [PATCH 13/18] chore: rm test branch dependencies --- .github/workflows/worm-cli.yml | 42 ---------------------------------- clients/js/package.json | 4 +--- 2 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 .github/workflows/worm-cli.yml diff --git a/.github/workflows/worm-cli.yml b/.github/workflows/worm-cli.yml deleted file mode 100644 index 1a0074289c..0000000000 --- a/.github/workflows/worm-cli.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Worm CLI - -on: - workflow_dispatch: - pull_request: - push: - branches: [main] - -jobs: - worm-cli: - runs-on: ubuntu-20.04 - strategy: - matrix: - node-version: [16.x] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - name: Install - working-directory: ./clients/js - run: | - npm ci - - - name: build worm CLI (Makefile) - working-directory: ./clients/js - run: | - npm run make - - - name: Run tests - working-directory: ./clients/js - run: | - npm run test-ci - - - name: Save HTML report as artifact - uses: actions/upload-artifact@v2 - with: - name: worm-cli-test-report - # Must save entire folder as artifact to preview report as HTML - path: ./clients/js/html-report/ diff --git a/clients/js/package.json b/clients/js/package.json index a4ecd58e89..529015af1a 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -19,9 +19,7 @@ "check": "tsc --noEmit", "docs": "npx tsx src/doc.ts", "prepublishOnly": "npm run check", - "make": "make install", - "test": "npm run make && jest --config jest.config.json", - "test-ci": "jest --config jest.config.json --verbose --forceExit" + "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Wormhole Contributors", "license": "Apache-2.0", From 6402d1be75f7379eafb642b714c01dca322e75cd Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Sun, 9 Jul 2023 10:30:33 +0100 Subject: [PATCH 14/18] feat: extract info cmds into array const --- clients/js/src/cmds/info/index.ts | 19 ++++--------------- clients/js/src/cmds/info/info.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 clients/js/src/cmds/info/info.ts diff --git a/clients/js/src/cmds/info/index.ts b/clients/js/src/cmds/info/index.ts index 108d735380..a346ba498f 100644 --- a/clients/js/src/cmds/info/index.ts +++ b/clients/js/src/cmds/info/index.ts @@ -1,23 +1,12 @@ import yargs from "yargs"; -import * as chainId from "./chainId"; -import * as contract from "./contract"; -import * as emitter from "./emitter"; -import * as origin from "./origin"; -import * as registrations from "./registrations"; -import * as rpc from "./rpc"; -import * as wrapped from "./wrapped"; import { YargsCommandModule } from "../Yargs"; +import { INFO_COMMANDS } from "./info"; export const command = "info"; export const desc = "Contract, chain, rpc and address information utilities"; // Imports modules logic from root commands, more info here -> https://github.com/yargs/yargs/blob/main/docs/advanced.md#providing-a-command-module export const builder = (y: typeof yargs) => - y - .command(chainId as unknown as YargsCommandModule) - .command(contract as unknown as YargsCommandModule) - .command(emitter as unknown as YargsCommandModule) - .command(origin as unknown as YargsCommandModule) - .command(registrations as unknown as YargsCommandModule) - .command(rpc as unknown as YargsCommandModule) - .command(wrapped as unknown as YargsCommandModule); + // Commands can be imported as an array of commands. + // Documentation about command hierarchy can be found here: https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs + y.command(INFO_COMMANDS as unknown as YargsCommandModule); export const handler = () => {}; diff --git a/clients/js/src/cmds/info/info.ts b/clients/js/src/cmds/info/info.ts new file mode 100644 index 0000000000..6f5a6438f9 --- /dev/null +++ b/clients/js/src/cmds/info/info.ts @@ -0,0 +1,19 @@ +import * as chainId from "./chainId"; +import * as contract from "./contract"; +import * as emitter from "./emitter"; +import * as origin from "./origin"; +import * as registrations from "./registrations"; +import * as rpc from "./rpc"; +import * as wrapped from "./wrapped"; + +// Commands can be imported as an array of commands. +// Documentation about command hierarchy can be found here: https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs +export const INFO_COMMANDS = [ + chainId, + contract, + emitter, + origin, + registrations, + rpc, + wrapped, +]; From 1209c61256b9042cd84ef2458db2af0dd2bd05a7 Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Sun, 9 Jul 2023 10:31:03 +0100 Subject: [PATCH 15/18] chore: document command imports as list --- clients/js/src/cmds/index.ts | 2 ++ clients/js/src/main.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clients/js/src/cmds/index.ts b/clients/js/src/cmds/index.ts index 07d7bd899b..ebf9f15c68 100644 --- a/clients/js/src/cmds/index.ts +++ b/clients/js/src/cmds/index.ts @@ -13,6 +13,8 @@ import * as transfer from "./transfer"; import * as verifyVaa from "./verifyVaa"; import * as status from "./status"; +// Commands can be imported as an array of commands. +// Documentation about command hierarchy can be found here: https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs export const CLI_COMMAND_MODULES = [ aptos, editVaa, diff --git a/clients/js/src/main.ts b/clients/js/src/main.ts index c698f4b78a..89572469c4 100644 --- a/clients/js/src/main.ts +++ b/clients/js/src/main.ts @@ -9,6 +9,7 @@ import { CLI_COMMAND_MODULES } from "./cmds"; yargs(hideBin(process.argv)) // Build CLI commands dinamically from CLI_COMMAND_MODULES list - .command(CLI_COMMAND_MODULES as YargsCommandModule[]) + // Documentation about command hierarchy can be found here: https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs + .command(CLI_COMMAND_MODULES as unknown as YargsCommandModule) .strict() .demandCommand().argv; From fd009f47fcd35e12302c7e7372b004df56b9ccc3 Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Sun, 9 Jul 2023 10:33:24 +0100 Subject: [PATCH 16/18] chore: package.json spacing --- clients/js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/js/package.json b/clients/js/package.json index 529015af1a..fdae4edac3 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -69,4 +69,4 @@ "copy-dir": "^1.3.0", "typescript": "^4.6" } -} \ No newline at end of file +} From ae13aa751e124303705a99fef7c18d4465aedbd2 Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Sun, 9 Jul 2023 23:22:05 +0100 Subject: [PATCH 17/18] chore: bump @types/yargs version --- clients/js/package-lock.json | 14 +++++++------- clients/js/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clients/js/package-lock.json b/clients/js/package-lock.json index 7bfc6f3696..34765d9c68 100644 --- a/clients/js/package-lock.json +++ b/clients/js/package-lock.json @@ -48,7 +48,7 @@ "@types/bn.js": "^5.1.0", "@types/bs58": "^4.0.1", "@types/node-fetch": "^2.6.3", - "@types/yargs": "^17.0.2", + "@types/yargs": "^17.0.24", "copy-dir": "^1.3.0", "typescript": "^4.6" } @@ -3531,9 +3531,9 @@ } }, "node_modules/@types/yargs": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.2.tgz", - "integrity": "sha512-JhZ+pNdKMfB0rXauaDlrIvm+U7V4m03PPOSVoPS66z8gf+G4Z/UW8UlrVIj2MRQOBzuoEvYtjS0bqYwnpZaS9Q==", + "version": "17.0.24", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", + "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", "dev": true, "dependencies": { "@types/yargs-parser": "*" @@ -10878,9 +10878,9 @@ } }, "@types/yargs": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.2.tgz", - "integrity": "sha512-JhZ+pNdKMfB0rXauaDlrIvm+U7V4m03PPOSVoPS66z8gf+G4Z/UW8UlrVIj2MRQOBzuoEvYtjS0bqYwnpZaS9Q==", + "version": "17.0.24", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.24.tgz", + "integrity": "sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==", "dev": true, "requires": { "@types/yargs-parser": "*" diff --git a/clients/js/package.json b/clients/js/package.json index fdae4edac3..86d801333d 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -65,7 +65,7 @@ "@types/bn.js": "^5.1.0", "@types/bs58": "^4.0.1", "@types/node-fetch": "^2.6.3", - "@types/yargs": "^17.0.2", + "@types/yargs": "^17.0.24", "copy-dir": "^1.3.0", "typescript": "^4.6" } From 6bdb56b6eac2f0013754c8ff92d46bd6f6cd1e03 Mon Sep 17 00:00:00 2001 From: Aber Erre Date: Sun, 9 Jul 2023 23:23:03 +0100 Subject: [PATCH 18/18] feat: cast correct array type YargsCommandModule[] --- clients/js/src/cmds/Yargs.ts | 2 +- clients/js/src/cmds/info/index.ts | 2 +- clients/js/src/main.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clients/js/src/cmds/Yargs.ts b/clients/js/src/cmds/Yargs.ts index 93d431dda0..65d4471abf 100644 --- a/clients/js/src/cmds/Yargs.ts +++ b/clients/js/src/cmds/Yargs.ts @@ -17,4 +17,4 @@ export class Yargs { export type YargsAddCommandsFn = (y: typeof yargs) => typeof yargs; -export type YargsCommandModule = CommandModule<{}, any>; +export type YargsCommandModule = CommandModule; diff --git a/clients/js/src/cmds/info/index.ts b/clients/js/src/cmds/info/index.ts index a346ba498f..005e316cce 100644 --- a/clients/js/src/cmds/info/index.ts +++ b/clients/js/src/cmds/info/index.ts @@ -8,5 +8,5 @@ export const desc = "Contract, chain, rpc and address information utilities"; export const builder = (y: typeof yargs) => // Commands can be imported as an array of commands. // Documentation about command hierarchy can be found here: https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs - y.command(INFO_COMMANDS as unknown as YargsCommandModule); + y.command(INFO_COMMANDS as unknown as YargsCommandModule[]); export const handler = () => {}; diff --git a/clients/js/src/main.ts b/clients/js/src/main.ts index 89572469c4..8f7bac2bad 100644 --- a/clients/js/src/main.ts +++ b/clients/js/src/main.ts @@ -10,6 +10,6 @@ import { CLI_COMMAND_MODULES } from "./cmds"; yargs(hideBin(process.argv)) // Build CLI commands dinamically from CLI_COMMAND_MODULES list // Documentation about command hierarchy can be found here: https://github.com/yargs/yargs/blob/main/docs/advanced.md#example-command-hierarchy-using-indexmjs - .command(CLI_COMMAND_MODULES as unknown as YargsCommandModule) + .command(CLI_COMMAND_MODULES as YargsCommandModule[]) .strict() .demandCommand().argv;