UNPKG

@shipengine/connect

Version:

The official developer tooling for building ShipEngine connect apps

52 lines 2 kB
"use strict"; 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")); const configuration_key_1 = require("../../core/types/configuration-key"); const parse_key_value_pairs_1 = require("../../core/utils/parse-key-value-pairs"); class Set extends base_app_command_1.default { static description = 'Set environment variables for an app'; static strict = false; static aliases = ['set']; 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=value ... NAME-N=value', description: 'the environment variable(s) name=value. e.g. FOO=bar (note: name will always be UPPERCASED)', required: true, }, ]; async run() { if (!(this.client && this.platformApp)) { this.error('Initialization failed - invalid state'); return; } const configurationKeys = (0, parse_key_value_pairs_1.parseKeyValuePairs)(this.argv).map((kvp) => { return { name: kvp.key.toUpperCase(), value: kvp.value, environmentType: configuration_key_1.EnvironmentType.dev, }; }); for (const key of configurationKeys) { try { const configurationKey = await this.client.configuration.set(this.platformApp.id, key); this.log(`${configurationKey.name}=${configurationKey.value} has been set.`); } catch (error) { this.error('Error setting environment variable', { exit: 1, }); } } } } exports.default = Set; //# sourceMappingURL=set.js.map