heroku 8.1.9 → 8.2.0-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 (314) hide show
  1. package/autocomplete-scripts/README.md +7 -0
  2. package/autocomplete-scripts/bash/heroku.bash +59 -0
  3. package/autocomplete-scripts/brew/bash +4 -0
  4. package/autocomplete-scripts/brew/zsh/_heroku +59 -0
  5. package/autocomplete-scripts/zsh/_heroku +53 -0
  6. package/bin/bats-test-runner.js +7 -0
  7. package/bin/dev +17 -0
  8. package/bin/dev.cmd +3 -0
  9. package/bin/run +36 -1
  10. package/lib/analytics.d.ts +2 -2
  11. package/lib/analytics.js +3 -4
  12. package/lib/commands/auth/2fa/disable.d.ts +7 -0
  13. package/lib/commands/auth/2fa/disable.js +16 -0
  14. package/lib/commands/auth/2fa/index.d.ts +6 -0
  15. package/lib/commands/auth/2fa/index.js +18 -0
  16. package/lib/commands/auth/login.d.ts +8 -0
  17. package/lib/commands/auth/login.js +25 -0
  18. package/lib/commands/auth/logout.d.ts +6 -0
  19. package/lib/commands/auth/logout.js +14 -0
  20. package/lib/commands/auth/token.d.ts +7 -0
  21. package/lib/commands/auth/token.js +31 -0
  22. package/lib/commands/auth/whoami.d.ts +7 -0
  23. package/lib/commands/auth/whoami.js +26 -0
  24. package/lib/commands/authorizations/create.d.ts +13 -0
  25. package/lib/commands/authorizations/create.js +41 -0
  26. package/lib/commands/authorizations/index.d.ts +9 -0
  27. package/lib/commands/authorizations/index.js +35 -0
  28. package/lib/commands/authorizations/info.d.ts +11 -0
  29. package/lib/commands/authorizations/info.js +25 -0
  30. package/lib/commands/authorizations/revoke.d.ts +10 -0
  31. package/lib/commands/authorizations/revoke.js +22 -0
  32. package/lib/commands/authorizations/rotate.d.ts +8 -0
  33. package/lib/commands/authorizations/rotate.js +19 -0
  34. package/lib/commands/authorizations/update.d.ts +13 -0
  35. package/lib/commands/authorizations/update.js +36 -0
  36. package/lib/commands/autocomplete/create.d.ts +29 -0
  37. package/lib/commands/autocomplete/create.js +213 -0
  38. package/lib/commands/autocomplete/doctor.d.ts +12 -0
  39. package/lib/commands/autocomplete/doctor.js +97 -0
  40. package/lib/commands/autocomplete/index.d.ts +12 -0
  41. package/lib/commands/autocomplete/index.js +67 -0
  42. package/lib/commands/autocomplete/options.d.ts +25 -0
  43. package/lib/commands/autocomplete/options.js +210 -0
  44. package/lib/commands/autocomplete/script.d.ts +10 -0
  45. package/lib/commands/autocomplete/script.js +23 -0
  46. package/lib/commands/buildpacks/add.d.ts +13 -0
  47. package/lib/commands/buildpacks/add.js +43 -0
  48. package/lib/commands/buildpacks/clear.d.ts +9 -0
  49. package/lib/commands/buildpacks/clear.js +17 -0
  50. package/lib/commands/buildpacks/index.d.ts +9 -0
  51. package/lib/commands/buildpacks/index.js +25 -0
  52. package/lib/commands/buildpacks/info.d.ts +8 -0
  53. package/lib/commands/buildpacks/info.js +41 -0
  54. package/lib/commands/buildpacks/remove.d.ts +13 -0
  55. package/lib/commands/buildpacks/remove.js +55 -0
  56. package/lib/commands/buildpacks/search.d.ts +13 -0
  57. package/lib/commands/buildpacks/search.js +69 -0
  58. package/lib/commands/buildpacks/set.d.ts +13 -0
  59. package/lib/commands/buildpacks/set.js +42 -0
  60. package/lib/commands/buildpacks/versions.d.ts +8 -0
  61. package/lib/commands/buildpacks/versions.js +56 -0
  62. package/lib/commands/certs/auto/wait.d.ts +9 -0
  63. package/lib/commands/certs/auto/wait.js +14 -0
  64. package/lib/commands/ci/index.d.ts +12 -0
  65. package/lib/commands/ci/index.js +25 -0
  66. package/lib/commands/ci/info.d.ts +14 -0
  67. package/lib/commands/ci/info.js +29 -0
  68. package/lib/commands/ci/last.d.ts +11 -0
  69. package/lib/commands/ci/last.js +31 -0
  70. package/lib/commands/ci/rerun.d.ts +13 -0
  71. package/lib/commands/ci/rerun.js +53 -0
  72. package/lib/commands/ci/run.d.ts +10 -0
  73. package/lib/commands/ci/run.js +42 -0
  74. package/lib/commands/clients/create.d.ts +14 -0
  75. package/lib/commands/clients/create.js +37 -0
  76. package/lib/commands/clients/destroy.d.ts +8 -0
  77. package/lib/commands/clients/destroy.js +18 -0
  78. package/lib/commands/clients/index.d.ts +8 -0
  79. package/lib/commands/clients/index.js +32 -0
  80. package/lib/commands/clients/info.d.ts +13 -0
  81. package/lib/commands/clients/info.js +33 -0
  82. package/lib/commands/clients/rotate.d.ts +12 -0
  83. package/lib/commands/clients/rotate.js +33 -0
  84. package/lib/commands/clients/update.d.ts +13 -0
  85. package/lib/commands/clients/update.js +38 -0
  86. package/lib/commands/config/edit.d.ts +23 -0
  87. package/lib/commands/config/edit.js +132 -0
  88. package/lib/commands/config/get.d.ts +16 -0
  89. package/lib/commands/config/get.js +35 -0
  90. package/lib/commands/config/index.d.ts +11 -0
  91. package/lib/commands/config/index.js +33 -0
  92. package/lib/commands/config/unset.d.ts +12 -0
  93. package/lib/commands/config/unset.js +51 -0
  94. package/lib/commands/console.d.ts +11 -0
  95. package/lib/commands/console.js +30 -0
  96. package/lib/commands/domains/add.d.ts +19 -0
  97. package/lib/commands/domains/add.js +117 -0
  98. package/lib/commands/domains/clear.d.ts +11 -0
  99. package/lib/commands/domains/clear.js +26 -0
  100. package/lib/commands/domains/index.d.ts +40 -0
  101. package/lib/commands/domains/index.js +79 -0
  102. package/lib/commands/domains/info.d.ts +14 -0
  103. package/lib/commands/domains/info.js +25 -0
  104. package/lib/commands/domains/remove.d.ts +14 -0
  105. package/lib/commands/domains/remove.js +26 -0
  106. package/lib/commands/domains/update.d.ts +15 -0
  107. package/lib/commands/domains/update.js +40 -0
  108. package/lib/commands/domains/wait.d.ts +13 -0
  109. package/lib/commands/domains/wait.js +32 -0
  110. package/lib/commands/git/clone.d.ts +13 -0
  111. package/lib/commands/git/clone.js +29 -0
  112. package/lib/commands/git/credentials.d.ts +9 -0
  113. package/lib/commands/git/credentials.js +32 -0
  114. package/lib/commands/git/remote.d.ts +11 -0
  115. package/lib/commands/git/remote.js +44 -0
  116. package/lib/commands/labs/disable.d.ts +11 -0
  117. package/lib/commands/labs/disable.js +65 -0
  118. package/lib/commands/local/index.d.ts +17 -0
  119. package/lib/commands/local/index.js +75 -0
  120. package/lib/commands/local/run.d.ts +11 -0
  121. package/lib/commands/local/run.js +38 -0
  122. package/lib/commands/local/version.d.ts +5 -0
  123. package/lib/commands/local/version.js +13 -0
  124. package/lib/commands/logs.d.ts +16 -0
  125. package/lib/commands/logs.js +45 -0
  126. package/lib/commands/pipelines/add.d.ts +14 -0
  127. package/lib/commands/pipelines/add.js +61 -0
  128. package/lib/commands/pipelines/connect.d.ts +12 -0
  129. package/lib/commands/pipelines/connect.js +52 -0
  130. package/lib/commands/pipelines/create.d.ts +15 -0
  131. package/lib/commands/pipelines/create.js +91 -0
  132. package/lib/commands/pipelines/destroy.d.ts +9 -0
  133. package/lib/commands/pipelines/destroy.js +27 -0
  134. package/lib/commands/pipelines/diff.d.ts +19 -0
  135. package/lib/commands/pipelines/diff.js +152 -0
  136. package/lib/commands/pipelines/index.d.ts +9 -0
  137. package/lib/commands/pipelines/index.js +27 -0
  138. package/lib/commands/pipelines/info.d.ts +13 -0
  139. package/lib/commands/pipelines/info.js +43 -0
  140. package/lib/commands/pipelines/open.d.ts +9 -0
  141. package/lib/commands/pipelines/open.js +19 -0
  142. package/lib/commands/pipelines/promote.d.ts +12 -0
  143. package/lib/commands/pipelines/promote.js +216 -0
  144. package/lib/commands/pipelines/remove.d.ts +10 -0
  145. package/lib/commands/pipelines/remove.js +23 -0
  146. package/lib/commands/pipelines/rename.d.ts +10 -0
  147. package/lib/commands/pipelines/rename.js +33 -0
  148. package/lib/commands/pipelines/setup.d.ts +14 -0
  149. package/lib/commands/pipelines/setup.js +91 -0
  150. package/lib/commands/pipelines/transfer.d.ts +13 -0
  151. package/lib/commands/pipelines/transfer.js +65 -0
  152. package/lib/commands/pipelines/update.d.ts +11 -0
  153. package/lib/commands/pipelines/update.js +32 -0
  154. package/lib/commands/ps/autoscale/disable.d.ts +9 -0
  155. package/lib/commands/ps/autoscale/disable.js +35 -0
  156. package/lib/commands/ps/autoscale/enable.d.ts +13 -0
  157. package/lib/commands/ps/autoscale/enable.js +65 -0
  158. package/lib/commands/ps/wait.d.ts +12 -0
  159. package/lib/commands/ps/wait.js +78 -0
  160. package/lib/commands/rake.d.ts +14 -0
  161. package/lib/commands/rake.js +46 -0
  162. package/lib/commands/regions.d.ts +11 -0
  163. package/lib/commands/regions.js +45 -0
  164. package/lib/commands/reviewapps/disable.d.ts +17 -0
  165. package/lib/commands/reviewapps/disable.js +102 -0
  166. package/lib/commands/reviewapps/enable.d.ts +14 -0
  167. package/lib/commands/reviewapps/enable.js +89 -0
  168. package/lib/commands/run/detached.d.ts +15 -0
  169. package/lib/commands/run/detached.js +56 -0
  170. package/lib/commands/run/index.d.ts +18 -0
  171. package/lib/commands/run/index.js +64 -0
  172. package/lib/commands/run/inside.d.ts +15 -0
  173. package/lib/commands/run/inside.js +55 -0
  174. package/lib/commands/sessions/destroy.d.ts +8 -0
  175. package/lib/commands/sessions/destroy.js +18 -0
  176. package/lib/commands/sessions/index.d.ts +8 -0
  177. package/lib/commands/sessions/index.js +31 -0
  178. package/lib/commands/status.d.ts +8 -0
  179. package/lib/commands/status.js +46 -0
  180. package/lib/commands/webhooks/add.d.ts +16 -0
  181. package/lib/commands/webhooks/add.js +47 -0
  182. package/lib/commands/webhooks/deliveries/index.d.ts +12 -0
  183. package/lib/commands/webhooks/deliveries/index.js +80 -0
  184. package/lib/commands/webhooks/deliveries/info.d.ts +14 -0
  185. package/lib/commands/webhooks/deliveries/info.js +42 -0
  186. package/lib/commands/webhooks/events/index.d.ts +11 -0
  187. package/lib/commands/webhooks/events/index.js +46 -0
  188. package/lib/commands/webhooks/events/info.d.ts +14 -0
  189. package/lib/commands/webhooks/events/info.js +31 -0
  190. package/lib/commands/webhooks/index.d.ts +11 -0
  191. package/lib/commands/webhooks/index.js +45 -0
  192. package/lib/commands/webhooks/info.d.ts +14 -0
  193. package/lib/commands/webhooks/info.js +31 -0
  194. package/lib/commands/webhooks/remove.d.ts +14 -0
  195. package/lib/commands/webhooks/remove.js +29 -0
  196. package/lib/commands/webhooks/update.d.ts +19 -0
  197. package/lib/commands/webhooks/update.js +41 -0
  198. package/lib/file.js +2 -3
  199. package/lib/global_telemetry.d.ts +53 -0
  200. package/lib/global_telemetry.js +82 -0
  201. package/lib/hooks/command_not_found/performance_analytics.d.ts +3 -0
  202. package/lib/hooks/command_not_found/performance_analytics.js +7 -0
  203. package/lib/hooks/init/terms-of-service.js +3 -4
  204. package/lib/hooks/init/version.d.ts +2 -1
  205. package/lib/hooks/init/version.js +1 -2
  206. package/lib/hooks/postrun/performance_analytics.d.ts +3 -0
  207. package/lib/hooks/postrun/performance_analytics.js +11 -0
  208. package/lib/hooks/prerun/analytics.d.ts +2 -1
  209. package/lib/hooks/prerun/analytics.js +4 -4
  210. package/lib/hooks/recache.d.ts +3 -0
  211. package/lib/hooks/recache.js +56 -0
  212. package/lib/hooks/update/brew.d.ts +2 -1
  213. package/lib/hooks/update/brew.js +3 -5
  214. package/lib/hooks/update/completions.d.ts +2 -1
  215. package/lib/hooks/update/completions.js +2 -3
  216. package/lib/hooks/update/plugin-migrate.d.ts +2 -1
  217. package/lib/hooks/update/plugin-migrate.js +3 -5
  218. package/lib/hooks/update/tidy.d.ts +2 -1
  219. package/lib/hooks/update/tidy.js +3 -5
  220. package/lib/lib/authorizations/authorizations.d.ts +2 -0
  221. package/lib/lib/authorizations/authorizations.js +39 -0
  222. package/lib/lib/autocomplete/base.d.ts +11 -0
  223. package/lib/lib/autocomplete/base.js +44 -0
  224. package/lib/lib/autocomplete/cache.d.ts +2 -0
  225. package/lib/lib/autocomplete/cache.js +28 -0
  226. package/lib/lib/autocomplete/completions.d.ts +37 -0
  227. package/lib/lib/autocomplete/completions.js +261 -0
  228. package/lib/lib/buildpacks/buildpacks.d.ts +32 -0
  229. package/lib/lib/buildpacks/buildpacks.js +161 -0
  230. package/lib/lib/buildpacks/push.d.ts +0 -0
  231. package/lib/lib/buildpacks/push.js +4 -0
  232. package/lib/lib/ci/git.d.ts +8 -0
  233. package/lib/lib/ci/git.js +71 -0
  234. package/lib/lib/ci/interfaces/kolkrabbi.d.ts +311 -0
  235. package/lib/lib/ci/interfaces/kolkrabbi.js +7 -0
  236. package/lib/lib/ci/pipelines.d.ts +3 -0
  237. package/lib/lib/ci/pipelines.js +57 -0
  238. package/lib/lib/ci/source.d.ts +2 -0
  239. package/lib/lib/ci/source.js +42 -0
  240. package/lib/lib/ci/test-run.d.ts +5 -0
  241. package/lib/lib/ci/test-run.js +232 -0
  242. package/lib/lib/clients/clients.d.ts +1 -0
  243. package/lib/lib/clients/clients.js +25 -0
  244. package/lib/lib/config/quote.d.ts +2 -0
  245. package/lib/lib/config/quote.js +33 -0
  246. package/lib/lib/config/util.d.ts +3 -0
  247. package/lib/lib/config/util.js +12 -0
  248. package/lib/lib/domains/wait-for-domain.d.ts +3 -0
  249. package/lib/lib/domains/wait-for-domain.js +19 -0
  250. package/lib/lib/git/git.d.ts +8 -0
  251. package/lib/lib/git/git.js +56 -0
  252. package/lib/lib/local/fork-foreman.d.ts +1 -0
  253. package/lib/lib/local/fork-foreman.js +33 -0
  254. package/lib/lib/local/load-foreman-procfile.d.ts +0 -0
  255. package/lib/lib/local/load-foreman-procfile.js +2 -0
  256. package/lib/lib/local/run-foreman.d.ts +0 -0
  257. package/lib/lib/local/run-foreman.js +2 -0
  258. package/lib/lib/pipelines/api.d.ts +25 -0
  259. package/lib/lib/pipelines/api.js +130 -0
  260. package/lib/lib/pipelines/disambiguate.d.ts +3 -0
  261. package/lib/lib/pipelines/disambiguate.js +49 -0
  262. package/lib/lib/pipelines/github-api.d.ts +8 -0
  263. package/lib/lib/pipelines/github-api.js +18 -0
  264. package/lib/lib/pipelines/infer.d.ts +1 -0
  265. package/lib/lib/pipelines/infer.js +11 -0
  266. package/lib/lib/pipelines/key-by.d.ts +1 -0
  267. package/lib/lib/pipelines/key-by.js +11 -0
  268. package/lib/lib/pipelines/kolkrabbi-api.d.ts +14 -0
  269. package/lib/lib/pipelines/kolkrabbi-api.js +62 -0
  270. package/lib/lib/pipelines/ownership.d.ts +4 -0
  271. package/lib/lib/pipelines/ownership.js +40 -0
  272. package/lib/lib/pipelines/render-pipeline.d.ts +6 -0
  273. package/lib/lib/pipelines/render-pipeline.js +52 -0
  274. package/lib/lib/pipelines/setup/create-apps.d.ts +1 -0
  275. package/lib/lib/pipelines/setup/create-apps.js +44 -0
  276. package/lib/lib/pipelines/setup/get-ci-settings.d.ts +4 -0
  277. package/lib/lib/pipelines/setup/get-ci-settings.js +19 -0
  278. package/lib/lib/pipelines/setup/get-github-token.d.ts +1 -0
  279. package/lib/lib/pipelines/setup/get-github-token.js +10 -0
  280. package/lib/lib/pipelines/setup/get-name-and-repo.d.ts +1 -0
  281. package/lib/lib/pipelines/setup/get-name-and-repo.js +47 -0
  282. package/lib/lib/pipelines/setup/get-repo.d.ts +1 -0
  283. package/lib/lib/pipelines/setup/get-repo.js +8 -0
  284. package/lib/lib/pipelines/setup/get-settings.d.ts +9 -0
  285. package/lib/lib/pipelines/setup/get-settings.js +39 -0
  286. package/lib/lib/pipelines/setup/poll-app-setups.d.ts +1 -0
  287. package/lib/lib/pipelines/setup/poll-app-setups.js +25 -0
  288. package/lib/lib/pipelines/setup/setup-pipeline.d.ts +1 -0
  289. package/lib/lib/pipelines/setup/setup-pipeline.js +15 -0
  290. package/lib/lib/pipelines/setup/validate.d.ts +9 -0
  291. package/lib/lib/pipelines/setup/validate.js +31 -0
  292. package/lib/lib/pipelines/stages.d.ts +7 -0
  293. package/lib/lib/pipelines/stages.js +22 -0
  294. package/lib/lib/run/colorize.d.ts +2 -0
  295. package/lib/lib/run/colorize.js +300 -0
  296. package/lib/lib/run/dyno.d.ts +72 -0
  297. package/lib/lib/run/dyno.js +397 -0
  298. package/lib/lib/run/helpers.d.ts +2 -0
  299. package/lib/lib/run/helpers.js +34 -0
  300. package/lib/lib/run/line-transform.d.ts +4 -0
  301. package/lib/lib/run/line-transform.js +26 -0
  302. package/lib/lib/run/log-displayer.d.ts +10 -0
  303. package/lib/lib/run/log-displayer.js +79 -0
  304. package/lib/lib/sessions/sessions.d.ts +7 -0
  305. package/lib/lib/sessions/sessions.js +2 -0
  306. package/lib/lib/status/util.d.ts +1 -0
  307. package/lib/lib/status/util.js +14 -0
  308. package/lib/lib/webhooks/base.d.ts +13 -0
  309. package/lib/lib/webhooks/base.js +28 -0
  310. package/lib/user-config.js +2 -3
  311. package/oclif.manifest.json +3376 -2
  312. package/package.json +79 -42
  313. package/lib/hooks/update/b.d.ts +0 -2
  314. package/lib/hooks/update/b.js +0 -48
