1 | 'use strict'
|
2 |
|
3 | let cli = require('heroku-cli-util')
|
4 | let co = require('co')
|
5 |
|
6 | function * run (context, heroku) {
|
7 | let app = yield heroku.get(`/organizations/apps/${context.app}`)
|
8 | if (app.locked) {
|
9 | throw new Error(`Error: cannot lock ${cli.color.cyan(app.name)}
|
10 | This app is already locked.`)
|
11 | }
|
12 | let request = heroku.request({
|
13 | method: 'PATCH',
|
14 | path: `/organizations/apps/${app.name}`,
|
15 | body: {locked: true}
|
16 | })
|
17 | yield cli.action(`Locking ${cli.color.cyan(app.name)}`, request)
|
18 | }
|
19 |
|
20 | let cmd = {
|
21 | topic: 'apps',
|
22 | command: 'lock',
|
23 | description: 'prevent organization members from joining an app',
|
24 | needsAuth: true,
|
25 | needsApp: true,
|
26 | run: cli.command(co.wrap(run))
|
27 | }
|
28 |
|
29 | module.exports.apps = cmd
|
30 | module.exports.root = Object.assign({}, cmd, {topic: 'lock', command: null})
|