backport 6.2.1 → 6.3.0-beta-4

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 (329) hide show
  1. package/README.md +13 -5
  2. package/dist/backportRun.d.ts +2 -2
  3. package/dist/backportRun.js +13 -8
  4. package/dist/{entrypoint.api.private.test.d.ts → entrypoint.cli.e2e.private.test.d.ts} +0 -0
  5. package/dist/entrypoint.cli.e2e.private.test.js +278 -0
  6. package/dist/{entrypoint.module.private.test.d.ts → entrypoint.cli.private.test.d.ts} +0 -0
  7. package/dist/{entrypoint.module.private.test.js → entrypoint.cli.private.test.js} +17 -8
  8. package/dist/entrypoint.module.js +1 -1
  9. package/dist/options/ConfigOptions.d.ts +5 -2
  10. package/dist/options/cliArgs.d.ts +1 -0
  11. package/dist/options/cliArgs.js +27 -6
  12. package/dist/options/cliArgs.test.js +28 -10
  13. package/dist/options/config/config.d.ts +4 -7
  14. package/dist/options/config/config.js +2 -7
  15. package/dist/options/config/config.test.js +5 -21
  16. package/dist/options/config/globalConfig.js +3 -3
  17. package/dist/options/config/globalConfig.test.js +10 -29
  18. package/dist/options/config/projectConfig.test.js +7 -26
  19. package/dist/options/config/readConfigFile.d.ts +4 -7
  20. package/dist/options/config/readConfigFile.js +2 -2
  21. package/dist/options/options.d.ts +6 -34
  22. package/dist/options/options.js +37 -29
  23. package/dist/options/options.test.js +53 -22
  24. package/dist/runSequentially.d.ts +0 -1
  25. package/dist/runSequentially.js +1 -1
  26. package/dist/runSequentially.test.js +35 -12
  27. package/dist/services/HandledError.d.ts +6 -4
  28. package/dist/services/HandledError.js +18 -3
  29. package/dist/services/child-process-promisified.d.ts +3 -1
  30. package/dist/services/env.test.js +2 -2
  31. package/dist/services/git.d.ts +22 -9
  32. package/dist/services/git.integration.test.js +123 -24
  33. package/dist/services/git.js +66 -54
  34. package/dist/services/git.test.js +35 -20
  35. package/dist/services/github/commitFormatters.d.ts +0 -1
  36. package/dist/services/github/commitFormatters.js +1 -8
  37. package/dist/services/github/v3/createPullRequest.js +8 -5
  38. package/dist/services/github/v3/createPullRequest.test.js +204 -39
  39. package/dist/services/github/v3/createStatusComment.js +26 -15
  40. package/dist/services/github/v3/createStatusComment.test.js +132 -72
  41. package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
  42. package/dist/{options/getValidatedOptions.test.d.ts → services/github/v3/index.d.ts} +0 -0
  43. package/dist/services/github/v3/index.js +61 -0
  44. package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -7
  45. package/dist/services/github/v4/apiRequestV4.d.ts +21 -17
  46. package/dist/services/github/v4/apiRequestV4.js +46 -28
  47. package/dist/services/github/v4/apiRequestV4.test.js +4 -4
  48. package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
  49. package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
  50. package/dist/services/github/v4/fetchAuthorId.private.test.js +2 -2
  51. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +38 -20
  52. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +19 -10
  53. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
  54. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +25 -16
  55. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
  56. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +6 -6
  57. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +41 -19
  58. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
  59. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +33 -16
  60. package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
  61. package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
  62. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +2 -2
  63. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
  64. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +2 -2
  65. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +6 -8
  66. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +49 -41
  67. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +7 -1
  68. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +15 -23
  69. package/dist/services/github/v4/getOptionsFromGithub/query.js +17 -25
  70. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
  71. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
  72. package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
  73. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
  74. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
  75. package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
  76. package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
  77. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
  78. package/dist/services/logger.d.ts +9 -18
  79. package/dist/services/logger.js +20 -56
  80. package/dist/services/prompt.test.js +66 -19
  81. package/dist/services/prompts.js +12 -10
  82. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
  83. package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
  84. package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
  85. package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
  86. package/dist/services/sourceCommit/parseSourceCommit.test.js +18 -20
  87. package/dist/{runWithOptions.test.d.ts → test/backport-e2e.mutation.test.d.ts} +0 -0
  88. package/dist/test/{backport-e2e.private.test.js → backport-e2e.mutation.test.js} +134 -112
  89. package/dist/test/handleUnbackportedPullRequests.private.test.js +26 -12
  90. package/dist/test/mockConfigFiles.js +4 -20
  91. package/dist/test/mocks.d.ts +10 -0
  92. package/dist/test/mocks.js +23 -0
  93. package/dist/test/private/getDevAccessToken.d.ts +2 -1
  94. package/dist/test/private/getDevAccessToken.js +6 -18
  95. package/dist/test/sandbox.d.ts +5 -0
  96. package/dist/{react-components/0-loadOptions.js → test/sandbox.js} +18 -20
  97. package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
  98. package/dist/test/setupFiles/automatic-mocks.js +27 -11
  99. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
  100. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -13
  101. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +47 -19
  102. package/dist/ui/getCommits.js +8 -14
  103. package/dist/ui/getCommitsWithoutBackports.js +6 -6
  104. package/dist/ui/getCommitsWithoutBackports.test.js +91 -39
  105. package/dist/ui/getTargetBranches.js +1 -1
  106. package/dist/ui/getTargetBranches.test.js +26 -8
  107. package/dist/ui/maybeSetupRepo.js +25 -5
  108. package/dist/ui/maybeSetupRepo.test.js +144 -18
  109. package/dist/utils/maybe.d.ts +1 -0
  110. package/dist/utils/maybe.js +7 -0
  111. package/dist/utils/packageVersion.d.ts +1 -0
  112. package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
  113. package/package.json +24 -19
  114. package/yarn.lock +119 -147
  115. package/dist/entrypoint.api.d.ts +0 -22
  116. package/dist/entrypoint.api.js +0 -57
  117. package/dist/entrypoint.api.private.test.js +0 -37
  118. package/dist/index.d.ts +0 -783
  119. package/dist/index.js +0 -8001
  120. package/dist/ink.d.ts +0 -1
  121. package/dist/ink.js +0 -49
  122. package/dist/main.d.ts +0 -14
  123. package/dist/main.js +0 -68
  124. package/dist/options/config/getOptionsFromGit.d.ts +0 -4
  125. package/dist/options/config/getOptionsFromGit.js +0 -8
  126. package/dist/options/config/getProjectConfig.d.ts +0 -0
  127. package/dist/options/config/getProjectConfig.js +0 -1
  128. package/dist/options/getValidatedOptions.d.ts +0 -49
  129. package/dist/options/getValidatedOptions.js +0 -45
  130. package/dist/options/getValidatedOptions.test.js +0 -97
  131. package/dist/options/parseRequiredOptions.d.ts +0 -71
  132. package/dist/options/parseRequiredOptions.js +0 -68
  133. package/dist/options/parseRequiredOptions.test.js +0 -122
  134. package/dist/react-components/0-loadOptions.d.ts +0 -6
  135. package/dist/react-components/1-loadCommit.d.ts +0 -8
  136. package/dist/react-components/1-loadCommit.js +0 -88
  137. package/dist/react-components/1a-loadCommit.d.ts +0 -5
  138. package/dist/react-components/1a-loadCommit.js +0 -76
  139. package/dist/react-components/1b-commitChoices.d.ts +0 -5
  140. package/dist/react-components/1b-commitChoices.js +0 -98
  141. package/dist/react-components/2-commitChoices.d.ts +0 -8
  142. package/dist/react-components/2-commitChoices.js +0 -96
  143. package/dist/react-components/2-commitsPrompt.d.ts +0 -8
  144. package/dist/react-components/2-commitsPrompt.js +0 -96
  145. package/dist/react-components/2-targetBranchChoices.d.ts +0 -9
  146. package/dist/react-components/2-targetBranchChoices.js +0 -109
  147. package/dist/react-components/3-cherrypick.d.ts +0 -1
  148. package/dist/react-components/3-cherrypick.js +0 -2
  149. package/dist/react-components/App.d.ts +0 -2
  150. package/dist/react-components/App.js +0 -35
  151. package/dist/react-components/BackportStateContext.d.ts +0 -33
  152. package/dist/react-components/BackportStateContext.js +0 -42
  153. package/dist/react-components/CommitPrompt/2-commitsPrompt.d.ts +0 -8
  154. package/dist/react-components/CommitPrompt/2-commitsPrompt.js +0 -96
  155. package/dist/react-components/CommitPrompt/CommitPrompt.d.ts +0 -8
  156. package/dist/react-components/CommitPrompt/CommitPrompt.js +0 -96
  157. package/dist/react-components/CommitPrompt/getCommits.d.ts +0 -2
  158. package/dist/react-components/CommitPrompt/getCommits.js +0 -27
  159. package/dist/react-components/CommitPrompt.d.ts +0 -8
  160. package/dist/react-components/CommitPrompt.js +0 -96
  161. package/dist/react-components/CustomMultiSelect.d.ts +0 -13
  162. package/dist/react-components/CustomMultiSelect.js +0 -21
  163. package/dist/react-components/CustomMultiSelectItem.d.ts +0 -5
  164. package/dist/react-components/CustomMultiSelectItem.js +0 -12
  165. package/dist/react-components/CustomSelect.d.ts +0 -14
  166. package/dist/react-components/CustomSelect.js +0 -34
  167. package/dist/react-components/ErrorBoundary.d.ts +0 -15
  168. package/dist/react-components/ErrorBoundary.js +0 -53
  169. package/dist/react-components/MultiSelect.d.ts +0 -7
  170. package/dist/react-components/MultiSelect.js +0 -16
  171. package/dist/react-components/hooks/useAsync.d.ts +0 -12
  172. package/dist/react-components/hooks/useAsync.js +0 -73
  173. package/dist/runWithOptions.d.ts +0 -9
  174. package/dist/runWithOptions.js +0 -43
  175. package/dist/runWithOptions.test.js +0 -304
  176. package/dist/scripts/generate-gql.d.ts +0 -1
  177. package/dist/scripts/generate-gql.js +0 -15
  178. package/dist/services/backportRun/backportRun.ci.d.ts +0 -6
  179. package/dist/services/backportRun/backportRun.ci.js +0 -81
  180. package/dist/services/backportRun/backportRun.d.ts +0 -14
  181. package/dist/services/backportRun/backportRun.interactive.d.ts +0 -1
  182. package/dist/services/backportRun/backportRun.interactive.js +0 -4
  183. package/dist/services/backportRun/backportRun.js +0 -14
  184. package/dist/services/backportRun/backportState.d.ts +0 -4
  185. package/dist/services/backportRun/backportState.js +0 -28
  186. package/dist/services/backportRun/getCommits.d.ts +0 -2
  187. package/dist/services/backportRun/getCommits.js +0 -20
  188. package/dist/services/backportRun/runSequentially.d.ts +0 -20
  189. package/dist/services/backportRun/runSequentially.js +0 -41
  190. package/dist/services/backportRun/runSequentially.test.d.ts +0 -1
  191. package/dist/services/backportRun/runSequentially.test.js +0 -199
  192. package/dist/services/cherrypickAndCreateTargetPullRequest.d.ts +0 -12
  193. package/dist/services/cherrypickAndCreateTargetPullRequest.js +0 -206
  194. package/dist/services/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
  195. package/dist/services/cherrypickAndCreateTargetPullRequest.test.js +0 -403
  196. package/dist/services/fs-promisified.d.ts +0 -6
  197. package/dist/services/fs-promisified.js +0 -12
  198. package/dist/services/getCommits.d.ts +0 -2
  199. package/dist/services/getCommits.js +0 -38
  200. package/dist/services/getCommitsWithoutBackports.d.ts +0 -11
  201. package/dist/services/getCommitsWithoutBackports.js +0 -68
  202. package/dist/services/getCommitsWithoutBackports.test.d.ts +0 -1
  203. package/dist/services/getCommitsWithoutBackports.test.js +0 -259
  204. package/dist/services/getExpectedTarget.d.ts +0 -9
  205. package/dist/services/getExpectedTarget.js +0 -77
  206. package/dist/services/getExpectedTargetPullRequests.d.ts +0 -9
  207. package/dist/services/getExpectedTargetPullRequests.js +0 -77
  208. package/dist/services/getTargetBranches.d.ts +0 -5
  209. package/dist/services/getTargetBranches.js +0 -60
  210. package/dist/services/getTargetBranches.test.d.ts +0 -1
  211. package/dist/services/getTargetBranches.test.js +0 -180
  212. package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
  213. package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
  214. package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
  215. package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
  216. package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
  217. package/dist/services/github/v4/fetchCommitBySha.js +0 -95
  218. package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
  219. package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
  220. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
  221. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
  222. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
  223. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
  224. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
  225. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
  226. package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
  227. package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
  228. package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
  229. package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
  230. package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
  231. package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
  232. package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
  233. package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
  234. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
  235. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
  236. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
  237. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
  238. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
  239. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
  240. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
  241. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
  242. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
  243. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
  244. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
  245. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
  246. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
  247. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
  248. package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
  249. package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
  250. package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
  251. package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
  252. package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
  253. package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
  254. package/dist/services/github/v4/fetchProjectConfig.d.ts +0 -8
  255. package/dist/services/github/v4/fetchProjectConfig.js +0 -56
  256. package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
  257. package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
  258. package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
  259. package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
  260. package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
  261. package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
  262. package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  263. package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
  264. package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
  265. package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
  266. package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
  267. package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
  268. package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
  269. package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
  270. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
  271. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
  272. package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
  273. package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
  274. package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
  275. package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
  276. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
  277. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
  278. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
  279. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
  280. package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
  281. package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
  282. package/dist/services/maybeSetupRepo.d.ts +0 -2
  283. package/dist/services/maybeSetupRepo.js +0 -33
  284. package/dist/services/maybeSetupRepo.test.d.ts +0 -1
  285. package/dist/services/maybeSetupRepo.test.js +0 -78
  286. package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
  287. package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
  288. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
  289. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
  290. package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
  291. package/dist/services/sourceCommit/sourceCommit.js +0 -86
  292. package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
  293. package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
  294. package/dist/services/sourceCommit.d.ts +0 -78
  295. package/dist/services/sourceCommit.js +0 -86
  296. package/dist/services/sourceCommit.test.d.ts +0 -1
  297. package/dist/services/sourceCommit.test.js +0 -280
  298. package/dist/test/backport-e2e.private.test.d.ts +0 -1
  299. package/dist/test/inquirer.private.test.d.ts +0 -1
  300. package/dist/test/inquirer.private.test.js +0 -170
  301. package/dist/test/integration/createSpies.d.ts +0 -17
  302. package/dist/test/integration/createSpies.js +0 -85
  303. package/dist/test/integration/envConstants.d.ts +0 -5
  304. package/dist/test/integration/envConstants.js +0 -9
  305. package/dist/test/integration/helpers.d.ts +0 -7
  306. package/dist/test/integration/helpers.js +0 -31
  307. package/dist/test/integration/integration.private.test.d.ts +0 -1
  308. package/dist/test/integration/integration.private.test.js +0 -327
  309. package/dist/test/integration/integration.test.d.ts +0 -1
  310. package/dist/test/integration/integration.test.js +0 -214
  311. package/dist/todo-delete.d.ts +0 -1
  312. package/dist/todo-delete.js +0 -17
  313. package/dist/types/Commit.d.ts +0 -85
  314. package/dist/types/Commit.js +0 -139
  315. package/dist/types/PromiseReturnType.d.ts +0 -1
  316. package/dist/types/commitNode.d.ts +0 -89
  317. package/dist/types/commitNode.js +0 -139
  318. package/dist/types/commitNode.test.d.ts +0 -1
  319. package/dist/types/commitNode.test.js +0 -255
  320. package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
  321. package/dist/types/commitWithAssociatedPullRequests.js +0 -145
  322. package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
  323. package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
  324. package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
  325. package/dist/ui/getTargetBranchesFromLabels.js +0 -40
  326. package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
  327. package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
  328. package/dist/utils/sequentially.d.ts +0 -1
  329. package/dist/utils/sequentially.js +0 -10
