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

feat: add generation column to spaces command #3029

Merged
merged 3 commits into from
Oct 10, 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
11 changes: 8 additions & 3 deletions packages/cli/src/commands/spaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import color from '@heroku-cli/color'
import {Command, flags as Flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import * as Heroku from '@heroku-cli/schema'
import {Space} from '../../lib/types/fir'

type SpaceArray = Array<Required<Heroku.Space>>
type SpaceArray = Array<Required<Space>>

export default class Index extends Command {
static topic = 'spaces'
Expand All @@ -16,7 +16,11 @@ export default class Index extends Command {
public async run(): Promise<void> {
const {flags} = await this.parse(Index)
const {team, json} = flags
let {body: spaces} = await this.heroku.get<SpaceArray>('/spaces')
let {body: spaces} = await this.heroku.get<SpaceArray>('/spaces', {
headers: {
Accept: 'application/vnd.heroku+json; version=3.fir',
},
})
if (team) {
spaces = spaces.filter(s => s.team.name === team)
}
Expand Down Expand Up @@ -54,6 +58,7 @@ export default class Index extends Command {
Team: {get: space => space.team.name},
Region: {get: space => space.region.name},
State: {get: space => space.state},
Generation: {get: space => space.generation},
createdAt: {
header: 'Created At',
get: space => space.created_at,
Expand Down
17 changes: 10 additions & 7 deletions packages/cli/test/unit/commands/spaces/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('spaces', function () {
region: {name: 'my-region'},
state: 'allocated',
created_at: now.toISOString(),
generation: 'cedar',
}]

afterEach(function () {
Expand All @@ -30,9 +31,9 @@ describe('spaces', function () {

api.done()
expect(heredoc(stdout.output)).to.eq(heredoc`
Name Team Region State Created At
──────── ─────── ───────── ───────── ────────────────────────
my-space my-team my-region allocated ${now.toISOString()}
Name Team Region State Generation Created At
──────── ─────── ───────── ───────── ────────── ────────────────────────
my-space my-team my-region allocated cedar ${now.toISOString()}
`)
})

Expand All @@ -55,15 +56,17 @@ describe('spaces', function () {
team: {name: 'other-team'},
region: {name: 'my-region'},
state: 'allocated',
created_at: now.toISOString()}]))
created_at: now.toISOString(),
generation: 'cedar',
}]))

await runCommand(Cmd, ['--team', 'my-team'])

api.done()
expect(heredoc(stdout.output)).to.eq(heredoc`
Name Team Region State Created At
──────── ─────── ───────── ───────── ────────────────────────
my-space my-team my-region allocated ${now.toISOString()}
Name Team Region State Generation Created At
──────── ─────── ───────── ───────── ────────── ────────────────────────
my-space my-team my-region allocated cedar ${now.toISOString()}
`)
})

Expand Down
Loading