heroku 10.0.0 → 10.0.1-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.
@@ -7,7 +7,7 @@ const resolve_1 = require("../../lib/addons/resolve");
7
7
  const fs = require("node:fs/promises");
8
8
  const os = require("node:os");
9
9
  const path = require("node:path");
10
- const http_call_1 = require("http-call");
10
+ const http_call_1 = require("@heroku/http-call");
11
11
  const open = require("open");
12
12
  class Open extends command_1.Command {
13
13
  constructor() {
@@ -3,11 +3,11 @@ 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 lodash_1 = require("lodash");
7
6
  const confirmCommand_1 = require("../../lib/confirmCommand");
8
7
  const git = require("../../lib/ci/git");
9
8
  class Destroy extends command_1.Command {
10
9
  async run() {
10
+ var _a, _b;
11
11
  const { flags, args } = await this.parse(Destroy);
12
12
  const app = args.app || flags.app;
13
13
  if (!app)
@@ -17,18 +17,18 @@ class Destroy extends command_1.Command {
17
17
  await (0, confirmCommand_1.default)(app, flags.confirm, `WARNING: This will delete ${color_1.default.app(app)} including all add-ons.`);
18
18
  core_1.ux.action.start(`Destroying ${color_1.default.app(app)} (including all add-ons)`);
19
19
  await this.heroku.delete(`/apps/${app}`);
20
+ /**
21
+ * It is possible to have as many git remotes as
22
+ * you want, and they can all point to the same url.
23
+ * The only requirement is that the "name" is unique.
24
+ */
20
25
  if (git.inGitRepo()) {
21
26
  // delete git remotes pointing to this app
22
- await git.listRemotes()
23
- .then(remotes => {
24
- const transformed = remotes
25
- .filter(r => git.gitUrl(app) === r[1] || git.sshGitUrl(app) === r[1])
26
- .map(r => r[0]);
27
- const uniqueRemotes = (0, lodash_1.uniq)(transformed);
28
- uniqueRemotes.forEach(element => {
29
- git.rmRemote(element);
30
- });
31
- });
27
+ const remotes = await git.listRemotes();
28
+ await Promise.all([
29
+ (_a = remotes.get(git.gitUrl(app))) === null || _a === void 0 ? void 0 : _a.map(({ name }) => git.rmRemote(name)),
30
+ (_b = remotes.get(git.sshGitUrl(app))) === null || _b === void 0 ? void 0 : _b.map(({ name }) => git.rmRemote(name)),
31
+ ]);
32
32
  }
33
33
  core_1.ux.action.stop();
34
34
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@oclif/core");
4
4
  const command_1 = require("@heroku-cli/command");
5
- const _ = require("lodash");
6
5
  const git = require("../../lib/ci/git");
7
6
  const color_1 = require("@heroku-cli/color");
8
7
  class AppsRename extends command_1.Command {
@@ -20,16 +19,28 @@ class AppsRename extends command_1.Command {
20
19
  core_1.ux.log('Please note that it may take a few minutes for Heroku to provision a SSL certificate for your application.');
21
20
  }
22
21
  if (git.inGitRepo()) {
23
- // delete git remotes pointing to this app
24
- await _(await git.listRemotes())
25
- .filter(r => git.gitUrl(oldApp) === r[1] || git.sshGitUrl(oldApp) === r[1])
26
- .map(r => r[0])
27
- .uniq()
28
- .map(r => {
29
- return git.rmRemote(r)
30
- .then(() => git.createRemote(r, gitUrl))
31
- .then(() => core_1.ux.log(`Git remote ${r} updated`));
32
- }).value();
22
+ /**
23
+ * It is possible to have as many git remotes as
24
+ * you want, and they can all point to the same url.
25
+ * The only requirement is that the "name" is unique.
26
+ */
27
+ const remotes = await git.listRemotes();
28
+ const httpsUrl = git.gitUrl(oldApp);
29
+ const sshUrl = git.sshGitUrl(oldApp);
30
+ const targetRemotesBySSHUrl = remotes.get(sshUrl);
31
+ const targetRemotesByHttpsUrl = remotes.get(httpsUrl);
32
+ const doRename = async (remotes, url) => {
33
+ for (const remote of remotes !== null && remotes !== void 0 ? remotes : []) {
34
+ const { name } = remote;
35
+ await git.rmRemote(name);
36
+ await git.createRemote(name, url.replace(oldApp, newApp));
37
+ core_1.ux.log(`Git remote ${name} updated`);
38
+ }
39
+ };
40
+ await Promise.all([
41
+ doRename(targetRemotesByHttpsUrl, httpsUrl),
42
+ doRename(targetRemotesBySSHUrl, sshUrl),
43
+ ]);
33
44
  }
34
45
  core_1.ux.warn("Don't forget to update git remotes for all other local checkouts of the app.");
35
46
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AmbiguousError = exports.NotFound = exports.resolveAddon = exports.attachmentResolver = exports.appAttachment = exports.addonResolver = exports.appAddon = void 0;
4
- const http_call_1 = require("http-call");
4
+ const http_call_1 = require("@heroku/http-call");
5
5
  const api_client_1 = require("@heroku-cli/command/lib/api-client");
6
6
  const addonHeaders = {
7
7
  Accept: 'application/vnd.heroku+json; version=3.actions',
package/lib/lib/api.d.ts CHANGED
@@ -7,33 +7,33 @@ export declare const FILTERS_HEADER: string;
7
7
  export declare const PIPELINES_HEADER: string;
8
8
  export declare function createAppSetup(heroku: APIClient, body: {
9
9
  body: any;
10
- }): Promise<import("http-call").HTTP<Heroku.AppSetup>>;
11
- export declare function postCoupling(heroku: APIClient, pipeline: any, app: any, stage: string): Promise<import("http-call").HTTP<unknown>>;
12
- export declare function createCoupling(heroku: APIClient, pipeline: any, app: string, stage: string): Promise<import("http-call").HTTP<unknown>>;
13
- export declare function createPipeline(heroku: APIClient, name: any, owner: any): Promise<import("http-call").HTTP<Heroku.Pipeline>>;
14
- export declare function createPipelineTransfer(heroku: APIClient, pipeline: Heroku.Pipeline): Promise<import("http-call").HTTP<unknown>>;
15
- export declare function destroyPipeline(heroku: APIClient, name: any, pipelineId: any): Promise<import("http-call").HTTP<unknown>>;
16
- export declare function findPipelineByName(heroku: APIClient, idOrName: string): Promise<import("http-call").HTTP<Heroku.Pipeline[]>>;
10
+ }): Promise<import("@heroku/http-call").HTTP<Heroku.AppSetup>>;
11
+ export declare function postCoupling(heroku: APIClient, pipeline: any, app: any, stage: string): Promise<import("@heroku/http-call").HTTP<unknown>>;
12
+ export declare function createCoupling(heroku: APIClient, pipeline: any, app: string, stage: string): Promise<import("@heroku/http-call").HTTP<unknown>>;
13
+ export declare function createPipeline(heroku: APIClient, name: any, owner: any): Promise<import("@heroku/http-call").HTTP<Heroku.Pipeline>>;
14
+ export declare function createPipelineTransfer(heroku: APIClient, pipeline: Heroku.Pipeline): Promise<import("@heroku/http-call").HTTP<unknown>>;
15
+ export declare function destroyPipeline(heroku: APIClient, name: any, pipelineId: any): Promise<import("@heroku/http-call").HTTP<unknown>>;
16
+ export declare function findPipelineByName(heroku: APIClient, idOrName: string): Promise<import("@heroku/http-call").HTTP<Heroku.Pipeline[]>>;
17
17
  export interface PipelineCouplingSdk extends Required<PipelineCoupling> {
18
18
  generation: 'fir' | 'cedar';
19
19
  }
20
- export declare function getCoupling(heroku: APIClient, app: string): Promise<import("http-call").HTTP<PipelineCouplingSdk>>;
21
- export declare function getPipeline(heroku: APIClient, id: string): Promise<import("http-call").HTTP<Heroku.Pipeline>>;
22
- export declare function updatePipeline(heroku: APIClient, id: string, body: Heroku.Pipeline): Promise<import("http-call").HTTP<Heroku.Pipeline>>;
23
- export declare function getTeam(heroku: APIClient, teamId: any): Promise<import("http-call").HTTP<Heroku.Team>>;
24
- export declare function getAccountInfo(heroku: APIClient, id?: string): Promise<import("http-call").HTTP<Heroku.Account>>;
25
- export declare function getAppSetup(heroku: APIClient, buildId: any): Promise<import("http-call").HTTP<Heroku.AppSetup>>;
20
+ export declare function getCoupling(heroku: APIClient, app: string): Promise<import("@heroku/http-call").HTTP<PipelineCouplingSdk>>;
21
+ export declare function getPipeline(heroku: APIClient, id: string): Promise<import("@heroku/http-call").HTTP<Heroku.Pipeline>>;
22
+ export declare function updatePipeline(heroku: APIClient, id: string, body: Heroku.Pipeline): Promise<import("@heroku/http-call").HTTP<Heroku.Pipeline>>;
23
+ export declare function getTeam(heroku: APIClient, teamId: any): Promise<import("@heroku/http-call").HTTP<Heroku.Team>>;
24
+ export declare function getAccountInfo(heroku: APIClient, id?: string): Promise<import("@heroku/http-call").HTTP<Heroku.Account>>;
25
+ export declare function getAppSetup(heroku: APIClient, buildId: any): Promise<import("@heroku/http-call").HTTP<Heroku.AppSetup>>;
26
26
  export interface AppWithPipelineCoupling extends App {
27
27
  pipelineCoupling: PipelineCouplingSdk;
28
28
  [k: string]: unknown;
29
29
  }
30
30
  export declare function listPipelineApps(heroku: APIClient, pipelineId: string): Promise<Array<AppWithPipelineCoupling>>;
31
- export declare function patchCoupling(heroku: APIClient, id: string, stage: string): Promise<import("http-call").HTTP<Heroku.PipelineCoupling>>;
32
- export declare function removeCoupling(heroku: APIClient, app: string): Promise<import("http-call").HTTP<unknown>>;
33
- export declare function updateCoupling(heroku: APIClient, app: string, stage: string): Promise<import("http-call").HTTP<Heroku.PipelineCoupling>>;
34
- export declare function getReleases(heroku: APIClient, appId: string): Promise<import("http-call").HTTP<Release[]>>;
35
- export declare function getPipelineConfigVars(heroku: APIClient, pipelineID: string): Promise<import("http-call").HTTP<Heroku.ConfigVars>>;
36
- export declare function setPipelineConfigVars(heroku: APIClient, pipelineID: string, body: Heroku.ConfigVars | Record<string, null>): Promise<import("http-call").HTTP<Heroku.ConfigVars>>;
37
- export declare function createTestRun(heroku: APIClient, body: Heroku.TestRun): Promise<import("http-call").HTTP<Heroku.TestRun>>;
38
- export declare function getTestNodes(heroku: APIClient, testRunIdD: string): Promise<import("http-call").HTTP<Heroku.TestRun>>;
39
- export declare function updateTestRun(heroku: APIClient, id: string, body: Heroku.TestRun): Promise<import("http-call").HTTP<Heroku.TestRun>>;
31
+ export declare function patchCoupling(heroku: APIClient, id: string, stage: string): Promise<import("@heroku/http-call").HTTP<Heroku.PipelineCoupling>>;
32
+ export declare function removeCoupling(heroku: APIClient, app: string): Promise<import("@heroku/http-call").HTTP<unknown>>;
33
+ export declare function updateCoupling(heroku: APIClient, app: string, stage: string): Promise<import("@heroku/http-call").HTTP<Heroku.PipelineCoupling>>;
34
+ export declare function getReleases(heroku: APIClient, appId: string): Promise<import("@heroku/http-call").HTTP<Release[]>>;
35
+ export declare function getPipelineConfigVars(heroku: APIClient, pipelineID: string): Promise<import("@heroku/http-call").HTTP<Heroku.ConfigVars>>;
36
+ export declare function setPipelineConfigVars(heroku: APIClient, pipelineID: string, body: Heroku.ConfigVars | Record<string, null>): Promise<import("@heroku/http-call").HTTP<Heroku.ConfigVars>>;
37
+ export declare function createTestRun(heroku: APIClient, body: Heroku.TestRun): Promise<import("@heroku/http-call").HTTP<Heroku.TestRun>>;
38
+ export declare function getTestNodes(heroku: APIClient, testRunIdD: string): Promise<import("@heroku/http-call").HTTP<Heroku.TestRun>>;
39
+ export declare function updateTestRun(heroku: APIClient, id: string, body: Heroku.TestRun): Promise<import("@heroku/http-call").HTTP<Heroku.TestRun>>;
@@ -7,8 +7,19 @@ declare function readCommit(commit: string): Promise<{
7
7
  }>;
8
8
  declare function sshGitUrl(app: string): string;
9
9
  declare function gitUrl(app?: string): string;
10
- declare function listRemotes(): Promise<string[][]>;
10
+ /**
11
+ * Lists remotes by their url and returns an
12
+ * array of objects containing the name and kind
13
+ *
14
+ * @return A map of remotes whose key is the url
15
+ * and value is an array of objects containing
16
+ * the 'name' (heroku, heroku-dev, etc.) and 'kind' (fetch, push, etc.)
17
+ */
18
+ declare function listRemotes(): Promise<Map<string, {
19
+ name: string;
20
+ kind: string;
21
+ }[]>>;
11
22
  declare function inGitRepo(): true | undefined;
12
- declare function rmRemote(remote: string): Promise<string>;
23
+ declare function rmRemote(remote: string): Promise<void>;
13
24
  declare function createRemote(remote: string, url: string): Promise<string | null>;
14
25
  export { createArchive, githubRepository, readCommit, sshGitUrl, gitUrl, createRemote, listRemotes, rmRemote, inGitRepo, };
package/lib/lib/ci/git.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inGitRepo = exports.rmRemote = exports.listRemotes = exports.createRemote = exports.gitUrl = exports.sshGitUrl = exports.readCommit = exports.githubRepository = exports.createArchive = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const fs = require("fs-extra");
5
6
  const command_1 = require("@heroku-cli/command");
6
7
  const gh = require('github-url-to-object');
@@ -15,6 +16,8 @@ function runGit(...args) {
15
16
  return new Promise((resolve, reject) => {
16
17
  git.on('exit', (exitCode) => {
17
18
  if (exitCode === 0) {
19
+ // not all git commands write data to stdout
20
+ resolve(exitCode.toString(10));
18
21
  return;
19
22
  }
20
23
  const error = (git.stderr.read() || 'unknown error').toString().trim();
@@ -78,8 +81,27 @@ function gitUrl(app) {
78
81
  return `https://${command_1.vars.httpGitHost}/${app}.git`;
79
82
  }
80
83
  exports.gitUrl = gitUrl;
84
+ /**
85
+ * Lists remotes by their url and returns an
86
+ * array of objects containing the name and kind
87
+ *
88
+ * @return A map of remotes whose key is the url
89
+ * and value is an array of objects containing
90
+ * the 'name' (heroku, heroku-dev, etc.) and 'kind' (fetch, push, etc.)
91
+ */
81
92
  async function listRemotes() {
82
- return runGit('remote', '-v').then(remotes => remotes.trim().split('\n').map(r => r.split(/\s/)));
93
+ const gitRemotes = await runGit('remote', '-v');
94
+ const lines = gitRemotes.trim().split('\n');
95
+ const remotes = lines.map(line => line.trim().split(/\s+/)).map(([name, url, kind]) => ({ name, url, kind }));
96
+ const remotesByUrl = new Map();
97
+ remotes.forEach(remote => {
98
+ var _a;
99
+ const { url } = remote, nameAndKind = tslib_1.__rest(remote, ["url"]);
100
+ const entry = (_a = remotesByUrl.get(url)) !== null && _a !== void 0 ? _a : [];
101
+ entry.push(nameAndKind);
102
+ remotesByUrl.set(url, entry);
103
+ });
104
+ return remotesByUrl;
83
105
  }
84
106
  exports.listRemotes = listRemotes;
85
107
  function inGitRepo() {
@@ -93,22 +115,19 @@ function inGitRepo() {
93
115
  }
94
116
  }
95
117
  exports.inGitRepo = inGitRepo;
96
- function rmRemote(remote) {
97
- return runGit('remote', 'rm', remote);
118
+ async function rmRemote(remote) {
119
+ await runGit('remote', 'rm', remote);
98
120
  }
99
121
  exports.rmRemote = rmRemote;
100
- function hasGitRemote(remote) {
101
- return runGit('remote')
102
- .then(remotes => remotes.split('\n'))
103
- .then(remotes => remotes.find(r => r === remote));
122
+ async function hasGitRemote(remote) {
123
+ const remotes = await runGit('remote');
124
+ return remotes.split('\n').find(r => r === remote);
104
125
  }
105
- function createRemote(remote, url) {
106
- return hasGitRemote(remote)
107
- .then(exists => {
108
- if (!exists) {
109
- return runGit('remote', 'add', remote, url);
110
- }
111
- return null;
112
- });
126
+ async function createRemote(remote, url) {
127
+ const exists = await hasGitRemote(remote);
128
+ if (!exists) {
129
+ return runGit('remote', 'add', remote, url);
130
+ }
131
+ return null;
113
132
  }
114
133
  exports.createRemote = createRemote;
@@ -23,7 +23,7 @@ export declare function getConfigs(db: ConnectionDetails): {
23
23
  export declare function sshTunnel(db: ConnectionDetails, dbTunnelConfig: TunnelConfig, timeout?: number): Promise<void | import("net").Server | null>;
24
24
  export declare function fetchConfig(heroku: APIClient, db: {
25
25
  id: string;
26
- }): Promise<import("http-call").HTTP<{
26
+ }): Promise<import("@heroku/http-call").HTTP<{
27
27
  host: string;
28
28
  private_key: string;
29
29
  }>>;
@@ -1,2 +1,2 @@
1
1
  import * as Heroku from '@heroku-cli/schema';
2
- export default function createApps(heroku: any, archiveURL: any, pipeline: any, pipelineName: any, stagingAppName: any, organization: any): Promise<void | import("http-call").HTTP<Heroku.AppSetup>[]>;
2
+ export default function createApps(heroku: any, archiveURL: any, pipeline: any, pipelineName: any, stagingAppName: any, organization: any): Promise<void | import("@heroku/http-call").HTTP<Heroku.AppSetup>[]>;
@@ -57,7 +57,7 @@ export declare type RedisFormationWaitResponse = {
57
57
  };
58
58
  declare type HttpVerb = 'GET' | 'POST' | 'PATCH' | 'DELETE' | 'PUT';
59
59
  declare const _default: (app: string, database: string | undefined, json: boolean, heroku: APIClient) => {
60
- request<T>(path: string, method?: HttpVerb, body?: {}): Promise<import("http-call").HTTP<T>>;
60
+ request<T>(path: string, method?: HttpVerb, body?: {}): Promise<import("@heroku/http-call").HTTP<T>>;
61
61
  makeAddonsFilter(filter: string | undefined): (addons: Required<Heroku.AddOn>[]) => Required<Heroku.AddOn>[];
62
62
  getRedisAddon(addons?: Required<Heroku.AddOn>[]): Promise<Required<Heroku.AddOn>>;
63
63
  info(): Promise<void>;