@shipengine/connect
Version:
The official developer tooling for building ShipEngine connect apps
48 lines • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const command_1 = require("@oclif/command");
const base_app_command_1 = tslib_1.__importDefault(require("../../base-app-command"));
class UnSet extends base_app_command_1.default {
static description = 'Unset (delete) environment variables from an app';
static strict = false;
static aliases = ['unset'];
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.filter((key) => names.includes(key.name)).length === 0) {
this.warn(`none of ${names.join(',')} exist as an environment variable for this app.`);
}
for (const name of names) {
await this.client.configuration.unset(this.platformApp.id, name);
this.log(`${name} has been removed as an environment variable.`);
}
}
catch (error) {
return this.error('Error unsetting the environment variable', {
exit: 1,
});
}
}
}
exports.default = UnSet;
//# sourceMappingURL=unset.js.map