@shipengine/connect
Version:
The official developer tooling for building ShipEngine connect apps
61 lines • 2.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const cli_table_1 = tslib_1.__importDefault(require("cli-table"));
const base_app_command_1 = tslib_1.__importDefault(require("../../base-app-command"));
class Get extends base_app_command_1.default {
static description = 'Get environment variables for an app';
static strict = false;
static aliases = ['get'];
static flags = {
...base_app_command_1.default.flags,
help: command_1.flags.help({
char: 'h',
description: 'show help for the env command',
}),
};
static args = [
{
name: 'NAME-1 ... NAME-N',
description: 'the environment variable name(s). e.g. FOO (note: name will always be UPPERCASED)',
required: true,
},
];
async run() {
if (!(this.client && this.platformApp)) {
this.error('Initialization failed - invalid state');
return;
}
const names = this.argv.map((a) => a.toUpperCase());
try {
const configurationKeys = await this.client.configuration.list(this.platformApp.id);
if (!(configurationKeys && configurationKeys.length > 0)) {
this.log(`${this.platformApp.name} has no environment variables set`);
return;
}
const table = new cli_table_1.default({
head: [chalk_1.default.green('Name'), chalk_1.default.green('Value')],
});
configurationKeys
.filter((key) => names.includes(key.name))
.forEach((key) => {
table.push([key.name, key.value]);
});
if (table.length >= 1) {
this.log(table.toString());
}
else {
this.warn(`none of ${names.join(',')} exist`);
}
}
catch (error) {
return this.error('Error retrieving environment variables', {
exit: 1,
});
}
}
}
exports.default = Get;
//# sourceMappingURL=get.js.map