@heroku/skynet 1.4.2 → 1.5.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.
@@ -10,8 +10,8 @@ function * run (context) {
10
10
  response = JSON.parse(response)
11
11
  cli.table(response, {
12
12
  columns: [
13
- {key: 'Category'},
14
- {key: 'Description'}
13
+ { key: 'Category' },
14
+ { key: 'Description' }
15
15
  ]
16
16
  })
17
17
  }
@@ -11,18 +11,18 @@ function readlines (file) {
11
11
  let users = []
12
12
 
13
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
- })
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
26
  })
27
27
  }
28
28
 
@@ -60,11 +60,11 @@ module.exports = {
60
60
  help: `Examples:
61
61
  $ heroku skynet:deprovision -u foo@bar.com -n "helpful suspend message" -c "spam"`,
62
62
  flags: [
63
- {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
- {name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true},
66
- {name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true},
67
- {name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false}
63
+ { 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
+ { name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true },
66
+ { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
67
+ { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false }
68
68
  ],
69
69
  run: cli.command(co.wrap(run))
70
70
  }
@@ -11,18 +11,18 @@ function readlines (file) {
11
11
  let users = []
12
12
 
13
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
- })
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
26
  })
27
27
  }
28
28
 
@@ -60,11 +60,11 @@ module.exports = {
60
60
  help: `Examples:
61
61
  $ heroku skynet:suspend:app-owner -a foobar -n "helpful suspend message" -c "ddos"`,
62
62
  flags: [
63
- {name: 'app', char: 'a', description: 'app that requires owner suspension', hasValue: true},
64
- {name: 'infile', char: 'i', description: 'file of apps that require owner suspension', hasValue: true},
65
- {name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true},
66
- {name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true},
67
- {name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false}
63
+ { name: 'app', char: 'a', description: 'app that requires owner suspension', hasValue: true },
64
+ { name: 'infile', char: 'i', description: 'file of apps that require owner suspension', hasValue: true },
65
+ { name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true },
66
+ { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
67
+ { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false }
68
68
  ],
69
69
  run: cli.command(co.wrap(run))
70
70
  }
@@ -18,8 +18,8 @@ module.exports = {
18
18
  help: `Examples:
19
19
  $ heroku skynet:suspend:app -a test-app -n "helpful suspend message"`,
20
20
  flags: [
21
- {name: 'app', char: 'a', description: 'app to suspend', hasValue: true, required: true},
22
- {name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true}
21
+ { name: 'app', char: 'a', description: 'app to suspend', hasValue: true, required: true },
22
+ { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true }
23
23
  ],
24
24
  run: cli.command(co.wrap(run))
25
25
  }
@@ -11,18 +11,18 @@ function readlines (file) {
11
11
  let users = []
12
12
 
13
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
- })
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
26
  })
27
27
  }
28
28
 
