@heroku/skynet 1.4.3 → 1.6.1

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
@@ -14,63 +14,15 @@ heroku plugins:install heroku-skynet-cli
14
14
  - Link the plugin with `heroku plugins:link .`
15
15
 
16
16
  ### Publishing to `npm`
17
- 1. Contact `heroku-cli@salesforce.com` to get credentials to Heroku's private NPM registry
17
+ 1. Send an email to `heroku-help@salesforce.com` requesting access to @heroku on npm. Include your npm username (https://www.npmjs.com/)
18
18
 
19
- 2. Make sure you have `np` installed. Install by running `npm install np`
19
+ 1. Install by running `npm install np`
20
20
 
21
- 3. When you are ready to publish what you have locally, run `np` and you will see an output like this:
22
- ```
23
- λ bargenbright[heroku-skynet-cli/] (git:master)~$ np
24
-
25
- Publish a new version of heroku-skynet-cli (current: 1.3.5)
26
-
27
- ? Select semver increment or specify new version minor 1.4.0
28
-
29
- Commits:
30
- - Merge pull request #28 from heroku/refactor+appowner f2c5655
31
- - add app-owner command b07940b
32
- - adds app-owner command and refactors e914b09
21
+ 1. Publish the package:
33
22
 
34
- ? Will bump from 1.3.5 to 1.4.0. Continue? Yes
35
- Prerequisite check
36
- Git
37
- Cleanup
38
- Installing dependencies using Yarn
39
- Running tests
40
- ✔ Bumping version using Yarn
41
- ✖ Publishing package using Yarn
42
- → info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
43
- Pushing tags
44
-
45
- ✖ Error: Command failed: yarn publish --new-version 1.4.0
46
- warning package.json: No license field
47
- warning package.json: No license field
48
- error An unexpected error occurred: "No token found and can't prompt for login when running with --non-interactive.".
49
- ```
50
-
51
- 4. After you get the `np` error, run `npm publish` to finish pushing the new release.
52
- ```
53
- λ bargenbright[heroku-skynet-cli/] (git:master)~$ npm publish
54
- + heroku-skynet-cli@1.4.0
55
- ```
56
-
57
- 5. Then, push the tags to the git repository
58
- ```
59
- λ bargenbright[heroku-skynet-cli/] (git:master)~$ git push origin --tags
60
- Counting objects: 4, done.
61
- Delta compression using up to 8 threads.
62
- Compressing objects: 100% (4/4), done.
63
- Writing objects: 100% (4/4), 416 bytes | 416.00 KiB/s, done.
64
- Total 4 (delta 2), reused 0 (delta 0)
65
- remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
66
- To github.com:heroku/heroku-skynet-cli.git
67
- * [new tag] v1.4.0 -> v1.4.0
68
- ```
69
-
70
- 6. Finally, push the version change commit done by the `np` tool
71
- ```
72
- λ bargenbright[heroku-skynet-cli/] (git:master)~$ git push origin master
73
- Total 0 (delta 0), reused 0 (delta 0)
74
- To github.com:heroku/heroku-skynet-cli.git
75
- f2c5655..e8ad793 master -> master
76
- ```
23
+ 1. cd into the root of the plugin
24
+ 1. Run `np`
25
+ Note: You will get an error because np attempts to commit to master the
26
+ updated version in the package.json
27
+ Open a pr manually on a separate branch to resolve
28
+ 1. Merge the pr once approved
@@ -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
  }
@@ -6,9 +6,16 @@ let SkynetAPI = require('../../lib/skynet')
6
6
  function * run (context) {
7
7
  sudo()
8
8
  const skynet = new SkynetAPI(context.auth.password)
9
- let response = yield skynet.suspendApp(context.flags.app, context.flags.notes)
9
+ let response = yield skynet.suspendApp(
10
+ context.flags.app,
11
+ context.flags.notes,
12
+ context.flags.category,
13
+ context.flags.bypass
14
+ )
10
15
  response = JSON.parse(response)
11
- cli.log(`suspending...${cli.color.cyan(response.status)}.\n${response.message}`)
16
+ cli.log(
17
+ `suspending...${cli.color.cyan(response.status)}.\n${response.message}`
18
+ )
12
19
  }
