@heroku/skynet 1.5.0 → 1.6.2

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
@@ -13,64 +13,37 @@ heroku plugins:install heroku-skynet-cli
13
13
  - Change directories into the cloned repository
14
14
  - Link the plugin with `heroku plugins:link .`
15
15
 
16
- ### Publishing to `npm`
17
- 1. Contact `heroku-cli@salesforce.com` to get credentials to Heroku's private NPM registry
18
-
19
- 2. Make sure you have `np` installed. Install by running `npm install np`
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
16
+ ### Manual testing
24
17
 
25
- Publish a new version of heroku-skynet-cli (current: 1.3.5)
18
+ 1. Make sure your staging account is setup: https://github.com/heroku/engineering-docs/blob/master/guides/staging-account-setup.md
19
+ 1. Get someone to add you to the `heroku-security` team/org in staging.
20
+ 1. Make sure you have the latest ion-client installed:
26
21
 
27
- ? Select semver increment or specify new version minor 1.4.0
22
+ ```
23
+ gem install ion-client
24
+ ```
28
25
 
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
26
+ If you get permissions errors against packagecloud, visit https://gemgate-heroku-internal-gems.herokuapp.com/setup-instructions
33
27
 
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
28
 
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
- ```
29
+ In skynet-cli directory, use the following:
50
30
 
51
- 4. After you get the `np` error, run `npm publish` to finish pushing the new release.
52
31
  ```
53
- λ bargenbright[heroku-skynet-cli/] (git:master)~$ npm publish
54
- + heroku-skynet-cli@1.4.0
32
+ heroku plugins:link .
33
+ export SKYNET_HOST=https://heroku-skynet-staging.herokuapp.com
34
+ cloud staging
35
+ heroku login # login to the staging cloud via the cli
36
+ heroku skynet:<cmd>
55
37
  ```
56
38
 
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
- ```
39
+ ### 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/)
69
41
 
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
- ```
42
+ 1. Publish the package:
43
+
44
+ 1. cd into the root of the plugin
45
+ 1. Run `npm run release`
46
+ Note: You will get an error because np attempts to commit to master the
47
+ updated version in the package.json
48
+ Open a pr manually on a separate branch to resolve
49
+ 1. Merge the pr once approved
@@ -1,12 +1,12 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../lib/command')
3
3
  let sudo = require('../lib/sudo')
4
4
  let SkynetAPI = require('../lib/skynet')
5
5
 
6
- function * run (context) {
6
+ async function run (context) {
7
7
  sudo()
8
8
  const skynet = new SkynetAPI(context.auth.password)
9
- let response = yield skynet.categories()
9
+ let response = await skynet.categories()
10
10
  response = JSON.parse(response)
11
11
  cli.table(response, {
12
12
  columns: [
@@ -23,5 +23,5 @@ module.exports = {
23
23
  help: `Examples:
