backport 6.1.4 → 6.3.0-beta

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 (291) hide show
  1. package/README.md +53 -42
  2. package/dist/{main.d.ts → backportRun.d.ts} +3 -3
  3. package/dist/{main.js → backportRun.js} +24 -9
  4. package/dist/entrypoint.cli.js +3 -5
  5. package/dist/entrypoint.module.d.ts +4 -3
  6. package/dist/entrypoint.module.js +9 -7
  7. package/dist/options/ConfigOptions.d.ts +6 -0
  8. package/dist/options/cliArgs.d.ts +17 -13
  9. package/dist/options/cliArgs.js +25 -6
  10. package/dist/options/config/config.d.ts +12 -1
  11. package/dist/options/config/config.js +8 -7
  12. package/dist/options/config/globalConfig.d.ts +2 -2
  13. package/dist/options/config/globalConfig.js +18 -16
  14. package/dist/options/config/projectConfig.d.ts +3 -1
  15. package/dist/options/config/projectConfig.js +5 -2
  16. package/dist/options/config/readConfigFile.d.ts +28 -22
  17. package/dist/options/config/readConfigFile.js +2 -2
  18. package/dist/options/options.d.ts +19 -37
  19. package/dist/options/options.js +44 -31
  20. package/dist/runSequentially.d.ts +0 -1
  21. package/dist/runSequentially.js +0 -1
  22. package/dist/scripts/postinstall.js +3 -3
  23. package/dist/services/HandledError.d.ts +6 -4
  24. package/dist/services/HandledError.js +18 -3
  25. package/dist/services/child-process-promisified.d.ts +3 -1
  26. package/dist/services/env.d.ts +5 -4
  27. package/dist/services/env.js +13 -11
  28. package/dist/services/git.d.ts +22 -9
  29. package/dist/services/git.js +66 -54
  30. package/dist/services/github/commitFormatters.d.ts +0 -1
  31. package/dist/services/github/commitFormatters.js +1 -8
  32. package/dist/services/github/v3/createPullRequest.js +16 -10
  33. package/dist/services/github/v3/createStatusComment.d.ts +1 -1
  34. package/dist/services/github/v3/createStatusComment.js +34 -18
  35. package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
  36. package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -7
  37. package/dist/services/github/v4/apiRequestV4.d.ts +21 -17
  38. package/dist/services/github/v4/apiRequestV4.js +38 -28
  39. package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
  40. package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
  41. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
  42. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
  43. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
  44. package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
  45. package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
  46. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
  47. package/dist/services/github/v4/{fetchProjectConfig.d.ts → fetchRemoteProjectConfig.d.ts} +1 -1
  48. package/dist/services/github/v4/{fetchProjectConfig.js → fetchRemoteProjectConfig.js} +3 -3
  49. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +7 -1
  50. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +38 -39
  51. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +2 -1
  52. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
  53. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
  54. package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
  55. package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
  56. package/dist/services/logger.d.ts +9 -4
  57. package/dist/services/logger.js +40 -37
  58. package/dist/services/prompts.js +12 -10
  59. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
  60. package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
  61. package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
  62. package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
  63. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
  64. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +13 -14
  65. package/dist/ui/getCommits.js +8 -14
  66. package/dist/ui/getCommitsWithoutBackports.js +6 -6
  67. package/dist/ui/getTargetBranches.js +1 -1
  68. package/dist/ui/maybeSetupRepo.js +24 -10
  69. package/dist/utils/maybe.d.ts +1 -0
  70. package/dist/utils/maybe.js +7 -0
  71. package/dist/utils/packageVersion.d.ts +1 -0
  72. package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
  73. package/dist/utils/redact.d.ts +1 -0
  74. package/dist/utils/redact.js +7 -0
  75. package/package.json +24 -20
  76. package/yarn.lock +160 -237
  77. package/dist/entrypoint.module.private.test.d.ts +0 -1
  78. package/dist/entrypoint.module.private.test.js +0 -37
  79. package/dist/index.d.ts +0 -783
  80. package/dist/index.js +0 -8001
  81. package/dist/ink.d.ts +0 -1
  82. package/dist/ink.js +0 -49
  83. package/dist/options/cliArgs.test.d.ts +0 -1
  84. package/dist/options/cliArgs.test.js +0 -152
  85. package/dist/options/config/config.test.d.ts +0 -1
  86. package/dist/options/config/config.test.js +0 -22
  87. package/dist/options/config/getOptionsFromGit.d.ts +0 -4
  88. package/dist/options/config/getOptionsFromGit.js +0 -8
  89. package/dist/options/config/globalConfig.test.d.ts +0 -1
  90. package/dist/options/config/globalConfig.test.js +0 -74
  91. package/dist/options/config/projectConfig.test.d.ts +0 -1
  92. package/dist/options/config/projectConfig.test.js +0 -99
  93. package/dist/options/getValidatedOptions.d.ts +0 -49
  94. package/dist/options/getValidatedOptions.js +0 -45
  95. package/dist/options/getValidatedOptions.test.d.ts +0 -1
  96. package/dist/options/getValidatedOptions.test.js +0 -97
  97. package/dist/options/options.test.d.ts +0 -1
  98. package/dist/options/options.test.js +0 -335
  99. package/dist/options/parseRequiredOptions.d.ts +0 -71
  100. package/dist/options/parseRequiredOptions.js +0 -68
  101. package/dist/options/parseRequiredOptions.test.d.ts +0 -1
  102. package/dist/options/parseRequiredOptions.test.js +0 -122
  103. package/dist/runSequentially.test.d.ts +0 -1
  104. package/dist/runSequentially.test.js +0 -199
  105. package/dist/runWithOptions.d.ts +0 -9
  106. package/dist/runWithOptions.js +0 -43
  107. package/dist/runWithOptions.test.d.ts +0 -1
  108. package/dist/runWithOptions.test.js +0 -304
  109. package/dist/scripts/generate-gql.d.ts +0 -1
  110. package/dist/scripts/generate-gql.js +0 -15
  111. package/dist/scripts/postinstall.test.d.ts +0 -1
  112. package/dist/scripts/postinstall.test.js +0 -53
  113. package/dist/services/env.test.d.ts +0 -1
  114. package/dist/services/env.test.js +0 -27
  115. package/dist/services/fs-promisified.d.ts +0 -6
  116. package/dist/services/fs-promisified.js +0 -12
  117. package/dist/services/getExpectedTarget.d.ts +0 -9
  118. package/dist/services/getExpectedTarget.js +0 -77
  119. package/dist/services/getExpectedTargetPullRequests.d.ts +0 -9
  120. package/dist/services/getExpectedTargetPullRequests.js +0 -77
  121. package/dist/services/git.integration.test.d.ts +0 -1
  122. package/dist/services/git.integration.test.js +0 -168
  123. package/dist/services/git.test.d.ts +0 -1
  124. package/dist/services/git.test.js +0 -503
  125. package/dist/services/github/commitFormatters.test.d.ts +0 -1
  126. package/dist/services/github/commitFormatters.test.js +0 -11
  127. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
  128. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
  129. package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
  130. package/dist/services/github/v3/createPullRequest.test.js +0 -110
  131. package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
  132. package/dist/services/github/v3/createStatusComment.test.js +0 -291
  133. package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
  134. package/dist/services/github/v4/apiRequestV4.test.js +0 -82
  135. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
  136. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  137. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
  138. package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -28
  139. package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
  140. package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
  141. package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
  142. package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
  143. package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
  144. package/dist/services/github/v4/fetchCommitBySha.js +0 -95
  145. package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
  146. package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
  147. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
  148. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -78
  149. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
  150. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -134
  151. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
  152. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -115
  153. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
  154. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -200
  155. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
  156. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -131
  157. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
  158. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
  159. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
  160. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
  161. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  162. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -85
  163. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
  164. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
  165. package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
  166. package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
  167. package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
  168. package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
  169. package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
  170. package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
  171. package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
  172. package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
  173. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
  174. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
  175. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
  176. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
  177. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
  178. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
  179. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
  180. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
  181. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
  182. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
  183. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
  184. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
  185. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
  186. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
  187. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
  188. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -47
  189. package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
  190. package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
  191. package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
  192. package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
  193. package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
  194. package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
  195. package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
  196. package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
  197. package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
  198. package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
  199. package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
  200. package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
  201. package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  202. package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
  203. package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
  204. package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
  205. package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
  206. package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
  207. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
  208. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -130
  209. package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
  210. package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
  211. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
  212. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
  213. package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
  214. package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
  215. package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
  216. package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
  217. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
  218. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -154
  219. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
  220. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
  221. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
  222. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
  223. package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
  224. package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
  225. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
  226. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
  227. package/dist/services/prompt.test.d.ts +0 -1
  228. package/dist/services/prompt.test.js +0 -87
  229. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
  230. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -433
  231. package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
  232. package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
  233. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
  234. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
  235. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
  236. package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -237
  237. package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
  238. package/dist/services/sourceCommit/sourceCommit.js +0 -86
  239. package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
  240. package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
  241. package/dist/services/sourceCommit.d.ts +0 -78
  242. package/dist/services/sourceCommit.js +0 -86
  243. package/dist/services/sourceCommit.test.d.ts +0 -1
  244. package/dist/services/sourceCommit.test.js +0 -280
  245. package/dist/test/ExecError.d.ts +0 -16
  246. package/dist/test/ExecError.js +0 -15
  247. package/dist/test/inquirer.private.test.d.ts +0 -1
  248. package/dist/test/inquirer.private.test.js +0 -168
  249. package/dist/test/integration/createSpies.d.ts +0 -17
  250. package/dist/test/integration/createSpies.js +0 -85
  251. package/dist/test/integration/envConstants.d.ts +0 -5
  252. package/dist/test/integration/envConstants.js +0 -9
  253. package/dist/test/integration/helpers.d.ts +0 -7
  254. package/dist/test/integration/helpers.js +0 -31
  255. package/dist/test/integration/integration.private.test.d.ts +0 -1
  256. package/dist/test/integration/integration.private.test.js +0 -327
  257. package/dist/test/integration/integration.test.d.ts +0 -1
  258. package/dist/test/integration/integration.test.js +0 -214
  259. package/dist/test/mockConfigFiles.d.ts +0 -5
  260. package/dist/test/mockConfigFiles.js +0 -37
  261. package/dist/test/nockHelpers.d.ts +0 -16
  262. package/dist/test/nockHelpers.js +0 -32
  263. package/dist/test/private/getDevAccessToken.d.ts +0 -1
  264. package/dist/test/private/getDevAccessToken.js +0 -24
  265. package/dist/test/setupFiles/automatic-mocks.d.ts +0 -0
  266. package/dist/test/setupFiles/automatic-mocks.js +0 -43
  267. package/dist/types/Commit.d.ts +0 -85
  268. package/dist/types/Commit.js +0 -139
  269. package/dist/types/PromiseReturnType.d.ts +0 -1
  270. package/dist/types/commitNode.d.ts +0 -89
  271. package/dist/types/commitNode.js +0 -139
  272. package/dist/types/commitNode.test.d.ts +0 -1
  273. package/dist/types/commitNode.test.js +0 -255
  274. package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
  275. package/dist/types/commitWithAssociatedPullRequests.js +0 -145
  276. package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
  277. package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
  278. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
  279. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -432
  280. package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
  281. package/dist/ui/getCommitsWithoutBackports.test.js +0 -259
  282. package/dist/ui/getTargetBranches.test.d.ts +0 -1
  283. package/dist/ui/getTargetBranches.test.js +0 -180
  284. package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
  285. package/dist/ui/getTargetBranchesFromLabels.js +0 -40
  286. package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
  287. package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
  288. package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
  289. package/dist/ui/maybeSetupRepo.test.js +0 -74
  290. package/dist/utils/excludeUndefined.test.d.ts +0 -1
  291. package/dist/utils/excludeUndefined.test.js +0 -24
