Skip to content

Commit b3f11bd

Browse files
authored
refactor: apply lint formatting to remaining commands (#3667)
* refactor: apply lint formatting to remaining commands Applies automated lint formatting to remaining command files in preparation for migration to eslint 9. Changes include import ordering, class property ordering, object property ordering, and whitespace cleanup. Affected command groups: pipelines, ps, rake, redis, regions, releases, repl, reviewapps, run, sessions, spaces, status, teams, telemetry, usage, version, webhooks. * test: add minimal tests to increase coverage for spaces commands Add error handling tests for missing required parameters: - spaces:hosts without space name - spaces:peerings:destroy without pcxid - spaces:peerings without space name These tests cover previously untested error handling paths. * test: add comprehensive tests for config quote parse function Adds 7 new test cases for the parse() function to increase code coverage from 35.48% to 100% for src/lib/config/quote.ts. New tests cover: - Double-quoted strings with newlines and escaped characters - Single-quoted strings with backslashes - Empty strings and simple unquoted strings - Error cases for multiple tokens and operator tokens * chore: add --all flag to coverage commands Ensures coverage reports include all source files, not just those that are tested. This provides a more accurate picture of overall code coverage. * test: add unit tests for lib/run dyno and fix colorize tests Adds comprehensive unit tests for the Dyno class: - Constructor default values and option handling - _useSSH protocol detection (http/https vs other protocols) - _env environment variable building and TERM handling - _isDebug HEROKU_DEBUG environment variable checking - _status dyno status formatting with name and size - _readData exit code parsing and output handling Also updates colorize.unit.test.ts: - Uncomments existing tests that were previously disabled - Updates color code constants to match current 256-color ANSI codes - All 7 colorize test cases now pass These changes improve coverage for src/lib/run which previously had 38.68% coverage and dyno.ts which had no dedicated test file.
1 parent fd4c8c0 commit b3f11bd

102 files changed

Lines changed: 707 additions & 549 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@
386386
"lint": "eslint . --ext .ts --config .eslintrc.cjs",
387387
"lint:fix": "eslint . --ext .ts --config .eslintrc.cjs --fix --quiet",
388388
"lint:fix:all": "eslint . --ext .ts --config .eslintrc.cjs --fix",
389-
"coverage": "c8 --reporter=lcov --reporter=text-summary npm run test",
390-
"coverage:html": "c8 --reporter=html --reporter=text-summary npm run test",
389+
"coverage": "c8 --all --reporter=lcov --reporter=text-summary npm run test",
390+
"coverage:html": "c8 --all --reporter=html --reporter=text-summary npm run test",
391391
"create-shrinkwrap": "npm shrinkwrap",
392392
"prepublishOnly": "npm run create-shrinkwrap",
393393
"postpublish": "rm -f oclif.manifest.json",

src/commands/pipelines/add.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ export default class PipelinesAdd extends Command {
1717
required: true,
1818
}),
1919
}
20-
2120
static description = `add this app to a pipeline
2221
The app and pipeline names must be specified.
2322
The stage of the app will be guessed based on its name if not specified.`
24-
2523
static examples = [
2624
color.command('heroku pipelines:add my-pipeline -a my-app -s production'),
2725
]
28-
2926
static flags = {
3027
app: flags.app({required: true}),
3128
remote: flags.remote(),

src/commands/pipelines/connect.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ export default class Connect extends Command {
1717
required: true,
1818
}),
1919
}
20-
2120
static description = 'connect a GitHub repo to an existing pipeline'
22-
2321
static examples = [
2422
color.command('heroku pipelines:connect my-pipeline -r githuborg/reponame'),
2523
]
26-
2724
static flags = {
2825
repo: flags.string({
2926
char: 'r',

src/commands/pipelines/create.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,15 @@ export default class Create extends Command {
2323
required: false,
2424
}),
2525
}
26-
2726
static description = `create a new pipeline
2827
An existing app must be specified as the first app in the pipeline.
2928
The pipeline name will be inferred from the app name if not specified.
3029
The stage of the app will be guessed based on its name if not specified.
3130
The pipeline owner will be the user creating the pipeline if not specified with -t for teams or -o for orgs.`
32-
3331
static examples = [
3432
color.command('heroku pipelines:create -a my-app-staging'),
3533
color.command('heroku pipelines:create my-pipeline -a my-app-staging'),
3634
]
37-
3835
static flags = {
3936
app: flags.app({required: true}),
4037
remote: flags.remote(),

src/commands/pipelines/destroy.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ export default class PipelinesDestroy extends Command {
1313
required: true,
1414
}),
1515
}
16-
1716
static description = 'destroy a pipeline'
18-
1917
static examples = [
2018
color.command('heroku pipelines:destroy my-pipeline'),
2119
]

src/commands/pipelines/diff.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ const PROMOTION_ORDER = ['development', 'staging', 'production']
2626