package/README.md CHANGED
@@ -201,12 +201,20 @@ console.log(commits);
201
201
 
202
202
  /*
203
203
  [{
204
- committedDate: '2021-12-20T14:20:16Z',
204
+ soureCommit: {
205
+ committedDate: '2021-12-20T14:20:16Z',
206
+ sha: 'd421ddcf6157150596581c7885afa3690cec6339',
207
+ message: '[APM] Add note about synthtrace to APM docs (#121633)',
208
+ },
209
+ sourcePullRequest: {
210
+ number: 121633,
211
+ url: 'https://github.com/elastic/kibana/pull/121633'
212
+ mergeCommit: {
213
+ sha: 'd421ddcf6157150596581c7885afa3690cec6339',
214
+ message: '[APM] Add note about synthtrace to APM docs (#121633)',
215
+ }
216
+ },
205
217
  sourceBranch: 'main',
206
- sha: 'd421ddcf6157150596581c7885afa3690cec6339',
207
- originalMessage: '[APM] Add note about synthtrace to APM docs (#121633)',
208
- pullNumber: 121633,
209
- pullUrl: 'https://github.com/elastic/kibana/pull/121633',
210
218
  expectedTargetPullRequests: [
211
219
  {
212
220
  url: 'https://github.com/elastic/kibana/pull/121643',
@@ -1,5 +1,6 @@
1
1
  import { ConfigFileOptions } from './options/ConfigOptions';
2
2
  import { Result } from './runSequentially';
3
+ import { HandledError } from './services/HandledError';
3
4
  import { Commit } from './services/sourceCommit/parseSourceCommit';
4
5
  export declare type BackportResponse = {
5
6
  status: 'success';
@@ -8,7 +9,6 @@ export declare type BackportResponse = {
8
9
  } | {
9
10
  status: 'failure';
10
11
  commits: Commit[];
11
- errorMessage: string;
12
- error: Error;
12
+ error: Error | HandledError;
13
13
  };
14
14
  export declare function backportRun(processArgs: string[], optionsFromModule?: ConfigFileOptions): Promise<BackportResponse>;
@@ -6,21 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.backportRun = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const ora_1 = __importDefault(require("ora"));
9
- const yargs_1 = __importDefault(require("yargs"));
9
+ const yargs_parser_1 = __importDefault(require("yargs-parser"));
10
10
  const options_1 = require("./options/options");
11
11
  const runSequentially_1 = require("./runSequentially");
12
12
  const HandledError_1 = require("./services/HandledError");
13
13
  const env_1 = require("./services/env");
14
14
  const createStatusComment_1 = require("./services/github/v3/createStatusComment");
15
+ const apiRequestV4_1 = require("./services/github/v4/apiRequestV4");
15
16
  const logger_1 = require("./services/logger");
16
17
  const getCommits_1 = require("./ui/getCommits");
17
18
  const getTargetBranches_1 = require("./ui/getTargetBranches");
18
19
  async function backportRun(processArgs, optionsFromModule = {}) {
19
- const argv = (0, yargs_1.default)(processArgs).argv;
20
+ const argv = (0, yargs_parser_1.default)(processArgs);
20
21
  const ci = argv.ci ?? optionsFromModule.ci;
21
22
  const logFilePath = argv.logFilePath ?? optionsFromModule.logFilePath;
22
23
  (0, logger_1.initLogger)({ ci, logFilePath });
23
- const spinner = (0, ora_1.default)().start('Initializing...');
24
+ // don't show spinner for yargs commands that exit the process without stopping the spinner first
25
+ const spinner = (0, ora_1.default)();
26
+ if (!argv.help && !argv.version) {
27
+ spinner.start('Initializing...');
28
+ }
24
29
  let options = null;
25
30
  let commits = [];
26
31
  try {
@@ -38,6 +43,7 @@ async function backportRun(processArgs, optionsFromModule = {}) {
38
43
  options,
39
44
  backportResponse,
40
45
  });
46
+ logger_1.logger.info('backportResponse', backportResponse);
41
47
  return backportResponse;
42
48
  }
43
49
  catch (e) {
@@ -45,7 +51,6 @@ async function backportRun(processArgs, optionsFromModule = {}) {
45
51
  const backportResponse = {
46
52
  status: 'failure',
47
53
  commits,
48
- errorMessage: e.message,
49
54
  error: e,
50
55
  };
51
56
  if (options) {
@@ -54,21 +59,21 @@ async function backportRun(processArgs, optionsFromModule = {}) {
54
59
  backportResponse,
55
60
  });
56
61
  }
57
- if (e instanceof HandledError_1.HandledError) {
62
+ if (e instanceof HandledError_1.HandledError || e instanceof apiRequestV4_1.GithubV4Exception) {
58
63
  (0, logger_1.consoleLog)(e.message);
59
64
  }
60
65
  else if (e instanceof Error) {
61
66
  // output
62
67
  (0, logger_1.consoleLog)('\n');
63
68
  (0, logger_1.consoleLog)(chalk_1.default.bold('⚠️ Ouch! An unhandled error occured 😿'));
64
- (0, logger_1.consoleLog)(`Error message: ${e.message}`);
69
+ (0, logger_1.consoleLog)(e.stack ? e.stack : e.message);
65
70
  (0, logger_1.consoleLog)('Please open an issue in https://github.com/sqren/backport/issues or contact me directly on https://twitter.com/sorenlouv');
66
71
  (0, logger_1.consoleLog)(chalk_1.default.italic(`For additional details see the logs: ${(0, env_1.getLogfilePath)({
67
72
  logFilePath,
68
73
  })}`));
69
- // log file
70
- logger_1.logger.info('Unknown error:', e);
71
74
  }
75
+ logger_1.logger.error('Unhandled exception', e);
76
+ process.exitCode = 1;
72
77
  return backportResponse;
73
78
  }
74
79
  }
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const child_process_1 = require("child_process");
7
+ const path_1 = __importDefault(require("path"));
8
+ const strip_ansi_1 = __importDefault(require("strip-ansi"));
9
+ const child_process_promisified_1 = require("./services/child-process-promisified");
10
+ const getDevAccessToken_1 = require("./test/private/getDevAccessToken");
11
+ const sandbox_1 = require("./test/sandbox");
12
+ const TIMEOUT_IN_SECONDS = 10;
13
+ jest.setTimeout(15000);
14
+ describe('inquirer cli', () => {
15
+ let devAccessToken;
16
+ beforeAll(() => {
17
+ devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
18
+ });
19
+ it('--version', async () => {
20
+ const res = await runBackportAsync([`--version`]);
21
+ expect(res).toContain(process.env.npm_package_version);
22
+ });
23
+ it('-v', async () => {
24
+ const res = await runBackportAsync([`-v`]);
25
+ expect(res).toContain(process.env.npm_package_version);
26
+ });
27
+ it('--help', async () => {
28
+ const res = await runBackportAsync([`--help`]);
29
+ expect(res).toMatchInlineSnapshot(`
30
+ "entrypoint.cli.ts [args]
31
+ Options:
32
+ -v, -V, --version Show version number [boolean]
33
+ --accessToken, --accesstoken Github access token [string]
34
+ -a, --all List all commits [boolean]
35
+ --assignee, --assign Add assignees to the target pull request [array]
36
+ --autoAssign Auto assign the target pull request to yourself [boolean]
37
+ --autoMerge Enable auto-merge for created pull requests [boolean]
38
+ --autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
39
+ merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
40
+ --ci Disable interactive prompts [boolean]
41
+ --cherrypickRef Append commit message with \\"(cherry picked from commit...)
42
+ [boolean]
43
+ --configFile, --config Path to project config [string]
44
+ --since ISO-8601 date for filtering commits [string]
45
+ --until ISO-8601 date for filtering commits [string]
46
+ --dir Location where the temporary repository will be stored
47
+ [string]
48
+ --details Show details about each commit [boolean]
49
+ --editor Editor to be opened during conflict resolution [string]
50
+ --skipRemoteConfig Use local .backportrc.json config instead of loading from
51
+ Github [boolean]
52
+ --fork Create backports in fork or origin repo [boolean]
53
+ --mainline Parent id of merge commit. Defaults to 1 when supplied
54
+ without arguments [number]
55
+ -n, --maxNumber, --number Number of commits to choose from [number]
56
+ --multiple Select multiple branches/commits [boolean]
57
+ --multipleBranches Backport to multiple branches [boolean]
58
+ --multipleCommits Backport multiple commits [boolean]
59
+ --noCherrypickRef Do not append commit message with \\"(cherry picked from
60
+ commit...)\\" [boolean]
61
+ --noStatusComment Don't publish status comment to Github [boolean]
62
+ --noVerify Bypass the pre-commit and commit-msg hooks [boolean]
63
+ --noFork Create backports in the origin repo [boolean]
64
+ -p, --path Only list commits touching files under the specified path
65
+ [array]
66
+ --prDescription, --description Description to be added to pull request [string]
67
+ --prTitle, --title Title of pull request [string]
68
+ --prFilter Filter source pull requests by a query [string]
69
+ --pullNumber, --pr Pull request to backport [number]
70
+ --resetAuthor Set yourself as commit author [boolean]
71
+ --reviewer Add reviewer to the target PR [array]
72
+ --repoOwner Repository owner [string]
73
+ --repoName Repository name [string]
74
+ --repo Repo owner and name [string]
75
+ --sha, --commit Commit sha to backport [string]
76
+ --sourceBranch Specify a non-default branch (normally \\"master\\") to backport
77
+ from [string]
78
+ --sourcePRLabel, --sourcePrLabel Add labels to the source (original) PR [array]
79
+ -b, --targetBranch, --branch Branch(es) to backport to [array]
80
+ --targetBranchChoice List branches to backport to [array]
81
+ -l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
82
+ --verbose Show additional debug information [boolean]
83
+ --verify Opposite of no-verify [boolean]
84
+ --help Show help [boolean]
85
+ For bugs, feature requests or questions: https://github.com/sqren/backport/issues
86
+ Or contact me directly: https://twitter.com/sorenlouv"
87
+ `);
88
+ });
89
+ it('should return error when branch is missing', async () => {
90
+ const res = await runBackportAsync([
91
+ '--skip-remote-config',
92
+ '--repo-owner',
93
+ 'backport-org',
94
+ '--repo-name',
95
+ 'backport-e2e',
96
+ '--accessToken',
97
+ devAccessToken,
98
+ ]);
99
+ expect(res).toMatchInlineSnapshot(`
100
+ "Please specify a target branch: \\"--branch 6.1\\".
101
+ Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
102
+ `);
103
+ });
104
+ it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
105
+ const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
106
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
107
+ await (0, child_process_promisified_1.exec)(`git init`, { cwd: sandboxPath });
108
+ await (0, child_process_promisified_1.exec)(`git remote add origin git@github.com:backport-org/backport-e2e.git`, { cwd: sandboxPath });
109
+ const res = await runBackportAsync(['--accessToken', devAccessToken], {
110
+ cwd: sandboxPath,
111
+ waitForString: 'Select commit',
112
+ });
113
+ expect(res).toMatchInlineSnapshot(`
114
+ "? Select commit (Use arrow keys)
115
+ ❯ 1. Add sheep emoji (#9) 7.8
116
+ 2. Change Ulysses to Gretha (conflict) (#8) 7.x
117
+ 3. Add 🍏 emoji (#5) 7.x, 7.8
118
+ 4. Add family emoji (#2) 7.x
119
+ 5. Add \`backport\` dep
120
+ 6. Merge pull request #1 from backport-org/add-heart-emoji
121
+ 7. Add ❤️ emoji
122
+ 8. Update .backportrc.json
123
+ 9. Bump to 8.0.0
124
+ 10.Add package.json"
125
+ `);
126
+ });
127
+ it('should return error when access token is invalid', async () => {
128
+ const res = await runBackportAsync([
129
+ '--branch',
130
+ 'foo',
131
+ '--repo-owner',
132
+ 'foo',
133
+ '--repo-name',
134
+ 'bar',
135
+ '--accessToken',
136
+ 'some-token',
137
+ ]);
138
+ expect(res).toContain('Please check your access token and make sure it is valid');
139
+ });
140
+ it(`should return error when repo doesn't exist`, async () => {
141
+ const res = await runBackportAsync([
142
+ '--branch',
143
+ 'foo',
144
+ '--repo-owner',
145
+ 'foo',
146
+ '--repo-name',
147
+ 'bar',
148
+ '--author',
149
+ 'sqren',
150
+ '--accessToken',
151
+ devAccessToken,
152
+ ]);
153
+ expect(res).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
154
+ });
155
+ it(`should list commits from master`, async () => {
156
+ jest.setTimeout(TIMEOUT_IN_SECONDS * 1000 * 1.1);
157
+ const output = await runBackportAsync([
158
+ '--branch',
159
+ 'foo',
160
+ '--repo-owner',
161
+ 'backport-org',
162
+ '--repo-name',
163
+ 'backport-e2e',
164
+ '--author',
165
+ 'sqren',
166
+ '--accessToken',
167
+ devAccessToken,
168
+ '--max-number',
169
+ '6',
170
+ ], { waitForString: 'Select commit' });
171
+ expect(output).toMatchInlineSnapshot(`
172
+ "? Select commit (Use arrow keys)
173
+ ❯ 1. Add sheep emoji (#9) 7.8
174
+ 2. Change Ulysses to Gretha (conflict) (#8) 7.x
175
+ 3. Add 🍏 emoji (#5) 7.x, 7.8
176
+ 4. Add family emoji (#2) 7.x
177
+ 5. Add \`backport\` dep
178
+ 6. Merge pull request #1 from backport-org/add-heart-emoji"
179
+ `);
180
+ });
181
+ it(`should limit commits by since and until`, async () => {
182
+ jest.setTimeout(TIMEOUT_IN_SECONDS * 1000 * 1.1);
183
+ const output = await runBackportAsync([
184
+ '--branch',
185
+ 'foo',
186
+ '--repo-owner',
187
+ 'backport-org',
188
+ '--repo-name',
189
+ 'backport-e2e',
190
+ '--accessToken',
191
+ devAccessToken,
192
+ '--since',
193
+ '2020-08-15T00:00:00.000Z',
194
+ '--until',
195
+ '2020-08-15T14:00:00.000Z',
196
+ ], { waitForString: 'Select commit' });
197
+ expect(output).toMatchInlineSnapshot(`
198
+ "? Select commit (Use arrow keys)
199
+ ❯ 1. Add 🍏 emoji (#5) 7.x, 7.8
200
+ 2. Add family emoji (#2) 7.x
201
+ 3. Add \`backport\` dep
202
+ 4. Merge pull request #1 from backport-org/add-heart-emoji
203
+ 5. Add ❤️ emoji
204
+ 6. Update .backportrc.json
205
+ 7. Bump to 8.0.0
206
+ 8. Add package.json
207
+ 9. Update .backportrc.json
208
+ 10.Create .backportrc.json"
209
+ `);
210
+ });
211
+ it(`should list commits from 7.x`, async () => {
212
+ const output = await runBackportAsync([
213
+ '--branch',
214
+ 'foo',
215
+ '--repo-owner',
216
+ 'backport-org',
217
+ '--repo-name',
218
+ 'backport-e2e',
219
+ '--author',
220
+ 'sqren',
221
+ '--accessToken',
222
+ devAccessToken,
223
+ '--max-number',
224
+ '6',
225
+ '--source-branch',
226
+ '7.x',
227
+ ], { waitForString: 'Select commit' });
228
+ expect(output).toMatchInlineSnapshot(`
229
+ "? Select commit (Use arrow keys)
230
+ ❯ 1. Add 🍏 emoji (#5) (#6)
231
+ 2. Change Ulysses to Carol
232
+ 3. Add family emoji (#2) (#4)
233
+ 4. Update .backportrc.json
234
+ 5. Branch off: 7.9.0 (7.x)
235
+ 6. Bump to 8.0.0"
236
+ `);
237
+ });
238
+ });
239
+ function runBackportAsync(cliArgs, { waitForString, cwd, } = {}) {
240
+ const tsNodeBinary = path_1.default.resolve('./node_modules/.bin/ts-node');
241
+ const entrypointFile = path_1.default.resolve('./src/entrypoint.cli.ts');
242
+ const proc = (0, child_process_1.spawn)(tsNodeBinary, [
243
+ '--transpile-only',
244
+ entrypointFile,
245
+ '--log-file-path',
246
+ '/dev/null',
247
+ ...cliArgs,
248
+ ], { cwd });
249
+ const p = new Promise((resolve, reject) => {
250
+ let data = '';
251
+ // fail if expectations hasn't been found within 10 seconds
252
+ const timeout = setTimeout(() => {
253
+ reject(`Expectation '${waitForString}' not found within ${TIMEOUT_IN_SECONDS} seconds in:
254
+ '${data.toString()}'`);
255
+ }, TIMEOUT_IN_SECONDS * 1000);
256
+ proc.stdout.on('data', (chunk) => {
257
+ data += chunk;
258
+ const output = data.toString();
259
+ if (!waitForString || output.includes(waitForString)) {
260
+ clearTimeout(timeout);
261
+ // remove ansi codes and whitespace
262
+ const strippedOutput = (0, strip_ansi_1.default)(output).replace(/\s+$/gm, '');
263
+ resolve(strippedOutput);
264
+ }
265
+ });
266
+ // for debugging only
267
+ // proc.stderr.on('data', (chunk) => {
268
+ // console.log('stderr', chunk.toString());
269
+ // });
270
+ proc.on('error', (err) => {
271
+ reject(`runBackportAsync failed with: ${err}`);
272
+ });
273
+ });
274
+ // kill child process
275
+ return p.finally(() => {
276
+ proc.kill();
277
+ });
278
+ }
@@ -11,9 +11,22 @@ describe('entrypoint.module', () => {
11
11
  repoOwner: 'backport-org',
12
12
  pullNumber: 2,
13
13
  });
14
- expect(commits).toEqual([
14
+ const expectedCommits = [
15
15
  {
16
- committedDate: '2020-08-15T10:44:04Z',
16
+ sourceCommit: {
17
+ committedDate: '2020-08-15T10:44:04Z',
18
+ message: 'Add family emoji (#2)',
19
+ sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
20
+ },
21
+ sourcePullRequest: {
22
+ number: 2,
23
+ url: 'https://github.com/backport-org/backport-e2e/pull/2',
24
+ mergeCommit: {
25
+ message: 'Add family emoji (#2)',
26
+ sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
27
+ },
28
+ },
29
+ sourceBranch: 'master',
17
30
  expectedTargetPullRequests: [
18
31
  {
19
32
  branch: '7.x',
@@ -26,12 +39,8 @@ describe('entrypoint.module', () => {
26
39
  },
27
40
  },
28
41
  ],
29
- originalMessage: 'Add family emoji (#2)',
30
- pullNumber: 2,
31
- pullUrl: 'https://github.com/backport-org/backport-e2e/pull/2',
32
- sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
33
- sourceBranch: 'master',
34
42
  },
35
- ]);
43
+ ];
44
+ expect(commits).toEqual(expectedCommits);
36
45
  });
37
46
  });
@@ -25,7 +25,7 @@ processArgs = []) {
25
25
  }
26
26
  exports.backportRun = backportRun;
27
27
  async function getCommits(options) {
28
- (0, logger_1.initLogger)({ ci: true });
28
+ (0, logger_1.initLogger)({ ci: true, accessToken: options.accessToken });
29
29
  const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(options);
30
30
  if (options.pullNumber) {
31
31
  return [
@@ -1,4 +1,4 @@
1
- import { Logger } from '../services/logger';
1
+ import winston from 'winston';
2
2
  export interface TargetBranchChoice {
3
3
  name: string;
4
4
  checked?: boolean;
@@ -7,7 +7,7 @@ export declare type TargetBranchChoiceOrString = string | TargetBranchChoice;
7
7
  declare type AutoFixConflictsHandler = ({ files, directory, logger, targetBranch, }: {
8
8
  files: string[];
9
9
  directory: string;
10
- logger: Logger;
10
+ logger: winston.Logger;
11
11
  targetBranch: string;
12
12
  }) => boolean | Promise<boolean>;
13
13
  declare type Options = Partial<{
@@ -52,9 +52,12 @@ declare type Options = Partial<{
52
52
  targetBranchChoices: TargetBranchChoiceOrString[];
53
53
  targetBranches: string[];
54
54
  targetPRLabels: string[];
55
+ username: string;
55
56
  verbose: boolean;
56
57
  }>;
57
58
  export declare type ConfigFileOptions = Options & Partial<{
59
+ help: boolean;
60
+ version: boolean;
58
61
  branchLabelMapping: Record<string, string>;
59
62
  /**
60
63
  * @deprecated Replaced by `repoOwner` and `repoName`
@@ -35,6 +35,7 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[], {
35
35
  repoOwner?: string | undefined;
36
36
  repoName?: string | undefined;
37
37
  sourceBranch?: string | undefined;
38
+ username?: string | undefined;
38
39
  dateSince?: string | undefined;
39
40
  dateUntil?: string | undefined;
40
41
  commitPaths?: string[] | undefined;
@@ -47,6 +47,12 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
47
47
  description: 'Sets auto-merge method when using --auto-merge. Default: merge',
48
48
  type: 'string',
49
49
  choices: ['merge', 'rebase', 'squash'],
50
+ })
51
+ .option('author', {
52
+ description: 'Show commits by a specific user',
53
+ alias: 'author',
54
+ type: 'string',
55
+ conflicts: 'all',
50
56
  })
51
57
  .option('ci', {
52
58
  description: 'Disable interactive prompts',
@@ -58,6 +64,7 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
58
64
  conflicts: ['noCherrypickRef'],
59
65
  })
60
66
  .option('configFile', {
67
+ alias: 'config',
61
68
  description: 'Path to project config',
62
69
  type: 'string',
63
70
  })
@@ -209,10 +216,17 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
209
216
  .option('repoOwner', {
210
217
  description: 'Repository owner',
211
218
  type: 'string',
219
+ conflicts: ['repo'],
212
220
  })
213
221
  .option('repoName', {
214
222
  description: 'Repository name',
215
223
  type: 'string',
224
+ conflicts: ['repo'],
225
+ })
226
+ .option('repo', {
227
+ description: 'Repo owner and name',
228
+ type: 'string',
229
+ conflicts: ['repoName', 'repoOwner'],
216
230
  })
217
231
  .option('sha', {
218
232
  conflicts: ['pullNumber', 'prFilter'],
@@ -247,11 +261,9 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
247
261
  type: 'array',
248
262
  string: true,
249
263
  })
250
- .option('author', {
251
- description: 'Show commits by a specific user',
252
- alias: 'author',
264
+ .option('username', {
265
+ description: 'User repo that branch will be pushed to. Defaults to the authenticated user',
253
266
  type: 'string',
254
- conflicts: 'all',
255
267
  })
256
268
  .option('verbose', {
257
269
  description: 'Show additional debug information',
@@ -282,18 +294,27 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
282
294
  $0, _,
283
295
  /* eslint-enable @typescript-eslint/no-unused-vars */
