diff --git a/packages/orgs-v5/commands/members/add.js b/packages/orgs-v5/commands/members/add.js deleted file mode 100644 index 21f9e91684..0000000000 --- a/packages/orgs-v5/commands/members/add.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict' - -let cli = require('heroku-cli-util') -let Utils = require('../../lib/utils') -const {flags} = require('@heroku-cli/command') -const {RoleCompletion} = require('@heroku-cli/command/lib/completions') - -async function run(context, heroku) { - let teamInfo = await Utils.teamInfo(context, heroku) - let groupName = context.flags.team - let email = context.args.email - let role = context.flags.role - let groupFeatures = await heroku.get(`/teams/${groupName}/features`) - - let inviteMemberToTeam = async function (email, role, groupName) { - let request = heroku.request({ - headers: { - Accept: 'application/vnd.heroku+json; version=3.team-invitations', - }, - method: 'PUT', - path: `/teams/${groupName}/invitations`, - body: {email, role}, - }).then(() => { - cli.action.done('email sent') - }) - - await cli.action(`Inviting ${cli.color.cyan(email)} to ${cli.color.magenta(groupName)} as ${cli.color.green(role)}`, request) - } - - if (teamInfo.type === 'team' && groupFeatures.find(feature => { - return feature.name === 'team-invite-acceptance' && feature.enabled - })) { - await inviteMemberToTeam(email, role, groupName) - } else { - await Utils.addMemberToTeam(email, role, groupName, heroku) - } -} - -let add = { - topic: 'members', - command: 'add', - description: 'adds a user to a team', - needsAuth: true, - wantsOrg: true, - args: [{name: 'email'}], - flags: [ - {name: 'role', char: 'r', hasValue: true, required: true, description: 'member role (admin, collaborator, member, owner)', completion: RoleCompletion}, - flags.team({name: 'team', hasValue: true, hidden: true}), - ], - run: cli.command(run), -} - -module.exports = add diff --git a/packages/orgs-v5/index.js b/packages/orgs-v5/index.js index a60ca0f990..ddba2a4686 100644 --- a/packages/orgs-v5/index.js +++ b/packages/orgs-v5/index.js @@ -22,7 +22,6 @@ exports.commands = flatten([ require('./commands/apps/lock'), require('./commands/apps/transfer'), require('./commands/apps/unlock'), - require('./commands/members/add'), require('./commands/members/set'), require('./commands/members/remove'), require('./commands/orgs'), diff --git a/packages/orgs-v5/test/unit/commands/members/add.unit.test.js b/packages/orgs-v5/test/unit/commands/members/add.unit.test.js deleted file mode 100644 index c72944aba4..0000000000 --- a/packages/orgs-v5/test/unit/commands/members/add.unit.test.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict' -/* globals beforeEach afterEach cli nock expect context */ - -let cmd = require('../../../../commands/members/add') -let stubGet = require('../../stub/get') -let stubPut = require('../../stub/put') -const unwrap = require('../../../unwrap') - -describe('heroku members:add', () => { - let apiUpdateMemberRole - - beforeEach(() => cli.mockConsole()) - afterEach(() => nock.cleanAll()) - - it('is configured for an optional team flag', function () { - expect(cmd).to.have.own.property('wantsOrg', true) - }) - - context('without the feature flag team-invite-acceptance', () => { - beforeEach(() => { - stubGet.teamFeatures([]) - }) - context('and group is an enterprise org', () => { - beforeEach(() => { - stubGet.teamInfo('enterprise') - stubGet.variableSizeTeamMembers(1) - }) - - it('adds a member to an org', () => { - apiUpdateMemberRole = stubPut.updateMemberRole('foo@foo.com', 'admin') - - return cmd.run({args: {email: 'foo@foo.com'}, flags: {team: 'myteam', role: 'admin'}}) - .then(() => expect('').to.eq(cli.stdout)) - .then(() => expect(`Adding foo@foo.com to myteam as admin... done -`).to.eq(cli.stderr)) - .then(() => apiUpdateMemberRole.done()) - }) - }) - }) - - context('with the feature flag team-invite-acceptance for a team', () => { - beforeEach(() => { - stubGet.teamFeatures([{name: 'team-invite-acceptance', enabled: true}]) - stubGet.teamInfo('team') - }) - - it('sends an invite when adding a new user to the team', () => { - let apiSendInvite = stubPut.sendInvite('foo@foo.com', 'admin') - - stubGet.variableSizeTeamMembers(1) - stubGet.variableSizeTeamInvites(0) - - return cmd.run({args: {email: 'foo@foo.com'}, flags: {role: 'admin', team: 'myteam'}}) - .then(() => expect('').to.eq(cli.stdout)) - .then(() => expect('Inviting foo@foo.com to myteam as admin... email sent\n').to.eq(cli.stderr)) - .then(() => apiSendInvite.done()) - }) - }) -})