backport 5.6.4 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +166 -41
  2. package/dist/entrypoint.cli.js +3 -1
  3. package/dist/entrypoint.module.d.ts +18 -5
  4. package/dist/entrypoint.module.js +42 -12
  5. package/dist/entrypoint.module.private.test.d.ts +1 -0
  6. package/dist/entrypoint.module.private.test.js +33 -0
  7. package/dist/ink.d.ts +1 -0
  8. package/dist/ink.js +49 -0
  9. package/dist/main.d.ts +11 -6
  10. package/dist/main.js +40 -25
  11. package/dist/options/ConfigOptions.d.ts +56 -39
  12. package/dist/options/cliArgs.d.ts +38 -45
  13. package/dist/options/cliArgs.js +123 -104
  14. package/dist/options/cliArgs.test.js +106 -119
  15. package/dist/options/config/config.d.ts +56 -2
  16. package/dist/options/config/config.js +12 -6
  17. package/dist/options/config/config.test.js +11 -6
  18. package/dist/options/config/getOptionsFromGit.d.ts +4 -0
  19. package/dist/options/config/getOptionsFromGit.js +8 -0
  20. package/dist/options/config/globalConfig.d.ts +2 -1
  21. package/dist/options/config/globalConfig.js +9 -12
  22. package/dist/options/config/globalConfig.test.js +7 -5
  23. package/dist/options/config/projectConfig.d.ts +2 -1
  24. package/dist/options/config/projectConfig.js +3 -3
  25. package/dist/options/config/projectConfig.test.js +54 -17
  26. package/dist/options/config/readConfigFile.d.ts +53 -2
  27. package/dist/options/config/readConfigFile.js +31 -5
  28. package/dist/options/options.d.ts +67 -35
  29. package/dist/options/options.js +99 -16
  30. package/dist/options/options.test.js +214 -67
  31. package/dist/options/parseRequiredOptions.d.ts +71 -0
  32. package/dist/options/parseRequiredOptions.js +68 -0
  33. package/dist/options/parseRequiredOptions.test.d.ts +1 -0
  34. package/dist/options/parseRequiredOptions.test.js +122 -0
  35. package/dist/runSequentially.d.ts +20 -0
  36. package/dist/runSequentially.js +41 -0
  37. package/dist/runSequentially.test.d.ts +1 -0
  38. package/dist/runSequentially.test.js +192 -0
  39. package/dist/runWithOptions.js +7 -14
  40. package/dist/runWithOptions.test.js +142 -16
  41. package/dist/scripts/generate-gql.d.ts +1 -0
  42. package/dist/scripts/generate-gql.js +15 -0
  43. package/dist/scripts/postinstall.js +4 -4
  44. package/dist/scripts/postinstall.test.js +9 -2
  45. package/dist/scripts/runPostinstall.js +1 -1
  46. package/dist/services/HandledError.d.ts +11 -1
  47. package/dist/services/HandledError.js +2 -1
  48. package/dist/services/child-process-promisified.d.ts +1 -1
  49. package/dist/services/child-process-promisified.js +2 -2
  50. package/dist/services/env.js +5 -5
  51. package/dist/services/env.test.js +11 -4
  52. package/dist/services/fs-promisified.js +4 -4
  53. package/dist/services/getExpectedTarget.d.ts +9 -0
  54. package/dist/services/getExpectedTarget.js +77 -0
  55. package/dist/services/getExpectedTargetPullRequests.d.ts +9 -0
  56. package/dist/services/getExpectedTargetPullRequests.js +77 -0
  57. package/dist/services/git.d.ts +23 -5
  58. package/dist/services/git.integration.test.d.ts +1 -0
  59. package/dist/services/git.integration.test.js +168 -0
  60. package/dist/services/git.js +133 -60
  61. package/dist/services/git.test.js +160 -53
  62. package/dist/services/github/commitFormatters.d.ts +3 -7
  63. package/dist/services/github/commitFormatters.js +10 -19
  64. package/dist/services/github/commitFormatters.test.js +2 -24
  65. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
  66. package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -8
  67. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +6 -8
  68. package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
  69. package/dist/services/github/v3/addLabelsToPullRequest.js +2 -6
  70. package/dist/services/github/v3/addReviewersToPullRequest.d.ts +2 -0
  71. package/dist/services/github/v3/addReviewersToPullRequest.js +34 -0
  72. package/dist/services/github/v3/createPullRequest.d.ts +3 -2
  73. package/dist/services/github/v3/createPullRequest.js +32 -26
  74. package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
  75. package/dist/services/github/v3/createPullRequest.test.js +78 -0
  76. package/dist/services/github/v3/createStatusComment.d.ts +11 -0
  77. package/dist/services/github/v3/createStatusComment.js +97 -0
  78. package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
  79. package/dist/services/github/v3/createStatusComment.test.js +209 -0
  80. package/dist/services/github/v4/FetchPullRequestId.d.ts +9 -0
  81. package/dist/services/github/v4/FetchPullRequestId.js +32 -0
  82. package/dist/services/github/v4/apiRequestV4.d.ts +2 -2
  83. package/dist/services/github/v4/apiRequestV4.js +9 -11
  84. package/dist/services/github/v4/apiRequestV4.test.js +7 -7
  85. package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +9 -0
  86. package/dist/services/github/v4/disablePullRequestAutoMerge.js +28 -0
  87. package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +9 -0
  88. package/dist/services/github/v4/enablePullRequestAutoMerge.js +51 -0
  89. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
  90. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
  91. package/dist/services/github/v4/fetchAuthorId.d.ts +10 -2
  92. package/dist/services/github/v4/fetchAuthorId.js +6 -7
  93. package/dist/services/github/v4/fetchAuthorId.private.test.js +6 -9
  94. package/dist/services/github/v4/fetchCommitByPullNumber.js +11 -9
  95. package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +6 -6
  96. package/dist/services/github/v4/fetchCommitBySha.js +14 -12
  97. package/dist/services/github/v4/fetchCommitBySha.private.test.js +7 -5
  98. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +12 -0
  99. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +46 -0
  100. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
  101. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +70 -0
  102. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +12 -0
  103. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +36 -0
  104. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
  105. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +55 -0
  106. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +27 -0
  107. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +88 -0
  108. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
  109. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +128 -0
  110. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
  111. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +125 -0
  112. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +28 -0
  113. package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +52 -0
  114. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +3 -0
  115. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +55 -0
  116. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +10 -0
  117. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +49 -0
  118. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
  119. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +77 -0
  120. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +1 -0
  121. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +252 -0
  122. package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +3 -2
  123. package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
  124. package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +81 -8
  125. package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
  126. package/dist/services/github/v4/fetchDefaultBranch.d.ts +1 -1
  127. package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
  128. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +4 -0
  129. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +52 -0
  130. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +1 -0
  131. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +32 -0
  132. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +4 -0
  133. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +72 -0
  134. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +1 -0
  135. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +34 -0
  136. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +40 -0
  137. package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +72 -0
  138. package/dist/services/github/v4/fetchExistingPullRequest.js +2 -3
  139. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -5
  140. package/dist/services/github/v4/fetchMergedPullRequests.d.ts +19 -20
  141. package/dist/services/github/v4/fetchMergedPullRequests.js +22 -68
  142. package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +8 -9
  143. package/dist/services/github/v4/fetchProjectConfig.d.ts +8 -0
  144. package/dist/services/github/v4/fetchProjectConfig.js +56 -0
  145. package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +1 -0
  146. package/dist/services/github/v4/fetchProjectConfig.private.test.js +52 -0
  147. package/dist/services/github/v4/fetchProjectConfig.test.d.ts +1 -0
  148. package/dist/services/github/v4/fetchProjectConfig.test.js +37 -0
  149. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +11 -0
  150. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +35 -0
  151. package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +1 -1
  152. package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
  153. package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +8 -6
  154. package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +2 -2
  155. package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +4 -58
  156. package/dist/services/github/v4/getExistingTargetPullRequests.js +3 -58
  157. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +66 -0
  158. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +130 -0
  159. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
  160. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +130 -0
  161. package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +63 -0
  162. package/dist/services/github/v4/getOptionsFromGithub/index.js +139 -0
  163. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +1 -0
  164. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +147 -0
  165. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +37 -0
  166. package/dist/services/github/v4/getOptionsFromGithub/query.js +47 -0
  167. package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -7
  168. package/dist/services/github/v4/getTargetBranchesFromLabels.js +1 -26
  169. package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +69 -32
  170. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -2
  171. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +39 -25
  172. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +2 -2
  173. package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
  174. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +2 -2
  175. package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +4 -1
  176. package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +1 -1
  177. package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +1 -0
  178. package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +1 -1
  179. package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -15
  180. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +7 -7
  181. package/dist/services/logger.d.ts +3 -3
  182. package/dist/services/logger.js +24 -24
  183. package/dist/services/prompt.test.d.ts +1 -0
  184. package/dist/services/prompt.test.js +87 -0
  185. package/dist/services/prompts.d.ts +10 -4
  186. package/dist/services/prompts.js +85 -22
  187. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +9 -0
  188. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +92 -0
  189. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  190. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +396 -0
  191. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +21 -0
  192. package/dist/services/sourceCommit/getMockSourceCommit.js +67 -0
  193. package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +5 -0
  194. package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +20 -0
  195. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +1 -0
  196. package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +201 -0
  197. package/dist/services/sourceCommit/parseSourceCommit.d.ts +82 -0
  198. package/dist/services/sourceCommit/parseSourceCommit.js +96 -0
  199. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  200. package/dist/services/sourceCommit/parseSourceCommit.test.js +229 -0
  201. package/dist/services/sourceCommit/sourceCommit.d.ts +78 -0
  202. package/dist/services/sourceCommit/sourceCommit.js +86 -0
  203. package/dist/services/sourceCommit/sourceCommit.test.d.ts +1 -0
  204. package/dist/services/sourceCommit/sourceCommit.test.js +287 -0
  205. package/dist/services/sourceCommit.d.ts +78 -0
  206. package/dist/services/sourceCommit.js +86 -0
  207. package/dist/services/sourceCommit.test.d.ts +1 -0
  208. package/dist/services/sourceCommit.test.js +280 -0
  209. package/dist/test/inquirer.private.test.js +105 -61
  210. package/dist/test/integration/createSpies.d.ts +1 -1
  211. package/dist/test/integration/createSpies.js +21 -9
  212. package/dist/test/integration/envConstants.js +5 -6
  213. package/dist/test/integration/helpers.js +1 -1
  214. package/dist/test/integration/integration.private.test.d.ts +1 -0
  215. package/dist/test/integration/integration.private.test.js +317 -0
  216. package/dist/test/integration/integration.test.js +30 -31
  217. package/dist/test/mockConfigFiles.d.ts +5 -0
  218. package/dist/test/mockConfigFiles.js +37 -0
  219. package/dist/test/nockHelpers.d.ts +3 -3
  220. package/dist/test/nockHelpers.js +7 -11
  221. package/dist/test/private/getDevAccessToken.js +1 -1
  222. package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
  223. package/dist/test/setupFiles/automatic-mocks.js +1 -51
  224. package/dist/types/Commit.d.ts +85 -0
  225. package/dist/types/Commit.js +139 -0
  226. package/dist/types/commitNode.d.ts +89 -0
  227. package/dist/types/commitNode.js +139 -0
  228. package/dist/types/commitNode.test.d.ts +1 -0
  229. package/dist/types/commitNode.test.js +255 -0
  230. package/dist/types/commitWithAssociatedPullRequests.d.ts +86 -0
  231. package/dist/types/commitWithAssociatedPullRequests.js +145 -0
  232. package/dist/ui/cherrypickAndCreatePullRequest.test.js +333 -76
  233. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +11 -1
  234. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +138 -67
  235. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
  236. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +468 -0
  237. package/dist/ui/getCommits.d.ts +1 -1
  238. package/dist/ui/getCommits.js +55 -25
  239. package/dist/ui/getTargetBranches.d.ts +3 -2
  240. package/dist/ui/getTargetBranches.js +33 -18
  241. package/dist/ui/getTargetBranches.test.js +75 -99
  242. package/dist/ui/getTargetBranchesFromLabels.d.ts +6 -0
  243. package/dist/ui/getTargetBranchesFromLabels.js +40 -0
  244. package/dist/ui/getTargetBranchesFromLabels.test.d.ts +1 -0
  245. package/dist/ui/getTargetBranchesFromLabels.test.js +288 -0
  246. package/dist/ui/maybeSetupRepo.js +11 -10
  247. package/dist/ui/maybeSetupRepo.test.js +54 -4
  248. package/dist/utils/excludeUndefined.d.ts +6 -0
  249. package/dist/utils/excludeUndefined.js +7 -0
  250. package/dist/utils/excludeUndefined.test.d.ts +1 -0
  251. package/dist/utils/excludeUndefined.test.js +24 -0
  252. package/package.json +37 -51
  253. package/yarn.lock +2416 -2987
