Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add quiet flag #621

Merged
merged 9 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -765,6 +778,7 @@ export const mirrorNodeVersion = {
type: 'string'
}
}

/** @type {CommandFlag[]} **/
export const allFlags = [
accountId,
Expand Down
5 changes: 4 additions & 1 deletion src/commands/mirror_node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
flags.namespace,
flags.profileFile,
flags.profileName,
flags.quiet,
flags.tlsClusterIssuerType,
flags.valuesFile,
flags.mirrorNodeVersion
Expand Down Expand Up @@ -158,7 +159,9 @@
flags.mirrorNodeVersion
])

await prompts.execute(task, self.configManager, MirrorNodeCommand.DEPLOY_FLAGS_LIST)
if (!MirrorNodeCommand.DEPLOY_FLAGS_LIST.includes(flags.quiet)) {
jeromy-cannon marked this conversation as resolved.
Show resolved Hide resolved
await prompts.execute(task, self.configManager, MirrorNodeCommand.DEPLOY_FLAGS_LIST)

Check warning on line 163 in src/commands/mirror_node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/mirror_node.mjs#L163

Added line #L163 was not covered by tests
}

/**
* @typedef {Object} MirrorNodeDeployConfigClass
Expand Down
5 changes: 4 additions & 1 deletion src/commands/network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
flags.persistentVolumeClaims,
flags.profileFile,
flags.profileName,
flags.quiet,
flags.releaseTag,
flags.settingTxt,
flags.valuesFile
Expand Down Expand Up @@ -154,7 +155,9 @@
flags.settingTxt
])

await prompts.execute(task, this.configManager, NetworkCommand.DEPLOY_FLAGS_LIST)
if (!NetworkCommand.DEPLOY_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, this.configManager, NetworkCommand.DEPLOY_FLAGS_LIST)

Check warning on line 159 in src/commands/network.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/network.mjs#L159

Added line #L159 was not covered by tests
}

/**
* @typedef {Object} NetworkDeployConfigClass
Expand Down
74 changes: 57 additions & 17 deletions src/commands/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,30 @@
]
}

/**
* @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 [

Check warning on line 132 in src/commands/node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/node.mjs#L131-L132

Added lines #L131 - L132 were not covered by tests
flags.namespace,
flags.nodeIDs,
flags.quiet
]
}

/**
* @returns {string}
*/
Expand All @@ -128,7 +152,8 @@
flags.devMode,
flags.generateGossipKeys,
flags.generateTlsKeys,
flags.nodeIDs
flags.nodeIDs,
flags.quiet
]
}

Expand All @@ -150,6 +175,7 @@
flags.localBuildPath,
flags.namespace,
flags.nodeIDs,
flags.quiet,
flags.releaseTag
]
}
Expand Down Expand Up @@ -179,6 +205,7 @@
flags.gossipEndpoints,
flags.grpcEndpoints,
flags.localBuildPath,
flags.quiet,
flags.namespace,
flags.releaseTag
]
Expand Down Expand Up @@ -244,6 +271,7 @@
flags.localBuildPath,
flags.namespace,
flags.nodeID,
flags.quiet,
flags.releaseTag
]
}
Expand All @@ -270,6 +298,7 @@
flags.newAccountNumber,
flags.newAdminKey,
flags.nodeID,
flags.quiet,
flags.releaseTag,
flags.tlsPrivateKey,
flags.tlsPublicKey
Expand Down Expand Up @@ -1058,7 +1087,9 @@
flags.localBuildPath
])

await prompts.execute(task, self.configManager, NodeCommand.SETUP_FLAGS_LIST)
if (!NodeCommand.SETUP_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, NodeCommand.SETUP_FLAGS_LIST)
}

