-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from heroku/amanmibra-open
addons:admin:open
- Loading branch information
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
// }) | ||
// }) |