2727
export default class PipelinesDiff extends Command {
2828
static description = 'compares the latest release of this app to its downstream app(s)'
29-
3029
static examples = [
3130
color.command('heroku pipelines:diff -a my-app-staging'),
3231
]
33-
3432
static flags = {
3533
app: flags.app({required: true}),
3634
remote: flags.remote(),
3735
}
38-
3936
getAppInfo = async (appName: string, appId: string, generation: GenerationKind): Promise<AppInfo> => {
4037
// Find GitHub connection for the app
4138
const githubApp = await this.kolkrabbi.getAppLink(appId)
@@ -70,7 +67,6 @@ export default class PipelinesDiff extends Command {
7067

7168
return {hash: commit, name: appName, repo: githubApp.repo}
7269
}
73-
7470
kolkrabbi: KolkrabbiAPI = new KolkrabbiAPI(this.config.userAgent, () => this.heroku.auth)
7571

7672
async run() {
@@ -113,11 +109,12 @@ export default class PipelinesDiff extends Command {
113109

114110
// Fetch GitHub repo/latest release hash for [target, downstream[0], .., downstream[n]] apps
115111
const appInfoPromises = [this.getAppInfo(targetAppName, targetAppId, generation)]
116-
downstreamApps.forEach(app => {
112+
for (const app of downstreamApps) {
117113
if (app.name && app.id) {
118114
appInfoPromises.push(this.getAppInfo(app.name, app.id, generation))
119115
}
120-
})
116+
}
117+
121118
ux.action.start('Fetching release info for all apps')
122119
const appInfo = await Promise.all(appInfoPromises)
123120
ux.action.stop()
@@ -138,9 +135,7 @@ export default class PipelinesDiff extends Command {
138135
// Diff [{target, downstream[0]}, {target, downstream[1]}, .., {target, downstream[n]}]
139136
const downstreamAppsInfo = appInfo.slice(1)
140137
for (const downstreamAppInfo of downstreamAppsInfo) {
141-
await diff(
142-
targetAppInfo, downstreamAppInfo, githubAccount.github.token, this.config.userAgent,
143-
)
138+
await diff(targetAppInfo, downstreamAppInfo, githubAccount.github.token, this.config.userAgent)
144139
}
145140
}
146141
}

src/commands/pipelines/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import {ux} from '@oclif/core/ux'
55

66
export default class Pipelines extends Command {
77
static description = 'list pipelines you have access to'
8-
98
static examples = [
109
color.command('heroku pipelines'),
1110
]
12-
1311
static flags = {
1412
json: flags.boolean({description: 'output in json format'}),
1513
}

src/commands/pipelines/info.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {color, hux} from '@heroku/heroku-cli-util'
21
import {Command, flags} from '@heroku-cli/command'
32
import * as Heroku from '@heroku-cli/schema'
3+
import {color, hux} from '@heroku/heroku-cli-util'
44
import {Args} from '@oclif/core'
55

66
import {listPipelineApps} from '../../lib/api.js'
@@ -14,13 +14,10 @@ export default class PipelinesInfo extends Command {
1414
required: true,
1515
}),
1616
}
17-
1817
static description = 'show list of apps in a pipeline'
19-
2018
static examples = [
2119
color.command('heroku pipelines:info my-pipeline'),
2220
]
23-
2421
static flags = {
2522
json: flags.boolean({
2623
description: 'output in json format',

src/commands/pipelines/open.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ export default class Open extends Command {
1010
static args = {
1111
pipeline: Args.string({description: 'name of pipeline', required: true}),
1212
}
13-
1413
static description = 'open a pipeline in dashboard'
15-
1614
static examples = [color.command('heroku pipelines:open my-pipeline')]
1715

1816
async run() {

src/commands/pipelines/promote.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import {APIClient, Command, flags} from '@heroku-cli/command'
22
import * as Heroku from '@heroku-cli/schema'
33
import {color, hux} from '@heroku/heroku-cli-util'
44
import {ux} from '@oclif/core/ux'
5-
import assert from 'assert'
65
import fetch from 'node-fetch'
7-
import * as Stream from 'stream'
8-
import * as util from 'util'
6+
import assert from 'node:assert'
7+
import * as Stream from 'node:stream'
8+
import {promisify} from 'node:util'
99

1010
import {AppWithPipelineCoupling, listPipelineApps} from '../../lib/api.js'
1111
import keyBy from '../../lib/pipelines/key-by.js'
@@ -27,11 +27,9 @@ const wait = (ms = 100) => new Promise(resolve => setTimeout(resolve, ms))
2727

2828
export default class Promote extends Command {
2929
static description = 'promote the latest release of this app to its downstream app(s)'
30-
3130
static examples = [
3231
color.command('heroku pipelines:promote -a my-app-staging'),
3332
]
34-
3533
static flags = {
3634
app: flags.app({
3735
required: true,
@@ -89,9 +87,7 @@ export default class Promote extends Command {
8987
promotionActionName = `Starting promotion to ${targetStage}`
9088
}
9189

92-
const promotion = await promote(
93-
this.heroku, promotionActionName, coupling.pipeline!.id!, coupling.app!.id!, targetApps,
94-
)
90+
const promotion = await promote(this.heroku, promotionActionName, coupling.pipeline!.id!, coupling.app!.id!, targetApps)
9591

9692
const pollLoop = pollPromotionStatus(this.heroku, promotion.id!, true)
9793
ux.stdout('Waiting for promotion to complete...')
@@ -228,7 +224,7 @@ async function streamReleaseCommand(heroku: APIClient, targets: Array<Heroku.App
228224
ux.stdout('Running release command...')
229225

230226
async function streamReleaseOutput(releaseStreamUrl: string) {
231-
const finished = util.promisify(Stream.finished)
227+
const finished = promisify(Stream.finished)
232228
const fetchResponse = await fetch(releaseStreamUrl)
233229

234230
if (fetchResponse.status >= 400) {

0 commit comments

Comments
 (0)