Skip to content

Commit

Permalink
Show devnet warning if applicable. (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur2136 authored Apr 26, 2024
1 parent 7f6578d commit 60b71a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/cli/src/CliSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
dryRunSuccessMessage,
generateNetworkSuffix,
parseKeypair,
showMessage
showMessage,
showNetworkWarningIfApplicable
} from "./CliUtils.js";
import { LAMPORTS_PER_SOL } from "@solana/web3.js"
import * as dotenv from "dotenv";
Expand Down Expand Up @@ -104,6 +105,7 @@ export const createPublisherCliCmd = createCliCmd
.option("-p, --priority-fee-lamports <priority-fee-lamports>", "Priority Fee lamports")
.action(async ({ keypair, url, dryRun, storageConfig, priorityFeeLamports }) => {
await tryWithErrorMessage(async () => {
showNetworkWarningIfApplicable(url)
latestReleaseMessage();
await checkForSelfUpdate();

Expand Down Expand Up @@ -141,6 +143,7 @@ export const createAppCliCmd = createCliCmd
.option("-p, --priority-fee-lamports <priority-fee-lamports>", "Priority Fee lamports")
.action(async ({ publisherMintAddress, keypair, url, dryRun, storageConfig, priorityFeeLamports }) => {
await tryWithErrorMessage(async () => {
showNetworkWarningIfApplicable(url)
latestReleaseMessage();
await checkForSelfUpdate();

Expand Down Expand Up @@ -194,6 +197,7 @@ export const createReleaseCliCmd = createCliCmd
.option("-p, --priority-fee-lamports <priority-fee-lamports>", "Priority Fee lamports")
.action(async ({ appMintAddress, keypair, url, dryRun, buildToolsPath, storageConfig, priorityFeeLamports }) => {
await tryWithErrorMessage(async () => {
showNetworkWarningIfApplicable(url)
latestReleaseMessage();
await checkForSelfUpdate();

Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/CliUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ export const dryRunSuccessMessage = () => {
showMessage("Dry run", "Dry run was successful", "standard")
}

export const showNetworkWarningIfApplicable = (rpcUrl: string) => {
if (isDevnet(rpcUrl)) {
showMessage("Devnet Mode", "Running on Devnet", "warning")
} else if (isTestnet(rpcUrl)) {
showMessage("Testnet Mode", "Running on Testnet", "warning")
}
}

export const showMessage = (
titleMessage = "",
contentMessage = "",
Expand Down

0 comments on commit 60b71a6

Please sign in to comment.