added warning to all CLI commands
This commit is contained in:
parent
6614f09b40
commit
8021d5c900
|
@ -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((<Input<any>>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;
|
||||
|
|
|
@ -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((<Input<any>>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}`
|
||||
);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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`;
|
|
@ -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 ");
|
||||
|
|
Loading…
Reference in New Issue