diff --git a/README.md b/README.md index 2072f7f42..f85c4bbfa 100644 --- a/README.md +++ b/README.md @@ -129,11 +129,11 @@ All debug, informational, warning, and error information is sent to `stderr`. Th ### Multiple Twilio accounts/projects -When you run `twilio login` (an alias for `twilio project:add`), it stores your credentials and associates them with the provided project ID. The first project added will default to being the "active" project. The active project is used for all subsequent commands. +When you run `twilio login` (an alias for `twilio projects:add`), it stores your credentials and associates them with the provided project ID. The first project added will default to being the "active" project. The active project is used for all subsequent commands. To add additional projects, run `twilio login` again but provide a different project ID (like, `my_other_proj`). Then, when you run subsequent commands, just include `-p my_other_proj` in the command (e.g. `twilio phone-numbers:list -p my_other_proj`). -Alternatively, you may switch which project is active using the `twilio project:use` command. To see the full list of local projects (including which project is active), run `twilio project:list`. +Alternatively, you may switch which project is active using the `twilio projects:use` command. To see the full list of local projects (including which project is active), run `twilio projects:list`. ### Want to use environment variables instead of creating a project? diff --git a/package.json b/package.json index d7676037a..cc0e3e048 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "phone-numbers": { "description": "manage Twilio phone numbers" }, - "project": { + "projects": { "description": "manage credentials for Twilio projects" } }, diff --git a/src/commands/login.js b/src/commands/login.js index ad15717b2..1abd9c5ba 100644 --- a/src/commands/login.js +++ b/src/commands/login.js @@ -1,10 +1,10 @@ -const ProjectAdd = require('./project/add'); +const ProjectsAdd = require('./projects/add'); -class Login extends ProjectAdd { +class Login extends ProjectsAdd { } -Login.aliases = ['project:add']; -Login.flags = ProjectAdd.flags; -Login.args = ProjectAdd.args; +Login.aliases = ['projects:add']; +Login.flags = ProjectsAdd.flags; +Login.args = ProjectsAdd.args; module.exports = Login; diff --git a/src/commands/project/add.js b/src/commands/projects/add.js similarity index 93% rename from src/commands/project/add.js rename to src/commands/projects/add.js index 6f2dd2298..9f48818f3 100644 --- a/src/commands/project/add.js +++ b/src/commands/projects/add.js @@ -13,7 +13,7 @@ const FRIENDLY_STORAGE_LOCATIONS = { [STORAGE_LOCATIONS.LIBSECRET]: 'using libsecret' }; -class ProjectAdd extends BaseCommand { +class ProjectsAdd extends BaseCommand { constructor(argv, config, secureStorage) { super(argv, config, secureStorage); @@ -58,7 +58,7 @@ class ProjectAdd extends BaseCommand { if (!this.projectId) { const answer = await this.inquirer.prompt([{ name: 'projectId', - message: ProjectAdd.flags.project.description + message: ProjectsAdd.flags.project.description }]); this.projectId = answer.projectId; } @@ -68,7 +68,7 @@ class ProjectAdd extends BaseCommand { if (!this.accountSid) { this.questions.push({ name: 'accountSid', - message: ProjectAdd.args[0].description + ':', + message: ProjectsAdd.args[0].description + ':', validate: input => Boolean(input) }); } @@ -79,7 +79,7 @@ class ProjectAdd extends BaseCommand { this.questions.push({ type: 'password', name: 'authToken', - message: ProjectAdd.flags['auth-token'].description, + message: ProjectsAdd.flags['auth-token'].description, validate: input => Boolean(input) }); } @@ -188,10 +188,10 @@ class ProjectAdd extends BaseCommand { } } -ProjectAdd.aliases = ['login']; -ProjectAdd.description = 'add credentials for an existing Twilio project'; +ProjectsAdd.aliases = ['login']; +ProjectsAdd.description = 'add credentials for an existing Twilio project'; -ProjectAdd.flags = Object.assign( +ProjectsAdd.flags = Object.assign( { 'auth-token': flags.string({ description: 'Your Twilio Auth Token for your Twilio project' @@ -207,11 +207,11 @@ ProjectAdd.flags = Object.assign( TwilioClientCommand.flags // Yes! We _do_ want the same flags as TwilioClientCommand ); -ProjectAdd.args = [ +ProjectsAdd.args = [ { name: 'account-sid', description: 'The Account SID for your Twilio project' } ]; -module.exports = ProjectAdd; +module.exports = ProjectsAdd; diff --git a/src/commands/project/list.js b/src/commands/projects/list.js similarity index 77% rename from src/commands/project/list.js rename to src/commands/projects/list.js index a142fe73a..72ad1d05b 100644 --- a/src/commands/project/list.js +++ b/src/commands/projects/list.js @@ -1,7 +1,7 @@ const chalk = require('chalk'); const { BaseCommand } = require('@twilio/cli-core').baseCommands; -class ProjectList extends BaseCommand { +class ProjectsList extends BaseCommand { async run() { await super.run(); if (this.userConfig.projects.length > 0) { @@ -19,12 +19,12 @@ class ProjectList extends BaseCommand { activeProject.active = true; this.output(this.userConfig.projects); } else { - this.logger.warn('No projects have been configured. Run ' + chalk.whiteBright('twilio project:add') + ' to add one!'); + this.logger.warn('No projects have been configured. Run ' + chalk.whiteBright('twilio projects:add') + ' to add one!'); } } } -ProjectList.description = 'show what Twilio projects you have configured'; -ProjectList.flags = BaseCommand.flags; +ProjectsList.description = 'show what Twilio projects you have configured'; +ProjectsList.flags = BaseCommand.flags; -module.exports = ProjectList; +module.exports = ProjectsList; diff --git a/src/commands/project/use.js b/src/commands/projects/use.js similarity index 70% rename from src/commands/project/use.js rename to src/commands/projects/use.js index 2d9d091eb..516d20cdf 100644 --- a/src/commands/project/use.js +++ b/src/commands/projects/use.js @@ -1,12 +1,12 @@ const { BaseCommand } = require('@twilio/cli-core').baseCommands; -class ProjectUse extends BaseCommand { +class ProjectsUse extends BaseCommand { async run() { await super.run(); const project = this.userConfig.getProjectById(this.args.project); if (!project) { - this.logger.error('The project "' + this.args.project + '" does not exist. Run "twilio project:list" to see the list of configured projects.'); + this.logger.error('The project "' + this.args.project + '" does not exist. Run "twilio projects:list" to see the list of configured projects.'); this.exit(1); } this.userConfig.activeProject = this.args.project; @@ -15,15 +15,15 @@ class ProjectUse extends BaseCommand { this.logger.info(configSavedMessage); } } -ProjectUse.description = 'select which project to use'; +ProjectsUse.description = 'select which project to use'; -ProjectUse.args = [ +ProjectsUse.args = [ { name: 'project', description: 'Shorthand identifier for your Twilio project', required: true } ]; -ProjectUse.flags = BaseCommand.flags; +ProjectsUse.flags = BaseCommand.flags; -module.exports = ProjectUse; +module.exports = ProjectsUse; diff --git a/test/commands/project/add.test.js b/test/commands/projects/add.test.js similarity index 96% rename from test/commands/project/add.test.js rename to test/commands/projects/add.test.js index f9daedf9e..518ccf54a 100644 --- a/test/commands/project/add.test.js +++ b/test/commands/projects/add.test.js @@ -2,16 +2,16 @@ const sinon = require('sinon'); const { expect, test, constants } = require('@twilio/cli-test'); const { Config, ConfigData } = require('@twilio/cli-core').services.config; -const ProjectAdd = require('../../../src/commands/project/add'); +const ProjectsAdd = require('../../../src/commands/projects/add'); const helpMessages = require('../../../src/services/messaging/help-messages'); describe('commands', () => { - describe('project', () => { + describe('projects', () => { describe('add', () => { const addTest = (commandArgs = []) => test .twilioFakeProject(ConfigData) .twilioCliEnv(Config) - .twilioCreateCommand(ProjectAdd, commandArgs) + .twilioCreateCommand(ProjectsAdd, commandArgs) .stdout() .stderr() .do(ctx => { @@ -44,7 +44,7 @@ describe('commands', () => { }); }) .do(ctx => ctx.testCmd.run()) - .it('runs project:add', ctx => { + .it('runs projects:add', ctx => { expect(ctx.stdout).to.equal(''); expect(ctx.stderr).to.contain(helpMessages.AUTH_TOKEN_NOT_SAVED); expect(ctx.stderr).to.contain('Saved default.'); diff --git a/test/commands/project/list.test.js b/test/commands/projects/list.test.js similarity index 84% rename from test/commands/project/list.test.js rename to test/commands/projects/list.test.js index 0a81b0e88..22767953e 100644 --- a/test/commands/project/list.test.js +++ b/test/commands/projects/list.test.js @@ -1,16 +1,16 @@ const { expect, test, constants } = require('@twilio/cli-test'); const { Config, ConfigData } = require('@twilio/cli-core').services.config; -const ProjectList = require('../../../src/commands/project/list'); +const ProjectsList = require('../../../src/commands/projects/list'); describe('commands', () => { - describe('project', () => { + describe('projects', () => { describe('list', () => { test .twilioCliEnv(Config) .stdout() .stderr() - .twilioCommand(ProjectList, []) - .it('runs project:list with no projects', ctx => { + .twilioCommand(ProjectsList, []) + .it('runs projects:list with no projects', ctx => { expect(ctx.stdout).to.equal(''); expect(ctx.stderr).to.contain('No projects have been configured'); }); @@ -23,8 +23,8 @@ describe('commands', () => { .twilioCliEnv(Config) .stdout() .stderr() - .twilioCommand(ProjectList, []) - .it('runs project:list with 1 project', ctx => { + .twilioCommand(ProjectsList, []) + .it('runs projects:list with 1 project', ctx => { expect(ctx.stdout).to.contain('project1'); expect(ctx.stdout).to.contain(constants.FAKE_ACCOUNT_SID); expect(ctx.stdout).to.not.contain('Region'); @@ -41,8 +41,8 @@ describe('commands', () => { .twilioCliEnv(Config) .stdout() .stderr() - .twilioCommand(ProjectList, []) - .it('runs project:list with multiple projects', ctx => { + .twilioCommand(ProjectsList, []) + .it('runs projects:list with multiple projects', ctx => { expect(ctx.stdout).to.contain('project1'); expect(ctx.stdout).to.contain('project2'); expect(ctx.stdout).to.contain(constants.FAKE_ACCOUNT_SID); @@ -61,7 +61,7 @@ describe('commands', () => { .twilioCliEnv(Config) .stdout() .stderr() - .twilioCommand(ProjectList, []) + .twilioCommand(ProjectsList, []) .it('when the active project is set', ctx => { expect(ctx.stdout).to.contain('project1'); expect(ctx.stdout).to.contain('project2'); @@ -80,8 +80,8 @@ describe('commands', () => { .twilioCliEnv(Config) .stdout() .stderr() - .twilioCommand(ProjectList, []) - .it('runs project:list with 1 regional project', ctx => { + .twilioCommand(ProjectsList, []) + .it('runs projects:list with 1 regional project', ctx => { expect(ctx.stdout).to.contain('default'); expect(ctx.stdout).to.contain(constants.FAKE_ACCOUNT_SID); expect(ctx.stdout).to.contain('dev'); diff --git a/test/commands/project/use.test.js b/test/commands/projects/use.test.js similarity index 65% rename from test/commands/project/use.test.js rename to test/commands/projects/use.test.js index b919fc27b..ddc37173e 100644 --- a/test/commands/project/use.test.js +++ b/test/commands/projects/use.test.js @@ -1,9 +1,9 @@ const { expect, test, constants } = require('@twilio/cli-test'); const { Config, ConfigData } = require('@twilio/cli-core').services.config; -const ProjectUse = require('../../../src/commands/project/use'); +const ProjectsUse = require('../../../src/commands/projects/use'); describe('commands', () => { - describe('project', () => { + describe('projects', () => { describe('use', () => { const setup = () => test .stdout() @@ -14,10 +14,10 @@ describe('commands', () => { }) .twilioCliEnv(Config); - setup().twilioCommand(ProjectUse, ['identity']).it('should set the active project with id', ctx => { + setup().twilioCommand(ProjectsUse, ['identity']).it('should set the active project with id', ctx => { expect(ctx.stderr).to.contain('set identity as active project'); }); - setup().twilioCommand(ProjectUse, ['incorrectId']).exit(1).it('run project:active with non-existing project', ctx => { + setup().twilioCommand(ProjectsUse, ['incorrectId']).exit(1).it('run projects:active with non-existing project', ctx => { expect(ctx.stderr).to.contain('does not exist'); }); }); diff --git a/welcome.js b/welcome.js index b017f2e37..39605d50d 100644 --- a/welcome.js +++ b/welcome.js @@ -8,7 +8,7 @@ console.log('* twilio login console.log('* *'); console.log('* OR *'); console.log('* *'); -console.log('* twilio project:add *'); +console.log('* twilio projects:add *'); console.log('* *'); console.log('*************************************************************************'); console.log();