Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint no-warning-comments: "off" */
// TODO: Remove the above eslint directive when this file
// is free of TODO's.
const { flags } = require('@oclif/command');
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { doesObjectHaveProperty } = require('@twilio/cli-core').services.JSUtils;
const { logger } = require('@twilio/cli-core').services.logging;
const { camelCase } = require('@twilio/cli-core').services.namingConventions;
const { ApiCommandRunner, getActionDescription, getFlagConfig } = require('../services/twilio-api');
// Open API type to oclif flag type mapping. For numerical types, we'll do validation elsewhere.
const typeMap = {
array: flags.string,
boolean: flags.boolean,
integer: flags.string,
number: flags.string,
string: flags.string,
object: flags.string,
undefined: flags.string // TODO: Handle "anyOf" case more explicitly
};
const chalk = require('chalk');
const { BaseCommand } = require('@twilio/cli-core').baseCommands;
class ProfilesList extends BaseCommand {
async run() {
await super.run();
if (this.userConfig.profiles.length > 0) {
// If none of the profiles have a region, delete it from all of them so it doesn't show up in the output.
if (!this.userConfig.profiles.some(p => p.region)) {
this.userConfig.profiles.forEach(p => delete p.region);
}
const activeProfile = this.userConfig.getActiveProfile();
this.userConfig.profiles.forEach(p => {
if (p.id === activeProfile.id) {
p.active = true;
}
});
this.output(this.userConfig.profiles);
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const {
handler,
cliInfo,
describe,
} = require('twilio-run/dist/commands/activate');
const {
convertYargsOptionsToOclifFlags,
normalizeFlags,
createExternalCliOptions,
} = require('../../utils');
class FunctionsActivate extends TwilioClientCommand {
async run() {
await super.run();
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { handler, cliInfo, describe } = require('twilio-run/dist/commands/list');
const {
convertYargsOptionsToOclifFlags,
normalizeFlags,
createExternalCliOptions,
} = require('../../utils');
class FunctionsList extends TwilioClientCommand {
async run() {
await super.run();
let { flags, args } = this.parse(FunctionsList);
flags = normalizeFlags(flags);
const externalOptions = createExternalCliOptions(flags, this.twilioClient);
const os = require('os');
const { flags } = require('@oclif/command');
const { BaseCommand, TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { CliRequestClient } = require('@twilio/cli-core').services;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const { STORAGE_LOCATIONS } = require('@twilio/cli-core').services.secureStorage;
const helpMessages = require('../../services/messaging/help-messages');
const FRIENDLY_STORAGE_LOCATIONS = {
[STORAGE_LOCATIONS.KEYCHAIN]: 'in your keychain',
[STORAGE_LOCATIONS.WIN_CRED_VAULT]: 'in the Windows credential vault',
[STORAGE_LOCATIONS.LIBSECRET]: 'using libsecret'
};
class ProfilesCreate extends BaseCommand {
constructor(argv, config, secureStorage) {
super(argv, config, secureStorage);
const chalk = require('chalk');
const { URL } = require('url');
const { flags } = require('@oclif/command');
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const IncomingPhoneNumberHelper = require('../../services/resource-helpers/api/v2010/incoming-phone-number');
class NumberUpdate extends TwilioClientCommand {
constructor(argv, config) {
super(argv, config);
this.ngrok = null;
}
async run() {
await super.run();
const helper = new IncomingPhoneNumberHelper(this.twilioClient);
const phoneNumber = await helper.findPhoneNumber(this.args['phone-number']);
const props = this.parseProperties();
const { BaseCommand } = require('@twilio/cli-core').baseCommands;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
class ProfilesUse extends BaseCommand {
async run() {
await super.run();
const profile = this.userConfig.setActiveProfile(this.args.profile);
if (!profile) {
throw new TwilioCliError(`The profile "${this.args.profile}" does not exist. Run "twilio profiles:list" to see the list of configured profiles.`);
}
const configSavedMessage = await this.configFile.save(this.userConfig);
this.logger.info(`set "${profile.id}" as active profile`);
this.logger.info(configSavedMessage);
}
}
const { flags } = require('@oclif/command');
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
class NumberList extends TwilioClientCommand {
async run() {
await super.run();
const fullData = await this.twilioClient.incomingPhoneNumbers.list();
this.output(fullData, this.flags.properties);
}
}
NumberList.description = 'show what Twilio phone numbers you have configured';
NumberList.flags = Object.assign(
{
properties: flags.string({
default: 'sid, phoneNumber, friendlyName',
description:
const { BaseCommand } = require('@twilio/cli-core').baseCommands;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
class Zork extends BaseCommand {
async run() {
await super.run();
try {
const zork = await this.install('zorkjs');
zork();
} catch (error) {
this.logger.debug('Error loading zork: ' + JSON.stringify(error));
throw new TwilioCliError('I don\'t know the word "zork".');
}
}
}
const { flags } = require('@oclif/command');
const { BaseCommand } = require('@twilio/cli-core').baseCommands;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const emailUtilities = require('../../services/email-utility');
class Set extends BaseCommand {
async run() {
await super.run();
this.reminderCurrentData();
const email = await this.promptSetDefaultEmail();
const subject = await this.promptSetDefaultSubject();
const verdict = emailUtilities.validateEmail(email);
if (verdict === false) {
throw new TwilioCliError('Please use a valid email.');
}
this.setDefaults(email, subject);
const configSavedMessage = await this.configFile.save(this.userConfig);
this.logger.info(configSavedMessage);