From 8021d5c9004ef844df9478983bc1a98f7b17bc57 Mon Sep 17 00:00:00 2001 From: Conner Gallagher Date: Thu, 1 Sep 2022 11:25:16 -0600 Subject: [PATCH] added warning to all CLI commands --- cli/src/BaseCommand.ts | 3 +++ cli/src/OutputFileBaseCommand.ts | 16 ++++++++++------ cli/src/PrintBaseCommand.ts | 4 +++- cli/src/announcement.ts | 8 ++++++++ cli/src/utils/icons.ts | 2 ++ 5 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 cli/src/announcement.ts diff --git a/cli/src/BaseCommand.ts b/cli/src/BaseCommand.ts index c052ff0..44fbd47 100644 --- a/cli/src/BaseCommand.ts +++ b/cli/src/BaseCommand.ts @@ -18,6 +18,7 @@ import Big from "big.js"; import chalk from "chalk"; import * as fs from "fs"; import * as path from "path"; +import { CURRENT_ANNOUNCEMENT } from "./announcement"; import { CliConfig, ConfigParameter, DEFAULT_CONFIG } from "./config"; import { AuthorityMismatch } from "./types"; import { CommandContext } from "./types/context/context"; @@ -74,6 +75,8 @@ abstract class BaseCommand extends Command { const { flags } = await this.parse((>this.constructor) as any); BaseCommand.flags = flags as any; + console.log(CURRENT_ANNOUNCEMENT); + // setup logging this.silent = (flags as any).silent; this.verbose = (flags as any).verbose; diff --git a/cli/src/OutputFileBaseCommand.ts b/cli/src/OutputFileBaseCommand.ts index d8ccab4..c3ceeda 100644 --- a/cli/src/OutputFileBaseCommand.ts +++ b/cli/src/OutputFileBaseCommand.ts @@ -5,6 +5,7 @@ import { SwitchboardDecimal } from "@switchboard-xyz/switchboard-v2"; import Big from "big.js"; import fs from "fs"; import path from "path"; +import { CURRENT_ANNOUNCEMENT } from "./announcement"; import BaseCommand from "./BaseCommand"; abstract class OutputFileBaseCommand extends BaseCommand { @@ -40,25 +41,28 @@ abstract class OutputFileBaseCommand extends BaseCommand { const { flags } = await this.parse((>this.constructor) as any); BaseCommand.flags = flags as any; + console.log(CURRENT_ANNOUNCEMENT); + const parsedPath = path.parse( - flags.outputFile.startsWith("/") || flags.outputFile.startsWith("C:") - ? flags.outputFile - : path.join(process.cwd(), flags.outputFile) + (flags as any).outputFile.startsWith("/") || + (flags as any).outputFile.startsWith("C:") + ? (flags as any).outputFile + : path.join(process.cwd(), (flags as any).outputFile) ); this.outputBasePath = path.join(parsedPath.dir, parsedPath.name); if (parsedPath.ext === ".json" || flags.json) { this.outputJsonFile = `${this.outputBasePath}.json`; - if (fs.existsSync(this.outputJsonFile) && !flags.force) { + if (fs.existsSync(this.outputJsonFile) && !(flags as any).force) { throw new Error( `output json file already exists: ${this.outputJsonFile}` ); } } - if (parsedPath.ext === ".csv" || flags.csv) { + if (parsedPath.ext === ".csv" || (flags as any).csv) { this.outputCsvFile = `${this.outputBasePath}.csv`; - if (fs.existsSync(this.outputCsvFile) && !flags.force) { + if (fs.existsSync(this.outputCsvFile) && !(flags as any).force) { throw new Error( `output csv file already exists: ${this.outputCsvFile}` ); diff --git a/cli/src/PrintBaseCommand.ts b/cli/src/PrintBaseCommand.ts index 1786ac8..39ef162 100644 --- a/cli/src/PrintBaseCommand.ts +++ b/cli/src/PrintBaseCommand.ts @@ -3,7 +3,6 @@ import * as anchor from "@project-serum/anchor"; import { ACCOUNT_DISCRIMINATOR_SIZE } from "@project-serum/anchor/dist/cjs/coder"; import { clusterApiUrl, Connection, Keypair, PublicKey } from "@solana/web3.js"; import { - DEFAULT_KEYPAIR, prettyPrintAggregator, prettyPrintBufferRelayer, prettyPrintCrank, @@ -31,6 +30,7 @@ import { } from "@switchboard-xyz/switchboard-v2"; import chalk from "chalk"; import * as path from "path"; +import { CURRENT_ANNOUNCEMENT } from "./announcement"; import { CliConfig } from "./config"; import { FsProvider } from "./types"; import { CommandContext } from "./types/context/context"; @@ -64,6 +64,8 @@ abstract class PrintBaseCommand extends Command { const { flags } = (await this.parse(this.constructor as any)) as any; // this.flags = flags; + console.log(CURRENT_ANNOUNCEMENT); + // setup logging const level = flags.silent ? "error" : flags.verbose ? "debug" : "info"; const logFilename = path.join(this.config.cacheDir, "log.txt"); diff --git a/cli/src/announcement.ts b/cli/src/announcement.ts new file mode 100644 index 0000000..0ba8350 --- /dev/null +++ b/cli/src/announcement.ts @@ -0,0 +1,8 @@ +import chalk from "chalk"; +// import { WARNING_ICON } from "./utils"; + +export const CURRENT_ANNOUNCEMENT = `${chalk.bgYellowBright( + chalk.bold(`WARNING`) +)}\n${chalk.blue( + `This package has been deprecated in favor of @switchboard-xyz/cli. Run the following commands to update:` +)}\n${`\tnpm uninstall -g @switchboard-xyz/switchboardv2-cli\n\tnpm install -g @switchboard-xyz/cli`}\nor\n\tyarn global remove @switchboard-xyz/switchboardv2-cli\n\tyarn global add @switchboard-xyz/cli\n`; diff --git a/cli/src/utils/icons.ts b/cli/src/utils/icons.ts index ac5555d..d5ca0ca 100644 --- a/cli/src/utils/icons.ts +++ b/cli/src/utils/icons.ts @@ -3,3 +3,5 @@ import chalk from "chalk"; export const CHECK_ICON = chalk.green("\u2714 "); export const FAILED_ICON = chalk.red("\u2717 "); + +export const WARNING_ICON = chalk.yellowBright("\u26A0 ");