How to use the @twilio/cli-core.services function in @twilio/cli-core

To help you get started, we’ve selected a few @twilio/cli-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twilio / twilio-cli / src / services / twilio-api / api-command-runner.js View on Github external
/* eslint no-warning-comments: "off" */
// TODO: Remove the above eslint directive when this file
// is free of TODO's.

const { doesObjectHaveProperty } = require('@twilio/cli-core').services.JSUtils;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const { logger } = require('@twilio/cli-core').services.logging;
const { TwilioApiFlags } = require('@twilio/cli-core').services.TwilioApi;
const { validateSchema } = require('../api-schema/schema-validator');
const { getFlagConfig } = require('./get-flag-config');

class ApiCommandRunner {
  constructor(twilioClient, actionDefinition, flagDefinitions, flagValues) {
    this.twilioClient = twilioClient;
    this.actionDefinition = actionDefinition;
    this.flagDefinitions = flagDefinitions;
    this.flagValues = flagValues;
  }

  async run() {
    this.validateFlags();

    return this.execute();
  }
github twilio / twilio-cli / src / services / twilio-api / get-flag-config.js View on Github external
const { kebabCase } = require('@twilio/cli-core').services.namingConventions;
const { TOPIC_SEPARATOR, BASE_TOPIC_NAME, CORE_TOPIC_NAME } = require('./get-topic-name');

// AccountSid is a special snowflake
const ACCOUNT_SID_FLAG = 'AccountSid';

const UPDATE_PHONE_NUMBER_COMMAND = [
  BASE_TOPIC_NAME,
  CORE_TOPIC_NAME,
  'incoming-phone-numbers',
  'update'
].join(TOPIC_SEPARATOR);

const getFlagName = paramName => {
  return kebabCase(
    paramName
      .replace('<', 'Before')
github twilio / twilio-cli / src / services / twilio-api / api-command-runner.js View on Github external
/* eslint no-warning-comments: "off" */
// TODO: Remove the above eslint directive when this file
// is free of TODO's.

const { doesObjectHaveProperty } = require('@twilio/cli-core').services.JSUtils;
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const { logger } = require('@twilio/cli-core').services.logging;
const { TwilioApiFlags } = require('@twilio/cli-core').services.TwilioApi;
const { validateSchema } = require('../api-schema/schema-validator');
const { getFlagConfig } = require('./get-flag-config');

class ApiCommandRunner {
  constructor(twilioClient, actionDefinition, flagDefinitions, flagValues) {
    this.twilioClient = twilioClient;
    this.actionDefinition = actionDefinition;
    this.flagDefinitions = flagDefinitions;
    this.flagValues = flagValues;
  }

  async run() {
    this.validateFlags();

    return this.execute();
github twilio / twilio-cli / src / hooks / init / plugin-verification.js View on Github external
const { logger } = require('@twilio/cli-core').services.logging;
const { splitArray } = require('@twilio/cli-core').services.JSUtils;

const MessageTemplates = require('../../services/messaging/templates');

const checkCommandConflicts = (corePlugins, installedPlugins) => {
  const commandSet = new Set();

  const collisionCheck = (plugin, command) => {
    // If there's a collision or conflict, issue a stern warning.
    if (commandSet.has(command)) {
      logger.warn(MessageTemplates.commandConflict({ plugin: plugin.name, command: command }));
    }
    commandSet.add(command);
  };

  // Add every command and alias from the our core plugins to the unique collection.
github twilio / twilio-cli / src / commands / profiles / remove.js View on Github external
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { TwilioCliError } = require('@twilio/cli-core').services.error;

class ProfilesRemove extends TwilioClientCommand {
  async run() {
    await super.run();

    const deleteProfile = this.userConfig.getProfileById(this.args.profile);
    this.removeProfileStatus(deleteProfile, this.args.profile);
    const verdict = await this.confirmRemoveProfile();
    if (verdict === true) {
      const keyVerdict = await this.confirmRemoveKey();
      const credentials = await this.deleteLocalKey(deleteProfile);
      await this.deleteRemoteKey(deleteProfile, keyVerdict, credentials);
      this.logger.info('Deleted ' + deleteProfile.id + ' profile.');
      this.userConfig.removeProfile(deleteProfile);
    } else {
      throw new TwilioCliError('Cancelled');
github twilio / twilio-cli / src / hooks / init / buy-phone-number.js View on Github external
const { Plugin } = require('@oclif/config');
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const { logger } = require('@twilio/cli-core').services.logging;
const { OutputFormats } = require('@twilio/cli-core').services.outputFormats;
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { ApiCommandRunner, TOPIC_SEPARATOR, BASE_TOPIC_NAME, CORE_TOPIC_NAME } = require('../../services/twilio-api');

const LIST_COMMAND = [
  BASE_TOPIC_NAME,
  CORE_TOPIC_NAME,
  'available-phone-numbers',
  '(.+)',
  'list'
].join(TOPIC_SEPARATOR);
const LIST_COMMAND_TYPE_GROUP_INDEX = 1;

const CREATE_COMMAND = [
  BASE_TOPIC_NAME,
github twilio / twilio-cli / src / commands / zork.js View on Github external
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".');
    }
  }
}

Zork.description = 'what could this be?';
github twilio / twilio-cli / src / commands / phone-numbers / update.js View on Github external
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();
    this.tunnels = {};
github twilio / twilio-cli / src / commands / profiles / create.js View on Github external
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);

    this.accountSid = undefined;
    this.authToken = undefined;
github twilio / twilio-cli / src / hooks / init / buy-phone-number.js View on Github external
const { Plugin } = require('@oclif/config');
const { TwilioCliError } = require('@twilio/cli-core').services.error;
const { logger } = require('@twilio/cli-core').services.logging;
const { OutputFormats } = require('@twilio/cli-core').services.outputFormats;
const { TwilioClientCommand } = require('@twilio/cli-core').baseCommands;
const { ApiCommandRunner, TOPIC_SEPARATOR, BASE_TOPIC_NAME, CORE_TOPIC_NAME } = require('../../services/twilio-api');

const LIST_COMMAND = [
  BASE_TOPIC_NAME,
  CORE_TOPIC_NAME,
  'available-phone-numbers',
  '(.+)',
  'list'
].join(TOPIC_SEPARATOR);
const LIST_COMMAND_TYPE_GROUP_INDEX = 1;

const CREATE_COMMAND = [
  BASE_TOPIC_NAME,
  CORE_TOPIC_NAME,
  'incoming-phone-numbers',