Skip to content

Commit

Permalink
fix(kadena-cli): add empty log message for networks + empty state lev…
Browse files Browse the repository at this point in the history
…el to warning (#2152)
  • Loading branch information
realdreamer committed May 28, 2024
1 parent f385a62 commit 7e1eb30
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/five-pans-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kadena/kadena-cli": minor
---

Add empty state warning message for network list command
All empty state log level to warning for consistency
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const createAccountListCommand: (
const isAccountAliasesExist = await ensureAccountAliasFilesExists();

if (!isAccountAliasesExist) {
return log.error(NO_ACCOUNTS_FOUND_ERROR_MESSAGE);
return log.warning(NO_ACCOUNTS_FOUND_ERROR_MESSAGE);
}

const { accountAlias } = await option.accountAlias();
Expand Down
6 changes: 3 additions & 3 deletions packages/tools/kadena-cli/src/keys/utils/keysDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export async function printPlainKeys(plainKeys: IPlainKey[]): Promise<void> {
});

if (plainKeys.length === 0) {
log.info('There are no key files in your working directory.');
log.info('You can add one using:\n');
log.info(' kadena key generate');
log.warning('There are no key files in your working directory.');
log.warning('You can add one using:\n');
log.warning(' kadena key generate');
return;
}
for (const key of plainKeys) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it } from 'vitest';
import { CWD_KADENA_DIR } from '../../constants/config.js';
import { NO_NETWORKS_FOUND_ERROR_MESSAGE } from '../../constants/networks.js';
import { services } from '../../services/index.js';
import { runCommand, runCommandJson } from '../../utils/test.util.js';

Expand All @@ -10,8 +11,8 @@ describe('network list command', () => {
}
});
it('should return empty networks list', async () => {
const res = await runCommandJson('network list');
expect(res.networks).toEqual([]);
const res = await runCommand('network list');
expect(res.stderr).toContain(NO_NETWORKS_FOUND_ERROR_MESSAGE);
});

it('should return networks list', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { networkDefaults } from '../../constants/networks.js';
import {
NO_NETWORKS_FOUND_ERROR_MESSAGE,
networkDefaults,
} from '../../constants/networks.js';

import { log } from '../../utils/logger.js';

Expand Down Expand Up @@ -37,6 +40,10 @@ export async function displayNetworksConfig(): Promise<void> {
const defaultNetworkName = await getDefaultNetworkName();
const existingNetworks: ICustomNetworkChoice[] = await getExistingNetworks();

if (existingNetworks.length === 0) {
return log.warning(NO_NETWORKS_FOUND_ERROR_MESSAGE);
}

const networks = await Promise.all(
existingNetworks.map(async (network) => {
const networkFilePath = path.join(networkDir!, `${network.value}.yaml`);
Expand Down
4 changes: 2 additions & 2 deletions packages/tools/kadena-cli/src/wallets/commands/walletList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const createListWalletsCommand: (
return log.error(`Selected wallet not found.`);
} else if (Array.isArray(config.walletNameConfig)) {
if (config.walletNameConfig.length === 0) {
log.info('There are no wallets created. You can add one with:\n');
log.info(' kadena wallet add');
log.warning('There are no wallets created. You can add one with:\n');
log.warning(' kadena wallet add');
}
for (const wallet of config.walletNameConfig) {
await printWalletKeys(wallet);
Expand Down

0 comments on commit 7e1eb30

Please sign in to comment.