Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge updates from main #2818

Merged
merged 8 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/auth.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
`heroku auth`
=============

check 2fa status
manage authentication for your Heroku account

* [`heroku auth:2fa`](#heroku-auth2fa)
* [`heroku auth:2fa:disable`](#heroku-auth2fadisable)
Expand Down
2 changes: 1 addition & 1 deletion packages/certs-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/certs-v5/<%- commandPath %>"
},
"dependencies": {
"@heroku-cli/color": "^1.1.14",
"@heroku-cli/color": "^2.0.1",
"@heroku-cli/notifications": "^1.2.4",
"date-fns": "^1.29.0",
"heroku-cli-util": "^8.0.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bin": "./bin/run",
"bugs": "https://github.com/heroku/cli/issues",
"dependencies": {
"@heroku-cli/color": "1.1.14",
"@heroku-cli/color": "2.0.1",
"@heroku-cli/command": "^10.0.0",
"@heroku-cli/command-v9": "npm:@heroku-cli/command@^9.0.2",
"@heroku-cli/notifications": "^1.2.4",
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/commands/authorizations/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class AuthorizationsCreate extends Command {

ux.action.start('Creating OAuth Authorization')

const {body: auth} = await this.heroku.post<Heroku.OAuthAuthorization>('/oauth/authorizations', {
const {body: auth, headers} = await this.heroku.post<Heroku.OAuthAuthorization>('/oauth/authorizations', {
body: {
description: flags.description,
scope: flags.scope ? flags.scope.split(',') : undefined,
Expand All @@ -35,6 +35,12 @@ export default class AuthorizationsCreate extends Command {

ux.action.stop()

const apiWarnings = headers['warning-message'] as string || ''

if (apiWarnings) {
ux.warn(apiWarnings)
}

if (flags.short) {
ux.log(auth.access_token && auth.access_token.token)
} else if (flags.json) {
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/commands/authorizations/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ export default class AuthorizationsInfo extends Command {
async run() {
const {args, flags} = await this.parse(AuthorizationsInfo)

const {body: authentication} = await this.heroku.get<Heroku.OAuthClient>(
const {body: authentication, headers} = await this.heroku.get<Heroku.OAuthAuthorization>(
`/oauth/authorizations/${args.id}`,
)

const apiWarnings = headers['warning-message'] as string || ''

if (apiWarnings) {
ux.warn(apiWarnings)
}

if (flags.json) {
ux.styledJSON(authentication)
} else {
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/commands/authorizations/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ export default class AuthorizationsRevoke extends Command {

ux.action.start('Revoking OAuth Authorization')

const {body: auth} = await this.heroku.delete<Heroku.OAuthAuthorization>(
const {body: auth, headers} = await this.heroku.delete<Heroku.OAuthAuthorization>(
`/oauth/authorizations/${encodeURIComponent(args.id)}`,
)

const apiWarnings = headers['warning-message'] as string || ''

if (apiWarnings) {
ux.warn(apiWarnings)
}

ux.action.stop(`done, revoked authorization from ${color.cyan(auth.description)}`)
}
}
8 changes: 7 additions & 1 deletion packages/cli/src/commands/authorizations/rotate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ export default class AuthorizationsRotate extends Command {

ux.action.start('Rotating OAuth Authorization')

const {body: authorization} = await this.heroku.post<Heroku.OAuthAuthorization>(
const {body: authorization, headers} = await this.heroku.post<Heroku.OAuthAuthorization>(
`/oauth/authorizations/${encodeURIComponent(args.id)}/actions/regenerate-tokens`,
)

const apiWarnings = headers['warning-message'] as string || ''

if (apiWarnings) {
ux.warn(apiWarnings)
}

ux.action.stop()

display(authorization)
Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/commands/authorizations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class AuthorizationsUpdate extends Command {
}
}

const {body: authentication} = await this.heroku.patch<Heroku.OAuthAuthorization>(
const {body: authentication, headers} = await this.heroku.patch<Heroku.OAuthAuthorization>(
`/oauth/authorizations/${args.id}`,
{
body: {
Expand All @@ -40,6 +40,12 @@ export default class AuthorizationsUpdate extends Command {
},
)

const apiWarnings = headers['warning-message'] as string || ''

if (apiWarnings) {
ux.warn(apiWarnings)
}

ux.action.stop()

display(authentication)
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/global_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {version} = require('../package.json')

const root = path.resolve(__dirname, '../package.json')
const isDev = process.env.IS_DEV_ENVIRONMENT === 'true'
const isTelemetryDisabled = process.env.DISABLE_TELEMETRY === 'true'

function getToken() {
const config = new Config({root})
Expand Down Expand Up @@ -152,6 +153,10 @@ export function reportCmdNotFound(config: any) {

export async function sendTelemetry(currentTelemetry: any, rollbarCb?: () => void) {
// send telemetry to honeycomb and rollbar
if (isTelemetryDisabled) {
return
}

const telemetry = currentTelemetry

if (telemetry instanceof Error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as nock from 'nock'
import {AddOn} from '@heroku-cli/schema'
import {expect} from 'chai'
import * as chalk from 'chalk'
import stripAnsi = require('strip-ansi')

describe('addons:upgrade', () => {
let api: ReturnType<typeof nock>
Expand Down Expand Up @@ -178,7 +179,7 @@ describe('addons:upgrade', () => {
])
} catch (error) {
if (error instanceof Error) {
expect(error.message).to.equal('Couldn\'t find either the add-on service or the add-on plan of "heroku-db1:invalid".\n\nHere are the available plans for heroku-db1:\nheroku-db1:free\nheroku-db1:basic\nheroku-db1:premium-0\n\nSee more plan information with heroku addons:plans heroku-db1\n\nhttps://devcenter.heroku.com/articles/managing-add-ons')
expect(stripAnsi(error.message)).to.equal('Couldn\'t find either the add-on service or the add-on plan of "heroku-db1:invalid".\n\nHere are the available plans for heroku-db1:\nheroku-db1:free\nheroku-db1:basic\nheroku-db1:premium-0\n\nSee more plan information with heroku addons:plans heroku-db1\n\nhttps://devcenter.heroku.com/articles/managing-add-ons')
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,19 @@ describe('authorizations:create', () => {
expect(json.scope).to.contain('global')
})
})

context('API warning headers', () => {
test
.stderr()
.stdout()
.nock('https://api.heroku.com:443', api => {
api
.post('/oauth/authorizations', {description: 'awesome'})
.reply(201, {scope: ['global'], access_token: {token: 'secrettoken'}}, {'warning-message': 'this is an API warning message example'})
})
.command(['authorizations:create', '--description', 'awesome'])
.it('outputs API warning message', ctx => {
expect(ctx.stderr).contains('this is an API warning message example')
})
})
})
2 changes: 1 addition & 1 deletion packages/run-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/run-v5/<%- commandPath %>"
},
"dependencies": {
"@heroku-cli/color": "^1.1.14",
"@heroku-cli/color": "^2.0.1",
"@heroku-cli/command": "^9.0.2",
"@heroku-cli/notifications": "^1.2.4",
"@heroku/eventsource": "^1.0.7",
Expand Down
29 changes: 25 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,19 @@ __metadata:
languageName: node
linkType: hard

"@heroku-cli/color@npm:1.1.14, @heroku-cli/color@npm:^1.1.14, @heroku-cli/color@npm:^1.1.3":
"@heroku-cli/color@npm:2.0.1, @heroku-cli/color@npm:^2.0.1":
version: 2.0.1
resolution: "@heroku-cli/color@npm:2.0.1"
dependencies:
ansi-styles: ^4.3.0
chalk: ^4.1.2
supports-color: ^7.2.0
tslib: ^1.9.3
checksum: 3f2591fab0d28a88592b78b8b6e171cafd927e8b6ea1b807878ad3a9b46636c07e63d6983b64b94ec47f05a5a9fe2db80f95d5f381e4b6c14dac48c4aab7ba93
languageName: node
linkType: hard

"@heroku-cli/color@npm:^1.1.14, @heroku-cli/color@npm:^1.1.3":
version: 1.1.14
resolution: "@heroku-cli/color@npm:1.1.14"
dependencies:
Expand Down Expand Up @@ -1261,7 +1273,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@heroku-cli/plugin-certs-v5@workspace:packages/certs-v5"
dependencies:
"@heroku-cli/color": ^1.1.14
"@heroku-cli/color": ^2.0.1
"@heroku-cli/notifications": ^1.2.4
"@oclif/plugin-legacy": ^1.3.0
chai: ^4.2.0
Expand Down Expand Up @@ -1383,7 +1395,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@heroku-cli/plugin-run-v5@workspace:packages/run-v5"
dependencies:
"@heroku-cli/color": ^1.1.14
"@heroku-cli/color": ^2.0.1
"@heroku-cli/command": ^9.0.2
"@heroku-cli/notifications": ^1.2.4
"@heroku/eventsource": ^1.0.7
Expand Down Expand Up @@ -10915,7 +10927,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "heroku@workspace:packages/cli"
dependencies:
"@heroku-cli/color": 1.1.14
"@heroku-cli/color": 2.0.1
"@heroku-cli/command": ^10.0.0
"@heroku-cli/command-v9": "npm:@heroku-cli/command@^9.0.2"
"@heroku-cli/notifications": ^1.2.4
Expand Down Expand Up @@ -17874,6 +17886,15 @@ __metadata:
languageName: node
linkType: hard

"supports-color@npm:^7.2.0":
version: 7.2.0
resolution: "supports-color@npm:7.2.0"
dependencies:
has-flag: ^4.0.0
checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a
languageName: node
linkType: hard

"supports-hyperlinks@npm:^1.0.1":
version: 1.0.1
resolution: "supports-hyperlinks@npm:1.0.1"
Expand Down
Loading