/**
* @typedef {Object} NodeSetupConfigClass
Expand Down Expand Up @@ -1143,10 +1174,13 @@
title: 'Initialize',
task: async (ctx, task) => {
self.configManager.update(argv)
await prompts.execute(task, self.configManager, [
flags.namespace,
flags.nodeIDs
])

if (!NodeCommand.START_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, [

Check warning on line 1179 in src/commands/node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/node.mjs#L1179

Added line #L1179 was not covered by tests
flags.namespace,
flags.nodeIDs
])
}

ctx.config = {
app: self.configManager.getFlag(flags.app),
Expand Down Expand Up @@ -1323,7 +1357,9 @@
flags.devMode
])

await prompts.execute(task, self.configManager, NodeCommand.KEYS_FLAGS_LIST)
if (!NodeCommand.KEYS_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, NodeCommand.KEYS_FLAGS_LIST)

Check warning on line 1361 in src/commands/node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/node.mjs#L1361

Added line #L1361 was not covered by tests
}

/**
* @typedef {Object} NodeKeysConfigClass
Expand Down Expand Up @@ -1435,7 +1471,9 @@
flags.localBuildPath
])

await prompts.execute(task, self.configManager, NodeCommand.REFRESH_FLAGS_LIST)
if (!NodeCommand.REFRESH_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, NodeCommand.REFRESH_FLAGS_LIST)

Check warning on line 1475 in src/commands/node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/node.mjs#L1475

Added line #L1475 was not covered by tests
}

/**
* @typedef {Object} NodeRefreshConfigClass
Expand Down Expand Up @@ -1617,7 +1655,9 @@
flags.grpcEndpoints
])

await prompts.execute(task, self.configManager, NodeCommand.ADD_FLAGS_LIST)
if (!NodeCommand.ADD_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, NodeCommand.ADD_FLAGS_LIST)

Check warning on line 1659 in src/commands/node.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/node.mjs#L1659

Added line #L1659 was not covered by tests
}

/**
* @typedef {Object} NodeAddConfigClass
Expand Down Expand Up @@ -2391,10 +2431,7 @@
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\' ===')
Expand All @@ -2413,8 +2450,7 @@
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\' ===')
Expand Down Expand Up @@ -2618,7 +2654,9 @@
flags.tlsPublicKey
])

await prompts.execute(task, self.configManager, NodeCommand.UPDATE_FLAGS_LIST)
if (NodeCommand.UPDATE_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, NodeCommand.UPDATE_FLAGS_LIST)
}

/**
* @typedef {Object} NodeUpdateConfigClass
Expand Down Expand Up @@ -3017,7 +3055,9 @@
flags.localBuildPath
])

await prompts.execute(task, self.configManager, NodeCommand.DELETE_FLAGS_LIST)
if (NodeCommand.DELETE_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, NodeCommand.DELETE_FLAGS_LIST)
}

/**
* @typedef {Object} NodeDeleteConfigClass
Expand Down
24 changes: 18 additions & 6 deletions src/commands/relay.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,24 @@
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
Expand Down Expand Up @@ -183,7 +195,9 @@

self.configManager.update(argv)

await prompts.execute(task, self.configManager, RelayCommand.DEPLOY_FLAGS_LIST)
if (!RelayCommand.DEPLOY_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, RelayCommand.DEPLOY_FLAGS_LIST)

Check warning on line 199 in src/commands/relay.mjs

View check run for this annotation

Codecov / codecov/patch

src/commands/relay.mjs#L199

Added line #L199 was not covered by tests
}

/**
* @typedef {Object} RelayDeployConfigClass
Expand Down Expand Up @@ -301,11 +315,9 @@
self.configManager.setFlag(flags.nodeIDs, '')

self.configManager.update(argv)
await prompts.execute(task, self.configManager, [
flags.chartDirectory,
flags.namespace,
flags.nodeIDs
])
if (!RelayCommand.DESTROY_FLAGS_LIST.includes(flags.quiet)) {
await prompts.execute(task, self.configManager, RelayCommand.DESTROY_FLAGS_LIST)
}

// prompt if inputs are empty and set it in the context
ctx.config = {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/commands/mirror_node.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,6 +100,7 @@ describe('MirrorNodeCommand', () => {
flags.hederaExplorerTlsLoadBalancerIp.constName,
flags.profileFile.constName,
flags.profileName.constName,
flags.quiet.constName,
flags.tlsClusterIssuerType.constName
])
}, 600_000)
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/commands/network.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -106,6 +107,7 @@ describe('NetworkCommand', () => {
flags.log4j2Xml.constName,
flags.profileFile.constName,
flags.profileName.constName,
flags.quiet.constName,
flags.settingTxt.constName
])
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/commands/node_delete.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions test/e2e/commands/node_local_hedera.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/commands/node_local_ptt.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/commands/node_update.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/commands/relay.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
Loading
Loading