Skip to content

Commit

Permalink
Oclif core migration (#2144)
Browse files Browse the repository at this point in the history
* fix(ps): migrate ps packages to oclif core (#2115)

* Attempt to move ps to oclif/core. Most difficulty with upgrading @oclif/test. Questionable tsconfig change.

* Upgraded TS to latest and skip running in node_modules. Tests passing.

* Move skipLibCheck from test level tsconfig to package level so build command succeeds.
Make import of run file readable

* revert tslint setting that should break things, but doesn't.

* fix(addons-v5): migrate addons-v5 package to OCLIF/core (#2116)

* fix(addons-v5): migrate addons-v5 package to OCLIF/core
- add oclif/core dependency
- remove oclif/dev-cli and oclif/plugin-legacy dependencies
- replace oclif/config with oclif/core in create.js test file

* fix yarn.lock file

Co-authored-by: Katy Bowman <katybowman@salesforce.com>

* fix(apps-v5): migrate to oclif core (#2121)

* chore: remove unused dependencies.

* fix: Add oclif/core to dependencies. Was counting on other packages to install it prior. Update imports.

* fix(addons-v5): migrate addons-v5 package to OCLIF/core (#2116)

* fix(addons-v5): migrate addons-v5 package to OCLIF/core
- add oclif/core dependency
- remove oclif/dev-cli and oclif/plugin-legacy dependencies
- replace oclif/config with oclif/core in create.js test file

* fix yarn.lock file

Co-authored-by: Katy Bowman <katybowman@salesforce.com>

* chore(ps-v5): update heroku ps plans pre nov 28 (#2118)

* chore(addons-v5): update free in heroku addons (#2041)

* Update free logic & wip tests

* Update & fix tests

* Include free formatting for cents

* Update from standard-0 to hobby-basic plan

* Update from hobby-basic to mini plan (#2069)

* chore(ps-v5): update heroku ps plans (#2077)

* Update docs & quota output

* Update tests

* Include basic plan

* Update tests

* Update eco plan messaging

* Remove post nov 28 changes. Move to post nov branch

* Update free and eco quota message

* Fix conditional

Co-authored-by: Katy Bowman <katy.bowman@salesforce.com>
Co-authored-by: Katy Bowman <katybowman@salesforce.com>
Co-authored-by: Zane Whitfield <zwhitfield@salesforce.com>

* refactor(status): migrate status package to oclif/core (#2134)

* refactor: add oclif/core to status package

* refactor(status): migrate to oclif/core and fix test

* remove unneeded oclif dependencies

* upgrade typescript and set to skipLibCheck

Co-authored-by: Katy Bowman <katybowman@salesforce.com>

* refactor: migrate pg-v5 certs-v5 redis-v5 to oclif/core (#2150)

* refactor(certs-v5): migrate to oclif/core

* refactor(pg-v5): migrate to oclif/core

* refactor(redis-v5): migrate to oclif/core

Co-authored-by: Katy Bowman <katybowman@salesforce.com>

* refactor(container-registry-v5): migrate to oclif/core (#2148)

* refactor(container-registry-v5): migrate to oclif/core

* move oclif/core to dev dependencies

Co-authored-by: Katy Bowman <katybowman@salesforce.com>

* refactor(oauth-v5): migrate to oclif/core (#2149)

* refactor(oauth-v5): migrate to oclif/core

* move oclif/core to dev dependencies

Co-authored-by: Katy Bowman <katybowman@salesforce.com>

* refactor (ci-v5): migrate ci-v5 to oclif/core (#2153)

* feat(autocomplete) upgrade to core and integrate with updated herokucli command (#2160)

* wip

* refactor: upgrade autocomplete to oclif/core and local linked @heroku-cli/command.

* chore: Remove random semi

* chore: update command

* feat(local): upgrade local package to core (#2169)

* feat: upgrade to core & command & required packages

* chore: work around incorrect type in @oclif/test stub method.

* fix: upgrade to oclif/core. (#2122)

Update oclif/test and typescript to handle oclif/test.
Remove unused @heroku-cli/command dependency.
Update tslint.json to extend a package that actually exists in the repo.

* refactor(run-v5): migrate run-v5 to oclif core (#2154)

* refactor (ci-v5): migrate ci-v5 to oclif/core

* refactor (run-v5): migrate run-v5 to oclif/core

* refactor: updated to use oclif/core

* Update packages/run-v5/lib/colorize.js

Co-authored-by: RyanDagg <ryandagg@users.noreply.github.com>

Co-authored-by: RyanDagg <ryandagg@users.noreply.github.com>

* chore(config): upgrade config package to core (#2174)

* chore: upgrade config package to oclif core, updated heroku/command and oclif/test.

* chore: upgrade from cli-ux to oclif/core. Update a test to handle extra newlines from CliUX

* refactor(git): update the git package to use oclif/core (#2175)

* refactor(git): update the git package to use oclif/core

* refactor(git): remove cli-ux package

* refactor(run): upgrade run package to oclif/core (#2180)

* refactor(run): upgrade run package to oclif/core

* fix: eslint error

* chore: yarn.lock

* fix: error in tests

* chore: yarn.lock

* fix: eslint errors

* fix: ci script

* Jh/migrate orgsv5 oclif core (#2192)

* refactor(run): upgrade run package to oclif/core

* fix: eslint error

* chore: yarn.lock

* fix: error in tests

* chore: yarn.lock

* fix: eslint errors

* fix: ci script

* refactor(orgs-v5): migrate orgs-v5 to oclif/core

* refactor(buildpacks): migrate to oclif/core (#2193)

* refactor(buildpacks): initial upgrade to oclif/core

* refactor(buildpacks): initial conversion to core CliUx

* refactor(buildpacks): remove fancynock from tests

* refactor(buildpacks): update table functions to use oclif/core instead of cli-ux

* fix(buildpacks): fix tests

* chore(buildpacks): removing unneeded dependencies

* refactor(spaces): upgrade spaces to oclif/core (#2194)

* refactor(pipelines) oclif core migration (#2198)

* refactor(pipelines): initial oclif/core migration

* fix(pipelines): add types for repo object

* refactor(pipelines): fix typescript in tests

* fix: adjust failing test. add eslint ignore file for */lib build artifacts.

* fix: update package.json for -h/-v flags and remove cli-ux

* fix: remove unused packages. Fix a test that was failing due to white space changes in CliUX.

* fix: test to handle CliUX whitespace changes.

Co-authored-by: Katy Bowman <katy.bowman@salesforce.com>

* Jh/migrate oauth oclif core (#2195)

* refactor(oauth): update oauth to oclif/core

* fix: failing tests

* fix: reverted comment removal

* Update packages/oauth/package.json

Co-authored-by: RyanDagg <ryandagg@users.noreply.github.com>

* fix: reverted tsconfig.json

Co-authored-by: RyanDagg <ryandagg@users.noreply.github.com>

* chore(ci): migrate to oclif core (#2183)

* chore: upgrade to oclif/core.

* fix: revert index.test format. Add comment for ts-disable

* fix: correctly add help and version flags.

* fix(pipelines) cli-ux migration (#2199)

* refactor(pipelines): initial oclif/core migration

* fix(pipelines): add types for repo object

* refactor(pipelines): fix typescript in tests

* fix: adjust failing test. add eslint ignore file for */lib build artifacts.

* fix: update package.json for -h/-v flags and remove cli-ux

* fix: remove unused packages. Fix a test that was failing due to white space changes in CliUX.

* fix: test to handle CliUX whitespace changes.

* fix: finish removing cli-ux package from pipelines.

Co-authored-by: Katy Bowman <katy.bowman@salesforce.com>

* Jh/migrate webhooks oclif core (#2197)

* refactor(webhooks): upgrade webhooks to oclif/core

* refactor(webhooks): migrate to oclif/core

* chore: fix failing tests & linting

* fix: tests handle \n differently

* fix: failing tests

* fix: failing tests

* fix: update node version in ci

* fix: removed Node 18

* fix: lint error, ci experiment

* fix: revert ci

* chore: troubleshooting

* fix: error in add.test

* chore: added message to action.stop

* refactor: build release packages from oclif  (#2204)

* chore: intitial exploration of what happens when trying to package debian build

* chore: enable downstream deb builds

* refactor: Add "oclif" cli, not core to all packages. Update all commands to use new location of .bin file.

* chore: pin oclif version across all packages

* chore: remove unused  @heroku-cli/dev-cli dependencies.

* chore: revert verification changes to ci.yml

* Attempt to retry on timeout

* fix: add retry to correct location

* chore: add comment to new retry approach

* might as well bump timeout in new plugin and drop yarn from 1000 minutes

* plugin would not get approved. Increasing timeout via yarn.

* Refactor(auth & cli): migrate auth and cli packages to oclif/core (#2173)

* refactor(auth): refactor the auth package to use oclif/core

* chore(auth): update typescript and oclif/test versions

* refactor(cli): migrate cli package to oclif/core, update typescript and oclif/test

* chore(auth & cli): yarn.lock updates

* A few fixes for oclif auth (#2176)

* wip: lint issue due to eslint plugin updated somewhere in chain.

* wip lock package numbers

* fix: revert yarn.lock from oclif-core-migration branch.

* chore(auth): align dependency versions with cli package

* chore: confirm TS error mirrors functionality. It does not.

* Revert "chore: confirm TS error mirrors functionality. It does not."

This reverts commit 4566880.

* chore: update yarn.lock

* fix: fix cli analytics tests

* chore(auth & cli): remove unneccessary dependencies

* chore: update yarn.lock

Co-authored-by: RyanDagg <ryandagg@users.noreply.github.com>
Co-authored-by: RyanDagg <rdagg@salesforce.com>

* refactor(apps): update to oclif core and merge in yarn 3 (#2214)

* refactor(pipelines): initial oclif/core migration

* fix(pipelines): add types for repo object

* refactor(pipelines): fix typescript in tests

* fix: adjust failing test. add eslint ignore file for */lib build artifacts.

* fix: update package.json for -h/-v flags and remove cli-ux

* fix: remove unused packages. Fix a test that was failing due to white space changes in CliUX.

* fix: test to handle CliUX whitespace changes.

* refactor: upgrade to oclif core in apps package

* fix: finish removing cli-ux package from pipelines.

* fix: migrate from cli-ux to core

* fix: finish removing cli-ux from autocomplete
fix a test issue in autocomplete due to some eslint module resolution issues.

* Re-add ts package

* fix(apps): test fix

* refactor: upgrade to yarn 3. Attempting to determine version in CI.

* chore: revert ci.yml changes. uneeded.

* fix: see if the Snyk security issue is do to rm -rf

* fix: type in JSON

* ci experiment

* chore: make import versions consistent

* add script to delete ALL node_modules

* fix: finish ps upgrade. tests passing.

* fix: get status command working again.

* revert to minimum needed change.

* remove yarn files.

* fix: finish ps upgrade. tests passing. (#2210)

* fix: finish ps upgrade. tests passing.

* fix: get status command working again.

* revert to minimum needed change.

* fix: correct core version in apps. Fix remaining tests outside of apps.

* Fix some missed dependencies in autocomplete

* chore: Removed all references to @oclif/command

* fix: No longer getting errors in pipelines lint.

* Fix all of the eslint problems.

* Revert "fix: No longer getting errors in pipelines lint."

This reverts commit 8adac9e.

* Revert "Revert "fix: No longer getting errors in pipelines lint.""

This reverts commit 6aca06b.

* fix: type issue in config

* Reverting to @oclif/command until we can figure out why core breaks everything.

* Merge in branch with master merged into oclif-core-migration

* Remove unnecessary "camelcase: off". Lint passing.

* chore: remove unneeded script

* Update packages/apps/package.json

* chore: remove unused plugin in auth

Co-authored-by: Katy Bowman <katy.bowman@salesforce.com>
Co-authored-by: Jennette <jheikes@salesforce.com>

* refactor(cli) finish upgrading cli package (#2215)

* refactor(pipelines): initial oclif/core migration

* fix(pipelines): add types for repo object

* refactor(pipelines): fix typescript in tests

* fix: adjust failing test. add eslint ignore file for */lib build artifacts.

* fix: update package.json for -h/-v flags and remove cli-ux

* fix: remove unused packages. Fix a test that was failing due to white space changes in CliUX.

* fix: test to handle CliUX whitespace changes.

* refactor: upgrade to oclif core in apps package

* fix: finish removing cli-ux package from pipelines.

* fix: migrate from cli-ux to core

* fix: finish removing cli-ux from autocomplete
fix a test issue in autocomplete due to some eslint module resolution issues.

* Re-add ts package

* fix(apps): test fix

* refactor: upgrade to yarn 3. Attempting to determine version in CI.

* chore: revert ci.yml changes. uneeded.

* fix: see if the Snyk security issue is do to rm -rf

* fix: type in JSON

* ci experiment

* chore: make import versions consistent

* add script to delete ALL node_modules

* fix: finish ps upgrade. tests passing.

* fix: get status command working again.

* revert to minimum needed change.

* remove yarn files.

* fix: finish ps upgrade. tests passing. (#2210)

* fix: finish ps upgrade. tests passing.

* fix: get status command working again.

* revert to minimum needed change.

* fix: correct core version in apps. Fix remaining tests outside of apps.

* Fix some missed dependencies in autocomplete

* chore: Removed all references to @oclif/command

* fix: No longer getting errors in pipelines lint.

* Fix all of the eslint problems.

* Revert "fix: No longer getting errors in pipelines lint."

This reverts commit 8adac9e.

* Revert "Revert "fix: No longer getting errors in pipelines lint.""

This reverts commit 6aca06b.

* fix: type issue in config

* Reverting to @oclif/command until we can figure out why core breaks everything.

* Merge in branch with master merged into oclif-core-migration

* Remove unnecessary "camelcase: off". Lint passing.

* chore standardize **/bin/run files. Add them where missing.

* chore: remove unneeded script

Co-authored-by: Katy Bowman <katy.bowman@salesforce.com>
Co-authored-by: Jennette <jheikes@salesforce.com>

* fix: use the spinner function from CliUx directly (#2222)

* fix(apps): use spinner function directly in several files

* fix(webhooks): use spinner function directly in several files

* chore(oclif) remove all old oclif dependencies (#2223)

* wip: first step to remove all dependencies importing pre core.

* chore: remove all imports of @oclif/core@2

* chore: remove @oclif/plugin-legacy and it's pre-core dependencies.

* chore: remove confusing yarn version. Remove boostrap line from readme.

---------

Co-authored-by: RyanDagg <ryandagg@users.noreply.github.com>
Co-authored-by: Katy Bowman <katybowman@salesforce.com>
Co-authored-by: Zane Whitfield <zwhitfield@salesforce.com>
Co-authored-by: jheikes515 <87785368+jheikes515@users.noreply.github.com>
Co-authored-by: RyanDagg <rdagg@salesforce.com>
Co-authored-by: Jennette <jheikes@salesforce.com>
  • Loading branch information
7 people committed Jan 31, 2023
1 parent 1d83190 commit a1f4604
Show file tree
Hide file tree
Showing 276 changed files with 4,226 additions and 2,387 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
packages/*/lib
packages/*/tmp
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ node_modules
!.yarn/sdks
!.yarn/versions


1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.19.0
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"devDependencies": {
"@oclif/tslint": "^3.1.1",
"eslint": "5.13.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-import": "^2.16.0",
Expand All @@ -19,14 +20,15 @@
]
},
"engines": {
"node": ">=10.0.0",
"node": ">=12.0.0",
"yarn": ">=3.0.0"
},
"packageManager": "yarn@3.3.1",
"private": true,
"scripts": {
"test": "lerna run test --concurrency 4",
"version": "cp packages/cli/CHANGELOG.md CHANGELOG.md && git add CHANGELOG.md"
"version": "cp packages/cli/CHANGELOG.md CHANGELOG.md && git add CHANGELOG.md",
"cleanNodeModules": "rm -rf ./packages/*/node_modules && rm -rf ./node_modules"
},
"workspaces": [
"packages/*"
Expand Down
16 changes: 12 additions & 4 deletions packages/addons-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/addons-v5/<%- commandPath %>"
},
"dependencies": {
"@oclif/core": "^1.22.0",
"heroku-cli-util": "^8.0.11",
"lodash": "^4.17.11",
"printf": "0.6.1"
},
"devDependencies": {
"@heroku-cli/dev-cli": "^1.26.13",
"@oclif/plugin-legacy": "^1.2.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"lolex": "^3.1.0",
"mocha": "^5.2.0",
"nock": "9.0.13",
"nyc": "^15.1.0",
"oclif": "3.4.3",
"sinon": "^6.3.5"
},
"files": [
Expand All @@ -41,12 +41,20 @@
],
"license": "ISC",
"main": "index.js",
"oclif": {
"additionalHelpFlags": [
"-h"
],
"additionalVersionFlags": [
"-v"
]
},
"repository": "heroku/cli",
"scripts": {
"postpublish": "rm oclif.manifest.json",
"prepack": "oclif-dev manifest",
"prepack": "oclif manifest",
"release": "np",
"test": "nyc mocha",
"version": "oclif-dev readme && git add README.md"
"version": "oclif readme && git add README.md"
}
}
2 changes: 1 addition & 1 deletion packages/addons-v5/test/commands/addons/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const cmd = commands.find(c => c.topic === 'addons' && c.command === 'create')
const { expect } = require('chai')
const lolex = require('lolex')
const _ = require('lodash')
const Config = require('@oclif/config')
const { Config } = require('@oclif/core')
const sinon = require('sinon')
let config

Expand Down
18 changes: 13 additions & 5 deletions packages/apps-v5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"repositoryPrefix": "<%- repo %>/blob/v<%- version %>/packages/apps-v5/<%- commandPath %>"
},
"dependencies": {
"@heroku-cli/command": "^8.4.1",
"@heroku-cli/command": "^9.0.1",
"@oclif/core": "^1.22.0",
"filesize": "^4.0.0",
"fs-extra": "^7.0.1",
"heroku-cli-util": "^8.0.11",
Expand All @@ -29,15 +30,14 @@
"urijs": "1.19.11"
},
"devDependencies": {
"@heroku-cli/dev-cli": "^1.26.13",
"@oclif/plugin-legacy": "^1.2.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"lolex": "^3.1.0",
"mocha": "^5.2.0",
"mockdate": "^2.0.2",
"netrc-parser": "^3.1.6",
"nock": "^10.0.6",
"oclif": "3.4.3",
"proxyquire": "^2.1.0",
"set-tz": "^0.1.0",
"std-mocks": "1.0.1",
Expand All @@ -58,11 +58,19 @@
"publishConfig": {
"access": "public"
},
"oclif": {
"additionalHelpFlags": [
"-h"
],
"additionalVersionFlags": [
"-v"
]
},
"repository": "heroku/cli",
"scripts": {
"postpublish": "rm oclif.manifest.json",
"prepack": "oclif-dev manifest && oclif-dev readme",
"prepack": "oclif manifest && oclif readme",
"test": "mocha",
"version": "oclif-dev readme && git add README.md"
"version": "oclif readme && git add README.md"
}
}
2 changes: 1 addition & 1 deletion packages/apps-v5/test/commands/apps/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const cli = require('heroku-cli-util')
const nock = require('nock')
const expect = require('chai').expect
const apps = commands.find(c => c.topic === 'apps' && c.command === 'create')
const Config = require('@oclif/config')
const { Config } = require('@oclif/core')
let config

describe('apps:create', function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/apps-v5/test/commands/config/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const assertExit = require('../../assert_exit.js')

describe('config:set', () => {
beforeEach(async () => {
config = await require('@oclif/config').load()
config = await require('@oclif/core').Config.load()
cli.mockConsole()
cli.exit.mock()
})
Expand Down
3 changes: 1 addition & 2 deletions packages/apps/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
"oclif",
"oclif-typescript"
],
"rules": {
}
"rules": {}
}
5 changes: 3 additions & 2 deletions packages/apps/bin/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node

require('@oclif/command').run()
.catch(require('@oclif/errors/handle'))
const oclif = require('@oclif/core')

oclif.run().catch(require('@oclif/core/handle'))
32 changes: 16 additions & 16 deletions packages/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@
"bugs": "https://github.com/heroku/heroku-cli-plugin-apps/issues",
"dependencies": {
"@heroku-cli/color": "^1.1.14",
"@heroku-cli/command": "^8.4.1",
"@heroku-cli/command": "^9.0.1",
"@heroku-cli/schema": "^1.0.25",
"@oclif/command": "^1",
"@oclif/config": "^1",
"cli-ux": "^5.3.2",
"@oclif/core": "^1.22.0",
"inquirer": "^7.0.1",
"shell-escape": "^0.2.0",
"tslib": "^1",
"urijs": "^1.19.11"
},
"devDependencies": {
"@fancy-test/nock": "^0.1.1",
"@heroku-cli/dev-cli": "^1.26.13",
"@oclif/plugin-help": "^2",
"@oclif/test": "^1",
"@oclif/test": "^2.2.20",
"@types/chai": "^4",
"@types/mocha": "^5",
"@types/node": "^10",
Expand All @@ -32,12 +27,14 @@
"eslint-config-oclif-typescript": "^0.1.0",
"globby": "^10",
"mocha": "^5",
"nock": "^13.0.1",
"nyc": "^15.1.0",
"oclif": "3.4.3",
"ts-node": "^10",
"typescript": "3.7.5"
"typescript": "4.8.4"
},
"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},
"files": [
"/lib",
Expand All @@ -51,20 +48,23 @@
],
"license": "MIT",
"oclif": {
"commands": "./lib/commands",
"additionalHelpFlags": [
"-h"
],
"additionalVersionFlags": [
"-v"
],
"bin": "heroku",
"devPlugins": [
"@oclif/plugin-help"
]
"commands": "./lib/commands"
},
"repository": "heroku/heroku-cli-plugin-apps",
"scripts": {
"postpack": "rm -f oclif.manifest.json",
"lint": "eslint . --ext .ts --config .eslintrc",
"pretest": "tsc -p test --noEmit",
"posttest": "yarn lint",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"prepack": "rm -rf lib && tsc -b && oclif manifest && oclif readme",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"version": "oclif-dev readme && git add README.md"
"version": "oclif readme && git add README.md"
}
}
18 changes: 11 additions & 7 deletions packages/apps/src/commands/domains/add.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import {color} from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import cli from 'cli-ux'
import {CliUx} from '@oclif/core'
import Spinner from '@oclif/core/lib/cli-ux/action/spinner'
import {prompt} from 'inquirer'
import * as shellescape from 'shell-escape'
import waitForDomain from '../../lib/wait-for-domain'

const cli = CliUx.ux

interface DomainCreatePayload {
hostname: string;
sni_endpoint: string | null;
Expand Down Expand Up @@ -71,8 +74,9 @@ export default class DomainsAdd extends Command {
}

async run() {
const {args, flags} = this.parse(DomainsAdd)
const {args, flags} = await this.parse(DomainsAdd)
const {hostname} = args
const action = new Spinner()

const domainCreatePayload: DomainCreatePayload = {
hostname,
Expand All @@ -81,7 +85,7 @@ export default class DomainsAdd extends Command {

let certs: Array<Heroku.SniEndpoint> = []

cli.action.start(`Adding ${color.green(domainCreatePayload.hostname)} to ${color.app(flags.app)}`)
action.start(`Adding ${color.green(domainCreatePayload.hostname)} to ${color.app(flags.app)}`)
if (flags.cert) {
domainCreatePayload.sni_endpoint = flags.cert
} else {
Expand All @@ -91,14 +95,14 @@ export default class DomainsAdd extends Command {
}

if (certs.length > 1) {
cli.action.stop('resolving SNI endpoint')
action.stop('resolving SNI endpoint')
const certSelection = await this.certSelect(certs)

if (certSelection) {
domainCreatePayload.sni_endpoint = certSelection
}

cli.action.start(`Adding ${color.green(domainCreatePayload.hostname)} to ${color.app(flags.app)}`)
action.start(`Adding ${color.green(domainCreatePayload.hostname)} to ${color.app(flags.app)}`)
}

try {
Expand All @@ -122,10 +126,10 @@ export default class DomainsAdd extends Command {
}
}
}
} catch (error) {
} catch (error: any) {
cli.error(error)
} finally {
cli.action.stop()
action.stop()
}
}
}
10 changes: 6 additions & 4 deletions packages/apps/src/commands/domains/clear.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {color} from '@heroku-cli/color'
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import cli from 'cli-ux'
import Spinner from '@oclif/core/lib/cli-ux/action/spinner'

export default class DomainsClear extends Command {
static description = 'remove all domains from an app'
Expand All @@ -15,14 +15,16 @@ export default class DomainsClear extends Command {
}

async run() {
const {flags} = this.parse(DomainsClear)
cli.action.start(`Removing all domains from ${color.app(flags.app)}`)
const {flags} = await this.parse(DomainsClear)
const action = new Spinner()

action.start(`Removing all domains from ${color.app(flags.app)}`)
let {body: domains} = await this.heroku.get<Array<Heroku.Domain>>(`/apps/${flags.app}/domains`)
domains = domains.filter((d: Heroku.Domain) => d.kind === 'custom')
for (const domain of domains) {
// eslint-disable-next-line no-await-in-loop
await this.heroku.delete(`/apps/${flags.app}/domains/${domain.hostname}`)
}
cli.action.stop()
action.stop()
}
}
6 changes: 4 additions & 2 deletions packages/apps/src/commands/domains/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import cli from 'cli-ux'
import {CliUx} from '@oclif/core'
import * as Uri from 'urijs'

const cli = CliUx.ux

function isApexDomain(hostname: string) {
if (hostname.includes('*')) return false
const a = new Uri({protocol: 'http', hostname})
Expand Down Expand Up @@ -71,7 +73,7 @@ www.example.com CNAME www.example.herokudns.com
}

async run() {
const {flags} = this.parse(DomainsIndex)
const {flags} = await this.parse(DomainsIndex)
const {body: domains} = await this.heroku.get<Array<Heroku.Domain>>(`/apps/${flags.app}/domains`)
const herokuDomain = domains.find(domain => domain.kind === 'heroku')
const customDomains = domains.filter(domain => domain.kind === 'custom')
Expand Down
6 changes: 4 additions & 2 deletions packages/apps/src/commands/domains/info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {Command, flags} from '@heroku-cli/command'
import * as Heroku from '@heroku-cli/schema'
import cli from 'cli-ux'
import {CliUx} from '@oclif/core'

const cli = CliUx.ux

export default class DomainsInfo extends Command {
static description = 'show detailed information for a domain on an app'
Expand All @@ -18,7 +20,7 @@ export default class DomainsInfo extends Command {
static args = [{name: 'hostname', required: true}]

async run() {
const {args, flags} = this.parse(DomainsInfo)
const {args, flags} = await this.parse(DomainsInfo)
const {body: res} = await this.heroku.get<Heroku.Domain>(`/apps/${flags.app}/domains/${args.hostname}`)
const domain = {
...res,
Expand Down
Loading

0 comments on commit a1f4604

Please sign in to comment.