heroku 10.13.2-beta.0 → 10.13.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/lib/commands/pg/backups/cancel.js +4 -4
  2. package/lib/commands/pg/backups/capture.js +5 -5
  3. package/lib/commands/pg/backups/delete.js +2 -2
  4. package/lib/commands/pg/backups/download.js +3 -3
  5. package/lib/commands/pg/backups/index.js +2 -2
  6. package/lib/commands/pg/backups/info.js +3 -3
  7. package/lib/commands/pg/backups/restore.js +5 -5
  8. package/lib/commands/pg/backups/schedule.js +7 -7
  9. package/lib/commands/pg/backups/schedules.js +2 -2
  10. package/lib/commands/pg/backups/unschedule.js +6 -5
  11. package/lib/commands/pg/backups/url.js +3 -3
  12. package/lib/commands/pg/bloat.js +5 -4
  13. package/lib/commands/pg/blocking.js +5 -4
  14. package/lib/commands/pg/connection-pooling/attach.js +5 -6
  15. package/lib/commands/pg/copy.js +6 -7
  16. package/lib/commands/pg/credentials/create.js +4 -4
  17. package/lib/commands/pg/credentials/destroy.js +4 -4
  18. package/lib/commands/pg/credentials/repair-default.js +4 -4
  19. package/lib/commands/pg/credentials/rotate.js +4 -4
  20. package/lib/commands/pg/credentials/url.js +4 -4
  21. package/lib/commands/pg/credentials.js +4 -4
  22. package/lib/commands/pg/diagnose.js +6 -5
  23. package/lib/commands/pg/info.js +5 -3
  24. package/lib/commands/pg/kill.js +6 -5
  25. package/lib/commands/pg/killall.js +4 -4
  26. package/lib/commands/pg/links/create.js +10 -8
  27. package/lib/commands/pg/links/destroy.js +4 -4
  28. package/lib/commands/pg/links/index.js +14 -8
  29. package/lib/commands/pg/locks.js +5 -4
  30. package/lib/commands/pg/maintenance/index.js +4 -4
  31. package/lib/commands/pg/maintenance/run.js +4 -4
  32. package/lib/commands/pg/maintenance/window.js +4 -4
  33. package/lib/commands/pg/outliers.d.ts +2 -2
  34. package/lib/commands/pg/outliers.js +9 -7
  35. package/lib/commands/pg/promote.js +5 -4
  36. package/lib/commands/pg/ps.js +6 -5
  37. package/lib/commands/pg/psql.js +6 -4
  38. package/lib/commands/pg/pull.d.ts +1 -1
  39. package/lib/commands/pg/pull.js +4 -4
  40. package/lib/commands/pg/push.d.ts +1 -1
  41. package/lib/commands/pg/push.js +4 -4
  42. package/lib/commands/pg/reset.js +4 -4
  43. package/lib/commands/pg/settings/index.js +2 -2
  44. package/lib/commands/pg/unfollow.js +5 -5
  45. package/lib/commands/pg/upgrade/cancel.js +5 -5
  46. package/lib/commands/pg/upgrade/dryrun.js +5 -5
  47. package/lib/commands/pg/upgrade/index.js +5 -5
  48. package/lib/commands/pg/upgrade/prepare.js +5 -5
  49. package/lib/commands/pg/upgrade/run.js +5 -5
  50. package/lib/commands/pg/upgrade/wait.js +9 -4
  51. package/lib/commands/pg/vacuum-stats.js +5 -4
  52. package/lib/commands/pg/wait.js +6 -4
  53. package/lib/commands/run/detached.d.ts +1 -0
  54. package/lib/commands/run/detached.js +5 -1
  55. package/lib/commands/run/index.d.ts +1 -0
  56. package/lib/commands/run/index.js +7 -2
  57. package/lib/commands/run/inside.js +1 -6
  58. package/lib/lib/addons/resolve.d.ts +6 -7
  59. package/lib/lib/pg/backups.js +4 -4
  60. package/lib/lib/pg/fetcher.d.ts +3 -34
  61. package/lib/lib/pg/fetcher.js +3 -92
  62. package/lib/lib/pg/psql.d.ts +5 -36
  63. package/lib/lib/pg/psql.js +17 -195
  64. package/lib/lib/pg/push_pull.d.ts +2 -7
  65. package/lib/lib/pg/push_pull.js +9 -7
  66. package/lib/lib/pg/setter.js +3 -3
  67. package/lib/lib/pg/types.d.ts +10 -15
  68. package/lib/lib/pg/util.d.ts +6 -32
  69. package/lib/lib/pg/util.js +3 -70
  70. package/lib/lib/run/helpers.d.ts +10 -0
  71. package/lib/lib/run/helpers.js +22 -1
  72. package/oclif.manifest.json +42 -30
  73. package/package.json +5 -7
  74. package/lib/lib/pg/bastion.d.ts +0 -29
  75. package/lib/lib/pg/bastion.js +0 -121
  76. package/lib/lib/pg/config.d.ts +0 -2
  77. package/lib/lib/pg/config.js +0 -13
  78. package/lib/lib/pg/host.d.ts +0 -1
  79. package/lib/lib/pg/host.js +0 -6
