@heroku/skynet 1.6.6 → 1.6.8
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/suspend/user.js +1 -1
- package/commands/userpass/add.js +1 -1
- package/lib/skynet.js +4 -18
- 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/suspend/user.js
CHANGED
|
@@ -42,7 +42,7 @@ async function run (context) {
|
|
|
42
42
|
|
|
43
43
|
if (file) {
|
|
44
44
|
let users = await readlines(file)
|
|
45
|
-
let response = await skynet.bulkSuspendUsers(users.join(), notes, category)
|
|
45
|
+
let response = await skynet.bulkSuspendUsers(users.join(), notes, category, notify, force)
|
|
46
46
|
cli.log(response)
|
|
47
47
|
} else {
|
|
48
48
|
if (!user) {
|
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
|
@@ -135,13 +135,15 @@ module.exports = class SkynetAPI {
|
|
|
135
135
|
})
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
bulkSuspendUsers (users, notes, category) {
|
|
138
|
+
bulkSuspendUsers (users, notes, category, notify, force = false) {
|
|
139
139
|
var body = {
|
|
140
140
|
value: users,
|
|
141
141
|
reason: notes,
|
|
142
142
|
method: 'skynet-cli',
|
|
143
143
|
category: category,
|
|
144
|
-
bulk: 'true'
|
|
144
|
+
bulk: 'true',
|
|
145
|
+
force: force,
|
|
146
|
+
notify: notify
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
return this.request(`/suspend/user`, {
|
|
@@ -183,22 +185,6 @@ module.exports = class SkynetAPI {
|
|
|
183
185
|
})
|
|
184
186
|
}
|
|
185
187
|
|
|
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
188
|
addCategory (category, description) {
|
|
203
189
|
let body = {
|
|
204
190
|
category: category,
|