Skip to content

Commit 6927b32

Browse files
refactor: migrate pg utils to esm (#3445)
* removing migrated functions to heroku-cli-util while converting remaining to esm and adding testing coverage * removing migrated functions to heroku-cli-util while converting remaining to esm and adding testing coverage
1 parent cd36e10 commit 6927b32

File tree

3 files changed

+152
-41
lines changed

3 files changed

+152
-41
lines changed

package-lock.json

Lines changed: 35 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/src/lib/pg/util.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
/*
2-
import color from '@heroku-cli/color'
1+
import {color} from '@heroku-cli/color'
32
import type {AddOnAttachment} from '@heroku-cli/schema'
4-
import {ux} from '@oclif/core'
5-
import type {ExtendedAddonAttachment} from '@heroku/heroku-cli-util'
6-
import {renderAttachment} from '../../commands/addons'
7-
import {multiSortCompareFn} from '../utils/multisort'
8-
import type {CredentialsInfo} from './types'
3+
import {hux} from '@heroku/heroku-cli-util'
4+
import {renderAttachment} from '../../commands/addons/index.js'
5+
import {multiSortCompareFn} from '../utils/multisort.js'
6+
import type {CredentialsInfo} from './types.js'
97
import {utils} from '@heroku/heroku-cli-util'
10-
import type {ExtendedAddon} from './types'
11-
12-
export const essentialNumPlan = (addon: ExtendedAddonAttachment['addon'] | ExtendedAddon) => Boolean(addon?.plan?.name?.split(':')[1].match(/^essential/))
13-
export const legacyEssentialPlan = (addon: ExtendedAddonAttachment['addon'] | ExtendedAddon) => Boolean(addon?.plan?.name?.split(':')[1].match(/(dev|basic|mini)$/))
14-
15-
export function essentialPlan(addon: ExtendedAddonAttachment['addon'] | ExtendedAddon) {
16-
return essentialNumPlan(addon) || legacyEssentialPlan(addon)
17-
}
188

199
export function formatResponseWithCommands(response: string): string {
2010
return response.replace(/`(.*?)`/g, (_, word) => color.cmd(word))
@@ -53,7 +43,10 @@ export function presentCredentialAttachments(app: string, credAttachments: Requi
5343
if (connectionInformationAvailable) {
5444
const prefix = ' '
5545
rotationLines.push(`${prefix}Usernames currently active for this credential:`)
56-
ux.table(formatted, {
46+
const printLine = (line: unknown) => {
47+
rotationLines.push(line as string)
48+
}
49+
hux.table(formatted, {
5750
user: {
5851
get(row: typeof formatted[0]) {
5952
return `${prefix}${row.user}`
@@ -70,10 +63,7 @@ export function presentCredentialAttachments(app: string, credAttachments: Requi
7063
},
7164
},
7265
}, {
73-
'no-header': true,
74-
printLine(line: unknown): void {
75-
rotationLines.push(line)
76-
},
66+
printLine,
7767
})
7868
}
7969
}
@@ -121,4 +111,3 @@ export const databaseNameFromUrl = (uri: string, config: Record<string, string>)
121111
const conn = utils.pg.DatabaseResolver.parsePostgresConnectionString(uri)
122112
return `${conn.host}:${conn.port}${conn.pathname}`
123113
}
124-
*/

0 commit comments

Comments
 (0)