From 927b1fbb0a5dbe64adf15b7b577ee3517fb342fa Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 12:50:52 -0700 Subject: [PATCH 1/7] ts linted and removed default generated test files --- src/commands/addons/admin.ts | 1 + src/commands/addons/admin/manifest.ts | 1 + test/commands/addons/admin.test.ts | 35 +++++++++++---------- test/commands/addons/admin/manifest.test.ts | 35 +++++++++++---------- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/commands/addons/admin.ts b/src/commands/addons/admin.ts index 9b8c397..c8da19e 100644 --- a/src/commands/addons/admin.ts +++ b/src/commands/addons/admin.ts @@ -1,3 +1,4 @@ +/* tslint:disable */ import {Command, flags} from '@oclif/command' export default class AddonsAdmin extends Command { diff --git a/src/commands/addons/admin/manifest.ts b/src/commands/addons/admin/manifest.ts index e5052b5..439aa7f 100644 --- a/src/commands/addons/admin/manifest.ts +++ b/src/commands/addons/admin/manifest.ts @@ -1,3 +1,4 @@ +/* tslint:disable */ import {Command, flags} from '@oclif/command' export default class AddonsAdminManifest extends Command { diff --git a/test/commands/addons/admin.test.ts b/test/commands/addons/admin.test.ts index 5ee8ada..059e98a 100644 --- a/test/commands/addons/admin.test.ts +++ b/test/commands/addons/admin.test.ts @@ -1,17 +1,18 @@ -import {expect, test} from '@oclif/test' - -describe('addons:admin', () => { - test - .stdout() - .command(['addons:admin']) - .it('runs hello', ctx => { - expect(ctx.stdout).to.contain('hello world') - }) - - test - .stdout() - .command(['addons:admin', '--name', 'jeff']) - .it('runs hello --name jeff', ctx => { - expect(ctx.stdout).to.contain('hello jeff') - }) -}) +/* tslint:disable */ +// import {expect, test} from '@oclif/test' +// +// describe('addons:admin', () => { +// test +// .stdout() +// .command(['addons:admin']) +// .it('runs hello', ctx => { +// expect(ctx.stdout).to.contain('hello world') +// }) +// +// test +// .stdout() +// .command(['addons:admin', '--name', 'jeff']) +// .it('runs hello --name jeff', ctx => { +// expect(ctx.stdout).to.contain('hello jeff') +// }) +// }) diff --git a/test/commands/addons/admin/manifest.test.ts b/test/commands/addons/admin/manifest.test.ts index 9d09d5d..05eb049 100644 --- a/test/commands/addons/admin/manifest.test.ts +++ b/test/commands/addons/admin/manifest.test.ts @@ -1,17 +1,18 @@ -import {expect, test} from '@oclif/test' - -describe('addons:admin:manifest', () => { - test - .stdout() - .command(['addons:admin:manifest']) - .it('runs hello', ctx => { - expect(ctx.stdout).to.contain('hello world') - }) - - test - .stdout() - .command(['addons:admin:manifest', '--name', 'jeff']) - .it('runs hello --name jeff', ctx => { - expect(ctx.stdout).to.contain('hello jeff') - }) -}) +/* tslint:disable */ +// import {expect, test} from '@oclif/test' +// +// describe('addons:admin:manifest', () => { +// test +// .stdout() +// .command(['addons:admin:manifest']) +// .it('runs hello', ctx => { +// expect(ctx.stdout).to.contain('hello world') +// }) +// +// test +// .stdout() +// .command(['addons:admin:manifest', '--name', 'jeff']) +// .it('runs hello --name jeff', ctx => { +// expect(ctx.stdout).to.contain('hello jeff') +// }) +// }) From 4962e26e642b29c99d5959ecf6cc295565ca9a1e Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 12:55:33 -0700 Subject: [PATCH 2/7] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5ee489d..4e4bdf9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ Heroku CLI plugin to help Heroku add-on providers integrate their services with # Usage ```sh-session -$ npm install -g @heroku-cli/plugin-addons-admin $ heroku COMMAND running command... $ heroku (-v|--version|version) From 1de16a230775d150ee9d54d3fafde80ac0983328 Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 14:54:40 -0700 Subject: [PATCH 3/7] Created open command --- src/commands/addons/admin/open.ts | 22 ++++++++++++++++++++++ test/commands/addons/admin/open.test.ts | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/commands/addons/admin/open.ts create mode 100644 test/commands/addons/admin/open.test.ts diff --git a/src/commands/addons/admin/open.ts b/src/commands/addons/admin/open.ts new file mode 100644 index 0000000..3308170 --- /dev/null +++ b/src/commands/addons/admin/open.ts @@ -0,0 +1,22 @@ +/* tslint:disable */ +// CommandExtension +import CommandExtension from '../../../CommandExtension'; + +// other packages +import cli from 'cli-ux'; + +// utilities +import { readManifest } from '../../../utils/manifest'; + +export default class AddonsAdminOpen extends CommandExtension { + static description = 'open add-on dashboard' + + async run() { + cli.action.start('Checking addon_manifest.json') + const manifest = readManifest.apply(this) + cli.action.stop() + + const slug: string = JSON.parse(manifest).id; + cli.open(`https://addons-next.heroku.com/addons/${slug}`) + } +} diff --git a/test/commands/addons/admin/open.test.ts b/test/commands/addons/admin/open.test.ts new file mode 100644 index 0000000..cae477c --- /dev/null +++ b/test/commands/addons/admin/open.test.ts @@ -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') +// }) +// }) From d5a6bb6568545f82b14005f866d34b4fcb6c1290 Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 15:05:26 -0700 Subject: [PATCH 4/7] Add option to specifiy slug dashboard to open --- src/commands/addons/admin/manifest/pull.ts | 2 +- src/commands/addons/admin/open.ts | 24 +++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/commands/addons/admin/manifest/pull.ts b/src/commands/addons/admin/manifest/pull.ts index 829a54f..44d13ec 100644 --- a/src/commands/addons/admin/manifest/pull.ts +++ b/src/commands/addons/admin/manifest/pull.ts @@ -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); diff --git a/src/commands/addons/admin/open.ts b/src/commands/addons/admin/open.ts index 3308170..5bd64ea 100644 --- a/src/commands/addons/admin/open.ts +++ b/src/commands/addons/admin/open.ts @@ -8,15 +8,29 @@ import cli from 'cli-ux'; // utilities import { readManifest } from '../../../utils/manifest'; -export default class AddonsAdminOpen extends CommandExtension { +export default class Open extends CommandExtension { static description = 'open add-on dashboard' + static args = [{name: 'slug', description: 'slug name of add-on'}]; + + async run() { - cli.action.start('Checking addon_manifest.json') - const manifest = readManifest.apply(this) - cli.action.stop() + 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 = readManifest.apply(this) + cli.action.stop() + + slug = JSON.parse(manifest).id; + } - const slug: string = JSON.parse(manifest).id; cli.open(`https://addons-next.heroku.com/addons/${slug}`) } } From 52fb9f25e0ad24b706bb5f413e8907da237b3a61 Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 15:06:04 -0700 Subject: [PATCH 5/7] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 5ee489d..5806094 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,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` @@ -74,6 +75,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 @@ -105,4 +109,18 @@ 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 +``` + +_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)_ From 9ae7aa97ef1ab3344e02cd217fdd2f92e04e2433 Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 15:31:12 -0700 Subject: [PATCH 6/7] Print url while opening --- src/commands/addons/admin/open.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/addons/admin/open.ts b/src/commands/addons/admin/open.ts index 5bd64ea..09e325b 100644 --- a/src/commands/addons/admin/open.ts +++ b/src/commands/addons/admin/open.ts @@ -13,6 +13,11 @@ export default class Open extends CommandExtension { 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); @@ -25,12 +30,16 @@ export default class Open extends CommandExtension { } else { // if not use slug specified in manifest cli.action.start('Checking addon_manifest.json') - const manifest = readManifest.apply(this) + const manifest = await readManifest.apply(this) cli.action.stop() slug = JSON.parse(manifest).id; } - cli.open(`https://addons-next.heroku.com/addons/${slug}`) + const url = `https://addons-next.heroku.com/addons/${slug}` + + cli.action.start(`Opening ${url}`) + cli.open(url) + cli.action.stop() } } From 3c03b518bc00a64ebef154fd335b3abf257934fc Mon Sep 17 00:00:00 2001 From: Aman Ibrahim Date: Fri, 3 Aug 2018 15:33:46 -0700 Subject: [PATCH 7/7] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5806094..f3d3880 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,11 @@ USAGE 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)_