backport 5.6.6 → 6.0.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 (206) hide show
  1. package/README.md +48 -39
  2. package/dist/entrypoint.cli.js +1 -1
  3. package/dist/entrypoint.module.d.ts +6 -5
  4. package/dist/entrypoint.module.js +8 -6
  5. package/dist/ink.d.ts +1 -0
  6. package/dist/ink.js +49 -0
  7. package/dist/main.d.ts +11 -6
  8. package/dist/main.js +40 -24
  9. package/dist/options/ConfigOptions.d.ts +13 -8
  10. package/dist/options/cliArgs.d.ts +11 -9
  11. package/dist/options/cliArgs.js +74 -36
  12. package/dist/options/cliArgs.test.js +33 -37
  13. package/dist/options/config/config.d.ts +17 -15
  14. package/dist/options/config/config.js +8 -8
  15. package/dist/options/config/config.test.js +3 -2
  16. package/dist/options/config/getOptionsFromGit.js +1 -1
  17. package/dist/options/config/globalConfig.d.ts +2 -51
  18. package/dist/options/config/globalConfig.js +8 -8
  19. package/dist/options/config/globalConfig.test.js +7 -3
  20. package/dist/options/config/projectConfig.d.ts +2 -51
  21. package/dist/options/config/projectConfig.js +2 -2
  22. package/dist/options/config/projectConfig.test.js +3 -3
  23. package/dist/options/config/readConfigFile.d.ts +2 -51
  24. package/dist/options/config/readConfigFile.js +2 -2
  25. package/dist/options/options.d.ts +19 -14
  26. package/dist/options/options.js +5 -6
  27. package/dist/options/options.test.js +48 -11
  28. package/dist/options/parseRequiredOptions.d.ts +18 -13
  29. package/dist/options/parseRequiredOptions.js +8 -12
  30. package/dist/options/parseRequiredOptions.test.js +25 -16
  31. package/dist/runSequentially.d.ts +20 -0
  32. package/dist/runSequentially.js +41 -0
  33. package/dist/runSequentially.test.d.ts +1 -0
  34. package/dist/runSequentially.test.js +235 -0
  35. package/dist/runWithOptions.js +7 -14
  36. package/dist/runWithOptions.test.js +138 -17
  37. package/dist/scripts/generate-gql.d.ts +1 -0
  38. package/dist/scripts/generate-gql.js +15 -0
  39. package/dist/scripts/postinstall.js +4 -4
  40. package/dist/scripts/postinstall.test.js +9 -2
  41. package/dist/scripts/runPostinstall.js +1 -1
  42. package/dist/services/HandledError.d.ts +11 -1
  43. package/dist/services/HandledError.js +2 -1
  44. package/dist/services/child-process-promisified.d.ts +1 -1
  45. package/dist/services/child-process-promisified.js +1 -1
  46. package/dist/services/env.js +5 -5
  47. package/dist/services/env.test.js +11 -4
  48. package/dist/services/fs-promisified.js +4 -4
  49. package/dist/services/getExpectedTarget.d.ts +9 -0
  50. package/dist/services/getExpectedTarget.js +77 -0
  51. package/dist/services/getExpectedTargetPullRequests.d.ts +9 -0
  52. package/dist/services/getExpectedTargetPullRequests.js +77 -0
  53. package/dist/services/git.d.ts +15 -4
  54. package/dist/services/git.integration.test.d.ts +1 -0
  55. package/dist/services/git.integration.test.js +168 -0
  56. package/dist/services/git.js +86 -61
  57. package/dist/services/git.test.js +61 -64
  58. package/dist/services/github/commitFormatters.d.ts +3 -7
  59. package/dist/services/github/commitFormatters.js +10 -19
  60. package/dist/services/github/commitFormatters.test.js +2 -24
  61. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
  62. package/dist/services/github/v3/addAssigneesToPullRequest.js +2 -6
  63. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +2 -3
  64. package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
  65. package/dist/services/github/v3/addLabelsToPullRequest.js +2 -6
  66. package/dist/services/github/v3/addReviewersToPullRequest.d.ts +2 -0
  67. package/dist/services/github/v3/addReviewersToPullRequest.js +34 -0
  68. package/dist/services/github/v3/createPullRequest.d.ts +3 -2
  69. package/dist/services/github/v3/createPullRequest.js +32 -23
  70. package/dist/services/github/v3/createStatusComment.d.ts +11 -0
  71. package/dist/services/github/v3/createStatusComment.js +97 -0
  72. package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
  73. package/dist/services/github/v3/createStatusComment.test.js +209 -0
  74. package/dist/services/github/v4/FetchPullRequestId.js +1 -1
  75. package/dist/services/github/v4/apiRequestV4.d.ts +1 -1
  76. package/dist/services/github/v4/apiRequestV4.js +5 -7
  77. package/dist/services/github/v4/apiRequestV4.test.js +7 -7
  78. package/dist/services/github/v4/disablePullRequestAutoMerge.js +3 -4
  79. package/dist/services/github/v4/enablePullRequestAutoMerge.js +8 -7
  80. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +94 -33
  81. package/dist/services/github/v4/fetchAuthorId.js +1 -1
  82. package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -3
  83. package/dist/services/github/v4/fetchCommitByPullNumber.js +11 -9
  84. package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +4 -4
  85. package/dist/services/github/v4/fetchCommitBySha.js +14 -12
  86. package/dist/services/github/v4/fetchCommitBySha.private.test.js +4 -4
  87. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +5 -0
  88. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +46 -0
  89. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
  90. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +67 -0
  91. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +5 -0
  92. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +36 -0
  93. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
  94. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +55 -0
  95. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +16 -0
  96. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +90 -0
  97. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
  98. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +130 -0
  99. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
  100. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +127 -0
  101. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +28 -0
  102. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +52 -0
  103. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +10 -0
  104. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +49 -0
  105. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
  106. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +81 -0
  107. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +1 -0
  108. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +252 -0
  109. package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +2 -1
  110. package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
  111. package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +78 -5
  112. package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
  113. package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
  114. package/dist/services/github/v4/fetchExistingPullRequest.js +2 -3
  115. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -3
  116. package/dist/services/github/v4/fetchMergedPullRequests.d.ts +18 -19
  117. package/dist/services/github/v4/fetchMergedPullRequests.js +22 -69
  118. package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +8 -9
  119. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +2 -3
  120. package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
  121. package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +3 -3
  122. package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +2 -2
  123. package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +4 -58
  124. package/dist/services/github/v4/getExistingTargetPullRequests.js +3 -58
  125. package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +16 -10
  126. package/dist/services/github/v4/getOptionsFromGithub/index.js +52 -22
  127. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +25 -7
  128. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +13 -16
  129. package/dist/services/github/v4/getOptionsFromGithub/query.js +13 -15
  130. package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -7
  131. package/dist/services/github/v4/getTargetBranchesFromLabels.js +1 -26
  132. package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +69 -32
  133. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -2
  134. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +39 -25
  135. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +1 -1
  136. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
  137. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +1 -1
  138. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +2 -0
  139. package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +1 -1
  140. package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +1 -0
  141. package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -15
  142. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +7 -7
  143. package/dist/services/logger.d.ts +3 -3
  144. package/dist/services/logger.js +16 -15
  145. package/dist/services/prompt.test.d.ts +1 -0
  146. package/dist/services/prompt.test.js +87 -0
  147. package/dist/services/prompts.d.ts +10 -4
  148. package/dist/services/prompts.js +85 -22
  149. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +9 -0
  150. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +92 -0
  151. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  152. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +396 -0
  153. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +21 -0
  154. package/dist/services/sourceCommit/getMockSourceCommit.js +67 -0
  155. package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +5 -0
  156. package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +20 -0
  157. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +1 -0
  158. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +201 -0
  159. package/dist/services/sourceCommit/parseSourceCommit.d.ts +78 -0
  160. package/dist/services/sourceCommit/parseSourceCommit.js +96 -0
  161. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  162. package/dist/services/sourceCommit/parseSourceCommit.test.js +114 -0
  163. package/dist/services/sourceCommit/sourceCommit.d.ts +78 -0
  164. package/dist/services/sourceCommit/sourceCommit.js +86 -0
  165. package/dist/services/sourceCommit/sourceCommit.test.d.ts +1 -0
  166. package/dist/services/sourceCommit/sourceCommit.test.js +287 -0
  167. package/dist/services/sourceCommit.d.ts +78 -0
  168. package/dist/services/sourceCommit.js +86 -0
  169. package/dist/services/sourceCommit.test.d.ts +1 -0
  170. package/dist/services/sourceCommit.test.js +280 -0
  171. package/dist/test/inquirer.private.test.js +22 -15
  172. package/dist/test/integration/createSpies.js +6 -6
  173. package/dist/test/integration/envConstants.js +5 -6
  174. package/dist/test/integration/helpers.js +1 -1
  175. package/dist/test/integration/integration.private.test.d.ts +1 -0
  176. package/dist/test/integration/integration.private.test.js +308 -0
  177. package/dist/test/integration/integration.test.js +28 -29
  178. package/dist/test/nockHelpers.js +3 -7
  179. package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
  180. package/dist/test/setupFiles/automatic-mocks.js +0 -22
  181. package/dist/types/Commit.d.ts +85 -0
  182. package/dist/types/Commit.js +139 -0
  183. package/dist/types/commitNode.d.ts +89 -0
  184. package/dist/types/commitNode.js +139 -0
  185. package/dist/types/commitNode.test.d.ts +1 -0
  186. package/dist/types/commitNode.test.js +255 -0
  187. package/dist/types/commitWithAssociatedPullRequests.d.ts +86 -0
  188. package/dist/types/commitWithAssociatedPullRequests.js +145 -0
  189. package/dist/ui/cherrypickAndCreatePullRequest.test.js +277 -59
  190. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +11 -1
  191. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +131 -68
  192. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
  193. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +468 -0
  194. package/dist/ui/getCommits.d.ts +1 -1
  195. package/dist/ui/getCommits.js +55 -25
  196. package/dist/ui/getTargetBranches.d.ts +2 -2
  197. package/dist/ui/getTargetBranches.js +16 -17
  198. package/dist/ui/getTargetBranches.test.js +75 -99
  199. package/dist/ui/getTargetBranchesFromLabels.d.ts +6 -0
  200. package/dist/ui/getTargetBranchesFromLabels.js +40 -0
  201. package/dist/ui/getTargetBranchesFromLabels.test.d.ts +1 -0
  202. package/dist/ui/getTargetBranchesFromLabels.test.js +288 -0
  203. package/dist/ui/maybeSetupRepo.js +9 -9
  204. package/dist/ui/maybeSetupRepo.test.js +5 -1
  205. package/package.json +36 -51
  206. package/yarn.lock +2387 -2987
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # backport
2
2
 
