heroku 10.13.2 → 10.14.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 +430 -418
  73. package/package.json +4 -6
  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
@@ -1,20 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePostgresConnectionString = exports.databaseNameFromUrl = exports.configVarNamesFromValue = exports.bastionKeyPlan = exports.getConnectionDetails = exports.presentCredentialAttachments = exports.formatResponseWithCommands = exports.getConfigVarNameFromAttachment = exports.essentialPlan = exports.legacyEssentialPlan = exports.essentialNumPlan = exports.getConfigVarName = void 0;
3
+ exports.databaseNameFromUrl = exports.configVarNamesFromValue = exports.presentCredentialAttachments = exports.formatResponseWithCommands = exports.essentialPlan = exports.legacyEssentialPlan = exports.essentialNumPlan = void 0;
4
4
  const color_1 = require("@heroku-cli/color");
5
5
  const core_1 = require("@oclif/core");
6
- const debug_1 = require("debug");
7
6
  const addons_1 = require("../../commands/addons");
8
7
  const multisort_1 = require("../utils/multisort");
9
- const bastion_1 = require("./bastion");
10
- const process_1 = require("process");
11
- function getConfigVarName(configVars) {
12
- const connStringVars = configVars.filter(cv => (cv.endsWith('_URL')));
13
- if (connStringVars.length === 0)
14
- throw new Error('Database URL not found for this addon');
15
- return connStringVars[0];
16
- }
17
- exports.getConfigVarName = getConfigVarName;
8
+ const heroku_cli_util_1 = require("@heroku/heroku-cli-util");
18
9
  const essentialNumPlan = (addon) => { var _a, _b; return Boolean((_b = (_a = addon === null || addon === void 0 ? void 0 : addon.plan) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.split(':')[1].match(/^essential/)); };
19
10
  exports.essentialNumPlan = essentialNumPlan;
20
11
  const legacyEssentialPlan = (addon) => { var _a, _b; return Boolean((_b = (_a = addon === null || addon === void 0 ? void 0 : addon.plan) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.split(':')[1].match(/(dev|basic|mini)$/)); };
@@ -23,22 +14,6 @@ function essentialPlan(addon) {
23
14
  return (0, exports.essentialNumPlan)(addon) || (0, exports.legacyEssentialPlan)(addon);
24
15
  }
25
16
  exports.essentialPlan = essentialPlan;
26
- function getConfigVarNameFromAttachment(attachment, config = {}) {
27
- var _a, _b;
28
- const configVars = (_b = (_a = attachment.config_vars) === null || _a === void 0 ? void 0 : _a.filter((cv) => {
29
- var _a;
30
- return (_a = config[cv]) === null || _a === void 0 ? void 0 : _a.startsWith('postgres://');
31
- })) !== null && _b !== void 0 ? _b : [];
32
- if (configVars.length === 0) {
33
- core_1.ux.error(`No config vars found for ${attachment.name}; perhaps they were removed as a side effect of ${color_1.default.cmd('heroku rollback')}? Use ${color_1.default.cmd('heroku addons:attach')} to create a new attachment and then ${color_1.default.cmd('heroku addons:detach')} to remove the current attachment.`);
34
- }
35
- const configVarName = `${attachment.name}_URL`;
36
- if (configVars.includes(configVarName) && configVarName in config) {
37
- return configVarName;
38
- }
39
- return getConfigVarName(configVars);
40
- }
41
- exports.getConfigVarNameFromAttachment = getConfigVarNameFromAttachment;
42
17
  function formatResponseWithCommands(response) {
43
18
  return response.replace(/`(.*?)`/g, (_, word) => color_1.default.cmd(word));
44
19
  }
@@ -102,33 +77,6 @@ function presentCredentialAttachments(app, credAttachments, credentials, cred) {
102
77
  return [cred, ...attLines, ...rotationLines].join('\n');
103
78
  }
104
79
  exports.presentCredentialAttachments = presentCredentialAttachments;
105
- const getConnectionDetails = (attachment, configVars = {}) => {
106
- const connStringVar = getConfigVarNameFromAttachment(attachment, configVars);
107
- // remove _URL from the end of the config var name
108
- const baseName = connStringVar.slice(0, -4);
109
- // build the default payload for non-bastion dbs
110
- (0, debug_1.default)(`Using "${connStringVar}" to connect to your database…`);
111
- const conn = (0, exports.parsePostgresConnectionString)(configVars[connStringVar]);
112
- const payload = {
113
- user: conn.user,
114
- password: conn.password,
115
- database: conn.database,
116
- host: conn.host,
117
- port: conn.port,
118
- pathname: conn.pathname,
119
- url: conn.url,
120
- attachment,
121
- };
122
- // If bastion creds exist, graft it into the payload
123
- const bastion = (0, bastion_1.getBastion)(configVars, baseName);
124
- if (bastion) {
125
- Object.assign(payload, bastion);
126
- }
127
- return payload;
128
- };
129
- exports.getConnectionDetails = getConnectionDetails;
130
- const bastionKeyPlan = (a) => Boolean(a.plan.name.match(/private/));
131
- exports.bastionKeyPlan = bastionKeyPlan;
132
80
  const configVarNamesFromValue = (config, value) => {
133
81
  const keys = [];
134
82
  for (const key of Object.keys(config)) {
@@ -166,22 +114,7 @@ const databaseNameFromUrl = (uri, config) => {
166
114
  if (name) {
167
115
  return color_1.default.configVar(name.replace(/_URL$/, ''));
168
116
  }
169
- const conn = (0, exports.parsePostgresConnectionString)(uri);
117
+ const conn = heroku_cli_util_1.utils.pg.DatabaseResolver.parsePostgresConnectionString(uri);
170
118
  return `${conn.host}:${conn.port}${conn.pathname}`;
171
119
  };
172
120
  exports.databaseNameFromUrl = databaseNameFromUrl;
173
- const parsePostgresConnectionString = (db) => {
174
- const dbPath = db.match(/:\/\//) ? db : `postgres:///${db}`;
175
- const url = new URL(dbPath);
176
- const { username, password, hostname, pathname, port } = url;
177
- return {
178
- user: username,
179
- password,
180
- database: pathname.charAt(0) === '/' ? pathname.slice(1) : pathname,
181
- host: hostname,
182
- port: port || process_1.env.PGPORT || (hostname && '5432'),
183
- pathname,
184
- url: dbPath,
185
- };
186
- };
187
- exports.parsePostgresConnectionString = parsePostgresConnectionString;
@@ -1,3 +1,13 @@
1
+ import type { APIClient } from '@heroku-cli/command';
1
2
  export declare function revertSortedArgs(processArgs: Array<string>, argv: Array<string>): string[];
2
3
  export declare function buildCommand(args: Array<string>, prependLauncher?: boolean): string;
3
4
  export declare function buildEnvFromFlag(flag: string): {};
5
+ /**
6
+ * Determines whether to prepend `launcher` to the command for a given app.
7
+ * Behavior: Only prepend on CNB stack apps and when not explicitly disabled.
8
+ */
9
+ export declare function shouldPrependLauncher(heroku: APIClient, appName: string, disableLauncher: boolean): Promise<boolean>;
10
+ /**
11
+ * Builds the command string, automatically deciding whether to prepend `launcher`.
12
+ */
13
+ export declare function buildCommandWithLauncher(heroku: APIClient, appName: string, args: string[], disableLauncher: boolean): Promise<string>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildEnvFromFlag = exports.buildCommand = exports.revertSortedArgs = void 0;
3
+ exports.buildCommandWithLauncher = exports.shouldPrependLauncher = exports.buildEnvFromFlag = exports.buildCommand = exports.revertSortedArgs = void 0;
4
4
  /* eslint-disable @typescript-eslint/ban-ts-comment */
5
5
  const core_1 = require("@oclif/core");
6
6
  // this function exists because oclif sorts argv
@@ -56,3 +56,24 @@ function buildEnvFromFlag(flag) {
56
56
  return env;
57
57
  }
58
58
  exports.buildEnvFromFlag = buildEnvFromFlag;
59
+ /**
60
+ * Determines whether to prepend `launcher` to the command for a given app.
61
+ * Behavior: Only prepend on CNB stack apps and when not explicitly disabled.
62
+ */
63
+ async function shouldPrependLauncher(heroku, appName, disableLauncher) {
64
+ if (disableLauncher)
65
+ return false;
66
+ const { body: app } = await heroku.get(`/apps/${appName}`, {
67
+ headers: { Accept: 'application/vnd.heroku+json; version=3.sdk' },
68
+ });
69
+ return (app.stack && app.stack.name) === 'cnb';
70
+ }
71
+ exports.shouldPrependLauncher = shouldPrependLauncher;
72
+ /**
73
+ * Builds the command string, automatically deciding whether to prepend `launcher`.
74
+ */
75
+ async function buildCommandWithLauncher(heroku, appName, args, disableLauncher) {
76
+ const prependLauncher = await shouldPrependLauncher(heroku, appName, disableLauncher);
77
+ return buildCommand(args, prependLauncher);
78
+ }
79
+ exports.buildCommandWithLauncher = buildCommandWithLauncher;