@heroku/skynet 1.7.0 → 1.9.0
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/suspend/app-owner.js +10 -26
- package/commands/suspend/user.js +10 -26
- package/index.js +0 -2
- package/lib/skynet.js +0 -21
- package/lib/utils.js +35 -0
- package/package.json +3 -3
- package/commands/categories/add.js +0 -21
- package/commands/categories/remove.js +0 -20
|
@@ -2,29 +2,8 @@ const cli = require('heroku-cli-util')
|
|
|
2
2
|
const command = require('../../lib/command')
|
|
3
3
|
const sudo = require('../../lib/sudo')
|
|
4
4
|
const SkynetAPI = require('../../lib/skynet')
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return new Promise(function (resolve, reject) {
|
|
8
|
-
const split = require('split')
|
|
9
|
-
const fs = require('fs')
|
|
10
|
-
|
|
11
|
-
const 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
|
-
}
|
|
5
|
+
const utils = require('../../lib/utils')
|
|
6
|
+
const chunkSize = 5
|
|
28
7
|
|
|
29
8
|
async function run (context) {
|
|
30
9
|
sudo()
|
|
@@ -40,9 +19,14 @@ async function run (context) {
|
|
|
40
19
|
}
|
|
41
20
|
|
|
42
21
|
if (file) {
|
|
43
|
-
const apps = await readlines(file)
|
|
44
|
-
const
|
|
45
|
-
|
|
22
|
+
const apps = await utils.readlines(file)
|
|
23
|
+
const chunks = utils.arrayChunks(apps, chunkSize)
|
|
24
|
+
for (const chunk of chunks) {
|
|
25
|
+
cli.log('Suspsneding app owners: ' + chunk.join())
|
|
26
|
+
const response = await skynet.bulkSuspendAppOwner(apps.join(), notes, category)
|
|
27
|
+
cli.log(response)
|
|
28
|
+
cli.log()
|
|
29
|
+
}
|
|
46
30
|
} else {
|
|
47
31
|
if (!app) {
|
|
48
32
|
throw new Error('Required flag: --owner OWNER or --infile FILE')
|
package/commands/suspend/user.js
CHANGED
|
@@ -4,29 +4,8 @@ const sudo = require('../../lib/sudo')
|
|
|
4
4
|
const SkynetAPI = require('../../lib/skynet')
|
|
5
5
|
const HerokuAPI = require('../../lib/heroku')
|
|
6
6
|
const notifyOption = require('../../lib/notifyOption')
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return new Promise(function (resolve, reject) {
|
|
10
|
-
const split = require('split')
|
|
11
|
-
const fs = require('fs')
|
|
12
|
-
|
|
13
|
-
const users = []
|
|
14
|
-
|
|
15
|
-
fs.createReadStream(file).pipe(split())
|
|
16
|
-
.on('data', function (line) {
|
|
17
|
-
line = line.trim()
|
|
18
|
-
if (line) {
|
|
19
|
-
users.push(line)
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
.on('end', function () {
|
|
23
|
-
resolve(users)
|
|
24
|
-
})
|
|
25
|
-
.on('error', function (err) {
|
|
26
|
-
reject(err)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
}
|
|
7
|
+
const utils = require('../../lib/utils')
|
|
8
|
+
const chunkSize = 5
|
|
30
9
|
|
|
31
10
|
async function unverifyUser (api, user) {
|
|
32
11
|
const resMsg = await api.unverifyUser(user)
|
|
@@ -52,9 +31,14 @@ async function run (context) {
|
|
|
52
31
|
}
|
|
53
32
|
|
|
54
33
|
if (file) {
|
|
55
|
-
const users = await readlines(file)
|
|
56
|
-
const
|
|
57
|
-
|
|
34
|
+
const users = await utils.readlines(file)
|
|
35
|
+
const chunks = utils.arrayChunks(users, chunkSize)
|
|
36
|
+
for (const chunk of chunks) {
|
|
37
|
+
cli.log('Suspsneding users: ' + chunk.join())
|
|
38
|
+
const response = await skynet.bulkSuspendUsers(chunk.join(), notes, category, notify, force)
|
|
39
|
+
cli.log(`${response}. Notification ${notificationStatus}`)
|
|
40
|
+
cli.log()
|
|
41
|
+
}
|
|
58
42
|
|
|
59
43
|
if (unverify) {
|
|
60
44
|
users.forEach(item => unverifyUser(api, item))
|
package/index.js
CHANGED
|
@@ -14,8 +14,6 @@ exports.commands = [
|
|
|
14
14
|
require('./commands/unsuspend/user.js'),
|
|
15
15
|
require('./commands/deprovision.js'),
|
|
16
16
|
require('./commands/categories.js'),
|
|
17
|
-
require('./commands/categories/add.js'),
|
|
18
|
-
require('./commands/categories/remove.js'),
|
|
19
17
|
require('./commands/whitelist/add.js'),
|
|
20
18
|
require('./commands/whitelist/remove.js'),
|
|
21
19
|
require('./commands/whitelists.js'),
|
package/lib/skynet.js
CHANGED
|
@@ -201,27 +201,6 @@ module.exports = class SkynetAPI {
|
|
|
201
201
|
})
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
addCategory (category, description) {
|
|
205
|
-
const body = {
|
|
206
|
-
category: category,
|
|
207
|
-
description: description
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
return this.request('/categories', {
|
|
211
|
-
method: 'POST',
|
|
212
|
-
body: body,
|
|
213
|
-
json: true
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
removeCategory (category) {
|
|
218
|
-
return this.request(`/categories/${category}`, {
|
|
219
|
-
method: 'DELETE',
|
|
220
|
-
body: {},
|
|
221
|
-
json: true
|
|
222
|
-
})
|
|
223
|
-
}
|
|
224
|
-
|
|
225
204
|
suspensions (account) {
|
|
226
205
|
return this.request(`/v2/suspensions/${account}`, {
|
|
227
206
|
method: 'GET'
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
exports.readlines = function (file) {
|
|
2
|
+
return new Promise(function (resolve, reject) {
|
|
3
|
+
const split = require('split')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
|
|
6
|
+
const entries = []
|
|
7
|
+
|
|
8
|
+
fs.createReadStream(file).pipe(split())
|
|
9
|
+
.on('data', function (line) {
|
|
10
|
+
line = line.trim()
|
|
11
|
+
if (line) {
|
|
12
|
+
entries.push(line)
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
.on('end', function () {
|
|
16
|
+
resolve(entries)
|
|
17
|
+
})
|
|
18
|
+
.on('error', function (err) {
|
|
19
|
+
reject(err)
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.arrayChunks = function (array, chunkSize) {
|
|
25
|
+
var chunks = []
|
|
26
|
+
if (array.length <= chunkSize) {
|
|
27
|
+
chunks.push(array)
|
|
28
|
+
} else {
|
|
29
|
+
for (var i = 0; i < array.length; i += chunkSize) {
|
|
30
|
+
chunks.push(array.slice(i, i + chunkSize))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return chunks
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heroku/skynet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "use Skynet from Heroku CLI",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Bob Argenbright @byt3smith",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"split": "^1.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"acorn": "
|
|
25
|
+
"acorn": "^6.4.1",
|
|
26
26
|
"minimist": ">=1.2.2",
|
|
27
27
|
"mocha": "^5.2.0",
|
|
28
28
|
"mockdate": "^2.0.1",
|
|
29
29
|
"nock": "^12.0.3",
|
|
30
|
-
"np": "^6.
|
|
30
|
+
"np": "^6.5.0",
|
|
31
31
|
"standard": "^14.3.3",
|
|
32
32
|
"unexpected": "^10.29.0"
|
|
33
33
|
},
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const cli = require('heroku-cli-util')
|
|
2
|
-
const command = require('../../lib/command')
|
|
3
|
-
const SkynetAPI = require('../../lib/skynet')
|
|
4
|
-
|
|
5
|
-
async function run (context) {
|
|
6
|
-
const skynet = new SkynetAPI(context.auth.password)
|
|
7
|
-
await cli.action(`adding new category: ${cli.color.cyan(context.flags.category)}`, skynet.addCategory(context.flags.category, context.flags.description))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
topic: 'skynet',
|
|
12
|
-
command: 'categories:add',
|
|
13
|
-
description: 'adds a value to suspension categories',
|
|
14
|
-
help: `Examples:
|
|
15
|
-
$ heroku sudo skynet:categories:add -c new-category -d "this is a new category"`,
|
|
16
|
-
flags: [
|
|
17
|
-
{ name: 'category', char: 'c', description: 'new category value', hasValue: true, required: true },
|
|
18
|
-
{ name: 'description', char: 'd', description: 'new category description', hasValue: true, required: true }
|
|
19
|
-
],
|
|
20
|
-
run: command(run)
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const cli = require('heroku-cli-util')
|
|
2
|
-
const command = require('../../lib/command')
|
|
3
|
-
const SkynetAPI = require('../../lib/skynet')
|
|
4
|
-
|
|
5
|
-
async function run (context) {
|
|
6
|
-
const skynet = new SkynetAPI(context.auth.password)
|
|
7
|
-
await cli.action(`removing ${cli.color.cyan(context.flags.category)} from suspension categories`, skynet.removeCategory(context.flags.category))
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
topic: 'skynet',
|
|
12
|
-
command: 'categories:remove',
|
|
13
|
-
description: 'removes a value from suspension categories',
|
|
14
|
-
help: `Examples:
|
|
15
|
-
$ heroku sudo skynet:categories:remove -c test-category`,
|
|
16
|
-
flags: [
|
|
17
|
-
{ name: 'category', char: 'c', description: 'category to remove', hasValue: true, required: true }
|
|
18
|
-
],
|
|
19
|
-
run: command(run)
|
|
20
|
-
}
|