Skip to content

Commit

Permalink
chore: fix eslint indent rule (heroku#2345)
Browse files Browse the repository at this point in the history
* chore: update yarn.lock

* chore: change eslint indent rule

* chore: update indentations in addons-v5

* chore: update indentations in apps

* chore: update indentations in apps-v5

* chore: update indentations in auth

* chore: update indentations in autocomplete

* chore: update indentations in buildpacks

* chore: update indentations in certs

* chore: update indentations in certs-v5

* chore: update indentations in ci

* chore: update indentations in ci-v5

* chore: update indentations in cli

* chore: update indentations in config

* chore: update indentations in container-registry-v5

* chore: update indentation in git

* chore: update indentation in local

* chore: update indentation in oauth

* chore: update indentation in oauth-v5

* chore: update indentation in orgs-v5

* chore: update indentation in pg-v5

* chore: update indentation in pipelines

* chore: update indentation in ps

* chore: update indentation in redis-v5

* chore: update indentation in run

* chore: update indentation in run-v5

* chore: update indentation in spaces

* chore: update indentation in status

* chore: update indentation in webhooks
  • Loading branch information
k80bowman authored May 9, 2023
1 parent 3b08b45 commit e16db09
Show file tree
Hide file tree
Showing 391 changed files with 9,812 additions and 9,815 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@typescript-eslint/no-unused-vars": "warn", // TODO: fix issues and turn this back on
"camelcase":"off",
"import/no-unresolved": "error",
"indent": ["error", 2, {"MemberExpression": 1}],
"func-names":"warn", // TODO: fix issues and turn this back on
"no-await-in-loop": "warn", // TODO: fix issues and turn this back on
"no-constant-condition": ["error", {"checkLoops": false }],
Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ async function run(context, heroku) {
await cli.action(
`Setting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
{success: false},
async function () {
(async function () {
let releases = await heroku.get(`/apps/${app}/releases`, {
partial: true,
headers: {Range: 'version ..; max=1, order=desc'},
})
cli.action.done(`done, v${releases[0].version}`)
}(),
})(),
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/detach.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ async function run(context, heroku) {
await cli.action(
`Unsetting ${cli.color.attachment(attachment.name)} config vars and restarting ${cli.color.app(app)}`,
{success: false},
async function () {
(async function () {
let releases = await heroku.request({
path: `/apps/${app}/releases`,
partial: true,
headers: {Range: 'version ..; max=1, order=desc'},
})
cli.action.done(`done, v${releases[0].version}`)
}(),
})(),
)
}

Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ async function run(ctx, api) {
format: function (addon) {
if (addon.app.name === app) {
return formatPrice(addon.plan.price)
} else {
return style('dim', printf('(billed to %s app)', style('app', addon.app.name)))
}

return style('dim', printf('(billed to %s app)', style('app', addon.app.name)))
},
}, {
label: 'State',
Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let style = require('../../lib/util').style

let run = cli.command({preauth: true}, function (ctx, api) {
const resolve = require('../../lib/resolve')
return async function () {
return (async function () {
let addon = await resolve.addon(api, ctx.app, ctx.args.addon)
let attachments = await api.request({
method: 'GET',
Expand All @@ -33,7 +33,7 @@ let run = cli.command({preauth: true}, function (ctx, api) {
'Installed at': (new Date(addon.created_at)).toString(),
State: formatState(addon.state),
})
}()
})()
})

let topic = 'addons'
Expand Down
6 changes: 3 additions & 3 deletions packages/addons-v5/commands/addons/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ async function run(ctx, api) {
if (process.env.HEROKU_SUDO) return sudo(ctx, api)

let attachment = await resolve.attachment(api, ctx.app, ctx.args.addon)
.catch(function (error) {
if (error.statusCode !== 404) throw error
})
.catch(function (error) {
if (error.statusCode !== 404) throw error
})

let webUrl
if (attachment) {
Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/commands/addons/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let cli = require('heroku-cli-util')

let run = cli.command({preauth: true}, function (ctx, api) {
return async function () {
return (async function () {
let addon = await api.get(`/addons/${ctx.args.addon}`)
let addonUrl = `/apps/${addon.app.id}/addons/${addon.id}`

Expand All @@ -13,7 +13,7 @@ let run = cli.command({preauth: true}, function (ctx, api) {
let newName = cli.color.magenta(ctx.args.name)

cli.log(`${oldName} successfully renamed to ${newName}.`)
}()
})()
})

let topic = 'addons'
Expand Down
12 changes: 6 additions & 6 deletions packages/addons-v5/commands/addons/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ function handlePlanChangeAPIError(err) {

if (err.statusCode === 422 && err.body.message && err.body.message.startsWith("Couldn't find either the add-on")) {
return heroku.get(`/addon-services/${service}/plans`)
.then(plans => {
plans = sortBy(plans, 'price.cents').map(plans => plans.name)
throw new Error(`${err.body.message}
.then(plans => {
plans = sortBy(plans, 'price.cents').map(plans => plans.name)
throw new Error(`${err.body.message}
Here are the available plans for ${cli.color.yellow(service)}:
${plans.join('\n')}
See more plan information with ${cli.color.blue('heroku addons:plans ' + service)}
${cli.color.cyan('https://devcenter.heroku.com/articles/managing-add-ons')}`)
})
})
}