@@ -1,199 +0,0 @@
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
- const os_1 = __importDefault(require("os"));
26
- const lodash_1 = require("lodash");
27
- const nock_1 = __importDefault(require("nock"));
28
- const runSequentially_1 = require("./runSequentially");
29
- const childProcess = __importStar(require("./services/child-process-promisified"));
30
- const nockHelpers_1 = require("./test/nockHelpers");
31
- jest.mock('./services/child-process-promisified', () => {
32
- return {
33
- exec: jest.fn(async (cmd) => {
34
- throw new Error(`Mock required for exec with cmd: "${cmd}"`);
35
- }),
36
- execAsCallback: jest.fn((...args) => {
37
- (0, lodash_1.last)(args)();
38
- return {
39
- stderr: {
40
- on: () => null,
41
- },
42
- };
43
- }),
44
- };
45
- });
46
- describe('runSequentially', () => {
47
- let rpcExecMock;
48
- let rpcExecOriginalMock;
49
- let res;
50
- let createPullRequestCalls;
51
- afterEach(() => {
52
- jest.clearAllMocks();
53
- nock_1.default.cleanAll();
54
- });
55
- beforeEach(async () => {
56
- jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
57
- const options = {
58
- accessToken: 'myAccessToken',
59
- assignees: [],
60
- authenticatedUsername: 'sqren_authenticated',
61
- author: 'sqren',
62
- autoAssign: false,
63
- autoFixConflicts: undefined,
64
- autoMerge: false,
65
- autoMergeMethod: 'merge',
66
- backportBinary: 'node scripts/backport',
67
- branchLabelMapping: undefined,
68
- cherrypickRef: true,
69
- ci: false,
70
- commitPaths: [],
71
- dateSince: null,
72
- dateUntil: null,
73
- details: false,
74
- editor: 'code',
75
- fork: true,
76
- gitHostname: 'github.com',
77
- githubApiBaseUrlV3: 'https://api.github.com',
78
- githubApiBaseUrlV4: 'http://localhost/graphql',
79
- historicalBranchLabelMappings: [],
80
- mainline: undefined,
81
- maxNumber: 10,
82
- multipleBranches: false,
83
- multipleCommits: false,
84
- noVerify: true,
85
- prDescription: 'myPrDescription',
86
- prFilter: undefined,
87
- prTitle: 'myPrTitle {targetBranch} {commitMessages}',
88
- pullNumber: undefined,
89
- repoName: 'kibana',
90
- repoOwner: 'elastic',
91
- resetAuthor: false,
92
- reviewers: [],
93
- sha: undefined,
94
- skipRemoteConfig: undefined,
95
- sourceBranch: 'my-source-branch-from-options',
96
- sourcePRLabels: [],
97
- targetBranches: [],
98
- targetBranchChoices: [
99
- { name: '6.x' },
100
- { name: '6.0' },
101
- { name: '5.6' },
102
- { name: '5.5' },
103
- { name: '5.4' },
104
- ],
105
- targetPRLabels: [],
106
- verbose: false,
107
- };
108
- rpcExecMock = jest
109
- .spyOn(childProcess, 'exec')
110
- .mockResolvedValue({ stdout: 'success', stderr: '' });
111
- rpcExecOriginalMock = jest.spyOn(childProcess, 'execAsCallback');
112
- const scope = (0, nock_1.default)('https://api.github.com')
113
- .post('/repos/elastic/kibana/pulls')
114
- .reply(200, {
115
- number: 1337,
116
- html_url: 'myHtmlUrl',
117
- });
118
- createPullRequestCalls = (0, nockHelpers_1.listenForCallsToNockScope)(scope);
119
- const commits = [
120
- {
121
- sha: 'abcd',
122
- committedDate: '1',
123
- expectedTargetPullRequests: [],
124
- originalMessage: 'My commit message',
125
- sourceBranch: 'master',
126
- pullNumber: 55,
127
- },
128
- ];
129
- const targetBranches = ['7.x'];
130
- res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
131
- scope.done();
132
- });
133
- it('returns pull request', () => {
134
- expect(res).toEqual([
135
- {
136
- didUpdate: false,
137
- pullRequestNumber: 1337,
138
- pullRequestUrl: 'myHtmlUrl',
139
- status: 'success',
140
- targetBranch: '7.x',
141
- },
142
- ]);
143
- });
144
- it('creates pull request', () => {
145
- expect(createPullRequestCalls).toMatchInlineSnapshot(`
146
- Array [
147
- Object {
148
- "base": "7.x",
149
- "body": "# Backport
150
-
151
- This is an automatic backport to \`7.x\` of:
152
- - #55
153
-
154
- ### Questions ?
155
- Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
156
-
157
- myPrDescription",
158
- "head": "sqren_authenticated:backport/7.x/pr-55",
159
- "title": "myPrTitle 7.x My commit message",
160
- },
161
- ]
162
- `);
163
- });
164
- it('should run all commands in the correct directory', () => {
165
- expect(rpcExecMock.mock.calls.every(
166
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
167
- ([cmd, opts]) => opts.cwd === '/myHomeDir/.backport/repositories/elastic/kibana')).toBe(true);
168
- });
169
- it('exec should be called with correct args', () => {
170
- expect(rpcExecMock).toHaveBeenCalledTimes(10);
171
- expect(rpcExecMock.mock.calls.map(([cmd]) => cmd)).toEqual([
172
- 'git remote rm origin',
173
- 'git remote rm sqren_authenticated',
174
- 'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
175
- 'git remote rm elastic',
176
- 'git remote add elastic https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
177
- 'git reset --hard && git clean -d --force && git fetch elastic 7.x && git checkout -B backport/7.x/pr-55 elastic/7.x --no-track',
178
- 'git fetch elastic master:master --force',
179
- 'git cherry-pick -x abcd',
180
- 'git push sqren_authenticated backport/7.x/pr-55:backport/7.x/pr-55 --force',
181
- 'git reset --hard && git checkout my-source-branch-from-options && git branch -D backport/7.x/pr-55',
182
- ]);
183
- });
184
- it('git clone should be called with correct args', () => {
185
- expect(rpcExecOriginalMock).toHaveBeenCalledTimes(1);
186
- expect(rpcExecOriginalMock.mock.calls).toMatchInlineSnapshot(`
187
- Array [
188
- Array [
189
- "git clone https://x-access-token:myAccessToken@github.com/elastic/kibana.git --progress",
190
- Object {
191
- "cwd": "/myHomeDir/.backport/repositories/elastic",
192
- "maxBuffer": 104857600,
193
- },
194
- [Function],
195
- ],
196
- ]
197
- `);
198
- });
199
- });
@@ -1,9 +0,0 @@
1
- import { ValidConfigOptions } from './options/options';
2
- export declare type Result = {
3
- success: boolean;
4
- targetBranch: string;
5
- pullRequestUrl?: string;
6
- errorMessage?: string;
7
- error?: Error;
8
- };
9
- export declare function runWithOptions(options: ValidConfigOptions): Promise<Result[]>;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runWithOptions = void 0;
4
- const HandledError_1 = require("./services/HandledError");
5
- const logger_1 = require("./services/logger");
6
- const sequentially_1 = require("./services/sequentially");
7
- const cherrypickAndCreateTargetPullRequest_1 = require("./ui/cherrypickAndCreateTargetPullRequest");
8
- const getCommits_1 = require("./ui/getCommits");
9
- const getTargetBranches_1 = require("./ui/getTargetBranches");
10
- const maybeSetupRepo_1 = require("./ui/maybeSetupRepo");
11
- async function runWithOptions(options) {
12
- logger_1.logger.verbose('Backport options', options);
13
- const commits = await (0, getCommits_1.getCommits)(options);
14
- const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
15
- await (0, maybeSetupRepo_1.maybeSetupRepo)(options);
16
- const results = [];
17
- await (0, sequentially_1.sequentially)(targetBranches, async (targetBranch) => {
18
- logger_1.logger.info(`Backporting ${JSON.stringify(commits)} to ${targetBranch}`);
19
- try {
20
- const pullRequest = await (0, cherrypickAndCreateTargetPullRequest_1.cherrypickAndCreateTargetPullRequest)({
21
- options,
22
- commits,
23
- targetBranch,
24
- });
25
- results.push({
26
- targetBranch,
27
- success: true,
28
- pullRequestUrl: pullRequest.url,
29
- });
30
- }
31
- catch (e) {
32
- const isHandledError = e instanceof HandledError_1.HandledError;
33
- const errorMessage = isHandledError
34
- ? (0, logger_1.redact)(e.message)
35
- : 'An unhandled error occurred. Please consult the logs';
36
- results.push({ targetBranch, success: false, errorMessage, error: e });
37
- (0, logger_1.consoleLog)(errorMessage);
38
- }
39
- });
40
- // return the results for consumers to programatically read
41
- return results;
42
- }
43
- exports.runWithOptions = runWithOptions;
@@ -1 +0,0 @@
1
- export {};
@@ -1,304 +0,0 @@
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
- const os_1 = __importDefault(require("os"));
26
- const inquirer_1 = __importDefault(require("inquirer"));
27
- const lodash_1 = require("lodash");
28
- const nock_1 = __importDefault(require("nock"));
29
- const runWithOptions_1 = require("./runWithOptions");
30
- const childProcess = __importStar(require("./services/child-process-promisified"));
31
- const fs = __importStar(require("./services/fs-promisified"));
32
- const commitsByAuthorMock_1 = require("./services/github/v4/mocks/commitsByAuthorMock");
33
- const nockHelpers_1 = require("./test/nockHelpers");
34
- jest.mock('./services/child-process-promisified', () => {
35
- return {
36
- exec: jest.fn(async (cmd) => {
37
- throw new Error(`Mock required for exec with cmd: "${cmd}"`);
38
- }),
39
- execAsCallback: jest.fn((...args) => {
40
- (0, lodash_1.last)(args)();
41
- return {
42
- stderr: {
43
- on: () => null,
44
- },
45
- };
46
- }),
47
- };
48
- });
49
- describe('runWithOptions', () => {
50
- let rpcExecMock;
51
- let rpcExecOriginalMock;
52
- let inquirerPromptMock;
53
- let res;
54
- let createPullRequestCalls;
55
- let commitsByAuthorCalls;
56
- let authorIdCalls;
57
- afterEach(() => {
58
- jest.clearAllMocks();
59
- nock_1.default.cleanAll();
60
- });
61
- beforeEach(async () => {
62
- jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
63
- const options = {
64
- accessToken: 'myAccessToken',
65
- all: false,
66
- assignees: [],
67
- author: 'sqren',
68
- autoAssign: false,
69
- autoFixConflicts: undefined,
70
- autoMerge: false,
71
- autoMergeMethod: 'merge',
72
- branchLabelMapping: undefined,
73
- ci: false,
74
- cherrypickRef: true,
75
- commitPaths: [],
76
- details: false,
77
- editor: 'code',
78
- forceLocalConfig: undefined,
79
- fork: true,
80
- gitHostname: 'github.com',
81
- githubApiBaseUrlV3: 'https://api.github.com',
82
- githubApiBaseUrlV4: 'http://localhost/graphql',
83
- mainline: undefined,
84
- maxNumber: 10,
85
- multipleBranches: false,
86
- multipleCommits: false,
87
- noVerify: true,
88
- prDescription: 'myPrDescription',
89
- prFilter: undefined,
90
- prTitle: 'myPrTitle {targetBranch} {commitMessages}',
91
- pullNumber: undefined,
92
- repoName: 'kibana',
93
- repoOwner: 'elastic',
94
- resetAuthor: false,
95
- sha: undefined,
96
- sourceBranch: 'my-source-branch-from-options',
97
- sourcePRLabels: [],
98
- targetBranches: [],
99
- upstream: 'elastic/kibana',
100
- targetBranchChoices: [
101
- { name: '6.x' },
102
- { name: '6.0' },
103
- { name: '5.6' },
104
- { name: '5.5' },
105
- { name: '5.4' },
106
- ],
107
- targetPRLabels: [],
108
- username: 'sqren',
109
- verbose: false,
110
- };
111
- rpcExecMock = jest
112
- .spyOn(childProcess, 'exec')
113
- .mockResolvedValue({ stdout: 'success', stderr: '' });
114
- rpcExecOriginalMock = jest.spyOn(childProcess, 'execAsCallback');
115
- jest.spyOn(fs, 'writeFile').mockResolvedValue(undefined);
116
- inquirerPromptMock = jest
117
- .spyOn(inquirer_1.default, 'prompt')
118
- .mockImplementationOnce((async (args) => {
119
- return { promptResult: args[0].choices[0].value };
120
- }))
121
- .mockImplementationOnce((async (args) => {
122
- return { promptResult: args[0].choices[0].name };
123
- }));
124
- authorIdCalls = (0, nockHelpers_1.mockGqlRequest)({
125
- name: 'AuthorId',
126
- statusCode: 200,
127
- body: { data: { user: { id: 'sqren_author_id' } } },
128
- });
129
- commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
130
- name: 'CommitsByAuthor',
131
- statusCode: 200,
132
- body: { data: commitsByAuthorMock_1.commitsByAuthorMock },
133
- });
134
- const scope = (0, nock_1.default)('https://api.github.com')
135
- .post('/repos/elastic/kibana/pulls')
136
- .reply(200, { html_url: 'pull request url', number: 1337 });
137
- createPullRequestCalls = (0, nockHelpers_1.getNockCallsForScope)(scope);
138
- res = await (0, runWithOptions_1.runWithOptions)(options);
139
- scope.done();
140
- });
141
- it('returns pull request', () => {
142
- expect(res).toEqual([
143
- {
144
- pullRequestUrl: 'pull request url',
145
- success: true,
146
- targetBranch: '6.x',
147
- },
148
- ]);
149
- });
150
- it('creates pull request', () => {
151
- expect(createPullRequestCalls).toEqual([
152
- {
153
- base: '6.x',
154
- body: 'Backports the following commits to 6.x:\n - Add 👻 (2e63475c)\n\nmyPrDescription',
155
- head: 'sqren:backport/6.x/commit-2e63475c',
156
- title: 'myPrTitle 6.x Add 👻',
157
- },
158
- ]);
159
- });
160
- it('retrieves author id', () => {
161
- expect(authorIdCalls).toMatchInlineSnapshot(`
162
- Array [
163
- Object {
164
- "query": "
165
- query AuthorId($login: String!) {
166
- user(login: $login) {
167
- id
168
- }
169
- }
170
- ",
171
- "variables": Object {
172
- "login": "sqren",
173
- },
174
- },
175
- ]
176
- `);
177
- });
178
- it('retrieves commits by author', () => {
179
- expect(commitsByAuthorCalls.map((body) => body.variables)).toEqual([
180
- {
181
- authorId: 'sqren_author_id',
182
- maxNumber: 10,
183
- commitPath: null,
184
- repoName: 'kibana',
185
- repoOwner: 'elastic',
186
- sourceBranch: 'my-source-branch-from-options',
187
- },
188
- ]);
189
- });
190
- it('prompt calls should match snapshot', () => {
191
- expect(inquirer_1.default.prompt).toHaveBeenCalledTimes(2);
192
- expect(
193
- // @ts-expect-error
194
- inquirerPromptMock.mock.calls[0][0][0].choices.map(({ name, short }) => ({
195
- name,
196
- short,
197
- }))).toMatchInlineSnapshot(`
198
- Array [
199
- Object {
200
- "name": "1. Add 👻 ",
201
- "short": "2e63475c",
202
- },
203
- Object {
204
- "name": "2. Add witch (#85) ",
205
- "short": "#85 (f3b618b9)",
206
- },
207
- Object {
208
- "name": "3. Add SF mention (#80) 6.3",
209
- "short": "#80 (79cf1845)",
210
- },
211
- Object {
212
- "name": "4. Add backport config ",
213
- "short": "3827bbba",
214
- },
215
- Object {
216
- "name": "5. Initial commit ",
217
- "short": "5ea0da55",
218
- },
219
- ]
220
- `);
221
- });
222
- it('exec should be called with correct args', () => {
223
- expect(rpcExecMock).toHaveBeenCalledTimes(10);
224
- expect(rpcExecMock.mock.calls).toMatchInlineSnapshot(`
225
- Array [
226
- Array [
227
- "git remote rm origin",
228
- Object {
229
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
230
- },
231
- ],
232
- Array [
233
- "git remote rm sqren",
234
- Object {
235
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
236
- },
237
- ],
238
- Array [
239
- "git remote add sqren https://x-access-token:myAccessToken@github.com/sqren/kibana.git",
240
- Object {
241
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
242
- },
243
- ],
244
- Array [
245
- "git remote rm elastic",
246
- Object {
247
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
248
- },
249
- ],
250
- Array [
251
- "git remote add elastic https://x-access-token:myAccessToken@github.com/elastic/kibana.git",
252
- Object {
253
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
254
- },
255
- ],
256
- Array [
257
- "git reset --hard && git clean -d --force && git fetch elastic 6.x && git checkout -B backport/6.x/commit-2e63475c elastic/6.x --no-track",
258
- Object {
259
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
260
- },
261
- ],
262
- Array [
263
- "git fetch elastic my-source-branch-from-options:my-source-branch-from-options --force",
264
- Object {
265
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
266
- },
267
- ],
268
- Array [
269
- "git cherry-pick 2e63475c483f7844b0f2833bc57fdee32095bacb",
270
- Object {
271
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
272
- },
273
- ],
274
- Array [
275
- "git push sqren backport/6.x/commit-2e63475c:backport/6.x/commit-2e63475c --force",
276
- Object {
277
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
278
- },
279
- ],
280
- Array [
281
- "git reset --hard && git checkout my-source-branch-from-options && git branch -D backport/6.x/commit-2e63475c",
282
- Object {
283
- "cwd": "/myHomeDir/.backport/repositories/elastic/kibana",
284
- },
285
- ],
286
- ]
287
- `);
288
- });
289
- it('git clone should be called with correct args', () => {
290
- expect(rpcExecOriginalMock).toHaveBeenCalledTimes(1);
291
- expect(rpcExecOriginalMock.mock.calls).toMatchInlineSnapshot(`
292
- Array [
293
- Array [
294
- "git clone https://x-access-token:myAccessToken@github.com/elastic/kibana.git --progress",
295
- Object {
296
- "cwd": "/myHomeDir/.backport/repositories/elastic",
297
- "maxBuffer": 104857600,
298
- },
299
- [Function],
300
- ],
301
- ]
302
- `);
303
- });
304
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fetchCommitBySha_1 = require("../services/github/v4/fetchCommits/fetchCommitBySha");
4
- const getDevAccessToken_1 = require("../test/private/getDevAccessToken");
5
- async function init() {
6
- const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
7
- const res = (0, fetchCommitBySha_1.fetchCommitBySha)({
8
- accessToken,
9
- githubApiBaseUrlV4: 'https://api.github.com/graphql',
10
- repoName: 'backport-org',
11
- repoOwner: 'backport-e2e',
12
- sha: 'b484e161b705b39dbbfc5005e67ca24d05b23c37',
13
- sourceBranch: 'main',
14
- });
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
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
- const os_1 = __importDefault(require("os"));
26
- const globalConfig = __importStar(require("../options/config/globalConfig"));
27
- const logger = __importStar(require("../services/logger"));
28
- const postinstall_1 = require("./postinstall");
29
- describe('postinstall', () => {
30
- beforeEach(() => {
31
- jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
32
- });
33
- afterEach(() => {
34
- jest.clearAllMocks();
35
- });
36
- it("should create global config if it doesn't exist", async () => {
37
- const createGlobalConfigAndFolderIfNotExistSpy = jest
38
- .spyOn(globalConfig, 'createGlobalConfigAndFolderIfNotExist')
39
- .mockResolvedValueOnce(true);
40
- await (0, postinstall_1.postinstall)();
41
- expect(createGlobalConfigAndFolderIfNotExistSpy).toBeCalledTimes(1);
42
- expect(logger.consoleLog).toBeCalledWith('Global config successfully created in /myHomeDir/.backport/config.json');
43
- });
44
- it('should not create global config if it already exists', async () => {
45
- const consoleSpy = jest.spyOn(console, 'log');
46
- const createGlobalConfigAndFolderIfNotExistSpy = jest
47
- .spyOn(globalConfig, 'createGlobalConfigAndFolderIfNotExist')
48
- .mockResolvedValueOnce(false);
49
- await (0, postinstall_1.postinstall)();
50
- expect(createGlobalConfigAndFolderIfNotExistSpy).toBeCalledTimes(1);
51
- expect(consoleSpy).toBeCalledTimes(0);
52
- });
53
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
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 os_1 = __importDefault(require("os"));
7
- const env_1 = require("../services/env");
8
- describe('env', () => {
9
- beforeEach(() => {
10
- jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
11
- });
12
- test('getGlobalConfigPath', () => {
13
- expect((0, env_1.getGlobalConfigPath)()).toBe('/myHomeDir/.backport/config.json');
14
- });
15
- test('getReposPath', () => {
16
- expect((0, env_1.getReposPath)()).toBe('/myHomeDir/.backport/repositories');
17
- });
18
- test('getRepoOwnerPath', () => {
19
- expect((0, env_1.getRepoOwnerPath)({ repoOwner: 'elastic' })).toBe('/myHomeDir/.backport/repositories/elastic');
20
- });
21
- test('getRepoPath', () => {
22
- expect((0, env_1.getRepoPath)({
23
- repoOwner: 'elastic',
24
- repoName: 'kibana',
25
- })).toBe('/myHomeDir/.backport/repositories/elastic/kibana');
26
- });
27
- });
@@ -1,6 +0,0 @@
1
- /// <reference types="node" />
2
- import fs from 'fs';
3
- export declare const writeFile: typeof fs.writeFile.__promisify__;
4
- export declare const readFile: typeof fs.readFile.__promisify__;
5
- export declare const stat: typeof fs.stat.__promisify__;
6
- export declare const chmod: typeof fs.chmod.__promisify__;