@stoked-cenv/cli
Version:
A well considered cli and Node.js library for helping manage application, infrastructure, and configuration management.
83 lines • 3.71 kB
JavaScript
;
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigCommand = void 0;
const nest_commander_1 = require("nest-commander");
const lib_1 = require("@stoked-cenv/lib");
const base_command_1 = require("./base.command");
const config_manage_command_1 = require("./config.manage.command");
let ConfigCommand = class ConfigCommand extends base_command_1.BaseCommand {
constructor() {
super();
this.config.allowPackages = false;
this.config.configRequired = false;
this.config.cenvRootRequired = true;
}
parseShow(val) {
return val;
}
parseEnvToParams(val) {
return val;
}
async runCommand(params, options, packages) {
try {
if (params.length > 1) {
lib_1.CenvLog.single.errorLog(`Too many parameters provided to config command.. only accepts one param which is the profile name..`);
process.exit(22);
}
const profile = params.length ? params[0] : options === null || options === void 0 ? void 0 : options.profile;
lib_1.Cenv.config = new lib_1.Config();
if (options === null || options === void 0 ? void 0 : options.show) {
await lib_1.Cenv.config.show(profile);
process.exit();
}
if (profile) {
const query = new lib_1.ConfigQuery({ name: profile });
if (query.valid) {
await lib_1.Cenv.config.loadProfile(profile);
await lib_1.Cenv.config.show(profile);
process.exit();
}
}
await lib_1.Cenv.config.createNewProfile(profile);
}
catch (e) {
lib_1.CenvLog.single.catchLog(e);
}
}
};
exports.ConfigCommand = ConfigCommand;
__decorate([
(0, nest_commander_1.Option)({
flags: '-s, --show', description: 'Show the configuration for a specific profile',
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Boolean]),
__metadata("design:returntype", Boolean)
], ConfigCommand.prototype, "parseShow", null);
__decorate([
(0, nest_commander_1.Option)({
flags: '-etp, --env-to-params', description: 'Add variables in .env file(s) to the parameters for the profile',
}),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Boolean]),
__metadata("design:returntype", Boolean)
], ConfigCommand.prototype, "parseEnvToParams", null);
exports.ConfigCommand = ConfigCommand = __decorate([
(0, nest_commander_1.Command)({
name: 'config',
description: 'Configure the cli for a specific aws profile and environment combination.',
aliases: ['conf'],
subCommands: [config_manage_command_1.ManageConfigCommand],
}),
__metadata("design:paramtypes", [])
], ConfigCommand);
//# sourceMappingURL=config.command.js.map