13
20
 
14
21
  module.exports = {
@@ -16,10 +23,35 @@ module.exports = {
16
23
  command: 'suspend:app',
17
24
  description: '(requires sudo) suspends an app',
18
25
  help: `Examples:
19
- $ heroku skynet:suspend:app -a test-app -n "helpful suspend message"`,
26
+ $ heroku skynet:suspend:app -a test-app -c "category" -n "helpful suspend message"`,
20
27
  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}
28
+ {
29
+ name: 'app',
30
+ char: 'a',
31
+ description: 'app to suspend',
32
+ hasValue: true,
33
+ required: true
34
+ },
35
+ {
36
+ name: 'notes',
37
+ char: 'n',
38
+ description: 'suspend notes',
39
+ hasValue: true,
40
+ required: true
41
+ },
42
+ {
43
+ name: 'category',
44
+ char: 'c',
45
+ description: 'suspension category',
46
+ hasValue: true,
47
+ required: true
48
+ },
49
+ {
50
+ name: 'bypass',
51
+ description: 'force suspension',
52
+ hasValue: false,
53
+ required: false
54
+ }
23
55
  ],
24
56
  run: cli.command(co.wrap(run))
25
57
  }
@@ -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
 
@@ -61,12 +61,12 @@ module.exports = {
61
61
  help: `Examples:
62
62
  $ heroku sudo skynet:suspend:user -u foo@bar.com -n "helpful suspend message" -c "ddos"`,
63
63
  flags: [
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}
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 }
70
70
  ],
71
71
  run: cli.command(co.wrap(run))
72
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
@@ -1,6 +1,12 @@
1
1
  const cli = require('heroku-cli-util')
2
2
  const qs = require('querystring')
3
- const SKYNET_BASE_URL = 'https://skynet.herokai.com/api-h'
3
+ let skynetHost = 'https://skynet.herokai.com'
4
+
5
+ if (process.env.SKYNET_HOST) {
6
+ skynetHost = process.env.SKYNET_HOST
7
+ }
8
+
9
+ const SKYNET_BASE_URL = `${skynetHost}/api-h`
4
10
 
5
11
  module.exports = class SkynetAPI {
6
12
  constructor (token) {
@@ -21,7 +27,7 @@ module.exports = class SkynetAPI {
21
27
 
22
28
  options.json = false
23
29
 
24
- return cli.got(SKYNET_BASE_URL + url, options).then((res) => res.body)
30
+ return cli.got(SKYNET_BASE_URL + url, options).then(res => res.body)
25
31
  }
26
32
 
27
33
  categories () {
@@ -30,6 +36,24 @@ module.exports = class SkynetAPI {
30
36
  })
31
37
  }
32
38
 
39
+ addWhitelist (appOrUserEmail, notes) {
40
+ var body = {
41
+ value: appOrUserEmail,
42
+ notes: notes
43
+ }
44
+
45
+ return this.request(`/whitelist`, {
46
+ method: 'POST',
47
+ body: qs.stringify(body)
48
+ })
49
+ }
50
+
51
+ removeWhitelist (appOrUserEmail) {
52
+ return this.request(`/whitelist/${appOrUserEmail}`, {
53
+ method: 'DELETE'
54
+ })
55
+ }
56
+
33
57
  removeUserpass (user, flag) {
34
58
  var body = {
35
59
  user: user,
@@ -69,12 +93,13 @@ module.exports = class SkynetAPI {
69
93
  })
70
94
  }
71
95
 
72
- suspendApp (app, notes, category) {
96
+ suspendApp (app, notes, category, force = false) {
73
97
  var body = {
74
98
  value: app,
75
99
  reason: notes,
76
- method: 'skynet-cli',
77
- category: category
100
+ category: category,
101
+ force: force,
102
+ method: 'skynet-cli'
78
103
  }
79
104
 
80
105
  return this.request('/suspend/app', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/skynet",
3
- "version": "1.4.3",
3
+ "version": "1.6.1",
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": {