Skip to content

Commit

Permalink
Merge pull request #21 from heroku/amanmibra-open
Browse files Browse the repository at this point in the history
addons:admin:open
  • Loading branch information
amanmibra authored Aug 3, 2018
2 parents a59b827 + 588e0b9 commit bf33ac7
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ USAGE
* [`heroku addons:admin:manifest:generate`](#heroku-addonsadminmanifestgenerate)
* [`heroku addons:admin:manifest:pull [SLUG]`](#heroku-addonsadminmanifestpull-slug)
* [`heroku addons:admin:manifest:push`](#heroku-addonsadminmanifestpush)
* [`heroku addons:admin:open [SLUG]`](#heroku-addonsadminopen-slug)

## `heroku addons:admin:manifest:diff`

Expand Down Expand Up @@ -73,6 +74,9 @@ pull a manifest for a given slug
USAGE
$ heroku addons:admin:manifest:pull [SLUG]
ARGUMENTS
SLUG slug name of add-on
OPTIONS
-h, --help show CLI help
Expand Down Expand Up @@ -104,4 +108,23 @@ EXAMPLE
```

_See code: [src/commands/addons/admin/manifest/push.ts](https://github.com/heroku/heroku-cli-addons-admin/blob/v0.1.3/src/commands/addons/admin/manifest/push.ts)_

## `heroku addons:admin:open [SLUG]`

open add-on dashboard

```
USAGE
$ heroku addons:admin:open [SLUG]
ARGUMENTS
SLUG slug name of add-on
EXAMPLE
$ heroku addons:admin:open
Checking addon_manifest.json... done
Opening https://addons-next.heroku.com/addons/testing-123... done
```

_See code: [src/commands/addons/admin/open.ts](https://github.com/heroku/heroku-cli-addons-admin/blob/v0.1.3/src/commands/addons/admin/open.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion src/commands/addons/admin/manifest/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class Pull extends CommandExtension {
help: flags.help({char: 'h'}),
};

static args = [{name: 'slug'}];
static args = [{name: 'slug', description: 'slug name of add-on'}];

async run() {
const {args, flags} = this.parse(Pull);
Expand Down
45 changes: 45 additions & 0 deletions src/commands/addons/admin/open.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* tslint:disable */
// CommandExtension
import CommandExtension from '../../../CommandExtension';

// other packages
import cli from 'cli-ux';

// utilities
import { readManifest } from '../../../utils/manifest';

export default class Open extends CommandExtension {
static description = 'open add-on dashboard'

static args = [{name: 'slug', description: 'slug name of add-on'}];

static examples = [
`$ heroku addons:admin:open
Checking addon_manifest.json... done
Opening https://addons-next.heroku.com/addons/testing-123... done`, ];


async run() {
const {args} = this.parse(Open);

let slug: string;

// check if user gave slug argument
if (args.slug) {
slug = args.slug
} else {
// if not use slug specified in manifest
cli.action.start('Checking addon_manifest.json')
const manifest = await readManifest.apply(this)
cli.action.stop()

slug = JSON.parse(manifest).id;
}

const url = `https://addons-next.heroku.com/addons/${slug}`

cli.action.start(`Opening ${url}`)
cli.open(url)
cli.action.stop()
}
}
18 changes: 18 additions & 0 deletions test/commands/addons/admin/open.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* tslint:disable */
// import {expect, test} from '@oclif/test'
//
// describe('addons:admin:open', () => {
// test
// .stdout()
// .command(['addons:admin:open'])
// .it('runs hello', ctx => {
// expect(ctx.stdout).to.contain('hello world')
// })
//
// test
// .stdout()
// .command(['addons:admin:open', '--name', 'jeff'])
// .it('runs hello --name jeff', ctx => {
// expect(ctx.stdout).to.contain('hello jeff')
// })
// })

0 comments on commit bf33ac7

Please sign in to comment.