@@ -34,6 +34,7 @@ function * run (context) {
34
34
  let notes = context.flags.notes
35
35
  let category = context.flags.category
36
36
  let force = context.flags.bypass
37
+ let notify = !context.flags['no-notify']
37
38
 
38
39
  if (user && file) {
39
40
  throw new Error('Either --user USER or --infile must be passed, but not both')
@@ -47,7 +48,7 @@ function * run (context) {
47
48
  throw new Error('Required flag: --user USER or --infile FILE')
48
49
  }
49
50
 
50
- let response = yield cli.action(`suspending ${cli.color.cyan(user)}`, skynet.suspendUser(user, notes, category, force))
51
+ let response = yield cli.action(`suspending ${cli.color.cyan(user)}`, skynet.suspendUser(user, notes, category, notify, force))
51
52
  response = JSON.parse(response)
52
53
  cli.log(`${response.status}. ${response.message}`)
53
54
  }
@@ -60,11 +61,12 @@ module.exports = {
60
61
  help: `Examples:
61
62
  $ heroku sudo skynet:suspend:user -u foo@bar.com -n "helpful suspend message" -c "ddos"`,
62
63
  flags: [
63
- {name: 'user', char: 'u', description: 'user to suspend', hasValue: true},
64
- {name: 'infile', char: 'i', description: 'file of users to suspend', hasValue: true},
65
- {name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true},
66
- {name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true},
67
- {name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false}
64
+ { name: 'user', char: 'u', description: 'user to suspend', hasValue: true },
65
+ { name: 'infile', char: 'i', description: 'file of users to suspend', hasValue: true },
66
+ { name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true },
67
+ { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
68
+ { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false },
69
+ { name: 'no-notify', description: 'skip user suspension email notification', hasValue: false, required: false }
68
70
  ],
69
71
  run: cli.command(co.wrap(run))
70
72
  }
@@ -18,7 +18,7 @@ module.exports = {
18
18
  help: `Examples:
19
19
  $ heroku skynet:unsuspend:app -a test-app`,
20
20
  flags: [
21
- {name: 'app', char: 'a', description: 'app to unsuspend', hasValue: true, required: true}
21
+ { name: 'app', char: 'a', description: 'app to unsuspend', hasValue: true, required: true }
22
22
  ],
23
23
  run: cli.command(co.wrap(run))
24
24
  }
@@ -20,7 +20,7 @@ module.exports = {
20
20
  help: `Examples:
21
21
  $ heroku skynet:unsuspend:user -u foo@bar.com`,
22
22
  flags: [
23
- {name: 'user', char: 'u', description: 'user to unsuspend', hasValue: true}
23
+ { name: 'user', char: 'u', description: 'user to unsuspend', hasValue: true }
24
24
  ],
25
25
  run: cli.command(co.wrap(run))
26
26
  }
@@ -14,8 +14,8 @@ module.exports = {
14
14
  help: `Examples:
15
15
  $ heroku skynet:userpass:add -u foo@bar.com -f cant-install-abused-addons`,
16
16
  flags: [
17
- {name: 'user', char: 'u', description: 'user to apply userpass flag to', hasValue: true, required: true},
18
- {name: 'flag', char: 'f', description: 'flag to add to the given user', hasValue: true, required: true}
17
+ { name: 'user', char: 'u', description: 'user to apply userpass flag to', hasValue: true, required: true },
18
+ { name: 'flag', char: 'f', description: 'flag to add to the given user', hasValue: true, required: true }
19
19
  ],
20
20
  run: cli.command(co.wrap(run))
21
21
  }
@@ -14,8 +14,8 @@ module.exports = {
14
14
  help: `Examples:
15
15
  $ heroku skynet:userpass:remove -u foo@bar.com -f cant-install-abused-addons`,
16
16
  flags: [
17
- {name: 'user', char: 'u', description: 'user to remove user_pass from', hasValue: true, required: true},
18
- {name: 'flag', char: 'f', description: 'flag to remove from given user', hasValue: true, required: true}
17
+ { name: 'user', char: 'u', description: 'user to remove user_pass from', hasValue: true, required: true },
18
+ { name: 'flag', char: 'f', description: 'flag to remove from given user', hasValue: true, required: true }
19
19
  ],
20
20
  run: cli.command(co.wrap(run))
21
21
  }
@@ -0,0 +1,38 @@
1
+ let cli = require('heroku-cli-util')
2
+ let co = require('co')
3
+ let SkynetAPI = require('../../lib/skynet')
4
+
5
+ function * run (context) {
6
+ const skynet = new SkynetAPI(context.auth.password)
7
+ yield cli.action(
8
+ `adding ${cli.color.cyan(
9
+ context.flags.value
10
+ )} to whitelist with ${cli.color.cyan(context.flags.notes)}`,
11
+ skynet.addWhitelist(context.flags.value, context.flags.notes)
12
+ )
13
+ }
14
+
15
+ module.exports = {
16
+ topic: 'skynet',
17
+ command: 'whitelist:add',
18
+ description: 'adds an app or user to the whitelist',
19
+ help: `Examples:
20
+ $ heroku skynet:whitelist:add -v foo@bar.com -n Additional info`,
21
+ flags: [
22
+ {
23
+ name: 'value',
24
+ char: 'v',
25
+ description: 'app name or user email to whitelist',
26
+ hasValue: true,
27
+ required: true
28
+ },
29
+ {
30
+ name: 'notes',
31
+ char: 'n',
32
+ description: 'additional information for the whitelist entry',
33
+ hasValue: true,
34
+ required: false
35
+ }
36
+ ],
37
+ run: cli.command(co.wrap(run))
38
+ }
@@ -0,0 +1,29 @@
1
+ let cli = require('heroku-cli-util')
2
+ let co = require('co')
3
+ let SkynetAPI = require('../../lib/skynet')
4
+
5
+ function * run (context) {
6
+ const skynet = new SkynetAPI(context.auth.password)
7
+ yield cli.action(
8
+ `removing ${cli.color.cyan(context.flags.value)} from whitelist`,
9
+ skynet.removeWhitelist(context.flags.value)
10
+ )
11
+ }
12
+
13
+ module.exports = {
14
+ topic: 'skynet',
15
+ command: 'whitelist:remove',
16
+ description: 'Remove user or app from the whitelist',
17
+ help: `Examples:
18
+ $ heroku skynet:whitelist:remove -v foo@bar.com`,
19
+ flags: [
20
+ {
21
+ name: 'value',
22
+ char: 'v',
23
+ description: 'app name or user email to remove from whitelist',
24
+ hasValue: true,
25
+ required: true
26
+ }
27
+ ],
28
+ run: cli.command(co.wrap(run))
29
+ }
package/index.js CHANGED
@@ -13,5 +13,7 @@ exports.commands = [
13
13
  require('./commands/unsuspend/apps.js'),
14
14
  require('./commands/unsuspend/user.js'),
15
15
  require('./commands/deprovision.js'),
16
- require('./commands/categories.js')
16
+ require('./commands/categories.js'),
17
+ require('./commands/whitelist/add.js'),
18
+ require('./commands/whitelist/remove.js')
17
19
  ]
package/lib/skynet.js CHANGED
@@ -21,7 +21,7 @@ module.exports = class SkynetAPI {
21
21
 
22
22
  options.json = false
23
23
 
24
- return cli.got(SKYNET_BASE_URL + url, options).then((res) => res.body)
24
+ return cli.got(SKYNET_BASE_URL + url, options).then(res => res.body)
25
25
  }
26
26
 
27
27
  categories () {
@@ -30,6 +30,24 @@ module.exports = class SkynetAPI {
30
30
  })
31
31
  }
32
32
 
33
+ addWhitelist (appOrUserEmail, notes) {
34
+ var body = {
35
+ value: appOrUserEmail,
36
+ notes: notes
37
+ }
38
+
39
+ return this.request(`/whitelist`, {
40
+ method: 'POST',
41
+ body: qs.stringify(body)
42
+ })
43
+ }
44
+
45
+ removeWhitelist (appOrUserEmail) {
46
+ return this.request(`/whitelist/${appOrUserEmail}`, {
47
+ method: 'DELETE'
48
+ })
49
+ }
50
+
33
51
  removeUserpass (user, flag) {
34
52
  var body = {
35
53
  user: user,
@@ -88,13 +106,15 @@ module.exports = class SkynetAPI {
88
106
  method: 'DELETE'
89
107
  })
90
108
  }
91
- suspendUser (user, notes, category, force = false) {
109
+
110
+ suspendUser (user, notes, category, notify, force = false) {
92
111
  var body = {
93
112
  value: user,
94
113
  reason: notes,
95
114
  method: 'skynet-cli',
96
115
  category: category,
97
- force: force
116
+ force: force,
117
+ notify: notify
98
118
  }
99
119
 
100
120
  return this.request(`/suspend/user`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/skynet",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "use Skynet from Heroku CLI",
5
5
  "main": "index.js",
6
6
  "author": "Bob Argenbright @byt3smith",
@@ -25,7 +25,7 @@
25
25
  "mocha": "^3.4.2",
26
26
  "mockdate": "^2.0.1",
27
27
  "nock": "^9.0.13",
28
- "standard": "^10.0.2",
28
+ "standard": "^12.0.1",
29
29
  "unexpected": "^10.29.0"
30
30
  },
31
31
  "scripts": {