diff --git a/src/commands/flags.mjs b/src/commands/flags.mjs index a9bb67466..3ab06b0b9 100644 --- a/src/commands/flags.mjs +++ b/src/commands/flags.mjs @@ -756,6 +756,19 @@ export const adminKey = { } /** @type {CommandFlag} **/ +export const quiet = { + constName: 'quiet', + name: 'quiet-mode', + definition: { + describe: 'Quiet mode, do not prompt for confirmation', + defaultValue: false, + alias: 'q', + type: 'boolean', + disablePrompt: true + } +} + +/** @type {CommandFlag[]} **/ export const mirrorNodeVersion = { constName: 'mirrorNodeVersion', name: 'mirror-node-version', @@ -765,6 +778,7 @@ export const mirrorNodeVersion = { type: 'string' } } + /** @type {CommandFlag[]} **/ export const allFlags = [ accountId, diff --git a/src/commands/mirror_node.mjs b/src/commands/mirror_node.mjs index 498fc4d0a..e8a50bee4 100644 --- a/src/commands/mirror_node.mjs +++ b/src/commands/mirror_node.mjs @@ -59,6 +59,7 @@ export class MirrorNodeCommand extends BaseCommand { flags.namespace, flags.profileFile, flags.profileName, + flags.quiet, flags.tlsClusterIssuerType, flags.valuesFile, flags.mirrorNodeVersion diff --git a/src/commands/network.mjs b/src/commands/network.mjs index d00048ba4..3bf8cc5bd 100644 --- a/src/commands/network.mjs +++ b/src/commands/network.mjs @@ -76,6 +76,7 @@ export class NetworkCommand extends BaseCommand { flags.persistentVolumeClaims, flags.profileFile, flags.profileName, + flags.quiet, flags.releaseTag, flags.settingTxt, flags.valuesFile diff --git a/src/commands/node.mjs b/src/commands/node.mjs index 4216c8716..72ed24d1e 100644 --- a/src/commands/node.mjs +++ b/src/commands/node.mjs @@ -112,6 +112,30 @@ export class NodeCommand extends BaseCommand { ] } + /** + * @returns {CommandFlag[]} + */ + static get START_FLAGS_LIST () { + return [ + flags.app, + flags.debugNodeId, + flags.namespace, + flags.nodeIDs, + flags.quiet + ] + } + + /** + * @returns {CommandFlag[]} + */ + static get STOP_FLAGS_LIST () { + return [ + flags.namespace, + flags.nodeIDs, + flags.quiet + ] + } + /** * @returns {string} */ @@ -128,7 +152,8 @@ export class NodeCommand extends BaseCommand { flags.devMode, flags.generateGossipKeys, flags.generateTlsKeys, - flags.nodeIDs + flags.nodeIDs, + flags.quiet ] } @@ -150,6 +175,7 @@ export class NodeCommand extends BaseCommand { flags.localBuildPath, flags.namespace, flags.nodeIDs, + flags.quiet, flags.releaseTag ] } @@ -179,6 +205,7 @@ export class NodeCommand extends BaseCommand { flags.gossipEndpoints, flags.grpcEndpoints, flags.localBuildPath, + flags.quiet, flags.namespace, flags.releaseTag ] @@ -244,6 +271,7 @@ export class NodeCommand extends BaseCommand { flags.localBuildPath, flags.namespace, flags.nodeID, + flags.quiet, flags.releaseTag ] } @@ -270,6 +298,7 @@ export class NodeCommand extends BaseCommand { flags.newAccountNumber, flags.newAdminKey, flags.nodeID, + flags.quiet, flags.releaseTag, flags.tlsPrivateKey, flags.tlsPublicKey @@ -1143,6 +1172,7 @@ export class NodeCommand extends BaseCommand { title: 'Initialize', task: async (ctx, task) => { self.configManager.update(argv) + await prompts.execute(task, self.configManager, [ flags.namespace, flags.nodeIDs @@ -2391,10 +2421,7 @@ export class NodeCommand extends BaseCommand { command: 'start', desc: 'Start a node', builder: y => flags.setCommandFlags(y, - flags.app, - flags.debugNodeId, - flags.namespace, - flags.nodeIDs + NodeCommand.START_FLAGS_LIST ), handler: argv => { nodeCmd.logger.debug('==== Running \'node start\' ===') @@ -2413,8 +2440,7 @@ export class NodeCommand extends BaseCommand { command: 'stop', desc: 'Stop a node', builder: y => flags.setCommandFlags(y, - flags.namespace, - flags.nodeIDs + NodeCommand.STOP_FLAGS_LIST ), handler: argv => { nodeCmd.logger.debug('==== Running \'node stop\' ===') diff --git a/src/commands/prompts.mjs b/src/commands/prompts.mjs index 69c134b26..4a8007cf9 100644 --- a/src/commands/prompts.mjs +++ b/src/commands/prompts.mjs @@ -498,6 +498,9 @@ export async function execute (task, configManager, flagList = []) { } const prompt = prompts.get(flag.name) + if (configManager.getFlag(flags.quiet)) { + return + } const input = await prompt(task, configManager.getFlag(flag)) configManager.setFlag(flag, input) } diff --git a/src/commands/relay.mjs b/src/commands/relay.mjs index 77a8e4e31..7f18352a6 100644 --- a/src/commands/relay.mjs +++ b/src/commands/relay.mjs @@ -59,12 +59,24 @@ export class RelayCommand extends BaseCommand { flags.operatorKey, flags.profileFile, flags.profileName, + flags.quiet, flags.relayReleaseTag, flags.replicaCount, flags.valuesFile ] } + /** + * @returns {CommandFlag[]} + */ + static get DESTROY_FLAGS_LIST () { + return [ + flags.chartDirectory, + flags.namespace, + flags.nodeIDs + ] + } + /** * @param {string} valuesFile * @param {string[]} nodeIDs @@ -301,11 +313,7 @@ export class RelayCommand extends BaseCommand { self.configManager.setFlag(flags.nodeIDs, '') self.configManager.update(argv) - await prompts.execute(task, self.configManager, [ - flags.chartDirectory, - flags.namespace, - flags.nodeIDs - ]) + await prompts.execute(task, self.configManager, RelayCommand.DESTROY_FLAGS_LIST) // prompt if inputs are empty and set it in the context ctx.config = { diff --git a/test/e2e/commands/mirror_node.test.mjs b/test/e2e/commands/mirror_node.test.mjs index 1d94da56b..d5eeb11ce 100644 --- a/test/e2e/commands/mirror_node.test.mjs +++ b/test/e2e/commands/mirror_node.test.mjs @@ -56,6 +56,7 @@ describe('MirrorNodeCommand', () => { argv[flags.relayReleaseTag.name] = flags.relayReleaseTag.definition.defaultValue // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined + argv[flags.quiet.name] = true const bootstrapResp = bootstrapNetwork(testName, argv) const k8 = bootstrapResp.opts.k8 @@ -99,6 +100,7 @@ describe('MirrorNodeCommand', () => { flags.hederaExplorerTlsLoadBalancerIp.constName, flags.profileFile.constName, flags.profileName.constName, + flags.quiet.constName, flags.tlsClusterIssuerType.constName ]) }, 600_000) diff --git a/test/e2e/commands/network.test.mjs b/test/e2e/commands/network.test.mjs index 80570aa8f..e1b19e386 100644 --- a/test/e2e/commands/network.test.mjs +++ b/test/e2e/commands/network.test.mjs @@ -57,6 +57,7 @@ describe('NetworkCommand', () => { argv[flags.applicationEnv.name] = applicationEnvFilePath // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined + argv[flags.quiet.name] = true const bootstrapResp = bootstrapTestVariables(testName, argv) const k8 = bootstrapResp.opts.k8 @@ -106,6 +107,7 @@ describe('NetworkCommand', () => { flags.log4j2Xml.constName, flags.profileFile.constName, flags.profileName.constName, + flags.quiet.constName, flags.settingTxt.constName ]) } catch (e) { diff --git a/test/e2e/commands/node_delete.test.mjs b/test/e2e/commands/node_delete.test.mjs index 9687fc168..fb0d3a7ae 100644 --- a/test/e2e/commands/node_delete.test.mjs +++ b/test/e2e/commands/node_delete.test.mjs @@ -42,6 +42,7 @@ describe('Node delete', () => { argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG argv[flags.namespace.name] = namespace + argv[flags.quiet.name] = true const bootstrapResp = bootstrapNetwork(namespace, argv) const nodeCmd = bootstrapResp.cmd.nodeCmd const accountCmd = bootstrapResp.cmd.accountCmd @@ -62,7 +63,8 @@ describe('Node delete', () => { expect(nodeCmd.getUnusedConfigs(NodeCommand.DELETE_CONFIGS_NAME)).toEqual([ flags.app.constName, flags.devMode.constName, - flags.endpointType.constName + flags.endpointType.constName, + flags.quiet.constName ]) await nodeCmd.accountManager.close() diff --git a/test/e2e/commands/node_local_hedera.test.mjs b/test/e2e/commands/node_local_hedera.test.mjs index 8a361f3af..1619e9cb4 100644 --- a/test/e2e/commands/node_local_hedera.test.mjs +++ b/test/e2e/commands/node_local_hedera.test.mjs @@ -35,6 +35,7 @@ describe('Node local build', () => { argv[flags.clusterName.name] = TEST_CLUSTER // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined + argv[flags.quiet.name] = true let hederaK8 afterAll(async () => { diff --git a/test/e2e/commands/node_local_ptt.test.mjs b/test/e2e/commands/node_local_ptt.test.mjs index f227152ab..716f35341 100644 --- a/test/e2e/commands/node_local_ptt.test.mjs +++ b/test/e2e/commands/node_local_ptt.test.mjs @@ -36,6 +36,7 @@ describe('Node local build', () => { argv[flags.clusterName.name] = TEST_CLUSTER // set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined + argv[flags.quiet.name] = true let pttK8 afterAll(async () => { diff --git a/test/e2e/commands/node_update.test.mjs b/test/e2e/commands/node_update.test.mjs index 8ef0afe44..d722c9523 100644 --- a/test/e2e/commands/node_update.test.mjs +++ b/test/e2e/commands/node_update.test.mjs @@ -49,6 +49,7 @@ describe('Node update', () => { argv[flags.releaseTag.name] = HEDERA_PLATFORM_VERSION_TAG argv[flags.namespace.name] = namespace argv[flags.persistentVolumeClaims.name] = true + argv[flags.quiet.name] = true const bootstrapResp = bootstrapNetwork(namespace, argv) const nodeCmd = bootstrapResp.cmd.nodeCmd const accountCmd = bootstrapResp.cmd.accountCmd @@ -91,7 +92,8 @@ describe('Node update', () => { await nodeCmd.update(argv) expect(nodeCmd.getUnusedConfigs(NodeCommand.UPDATE_CONFIGS_NAME)).toEqual([ flags.app.constName, - flags.devMode.constName + flags.devMode.constName, + flags.quiet.constName ]) await nodeCmd.accountManager.close() }, 1800000) diff --git a/test/e2e/commands/relay.test.mjs b/test/e2e/commands/relay.test.mjs index ff8b47656..8212f65fb 100644 --- a/test/e2e/commands/relay.test.mjs +++ b/test/e2e/commands/relay.test.mjs @@ -47,6 +47,7 @@ describe('RelayCommand', () => { argv[flags.fstChartVersion.name] = version.FST_CHART_VERSION argv[flags.force.name] = true argv[flags.relayReleaseTag.name] = flags.relayReleaseTag.definition.defaultValue + argv[flags.quiet.name] = true const bootstrapResp = bootstrapNetwork(testName, argv) const k8 = bootstrapResp.opts.k8 @@ -79,7 +80,8 @@ describe('RelayCommand', () => { } expect(relayCmd.getUnusedConfigs(RelayCommand.DEPLOY_CONFIGS_NAME)).toEqual([ flags.profileFile.constName, - flags.profileName.constName + flags.profileName.constName, + flags.quiet.constName ]) await sleep(500) diff --git a/test/e2e/commands/separate_node_add.test.mjs b/test/e2e/commands/separate_node_add.test.mjs index b6fc57068..7179ac935 100644 --- a/test/e2e/commands/separate_node_add.test.mjs +++ b/test/e2e/commands/separate_node_add.test.mjs @@ -40,6 +40,7 @@ describe('Node add via separated commands should success', () => { argv[flags.namespace.name] = namespace argv[flags.force.name] = true argv[flags.persistentVolumeClaims.name] = true + argv[flags.quiet.name] = true const argvPrepare = Object.assign({}, argv) @@ -87,6 +88,7 @@ describe('Node add via separated commands should success', () => { flags.generateTlsKeys.constName, flags.gossipEndpoints.constName, flags.grpcEndpoints.constName, + flags.quiet.constName, flags.adminKey.constName, 'curDate', 'freezeAdminPrivateKey' diff --git a/test/e2e/e2e_node_util.js b/test/e2e/e2e_node_util.js index 1ff6f283f..d9f02109a 100644 --- a/test/e2e/e2e_node_util.js +++ b/test/e2e/e2e_node_util.js @@ -56,6 +56,7 @@ export function e2eNodeKeyRefreshTest (testName, mode, releaseTag = HEDERA_PLATF argv[flags.chartDirectory.name] = process.env.SOLO_FST_CHARTS_DIR ? process.env.SOLO_FST_CHARTS_DIR : undefined + argv[flags.quiet.name] = true const bootstrapResp = bootstrapNetwork(testName, argv) const accountManager = bootstrapResp.opts.accountManager @@ -149,7 +150,8 @@ export function e2eNodeKeyRefreshTest (testName, mode, releaseTag = HEDERA_PLATF await expect(nodeCmd.refresh(argv)).resolves.toBeTruthy() expect(nodeCmd.getUnusedConfigs( NodeCommand.REFRESH_CONFIGS_NAME)).toEqual( - [flags.devMode.constName]) + [flags.devMode.constName, + flags.quiet.constName]) } catch (e) { nodeCmd.logger.showUserError(e) expect(e).toBeNull() diff --git a/test/test_add.mjs b/test/test_add.mjs index 72ea442ba..320253bb7 100644 --- a/test/test_add.mjs +++ b/test/test_add.mjs @@ -46,6 +46,7 @@ export function testNodeAdd (localBuildPath argv[flags.force.name] = true argv[flags.persistentVolumeClaims.name] = true argv[flags.localBuildPath.name] = localBuildPath + argv[flags.quiet.name] = true const bootstrapResp = bootstrapNetwork(namespace, argv) const nodeCmd = bootstrapResp.cmd.nodeCmd @@ -79,6 +80,7 @@ export function testNodeAdd (localBuildPath flags.app.constName, flags.chainId.constName, flags.devMode.constName, + flags.quiet.constName, flags.adminKey.constName ]) await nodeCmd.accountManager.close() diff --git a/test/test_util.js b/test/test_util.js index 9987d3bad..f9d71e4cd 100644 --- a/test/test_util.js +++ b/test/test_util.js @@ -224,7 +224,8 @@ export function bootstrapNetwork (testName, argv, await expect(nodeCmd.keys(argv)).resolves.toBeTruthy() expect(nodeCmd.getUnusedConfigs(NodeCommand.KEYS_CONFIGS_NAME)).toEqual([ flags.cacheDir.constName, - flags.devMode.constName + flags.devMode.constName, + flags.quiet.constName ]) }, 120000) @@ -241,6 +242,7 @@ export function bootstrapNetwork (testName, argv, flags.log4j2Xml.constName, flags.profileFile.constName, flags.profileName.constName, + flags.quiet.constName, flags.settingTxt.constName ]) }, 180000)