Skip to content
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 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/commands/maintenance/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import {createPlatformClient} from '@heroku/sdk/platform'
import {ux} from '@oclif/core/ux'

export default class MaintenanceIndex extends Command {
Expand All @@ -12,8 +12,8 @@ export default class MaintenanceIndex extends Command {

async run() {
const {flags} = await this.parse(MaintenanceIndex)
const appResponse = await this.heroku.get<Heroku.App>(`/apps/${flags.app}`)
const app = appResponse.body
const heroku = createPlatformClient()
const app = await heroku.app.info(flags.app)
ux.stdout(app.maintenance ? 'on' : 'off')
}
}
4 changes: 2 additions & 2 deletions src/commands/maintenance/off.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import * as color from '@heroku/heroku-cli-util/color'
import {disableMaintenanceMode} from '@heroku/sdk/compositions/app'
import {ux} from '@oclif/core/ux'

export default class MaintenanceOff extends Command {
Expand All @@ -14,7 +14,7 @@ export default class MaintenanceOff extends Command {
async run() {
const {flags} = await this.parse(MaintenanceOff)
ux.action.start(`Disabling maintenance mode for ${color.app(flags.app)}`)
await this.heroku.patch<Heroku.App>(`/apps/${flags.app}`, {body: {maintenance: false}})
await disableMaintenanceMode(flags.app)
ux.action.stop()
}
}
4 changes: 2 additions & 2 deletions src/commands/maintenance/on.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import * as color from '@heroku/heroku-cli-util/color'
import {enableMaintenanceMode} from '@heroku/sdk/compositions/app'
import {ux} from '@oclif/core/ux'

export default class MaintenanceOn extends Command {
Expand All @@ -14,7 +14,7 @@ export default class MaintenanceOn extends Command {
async run() {
const {flags} = await this.parse(MaintenanceOn)
ux.action.start(`Enabling maintenance mode for ${color.app(flags.app)}`)
await this.heroku.patch<Heroku.App>(`/apps/${flags.app}`, {body: {maintenance: true}})
await enableMaintenanceMode(flags.app)
ux.action.stop()
}
}
4 changes: 0 additions & 4 deletions test/helpers/init.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import chaiAsPromised from 'chai-as-promised'
import nock from 'nock'
import path from 'node:path'

globalThis.setInterval = () => ({unref() {}})
const tm = globalThis.setTimeout
globalThis.setTimeout = cb => tm(cb)

process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json')
// Env var used to prevent some expensive
// prerun and postrun hooks from initializing
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/maintenance/off.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('maintenance:off', function () {
it('turns maintenance mode off', async function () {
api
.patch('/apps/myapp', {maintenance: false})
.reply(200)
.reply(200, {maintenance: false})

const {stderr, stdout} = await runCommand(Off, ['-a', 'myapp'])

Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/maintenance/on.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('maintenance:on', function () {
it('turns maintenance mode on', async function () {
api
.patch('/apps/myapp', {maintenance: true})
.reply(200)
.reply(200, {maintenance: true})

const {stderr, stdout} = await runCommand(On, ['-a', 'myapp'])

Expand Down
Loading