24
24
  $ heroku skynet:categories`,
25
25
  flags: [],
26
- run: cli.command(co.wrap(run))
26
+ run: command(run)
27
27
  }
@@ -1,5 +1,5 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../lib/command')
3
3
  let sudo = require('../lib/sudo')
4
4
  let SkynetAPI = require('../lib/skynet')
5
5
 
@@ -26,7 +26,7 @@ function readlines (file) {
26
26
  })
27
27
  }
28
28
 
29
- function * run (context) {
29
+ async function run (context) {
30
30
  sudo()
31
31
  const skynet = new SkynetAPI(context.auth.password)
32
32
  let user = context.flags.user || process.env.HEROKU_USER
@@ -40,14 +40,14 @@ function * run (context) {
40
40
  }
41
41
 
42
42
  if (file) {
43
- let users = yield readlines(file)
44
- yield cli.action(`bulk deprovisioning for ${cli.color.cyan(users.length)} users`, skynet.bulkDeprovision(users.join(), notes, category))
43
+ let users = await readlines(file)
44
+ await cli.action(`bulk deprovisioning for ${cli.color.cyan(users.length)} users`, skynet.bulkDeprovision(users.join(), notes, category))
45
45
  } else {
46
46
  if (!user) {
47
47
  throw new Error('Required flag: --user USER or --infile FILE')
48
48
  }
49
49
 
50
- let response = yield cli.action(`deprovisioning ${cli.color.cyan(user)}`, skynet.deprovision(user, notes, category, force))
50
+ let response = await cli.action(`deprovisioning ${cli.color.cyan(user)}`, skynet.deprovision(user, notes, category, force))
51
51
  response = JSON.parse(response)
52
52
  cli.log(`${response.status}. ${response.message}`)
53
53
  }
@@ -66,5 +66,5 @@ module.exports = {
66
66
  { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
67
67
  { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false }
68
68
  ],
69
- run: cli.command(co.wrap(run))
69
+ run: command(run)
70
70
  }
@@ -1,5 +1,5 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let sudo = require('../../lib/sudo')
4
4
  let SkynetAPI = require('../../lib/skynet')
5
5
 
@@ -26,7 +26,7 @@ function readlines (file) {
26
26
  })
27
27
  }
28
28
 
29
- function * run (context) {
29
+ async function run (context) {
30
30
  sudo()
31
31
  const skynet = new SkynetAPI(context.auth.password)
32
32
  let app = context.flags.app
@@ -40,14 +40,14 @@ function * run (context) {
40
40
  }
41
41
 
42
42
  if (file) {
43
- let apps = yield readlines(file)
44
- yield cli.action(`bulk app-owner suspension for ${cli.color.cyan(apps.length)} apps.`, skynet.bulkSuspendAppOwner(apps.join(), notes, category))
43
+ let apps = await readlines(file)
44
+ await cli.action(`bulk app-owner suspension for ${cli.color.cyan(apps.length)} apps.`, skynet.bulkSuspendAppOwner(apps.join(), notes, category))
45
45
  } else {
46
46
  if (!app) {
47
47
  throw new Error('Required flag: --owner OWNER or --infile FILE')
48
48
  }
49
49
 
50
- let response = yield cli.action(`suspending the owner of ${cli.color.cyan(app)}`, skynet.suspendAppOwner(app, notes, category, force))
50
+ let response = await cli.action(`suspending the owner of ${cli.color.cyan(app)}`, skynet.suspendAppOwner(app, notes, category, force))
51
51
  response = JSON.parse(response)
52
52
  cli.log(`${response.status}. ${response.message}`)
53
53
  }
@@ -66,5 +66,5 @@ module.exports = {
66
66
  { name: 'notes', char: 'n', description: 'suspend notes', hasValue: true, required: true },
67
67
  { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false }
68
68
  ],
69
- run: cli.command(co.wrap(run))
69
+ run: command(run)
70
70
  }
@@ -1,14 +1,21 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let sudo = require('../../lib/sudo')
4
4
  let SkynetAPI = require('../../lib/skynet')
5
5
 
6
- function * run (context) {
6
+ async 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 = await 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
- run: cli.command(co.wrap(run))
56
+ run: command(run)
25
57
  }
@@ -1,5 +1,5 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let sudo = require('../../lib/sudo')
4
4
  let SkynetAPI = require('../../lib/skynet')
5
5
 
@@ -26,7 +26,7 @@ function readlines (file) {
26
26
  })
27
27
  }
28
28
 
29
- function * run (context) {
29
+ async function run (context) {
30
30
  sudo()
31
31
  const skynet = new SkynetAPI(context.auth.password)
32
32
  let user = context.flags.user || process.env.HEROKU_USER
@@ -41,14 +41,14 @@ function * run (context) {
41
41
  }
42
42
 
43
43
  if (file) {
44
- let users = yield readlines(file)
45
- yield cli.action(`bulk user suspension for ${cli.color.cyan(users.length)} users.`, skynet.bulkSuspendUsers(users.join(), notes, category))
44
+ let users = await readlines(file)
45
+ await cli.action(`bulk user suspension for ${cli.color.cyan(users.length)} users.`, skynet.bulkSuspendUsers(users.join(), notes, category))
46
46
  } else {
47
47
  if (!user) {
48
48
  throw new Error('Required flag: --user USER or --infile FILE')
49
49
  }
50
50
 
51
- let response = yield cli.action(`suspending ${cli.color.cyan(user)}`, skynet.suspendUser(user, notes, category, notify, force))
51
+ let response = await cli.action(`suspending ${cli.color.cyan(user)}`, skynet.suspendUser(user, notes, category, notify, force))
52
52
  response = JSON.parse(response)
53
53
  cli.log(`${response.status}. ${response.message}`)
54
54
  }
@@ -68,5 +68,5 @@ module.exports = {
68
68
  { name: 'bypass', description: 'bypass the whitelist', hasValue: false, required: false },
69
69
  { name: 'no-notify', description: 'skip user suspension email notification', hasValue: false, required: false }
70
70
  ],
71
- run: cli.command(co.wrap(run))
71
+ run: command(run)
72
72
  }
@@ -1,12 +1,12 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let sudo = require('../../lib/sudo')
4
4
  let SkynetAPI = require('../../lib/skynet')
5
5
 
6
- function * run (context) {
6
+ async function run (context) {
7
7
  sudo()
8
8
  const skynet = new SkynetAPI(context.auth.password)
9
- let response = yield skynet.unsuspendApp(context.flags.app, context.flags.notes)
9
+ let response = await skynet.unsuspendApp(context.flags.app, context.flags.notes)
10
10
  response = JSON.parse(response)
11
11
  cli.log(`suspending...${cli.color.cyan(response.status)}.\n${response.message}`)
12
12
  }
@@ -20,5 +20,5 @@ module.exports = {
20
20
  flags: [
21
21
  { name: 'app', char: 'a', description: 'app to unsuspend', hasValue: true, required: true }
22
22
  ],
23
- run: cli.command(co.wrap(run))
23
+ run: command(run)
24
24
  }
@@ -1,14 +1,14 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let sudo = require('../../lib/sudo')
4
4
  let SkynetAPI = require('../../lib/skynet')
5
5
 
6
- function * run (context) {
6
+ 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
10
 
11
- let response = yield cli.action(`unsuspending ${cli.color.cyan(user)}`, skynet.unsuspendUser(user))
11
+ let response = await cli.action(`unsuspending ${cli.color.cyan(user)}`, skynet.unsuspendUser(user))
12
12
  response = JSON.parse(response)
13
13
  cli.log(`${response.status}. ${response.message}`)
14
14
  }
@@ -22,5 +22,5 @@ module.exports = {
22
22
  flags: [
23
23
  { name: 'user', char: 'u', description: 'user to unsuspend', hasValue: true }
24
24
  ],
25
- run: cli.command(co.wrap(run))
25
+ run: command(run)
26
26
  }
@@ -1,10 +1,10 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let SkynetAPI = require('../../lib/skynet')
4
4
 
5
- function * run (context) {
5
+ async function run (context) {
6
6
  const skynet = new SkynetAPI(context.auth.password)
7
- yield cli.action(`adding ${cli.color.cyan(context.flags.userpass)} to ${cli.color.cyan(context.flags.user)}`, skynet.addUserpass(context.flags.user, context.flags.flag))
7
+ await cli.action(`adding ${cli.color.cyan(context.flags.userpass)} to ${cli.color.cyan(context.flags.user)}`, skynet.addUserpass(context.flags.user, context.flags.flag))
8
8
  }
9
9
 
10
10
  module.exports = {
@@ -17,5 +17,5 @@ module.exports = {
17
17
  { name: 'user', char: 'u', description: 'user to apply userpass flag to', hasValue: true, required: true },
18
18
  { name: 'flag', char: 'f', description: 'flag to add to the given user', hasValue: true, required: true }
19
19
  ],
20
- run: cli.command(co.wrap(run))
20
+ run: command(run)
21
21
  }
@@ -1,10 +1,10 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let SkynetAPI = require('../../lib/skynet')
4
4
 
5
- function * run (context) {
5
+ async function run (context) {
6
6
  const skynet = new SkynetAPI(context.auth.password)
7
- yield cli.action(`removing ${cli.color.cyan(context.flags.userpass)} from ${cli.color.cyan(context.flags.user)}`, skynet.removeUserpass(context.flags.user, context.flags.flag))
7
+ await cli.action(`removing ${cli.color.cyan(context.flags.userpass)} from ${cli.color.cyan(context.flags.user)}`, skynet.removeUserpass(context.flags.user, context.flags.flag))
8
8
  }
9
9
 
10
10
  module.exports = {
@@ -17,5 +17,5 @@ module.exports = {
17
17
  { name: 'user', char: 'u', description: 'user to remove user_pass from', hasValue: true, required: true },
18
18
  { name: 'flag', char: 'f', description: 'flag to remove from given user', hasValue: true, required: true }
19
19
  ],
20
- run: cli.command(co.wrap(run))
20
+ run: command(run)
21
21
  }
@@ -1,10 +1,10 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let SkynetAPI = require('../../lib/skynet')
4
4
 
5
- function * run (context) {
5
+ async function run (context) {
6
6
  const skynet = new SkynetAPI(context.auth.password)
7
- yield cli.action(
7
+ await cli.action(
8
8
  `adding ${cli.color.cyan(
9
9
  context.flags.value
10
10
  )} to whitelist with ${cli.color.cyan(context.flags.notes)}`,
@@ -34,5 +34,5 @@ module.exports = {
34
34
  required: false
35
35
  }
36
36
  ],
37
- run: cli.command(co.wrap(run))
37
+ run: command(run)
38
38
  }
@@ -1,10 +1,10 @@
1
1
  let cli = require('heroku-cli-util')
2
- let co = require('co')
2
+ let command = require('../../lib/command')
3
3
  let SkynetAPI = require('../../lib/skynet')
4
4
 
5
- function * run (context) {
5
+ async function run (context) {
6
6
  const skynet = new SkynetAPI(context.auth.password)
7
- yield cli.action(
7
+ await cli.action(
8
8
  `removing ${cli.color.cyan(context.flags.value)} from whitelist`,
9
9
  skynet.removeWhitelist(context.flags.value)
10
10
  )
@@ -25,5 +25,5 @@ module.exports = {
25
25
  required: true
26
26
  }
27
27
  ],
28
- run: cli.command(co.wrap(run))
28
+ run: command(run)
29
29
  }
package/lib/command.js ADDED
@@ -0,0 +1,13 @@
1
+ let cli = require('heroku-cli-util')
2
+
3
+ module.exports = fn =>
4
+ cli.command((context, client) =>
5
+ fn(context, client).catch(err => {
6
+ if (err.body) {
7
+ console.log(JSON.stringify(err.body))
8
+ } else {
9
+ console.log(err)
10
+ }
11
+ throw err
12
+ })
13
+ )
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) {
@@ -87,12 +93,13 @@ module.exports = class SkynetAPI {
87
93
  })
88
94
  }
89
95
 
90
- suspendApp (app, notes, category) {
96
+ suspendApp (app, notes, category, force = false) {
91
97
  var body = {
92
98
  value: app,
93
99
  reason: notes,
94
- method: 'skynet-cli',
95
- category: category
100
+ category: category,
101
+ force: force,
102
+ method: 'skynet-cli'
96
103
  }
97
104
 
98
105
  return this.request('/suspend/app', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroku/skynet",
3
- "version": "1.5.0",
3
+ "version": "1.6.2",
4
4
  "description": "use Skynet from Heroku CLI",
5
5
  "main": "index.js",
6
6
  "author": "Bob Argenbright @byt3smith",
@@ -17,18 +17,19 @@
17
17
  "/commands"
18
18
  ],
19
19
  "dependencies": {
20
- "co": "^4.6.0",
21
20
  "heroku-cli-util": "~6.2.12",
22
21
  "split": "^1.0.0"
23
22
  },
24
23
  "devDependencies": {
25
24
  "mocha": "^3.4.2",
26
25
  "mockdate": "^2.0.1",
27
- "nock": "^9.0.13",
26
+ "nock": "~9.0.13",
27
+ "np": "^3.1.0",
28
28
  "standard": "^12.0.1",
29
29
  "unexpected": "^10.29.0"
30
30
  },
31
31
  "scripts": {
32
- "test": "mocha && standard"
32
+ "test": "mocha && standard",
33
+ "release": "np --no-yarn"
33
34
  }
34
35
  }