UNPKG

ryuu

Version:

Domo App Dev Studio CLI, The main tool used to create, edit, and publish app designs to Domo

53 lines 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const log_1 = require("../util/log"); const Configstore = require('configstore'); const prompts_1 = require("../util/prompts"); module.exports = function (program) { program .command('proxy [host] [port]') .description('configure the proxy through which you wish to send all commands') //.option('-u, --username <value>, Username for authentication based proxy') //.option('-p, --password <value>, Password for authentication based proxy') .option('-r, --remove-proxy', 'Remove current proxy settings') .option('-a, --auth, Flag for if you wish to enter a username for your corporate proxy (password will be prompted on each command)') .action(async function (host, port, options) { if (options.removeProxy) { const proxy = new Configstore.default('/proxy'); proxy.delete('host'); proxy.delete('port'); proxy.delete('username'); log_1.log.ok('Proxy Removed!'); } else { const prompts = []; if (options.auth) { prompts.push({ type: 'input', message: 'Please enter your username:', name: 'username', }); } const shouldSetProxy = await (0, prompts_1.createConfirm)(`You are about to set all requests to go through proxy ${host}:${port}, are you sure you want to do this?`, false); if (shouldSetProxy) { handleUserResponse({ proxy: true, username: '', password: '' }); } else { log_1.log.info('Proxy not set'); } } function handleUserResponse(answer) { if (answer.proxy) { const proxy = new Configstore.default('/proxy'); proxy.set('host', host); proxy.set('port', port); proxy.set('username', answer.username); log_1.log.ok('Proxy set for all future commands'); } else { log_1.log.fail('Proxy command aborted'); } } }); }; //# sourceMappingURL=proxy.js.map