@@ -0,0 +1,37 @@
1
+ import { Completion, CompletionContext } from '@oclif/core/lib/interfaces/parser';
2
+ export declare const oneDay: number;
3
+ export declare const herokuGet: (resource: string, ctx: CompletionContext) => Promise<string[]>;
4
+ export declare const AppCompletion: Completion;
5
+ export declare const AppAddonCompletion: Completion;
6
+ export declare const AppDynoCompletion: Completion;
7
+ export declare const BuildpackCompletion: Completion;
8
+ export declare const DynoSizeCompletion: Completion;
9
+ export declare const FileCompletion: Completion;
10
+ export declare const PipelineCompletion: Completion;
11
+ export declare const ProcessTypeCompletion: Completion;
12
+ export declare const RegionCompletion: Completion;
13
+ export declare const RemoteCompletion: Completion;
14
+ export declare const RoleCompletion: Completion;
15
+ export declare const ScopeCompletion: Completion;
16
+ export declare const SpaceCompletion: Completion;
17
+ export declare const StackCompletion: Completion;
18
+ export declare const StageCompletion: Completion;
19
+ export declare const TeamCompletion: Completion;
20
+ export declare const CompletionMapping: {
21
+ [key: string]: Completion;
22
+ };
23
+ export declare class CompletionLookup {
24
+ private readonly cmdId;
25
+ private readonly name;
26
+ private readonly description?;
27
+ private get key();
28
+ private readonly blocklistMap;
29
+ private readonly keyAliasMap;
30
+ private readonly commandArgsMap;
31
+ constructor(cmdId: string, name: string, description?: string | undefined);
32
+ run(): Completion | undefined;
33
+ private argAlias;
34
+ private keyAlias;
35
+ private descriptionAlias;
36
+ private blocklisted;
37
+ }
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CompletionLookup = exports.CompletionMapping = exports.TeamCompletion = exports.StageCompletion = exports.StackCompletion = exports.SpaceCompletion = exports.ScopeCompletion = exports.RoleCompletion = exports.RemoteCompletion = exports.RegionCompletion = exports.ProcessTypeCompletion = exports.PipelineCompletion = exports.FileCompletion = exports.DynoSizeCompletion = exports.BuildpackCompletion = exports.AppDynoCompletion = exports.AppAddonCompletion = exports.AppCompletion = exports.herokuGet = exports.oneDay = void 0;
4
+ const command_1 = require("@heroku-cli/command");
5
+ const deps_1 = require("@heroku-cli/command/lib/deps");
6
+ const git_1 = require("@heroku-cli/command/lib/git");
7
+ const path = require("path");
8
+ const lodash_1 = require("lodash");
9
+ exports.oneDay = 60 * 60 * 24;
10
+ const herokuGet = async (resource, ctx) => {
11
+ const heroku = new command_1.APIClient(ctx.config);
12
+ let { body } = await heroku.get(`/${resource}`, { retryAuth: false });
13
+ if (typeof body === 'string')
14
+ body = JSON.parse(body);
15
+ return body.map((a) => a.name).sort();
16
+ };
17
+ exports.herokuGet = herokuGet;
18
+ exports.AppCompletion = {
19
+ cacheDuration: exports.oneDay,
20
+ options: async (ctx) => {
21
+ const teams = await (0, exports.herokuGet)('teams', ctx);
22
+ const apps = {
23
+ personal: await (0, exports.herokuGet)('users/~/apps', ctx),
24
+ teams: (0, lodash_1.flatten)(await Promise.all(teams.map((team) => (0, exports.herokuGet)(`teams/${team}/apps`, ctx)))),
25
+ };
26
+ return apps.personal.concat(apps.teams);
27
+ },
28
+ };
29
+ exports.AppAddonCompletion = {
30
+ cacheDuration: exports.oneDay,
31
+ cacheKey: async (ctx) => {
32
+ return ctx.flags && ctx.flags.app ? `${ctx.flags.app}_addons` : '';
33
+ },
34
+ options: async (ctx) => {
35
+ const addons = ctx.flags && ctx.flags.app ? await (0, exports.herokuGet)(`apps/${ctx.flags.app}/addons`, ctx) : [];
36
+ return addons;
37
+ },
38
+ };
39
+ exports.AppDynoCompletion = {
40
+ cacheDuration: exports.oneDay,
41
+ cacheKey: async (ctx) => {
42
+ return ctx.flags && ctx.flags.app ? `${ctx.flags.app}_dynos` : '';
43
+ },
44
+ options: async (ctx) => {
45
+ const dynos = ctx.flags && ctx.flags.app ? await (0, exports.herokuGet)(`apps/${ctx.flags.app}/dynos`, ctx) : [];
46
+ return dynos;
47
+ },
48
+ };
49
+ exports.BuildpackCompletion = {
50
+ skipCache: true,
51
+ options: async () => {
52
+ return [
53
+ 'heroku/ruby',
54
+ 'heroku/nodejs',
55
+ 'heroku/clojure',
56
+ 'heroku/python',
57
+ 'heroku/java',
58
+ 'heroku/gradle',
59
+ 'heroku/scala',
60
+ 'heroku/php',
61
+ 'heroku/go',
62
+ ];
63
+ },
64
+ };
65
+ const ConfigCompletion = {
66
+ cacheDuration: 60 * 60 * 24 * 7,
67
+ cacheKey: async (ctx) => {
68
+ return ctx.flags && ctx.flags.app ? `${ctx.flags.app}_config_vars` : '';
69
+ },
70
+ options: async (ctx) => {
71
+ const heroku = new command_1.APIClient(ctx.config);
72
+ if (ctx.flags && ctx.flags.app) {
73
+ const { body: configs } = await heroku.get(`/apps/${ctx.flags.app}/config-vars`, { retryAuth: false });
74
+ return Object.keys(configs);
75
+ }
76
+ return [];
77
+ },
78
+ };
79
+ const ConfigSetCompletion = {
80
+ cacheDuration: 60 * 60 * 24 * 7,
81
+ cacheKey: async (ctx) => {
82
+ return ctx.flags && ctx.flags.app ? `${ctx.flags.app}_config_set_vars` : '';
83
+ },
84
+ options: async (ctx) => {
85
+ const heroku = new command_1.APIClient(ctx.config);
86
+ if (ctx.flags && ctx.flags.app) {
87
+ const { body: configs } = await heroku.get(`/apps/${ctx.flags.app}/config-vars`, { retryAuth: false });
88
+ return Object.keys(configs).map(k => `${k}=`);
89
+ }
90
+ return [];
91
+ },
92
+ };
93
+ exports.DynoSizeCompletion = {
94
+ cacheDuration: exports.oneDay * 90,
95
+ options: async (ctx) => {
96
+ let sizes = await (0, exports.herokuGet)('dyno-sizes', ctx);
97
+ if (sizes)
98
+ sizes = sizes.map(s => s.toLowerCase());
99
+ return sizes;
100
+ },
101
+ };
102
+ exports.FileCompletion = {
103
+ skipCache: true,
104
+ options: async () => {
105
+ const files = await deps_1.deps.file.readdir(process.cwd());
106
+ return files;
107
+ },
108
+ };
109
+ exports.PipelineCompletion = {
110
+ cacheDuration: exports.oneDay,
111
+ options: async (ctx) => {
112
+ const pipelines = await (0, exports.herokuGet)('pipelines', ctx);
113
+ return pipelines;
114
+ },
115
+ };
116
+ exports.ProcessTypeCompletion = {
117
+ skipCache: true,
118
+ options: async () => {
119
+ let types = [];
120
+ const procfile = path.join(process.cwd(), 'Procfile');
121
+ try {
122
+ const buff = await deps_1.deps.file.readFile(procfile);
123
+ types = buff
124
+ .toString()
125
+ .split('\n')
126
+ .map(s => {
127
+ if (!s)
128
+ return false;
129
+ const m = s.match(/^([A-Za-z0-9_-]+)/);
130
+ return m ? m[0] : false;
131
+ })
132
+ .filter(t => t);
133
+ }
134
+ catch (error) {
135
+ if (error.code !== 'ENOENT')
136
+ throw error;
137
+ }
138
+ return types;
139
+ },
140
+ };
141
+ exports.RegionCompletion = {
142
+ cacheDuration: exports.oneDay * 7,
143
+ options: async (ctx) => {
144
+ const regions = await (0, exports.herokuGet)('regions', ctx);
145
+ return regions;
146
+ },
147
+ };
148
+ exports.RemoteCompletion = {
149
+ skipCache: true,
150
+ options: async () => {
151
+ const remotes = (0, git_1.getGitRemotes)((0, git_1.configRemote)());
152
+ return remotes.map(r => r.remote);
153
+ },
154
+ };
155
+ exports.RoleCompletion = {
156
+ skipCache: true,
157
+ options: async () => {
158
+ return ['admin', 'collaborator', 'member', 'owner'];
159
+ },
160
+ };
161
+ exports.ScopeCompletion = {
162
+ skipCache: true,
163
+ options: async () => {
164
+ return ['global', 'identity', 'read', 'write', 'read-protected', 'write-protected'];
165
+ },
166
+ };
167
+ exports.SpaceCompletion = {
168
+ cacheDuration: exports.oneDay,
169
+ options: async (ctx) => {
170
+ const spaces = await (0, exports.herokuGet)('spaces', ctx);
171
+ return spaces;
172
+ },
173
+ };
174
+ exports.StackCompletion = {
175
+ cacheDuration: exports.oneDay,
176
+ options: async (ctx) => {
177
+ const stacks = await (0, exports.herokuGet)('stacks', ctx);
178
+ return stacks;
179
+ },
180
+ };
181
+ exports.StageCompletion = {
182
+ skipCache: true,
183
+ options: async () => {
184
+ return ['test', 'review', 'development', 'staging', 'production'];
185
+ },
186
+ };
187
+ exports.TeamCompletion = {
188
+ cacheDuration: exports.oneDay,
189
+ options: async (ctx) => {
190
+ const teams = await (0, exports.herokuGet)('teams', ctx);
191
+ return teams;
192
+ },
193
+ };
194
+ exports.CompletionMapping = {
195
+ app: exports.AppCompletion,
196
+ addon: exports.AppAddonCompletion,
197
+ dyno: exports.AppDynoCompletion,
198
+ buildpack: exports.BuildpackCompletion,
199
+ config: ConfigCompletion,
200
+ configSet: ConfigSetCompletion,
201
+ dynosize: exports.DynoSizeCompletion,
202
+ pipeline: exports.PipelineCompletion,
203
+ processtype: exports.ProcessTypeCompletion,
204
+ region: exports.RegionCompletion,
205
+ remote: exports.RemoteCompletion,
206
+ role: exports.RoleCompletion,
207
+ scope: exports.ScopeCompletion,
208
+ space: exports.SpaceCompletion,
209
+ stack: exports.StackCompletion,
210
+ stage: exports.StageCompletion,
211
+ team: exports.TeamCompletion,
212
+ };
213
+ class CompletionLookup {
214
+ // eslint-disable-next-line no-useless-constructor
215
+ constructor(cmdId, name, description) {
216
+ this.cmdId = cmdId;
217
+ this.name = name;
218
+ this.description = description;
219
+ this.blocklistMap = {
220
+ app: ['apps:create'],
221
+ space: ['spaces:create'],
222
+ };
223
+ this.keyAliasMap = {
224
+ key: {
225
+ 'config:get': 'config',
226
+ },
227
+ };
228
+ this.commandArgsMap = {
229
+ key: {
230
+ 'config:set': 'configSet',
231
+ },
232
+ };
233
+ }
234
+ get key() {
235
+ return this.argAlias() || this.keyAlias() || this.descriptionAlias() || this.name;
236
+ }
237
+ run() {
238
+ if (this.blocklisted())
239
+ return;
240
+ return exports.CompletionMapping[this.key];
241
+ }
242
+ argAlias() {
243
+ return this.commandArgsMap[this.name] && this.commandArgsMap[this.name][this.cmdId];
244
+ }
245
+ keyAlias() {
246
+ return this.keyAliasMap[this.name] && this.keyAliasMap[this.name][this.cmdId];
247
+ }
248
+ descriptionAlias() {
249
+ const d = this.description;
250
+ // eslint-disable-next-line unicorn/prefer-starts-ends-with
251
+ if (d.match(/^dyno size/))
252
+ return 'dynosize';
253
+ // eslint-disable-next-line unicorn/prefer-starts-ends-with
254
+ if (d.match(/^process type/))
255
+ return 'processtype';
256
+ }
257
+ blocklisted() {
258
+ return this.blocklistMap[this.name] && this.blocklistMap[this.name].includes(this.cmdId);
259
+ }
260
+ }
261
+ exports.CompletionLookup = CompletionLookup;
@@ -0,0 +1,32 @@
1
+ import { APIClient } from '@heroku-cli/command';
2
+ import { BuildpackRegistry } from '@heroku/buildpack-registry';
3
+ export declare type BuildpackResponse = {
4
+ buildpack: {
5
+ url: string;
6
+ name: string;
7
+ };
8
+ ordinal: number;
9
+ };
10
+ export declare class BuildpackCommand {
11
+ heroku: APIClient;
12
+ registry: BuildpackRegistry;
13
+ constructor(heroku: APIClient);
14
+ fetch(app: string): Promise<any[]>;
15
+ mapBuildpackResponse(buildpacks: {
16
+ body: any;
17
+ }): BuildpackResponse[];
18
+ display(buildpacks: BuildpackResponse[], indent: string): void;
19
+ registryNameToUrl(buildpack: string): Promise<string>;
20
+ findUrl(buildpacks: BuildpackResponse[], buildpack: string): Promise<number>;
21
+ validateUrlNotSet(buildpacks: BuildpackResponse[], buildpack: string): Promise<void>;
22
+ findIndex(buildpacks: BuildpackResponse[], index?: number): number;
23
+ mutate(app: string, buildpacks: BuildpackResponse[], spliceIndex: number, buildpack: string, command: 'add' | 'set' | 'remove'): Promise<BuildpackResponse[]>;
24
+ put(app: string, buildpackUpdates: {
25
+ buildpack: string;
26
+ }[]): Promise<BuildpackResponse[]>;
27
+ displayUpdate(app: string, remote: string, buildpacks: BuildpackResponse[], action: 'added' | 'set' | 'removed'): void;
28
+ registryUrlToName(buildpack: string, registryOnly?: boolean): string;
29
+ clear(app: string, command: 'clear' | 'remove', action: 'cleared' | 'removed'): Promise<void>;
30
+ validateIndexInRange(buildpacks: BuildpackResponse[], index: number): void;
31
+ validateIndex(index: number): void;
32
+ }
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuildpackCommand = void 0;
4
+ const color_1 = require("@heroku-cli/color");
5
+ const buildpack_registry_1 = require("@heroku/buildpack-registry");
6
+ const core_1 = require("@oclif/core");
7
+ const lodash_1 = require("lodash");
8
+ const true_myth_1 = require("true-myth");
9
+ // eslint-disable-next-line node/no-missing-require
10
+ const push = require('./push');
11
+ const validUrl = require('valid-url');
12
+ class BuildpackCommand {
13
+ constructor(heroku) {
14
+ this.heroku = heroku;
15
+ this.registry = new buildpack_registry_1.BuildpackRegistry();
16
+ }
17
+ async fetch(app) {
18
+ const buildpacks = await this.heroku.get(`/apps/${app}/buildpack-installations`);
19
+ return this.mapBuildpackResponse(buildpacks);
20
+ }
21
+ mapBuildpackResponse(buildpacks) {
22
+ const body = buildpacks.body;
23
+ return body.map((bp) => {
24
+ bp.buildpack.url = bp.buildpack.url.replace(/^urn:buildpack:/, '');
25
+ return bp;
26
+ });
27
+ }
28
+ display(buildpacks, indent) {
29
+ if (buildpacks.length === 1) {
30
+ core_1.ux.log(this.registryUrlToName(buildpacks[0].buildpack.url, true));
31
+ }
32
+ else {
33
+ buildpacks.forEach((b, i) => {
34
+ core_1.ux.log(`${indent}${i + 1}. ${this.registryUrlToName(b.buildpack.url, true)}`);
35
+ });
36
+ }
37
+ }
38
+ async registryNameToUrl(buildpack) {
39
+ if (validUrl.isWebUri(buildpack)) {
40
+ return buildpack;
41
+ }
42
+ true_myth_1.Result.match({
43
+ Ok: _ => { },
44
+ Err: err => {
45
+ core_1.ux.error(`Could not find the buildpack: ${buildpack}. ${err}`, { exit: 1 });
46
+ },
47
+ }, buildpack_registry_1.BuildpackRegistry.isValidBuildpackSlug(buildpack));
48
+ try {
49
+ const response = await this.registry.buildpackExists(buildpack);
50
+ const body = await response.json();
51
+ return body.blob_url;
52
+ }
53
+ catch (error) {
54
+ if (error.statusCode === 404) {
55
+ core_1.ux.error(`${buildpack} is not in the buildpack registry.`, { exit: 1 });
56
+ }
57
+ else if (error.statusCode) {
58
+ core_1.ux.error(`${error.statusCode}: ${error.message}`, { exit: 1 });
59
+ }
60
+ else {
61
+ core_1.ux.error(error.message, { exit: 1 });
62
+ }
63
+ }
64
+ return '';
65
+ }
66
+ async findUrl(buildpacks, buildpack) {
67
+ const mappedUrl = await this.registryNameToUrl(buildpack);
68
+ return (0, lodash_1.findIndex)(buildpacks, (b) => {
69
+ return b.buildpack.url === buildpack || b.buildpack.url === mappedUrl;
70
+ });
71
+ }
72
+ async validateUrlNotSet(buildpacks, buildpack) {
73
+ if (await this.findUrl(buildpacks, buildpack) !== -1) {
74
+ core_1.ux.error(`The buildpack ${buildpack} is already set on your app.`, { exit: 1 });
75
+ }
76
+ }
77
+ findIndex(buildpacks, index) {
78
+ if (index) {
79
+ return (0, lodash_1.findIndex)(buildpacks, function (b) {
80
+ return b.ordinal + 1 === index;
81
+ });
82
+ }
83
+ return -1;
84
+ }
85
+ async mutate(app, buildpacks, spliceIndex, buildpack, command) {
86
+ const buildpackUpdates = buildpacks.map(function (b) {
87
+ return { buildpack: b.buildpack.url };
88
+ });
89
+ const howmany = (command === 'add') ? 0 : 1;
90
+ const urls = (command === 'remove') ? [] : [{ buildpack: await this.registryNameToUrl(buildpack) }];
91
+ const indexes = [spliceIndex, howmany];
92
+ const array = indexes.concat(urls);
93
+ Array.prototype.splice.apply(buildpackUpdates, array);
94
+ return this.put(app, buildpackUpdates);
95
+ }
96
+ async put(app, buildpackUpdates) {
97
+ const buildpacks = await this.heroku.put(`/apps/${app}/buildpack-installations`, {
98
+ headers: { Range: '' },
99
+ body: { updates: buildpackUpdates },
100
+ });
101
+ return this.mapBuildpackResponse(buildpacks);
102
+ }
103
+ displayUpdate(app, remote, buildpacks, action) {
104
+ if (buildpacks.length === 1) {
105
+ core_1.ux.log(`Buildpack ${action}. Next release on ${app} will use ${this.registryUrlToName(buildpacks[0].buildpack.url)}.`);
106
+ core_1.ux.log(`Run ${color_1.default.magenta(push(remote))} to create a new release using this buildpack.`);
107
+ }
108
+ else {
109
+ core_1.ux.log(`Buildpack ${action}. Next release on ${app} will use:`);
110
+ this.display(buildpacks, ' ');
111
+ core_1.ux.log(`Run ${color_1.default.magenta(push(remote))} to create a new release using these buildpacks.`);
112
+ }
113
+ }
114
+ registryUrlToName(buildpack, registryOnly = false) {
115
+ // eslint-disable-next-line no-useless-escape
116
+ let match = /^https:\/\/buildpack\-registry\.s3\.amazonaws\.com\/buildpacks\/([\w\-]+\/[\w\-]+).tgz$/.exec(buildpack);
117
+ if (match) {
118
+ return match[1];
119
+ }
120
+ if (!registryOnly) {
121
+ // eslint-disable-next-line no-useless-escape
122
+ match = /^https:\/\/codon\-buildpacks\.s3\.amazonaws\.com\/buildpacks\/heroku\/([\w\-]+).tgz$/.exec(buildpack);
123
+ if (match) {
124
+ return `heroku/${match[1]}`;
125
+ }
126
+ }
127
+ return buildpack;
128
+ }
129
+ async clear(app, command, action) {
130
+ await this.put(app, []);
131
+ const configVars = await this.heroku.get(`/apps/${app}/config-vars`);
132
+ const message = `Buildpack${command === 'clear' ? 's' : ''} ${action}.`;
133
+ if (configVars.body.BUILDPACK_URL) {
134
+ core_1.ux.log(message);
135
+ core_1.ux.warn('The BUILDPACK_URL config var is still set and will be used for the next release');
136
+ }
137
+ else if (configVars.body.LANGUAGE_PACK_URL) {
138
+ core_1.ux.log(message);
139
+ core_1.ux.warn('The LANGUAGE_PACK_URL config var is still set and will be used for the next release');
140
+ }
141
+ else {
142
+ core_1.ux.log(`${message} Next release on ${app} will detect buildpacks normally.`);
143
+ }
144
+ }
145
+ validateIndexInRange(buildpacks, index) {
146
+ if (index < 0 || index > buildpacks.length) {
147
+ if (buildpacks.length === 1) {
148
+ core_1.ux.error('Invalid index. Only valid value is 1.', { exit: 1 });
149
+ }
150
+ else {
151
+ core_1.ux.error(`Invalid index. Please choose a value between 1 and ${buildpacks.length}`, { exit: 1 });
152
+ }
153
+ }
154
+ }
155
+ validateIndex(index) {
156
+ if (Number.isNaN(index) || index <= 0) {
157
+ core_1.ux.error('Invalid index. Must be greater than 0.', { exit: 1 });
158
+ }
159
+ }
160
+ }
161
+ exports.BuildpackCommand = BuildpackCommand;
File without changes
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ module.exports = function (remote) {
3
+ return `git push ${remote || 'heroku'} main`;
4
+ };
@@ -0,0 +1,8 @@
1
+ declare function createArchive(ref: string): Promise<any>;
2
+ declare function githubRepository(): Promise<any>;
3
+ declare function readCommit(commit: string): Promise<{
4
+ branch: string | undefined;
5
+ ref: string | undefined;
6
+ message: string | undefined;
7
+ }>;
8
+ export { createArchive, githubRepository, readCommit, };
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readCommit = exports.githubRepository = exports.createArchive = void 0;
4
+ const fs = require("fs-extra");
5
+ const gh = require('github-url-to-object');
6
+ const spawn = require('child_process').spawn;
7
+ const tmp = require('tmp');
8
+ const NOT_A_GIT_REPOSITORY = 'not a git repository';
9
+ const RUN_IN_A_GIT_REPOSITORY = 'Please run this command from the directory containing your project\'s git repo';
10
+ const NOT_ON_A_BRANCH = 'not a symbolic ref';
11
+ const CHECKOUT_A_BRANCH = 'Please checkout a branch before running this command';
12
+ function runGit(...args) {
13
+ const git = spawn('git', args);
14
+ return new Promise((resolve, reject) => {
15
+ git.on('exit', (exitCode) => {
16
+ if (exitCode === 0) {
17
+ return;
18
+ }
19
+ const error = (git.stderr.read() || 'unknown error').toString().trim();
20
+ if (error.toLowerCase().includes(NOT_A_GIT_REPOSITORY)) {
21
+ reject(RUN_IN_A_GIT_REPOSITORY);
22
+ return;
23
+ }
24
+ if (error.includes(NOT_ON_A_BRANCH)) {
25
+ reject(CHECKOUT_A_BRANCH);
26
+ return;
27
+ }
28
+ reject(new Error(`Error while running 'git ${args.join(' ')}' (${error})`));
29
+ });
30
+ git.stdout.on('data', (data) => resolve(data.toString().trim()));
31
+ });
32
+ }
33
+ async function getRef(branch) {
34
+ return runGit('rev-parse', branch || 'HEAD');
35
+ }
36
+ async function getBranch(symbolicRef) {
37
+ return runGit('symbolic-ref', '--short', symbolicRef);
38
+ }
39
+ async function getCommitTitle(ref) {
40
+ return runGit('log', ref || '', '-1', '--pretty=format:%s');
41
+ }
42
+ async function createArchive(ref) {
43
+ const tar = spawn('git', ['archive', '--format', 'tar.gz', ref]);
44
+ const file = tmp.fileSync({ postfix: '.tar.gz' });
45
+ const write = tar.stdout.pipe(fs.createWriteStream(file.name));
46
+ return new Promise((resolve, reject) => {
47
+ write.on('close', () => resolve(file.name));
48
+ write.on('error', reject);
49
+ });
50
+ }
51
+ exports.createArchive = createArchive;
52
+ async function githubRepository() {
53
+ const remote = await runGit('remote', 'get-url', 'origin');
54
+ const repository = gh(remote);
55
+ if (repository === null) {
56
+ throw new Error('Not a GitHub repository');
57
+ }
58
+ return repository;
59
+ }
60
+ exports.githubRepository = githubRepository;
61
+ async function readCommit(commit) {
62
+ const branch = await getBranch('HEAD');
63
+ const ref = await getRef(commit);
64
+ const message = await getCommitTitle(ref);
65
+ return Promise.resolve({
66
+ branch,
67
+ ref,
68
+ message,
69
+ });
70
+ }
71
+ exports.readCommit = readCommit;