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.
- package/README.md +13 -5
- package/dist/backportRun.d.ts +2 -2
- package/dist/backportRun.js +13 -8
- package/dist/{entrypoint.api.private.test.d.ts → entrypoint.cli.e2e.private.test.d.ts} +0 -0
- package/dist/entrypoint.cli.e2e.private.test.js +278 -0
- package/dist/{entrypoint.module.private.test.d.ts → entrypoint.cli.private.test.d.ts} +0 -0
- package/dist/{entrypoint.module.private.test.js → entrypoint.cli.private.test.js} +17 -8
- package/dist/entrypoint.module.js +1 -1
- package/dist/options/ConfigOptions.d.ts +5 -2
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +27 -6
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +4 -7
- package/dist/options/config/config.js +2 -7
- package/dist/options/config/config.test.js +5 -21
- package/dist/options/config/globalConfig.js +3 -3
- package/dist/options/config/globalConfig.test.js +10 -29
- package/dist/options/config/projectConfig.test.js +7 -26
- package/dist/options/config/readConfigFile.d.ts +4 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +6 -34
- package/dist/options/options.js +37 -29
- package/dist/options/options.test.js +53 -22
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +1 -1
- package/dist/runSequentially.test.js +35 -12
- package/dist/services/HandledError.d.ts +6 -4
- package/dist/services/HandledError.js +18 -3
- package/dist/services/child-process-promisified.d.ts +3 -1
- package/dist/services/env.test.js +2 -2
- package/dist/services/git.d.ts +22 -9
- package/dist/services/git.integration.test.js +123 -24
- package/dist/services/git.js +66 -54
- package/dist/services/git.test.js +35 -20
- package/dist/services/github/commitFormatters.d.ts +0 -1
- package/dist/services/github/commitFormatters.js +1 -8
- package/dist/services/github/v3/createPullRequest.js +8 -5
- package/dist/services/github/v3/createPullRequest.test.js +204 -39
- package/dist/services/github/v3/createStatusComment.js +26 -15
- package/dist/services/github/v3/createStatusComment.test.js +132 -72
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
- package/dist/{options/getValidatedOptions.test.d.ts → services/github/v3/index.d.ts} +0 -0
- package/dist/services/github/v3/index.js +61 -0
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -7
- package/dist/services/github/v4/apiRequestV4.d.ts +21 -17
- package/dist/services/github/v4/apiRequestV4.js +46 -28
- package/dist/services/github/v4/apiRequestV4.test.js +4 -4
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/fetchAuthorId.private.test.js +2 -2
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +38 -20
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +19 -10
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +25 -16
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +6 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +41 -19
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +33 -16
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
- package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +2 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +6 -8
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +49 -41
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +7 -1
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +15 -23
- package/dist/services/github/v4/getOptionsFromGithub/query.js +17 -25
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
- package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +9 -18
- package/dist/services/logger.js +20 -56
- package/dist/services/prompt.test.js +66 -19
- package/dist/services/prompts.js +12 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
- package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
- package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
- package/dist/services/sourceCommit/parseSourceCommit.test.js +18 -20
- package/dist/{runWithOptions.test.d.ts → test/backport-e2e.mutation.test.d.ts} +0 -0
- package/dist/test/{backport-e2e.private.test.js → backport-e2e.mutation.test.js} +134 -112
- package/dist/test/handleUnbackportedPullRequests.private.test.js +26 -12
- package/dist/test/mockConfigFiles.js +4 -20
- package/dist/test/mocks.d.ts +10 -0
- package/dist/test/mocks.js +23 -0
- package/dist/test/private/getDevAccessToken.d.ts +2 -1
- package/dist/test/private/getDevAccessToken.js +6 -18
- package/dist/test/sandbox.d.ts +5 -0
- package/dist/{react-components/0-loadOptions.js → test/sandbox.js} +18 -20
- package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
- package/dist/test/setupFiles/automatic-mocks.js +27 -11
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +47 -19
- package/dist/ui/getCommits.js +8 -14
- package/dist/ui/getCommitsWithoutBackports.js +6 -6
- package/dist/ui/getCommitsWithoutBackports.test.js +91 -39
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/getTargetBranches.test.js +26 -8
- package/dist/ui/maybeSetupRepo.js +25 -5
- package/dist/ui/maybeSetupRepo.test.js +144 -18
- package/dist/utils/maybe.d.ts +1 -0
- package/dist/utils/maybe.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -0
- package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
- package/package.json +24 -19
- package/yarn.lock +119 -147
- package/dist/entrypoint.api.d.ts +0 -22
- package/dist/entrypoint.api.js +0 -57
- package/dist/entrypoint.api.private.test.js +0 -37
- package/dist/index.d.ts +0 -783
- package/dist/index.js +0 -8001
- package/dist/ink.d.ts +0 -1
- package/dist/ink.js +0 -49
- package/dist/main.d.ts +0 -14
- package/dist/main.js +0 -68
- package/dist/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- package/dist/options/config/getProjectConfig.d.ts +0 -0
- package/dist/options/config/getProjectConfig.js +0 -1
- package/dist/options/getValidatedOptions.d.ts +0 -49
- package/dist/options/getValidatedOptions.js +0 -45
- package/dist/options/getValidatedOptions.test.js +0 -97
- package/dist/options/parseRequiredOptions.d.ts +0 -71
- package/dist/options/parseRequiredOptions.js +0 -68
- package/dist/options/parseRequiredOptions.test.js +0 -122
- package/dist/react-components/0-loadOptions.d.ts +0 -6
- package/dist/react-components/1-loadCommit.d.ts +0 -8
- package/dist/react-components/1-loadCommit.js +0 -88
- package/dist/react-components/1a-loadCommit.d.ts +0 -5
- package/dist/react-components/1a-loadCommit.js +0 -76
- package/dist/react-components/1b-commitChoices.d.ts +0 -5
- package/dist/react-components/1b-commitChoices.js +0 -98
- package/dist/react-components/2-commitChoices.d.ts +0 -8
- package/dist/react-components/2-commitChoices.js +0 -96
- package/dist/react-components/2-commitsPrompt.d.ts +0 -8
- package/dist/react-components/2-commitsPrompt.js +0 -96
- package/dist/react-components/2-targetBranchChoices.d.ts +0 -9
- package/dist/react-components/2-targetBranchChoices.js +0 -109
- package/dist/react-components/3-cherrypick.d.ts +0 -1
- package/dist/react-components/3-cherrypick.js +0 -2
- package/dist/react-components/App.d.ts +0 -2
- package/dist/react-components/App.js +0 -35
- package/dist/react-components/BackportStateContext.d.ts +0 -33
- package/dist/react-components/BackportStateContext.js +0 -42
- package/dist/react-components/CommitPrompt/2-commitsPrompt.d.ts +0 -8
- package/dist/react-components/CommitPrompt/2-commitsPrompt.js +0 -96
- package/dist/react-components/CommitPrompt/CommitPrompt.d.ts +0 -8
- package/dist/react-components/CommitPrompt/CommitPrompt.js +0 -96
- package/dist/react-components/CommitPrompt/getCommits.d.ts +0 -2
- package/dist/react-components/CommitPrompt/getCommits.js +0 -27
- package/dist/react-components/CommitPrompt.d.ts +0 -8
- package/dist/react-components/CommitPrompt.js +0 -96
- package/dist/react-components/CustomMultiSelect.d.ts +0 -13
- package/dist/react-components/CustomMultiSelect.js +0 -21
- package/dist/react-components/CustomMultiSelectItem.d.ts +0 -5
- package/dist/react-components/CustomMultiSelectItem.js +0 -12
- package/dist/react-components/CustomSelect.d.ts +0 -14
- package/dist/react-components/CustomSelect.js +0 -34
- package/dist/react-components/ErrorBoundary.d.ts +0 -15
- package/dist/react-components/ErrorBoundary.js +0 -53
- package/dist/react-components/MultiSelect.d.ts +0 -7
- package/dist/react-components/MultiSelect.js +0 -16
- package/dist/react-components/hooks/useAsync.d.ts +0 -12
- package/dist/react-components/hooks/useAsync.js +0 -73
- package/dist/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.d.ts +0 -1
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/services/backportRun/backportRun.ci.d.ts +0 -6
- package/dist/services/backportRun/backportRun.ci.js +0 -81
- package/dist/services/backportRun/backportRun.d.ts +0 -14
- package/dist/services/backportRun/backportRun.interactive.d.ts +0 -1
- package/dist/services/backportRun/backportRun.interactive.js +0 -4
- package/dist/services/backportRun/backportRun.js +0 -14
- package/dist/services/backportRun/backportState.d.ts +0 -4
- package/dist/services/backportRun/backportState.js +0 -28
- package/dist/services/backportRun/getCommits.d.ts +0 -2
- package/dist/services/backportRun/getCommits.js +0 -20
- package/dist/services/backportRun/runSequentially.d.ts +0 -20
- package/dist/services/backportRun/runSequentially.js +0 -41
- package/dist/services/backportRun/runSequentially.test.d.ts +0 -1
- package/dist/services/backportRun/runSequentially.test.js +0 -199
- package/dist/services/cherrypickAndCreateTargetPullRequest.d.ts +0 -12
- package/dist/services/cherrypickAndCreateTargetPullRequest.js +0 -206
- package/dist/services/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/services/cherrypickAndCreateTargetPullRequest.test.js +0 -403
- package/dist/services/fs-promisified.d.ts +0 -6
- package/dist/services/fs-promisified.js +0 -12
- package/dist/services/getCommits.d.ts +0 -2
- package/dist/services/getCommits.js +0 -38
- package/dist/services/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/services/getCommitsWithoutBackports.js +0 -68
- package/dist/services/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/services/getCommitsWithoutBackports.test.js +0 -259
- package/dist/services/getExpectedTarget.d.ts +0 -9
- package/dist/services/getExpectedTarget.js +0 -77
- package/dist/services/getExpectedTargetPullRequests.d.ts +0 -9
- package/dist/services/getExpectedTargetPullRequests.js +0 -77
- package/dist/services/getTargetBranches.d.ts +0 -5
- package/dist/services/getTargetBranches.js +0 -60
- package/dist/services/getTargetBranches.test.d.ts +0 -1
- package/dist/services/getTargetBranches.test.js +0 -180
- package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
- package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitBySha.js +0 -95
- package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
- package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
- package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
- package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
- package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
- package/dist/services/github/v4/fetchProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchProjectConfig.js +0 -56
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
- package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
- package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
- package/dist/services/maybeSetupRepo.d.ts +0 -2
- package/dist/services/maybeSetupRepo.js +0 -33
- package/dist/services/maybeSetupRepo.test.d.ts +0 -1
- package/dist/services/maybeSetupRepo.test.js +0 -78
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit/sourceCommit.js +0 -86
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
- package/dist/services/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit.js +0 -86
- package/dist/services/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit.test.js +0 -280
- package/dist/test/backport-e2e.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.js +0 -170
- package/dist/test/integration/createSpies.d.ts +0 -17
- package/dist/test/integration/createSpies.js +0 -85
- package/dist/test/integration/envConstants.d.ts +0 -5
- package/dist/test/integration/envConstants.js +0 -9
- package/dist/test/integration/helpers.d.ts +0 -7
- package/dist/test/integration/helpers.js +0 -31
- package/dist/test/integration/integration.private.test.d.ts +0 -1
- package/dist/test/integration/integration.private.test.js +0 -327
- package/dist/test/integration/integration.test.d.ts +0 -1
- package/dist/test/integration/integration.test.js +0 -214
- package/dist/todo-delete.d.ts +0 -1
- package/dist/todo-delete.js +0 -17
- package/dist/types/Commit.d.ts +0 -85
- package/dist/types/Commit.js +0 -139
- package/dist/types/PromiseReturnType.d.ts +0 -1
- package/dist/types/commitNode.d.ts +0 -89
- package/dist/types/commitNode.js +0 -139
- package/dist/types/commitNode.test.d.ts +0 -1
- package/dist/types/commitNode.test.js +0 -255
- package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
- package/dist/types/commitWithAssociatedPullRequests.js +0 -145
- package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
- package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
- package/dist/ui/getTargetBranchesFromLabels.js +0 -40
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
- package/dist/utils/sequentially.d.ts +0 -1
- package/dist/utils/sequentially.js +0 -10
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOptionsFromConfigFiles = void 0;
|
|
4
|
-
const getOptionsFromGit_1 = require("./getOptionsFromGit");
|
|
5
4
|
const globalConfig_1 = require("./globalConfig");
|
|
6
5
|
const projectConfig_1 = require("./projectConfig");
|
|
7
6
|
async function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule, defaultConfigOptions, }) {
|
|
8
7
|
// ci: cli and module only flag
|
|
9
8
|
const ci = optionsFromCliArgs.ci ?? optionsFromModule.ci ?? defaultConfigOptions.ci;
|
|
10
9
|
// ci: cli and module only flag
|
|
11
|
-
const configFile = optionsFromCliArgs.configFile ??
|
|
12
|
-
|
|
13
|
-
defaultConfigOptions.configFile;
|
|
14
|
-
const [gitConfig, projectConfig, globalConfig] = await Promise.all([
|
|
15
|
-
(0, getOptionsFromGit_1.getOptionsFromGit)(),
|
|
10
|
+
const configFile = optionsFromCliArgs.configFile ?? optionsFromModule.configFile;
|
|
11
|
+
const [projectConfig, globalConfig] = await Promise.all([
|
|
16
12
|
(0, projectConfig_1.getProjectConfig)({ configFile }),
|
|
17
13
|
ci ? undefined : (0, globalConfig_1.getGlobalConfig)(),
|
|
18
14
|
]);
|
|
19
15
|
return {
|
|
20
|
-
...gitConfig,
|
|
21
16
|
...globalConfig,
|
|
22
17
|
...projectConfig,
|
|
23
18
|
...optionsFromModule,
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const
|
|
6
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
23
7
|
const mockConfigFiles_1 = require("../../test/mockConfigFiles");
|
|
24
8
|
const config_1 = require("./config");
|
|
25
9
|
describe('getOptionsFromConfigFiles', () => {
|
|
26
10
|
let res;
|
|
27
11
|
beforeEach(async () => {
|
|
28
|
-
jest.spyOn(
|
|
29
|
-
jest.spyOn(
|
|
12
|
+
jest.spyOn(promises_1.default, 'writeFile').mockResolvedValueOnce(undefined);
|
|
13
|
+
jest.spyOn(promises_1.default, 'chmod').mockResolvedValue();
|
|
30
14
|
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
31
15
|
globalConfig: { accessToken: 'abc', editor: 'vim' },
|
|
32
16
|
projectConfig: { repoName: 'kibana', repoOwner: 'elastic' },
|
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createGlobalConfigIfNotExist = exports.createGlobalConfigAndFolderIfNotExist = exports.getGlobalConfig = void 0;
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
7
8
|
const make_dir_1 = __importDefault(require("make-dir"));
|
|
8
9
|
const HandledError_1 = require("../../services/HandledError");
|
|
9
10
|
const env_1 = require("../../services/env");
|
|
10
|
-
const fs_promisified_1 = require("../../services/fs-promisified");
|
|
11
11
|
const readConfigFile_1 = require("./readConfigFile");
|
|
12
12
|
async function getGlobalConfig() {
|
|
13
13
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
@@ -25,11 +25,11 @@ async function createGlobalConfigAndFolderIfNotExist(globalConfigPath) {
|
|
|
25
25
|
}
|
|
26
26
|
exports.createGlobalConfigAndFolderIfNotExist = createGlobalConfigAndFolderIfNotExist;
|
|
27
27
|
function ensureCorrectPermissions(globalConfigPath) {
|
|
28
|
-
return (0,
|
|
28
|
+
return (0, promises_1.chmod)(globalConfigPath, '600');
|
|
29
29
|
}
|
|
30
30
|
async function createGlobalConfigIfNotExist(globalConfigPath, configTemplate) {
|
|
31
31
|
try {
|
|
32
|
-
await (0,
|
|
32
|
+
await (0, promises_1.writeFile)(globalConfigPath, configTemplate, {
|
|
33
33
|
flag: 'wx',
|
|
34
34
|
mode: 0o600, // give the owner read-write privleges, no access for others
|
|
35
35
|
});
|
|
@@ -1,30 +1,11 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
24
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
25
7
|
const os_1 = __importDefault(require("os"));
|
|
26
8
|
const make_dir_1 = __importDefault(require("make-dir"));
|
|
27
|
-
const fs = __importStar(require("../../services/fs-promisified"));
|
|
28
9
|
const globalConfig_1 = require("./globalConfig");
|
|
29
10
|
describe('config', () => {
|
|
30
11
|
afterEach(() => jest.clearAllMocks());
|
|
@@ -34,21 +15,21 @@ describe('config', () => {
|
|
|
34
15
|
describe('getGlobalConfig', () => {
|
|
35
16
|
let res;
|
|
36
17
|
beforeEach(async () => {
|
|
37
|
-
jest.spyOn(
|
|
38
|
-
jest.spyOn(
|
|
39
|
-
jest.spyOn(
|
|
18
|
+
jest.spyOn(promises_1.default, 'chmod').mockResolvedValueOnce();
|
|
19
|
+
jest.spyOn(promises_1.default, 'writeFile').mockResolvedValueOnce();
|
|
20
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
40
21
|
accessToken: 'myAccessToken',
|
|
41
22
|
}));
|
|
42
23
|
res = await (0, globalConfig_1.getGlobalConfig)();
|
|
43
24
|
});
|
|
44
25
|
it("should create config if it doesn't exist", () => {
|
|
45
|
-
expect(
|
|
26
|
+
expect(promises_1.default.writeFile).toHaveBeenCalledWith('/myHomeDir/.backport/config.json', expect.any(String), { flag: 'wx', mode: 384 });
|
|
46
27
|
});
|
|
47
28
|
it("should create .backport folder if it doesn't exist", () => {
|
|
48
29
|
expect(make_dir_1.default).toHaveBeenCalledWith('/myHomeDir/.backport');
|
|
49
30
|
});
|
|
50
31
|
it('should load config', () => {
|
|
51
|
-
expect(
|
|
32
|
+
expect(promises_1.default.readFile).toHaveBeenCalledWith('/myHomeDir/.backport/config.json', 'utf8');
|
|
52
33
|
});
|
|
53
34
|
it('should return config', () => {
|
|
54
35
|
expect(res).toEqual({
|
|
@@ -58,22 +39,22 @@ describe('config', () => {
|
|
|
58
39
|
});
|
|
59
40
|
describe('createGlobalConfigIfNotExist', () => {
|
|
60
41
|
it("should create config if it does't exist", async () => {
|
|
61
|
-
jest.spyOn(
|
|
42
|
+
jest.spyOn(promises_1.default, 'writeFile').mockResolvedValueOnce(undefined);
|
|
62
43
|
const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/globalConfig', 'myConfigTemplate');
|
|
63
44
|
expect(didCreate).toEqual(true);
|
|
64
|
-
expect(
|
|
45
|
+
expect(promises_1.default.writeFile).toHaveBeenCalledWith('/path/to/globalConfig', expect.stringContaining('myConfigTemplate'), { flag: 'wx', mode: 384 });
|
|
65
46
|
});
|
|
66
47
|
it('should not fail if config already exists', async () => {
|
|
67
48
|
const err = new Error();
|
|
68
49
|
err.code = 'EEXIST';
|
|
69
|
-
jest.spyOn(
|
|
50
|
+
jest.spyOn(promises_1.default, 'writeFile').mockRejectedValueOnce(err);
|
|
70
51
|
const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/global/config.json', 'myConfigTemplate');
|
|
71
52
|
expect(didCreate).toEqual(false);
|
|
72
53
|
});
|
|
73
54
|
it("should fail gracefully if .backport folder doesn't exist", async () => {
|
|
74
55
|
const err = new Error();
|
|
75
56
|
err.code = 'ENOENT';
|
|
76
|
-
jest.spyOn(
|
|
57
|
+
jest.spyOn(promises_1.default, 'writeFile').mockRejectedValueOnce(err);
|
|
77
58
|
await expect(() => (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/global/config.json', 'myConfigTemplate')).rejects.toThrowError('The .backport folder (/path/to/global/config.json) does not exist.');
|
|
78
59
|
});
|
|
79
60
|
});
|
|
@@ -1,36 +1,17 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
24
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
25
7
|
const find_up_1 = __importDefault(require("find-up"));
|
|
26
|
-
const fs = __importStar(require("../../services/fs-promisified"));
|
|
27
8
|
const projectConfig_1 = require("./projectConfig");
|
|
28
9
|
describe('getProjectConfig', () => {
|
|
29
10
|
afterEach(() => jest.clearAllMocks());
|
|
30
11
|
describe('deprecations', () => {
|
|
31
12
|
describe('when specifying deprecated `branches`', () => {
|
|
32
13
|
it('is returned as `targetBranchChoices`', async () => {
|
|
33
|
-
jest.spyOn(
|
|
14
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
34
15
|
repoName: 'kibana',
|
|
35
16
|
repoOwner: 'elastic',
|
|
36
17
|
branches: ['6.x'],
|
|
@@ -41,7 +22,7 @@ describe('getProjectConfig', () => {
|
|
|
41
22
|
});
|
|
42
23
|
describe('when specifying deprecated `labels`', () => {
|
|
43
24
|
it('is returned as `targetPRLabels`', async () => {
|
|
44
|
-
jest.spyOn(
|
|
25
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
45
26
|
labels: ['backport'],
|
|
46
27
|
}));
|
|
47
28
|
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
@@ -50,7 +31,7 @@ describe('getProjectConfig', () => {
|
|
|
50
31
|
});
|
|
51
32
|
describe('when specifying deprecated `upstream`', () => {
|
|
52
33
|
it('is split into `repoOwner` and `repoName`', async () => {
|
|
53
|
-
jest.spyOn(
|
|
34
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
54
35
|
upstream: 'elastic/kibana',
|
|
55
36
|
}));
|
|
56
37
|
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
@@ -61,7 +42,7 @@ describe('getProjectConfig', () => {
|
|
|
61
42
|
describe('when projectConfig is valid', () => {
|
|
62
43
|
let projectConfig;
|
|
63
44
|
beforeEach(async () => {
|
|
64
|
-
jest.spyOn(
|
|
45
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
65
46
|
repoName: 'kibana',
|
|
66
47
|
repoOwner: 'elastic',
|
|
67
48
|
targetBranchChoices: ['6.x'],
|
|
@@ -85,7 +66,7 @@ describe('getProjectConfig', () => {
|
|
|
85
66
|
let projectConfig;
|
|
86
67
|
let spy;
|
|
87
68
|
beforeEach(async () => {
|
|
88
|
-
spy = jest.spyOn(
|
|
69
|
+
spy = jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
89
70
|
repoName: 'kibana',
|
|
90
71
|
repoOwner: 'elastic',
|
|
91
72
|
targetBranchChoices: ['6.x'],
|
|
@@ -113,7 +94,7 @@ describe('getProjectConfig', () => {
|
|
|
113
94
|
});
|
|
114
95
|
describe('when projectConfig is empty', () => {
|
|
115
96
|
it('should return empty config', async () => {
|
|
116
|
-
jest.spyOn(
|
|
97
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce('{}');
|
|
117
98
|
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
118
99
|
expect(projectConfig).toEqual({});
|
|
119
100
|
});
|
|
@@ -3,6 +3,7 @@ export declare function readConfigFile(filepath: string): Promise<ConfigFileOpti
|
|
|
3
3
|
export declare function withConfigMigrations({ upstream, labels, branches, ...config }: ConfigFileOptions): {
|
|
4
4
|
fork?: boolean | undefined;
|
|
5
5
|
dir?: string | undefined;
|
|
6
|
+
help?: boolean | undefined;
|
|
6
7
|
verbose?: boolean | undefined;
|
|
7
8
|
accessToken?: string | undefined;
|
|
8
9
|
author?: string | null | undefined;
|
|
@@ -34,6 +35,8 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
34
35
|
repoOwner?: string | undefined;
|
|
35
36
|
repoName?: string | undefined;
|
|
36
37
|
sourceBranch?: string | undefined;
|
|
38
|
+
username?: string | undefined;
|
|
39
|
+
version?: boolean | undefined;
|
|
37
40
|
commitPaths?: string[] | undefined;
|
|
38
41
|
reviewers?: string[] | undefined;
|
|
39
42
|
sourcePRLabels?: string[] | undefined;
|
|
@@ -44,13 +47,7 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
44
47
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
45
48
|
files: string[];
|
|
46
49
|
directory: string;
|
|
47
|
-
logger:
|
|
48
|
-
error: (message: string, meta?: unknown) => void;
|
|
49
|
-
warn: (message: string, meta?: unknown) => void;
|
|
50
|
-
info: (message: string, meta?: unknown) => void;
|
|
51
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
52
|
-
debug: (message: string, meta?: unknown) => void;
|
|
53
|
-
};
|
|
50
|
+
logger: import("winston").Logger;
|
|
54
51
|
targetBranch: string;
|
|
55
52
|
}) => boolean | Promise<boolean>) | undefined;
|
|
56
53
|
backportBinary?: string | undefined;
|
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.withConfigMigrations = exports.readConfigFile = void 0;
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
7
8
|
const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
|
8
9
|
const HandledError_1 = require("../../services/HandledError");
|
|
9
|
-
const fs_promisified_1 = require("../../services/fs-promisified");
|
|
10
10
|
const excludeUndefined_1 = require("../../utils/excludeUndefined");
|
|
11
11
|
async function readConfigFile(filepath) {
|
|
12
|
-
const fileContents = await (0,
|
|
12
|
+
const fileContents = await (0, promises_1.readFile)(filepath, 'utf8');
|
|
13
13
|
const configWithoutComments = (0, strip_json_comments_1.default)(fileContents);
|
|
14
14
|
try {
|
|
15
15
|
return withConfigMigrations(JSON.parse(configWithoutComments));
|
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
import { ConfigFileOptions, TargetBranchChoiceOrString } from './ConfigOptions';
|
|
2
2
|
export declare type ValidConfigOptions = Readonly<Awaited<ReturnType<typeof getOptions>>>;
|
|
3
|
-
export declare const defaultConfigOptions: {
|
|
4
|
-
assignees: string[];
|
|
5
|
-
autoAssign: boolean;
|
|
6
|
-
autoMerge: boolean;
|
|
7
|
-
autoMergeMethod: string;
|
|
8
|
-
backportBinary: string;
|
|
9
|
-
cherrypickRef: boolean;
|
|
10
|
-
ci: boolean;
|
|
11
|
-
commitPaths: string[];
|
|
12
|
-
dateSince: null;
|
|
13
|
-
dateUntil: null;
|
|
14
|
-
details: boolean;
|
|
15
|
-
fork: boolean;
|
|
16
|
-
maxNumber: number;
|
|
17
|
-
multipleBranches: boolean;
|
|
18
|
-
multipleCommits: boolean;
|
|
19
|
-
noVerify: boolean;
|
|
20
|
-
publishStatusComment: boolean;
|
|
21
|
-
resetAuthor: boolean;
|
|
22
|
-
reviewers: string[];
|
|
23
|
-
sourcePRLabels: string[];
|
|
24
|
-
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
25
|
-
targetBranches: string[];
|
|
26
|
-
targetPRLabels: string[];
|
|
27
|
-
verbose: boolean;
|
|
28
|
-
};
|
|
29
3
|
export declare function getOptions(processArgs: string[], optionsFromModule: ConfigFileOptions): Promise<{
|
|
30
4
|
accessToken: string;
|
|
31
5
|
repoName: string;
|
|
@@ -44,7 +18,7 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
44
18
|
details: boolean;
|
|
45
19
|
editor?: string | undefined;
|
|
46
20
|
skipRemoteConfig?: boolean | undefined;
|
|
47
|
-
gitHostname
|
|
21
|
+
gitHostname: string;
|
|
48
22
|
githubApiBaseUrlV3?: string | undefined;
|
|
49
23
|
githubApiBaseUrlV4?: string | undefined;
|
|
50
24
|
logFilePath?: string | undefined;
|
|
@@ -60,6 +34,7 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
60
34
|
sha?: string | undefined;
|
|
61
35
|
resetAuthor: boolean;
|
|
62
36
|
sourceBranch: string;
|
|
37
|
+
username?: string | undefined;
|
|
63
38
|
dateSince: string | null;
|
|
64
39
|
dateUntil: string | null;
|
|
65
40
|
commitPaths: string[];
|
|
@@ -76,20 +51,17 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
76
51
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
77
52
|
files: string[];
|
|
78
53
|
directory: string;
|
|
79
|
-
logger:
|
|
80
|
-
error: (message: string, meta?: unknown) => void;
|
|
81
|
-
warn: (message: string, meta?: unknown) => void;
|
|
82
|
-
info: (message: string, meta?: unknown) => void;
|
|
83
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
84
|
-
debug: (message: string, meta?: unknown) => void;
|
|
85
|
-
};
|
|
54
|
+
logger: import("winston").Logger;
|
|
86
55
|
targetBranch: string;
|
|
87
56
|
}) => boolean | Promise<boolean>) | undefined;
|
|
88
57
|
backportBinary: string;
|
|
89
58
|
multiple?: boolean | undefined;
|
|
59
|
+
help?: boolean | undefined;
|
|
60
|
+
version?: boolean | undefined;
|
|
90
61
|
branchLabelMapping?: Record<string, string> | undefined;
|
|
91
62
|
upstream?: string | undefined;
|
|
92
63
|
branches?: TargetBranchChoiceOrString[] | undefined;
|
|
93
64
|
labels?: string[] | undefined;
|
|
94
65
|
authenticatedUsername: string;
|
|
66
|
+
cwd: string;
|
|
95
67
|
}>;
|
package/dist/options/options.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptions =
|
|
3
|
+
exports.getOptions = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const HandledError_1 = require("../services/HandledError");
|
|
6
6
|
const env_1 = require("../services/env");
|
|
7
7
|
const getOptionsFromGithub_1 = require("../services/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
8
|
+
const getRepoOwnerAndNameFromGitRemotes_1 = require("../services/github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
8
9
|
const logger_1 = require("./../services/logger");
|
|
9
10
|
const cliArgs_1 = require("./cliArgs");
|
|
10
11
|
const config_1 = require("./config/config");
|
|
11
12
|
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson';
|
|
12
13
|
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson';
|
|
13
|
-
|
|
14
|
+
const defaultConfigOptions = {
|
|
14
15
|
assignees: [],
|
|
15
16
|
autoAssign: false,
|
|
16
17
|
autoMerge: false,
|
|
@@ -19,10 +20,12 @@ exports.defaultConfigOptions = {
|
|
|
19
20
|
cherrypickRef: true,
|
|
20
21
|
ci: false,
|
|
21
22
|
commitPaths: [],
|
|
23
|
+
cwd: process.cwd(),
|
|
22
24
|
dateSince: null,
|
|
23
25
|
dateUntil: null,
|
|
24
26
|
details: false,
|
|
25
27
|
fork: true,
|
|
28
|
+
gitHostname: 'github.com',
|
|
26
29
|
maxNumber: 10,
|
|
27
30
|
multipleBranches: true,
|
|
28
31
|
multipleCommits: false,
|
|
@@ -41,22 +44,19 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
41
44
|
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)({
|
|
42
45
|
optionsFromCliArgs,
|
|
43
46
|
optionsFromModule,
|
|
44
|
-
defaultConfigOptions
|
|
47
|
+
defaultConfigOptions,
|
|
45
48
|
});
|
|
46
49
|
// combined options from cli and config files
|
|
47
50
|
const combined = getCombinedOptions({
|
|
48
51
|
optionsFromConfigFiles,
|
|
49
52
|
optionsFromCliArgs,
|
|
50
53
|
});
|
|
54
|
+
const { accessToken, repoName, repoOwner } = await getRequiredOptions(combined);
|
|
51
55
|
// update logger
|
|
52
|
-
(0, logger_1.updateLogger)(combined);
|
|
53
|
-
// required
|
|
54
|
-
const accessToken = requireAccessToken(combined);
|
|
55
|
-
const repoName = requireRepoName(combined);
|
|
56
|
-
const repoOwner = requireRepoOwner(combined);
|
|
56
|
+
(0, logger_1.updateLogger)({ accessToken, verbose: combined.verbose });
|
|
57
57
|
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)({
|
|
58
58
|
...combined,
|
|
59
|
-
// required
|
|
59
|
+
// required options
|
|
60
60
|
accessToken,
|
|
61
61
|
repoName,
|
|
62
62
|
repoOwner,
|
|
@@ -65,7 +65,7 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
65
65
|
// default author
|
|
66
66
|
author: optionsFromGithub.authenticatedUsername,
|
|
67
67
|
// default values have lowest precedence
|
|
68
|
-
...
|
|
68
|
+
...defaultConfigOptions,
|
|
69
69
|
// local config options override default options
|
|
70
70
|
...optionsFromConfigFiles,
|
|
71
71
|
// remote config options override local config options
|
|
@@ -81,32 +81,40 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
81
81
|
return res;
|
|
82
82
|
}
|
|
83
83
|
exports.getOptions = getOptions;
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
function requireAccessToken(combinedOptions) {
|
|
92
|
-
// accessToken must be supplied in config or via cli args
|
|
93
|
-
if (!combinedOptions.accessToken) {
|
|
84
|
+
async function getRequiredOptions(combined) {
|
|
85
|
+
const { accessToken, repoName, repoOwner } = combined;
|
|
86
|
+
if (accessToken && repoName && repoOwner) {
|
|
87
|
+
return { accessToken, repoName, repoOwner };
|
|
88
|
+
}
|
|
89
|
+
// require access token
|
|
90
|
+
if (!accessToken) {
|
|
94
91
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
95
92
|
throw new HandledError_1.HandledError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
96
93
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
// attempt to retrieve repo-owner and repo-name from git remote
|
|
95
|
+
const gitRemote = await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
96
|
+
cwd: combined.cwd,
|
|
97
|
+
githubApiBaseUrlV4: combined.githubApiBaseUrlV4,
|
|
98
|
+
accessToken,
|
|
99
|
+
});
|
|
100
|
+
if (!gitRemote.repoName) {
|
|
101
101
|
throw new HandledError_1.HandledError(`Please specify a repo name: "--repo-name kibana".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
function requireRepoOwner(combinedOptions) {
|
|
106
|
-
if (!combinedOptions.repoOwner) {
|
|
103
|
+
if (!gitRemote.repoOwner) {
|
|
107
104
|
throw new HandledError_1.HandledError(`Please specify a repo owner: "--repo-owner elastic".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
108
105
|
}
|
|
109
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
accessToken,
|
|
108
|
+
repoName: gitRemote.repoName,
|
|
109
|
+
repoOwner: gitRemote.repoOwner,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function getCombinedOptions({ optionsFromConfigFiles, optionsFromCliArgs, }) {
|
|
113
|
+
return {
|
|
114
|
+
...defaultConfigOptions,
|
|
115
|
+
...optionsFromConfigFiles,
|
|
116
|
+
...optionsFromCliArgs,
|
|
117
|
+
};
|
|
110
118
|
}
|
|
111
119
|
function requireTargetBranch(config) {
|
|
112
120
|
// ensure `targetBranches` or `targetBranchChoices` are given
|
|
@@ -22,14 +22,14 @@ 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 promises_1 = __importDefault(require("fs/promises"));
|
|
25
26
|
const os_1 = __importDefault(require("os"));
|
|
26
27
|
const nock_1 = __importDefault(require("nock"));
|
|
27
|
-
const
|
|
28
|
+
const git = __importStar(require("../services/git"));
|
|
28
29
|
const logger = __importStar(require("../services/logger"));
|
|
29
30
|
const mockConfigFiles_1 = require("../test/mockConfigFiles");
|
|
30
31
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
31
32
|
const options_1 = require("./options");
|
|
32
|
-
jest.unmock('../services/fs-promisified');
|
|
33
33
|
const defaultConfigs = {
|
|
34
34
|
projectConfig: {
|
|
35
35
|
// use localhost to avoid CORS issues with nock
|
|
@@ -48,8 +48,8 @@ describe('getOptions', () => {
|
|
|
48
48
|
beforeEach(() => {
|
|
49
49
|
(0, mockConfigFiles_1.mockConfigFiles)(defaultConfigs);
|
|
50
50
|
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
51
|
-
jest.spyOn(
|
|
52
|
-
jest.spyOn(
|
|
51
|
+
jest.spyOn(promises_1.default, 'writeFile').mockResolvedValue();
|
|
52
|
+
jest.spyOn(promises_1.default, 'chmod').mockResolvedValue();
|
|
53
53
|
});
|
|
54
54
|
describe('should throw', () => {
|
|
55
55
|
beforeEach(() => {
|
|
@@ -81,27 +81,36 @@ describe('getOptions', () => {
|
|
|
81
81
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
82
82
|
`);
|
|
83
83
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
describe('when repoName and repoOwner are missing', () => {
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
mockProjectConfig({ repoName: undefined, repoOwner: undefined });
|
|
87
|
+
});
|
|
88
|
+
it('should throw if there are no remotes', async () => {
|
|
89
|
+
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
90
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
91
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
88
92
|
"Please specify a repo name: \\"--repo-name kibana\\".
|
|
89
93
|
|
|
90
94
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
91
95
|
`);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
});
|
|
97
|
+
it('should get repoName from the remote', async () => {
|
|
98
|
+
mockRepoOwnerAndName({
|
|
99
|
+
childRepoOwner: 'sqren',
|
|
100
|
+
parentRepoOwner: 'elastic',
|
|
101
|
+
repoName: 'kibana',
|
|
102
|
+
});
|
|
103
|
+
jest
|
|
104
|
+
.spyOn(git, 'getRepoInfoFromGitRemotes')
|
|
105
|
+
.mockResolvedValue([{ repoName: 'kibana', repoOwner: 'sqren' }]);
|
|
106
|
+
const options = await (0, options_1.getOptions)([], {});
|
|
107
|
+
expect(options.repoName).toBe('kibana');
|
|
108
|
+
expect(options.repoOwner).toBe('elastic');
|
|
109
|
+
});
|
|
101
110
|
});
|
|
102
111
|
});
|
|
103
112
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
104
|
-
mockGithubConfigOptions({
|
|
113
|
+
mockGithubConfigOptions({ hasBackportBranch: true });
|
|
105
114
|
await expect((0, options_1.getOptions)([], {})).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
106
115
|
});
|
|
107
116
|
it('should merge config options and module options', async () => {
|
|
@@ -142,11 +151,13 @@ describe('getOptions', () => {
|
|
|
142
151
|
cherrypickRef: true,
|
|
143
152
|
ci: false,
|
|
144
153
|
commitPaths: [],
|
|
154
|
+
cwd: expect.any(String),
|
|
145
155
|
dateSince: null,
|
|
146
156
|
dateUntil: null,
|
|
147
157
|
details: false,
|
|
148
158
|
editor: 'code',
|
|
149
159
|
fork: true,
|
|
160
|
+
gitHostname: 'github.com',
|
|
150
161
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
151
162
|
historicalBranchLabelMappings: [
|
|
152
163
|
{
|
|
@@ -297,7 +308,7 @@ function mockProjectConfig(projectConfig) {
|
|
|
297
308
|
},
|
|
298
309
|
});
|
|
299
310
|
}
|
|
300
|
-
function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBranchRef = 'DO_NOT_USE-default-branch-name',
|
|
311
|
+
function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBranchRef = 'DO_NOT_USE-default-branch-name', hasBackportBranch, historicalMappings = [], }) {
|
|
301
312
|
return (0, nockHelpers_1.mockGqlRequest)({
|
|
302
313
|
name: 'GithubConfigOptions',
|
|
303
314
|
statusCode: 200,
|
|
@@ -307,9 +318,7 @@ function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBran
|
|
|
307
318
|
login: viewerLogin,
|
|
308
319
|
},
|
|
309
320
|
repository: {
|
|
310
|
-
|
|
311
|
-
parent: null,
|
|
312
|
-
ref: refName ? { name: refName } : null,
|
|
321
|
+
illegalBackportBranch: hasBackportBranch ? { id: 'foo' } : null,
|
|
313
322
|
defaultBranchRef: {
|
|
314
323
|
name: defaultBranchRef,
|
|
315
324
|
target: {
|
|
@@ -336,3 +345,25 @@ function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBran
|
|
|
336
345
|
},
|
|
337
346
|
});
|
|
338
347
|
}
|
|
348
|
+
function mockRepoOwnerAndName({ repoName, parentRepoOwner, childRepoOwner, }) {
|
|
349
|
+
return (0, nockHelpers_1.mockGqlRequest)({
|
|
350
|
+
name: 'RepoOwnerAndName',
|
|
351
|
+
statusCode: 200,
|
|
352
|
+
body: {
|
|
353
|
+
data: {
|
|
354
|
+
repository: {
|
|
355
|
+
isFork: true,
|
|
356
|
+
name: repoName,
|
|
357
|
+
owner: {
|
|
358
|
+
login: childRepoOwner,
|
|
359
|
+
},
|
|
360
|
+
parent: {
|
|
361
|
+
owner: {
|
|
362
|
+
login: parentRepoOwner,
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|