From 383479263a288bd3c5dd7d44b177324630c38b3e Mon Sep 17 00:00:00 2001 From: Nathan HERVIER <113121626+Elli610@users.noreply.github.com> Date: Wed, 16 Aug 2023 12:53:53 +0200 Subject: [PATCH] add protofile retrieving it only gets protofiles. Callers are not generated --- packages/massa-proto-cli/src/index.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/massa-proto-cli/src/index.ts b/packages/massa-proto-cli/src/index.ts index 75e630fa..975b396a 100644 --- a/packages/massa-proto-cli/src/index.ts +++ b/packages/massa-proto-cli/src/index.ts @@ -7,6 +7,8 @@ import { Command } from 'commander'; import { MassaCustomType, extractTypes } from '@massalabs/as-transformer'; import * as dotenv from 'dotenv'; import { existsSync, mkdirSync } from 'fs'; +import path from 'path'; + // Load .env file content into process.env dotenv.config(); const program = new Command(); @@ -43,9 +45,9 @@ if (!publicApi) { async function run() { const args = program.opts(); let files: ProtoFile[] = []; - let mode = args['gen']; - let address = args['addr']; - let out = args['out']; + let mode: string = args['gen']; + let address: string = args['addr']; + let out: string = args['out']; if (mode === '' || address === '' || publicApi === undefined) { program.help(); @@ -57,6 +59,17 @@ async function run() { mkdirSync(out); } + // if mode is 'get-protofile', we only need to fetch the proto files and save them + if (mode === 'get-protofile') { + const folderName = address.slice(-10); + // check if the folder exists + if (!existsSync(path.join(out, folderName))) { + mkdirSync(path.join(out, folderName)); + } + await getProtoFiles([address], out + '/' + folderName, publicApi); + return; + } + // call sc client to fetch protos const mpFiles: MassaProtoFile[] = await getProtoFiles( [address],