Skip to content

Commit

Permalink
refactor(certs-v5): move certs:auto:refresh to CLI & upgrade to oclif (
Browse files Browse the repository at this point in the history
…#2668)

* Convert acm refresh command to oclif

* Fix spacing lint issue

* Remove v5 versions of certs auto refresh
  • Loading branch information
eablack committed Mar 6, 2024
1 parent 0159039 commit 058c586
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 48 deletions.
21 changes: 0 additions & 21 deletions packages/certs-v5/commands/certs/auto/refresh.js

This file was deleted.

This file was deleted.

21 changes: 21 additions & 0 deletions packages/cli/src/commands/certs/auto/refresh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {Command, flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'

export default class Refresh extends Command {
static topic = 'certs';
static description = 'refresh ACM for an app';
static flags = {
app: flags.app({required: true}),
};

public async run(): Promise<void> {
const {flags} = await this.parse(Refresh)

ux.action.start('Refreshing Automatic Certificate Management')
await this.heroku.patch(`/apps/${flags.app}/acm`, {
headers: {Accept: 'application/vnd.heroku+json; version=3.cedar-acm'},
body: {acm_refresh: true},
})
ux.action.stop()
}
}
29 changes: 29 additions & 0 deletions packages/cli/test/unit/commands/certs/auto/refresh.unit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {stdout, stderr} from 'stdout-stderr'
import Cmd from '../../../../../src/commands/certs/auto/refresh'
import runCommand from '../../../../helpers/runCommand'
import expectOutput from '../../../../helpers/utils/expectOutput'
import heredoc from 'tsheredoc'
import * as nock from 'nock'

describe('heroku certs:auto:enable', function () {
beforeEach(function () {
nock.cleanAll()
})

it('refreshes acm', async function () {
nock('https://api.heroku.com', {
reqheaders: {Accept: 'application/vnd.heroku+json; version=3.cedar-acm'},
})
.patch('/apps/example/acm', {acm_refresh: true})
.reply(200, {acm: true, acm_refresh: true})
await runCommand(Cmd, [
'--app',
'example',
])
expectOutput(stderr.output, heredoc(`
Refreshing Automatic Certificate Management...
Refreshing Automatic Certificate Management... done
`))
expectOutput((stdout.output), '')
})
})

0 comments on commit 058c586

Please sign in to comment.