throw err
Expand Down Expand Up @@ -86,7 +86,7 @@ async function run(c, h) {
service = addon.addon_service.name
app = addon.app.name
plan = `${service}:${plan}`
await cli.action(`Changing ${cli.color.magenta(addon.name)} on ${cli.color.cyan(app)} from ${cli.color.blue(addon.plan.name)} to ${cli.color.blue(plan)}`, {success: false}, async function () {
await cli.action(`Changing ${cli.color.magenta(addon.name)} on ${cli.color.cyan(app)} from ${cli.color.blue(addon.plan.name)} to ${cli.color.blue(plan)}`, {success: false}, (async function () {
addon = await heroku.request({
path: `/apps/${app}/addons/${addon.name}`,
method: 'PATCH',
Expand All @@ -98,7 +98,7 @@ async function run(c, h) {
}).catch(error => handlePlanChangeAPIError(error))
cli.action.done(`done, ${cli.color.green(util.formatPrice(addon.plan.price))}`)
if (addon.provision_message) cli.log(addon.provision_message)
}())
})())
}

let cmd = {
Expand Down
4 changes: 2 additions & 2 deletions packages/addons-v5/lib/addons_wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = async function (api, addon, interval) {
const app = addon.app.name
const addonName = addon.name

await cli.action(`Creating ${cli.color.addon(addon.name)}`, async function () {
await cli.action(`Creating ${cli.color.addon(addon.name)}`, (async function () {
while (addon.state === 'provisioning') {
await new Promise(resolve => setTimeout(resolve, interval * 1000))

Expand All @@ -20,7 +20,7 @@ module.exports = async function (api, addon, interval) {
if (addon.state === 'deprovisioned') {
throw new Error(`The add-on was unable to be created, with status ${addon.state}`)
}
}())
})())

return addon
}
4 changes: 2 additions & 2 deletions packages/addons-v5/lib/create_addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ function formatConfigVarsMessage(addon) {
if (configVars.length > 0) {
configVars = configVars.map(c => cli.color.configVar(c)).join(', ')
return `Created ${cli.color.addon(addon.name)} as ${configVars}`
} else {
return `Created ${cli.color.addon(addon.name)}`
}

return `Created ${cli.color.addon(addon.name)}`
}

module.exports = async function (heroku, app, plan, confirm, wait, options) {
Expand Down
78 changes: 39 additions & 39 deletions packages/addons-v5/lib/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const appAddon = function (heroku, app, id, options = {}) {
headers: headers,
body: {app: app, addon: id, addon_service: options.addon_service},
})
.then(singularize('addon', options.namespace))
.then(singularize('addon', options.namespace))
}

const handleNotFound = function (err, resource) {
if (err.statusCode === 404 && err.body && err.body.resource === resource) {
return true
} else {
throw err
}

throw err
}

exports.appAddon = appAddon
Expand All @@ -43,15 +43,15 @@ const addonResolver = function (heroku, app, id, options = {}) {
headers: headers,
body: {app: null, addon: id, addon_service: options.addon_service},
})
.then(singularize('addon', options.namespace))
.then(singularize('addon', options.namespace))
}

if (!app || id.includes('::')) return getAddon(id)

return appAddon(heroku, app, id, options)
.catch(function (error) {
if (handleNotFound(error, 'add_on')) return getAddon(id)
})
.catch(function (error) {
if (handleNotFound(error, 'add_on')) return getAddon(id)
})
}

