@hashgraph/solo
Version:
An opinionated CLI tool to deploy and manage private Hedera Networks.
98 lines • 9.51 kB
JavaScript
// SPDX-License-Identifier: Apache-2.0
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var DeploymentCommandDefinition_1;
import { inject, injectable } from 'tsyringe-neo';
import { InjectTokens } from '../../core/dependency-injection/inject-tokens.js';
import { patchInject } from '../../core/dependency-injection/container-helper.js';
import { BaseCommandDefinition } from './base-command-definition.js';
import { CommandBuilder, CommandGroup, Subcommand } from '../../core/command-path-builders/command-builder.js';
import { DeploymentCommand } from '../deployment.js';
import * as constants from '../../core/constants.js';
import { NodeCommand } from '../node/index.js';
import * as NodeFlags from '../node/flags.js';
let DeploymentCommandDefinition = class DeploymentCommandDefinition extends BaseCommandDefinition {
static { DeploymentCommandDefinition_1 = this; }
logger;
deploymentCommand;
nodeCommand;
constructor(logger, deploymentCommand, nodeCommand) {
super();
this.logger = logger;
this.deploymentCommand = deploymentCommand;
this.nodeCommand = nodeCommand;
this.deploymentCommand = patchInject(deploymentCommand, InjectTokens.DeploymentCommand, this.constructor.name);
this.nodeCommand = patchInject(nodeCommand, InjectTokens.NodeCommand, this.constructor.name);
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
}
static COMMAND_NAME = 'deployment';
static DESCRIPTION = 'Create, modify, and delete deployment configurations. ' +
'Deployments are required for most of the other commands.';
static CLUSTER_SUBCOMMAND_NAME = 'cluster';
static CLUSTER_SUBCOMMAND_DESCRIPTION = 'View and manage Solo cluster references used by a deployment.';
static CONFIG_SUBCOMMAND_NAME = 'config';
static CONFIG_SUBCOMMAND_DESCRIPTION = 'List, view, create, delete, and import deployments. These commands affect the local configuration only.';
static STATE_SUBCOMMAND_NAME = 'state';
static STATE_SUBCOMMAND_DESCRIPTION = 'View the actual state of the deployment on the Kubernetes clusters or ' +
'teardown/destroy all remote and local configuration for a given deployment.';
static REFRESH_SUBCOMMAND_NAME = 'refresh';
static REFRESH_SUBCOMMAND_DESCRIPTION = 'Refresh port-forward processes for all components in the deployment.';
static DIAGNOSTICS_SUBCOMMAND_NAME = 'diagnostics';
static DIAGNOSTIC_SUBCOMMAND_DESCRIPTION = 'Capture diagnostic information such as logs, signed states, and ledger/network/node configurations.';
static CLUSTER_ATTACH = 'attach';
static CONFIG_LIST = 'list';
static CONFIG_CREATE = 'create';
static CONFIG_DELETE = 'delete';
static CONFIG_INFO = 'info';
static CONFIG_PORTS = 'ports';
static DIAGNOSTICS_ALL = 'all';
static DIAGNOSTICS_ANALYZE = 'analyze';
static DIAGNOSTICS_DEBUG = 'debug';
static DIAGNOSTICS_LOGS = 'logs';
static DIAGNOSTICS_CONNECTIONS = 'connections';
static DIAGNOSTICS_REPORT = 'report';
static CREATE_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_CREATE}`;
static ATTACH_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.CLUSTER_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.CLUSTER_ATTACH}`;
static DELETE_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.CONFIG_DELETE}`;
static CONNECTIONS_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.DIAGNOSTICS_SUBCOMMAND_NAME} ${DeploymentCommandDefinition_1.DIAGNOSTICS_CONNECTIONS}`;
static REFRESH_COMMAND = `${DeploymentCommandDefinition_1.COMMAND_NAME} ${DeploymentCommandDefinition_1.REFRESH_SUBCOMMAND_NAME} port-forwards`;
getCommandDefinition() {
return new CommandBuilder(DeploymentCommandDefinition_1.COMMAND_NAME, DeploymentCommandDefinition_1.DESCRIPTION, this.logger)
.addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.CLUSTER_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.CLUSTER_SUBCOMMAND_DESCRIPTION).addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CLUSTER_ATTACH, 'Attaches a cluster reference to a deployment.', this.deploymentCommand, this.deploymentCommand.addCluster, DeploymentCommand.ADD_CLUSTER_FLAGS_LIST, [...constants.BASE_DEPENDENCIES])))
.addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.CONFIG_SUBCOMMAND_DESCRIPTION)
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_LIST, 'Lists all local deployment configurations or deployments in a specific cluster.', this.deploymentCommand, this.deploymentCommand.list, DeploymentCommand.LIST_DEPLOYMENTS_FLAGS_LIST, []))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_CREATE, 'Creates a new local deployment configuration.', this.deploymentCommand, this.deploymentCommand.create, DeploymentCommand.CREATE_FLAGS_LIST, []))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_DELETE, 'Removes a local deployment configuration.', this.deploymentCommand, this.deploymentCommand.delete, DeploymentCommand.DESTROY_FLAGS_LIST, []))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_INFO, 'Displays the full status of a deployment including components, versions, and port-forward status.', this.deploymentCommand, this.deploymentCommand.showDeploymentStatus, DeploymentCommand.SHOW_STATUS_FLAGS_LIST, []))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.CONFIG_PORTS, 'List all port-forwards for a deployment. JSON and YAMl output formats, create files containing the data', this.deploymentCommand, this.deploymentCommand.ports, DeploymentCommand.PORTS_FLAGS_LIST, [])))
.addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.REFRESH_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.REFRESH_SUBCOMMAND_DESCRIPTION).addSubcommand(new Subcommand('port-forwards', 'Refresh and restore killed port-forward processes.', this.deploymentCommand, this.deploymentCommand.refresh, DeploymentCommand.REFRESH_FLAGS_LIST, [constants.KUBECTL])))
.addCommandGroup(new CommandGroup(DeploymentCommandDefinition_1.DIAGNOSTICS_SUBCOMMAND_NAME, DeploymentCommandDefinition_1.DIAGNOSTIC_SUBCOMMAND_DESCRIPTION)
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTICS_ALL, 'Captures logs, configs, and diagnostic artifacts from all consensus nodes and test connections.', this.nodeCommand.handlers, this.nodeCommand.handlers.all, NodeFlags.DIAGNOSTICS_CONNECTIONS))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTICS_DEBUG, 'Similar to diagnostics all subcommand, but creates a zip archive for easy sharing.', this.nodeCommand.handlers, this.nodeCommand.handlers.debug, NodeFlags.LOGS_FLAGS))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTICS_CONNECTIONS, 'Tests connections to Consensus, Relay, Explorer, Mirror and Block nodes.', this.nodeCommand.handlers, this.nodeCommand.handlers.connections, NodeFlags.DIAGNOSTICS_CONNECTIONS))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTICS_LOGS, 'Get logs and configuration files from consensus node/nodes.', this.nodeCommand.handlers, this.nodeCommand.handlers.logs, NodeFlags.LOGS_FLAGS))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTICS_ANALYZE, 'Analyze a previously collected diagnostics logs directory for common failure signatures.', this.nodeCommand.handlers, this.nodeCommand.handlers.analyze, NodeFlags.ANALYZE_FLAGS))
.addSubcommand(new Subcommand(DeploymentCommandDefinition_1.DIAGNOSTICS_REPORT, 'Collect diagnostic logs and create a GitHub issue using the gh CLI.', this.nodeCommand.handlers, this.nodeCommand.handlers.report, NodeFlags.REPORT_FLAGS)))
.build();
}
};
DeploymentCommandDefinition = DeploymentCommandDefinition_1 = __decorate([
injectable(),
__param(0, inject(InjectTokens.SoloLogger)),
__param(1, inject(InjectTokens.DeploymentCommand)),
__param(2, inject(InjectTokens.NodeCommand)),
__metadata("design:paramtypes", [Object, DeploymentCommand,
NodeCommand])
], DeploymentCommandDefinition);
export { DeploymentCommandDefinition };
//# sourceMappingURL=deployment-command-definition.js.map