@heroku/skynet 1.6.8 → 1.6.10
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 +47 -1
- package/commands/unsuspend/apps.js +13 -4
- package/commands/unsuspend/user.js +11 -4
- package/lib/skynet.js +18 -10
- package/package.json +1 -1
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.
|
|
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
|
|
|
@@ -6,8 +6,15 @@ 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
|
|
10
|
-
|
|
9
|
+
let app = context.flags.app
|
|
10
|
+
let category = context.flags.category
|
|
11
|
+
let notes = context.flags.notes
|
|
12
|
+
|
|
13
|
+
if (!app) {
|
|
14
|
+
throw new Error('Required flag: --app APP')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const response = await skynet.unsuspendApp(app, category, notes)
|
|
11
18
|
cli.log(`suspending...${cli.color.cyan(response.status)}.\n${response.message}`)
|
|
12
19
|
}
|
|
13
20
|
|
|
@@ -16,9 +23,11 @@ module.exports = {
|
|
|
16
23
|
command: 'unsuspend:app',
|
|
17
24
|
description: '(requires sudo) unsuspends an app',
|
|
18
25
|
help: `Examples:
|
|
19
|
-
$ heroku skynet:unsuspend:app -a test-app`,
|
|
26
|
+
$ heroku skynet:unsuspend:app -a test-app -n "helpful unsuspend message" -c "ddos"`,
|
|
20
27
|
flags: [
|
|
21
|
-
{ name: 'app', char: 'a', description: 'app to unsuspend', hasValue: true, required: true }
|
|
28
|
+
{ name: 'app', char: 'a', description: 'app to unsuspend', hasValue: true, required: true },
|
|
29
|
+
{ name: 'category', char: 'c', description: 'unsuspension category', hasValue: true, required: false },
|
|
30
|
+
{ name: 'notes', char: 'n', description: 'unsuspend notes', hasValue: true, required: false }
|
|
22
31
|
],
|
|
23
32
|
run: command(run)
|
|
24
33
|
}
|
|
@@ -7,9 +7,14 @@ 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
|
+
let category = context.flags.category
|
|
11
|
+
let notes = context.flags.notes
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
if (!user) {
|
|
14
|
+
throw new Error('Required flag: --user USER')
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const response = await cli.action(`unsuspending ${cli.color.cyan(user)}`, skynet.unsuspendUser(user, category, notes))
|
|
13
18
|
cli.log(`${response.status}. ${response.message}`)
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -18,9 +23,11 @@ module.exports = {
|
|
|
18
23
|
command: 'unsuspend:user',
|
|
19
24
|
description: '(requires sudo) unsuspends a user',
|
|
20
25
|
help: `Examples:
|
|
21
|
-
$ heroku skynet:unsuspend:user -u foo@bar.com`,
|
|
26
|
+
$ heroku skynet:unsuspend:user -u foo@bar.com -n "helpful unsuspend message" -c "ddos"`,
|
|
22
27
|
flags: [
|
|
23
|
-
{ name: 'user', char: 'u', description: 'user to unsuspend', hasValue: true }
|
|
28
|
+
{ name: 'user', char: 'u', description: 'user to unsuspend', hasValue: true },
|
|
29
|
+
{ name: 'category', char: 'c', description: 'unsuspension category', hasValue: true, required: false },
|
|
30
|
+
{ name: 'notes', char: 'n', description: 'unsuspend notes', hasValue: true, required: false }
|
|
24
31
|
],
|
|
25
32
|
run: command(run)
|
|
26
33
|
}
|
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
|
-
|
|
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
|
|
|
@@ -106,9 +108,11 @@ module.exports = class SkynetAPI {
|
|
|
106
108
|
})
|
|
107
109
|
}
|
|
108
110
|
|
|
109
|
-
unsuspendApp (app) {
|
|
110
|
-
return this.request(`/suspensions/app/${app}`, {
|
|
111
|
-
method: 'DELETE'
|
|
111
|
+
unsuspendApp (app, category, notes) {
|
|
112
|
+
return this.request(`/suspensions/app/${app}?category=${category}&reason=${notes}`, {
|
|
113
|
+
method: 'DELETE',
|
|
114
|
+
body: {},
|
|
115
|
+
json: true
|
|
112
116
|
})
|
|
113
117
|
}
|
|
114
118
|
|
|
@@ -129,9 +133,11 @@ module.exports = class SkynetAPI {
|
|
|
129
133
|
})
|
|
130
134
|
}
|
|
131
135
|
|
|
132
|
-
unsuspendUser (user) {
|
|
133
|
-
return this.request(`/suspensions/user/${user}`, {
|
|
134
|
-
method: 'DELETE'
|
|
136
|
+
unsuspendUser (user, category, notes) {
|
|
137
|
+
return this.request(`/suspensions/user/${user}?category=${category}&reason=${notes}`, {
|
|
138
|
+
method: 'DELETE',
|
|
139
|
+
body: {},
|
|
140
|
+
json: true
|
|
135
141
|
})
|
|
136
142
|
}
|
|
137
143
|
|
|
@@ -186,7 +192,7 @@ module.exports = class SkynetAPI {
|
|
|
186
192
|
}
|
|
187
193
|
|
|
188
194
|
addCategory (category, description) {
|
|
189
|
-
|
|
195
|
+
const body = {
|
|
190
196
|
category: category,
|
|
191
197
|
description: description
|
|
192
198
|
}
|
|
@@ -200,7 +206,9 @@ module.exports = class SkynetAPI {
|
|
|
200
206
|
|
|
201
207
|
removeCategory (category) {
|
|
202
208
|
return this.request(`/categories/${category}`, {
|
|
203
|
-
method: 'DELETE'
|
|
209
|
+
method: 'DELETE',
|
|
210
|
+
body: {},
|
|
211
|
+
json: true
|
|
204
212
|
})
|
|
205
213
|
}
|
|
206
214
|
}
|