From c4f4652f35aee844963cc7e7faaea4bc1ad6628f Mon Sep 17 00:00:00 2001 From: Csongor Kiss Date: Sun, 28 Aug 2022 15:52:29 +0200 Subject: [PATCH] clients/js: Add command to start aptos validator commit-id:ab3ef326 --- clients/js/cmds/start.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 clients/js/cmds/start.ts diff --git a/clients/js/cmds/start.ts b/clients/js/cmds/start.ts new file mode 100644 index 000000000..d1570ab4f --- /dev/null +++ b/clients/js/cmds/start.ts @@ -0,0 +1,29 @@ +import yargs from "yargs"; +import { spawnSync } from 'child_process'; +import { config } from '../config'; + +exports.command = 'start-validator'; +exports.desc = 'Start a local validator'; +exports.builder = function(y: typeof yargs) { + return y.option("validator-args", { + alias: "a", + type: "string", + array: true, + default: [], + describe: "Additional args to validator", + }).command("aptos", "Start a local aptos validator", (yargs) => { + }, (argv) => { + const dir = `${config.wormholeDir}/aptos`; + // check if aptos is installed + const aptos = spawnSync("aptos", ["--version"]); + if (aptos.status !== 0) { + console.error("aptos is not installed. Please install aptos and try again."); + console.error(`See ${dir}/README.md for instructions.`); + process.exit(1); + } + const args = argv['validator-args'].map(a => `"${a}"`).join(" "); + const cmd = `cd ${dir} && aptos node run-local-testnet --with-faucet --force-restart --assume-yes ${args}`; + console.log("\x1b[33m%s\x1b[0m", cmd); + spawnSync(cmd, { shell: true, stdio: "inherit" }); + }).strict().demandCommand(); +}