@@ -5,7 +5,7 @@ const core_1 = require("@oclif/core");
5
5
  const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
6
6
  const resolve_1 = require("../../../lib/addons/resolve");
7
7
  const util_1 = require("../../../lib/pg/util");
8
- const host_1 = require("../../../lib/pg/host");
8
+ const heroku_cli_util_2 = require("@heroku/heroku-cli-util");
9
9
  const nls_1 = require("../../../nls");
10
10
  class Index extends command_1.Command {
11
11
  async run() {
@@ -15,7 +15,7 @@ class Index extends command_1.Command {
15
15
  const db = await (0, resolve_1.addonResolver)(this.heroku, app, database || 'DATABASE_URL');
16
16
  if ((0, util_1.essentialPlan)(db))
17
17
  core_1.ux.error('You can’t perform this operation on Essential-tier databases.');
18
- const { body: settings } = await this.heroku.get(`/postgres/v0/databases/${db.id}/config`, { hostname: (0, host_1.default)() });
18
+ const { body: settings } = await this.heroku.get(`/postgres/v0/databases/${db.id}/config`, { hostname: heroku_cli_util_2.utils.pg.host() });
19
19
  heroku_cli_util_1.hux.styledHeader(db.name);
20
20
  const remapped = {};
21
21
  Object.keys(settings).forEach(k => {
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
- const fetcher_1 = require("../../lib/pg/fetcher");
7
- const host_1 = require("../../lib/pg/host");
6
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
8
7
  const util_1 = require("../../lib/pg/util");
9
8
  const confirmCommand_1 = require("../../lib/confirmCommand");
10
9
  const tsheredoc_1 = require("tsheredoc");
@@ -13,8 +12,9 @@ class Unfollow extends command_1.Command {
13
12
  async run() {
14
13
  const { flags, args } = await this.parse(Unfollow);
15
14
  const { app, confirm } = flags;
16
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, args.database);
17
- const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
15
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
16
+ const { addon: db } = await dbResolver.getAttachment(app, args.database);
17
+ const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
18
18
  if (!replica.following)
19
19
  core_1.ux.error(`${color_1.default.addon(db.name)} is not a follower`);
20
20
  const { body: configVars } = await this.heroku.get(`/apps/${app}/config-vars`);
@@ -24,7 +24,7 @@ class Unfollow extends command_1.Command {
24
24
  ${color_1.default.addon(db.name)} will become writeable and no longer follow ${origin}. This cannot be undone.
25
25
  `));
26
26
  core_1.ux.action.start(`${color_1.default.addon(db.name)} unfollowing`);
27
- await this.heroku.put(`/client/v11/databases/${db.id}/unfollow`, { hostname: (0, host_1.default)() });
27
+ await this.heroku.put(`/client/v11/databases/${db.id}/unfollow`, { hostname: heroku_cli_util_1.utils.pg.host() });
28
28
  core_1.ux.action.stop();
29
29
  }
30
30
  }
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const confirmCommand_1 = require("../../../lib/confirmCommand");
11
10
  const nls_1 = require("../../../nls");
@@ -14,12 +13,13 @@ class Upgrade extends command_1.Command {
14
13
  const { flags, args } = await this.parse(Upgrade);
15
14
  const { app, confirm } = flags;
16
15
  const { database } = args;
17
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
16
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
17
+ const { addon: db } = await dbResolver.getAttachment(app, database);
18
18
  if ((0, util_1.legacyEssentialPlan)(db))
19
19
  core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
20
20
  if ((0, util_1.essentialNumPlan)(db))
21
21
  core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:cancel')} on Essential-tier databases. You can only use this command on Standard-tier and higher leader databases.`);
22
- const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
22
+ const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
23
23
  if (replica.following)
24
24
  core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:cancel')} on follower databases. You can only use this command on Standard-tier and higher leader databases.`);
25
25
  await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
@@ -30,7 +30,7 @@ class Upgrade extends command_1.Command {
30
30
  `));
31
31
  try {
32
32
  core_1.ux.action.start(`Cancelling upgrade on ${color_1.default.addon(db.name)}`);
33
- const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/cancel`, { hostname: (0, host_1.default)(), body: {} });
33
+ const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/cancel`, { hostname: heroku_cli_util_1.utils.pg.host(), body: {} });
34
34
  core_1.ux.action.stop('done\n' + (0, util_1.formatResponseWithCommands)(response.body.message));
35
35
  }
36
36
  catch (error) {
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const confirmCommand_1 = require("../../../lib/confirmCommand");
11
10
  const nls_1 = require("../../../nls");
@@ -14,13 +13,14 @@ class Upgrade extends command_1.Command {
14
13
  const { flags, args } = await this.parse(Upgrade);
15
14
  const { app, version, confirm } = flags;
16
15
  const { database } = args;
17
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
16
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
17
+ const { addon: db } = await dbResolver.getAttachment(app, database);
18
18
  if ((0, util_1.legacyEssentialPlan)(db))
19
19
  core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
20
20
  if ((0, util_1.essentialNumPlan)(db))
21
21
  core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:dryrun')} on Essential-tier databases. You can only use this command on Standard-tier and higher leader databases.`);
22
22
  const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
23
- const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
23
+ const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
24
24
  if (replica.following)
25
25
  core_1.ux.error(`You can't use ${color_1.default.cmd('pg:upgrade:dryrun')} on follower databases. You can only use this command on Standard-tier and higher leader databases.`);
26
26
  await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
@@ -29,7 +29,7 @@ class Upgrade extends command_1.Command {
29
29
  try {
30
30
  const data = { version };
31
31
  core_1.ux.action.start(`Starting a test upgrade on ${color_1.default.addon(db.name)}`);
32
- const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/dry_run`, { hostname: (0, host_1.default)(), body: data });
32
+ const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/dry_run`, { hostname: heroku_cli_util_1.utils.pg.host(), body: data });
33
33
  core_1.ux.action.stop('done\n' + (0, util_1.formatResponseWithCommands)(response.body.message));
34
34
  }
35
35
  catch (error) {
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const confirmCommand_1 = require("../../../lib/confirmCommand");
11
10
  const nls_1 = require("../../../nls");
@@ -14,11 +13,12 @@ class Upgrade extends command_1.Command {
14
13
  const { flags, args } = await this.parse(Upgrade);
15
14
  const { app, version, confirm } = flags;
16
15
  const { database } = args;
17
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
16
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
17
+ const { addon: db } = await dbResolver.getAttachment(app, database);
18
18
  if ((0, util_1.legacyEssentialPlan)(db))
19
19
  core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade')} on Essential-tier databases and follower databases on Standard-tier and higher plans.`);
20
20
  const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
21
- const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
21
+ const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
22
22
  if (replica.following) {
23
23
  const { body: configVars } = await this.heroku.get(`/apps/${app}/config-vars`);
24
24
  const origin = (0, util_1.databaseNameFromUrl)(replica.following, configVars);
@@ -49,7 +49,7 @@ class Upgrade extends command_1.Command {
49
49
  try {
50
50
  const data = { version };
51
51
  core_1.ux.action.start(`Starting upgrade on ${color_1.default.addon(db.name)}`);
52
- const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade`, { hostname: (0, host_1.default)(), body: data });
52
+ const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade`, { hostname: heroku_cli_util_1.utils.pg.host(), body: data });
53
53
  core_1.ux.action.stop((0, tsheredoc_1.default)(`done\n${(0, util_1.formatResponseWithCommands)(response.body.message)}`));
54
54
  }
55
55
  catch (error) {
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const confirmCommand_1 = require("../../../lib/confirmCommand");
11
10
  const nls_1 = require("../../../nls");
@@ -14,13 +13,14 @@ class Upgrade extends command_1.Command {
14
13
  const { flags, args } = await this.parse(Upgrade);
15
14
  const { app, version, confirm } = flags;
16
15
  const { database } = args;
17
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
16
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
17
+ const { addon: db } = await dbResolver.getAttachment(app, database);
18
18
  if ((0, util_1.legacyEssentialPlan)(db))
19
19
  core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
20
20
  if ((0, util_1.essentialNumPlan)(db))
21
21
  core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade:prepare')} on Standard-tier and higher leader databases. For Essential-tier databases, use ${color_1.default.cmd('heroku pg:upgrade:run')} instead.`);
22
22
  const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
23
- const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
23
+ const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
24
24
  if (replica.following)
25
25
  core_1.ux.error(`You can only use ${color_1.default.cmd('heroku pg:upgrade:prepare')} on Standard-tier and higher leader databases. For follower databases, use ${color_1.default.cmd('heroku pg:upgrade:run')} instead.`);
26
26
  await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
@@ -30,7 +30,7 @@ class Upgrade extends command_1.Command {
30
30
  try {
31
31
  const data = { version };
32
32
  core_1.ux.action.start(`Preparing upgrade on ${color_1.default.addon(db.name)}`);
33
- const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/prepare`, { hostname: (0, host_1.default)(), body: data });
33
+ const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/prepare`, { hostname: heroku_cli_util_1.utils.pg.host(), body: data });
34
34
  core_1.ux.action.stop((0, tsheredoc_1.default)(`done\n${(0, util_1.formatResponseWithCommands)(response.body.message)}`));
35
35
  }
36
36
  catch (error) {
@@ -4,8 +4,7 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const fetcher_1 = require("../../../lib/pg/fetcher");
8
- const host_1 = require("../../../lib/pg/host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
9
8
  const util_1 = require("../../../lib/pg/util");
10
9
  const confirmCommand_1 = require("../../../lib/confirmCommand");
11
10
  const nls_1 = require("../../../nls");
@@ -14,11 +13,12 @@ class Upgrade extends command_1.Command {
14
13
  const { flags, args } = await this.parse(Upgrade);
15
14
  const { app, version, confirm } = flags;
16
15
  const { database } = args;
17
- const db = await (0, fetcher_1.getAddon)(this.heroku, app, database);
16
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
17
+ const { addon: db } = await dbResolver.getAttachment(app, database);
18
18
  if ((0, util_1.legacyEssentialPlan)(db))
19
19
  core_1.ux.error(`You can only use ${color_1.default.cmd('pg:upgrade:*')} commands on Essential-* and higher plans.`);
20
20
  const versionPhrase = version ? (0, tsheredoc_1.default)(`Postgres version ${version}`) : (0, tsheredoc_1.default)('the latest supported Postgres version');
21
- const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: (0, host_1.default)() });
21
+ const { body: replica } = await this.heroku.get(`/client/v11/databases/${db.id}`, { hostname: heroku_cli_util_1.utils.pg.host() });
22
22
  if ((0, util_1.essentialNumPlan)(db)) {
23
23
  await (0, confirmCommand_1.default)(app, confirm, (0, tsheredoc_1.default)(`
24
24
  Destructive action
@@ -48,7 +48,7 @@ class Upgrade extends command_1.Command {
48
48
  try {
49
49
  const data = { version };
50
50
  core_1.ux.action.start(`Starting upgrade on ${color_1.default.addon(db.name)}`);
51
- const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/run`, { hostname: (0, host_1.default)(), body: data });
51
+ const response = await this.heroku.post(`/client/v11/databases/${db.id}/upgrade/run`, { hostname: heroku_cli_util_1.utils.pg.host(), body: data });
52
52
  core_1.ux.action.stop((0, tsheredoc_1.default)(`done\n${(0, util_1.formatResponseWithCommands)(response.body.message)}`));
53
53
  }
54
54
  catch (error) {
@@ -5,8 +5,7 @@ const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const debug_1 = require("debug");
7
7
  const tsheredoc_1 = require("tsheredoc");
8
- const fetcher_1 = require("../../../lib/pg/fetcher");
9
- const host_1 = require("../../../lib/pg/host");
8
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
10
9
  const notify_1 = require("../../../lib/notify");
11
10
  const http_call_1 = require("@heroku/http-call");
12
11
  const nls_1 = require("../../../nls");
@@ -28,7 +27,7 @@ class Wait extends command_1.Command {
28
27
  const notFoundMessage = 'Waiting to provision...';
29
28
  while (true) {
30
29
  try {
31
- ({ body: status } = await this.heroku.get(`/client/v11/databases/${db.id}/upgrade/wait_status`, { hostname: (0, host_1.default)() }));
30
+ ({ body: status } = await this.heroku.get(`/client/v11/databases/${db.id}/upgrade/wait_status`, { hostname: heroku_cli_util_1.utils.pg.host() }));
32
31
  }
33
32
  catch (error) {
34
33
  if (error instanceof http_call_1.HTTPError && (!retries || error.statusCode !== 404)) {
@@ -63,9 +62,15 @@ class Wait extends command_1.Command {
63
62
  await wait(interval * 1000);
64
63
  }
65
64
  };
65
+ // This is actually incorrect, if we're only using one db we should make the database arg required and
66
+ // just use the resolver to get the add-on to be waited on.
67
+ // This looks similar to other implementations where you also can wait on all databases from the same app.
68
+ // Maybe it was initially thought to implement this in the future, but it was never implemented.
66
69
  let dbs = [];
67
70
  if (dbName) {
68
- dbs = [await (0, fetcher_1.getAddon)(this.heroku, app, dbName)];
71
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
72
+ const { addon } = await dbResolver.getAttachment(app, dbName);
73
+ dbs = [addon];
69
74
  }
70
75
  else {
71
76
  core_1.ux.error((0, tsheredoc_1.default)('You must provide a database. Run `--help` for more information on the command.'));
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const command_1 = require("@heroku-cli/command");
4
4
  const core_1 = require("@oclif/core");
5
- const fetcher_1 = require("../../lib/pg/fetcher");
6
- const psql_1 = require("../../lib/pg/psql");
5
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
6
  const tsheredoc_1 = require("tsheredoc");
8
7
  const nls_1 = require("../../nls");
9
8
  class VacuumStats extends command_1.Command {
10
9
  async run() {
11
10
  const { flags, args } = await this.parse(VacuumStats);
12
- const db = await (0, fetcher_1.database)(this.heroku, flags.app, args.database);
11
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
12
+ const db = await dbResolver.getDatabase(flags.app, args.database);
13
+ const psqlService = new heroku_cli_util_1.utils.pg.PsqlService(db);
13
14
  const query = (0, tsheredoc_1.default)(`
14
15
  WITH table_opts AS (
15
16
  SELECT
@@ -50,7 +51,7 @@ class VacuumStats extends command_1.Command {
50
51
  INNER JOIN vacuum_settings ON pg_class.oid = vacuum_settings.oid
51
52
  ORDER BY 1
52
53
  `);
53
- const output = await (0, psql_1.exec)(db, query);
54
+ const output = await psqlService.execQuery(query);
54
55
  core_1.ux.log(output);
55
56
  }
56
57
  }
@@ -4,8 +4,8 @@ const color_1 = require("@heroku-cli/color");
4
4
  const command_1 = require("@heroku-cli/command");
5
5
  const core_1 = require("@oclif/core");
6
6
  const debug_1 = require("debug");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
7
8
  const fetcher_1 = require("../../lib/pg/fetcher");
8
- const host_1 = require("../../lib/pg/host");
9
9
  const notify_1 = require("../../lib/notify");
10
10
  const nls_1 = require("../../nls");
11
11
  const wait = (ms) => new Promise(resolve => {
@@ -27,7 +27,7 @@ class Wait extends command_1.Command {
27
27
  const notFoundMessage = 'Waiting to provision...';
28
28
  while (true) {
29
29
  try {
30
- ({ body: status } = await this.heroku.get(`/client/v11/databases/${db.id}/wait_status`, { hostname: (0, host_1.default)() }));
30
+ ({ body: status } = await this.heroku.get(`/client/v11/databases/${db.id}/wait_status`, { hostname: heroku_cli_util_1.utils.pg.host() }));
31
31
  }
32
32
  catch (error) {
33
33
  const httpError = error;
@@ -55,9 +55,11 @@ class Wait extends command_1.Command {
55
55
  await wait(interval * 1000);
56
56
  }
57
57
  };
58
- let dbs = [];
58
+ let dbs;
59
59
  if (dbName) {
60
- dbs = [await (0, fetcher_1.getAddon)(this.heroku, app, dbName)];
60
+ const dbResolver = new heroku_cli_util_1.utils.pg.DatabaseResolver(this.heroku);
61
+ const { addon } = await dbResolver.getAttachment(app, dbName);
62
+ dbs = [addon];
61
63
  }
62
64
  else {
63
65
  dbs = await (0, fetcher_1.all)(this.heroku, app);
@@ -10,6 +10,7 @@ export default class RunDetached extends Command {
10
10
  size: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
11
11
  tail: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
12
  type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
13
+ 'no-launcher': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
14
  };
14
15
  run(): Promise<void>;
15
16
  }
@@ -14,7 +14,7 @@ class RunDetached extends command_1.Command {
14
14
  const opts = {
15
15
  heroku: this.heroku,
16
16
  app: flags.app,
17
- command: (0, helpers_1.buildCommand)(argv),
17
+ command: await (0, helpers_1.buildCommandWithLauncher)(this.heroku, flags.app, argv, flags['no-launcher']),
18
18
  size: flags.size,
19
19
  type: flags.type,
20
20
  env: flags.env,
@@ -50,4 +50,8 @@ RunDetached.flags = {
50
50
  size: command_1.flags.string({ char: 's', description: 'dyno size', completion: completions_1.DynoSizeCompletion }),
51
51
  tail: command_1.flags.boolean({ char: 't', description: 'continually stream logs' }),
52
52
  type: command_1.flags.string({ description: 'process type', completion: completions_1.ProcessTypeCompletion }),
53
+ 'no-launcher': command_1.flags.boolean({
54
+ description: 'don’t prepend ‘launcher’ before a command',
55
+ default: false,
56
+ }),
53
57
  };
@@ -13,6 +13,7 @@ export default class Run extends Command {
13
13
  'no-tty': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
14
  listen: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
15
  'no-notify': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
+ 'no-launcher': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
17
  };
17
18
  run(): Promise<void>;
18
19
  }
@@ -11,12 +11,13 @@ class Run extends command_1.Command {
11
11
  async run() {
12
12
  const { argv, flags } = await this.parse(Run);
13
13
  const command = (0, helpers_1.revertSortedArgs)(process.argv, argv);
14
+ const builtCommand = await (0, helpers_1.buildCommandWithLauncher)(this.heroku, flags.app, command, flags['no-launcher']);
14
15
  const opts = {
15
16
  'exit-code': flags['exit-code'],
16
17
  'no-tty': flags['no-tty'],
17
18
  app: flags.app,
18
19
  attach: true,
19
- command: (0, helpers_1.buildCommand)(command),
20
+ command: builtCommand,
20
21
  env: flags.env,
21
22
  heroku: this.heroku,
22
23
  listen: flags.listen,
@@ -45,7 +46,7 @@ class Run extends command_1.Command {
45
46
  }
46
47
  }
47
48
  exports.default = Run;
48
- Run.description = 'run a one-off process inside a heroku dyno\nShows a notification if the dyno takes more than 20 seconds to start.';
49
+ Run.description = 'run a one-off process inside a heroku dyno\nShows a notification if the dyno takes more than 20 seconds to start.\nHeroku automatically prepends ‘launcher’ to the command on CNB apps (use --no-launcher to disable).';
49
50
  Run.examples = [
50
51
  '$ heroku run bash',
51
52
  '$ heroku run -s standard-2x -- myscript.sh -a arg1 -s arg2',
@@ -62,4 +63,8 @@ Run.flags = {
62
63
  'no-tty': command_1.flags.boolean({ description: 'force the command to not run in a tty' }),
63
64
  listen: command_1.flags.boolean({ description: 'listen on a local port', hidden: true }),
64
65
  'no-notify': command_1.flags.boolean({ description: 'disables notification when dyno is up (alternatively use HEROKU_NOTIFICATIONS=0)' }),
66
+ 'no-launcher': command_1.flags.boolean({
67
+ description: 'don’t prepend ‘launcher’ before a command',
68
+ default: false,
69
+ }),
65
70
  };
@@ -12,14 +12,9 @@ class RunInside extends command_1.Command {
12
12
  const { args, argv, flags } = await this.parse(RunInside);
13
13
  const { dyno_name: dynoName } = args;
14
14
  const { app: appName, 'exit-code': exitCode, listen, 'no-launcher': noLauncher } = flags;
15
- const prependLauncher = !noLauncher;
16
- const { body: app } = await this.heroku.get(`/apps/${appName}`, {
17
- headers: { Accept: 'application/vnd.heroku+json; version=3.sdk' },
18
- });
19
- const appStackIsCnb = app.stack.name === 'cnb';
20
15
  const opts = {
21
16
  app: appName,
22
- command: (0, helpers_1.buildCommand)(argv.slice(1), appStackIsCnb && prependLauncher),
17
+ command: await (0, helpers_1.buildCommandWithLauncher)(this.heroku, appName, argv.slice(1), noLauncher),
23
18
  dyno: dynoName,
24
19
  'exit-code': exitCode,
25
20
  heroku: this.heroku,
@@ -1,21 +1,20 @@
1
1
  import { APIClient } from '@heroku-cli/command';
2
2
  import type { AddOnAttachment } from '@heroku-cli/schema';
3
- import type { AddOnAttachmentWithConfigVarsAndPlan } from '../pg/types';
4
- export declare const appAddon: (heroku: APIClient, app: string, id: string, options?: AddOnAttachment) => Promise<AddOnAttachmentWithConfigVarsAndPlan>;
5
- export declare const addonResolver: (heroku: APIClient, app: string | undefined, id: string, options?: AddOnAttachment) => Promise<AddOnAttachmentWithConfigVarsAndPlan>;
3
+ import type { ExtendedAddon } from '../pg/types';
4
+ import type { ExtendedAddonAttachment } from '@heroku/heroku-cli-util';
5
+ export declare const appAddon: (heroku: APIClient, app: string, id: string, options?: AddOnAttachment) => Promise<ExtendedAddon>;
6
+ export declare const addonResolver: (heroku: APIClient, app: string | undefined, id: string, options?: AddOnAttachment) => Promise<ExtendedAddon>;
6
7
  export declare const appAttachment: (heroku: APIClient, app: string | undefined, id: string, options?: {
7
8
  addon_service?: string;
8
9
  namespace?: string;
9
- }) => Promise<AddOnAttachment & {
10
- addon: AddOnAttachmentWithConfigVarsAndPlan;
11
- }>;
10
+ }) => Promise<ExtendedAddonAttachment>;
12
11
  export declare const attachmentResolver: (heroku: APIClient, app: string | undefined, id: string, options?: {
13
12
  addon_service?: string;
14
13
  namespace?: string;
15
14
  }) => Promise<void | AddOnAttachment>;
16
15
  export declare function resolveAddon(...args: Parameters<typeof addonResolver>): ReturnType<typeof addonResolver>;
17
16
  export declare namespace resolveAddon {
18
- var cache: Map<string, Promise<AddOnAttachmentWithConfigVarsAndPlan>>;
17
+ var cache: Map<string, Promise<ExtendedAddon>>;
19
18
  }
20
19
  export declare class NotFound extends Error {
21
20
  readonly statusCode = 404;
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const color_1 = require("@heroku-cli/color");
5
5
  const core_1 = require("@oclif/core");
6
6
  const tsheredoc_1 = require("tsheredoc");
7
- const host_1 = require("./host");
7
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
8
8
  const bytes = require("bytes");
9
9
  function prefix(transfer) {
10
10
  if (transfer.from_type === 'pg_dump') {
@@ -46,7 +46,7 @@ class Backups {
46
46
  return Number.parseInt(m[1], 10);
47
47
  m = name.match(/^o[ab]\d+$/);
48
48
  if (m) {
49
- const { body: transfers } = await this.heroku.get(`/client/v11/apps/${this.app}/transfers`, { hostname: (0, host_1.default)() });
49
+ const { body: transfers } = await this.heroku.get(`/client/v11/apps/${this.app}/transfers`, { hostname: heroku_cli_util_1.utils.pg.host() });
50
50
  const transfer = transfers.find(t => this.name(t) === name);
51
51
  if (transfer)
52
52
  return transfer.num;
@@ -117,7 +117,7 @@ class Backups {
117
117
  const url = verbose ? verboseUrl : quietUrl;
118
118
  while (failures < 21) {
119
119
  try {
120
- ({ body: backup } = yield tslib_1.__await(this.heroku.get(url, { hostname: (0, host_1.default)() })));
120
+ ({ body: backup } = yield tslib_1.__await(this.heroku.get(url, { hostname: heroku_cli_util_1.utils.pg.host() })));
121
121
  }
122
122
  catch (error) {
123
123
  if (failures++ > 20) {
@@ -143,7 +143,7 @@ class Backups {
143
143
  break;
144
144
  }
145
145
  // logs is undefined unless verbose=true is passed
146
- ({ body: backup } = yield tslib_1.__await(this.heroku.get(verboseUrl, { hostname: (0, host_1.default)() })));
146
+ ({ body: backup } = yield tslib_1.__await(this.heroku.get(verboseUrl, { hostname: heroku_cli_util_1.utils.pg.host() })));
147
147
  throw new Error((0, tsheredoc_1.default)(`
148
148
  An error occurred and the backup did not finish.
149
149
 
@@ -1,39 +1,8 @@
1
1
  import { APIClient } from '@heroku-cli/command';
2
- import type { AddOnAttachment } from '@heroku-cli/schema';
3
2
  import * as Heroku from '@heroku-cli/schema';
4
- import type { AddOnAttachmentWithConfigVarsAndPlan, AddOnWithRelatedData } from './types';
3
+ import { ExtendedAddonAttachment } from '@heroku/heroku-cli-util';
5
4
  export declare function arbitraryAppDB(heroku: APIClient, app: string): Promise<Heroku.AddOn>;
6
- export declare function all(heroku: APIClient, app_id: string): Promise<AddOnWithRelatedData[]>;
7
- export declare function getAttachment(heroku: APIClient, app: string, db?: string, namespace?: string): Promise<Required<AddOnAttachment & {
8
- addon: AddOnAttachmentWithConfigVarsAndPlan;
5
+ export declare function all(heroku: APIClient, app_id: string): Promise<Array<ExtendedAddonAttachment['addon'] & {
6
+ attachment_names?: string[];
9
7
  }>>;
10
- export declare function getAddon(heroku: APIClient, app: string, db?: string): Promise<{
11
- id: string;
12
- name: string;
13
- app: {
14
- [k: string]: any;
15
- id?: string | undefined;
16
- name?: string | undefined;
17
- };
18
- } & Required<AddOnAttachment> & {
19
- config_vars: string[] | undefined;
20
- addon: Required<{
21
- id: string;
22
- name: string;
23
- app: {
24
- [k: string]: any;
25
- id?: string | undefined;
26
- name?: string | undefined;
27
- };
28
- }> & {
29
- attachment_names?: string[] | undefined;
30
- links?: import("./types").Link[] | undefined;
31
- plan: Required<{
32
- [k: string]: any;
33
- id?: string | undefined;
34
- name?: string | undefined;
35
- } | undefined>;
36
- };
37
- }>;
38
- export declare function database(heroku: APIClient, app: string, db?: string, namespace?: string): Promise<import("./util").ConnectionDetailsWithAttachment>;
39
8
  export declare function getRelease(heroku: APIClient, appName: string, id: string): Promise<Heroku.Release>;