284
296
  multiple, multipleBranches, multipleCommits, all,
297
+ // repoName and repoOwner
298
+ repo,
285
299
  // filters
286
300
  author, since, until,
287
301
  // negations
288
302
  noCherrypickRef, noFork, noStatusComment, noVerify, verify,
289
303
  // array types (should be renamed to plural form)
290
304
  assignee, path, reviewer, sourcePRLabel, targetBranch, targetBranchChoice, targetPRLabel, ...restOptions } = yargsInstance.parseSync();
305
+ const [repoOwner, repoName] = repo?.split('/') ?? [
306
+ restOptions.repoOwner,
307
+ restOptions.repoName,
308
+ ];
291
309
  return (0, excludeUndefined_1.excludeUndefined)({
292
310
  ...restOptions,
311
+ // repoName and repoOwner
312
+ repoOwner,
313
+ repoName,
293
314
  // filters
294
315
  author: all ? null : author,
295
- dateSince: since,
296
- dateUntil: until,
316
+ dateSince: since ? new Date(since).toISOString() : undefined,
317
+ dateUntil: until ? new Date(until).toISOString() : undefined,
297
318
  // `multiple` is a cli-only flag to override `multipleBranches` and `multipleCommits`
298
319
  multipleBranches: multiple ?? multipleBranches,
299
320
  multipleCommits: multiple ?? multipleCommits,
@@ -33,16 +33,6 @@ describe('getOptionsFromCliArgs', () => {
33
33
  });
34
34
  });
