@heroku/skynet 1.6.7 → 1.6.9

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/README.md CHANGED
@@ -36,8 +36,54 @@ heroku login # login to the staging cloud via the cli
36
36
  heroku skynet:<cmd>
37
37
  ```
38
38
 
39
+ ### Unit test
40
+ ```
41
+ # $SKYNET_CLI_HOME points to the home dir of heroku-skynet-cli
42
+ cd $SKYNET_CLI_HOME
43
+ unset SKYNET_HOST
44
+ npm test
45
+ ```
46
+
47
+ ### Integration test
48
+ ```
49
+ #
50
+ # Start local skynet
51
+ #
52
+
53
+ # start postgres DB and redis
54
+ $ pg_ctl -D /usr/local/var/postgres start
55
+ $ redis-server
56
+
57
+ # Update URL and KEY in .env. $REAL_KEY_IN_PRODUCTION refers to the real key in production.
58
+ $ sed -i -e 's/HEROKU_API_URL=.*/HEROKU_API_URL=https:\/\/api.heroku.com/g' .env
59
+ $ sed -i -e 's/HEROKU_API_KEY=.*/HEROKU_API_KEY=$REAL_KEY_IN_PRODUCTION/g' .env
60
+
61
+ # Start skynet instance
62
+ $ cd $SKYNET_HOME
63
+ $ heroku local web,worker
64
+
65
+ #
66
+ # Config heroku-skynet-cli
67
+ #
68
+
69
+ # Pointing CLI to the Heroku Production
70
+ $ cd $HEROKU_SKYNET_CLI_HOME
71
+ $ cloud production
72
+
73
+ # Pointing to the local Skynet instance
74
+ $ export SKYNET_HOST=http://localhost:5000
75
+
76
+ #
77
+ # Run Tests
78
+ #
79
+
80
+ # This unsuspend request will be sent to the local Skynet instance
81
+ $ heroku skynet::unsuspend::user -u dzhuo@heroku.com
82
+
83
+ ```
84
+
39
85
  ### Publishing to `npm`
40
- 1. Send an email to `heroku-help@salesforce.com` requesting access to @heroku on npm. Include your npm username (https://www.npmjs.com/)
86
+ 1. Request access to NPM using [this form](https://securityorg.force.com/IntakeApp/s/?entityCode=HerokuAccess&si=a1i3A0000007euiQAA)
41
87
 
42
88
  1. Publish the package:
43
89
 
@@ -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) {
@@ -6,9 +6,8 @@ let SkynetAPI = require('../../lib/skynet')
6
6
  async function run (context) {
7
7
  sudo()
8
8
  const skynet = new SkynetAPI(context.auth.password)
9
- let response = await skynet.unsuspendApp(context.flags.app, context.flags.notes)
10
- response = JSON.parse(response)
11
- cli.log(`suspending...${cli.color.cyan(response.status)}.\n${response.message}`)
9
+ const response = await cli.action(`unsuspending ${cli.color.cyan(context.flags.app)}`, skynet.unsuspendApp(context.flags.app))
10
+ cli.log(`unsuspending...${cli.color.cyan(response.status)}.\n${response.message}`)
12
11
  }
13
12
 
14
13
  module.exports = {
@@ -7,9 +7,7 @@ async function run (context) {
7
7
  sudo()
8
8
  const skynet = new SkynetAPI(context.auth.password)
9
9
  let user = context.flags.user || process.env.HEROKU_USER
10
-
11
- let response = await cli.action(`unsuspending ${cli.color.cyan(user)}`, skynet.unsuspendUser(user))
12
- response = JSON.parse(response)
10
+ const response = await cli.action(`unsuspending ${cli.color.cyan(user)}`, skynet.unsuspendUser(user))
13
11
  cli.log(`${response.status}. ${response.message}`)
14
12
  }
15
13
 
package/lib/skynet.js CHANGED
@@ -9,7 +9,7 @@ const SKYNET_BASE_URL = `${skynetHost}/api-h`
9
9
 
10
10
  module.exports = class SkynetAPI {
11
11
  constructor (token) {
12
- let packageJSON = require('../package.json')
12
+ const packageJSON = require('../package.json')
13
13
  this.version = `skynet-${packageJSON.version}`
14
14
  this.token = token
15
15
  }
@@ -44,7 +44,9 @@ module.exports = class SkynetAPI {
44
44
 
45
45
  removeWhitelist (appOrUserEmail) {
46
46
  return this.request(`/whitelist/${appOrUserEmail}`, {
47
- method: 'DELETE'
47
+ method: 'DELETE',
48
+ body: {},
49
+ json: true
48
50
  })
49
51
  }
50
52
 
@@ -108,7 +110,9 @@ module.exports = class SkynetAPI {
108
110
 
109
111
  unsuspendApp (app) {
110
112
  return this.request(`/suspensions/app/${app}`, {
111
- method: 'DELETE'
113
+ method: 'DELETE',
114
+ body: {},
115
+ json: true
112
116
  })
113
117
  }
114
118
 
@@ -131,17 +135,21 @@ module.exports = class SkynetAPI {
131
135
 
132
136
  unsuspendUser (user) {
133
137
  return this.request(`/suspensions/user/${user}`, {
134
- method: 'DELETE'
138
+ method: 'DELETE',
139
+ body: {},
140
+ json: true
135
141
  })
136
142
  }
137
143
 
138
- bulkSuspendUsers (users, notes, category) {
144
+ bulkSuspendUsers (users, notes, category, notify, force = false) {
139
145
  var body = {
140
146
  value: users,
141
147
  reason: notes,
142
148
  method: 'skynet-cli',
143
149
  category: category,
144
- bulk: 'true'
150
+ bulk: 'true',
151
+ force: force,
152
+ notify: notify
145
153
  }
146
154
 
147
155
  return this.request(`/suspend/user`, {
@@ -184,7 +192,7 @@ module.exports = class SkynetAPI {
184
192
  }
185
193
 
186
194
  addCategory (category, description) {
187
- let body = {
195
+ const body = {
188
196
  category: category,
189
197
  description: description
190
198
  }
@@ -198,7 +206,9 @@ module.exports = class SkynetAPI {
198
206
 
199
207
  removeCategory (category) {
200
208
  return this.request(`/categories/${category}`, {
201
- method: 'DELETE'
209
+ method: 'DELETE',
210
+ body: {},
211
+ json: true
202
212
  })
203
213
  }
204
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/skynet",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "description": "use Skynet from Heroku CLI",
5
5
  "main": "index.js",
6
6
  "author": "Bob Argenbright @byt3smith",