@@ -2,171 +2,158 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const cliArgs_1 = require("./cliArgs");
4
4
  describe('getOptionsFromCliArgs', () => {
5
- it('should merge config and cli options', () => {
6
- const configOptions = {
7
- accessToken: 'myAccessToken',
8
- all: false,
9
- fork: true,
10
- gitHostname: 'github.com',
11
- githubApiBaseUrlV3: 'https://api.github.com',
12
- githubApiBaseUrlV4: 'https://api.github.com/graphql',
13
- maxNumber: 10,
14
- multipleBranches: true,
15
- multipleCommits: false,
16
- noVerify: true,
17
- prTitle: 'myPrTitle',
18
- sourcePRLabels: [],
19
- targetBranchChoices: [],
20
- targetPRLabels: [],
21
- upstream: 'elastic/kibana',
22
- username: 'sqren',
23
- };
24
- const argv = [
25
- '--branch',
26
- '6.0',
27
- '--branch',
28
- '6.1',
29
- '--upstream',
30
- 'backport-org/backport-demo',
31
- '--all',
32
- '--username',
33
- 'sqren',
34
- ];
35
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
36
- expect(res).toEqual({
37
- accessToken: 'myAccessToken',
38
- all: true,
39
- assignees: [],
40
- ci: false,
41
- dryRun: false,
42
- fork: true,
43
- gitHostname: 'github.com',
44
- githubApiBaseUrlV3: 'https://api.github.com',
45
- githubApiBaseUrlV4: 'https://api.github.com/graphql',
46
- maxNumber: 10,
47
- multipleBranches: true,
48
- multipleCommits: false,
49
- noVerify: true,
50
- prTitle: 'myPrTitle',
51
- resetAuthor: false,
52
- sha: undefined,
53
- sourcePRLabels: [],
54
- targetBranchChoices: [],
55
- targetBranches: ['6.0', '6.1'],
56
- targetPRLabels: [],
57
- upstream: 'backport-org/backport-demo',
58
- username: 'sqren',
59
- verbose: false,
5
+ describe('yargs settings', () => {
6
+ it('should accept both camel-case and dashed-case and convert them to camel cased', () => {
7
+ const argv = [
8
+ '--access-token',
9
+ 'my access token',
10
+ '--githubApiBaseUrlV3',
11
+ 'my api hostname',
12
+ ];
13
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
14
+ expect(res.accessToken).toEqual('my access token');
15
+ expect('access-token' in res).toEqual(false);
16
+ expect(res.githubApiBaseUrlV3).toEqual('my api hostname');
17
+ expect('api-hostname' in res).toEqual(false);
60
18
  });
19
+ it('strips undefined values from the object', () => {
20
+ const argv = [
21
+ '--access-token',
22
+ 'my access token',
23
+ '--author',
24
+ 'sqren',
25
+ '--repo-owner',
26
+ 'elastic',
27
+ '--repo-name',
28
+ 'kibana',
29
+ ];
30
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
31
+ expect(res).toEqual({
32
+ accessToken: 'my access token',
33
+ repoOwner: 'elastic',
34
+ repoName: 'kibana',
35
+ author: 'sqren',
36
+ mainline: 1,
37
+ reviewers: [],
38
+ assignees: [],
39
+ commitPaths: [],
40
+ });
41
+ });
42
+ });
43
+ // blocked by: https://github.com/yargs/yargs/issues/1853
44
+ describe('help', () => {
45
+ // eslint-disable-next-line jest/no-commented-out-tests
46
+ // it('should output help', () => {
47
+ // const argv = ['--help'];
48
+ // expect(() =>
49
+ // getOptionsFromCliArgs(argv, { exitOnError: false, returnHelp: true })
50
+ // ).toThrow('asa');
51
+ // });
61
52
  });
62
- it('should accept both camel-case and dashed-case and convert them to camel cased', () => {
63
- const configOptions = {};
64
- const argv = [
65
- '--access-token',
66
- 'my access token',
67
- '--githubApiBaseUrlV3',
68
- 'my api hostname',
69
- ];
70
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
71
- expect(res.accessToken).toEqual('my access token');
72
- expect('access-token' in res).toEqual(false);
73
- expect(res.githubApiBaseUrlV3).toEqual('my api hostname');
74
- expect('api-hostname' in res).toEqual(false);
53
+ describe('sourcePRLabels', () => {
54
+ it('should handle all variations', () => {
55
+ const argv = [
56
+ '--sourcePRLabel',
57
+ 'label a',
58
+ '--sourcePrLabel',
59
+ 'label b',
60
+ '--source-pr-label',
61
+ 'label c',
62
+ ];
63
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
64
+ expect(res.sourcePRLabels).toEqual(['label a', 'label b', 'label c']);
65
+ });
75
66
  });
76
67
  describe('pullNumber', () => {
77
68
  it('should accept `--pr` alias but only return the full representation (`pullNumber`)', () => {
78
- const configOptions = {};
79
69
  const argv = ['--pr', '1337'];
80
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
70
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
81
71
  expect(res.pullNumber).toEqual(1337);
82
72
  //@ts-expect-error
83
73
  expect(res.pr).toBe(undefined);
84
74
  });
85
75
  });
86
- describe('autoAssign', () => {
87
- it('should set assignees to current user if `autoAssign` is true', () => {
88
- const configOptions = { username: 'sqren' };
89
- const argv = ['--auto-assign'];
90
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
91
- expect(res.assignees).toEqual(['sqren']);
92
- });
93
- });
94
76
  describe('assignees', () => {
95
- it('should set assignees', () => {
96
- const configOptions = { username: 'sqren' };
97
- const argv = ['--assignees', 'john'];
98
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
77
+ it('--assignee', () => {
78
+ const argv = ['--assignee', 'john'];
79
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
80
+ expect(res.assignees).toEqual(['john']);
81
+ });
82
+ it('--assign', () => {
83
+ const argv = ['--assign', 'john'];
84
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
99
85
  expect(res.assignees).toEqual(['john']);
100
86
  });
101
87
  });
102
88
  describe('multipleBranches', () => {
103
- it('should be settable', () => {
104
- const configOptions = { multipleBranches: false };
89
+ it('should be undefined by default', () => {
105
90
  const argv = [];
106
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
91
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
92
+ expect(res.multipleBranches).toBe(undefined);
93
+ });
94
+ it('should set to true', () => {
95
+ const argv = ['--multiple-branches', 'true'];
96
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
97
+ expect(res.multipleBranches).toBe(true);
98
+ });
99
+ it('should set to false', () => {
100
+ const argv = ['--multiple-branches', 'false'];
101
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
107
102
  expect(res.multipleBranches).toBe(false);
108
103
  });
109
104
  it('should respect `multiple` option', () => {
110
- const configOptions = { multipleBranches: false };
111
105
  const argv = ['--multiple'];
112
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
106
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
113
107
  expect(res.multipleBranches).toBe(true);
114
108
  });
109
+ it('should conflict when using both', () => {
110
+ const argv = ['--multiple', '--multiple-branches', 'false'];
111
+ expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv, { exitOnError: false })).toThrow('Arguments multiple and multipleBranches are mutually exclusive');
112
+ });
115
113
  });
116
114
  describe('noVerify', () => {
117
- it('should be settable', () => {
118
- const configOptions = { noVerify: false };
115
+ it('should be undefined by default', () => {
119
116
  const argv = [];
120
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
117
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
118
+ expect(res.noVerify).toBe(undefined);
119
+ });
120
+ it('should set to false', () => {
121
+ const argv = ['--no-verify', 'false'];
122
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
121
123
  expect(res.noVerify).toBe(false);
122
124
  });
123
- it('should be flipped by `verify`', () => {
124
- const configOptions = { noVerify: false };
125
+ it('should set to true', () => {
126
+ const argv = ['--no-verify', 'true'];
127
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
128
+ expect(res.noVerify).toBe(true);
129
+ });
130
+ it('should be enabled by `verify`', () => {
125
131
  const argv = ['--verify'];
126
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
132
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
127
133
  expect(res.noVerify).toBe(true);
128
134
  });
129
135
  });
130
136
  describe('mainline', () => {
131
137
  it('should default to 1', () => {
132
- const configOptions = {};
133
138
  const argv = ['--mainline'];
134
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
139
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
135
140
  expect(res.mainline).toEqual(1);
136
141
  });
137
142
  it('should accept numbers', () => {
138
- const configOptions = {};
139
143
  const argv = ['--mainline', '2'];
140
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
144
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
141
145
  expect(res.mainline).toEqual(2);
142
146
  });
147
+ it('should throw on invalid values', () => {
148
+ const argv = ['--mainline', 'foo'];
149
+ expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv, { exitOnError: false })).toThrowError('--mainline must be an integer. Received: NaN');
150
+ });
143
151
  });
144
152
  describe('targetBranches', () => {
145
153
  it('should not coerce 6.0 to 6', () => {
146
- const configOptions = {};
147
154
  const argv = ['-b', '6.0'];
148
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
155
+ const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
149
156
  expect(res.targetBranches).toEqual(['6.0']);
150
157
  });
151
158
  });
152
- describe('targetBranchChoices', () => {
153
- it('should support objects', () => {
154
- const configOptions = {
155
- targetBranchChoices: [{ name: '7.x', checked: false }],
156
- };
157
- const argv = [];
158
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
159
- expect(res.targetBranchChoices).toEqual([
160
- { name: '7.x', checked: false },
161
- ]);
162
- });
163
- it('should convert primitive values to objects', () => {
164
- const configOptions = {};
165
- const argv = ['--target-branch-choices', '8.x'];
166
- const res = cliArgs_1.getOptionsFromCliArgs(configOptions, argv);
167
- expect(res.targetBranchChoices).toEqual([
168
- { name: '8.x', checked: false },
169
- ]);
170
- });
171
- });
172
159
  });
@@ -1,2 +1,56 @@
1
- import { ConfigOptions } from '../ConfigOptions';
2
- export declare function getOptionsFromConfigFiles(ci?: boolean): Promise<ConfigOptions>;
1
+ import { ConfigFileOptions } from '../ConfigOptions';
2
+ export declare type OptionsFromConfigFiles = Awaited<ReturnType<typeof getOptionsFromConfigFiles>>;
3
+ export declare function getOptionsFromConfigFiles(optionsFromModule?: ConfigFileOptions): Promise<{
4
+ accessToken?: string | undefined;
5
+ assignees?: string[] | undefined;
6
+ author?: string | null | undefined;
7
+ autoAssign?: boolean | undefined;
8
+ autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
9
+ files: string[];
10
+ directory: string;
11
+ logger: {
12
+ error: (message: string, meta?: unknown) => void;
13
+ warn: (message: string, meta?: unknown) => void;
14
+ info: (message: string, meta?: unknown) => void;
15
+ verbose: (message: string, meta?: unknown) => void;
16
+ debug: (message: string, meta?: unknown) => void;
17
+ };
18
+ targetBranch: string;
19
+ }) => boolean | Promise<boolean>) | undefined;
20
+ autoMerge?: boolean | undefined;
21
+ autoMergeMethod?: string | undefined;
22
+ cherrypickRef?: boolean | undefined;
23
+ ci?: boolean | undefined;
24
+ commitPaths?: string[] | undefined;
25
+ details?: boolean | undefined;
26
+ editor?: string | undefined;
27
+ fork?: boolean | undefined;
28
+ gitHostname?: string | undefined;
29
+ githubApiBaseUrlV3?: string | undefined;
30
+ githubApiBaseUrlV4?: string | undefined;
31
+ maxNumber?: number | undefined;
32
+ multiple?: boolean | undefined;
33
+ multipleBranches?: boolean | undefined;
34
+ multipleCommits?: boolean | undefined;
35
+ noVerify?: boolean | undefined;
36
+ prDescription?: string | undefined;
37
+ prFilter?: string | undefined;
38
+ prTitle?: string | undefined;
39
+ pullNumber?: number | undefined;
40
+ repoName?: string | undefined;
41
+ repoOwner?: string | undefined;
42
+ resetAuthor?: boolean | undefined;
43
+ reviewers?: string[] | undefined;
44
+ sha?: string | undefined;
45
+ skipRemoteConfig?: boolean | undefined;
46
+ sourceBranch?: string | undefined;
47
+ sourcePRLabels?: string[] | undefined;
48
+ targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
49
+ targetBranches?: string[] | undefined;
50
+ targetPRLabels?: string[] | undefined;
51
+ verbose?: boolean | undefined;
52
+ branchLabelMapping?: Record<string, string> | undefined;
53
+ upstream?: string | undefined;
54
+ branches?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
55
+ labels?: string[] | undefined;
56
+ }>;
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOptionsFromConfigFiles = void 0;
4
+ const getOptionsFromGit_1 = require("./getOptionsFromGit");
4
5
  const globalConfig_1 = require("./globalConfig");
5
6
  const projectConfig_1 = require("./projectConfig");
6
- async function getOptionsFromConfigFiles(ci) {
7
- const [projectConfig, globalConfig] = await Promise.all([
8
- projectConfig_1.getProjectConfig(),
9
- globalConfig_1.getGlobalConfig(ci),
7
+ async function getOptionsFromConfigFiles(optionsFromModule) {
8
+ const [gitConfig, projectConfig, globalConfig] = await Promise.all([
9
+ (0, getOptionsFromGit_1.getOptionsFromGit)(),
10
+ (0, projectConfig_1.getProjectConfig)(),
11
+ (0, globalConfig_1.getGlobalConfig)(optionsFromModule?.ci),
10
12
  ]);
11
- // global and project config combined
12
- return { ...globalConfig, ...projectConfig };
13
+ return {
14
+ ...gitConfig,
15
+ ...globalConfig,
16
+ ...projectConfig,
17
+ ...optionsFromModule,
18
+ };
13
19
  }
14
20
  exports.getOptionsFromConfigFiles = getOptionsFromConfigFiles;
@@ -1,17 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mockConfigFiles_1 = require("../../test/mockConfigFiles");
3
4
  const config_1 = require("./config");
4
5
  describe('getOptionsFromConfigFiles', () => {
5
6
  let res;
6
7
  beforeEach(async () => {
7
- res = await config_1.getOptionsFromConfigFiles();
8
+ (0, mockConfigFiles_1.mockConfigFiles)({
9
+ globalConfig: { accessToken: 'abc', editor: 'vim' },
10
+ projectConfig: { repoName: 'kibana', repoOwner: 'elastic' },
11
+ });
12
+ res = await (0, config_1.getOptionsFromConfigFiles)();
8
13
  });
9
- it('should return default config values', () => {
14
+ it('should return values from config files', () => {
10
15
  expect(res).toEqual({
11
- accessToken: 'myAccessToken',
12
- targetBranchChoices: ['6.0', '5.9'],
13
- upstream: 'backport-org/backport-demo',
14
- username: 'sqren',
16
+ accessToken: 'abc',
17
+ editor: 'vim',
18
+ repoName: 'kibana',
19
+ repoOwner: 'elastic',
15
20
  });
16
21
  });
17
22
  });
@@ -0,0 +1,4 @@
1
+ export declare function getOptionsFromGit(): Promise<{
2
+ repoOwner: string;
3
+ repoName: string;
4
+ } | undefined>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOptionsFromGit = void 0;
4
+ const git_1 = require("../../services/git");
5
+ async function getOptionsFromGit() {
6
+ return (0, git_1.getRepoOwnerAndNameFromGitRemote)();
7
+ }
8
+ exports.getOptionsFromGit = getOptionsFromGit;
@@ -1,3 +1,4 @@
1
- export declare function getGlobalConfig(ci?: boolean): Promise<import("../ConfigOptions").ConfigOptions | undefined>;
1
+ import { ConfigFileOptions } from '../ConfigOptions';
2
+ export declare function getGlobalConfig(ci?: boolean): Promise<ConfigFileOptions | undefined>;
2
3
  export declare function createGlobalConfigAndFolderIfNotExist(): Promise<boolean>;
3
4
  export declare function createGlobalConfigIfNotExist(globalConfigPath: string, configTemplate: string): Promise<boolean>;
@@ -14,28 +14,28 @@ async function getGlobalConfig(ci) {
14
14
  return;
15
15
  }
16
16
  await createGlobalConfigAndFolderIfNotExist();
17
- const globalConfigPath = env_1.getGlobalConfigPath();
18
- return readConfigFile_1.readConfigFile(globalConfigPath);
17
+ const globalConfigPath = (0, env_1.getGlobalConfigPath)();
18
+ return (0, readConfigFile_1.readConfigFile)(globalConfigPath);
19
19
  }
20
20
  exports.getGlobalConfig = getGlobalConfig;
21
21
  async function createGlobalConfigAndFolderIfNotExist() {
22
- const reposPath = env_1.getReposPath();
23
- const globalConfigPath = env_1.getGlobalConfigPath();
22
+ const reposPath = (0, env_1.getReposPath)();
23
+ const globalConfigPath = (0, env_1.getGlobalConfigPath)();
24
24
  const configTemplate = getConfigTemplate();
25
- await make_dir_1.default(reposPath);
25
+ await (0, make_dir_1.default)(reposPath);
26
26
  const didCreate = await createGlobalConfigIfNotExist(globalConfigPath, configTemplate);
27
27
  await ensureCorrectPermissions(globalConfigPath);
28
28
  return didCreate;
29
29
  }
30
30
  exports.createGlobalConfigAndFolderIfNotExist = createGlobalConfigAndFolderIfNotExist;
31
31
  function ensureCorrectPermissions(globalConfigPath) {
32
- return fs_promisified_1.chmod(globalConfigPath, '600');
32
+ return (0, fs_promisified_1.chmod)(globalConfigPath, '600');
33
33
  }
34
34
  async function createGlobalConfigIfNotExist(globalConfigPath, configTemplate) {
35
35
  try {
36
- await fs_promisified_1.writeFile(globalConfigPath, configTemplate, {
36
+ await (0, fs_promisified_1.writeFile)(globalConfigPath, configTemplate, {
37
37
  flag: 'wx',
38
- mode: 0o600,
38
+ mode: 0o600, // give the owner read-write privleges, no access for others
39
39
  });
40
40
  return true;
41
41
  }
@@ -52,9 +52,6 @@ function getConfigTemplate() {
52
52
  return `{
53
53
  // Github personal access token. Must be created here: https://github.com/settings/tokens/new
54
54
  // Must have "Repo: Full control of private repositories"
55
- "accessToken": "",
56
-
57
- // Github username, eg. kimchy
58
- "username": ""
55
+ "accessToken": ""
59
56
  }`;
60
57
  }
@@ -22,11 +22,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
+ const os_1 = __importDefault(require("os"));
25
26
  const make_dir_1 = __importDefault(require("make-dir"));
26
27
  const fs = __importStar(require("../../services/fs-promisified"));
27
28
  const globalConfig_1 = require("./globalConfig");
28
29
  describe('config', () => {
29
30
  afterEach(() => jest.clearAllMocks());
31
+ beforeEach(() => {
32
+ jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
33
+ });
30
34
  describe('getGlobalConfig', () => {
31
35
  let res;
32
36
  beforeEach(async () => {
@@ -34,9 +38,8 @@ describe('config', () => {
34
38
  jest.spyOn(fs, 'writeFile').mockResolvedValueOnce();
35
39
  jest.spyOn(fs, 'readFile').mockResolvedValueOnce(JSON.stringify({
36
40
  accessToken: 'myAccessToken',
37
- username: 'sqren',
38
41
  }));
39
- res = await globalConfig_1.getGlobalConfig();
42
+ res = await (0, globalConfig_1.getGlobalConfig)();
40
43
  });
41
44
  it("should create config if it doesn't exist", () => {
42
45
  expect(fs.writeFile).toHaveBeenCalledWith('/myHomeDir/.backport/config.json', expect.any(String), { flag: 'wx', mode: 384 });
@@ -50,14 +53,13 @@ describe('config', () => {
50
53
  it('should return config', () => {
51
54
  expect(res).toEqual({
52
55
  accessToken: 'myAccessToken',
53
- username: 'sqren',
54
56
  });
55
57
  });
56
58
  });
57
59
  describe('createGlobalConfigIfNotExist', () => {
58
60
  it('should create config and succeed', async () => {
59
61
  jest.spyOn(fs, 'writeFile').mockResolvedValueOnce(undefined);
60
- const didCreate = await globalConfig_1.createGlobalConfigIfNotExist('/path/to/globalConfig', 'myConfigTemplate');
62
+ const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/globalConfig', 'myConfigTemplate');
61
63
  expect(didCreate).toEqual(true);
62
64
  expect(fs.writeFile).toHaveBeenCalledWith('/path/to/globalConfig', expect.stringContaining('myConfigTemplate'), { flag: 'wx', mode: 384 });
63
65
  });
@@ -65,7 +67,7 @@ describe('config', () => {
65
67
  const err = new Error();
66
68
  err.code = 'EEXIST';
67
69
  jest.spyOn(fs, 'writeFile').mockRejectedValueOnce(err);
68
- const didCreate = await globalConfig_1.createGlobalConfigIfNotExist('myPath', 'myConfigTemplate');
70
+ const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('myPath', 'myConfigTemplate');
69
71
  expect(didCreate).toEqual(false);
70
72
  });
71
73
  });
@@ -1 +1,2 @@
1
- export declare function getProjectConfig(): Promise<import("../ConfigOptions").ConfigOptions>;
1
+ import { ConfigFileOptions } from '../ConfigOptions';
2
+ export declare function getProjectConfig(): Promise<ConfigFileOptions | undefined>;
@@ -7,10 +7,10 @@ exports.getProjectConfig = void 0;
7
7
  const find_up_1 = __importDefault(require("find-up"));
8
8
  const readConfigFile_1 = require("../config/readConfigFile");
9
9
  async function getProjectConfig() {
10
- const filepath = await find_up_1.default('.backportrc.json');
10
+ const filepath = await (0, find_up_1.default)('.backportrc.json');
11
11
  if (!filepath) {
12
- return {};
12
+ return;
13
13
  }
14
- return readConfigFile_1.readConfigFile(filepath);
14
+ return (0, readConfigFile_1.readConfigFile)(filepath);
15
15
  }
16
16
  exports.getProjectConfig = getProjectConfig;
@@ -27,36 +27,73 @@ const fs = __importStar(require("../../services/fs-promisified"));
27
27
  const projectConfig_1 = require("./projectConfig");
28
28
  describe('getProjectConfig', () => {
29
29
  afterEach(() => jest.clearAllMocks());
30
- describe('when projectConfig is valid', () => {
31
- let projectConfig;
32
- beforeEach(async () => {
33
- jest
34
- .spyOn(fs, 'readFile')
35
- .mockResolvedValueOnce(JSON.stringify({ upstream: 'elastic/kibana', branches: ['6.x'] }));
36
- projectConfig = await projectConfig_1.getProjectConfig();
30
+ describe('deprecations', () => {
31
+ describe('when specifying deprecated `branches`', () => {
32
+ it('is returned as `targetBranchChoices`', async () => {
33
+ jest.spyOn(fs, 'readFile').mockResolvedValueOnce(JSON.stringify({
34
+ repoName: 'kibana',
35
+ repoOwner: 'elastic',
36
+ branches: ['6.x'],
37
+ }));
38
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)();
39
+ expect(projectConfig?.targetBranchChoices).toEqual(['6.x']);
40
+ });
41
+ });
42
+ describe('when specifying deprecated `labels`', () => {
43
+ it('is returned as `targetPRLabels`', async () => {
44
+ jest.spyOn(fs, 'readFile').mockResolvedValueOnce(JSON.stringify({
45
+ labels: ['backport'],
46
+ }));
47
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)();
48
+ expect(projectConfig?.targetPRLabels).toEqual(['backport']);
49
+ });
37
50
  });
38
- it('should call findUp', () => {
39
- expect(find_up_1.default).toHaveBeenCalledWith('.backportrc.json');
51
+ describe('when specifying deprecated `upstream`', () => {
52
+ it('is split into `repoOwner` and `repoName`', async () => {
53
+ jest.spyOn(fs, 'readFile').mockResolvedValueOnce(JSON.stringify({
54
+ upstream: 'elastic/kibana',
55
+ }));
56
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)();
57
+ expect(projectConfig?.repoOwner).toEqual('elastic');
58
+ expect(projectConfig?.repoName).toEqual('kibana');
59
+ });
40
60
  });
41
- it('should return config with branches', () => {
42
- expect(projectConfig).toEqual({
43
- branches: ['6.x'],
44
- upstream: 'elastic/kibana',
61
+ describe('when projectConfig is valid', () => {
62
+ let projectConfig;
63
+ beforeEach(async () => {
64
+ jest.spyOn(fs, 'readFile').mockResolvedValueOnce(JSON.stringify({
65
+ repoName: 'kibana',
66
+ repoOwner: 'elastic',
67
+ targetBranchChoices: ['6.x'],
68
+ targetPRLabels: ['backport'],
69
+ }));
70
+ projectConfig = await (0, projectConfig_1.getProjectConfig)();
71
+ });
72
+ it('should call findUp', () => {
73
+ expect(find_up_1.default).toHaveBeenCalledWith('.backportrc.json');
74
+ });
75
+ it('should return config', () => {
76
+ expect(projectConfig).toEqual({
77
+ repoName: 'kibana',
78
+ repoOwner: 'elastic',
79
+ targetBranchChoices: ['6.x'],
80
+ targetPRLabels: ['backport'],
81
+ });
45
82
  });
46
83
  });
47
84
  });
48
85
  describe('when projectConfig is empty', () => {
49
86
  it('should return empty config', async () => {
50
87
  jest.spyOn(fs, 'readFile').mockResolvedValueOnce('{}');
51
- const projectConfig = await projectConfig_1.getProjectConfig();
52
- expect(projectConfig).toEqual({ targetBranchChoices: undefined });
88
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)();
89
+ expect(projectConfig).toEqual({});
53
90
  });
54
91
  });
55
92
  describe('when projectConfig is missing', () => {
56
93
  it('should return empty config', async () => {
57
94
  find_up_1.default.mockReturnValueOnce(undefined);
58
- const projectConfig = await projectConfig_1.getProjectConfig();
59
- expect(projectConfig).toEqual({});
95
+ const projectConfig = await (0, projectConfig_1.getProjectConfig)();
96
+ expect(projectConfig).toEqual(undefined);
60
97
  });
61
98
  });
62
99
  });