@heroku/skynet 1.6.6 → 1.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/deprovision.js +5 -39
- package/commands/userpass/add.js +1 -1
- package/lib/skynet.js +0 -16
- package/package.json +1 -1
package/commands/deprovision.js
CHANGED
|
@@ -3,54 +3,21 @@ let command = require('../lib/command')
|
|
|
3
3
|
let sudo = require('../lib/sudo')
|
|
4
4
|
let SkynetAPI = require('../lib/skynet')
|
|
5
5
|
|
|
6
|
-
function readlines (file) {
|
|
7
|
-
return new Promise(function (resolve, reject) {
|
|
8
|
-
let split = require('split')
|
|
9
|
-
let fs = require('fs')
|
|
10
|
-
|
|
11
|
-
let users = []
|
|
12
|
-
|
|
13
|
-
fs.createReadStream(file).pipe(split())
|
|
14
|
-
.on('data', function (line) {
|
|
15
|
-
line = line.trim()
|
|
16
|
-
if (line) {
|
|
17
|
-
users.push(line)
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
.on('end', function () {
|
|
21
|
-
resolve(users)
|
|
22
|
-
})
|
|
23
|
-
.on('error', function (err) {
|
|
24
|
-
reject(err)
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
6
|
async function run (context) {
|
|
30
7
|
sudo()
|
|
31
8
|
const skynet = new SkynetAPI(context.auth.password)
|
|
32
9
|
let user = context.flags.user || process.env.HEROKU_USER
|
|
33
|
-
let file = context.flags.infile
|
|
34
10
|
let notes = context.flags.notes
|
|
35
11
|
let category = context.flags.category
|
|
36
12
|
let force = context.flags.bypass
|
|
37
13
|
|
|
38
|
-
if (user
|
|
39
|
-
throw new Error('
|
|
14
|
+
if (!user) {
|
|
15
|
+
throw new Error('Required flag: --user USER')
|
|
40
16
|
}
|
|
41
17
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} else {
|
|
46
|
-
if (!user) {
|
|
47
|
-
throw new Error('Required flag: --user USER or --infile FILE')
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let response = await cli.action(`deprovisioning ${cli.color.cyan(user)}`, skynet.deprovision(user, notes, category, force))
|
|
51
|
-
response = JSON.parse(response)
|
|
52
|
-
cli.log(`${response.status}. ${response.message}`)
|
|
53
|
-
}
|
|
18
|
+
let response = await cli.action(`deprovisioning ${cli.color.cyan(user)}`, skynet.deprovision(user, notes, category, force))
|
|
19
|
+
response = JSON.parse(response)
|
|
20
|
+
cli.log(`${response.status}. ${response.message}`)
|
|
54
21
|
}
|
|
55
22
|
|
|
56
23
|
module.exports = {
|
|
@@ -61,7 +28,6 @@ module.exports = {
|
|
|
61
28
|
$ heroku skynet:deprovision -u foo@bar.com -n "helpful suspend message" -c "spam"`,
|
|
62
29
|
flags: [
|
|
63
30
|
{ name: 'user', char: 'u', description: 'user to deprovision', hasValue: true },
|
|
64
|
-
{ name: 'infile', char: 'i', description: 'file list of users to deprovision', hasValue: true },
|
|
65
31
|
{ name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true },
|
|
66
32
|
{ name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
|
|
67
33
|
{ name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false }
|
package/commands/userpass/add.js
CHANGED
|
@@ -4,7 +4,7 @@ let SkynetAPI = require('../../lib/skynet')
|
|
|
4
4
|
|
|
5
5
|
async function run (context) {
|
|
6
6
|
const skynet = new SkynetAPI(context.auth.password)
|
|
7
|
-
await cli.action(`adding ${cli.color.cyan(context.flags.
|
|
7
|
+
await cli.action(`adding ${cli.color.cyan(context.flags.flag)} to ${cli.color.cyan(context.flags.user)}`, skynet.addUserpass(context.flags.user, context.flags.flag))
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
package/lib/skynet.js
CHANGED
|
@@ -183,22 +183,6 @@ module.exports = class SkynetAPI {
|
|
|
183
183
|
})
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
bulkDeprovision (users, notes, category) {
|
|
187
|
-
var body = {
|
|
188
|
-
value: users,
|
|
189
|
-
reason: notes,
|
|
190
|
-
method: 'skynet-cli',
|
|
191
|
-
category: category,
|
|
192
|
-
bulk: 'true'
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return this.request(`/deprovision`, {
|
|
196
|
-
method: 'POST',
|
|
197
|
-
body: body,
|
|
198
|
-
form: true
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
|
|
202
186
|
addCategory (category, description) {
|
|
203
187
|
let body = {
|
|
204
188
|
category: category,
|