/**
Expand Down Expand Up @@ -130,56 +130,56 @@ exports.attachment = function (heroku, app, id, options = {}) {
return heroku.post('/actions/addon-attachments/resolve', {
headers: headers, body: {app: null, addon_attachment: id, addon_service: options.addon_service},
}).then(singularize('addon_attachment', options.namespace))
.catch(function (error) {
handleNotFound(error, 'add_on attachment')
})
.catch(function (error) {
handleNotFound(error, 'add_on attachment')
})
}

function getAppAddonAttachment(addon, app) {
return heroku.get(`/addons/${encodeURIComponent(addon.id)}/addon-attachments`, {headers})
.then(filter(app, options.addon_service))
.then(singularize('addon_attachment', options.namespace))
.then(filter(app, options.addon_service))
.then(singularize('addon_attachment', options.namespace))
}

let promise
if (!app || id.includes('::')) {
promise = getAttachment(id)
} else {
promise = appAttachment(heroku, app, id, options)
.catch(function (error) {
handleNotFound(error, 'add_on attachment')
})
.catch(function (error) {
handleNotFound(error, 'add_on attachment')
})
}

// first check to see if there is an attachment matching this app/id combo
return promise
.then(function (attachment) {
return {attachment}
})
.catch(function (error) {
return {error}
})
.then(function (attachment) {
return {attachment}
})
.catch(function (error) {
return {error}
})
// if no attachment, look up an add-on that matches the id
.then(attachOrError => {
let {attachment, error} = attachOrError

if (attachment) return attachment

// If we were passed an add-on slug, there still could be an attachment
// to the context app. Try to find and use it so `context_app` is set
// correctly in the SSO payload.
else if (app) {
return exports.addon(heroku, app, id, options)
.then(addon => getAppAddonAttachment(addon, app))
.catch(addonError => {
if (error) throw error
throw addonError
})
} else {
.then(attachOrError => {
let {attachment, error} = attachOrError

if (attachment) return attachment

// If we were passed an add-on slug, there still could be an attachment
// to the context app. Try to find and use it so `context_app` is set
// correctly in the SSO payload.
if (app) {
return exports.addon(heroku, app, id, options)
.then(addon => getAppAddonAttachment(addon, app))
.catch(addonError => {
if (error) throw error
throw addonError
})
}

if (error) throw error
throw new NotFound()
}
})
})
}

const appAttachment = function (heroku, app, id, options = {}) {
Expand Down
10 changes: 5 additions & 5 deletions packages/addons-v5/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ module.exports = {

trapConfirmationRequired: async function (app, confirm, fn) {
return await fn(confirm)
.catch(error => {
if (!error.body || error.body.id !== 'confirmation_required') throw error
return cli.confirmApp(app, confirm, error.body.message)
.then(() => fn(app))
})
.catch(error => {
if (!error.body || error.body.id !== 'confirmation_required') throw error
return cli.confirmApp(app, confirm, error.body.message)
.then(() => fn(app))
})
},

formatState: function (state) {
Expand Down
18 changes: 9 additions & 9 deletions packages/addons-v5/test/commands/addons.--all.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe('addons --all', function () {
context('with add-ons', function () {
beforeEach(function () {
nock('https://api.heroku.com', {reqheaders: {'Accept-Expansion': 'addon_service,plan'}})
.get('/addons')
.reply(200, addons)
.get('/addons')
.reply(200, addons)
})

it('prints add-ons in a table', function () {
Expand All @@ -45,9 +45,9 @@ acme-inc-www www-redis heroku-redis:premium-2 $60/month creating`)
context('--json', function () {
it('prints the output in json format', function () {
return cmd.run({flags: {json: true}})
.then(function () {
expect(JSON.parse(cli.stdout)[0].name).to.eq('www-db')
})
.then(function () {
expect(JSON.parse(cli.stdout)[0].name).to.eq('www-db')
})
})
})
})
Expand All @@ -60,8 +60,8 @@ acme-inc-www www-redis heroku-redis:premium-2 $60/month creating`)
nock('https://api.heroku.com', {reqheaders: {
'Accept-Expansion': 'addon_service,plan',
}})
.get('/addons')
.reply(200, [addon])
.get('/addons')
.reply(200, [addon])
})

it('prints add-ons in a table with the grandfathered price', function () {
Expand All @@ -82,8 +82,8 @@ acme-inc-dwh dwh-db heroku-postgresql:standard-2 $100/month created`)
nock('https://api.heroku.com', {reqheaders: {
'Accept-Expansion': 'addon_service,plan',
}})
.get('/addons')
.reply(200, [addon])
.get('/addons')
.reply(200, [addon])
})

it('prints add-ons in a table with contract', function () {
Expand Down
8 changes: 4 additions & 4 deletions packages/addons-v5/test/commands/addons.--app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ describe('addons --app', function () {
nock('https://api.heroku.com', {reqheaders: {
'Accept-Expansion': 'addon_service,plan',
}})
.get(`/apps/${appName}/addons`)
.reply(200, addons)
.get(`/apps/${appName}/addons`)
.reply(200, addons)

nock('https://api.heroku.com')
.get('/addon-attachments')
.reply(200, attachments)
.get('/addon-attachments')
.reply(200, attachments)
}

beforeEach(() => cli.mockConsole())
Expand Down
Loading

0 comments on commit e16db09

Please sign in to comment.