35
35
  });
36
- // blocked by: https://github.com/yargs/yargs/issues/1853
37
- describe('help', () => {
38
- // eslint-disable-next-line jest/no-commented-out-tests
39
- // it('should output help', () => {
40
- // const argv = ['--help'];
41
- // expect(() =>
42
- // getOptionsFromCliArgs(argv, { exitOnError: false, returnHelp: true })
43
- // ).toThrow('asa');
44
- // });
45
- });
46
36
  describe('sourcePRLabels', () => {
47
37
  it('should handle all variations', () => {
48
38
  const argv = [
@@ -149,4 +139,32 @@ describe('getOptionsFromCliArgs', () => {
149
139
  expect(res.targetBranches).toEqual(['6.0']);
150
140
  });
151
141
  });
142
+ describe('since/until', () => {
143
+ it('should always be UTC time (configured globally in jest.config.js)', () => {
144
+ expect(new Date().getTimezoneOffset()).toBe(0);
145
+ });
146
+ it('accepts ISO dates', () => {
147
+ const argv = [
148
+ '--since',
149
+ '2020-08-15T00:00:00.000Z',
150
+ '--until',
151
+ '2020-08-15T14:00:00.000Z',
152
+ ];
153
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
154
+ expect(res.dateSince).toEqual('2020-08-15T00:00:00.000Z');
155
+ expect(res.dateUntil).toEqual('2020-08-15T14:00:00.000Z');
156
+ });
157
+ it('accepts non-ISO dates', () => {
158
+ const argv = ['--since', '2020-08-15', '--until', '2020-08-15 14:00'];
159
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
160
+ expect(res.dateSince).toEqual('2020-08-15T00:00:00.000Z');
161
+ expect(res.dateUntil).toEqual('2020-08-15T14:00:00.000Z');
162
+ });
163
+ it('accepts years', () => {
164
+ const argv = ['--since', '2020', '--until', '2021'];
165
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
166
+ expect(res.dateSince).toEqual('2020-01-01T00:00:00.000Z');
167
+ expect(res.dateUntil).toEqual('2021-01-01T00:00:00.000Z');
168
+ });
169
+ });
152
170
  });
@@ -13,13 +13,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
13
13
  autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
14
14
  files: string[];
15
15
  directory: string;
16
- logger: {
17
- error: (message: string, meta?: unknown) => void;
18
- warn: (message: string, meta?: unknown) => void;
19
- info: (message: string, meta?: unknown) => void;
20
- verbose: (message: string, meta?: unknown) => void;
21
- debug: (message: string, meta?: unknown) => void;
22
- };
16
+ logger: import("winston").Logger;
23
17
  targetBranch: string;
24
18
  }) => boolean | Promise<boolean>) | undefined;
25
19
  autoMerge?: boolean | undefined;
@@ -58,7 +52,10 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
58
52
  targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
59
53
  targetBranches?: string[] | undefined;
60
54
  targetPRLabels?: string[] | undefined;
55
+ username?: string | undefined;
61
56
  verbose?: boolean | undefined;
57
+ help?: boolean | undefined;
58
+ version?: boolean | undefined;
62
59
  branchLabelMapping?: Record<string, string> | undefined;
63
60
  upstream?: string | undefined;
64
61
  branches?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;