3
- [![Build Status](https://travis-ci.com/sqren/backport.svg?branch=master)](https://travis-ci.com/sqren/backport)
3
+ [![Build Status](https://travis-ci.com/sqren/backport.svg?branch=master)](https://app.travis-ci.com/github/sqren/backport)
4
4
  [![NPM version](https://img.shields.io/npm/v/backport.svg)](https://www.npmjs.com/package/backport)
5
- [![dependencies Status](https://david-dm.org/sqren/backport/status.svg)](https://david-dm.org/sqren/backport)
6
5
  [![Coverage Status](https://coveralls.io/repos/github/sqren/backport/badge.svg?branch=master)](https://coveralls.io/github/sqren/backport?branch=master)
7
6
 
8
7
  A simple CLI tool that automates the process of backporting commits on a GitHub repo.
@@ -11,7 +10,7 @@ A simple CLI tool that automates the process of backporting commits on a GitHub
11
10
 
12
11
  ## Requirements
13
12
 
14
- - Node 10 or higher
13
+ - Node 16 or higher
15
14
  - git
16
15
 
17
16
  ## Install
@@ -30,7 +29,11 @@ Add a [project config](https://github.com/sqren/backport/blob/master/docs/config
30
29
  // .backportrc.json
31
30
  {
32
31
  "upstream": "elastic/kibana",
33
- "targetBranchChoices": [{ "name": "6.x", "checked": true }, "6.3", "6.2", "6.1", "6.0"],
32
+ "targetBranchChoices": ["main", "6.3", "6.2", "6.1", "6.0"],
33
+ "branchLabelMapping": {
34
+ "^v6.4.0$": "main",
35
+ "^v(\\d+).(\\d+).\\d+$": "$1.$2"
36
+ }
34
37
  }
35
38
  ```
36
39
 
@@ -54,41 +57,44 @@ See [configuration.md](https://github.com/sqren/backport/blob/master/docs/config
54
57
 
55
58
  ### CLI options
56
59
 
57
- Please note that dashes between the words are optional,for instance you can type `--targetBranchor` `--target-branch` both are valid options.
58
-
59
- | Option | Shorthand notation | Description | Default | Type |
60
- | ------------------- | -------------------- | ------------------------------------------------------ | -------------- | --------------- |
61
- | --access-token | --accesstoken | Github access token | | `string` |
62
- | --all | -a | Show commits from other than me | false | `boolean` |
63
- | --author | | Filter commits by author | _Current user_ | `string` |
64
- | --assignees | --assignee, --assign | Assign users to target pull request | | `Array<string>` |
65
- | --auto-assign | | Assign current user to target pull request | false | `boolean` |
66
- | --branch | --b | Target branch to backport to | | `string` |
67
- | --ci | | Disable interactive prompts | false | `boolean` |
68
- | --dry-run | | Perform backport without pushing to Github | false | `string` |
69
- | --editor | | Editor (eg. `code`) to open and solve conflicts | nano | `string` |
70
- | --fork | | Create backports in fork (true) or origin repo (false) | true | `boolean` |
71
- | --git-hostname | | Hostname for Git | github.com | `string` |
72
- | --mainline | | Parent id of merge commit | 1 | `number` |
73
- | --max-number | --number, --n | Number of commits to choose from | 10 | `number` |
74
- | --multiple | | Select multiple commits/branches | false | `boolean` |
75
- | --multiple-branches | | Backport to multiple branches | true | `boolean` |
76
- | --multiple-commits | | Backport multiple commits | false | `boolean` |
77
- | --path | -p | Only list commits touching files under a specific path | | `string` |
78
- | --pull-number | --pr | Pull request to backport | | `number` |
79
- | --pr-description | --description | Pull request description suffix | | `string` |
80
- | --pr-filter | | List commits from PRs filtered by a given query | | `string` |
81
- | --pr-title | --title | Title of pull request | | `string` |
82
- | --reset-author | | Set yourself as commit author | | `boolean` |
83
- | --sha | | Sha of commit to backport | | `string` |
84
- | --source-branch | | Specify a non-default branch to backport from | | `string` |
85
- | --source-pr-labels | --sourcePRLabel | Labels added to the source PR | | `array<string>` |
86
- | --target-pr-Labels | --labels, --label | Labels added to the target PR | | `array<string>` |
87
- | --target-branches | --b, --targetBranch | Target branch(es) to backport to | | `array<string>` |
88
- | --upstream | --up | Name of organization and repository | | `string` |
89
- | --username | | Github username | | `string` |
90
- | --help | | Show help | | |
91
- | -v, --version | | Show version number | | |
60
+ Please note that dashes between the words are optional, for instance you can type `--targetBranch` or `--target-branch` both are valid options.
61
+
62
+ | Option | Shorthand notation | Description | Default | Type |
63
+ | ------------------- | ------------------ | ------------------------------------------------------------- | -------------- | --------- |
64
+ | --access-token | | Github access token | | `string` |
65
+ | --all | -a | Show commits from other than yourself | false | `boolean` |
66
+ | --author | | Filter commits by Github username | _Current user_ | `string` |
67
+ | --assignee | --assign | Assign users to the target PR | | `string` |
68
+ | --auto-assign | | Assign current user to the target PR | false | `boolean` |
69
+ | --branch | -b | Target branch to backport to | | `string` |
70
+ | --ci | | Disable interactive prompts | false | `boolean` |
71
+ | --dry-run | | Perform backport without pushing to Github | false | `string` |
72
+ | --editor | | Editor (eg. `code`) to open and resolve conflicts | nano | `string` |
73
+ | --fork | | Create backports in fork repo | true | `boolean` |
74
+ | --git-hostname | | Hostname for Git | github.com | `string` |
75
+ | --no-cherrypick-ref | | Do not append "(cherry picked from commit...)". [Git Docs][1] | false | `boolean` |
76
+ | --no-verify | | Bypass the pre-commit and commit-msg hooks | false | `boolean` |
77
+ | --mainline | | Parent id of merge commit | 1 | `number` |
78
+ | --max-number | --number, -n | Number of commits to choose from | 10 | `number` |
79
+ | --multiple | | Multi-select for commits and branches | false | `boolean` |
80
+ | --multiple-branches | | Multi-select for branches | true | `boolean` |
81
+ | --multiple-commits | | Multi-select for commits | false | `boolean` |
82
+ | --path | -p | Filter commits by path | | `string` |
83
+ | --pull-number | --pr | Backport pull request by number | | `number` |
84
+ | --pr-description | --description | Pull request description suffix | | `string` |
85
+ | --pr-filter | | Find PRs using [Github's search syntax][2] | | `string` |
86
+ | --pr-title | --title | Title of pull request | | `string` |
87
+ | --reset-author | | Set yourself as commit author | | `boolean` |
88
+ | --reviewer | | Add reviewer to the target PR | | `boolean` |
89
+ | --sha | | Sha of commit to backport | | `string` |
90
+ | --source-branch | | Specify a non-default branch to backport from | | `string` |
91
+ | --source-pr-label | | Labels added to the source PR | | `string` |
92
+ | --target-pr-label | --label, -l | Labels added to the target PR | | `string` |
93
+ | --target-branch | -b | Target branch(es) to backport to | | `string` |
94
+ | --upstream | --up | Name of organization and repository | | `string` |
95
+ | --username | | Github username | | `string` |
96
+ | --help | | Show help | | |
97
+ | -v, --version | | Show version number | | |
92
98
 
93
99
  The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/master/docs/configuration.md).
94
100
 
@@ -120,3 +126,6 @@ This tools is for anybody who is working on a codebase where they have to mainta
120
126
  ## Contributing
121
127
 
122
128
  See [CONTRIBUTING.md](https://github.com/sqren/backport/blob/master/CONTRIBUTING.md)
129
+
130
+ [1]: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x
131
+ [2]: https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const main_1 = require("./main");
5
5
  const args = process.argv.slice(2);
6
6
  // this is the entrypoint when running from command line
7
- main_1.main(args);
7
+ (0, main_1.main)(args);
@@ -1,6 +1,7 @@
1
- import { ConfigOptions } from './options/ConfigOptions';
2
- export declare function run(options: ConfigOptions, args?: string[]): Promise<import("./main").BackportResponse>;
1
+ import { ConfigFileOptions } from './options/ConfigOptions';
2
+ export declare function run(options: ConfigFileOptions, args?: string[]): Promise<import("./main").BackportResponse>;
3
3
  export { BackportResponse } from './main';
4
- export { ConfigOptions } from './options/ConfigOptions';
5
- export { getTargetBranchForLabel } from './services/github/v4/getTargetBranchesFromLabels';
6
- export { fetchMergedPullRequests } from './services/github/v4/fetchMergedPullRequests';
4
+ export { ConfigFileOptions } from './options/ConfigOptions';
5
+ export { fetchCommitsByAuthor } from './services/github/v4/fetchCommits/fetchCommitsByAuthor';
6
+ export { fetchCommitByPullNumber } from './services/github/v4/fetchCommits/fetchCommitByPullNumber';
7
+ export { fetchCommitBySha } from './services/github/v4/fetchCommits/fetchCommitBySha';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchMergedPullRequests = exports.getTargetBranchForLabel = exports.run = void 0;
3
+ exports.fetchCommitBySha = exports.fetchCommitByPullNumber = exports.fetchCommitsByAuthor = exports.run = void 0;
4
4
  const main_1 = require("./main");
5
5
  // this is the entry point when importing backport as module:
6
6
  function run(options,
@@ -12,10 +12,12 @@ function run(options,
12
12
  // run(options, args)
13
13
  //
14
14
  args = []) {
15
- return main_1.main(args, options);
15
+ return (0, main_1.main)(args, options);
16
16
  }
17
17
  exports.run = run;
18
- var getTargetBranchesFromLabels_1 = require("./services/github/v4/getTargetBranchesFromLabels");
19
- Object.defineProperty(exports, "getTargetBranchForLabel", { enumerable: true, get: function () { return getTargetBranchesFromLabels_1.getTargetBranchForLabel; } });
20
- var fetchMergedPullRequests_1 = require("./services/github/v4/fetchMergedPullRequests");
21
- Object.defineProperty(exports, "fetchMergedPullRequests", { enumerable: true, get: function () { return fetchMergedPullRequests_1.fetchMergedPullRequests; } });
18
+ var fetchCommitsByAuthor_1 = require("./services/github/v4/fetchCommits/fetchCommitsByAuthor");
19
+ Object.defineProperty(exports, "fetchCommitsByAuthor", { enumerable: true, get: function () { return fetchCommitsByAuthor_1.fetchCommitsByAuthor; } });
20
+ var fetchCommitByPullNumber_1 = require("./services/github/v4/fetchCommits/fetchCommitByPullNumber");
21
+ Object.defineProperty(exports, "fetchCommitByPullNumber", { enumerable: true, get: function () { return fetchCommitByPullNumber_1.fetchCommitByPullNumber; } });
22
+ var fetchCommitBySha_1 = require("./services/github/v4/fetchCommits/fetchCommitBySha");
23
+ Object.defineProperty(exports, "fetchCommitBySha", { enumerable: true, get: function () { return fetchCommitBySha_1.fetchCommitBySha; } });
package/dist/ink.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function renderInk(): void;
package/dist/ink.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.renderInk = void 0;
26
+ const ink_1 = require("ink");
27
+ const ink_spinner_1 = __importDefault(require("ink-spinner"));
28
+ const react_1 = __importStar(require("react"));
29
+ const Example = () => {
30
+ const [message, setMessage] = (0, react_1.useState)();
31
+ (0, react_1.useEffect)(() => {
32
+ setTimeout(() => {
33
+ setMessage('Received message');
34
+ }, 5000);
35
+ });
36
+ if (!message) {
37
+ return (react_1.default.createElement(react_1.default.Fragment, null,
38
+ react_1.default.createElement(ink_1.Box, null,
39
+ react_1.default.createElement(ink_1.Box, { marginRight: 1 },
40
+ react_1.default.createElement(ink_1.Text, { color: 'cyan' },
41
+ react_1.default.createElement(ink_spinner_1.default, { type: "dots" }))),
42
+ react_1.default.createElement(ink_1.Text, null, "Loading via ink!!"))));
43
+ }
44
+ return react_1.default.createElement(ink_1.Text, null, message);
45
+ };
46
+ function renderInk() {
47
+ (0, ink_1.render)(react_1.default.createElement(Example, null));
48
+ }
49
+ exports.renderInk = renderInk;
package/dist/main.d.ts CHANGED
@@ -1,9 +1,14 @@
1
- import { ConfigOptions } from './options/ConfigOptions';
2
- import { Result } from './runWithOptions';
1
+ import { ConfigFileOptions } from './options/ConfigOptions';
2
+ import { Result } from './runSequentially';
3
+ import { Commit } from './services/sourceCommit/parseSourceCommit';
3
4
  export declare type BackportResponse = {
4
- success: boolean;
5
+ status: 'success';
6
+ commits: Commit[];
5
7
  results: Result[];
6
- errorMessage?: string;
7
- error?: Error;
8
+ } | {
9
+ status: 'failure';
10
+ commits: Commit[];
11
+ errorMessage: string;
12
+ error: Error;
8
13
  };
9
- export declare function main(argv: string[], optionsFromModule?: ConfigOptions): Promise<BackportResponse>;
14
+ export declare function main(argv: string[], optionsFromModule?: ConfigFileOptions): Promise<BackportResponse>;
package/dist/main.js CHANGED
@@ -6,44 +6,60 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.main = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const options_1 = require("./options/options");
9
- const runWithOptions_1 = require("./runWithOptions");
9
+ const runSequentially_1 = require("./runSequentially");
10
10
  const HandledError_1 = require("./services/HandledError");
11
11
  const env_1 = require("./services/env");
12
+ const createStatusComment_1 = require("./services/github/v3/createStatusComment");
12
13
  const logger_1 = require("./services/logger");
14
+ const getCommits_1 = require("./ui/getCommits");
15
+ const getTargetBranches_1 = require("./ui/getTargetBranches");
13
16
  async function main(argv, optionsFromModule) {
14
- const logger = logger_1.initLogger();
17
+ const logger = (0, logger_1.initLogger)();
18
+ let options = null;
19
+ let commits = [];
15
20
  try {
16
- const options = await options_1.getOptions(argv, optionsFromModule);
17
- const results = await runWithOptions_1.runWithOptions(options);
18
- return {
19
- success: results.every((res) => res.success),
21
+ options = await (0, options_1.getOptions)(argv, optionsFromModule);
22
+ commits = await (0, getCommits_1.getCommits)(options);
23
+ const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
24
+ const results = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
25
+ const backportResponse = {
26
+ status: 'success',
27
+ commits,
20
28
  results,
21
29
  };
30
+ await (0, createStatusComment_1.createStatusComment)({
31
+ options,
32
+ backportResponse,
33
+ });
34
+ return backportResponse;
22
35
  }
23
36
  catch (e) {
24
- const isHandledError = e instanceof HandledError_1.HandledError;
25
- if (isHandledError) {
26
- logger_1.consoleLog(e.message);
37
+ const backportResponse = {
38
+ status: 'failure',
39
+ commits,
40
+ errorMessage: e.message,
41
+ error: e,
42
+ };
43
+ if (options?.ci) {
44
+ await (0, createStatusComment_1.createStatusComment)({
45
+ options,
46
+ backportResponse,
47
+ });
48
+ }
49
+ if (e instanceof HandledError_1.HandledError) {
50
+ (0, logger_1.consoleLog)(e.message);
27
51
  }
28
- else {
52
+ else if (e instanceof Error) {
29
53
  // output
30
- logger_1.consoleLog('\n');
31
- logger_1.consoleLog(chalk_1.default.bold('⚠️ Ouch! An unknown error occured 😿'));
32
- logger_1.consoleLog(`Error message: ${e.message}`);
33
- logger_1.consoleLog('Please open an issue in https://github.com/sqren/backport/issues or contact me directly on https://twitter.com/sorenlouv');
34
- logger_1.consoleLog(chalk_1.default.italic(`For additional details see the logs: ${env_1.getLogfilePath()}`));
54
+ (0, logger_1.consoleLog)('\n');
55
+ (0, logger_1.consoleLog)(chalk_1.default.bold('⚠️ Ouch! An unhandled error occured 😿'));
56
+ (0, logger_1.consoleLog)(`Error message: ${e.message}`);
57
+ (0, logger_1.consoleLog)('Please open an issue in https://github.com/sqren/backport/issues or contact me directly on https://twitter.com/sorenlouv');
58
+ (0, logger_1.consoleLog)(chalk_1.default.italic(`For additional details see the logs: ${(0, env_1.getLogfilePath)()}`));
35
59
  // log file
36
60
  logger.info('Unknown error:', e);
37
61
  }
38
- const errorMessage = logger_1.redact(e.message);
39
- return {
40
- success: false,
41
- results: [],
42
- errorMessage: isHandledError
43
- ? errorMessage
44
- : `An unhandled error occurred: ${errorMessage}`,
45
- error: e,
46
- };
62
+ return backportResponse;
47
63
  }
48
64
  }
49
65
  exports.main = main;
@@ -1,26 +1,28 @@
1
1
  import { Logger } from '../services/logger';
2
- export interface BranchChoice {
2
+ export interface TargetBranchChoice {
3
3
  name: string;
4
4
  checked?: boolean;
5
5
  }
6
- export declare type BranchChoiceRaw = string | BranchChoice;
6
+ export declare type TargetBranchChoiceOrString = string | TargetBranchChoice;
7
7
  declare type AutoFixConflictsHandler = ({ files, directory, logger, targetBranch, }: {
8
8
  files: string[];
9
9
  directory: string;
10
10
  logger: Logger;
11
11
  targetBranch: string;
12
12
  }) => boolean | Promise<boolean>;
13
- export declare type ConfigOptions = Partial<{
13
+ declare type Options = Partial<{
14
14
  accessToken: string;
15
15
  all: boolean;
16
16
  assignees: string[];
17
17
  author: string;
18
18
  autoAssign: boolean;
19
+ autoFixConflicts: AutoFixConflictsHandler;
19
20
  autoMerge: boolean;
20
21
  autoMergeMethod: string;
21
- autoFixConflicts: AutoFixConflictsHandler;
22
- branchLabelMapping: Record<string, string>;
23
22
  ci: boolean;
23
+ cherrypickRef: boolean;
24
+ commitPaths: string[];
25
+ details: boolean;
24
26
  editor: string;
25
27
  forceLocalConfig: boolean;
26
28
  fork: boolean;
@@ -32,22 +34,25 @@ export declare type ConfigOptions = Partial<{
32
34
  multipleBranches: boolean;
33
35
  multipleCommits: boolean;
34
36
  noVerify: boolean;
35
- path: string;
36
37
  prDescription: string;
37
38
  prFilter: string;
38
39
  prTitle: string;
39
40
  pullNumber: number;
40
41
  resetAuthor: boolean;
42
+ reviewers: string[];
41
43
  sha: string;
42
44
  sourceBranch: string;
43
45
  sourcePRLabels: string[];
44
- targetBranchChoices: BranchChoiceRaw[];
46
+ targetBranchChoices: TargetBranchChoiceOrString[];
45
47
  targetBranches: string[];
46
48
  targetPRLabels: string[];
47
49
  upstream: string;
48
50
  username: string;
49
51
  verbose: boolean;
50
- branches: BranchChoiceRaw[];
52
+ }>;
53
+ export declare type ConfigFileOptions = Options & Partial<{
54
+ branchLabelMapping: Record<string, string>;
55
+ branches: TargetBranchChoiceOrString[];
51
56
  labels: string[];
52
57
  }>;
53
58
  export {};
@@ -4,36 +4,38 @@ export declare function getOptionsFromCliArgs(argv: readonly string[], { exitOnE
4
4
  }): {
5
5
  multipleBranches: boolean | undefined;
6
6
  multipleCommits: boolean | undefined;
7
+ assignees: string[];
8
+ commitPaths: string[];
9
+ reviewers: string[];
10
+ sourcePRLabels: string[] | undefined;
11
+ targetBranchChoices: string[] | undefined;
12
+ targetBranches: string[] | undefined;
13
+ targetPRLabels: string[] | undefined;
14
+ cherrypickRef: boolean | undefined;
15
+ fork: boolean | undefined;
7
16
  noVerify: boolean | undefined;
8
17
  accessToken: string | undefined;
9
18
  all: boolean | undefined;
10
19
  author: string | undefined;
11
- assignees: string[] | undefined;
12
20
  autoAssign: boolean | undefined;
13
21
  autoMerge: boolean | undefined;
14
22
  autoMergeMethod: string | undefined;
15
23
  ci: boolean | undefined;
16
- dryRun: boolean | undefined;
24
+ details: boolean | undefined;
17
25
  editor: string | undefined;
18
26
  forceLocalConfig: boolean | undefined;
19
- fork: boolean | undefined;
20
27
  gitHostname: string | undefined;
21
28
  githubApiBaseUrlV3: string | undefined;
22
29
  githubApiBaseUrlV4: string | undefined;
23
30
  mainline: number | undefined;
24
31
  maxNumber: number | undefined;
25
- path: string | undefined;
26
- prTitle: string | undefined;
27
32
  prDescription: string | undefined;
33
+ prTitle: string | undefined;
28
34
  prFilter: string | undefined;
29
35
  pullNumber: number | undefined;
30
36
  resetAuthor: boolean | undefined;
31
37
  sha: string | undefined;
32
38
  sourceBranch: string | undefined;
33
- sourcePRLabels: string[] | undefined;
34
- targetBranches: string[] | undefined;
35
- targetBranchChoices: string[] | undefined;
36
- targetPRLabels: string[] | undefined;
37
39
  upstream: string | undefined;
38
40
  username: string | undefined;
39
41
  verbose: boolean | undefined;