@heroku/skynet 1.6.17 → 1.6.18

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.
@@ -2,6 +2,7 @@ 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
+ const notifyOption = require('../lib/notifyOption')
5
6
 
6
7
  async function run (context) {
7
8
  sudo()
@@ -10,7 +11,9 @@ async function run (context) {
10
11
  const notes = context.flags.notes
11
12
  const category = context.flags.category
12
13
  const force = context.flags.bypass
13
- const notify = !context.flags['no-notify']
14
+
15
+ const notify = notifyOption.set(context.flags.notify, context.flags['no-notify'])
16
+ const notificationStatus = (notify) ? 'enabled' : 'disabled'
14
17
 
15
18
  if (!user) {
16
19
  throw new Error('Required flag: --user USER')
@@ -18,7 +21,7 @@ async function run (context) {
18
21
 
19
22
  let response = await cli.action(`deprovisioning ${cli.color.cyan(user)}`, skynet.deprovision(user, notes, category, notify, force))
20
23
  response = JSON.parse(response)
21
- cli.log(`${response.status}. ${response.message}`)
24
+ cli.log(`${response.status}. ${response.message}. Notification ${notificationStatus}`)
22
25
  }
23
26
 
24
27
  module.exports = {
@@ -32,6 +35,7 @@ module.exports = {
32
35
  { name: 'category', char: 'c', description: 'suspension category', hasValue: true, required: true },
33
36
  { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
34
37
  { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false },
38
+ { name: 'notify', description: 'send user suspension email notification', hasValue: false, required: false },
35
39
  { name: 'no-notify', description: 'skip user suspension email notification', hasValue: false, required: false }
36
40
  ],
37
41
  run: command(run)
@@ -3,6 +3,7 @@ const command = require('../../lib/command')
3
3
  const sudo = require('../../lib/sudo')
4
4
  const SkynetAPI = require('../../lib/skynet')
5
5
  const HerokuAPI = require('../../lib/heroku')
6
+ const notifyOption = require('../../lib/notifyOption')
6
7
 
7
8
  function readlines (file) {
8
9
  return new Promise(function (resolve, reject) {
@@ -41,9 +42,11 @@ async function run (context) {
41
42
  const notes = context.flags.notes
42
43
  const category = context.flags.category
43
44
  const force = context.flags.bypass
44
- const notify = !context.flags['no-notify']
45
45
  const unverify = context.flags.unverify
46
46
 
47
+ const notify = notifyOption.set(context.flags.notify, context.flags['no-notify'])
48
+ const notificationStatus = (notify) ? 'enabled' : 'disabled'
49
+
47
50
  if (user && file) {
48
51
  throw new Error('Either --user USER or --infile must be passed, but not both')
49
52
  }
@@ -51,7 +54,7 @@ async function run (context) {
51
54
  if (file) {
52
55
  const users = await readlines(file)
53
56
  const response = await skynet.bulkSuspendUsers(users.join(), notes, category, notify, force)
54
- cli.log(response)
57
+ cli.log(`${response}. Notification ${notificationStatus}`)
55
58
 
56
59
  if (unverify) {
57
60
  users.forEach(item => unverifyUser(api, item))
@@ -63,7 +66,7 @@ async function run (context) {
63
66
 
64
67
  let response = await skynet.suspendUser(user, notes, category, notify, force)
65
68
  response = JSON.parse(response)
66
- cli.log(`${response.status}. ${response.message}`)
69
+ cli.log(`${response.status}. ${response.message}. Notification ${notificationStatus}`)
67
70
 
68
71
  if (unverify) {
69
72
  unverifyUser(api, user)
@@ -84,6 +87,7 @@ module.exports = {
84
87
  { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
85
88
  { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false },
86
89
  { name: 'no-notify', description: 'skip user suspension email notification', hasValue: false, required: false },
90
+ { name: 'notify', description: 'send user suspension email notification', hasValue: false, required: false },
87
91
  { name: 'unverify', description: 'unverifies a user account, removes all billing info', hasValue: false, required: false }
88
92
  ],
89
93
  run: command(run)
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ exports.set = set
4
+
5
+ function set (notifyFlag, noNotifyFlag) {
6
+ let notify = true
7
+ if (process.env.SKYNET_NOTIFICATION && process.env.SKYNET_NOTIFICATION === 'false') {
8
+ notify = false
9
+ }
10
+
11
+ if (notifyFlag && noNotifyFlag) {
12
+ throw new Error('Flag --notify and --no-notify could not use together')
13
+ }
14
+
15
+ if (noNotifyFlag) {
16
+ notify = false
17
+ }
18
+
19
+ if (notifyFlag) {
20
+ notify = true
21
+ }
22
+
23
+ return notify
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/skynet",
3
- "version": "1.6.17",
3
+ "version": "1.6.18",
4
4
  "description": "use Skynet from Heroku CLI",
5
5
  "main": "index.js",
6
6
  "author": "Bob Argenbright @byt3smith",