backport 6.2.0 → 6.3.0-beta-3
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 +15 -6
- 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 +277 -0
- package/dist/entrypoint.cli.js +3 -5
- 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.d.ts +2 -2
- package/dist/entrypoint.module.js +4 -4
- package/dist/options/ConfigOptions.d.ts +7 -3
- package/dist/options/cliArgs.d.ts +16 -14
- package/dist/options/cliArgs.js +31 -5
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +11 -11
- package/dist/options/config/config.js +7 -6
- package/dist/options/config/config.test.js +11 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +15 -9
- package/dist/options/config/globalConfig.test.js +17 -30
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/projectConfig.test.js +41 -31
- package/dist/options/config/readConfigFile.d.ts +21 -23
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +19 -46
- package/dist/options/options.js +40 -32
- package/dist/options/options.test.js +83 -50
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +1 -1
- package/dist/runSequentially.test.js +37 -18
- package/dist/scripts/postinstall.js +3 -3
- 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.d.ts +3 -1
- package/dist/services/env.js +4 -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 +16 -10
- package/dist/services/github/v3/createPullRequest.test.js +248 -33
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- 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/fetchCommits/allFetchers.private.test.js +37 -19
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +17 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +23 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -4
- 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 +31 -14
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
- package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +7 -9
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +48 -40
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -0
- 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 +11 -17
- package/dist/services/logger.js +29 -66
- 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} +136 -116
- 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.js +5 -4
- 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 +50 -27
- 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 +26 -21
- package/yarn.lock +165 -237
- 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 -168
- 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
package/dist/options/cliArgs.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getOptionsFromCliArgs = void 0;
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
8
|
const excludeUndefined_1 = require("../utils/excludeUndefined");
|
|
9
|
-
function getOptionsFromCliArgs(
|
|
10
|
-
const yargsInstance = (0, yargs_1.default)(
|
|
9
|
+
function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
10
|
+
const yargsInstance = (0, yargs_1.default)(processArgs)
|
|
11
11
|
.parserConfiguration({
|
|
12
12
|
'strip-dashed': true,
|
|
13
13
|
'strip-aliased': true,
|
|
@@ -56,6 +56,11 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
56
56
|
description: 'Append commit message with "(cherry picked from commit...)',
|
|
57
57
|
type: 'boolean',
|
|
58
58
|
conflicts: ['noCherrypickRef'],
|
|
59
|
+
})
|
|
60
|
+
.option('configFile', {
|
|
61
|
+
alias: 'config',
|
|
62
|
+
description: 'Path to project config',
|
|
63
|
+
type: 'string',
|
|
59
64
|
})
|
|
60
65
|
.option('since', {
|
|
61
66
|
description: 'ISO-8601 date for filtering commits',
|
|
@@ -101,6 +106,11 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
101
106
|
hidden: true,
|
|
102
107
|
description: `Base url for Github's GraphQL (v4) API`,
|
|
103
108
|
type: 'string',
|
|
109
|
+
})
|
|
110
|
+
.option('logFilePath', {
|
|
111
|
+
hidden: true,
|
|
112
|
+
description: `Path to log file`,
|
|
113
|
+
type: 'string',
|
|
104
114
|
})
|
|
105
115
|
.option('mainline', {
|
|
106
116
|
description: 'Parent id of merge commit. Defaults to 1 when supplied without arguments',
|
|
@@ -109,7 +119,7 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
109
119
|
if (mainline === undefined) {
|
|
110
120
|
// return 1 if `--mainline` is given without a value
|
|
111
121
|
// return undefined if --mainline is not supplied at all
|
|
112
|
-
return
|
|
122
|
+
return processArgs.includes('--mainline') ? 1 : undefined;
|
|
113
123
|
}
|
|
114
124
|
// use specified mainline parent
|
|
115
125
|
if (Number.isInteger(mainline)) {
|
|
@@ -200,10 +210,17 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
200
210
|
.option('repoOwner', {
|
|
201
211
|
description: 'Repository owner',
|
|
202
212
|
type: 'string',
|
|
213
|
+
conflicts: ['repo'],
|
|
203
214
|
})
|
|
204
215
|
.option('repoName', {
|
|
205
216
|
description: 'Repository name',
|
|
206
217
|
type: 'string',
|
|
218
|
+
conflicts: ['repo'],
|
|
219
|
+
})
|
|
220
|
+
.option('repo', {
|
|
221
|
+
description: 'Repo owner and name',
|
|
222
|
+
type: 'string',
|
|
223
|
+
conflicts: ['repoName', 'repoOwner'],
|
|
207
224
|
})
|
|
208
225
|
.option('sha', {
|
|
209
226
|
conflicts: ['pullNumber', 'prFilter'],
|
|
@@ -273,18 +290,27 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
273
290
|
$0, _,
|
|
274
291
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
275
292
|
multiple, multipleBranches, multipleCommits, all,
|
|
293
|
+
// repoName and repoOwner
|
|
294
|
+
repo,
|
|
276
295
|
// filters
|
|
277
296
|
author, since, until,
|
|
278
297
|
// negations
|
|
279
298
|
noCherrypickRef, noFork, noStatusComment, noVerify, verify,
|
|
280
299
|
// array types (should be renamed to plural form)
|
|
281
300
|
assignee, path, reviewer, sourcePRLabel, targetBranch, targetBranchChoice, targetPRLabel, ...restOptions } = yargsInstance.parseSync();
|
|
301
|
+
const [repoOwner, repoName] = repo?.split('/') ?? [
|
|
302
|
+
restOptions.repoOwner,
|
|
303
|
+
restOptions.repoName,
|
|
304
|
+
];
|
|
282
305
|
return (0, excludeUndefined_1.excludeUndefined)({
|
|
283
306
|
...restOptions,
|
|
307
|
+
// repoName and repoOwner
|
|
308
|
+
repoOwner,
|
|
309
|
+
repoName,
|
|
284
310
|
// filters
|
|
285
311
|
author: all ? null : author,
|
|
286
|
-
dateSince: since,
|
|
287
|
-
dateUntil: until,
|
|
312
|
+
dateSince: since ? new Date(since).toISOString() : undefined,
|
|
313
|
+
dateUntil: until ? new Date(until).toISOString() : undefined,
|
|
288
314
|
// `multiple` is a cli-only flag to override `multipleBranches` and `multipleCommits`
|
|
289
315
|
multipleBranches: multiple ?? multipleBranches,
|
|
290
316
|
multipleCommits: multiple ?? multipleCommits,
|
|
@@ -33,16 +33,6 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
});
|
|
36
|
-
// blocked by: https://github.com/yargs/yargs/issues/1853
|
|
37
|
-
describe('help', () => {
|
|
38
|
-
// eslint-disable-next-line jest/no-commented-out-tests
|
|
39
|
-
// it('should output help', () => {
|
|
40
|
-
// const argv = ['--help'];
|
|
41
|
-
// expect(() =>
|
|
42
|
-
// getOptionsFromCliArgs(argv, { exitOnError: false, returnHelp: true })
|
|
43
|
-
// ).toThrow('asa');
|
|
44
|
-
// });
|
|
45
|
-
});
|
|
46
36
|
describe('sourcePRLabels', () => {
|
|
47
37
|
it('should handle all variations', () => {
|
|
48
38
|
const argv = [
|
|
@@ -149,4 +139,32 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
149
139
|
expect(res.targetBranches).toEqual(['6.0']);
|
|
150
140
|
});
|
|
151
141
|
});
|
|
142
|
+
describe('since/until', () => {
|
|
143
|
+
it('should always be UTC time (configured globally in jest.config.js)', () => {
|
|
144
|
+
expect(new Date().getTimezoneOffset()).toBe(0);
|
|
145
|
+
});
|
|
146
|
+
it('accepts ISO dates', () => {
|
|
147
|
+
const argv = [
|
|
148
|
+
'--since',
|
|
149
|
+
'2020-08-15T00:00:00.000Z',
|
|
150
|
+
'--until',
|
|
151
|
+
'2020-08-15T14:00:00.000Z',
|
|
152
|
+
];
|
|
153
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
154
|
+
expect(res.dateSince).toEqual('2020-08-15T00:00:00.000Z');
|
|
155
|
+
expect(res.dateUntil).toEqual('2020-08-15T14:00:00.000Z');
|
|
156
|
+
});
|
|
157
|
+
it('accepts non-ISO dates', () => {
|
|
158
|
+
const argv = ['--since', '2020-08-15', '--until', '2020-08-15 14:00'];
|
|
159
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
160
|
+
expect(res.dateSince).toEqual('2020-08-15T00:00:00.000Z');
|
|
161
|
+
expect(res.dateUntil).toEqual('2020-08-15T14:00:00.000Z');
|
|
162
|
+
});
|
|
163
|
+
it('accepts years', () => {
|
|
164
|
+
const argv = ['--since', '2020', '--until', '2021'];
|
|
165
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
166
|
+
expect(res.dateSince).toEqual('2020-01-01T00:00:00.000Z');
|
|
167
|
+
expect(res.dateUntil).toEqual('2021-01-01T00:00:00.000Z');
|
|
168
|
+
});
|
|
169
|
+
});
|
|
152
170
|
});
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
+
import { OptionsFromCliArgs } from '../cliArgs';
|
|
2
3
|
export declare type OptionsFromConfigFiles = Awaited<ReturnType<typeof getOptionsFromConfigFiles>>;
|
|
3
|
-
export declare function getOptionsFromConfigFiles({ optionsFromModule,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule, defaultConfigOptions, }: {
|
|
5
|
+
optionsFromCliArgs: OptionsFromCliArgs;
|
|
6
|
+
optionsFromModule: ConfigFileOptions;
|
|
7
|
+
defaultConfigOptions: ConfigFileOptions;
|
|
6
8
|
}): Promise<{
|
|
7
9
|
accessToken?: string | undefined;
|
|
8
10
|
assignees?: string[] | undefined;
|
|
@@ -11,13 +13,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromModule, ci, }: {
|
|
|
11
13
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
12
14
|
files: string[];
|
|
13
15
|
directory: string;
|
|
14
|
-
logger:
|
|
15
|
-
error: (message: string, meta?: unknown) => void;
|
|
16
|
-
warn: (message: string, meta?: unknown) => void;
|
|
17
|
-
info: (message: string, meta?: unknown) => void;
|
|
18
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
19
|
-
debug: (message: string, meta?: unknown) => void;
|
|
20
|
-
};
|
|
16
|
+
logger: import("winston").Logger;
|
|
21
17
|
targetBranch: string;
|
|
22
18
|
}) => boolean | Promise<boolean>) | undefined;
|
|
23
19
|
autoMerge?: boolean | undefined;
|
|
@@ -26,13 +22,15 @@ export declare function getOptionsFromConfigFiles({ optionsFromModule, ci, }: {
|
|
|
26
22
|
cherrypickRef?: boolean | undefined;
|
|
27
23
|
ci?: boolean | undefined;
|
|
28
24
|
commitPaths?: string[] | undefined;
|
|
29
|
-
|
|
25
|
+
configFile?: string | undefined;
|
|
30
26
|
details?: boolean | undefined;
|
|
27
|
+
dir?: string | undefined;
|
|
31
28
|
editor?: string | undefined;
|
|
32
29
|
fork?: boolean | undefined;
|
|
33
30
|
gitHostname?: string | undefined;
|
|
34
31
|
githubApiBaseUrlV3?: string | undefined;
|
|
35
32
|
githubApiBaseUrlV4?: string | undefined;
|
|
33
|
+
logFilePath?: string | undefined;
|
|
36
34
|
maxNumber?: number | undefined;
|
|
37
35
|
multiple?: boolean | undefined;
|
|
38
36
|
multipleBranches?: boolean | undefined;
|
|
@@ -55,6 +53,8 @@ export declare function getOptionsFromConfigFiles({ optionsFromModule, ci, }: {
|
|
|
55
53
|
targetBranches?: string[] | undefined;
|
|
56
54
|
targetPRLabels?: string[] | undefined;
|
|
57
55
|
verbose?: boolean | undefined;
|
|
56
|
+
help?: boolean | undefined;
|
|
57
|
+
version?: boolean | undefined;
|
|
58
58
|
branchLabelMapping?: Record<string, string> | undefined;
|
|
59
59
|
upstream?: string | undefined;
|
|
60
60
|
branches?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
@@ -1,17 +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
|
-
async function getOptionsFromConfigFiles({ optionsFromModule,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
async function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule, defaultConfigOptions, }) {
|
|
7
|
+
// ci: cli and module only flag
|
|
8
|
+
const ci = optionsFromCliArgs.ci ?? optionsFromModule.ci ?? defaultConfigOptions.ci;
|
|
9
|
+
// ci: cli and module only flag
|
|
10
|
+
const configFile = optionsFromCliArgs.configFile ?? optionsFromModule.configFile;
|
|
11
|
+
const [projectConfig, globalConfig] = await Promise.all([
|
|
12
|
+
(0, projectConfig_1.getProjectConfig)({ configFile }),
|
|
11
13
|
ci ? undefined : (0, globalConfig_1.getGlobalConfig)(),
|
|
12
14
|
]);
|
|
13
15
|
return {
|
|
14
|
-
...gitConfig,
|
|
15
16
|
...globalConfig,
|
|
16
17
|
...projectConfig,
|
|
17
18
|
...optionsFromModule,
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
3
7
|
const mockConfigFiles_1 = require("../../test/mockConfigFiles");
|
|
4
8
|
const config_1 = require("./config");
|
|
5
9
|
describe('getOptionsFromConfigFiles', () => {
|
|
6
10
|
let res;
|
|
7
11
|
beforeEach(async () => {
|
|
12
|
+
jest.spyOn(promises_1.default, 'writeFile').mockResolvedValueOnce(undefined);
|
|
13
|
+
jest.spyOn(promises_1.default, 'chmod').mockResolvedValue();
|
|
8
14
|
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
9
15
|
globalConfig: { accessToken: 'abc', editor: 'vim' },
|
|
10
16
|
projectConfig: { repoName: 'kibana', repoOwner: 'elastic' },
|
|
11
17
|
});
|
|
12
|
-
res = await (0, config_1.getOptionsFromConfigFiles)({
|
|
18
|
+
res = await (0, config_1.getOptionsFromConfigFiles)({
|
|
19
|
+
optionsFromCliArgs: {},
|
|
20
|
+
optionsFromModule: {},
|
|
21
|
+
defaultConfigOptions: { ci: false },
|
|
22
|
+
});
|
|
13
23
|
});
|
|
14
24
|
it('should return values from config files', () => {
|
|
15
25
|
expect(res).toEqual({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
2
|
export declare function getGlobalConfig(): Promise<ConfigFileOptions>;
|
|
3
|
-
export declare function createGlobalConfigAndFolderIfNotExist(): Promise<boolean>;
|
|
3
|
+
export declare function createGlobalConfigAndFolderIfNotExist(globalConfigPath: string): Promise<boolean>;
|
|
4
4
|
export declare function createGlobalConfigIfNotExist(globalConfigPath: string, configTemplate: string): Promise<boolean>;
|
|
@@ -4,20 +4,20 @@ 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"));
|
|
9
|
+
const HandledError_1 = require("../../services/HandledError");
|
|
8
10
|
const env_1 = require("../../services/env");
|
|
9
|
-
const fs_promisified_1 = require("../../services/fs-promisified");
|
|
10
11
|
const readConfigFile_1 = require("./readConfigFile");
|
|
11
12
|
async function getGlobalConfig() {
|
|
12
|
-
await createGlobalConfigAndFolderIfNotExist();
|
|
13
13
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
14
|
+
await createGlobalConfigAndFolderIfNotExist(globalConfigPath);
|
|
14
15
|
return (0, readConfigFile_1.readConfigFile)(globalConfigPath);
|
|
15
16
|
}
|
|
16
17
|
exports.getGlobalConfig = getGlobalConfig;
|
|
17
|
-
async function createGlobalConfigAndFolderIfNotExist() {
|
|
18
|
+
async function createGlobalConfigAndFolderIfNotExist(globalConfigPath) {
|
|
18
19
|
// create .backport folder
|
|
19
20
|
await (0, make_dir_1.default)((0, env_1.getBackportDirPath)());
|
|
20
|
-
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
21
21
|
const configTemplate = getConfigTemplate();
|
|
22
22
|
const didCreate = await createGlobalConfigIfNotExist(globalConfigPath, configTemplate);
|
|
23
23
|
await ensureCorrectPermissions(globalConfigPath);
|
|
@@ -25,22 +25,28 @@ async function createGlobalConfigAndFolderIfNotExist() {
|
|
|
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
|
});
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
38
|
catch (e) {
|
|
39
|
+
// ignore error if file already exists
|
|
39
40
|
const FILE_ALREADY_EXISTS = 'EEXIST';
|
|
40
|
-
if (e.code
|
|
41
|
-
|
|
41
|
+
if (e.code === FILE_ALREADY_EXISTS) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
// handle error if folder does not exist
|
|
45
|
+
const FOLDER_NOT_EXISTS = 'ENOENT';
|
|
46
|
+
if (e.code === FOLDER_NOT_EXISTS) {
|
|
47
|
+
throw new HandledError_1.HandledError(`The .backport folder (${globalConfigPath}) does not exist. `);
|
|
42
48
|
}
|
|
43
|
-
|
|
49
|
+
throw e;
|
|
44
50
|
}
|
|
45
51
|
}
|
|
46
52
|
exports.createGlobalConfigIfNotExist = createGlobalConfigIfNotExist;
|
|
@@ -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({
|
|
@@ -57,18 +38,24 @@ describe('config', () => {
|
|
|
57
38
|
});
|
|
58
39
|
});
|
|
59
40
|
describe('createGlobalConfigIfNotExist', () => {
|
|
60
|
-
it(
|
|
61
|
-
jest.spyOn(
|
|
41
|
+
it("should create config if it does't exist", async () => {
|
|
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(
|
|
70
|
-
const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('
|
|
50
|
+
jest.spyOn(promises_1.default, 'writeFile').mockRejectedValueOnce(err);
|
|
51
|
+
const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/global/config.json', 'myConfigTemplate');
|
|
71
52
|
expect(didCreate).toEqual(false);
|
|
72
53
|
});
|
|
54
|
+
it("should fail gracefully if .backport folder doesn't exist", async () => {
|
|
55
|
+
const err = new Error();
|
|
56
|
+
err.code = 'ENOENT';
|
|
57
|
+
jest.spyOn(promises_1.default, 'writeFile').mockRejectedValueOnce(err);
|
|
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.');
|
|
59
|
+
});
|
|
73
60
|
});
|
|
74
61
|
});
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
-
export declare function getProjectConfig(
|
|
2
|
+
export declare function getProjectConfig({ configFile, }: {
|
|
3
|
+
configFile: string | undefined;
|
|
4
|
+
}): Promise<ConfigFileOptions | undefined>;
|
|
@@ -4,10 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getProjectConfig = void 0;
|
|
7
|
+
const posix_1 = __importDefault(require("path/posix"));
|
|
7
8
|
const find_up_1 = __importDefault(require("find-up"));
|
|
8
9
|
const readConfigFile_1 = require("../config/readConfigFile");
|
|
9
|
-
async function getProjectConfig() {
|
|
10
|
-
const filepath =
|
|
10
|
+
async function getProjectConfig({ configFile, }) {
|
|
11
|
+
const filepath = configFile
|
|
12
|
+
? posix_1.default.resolve(configFile)
|
|
13
|
+
: await (0, find_up_1.default)('.backportrc.json');
|
|
11
14
|
if (!filepath) {
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
@@ -1,59 +1,40 @@
|
|
|
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'],
|
|
37
18
|
}));
|
|
38
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
19
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
39
20
|
expect(projectConfig?.targetBranchChoices).toEqual(['6.x']);
|
|
40
21
|
});
|
|
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
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
28
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
48
29
|
expect(projectConfig?.targetPRLabels).toEqual(['backport']);
|
|
49
30
|
});
|
|
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
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
37
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
57
38
|
expect(projectConfig?.repoOwner).toEqual('elastic');
|
|
58
39
|
expect(projectConfig?.repoName).toEqual('kibana');
|
|
59
40
|
});
|
|
@@ -61,13 +42,13 @@ 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'],
|
|
68
49
|
targetPRLabels: ['backport'],
|
|
69
50
|
}));
|
|
70
|
-
projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
51
|
+
projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
71
52
|
});
|
|
72
53
|
it('should call findUp', () => {
|
|
73
54
|
expect(find_up_1.default).toHaveBeenCalledWith('.backportrc.json');
|
|
@@ -81,18 +62,47 @@ describe('getProjectConfig', () => {
|
|
|
81
62
|
});
|
|
82
63
|
});
|
|
83
64
|
});
|
|
65
|
+
describe('when specifying a path to project config', () => {
|
|
66
|
+
let projectConfig;
|
|
67
|
+
let spy;
|
|
68
|
+
beforeEach(async () => {
|
|
69
|
+
spy = jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
70
|
+
repoName: 'kibana',
|
|
71
|
+
repoOwner: 'elastic',
|
|
72
|
+
targetBranchChoices: ['6.x'],
|
|
73
|
+
targetPRLabels: ['backport'],
|
|
74
|
+
}));
|
|
75
|
+
projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
76
|
+
configFile: '/custom/path/to/project/.backportrc.json',
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it('should not call findUp', () => {
|
|
80
|
+
expect(find_up_1.default).not.toHaveBeenCalled();
|
|
81
|
+
});
|
|
82
|
+
it('should retrieve config via custom config path', () => {
|
|
83
|
+
expect(spy).toHaveBeenCalledWith('/custom/path/to/project/.backportrc.json', 'utf8');
|
|
84
|
+
});
|
|
85
|
+
it('should return config', () => {
|
|
86
|
+
expect(projectConfig).toEqual({
|
|
87
|
+
repoName: 'kibana',
|
|
88
|
+
repoOwner: 'elastic',
|
|
89
|
+
targetBranchChoices: ['6.x'],
|
|
90
|
+
targetPRLabels: ['backport'],
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
84
94
|
});
|
|
85
95
|
describe('when projectConfig is empty', () => {
|
|
86
96
|
it('should return empty config', async () => {
|
|
87
|
-
jest.spyOn(
|
|
88
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
97
|
+
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce('{}');
|
|
98
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
89
99
|
expect(projectConfig).toEqual({});
|
|
90
100
|
});
|
|
91
101
|
});
|
|
92
102
|
describe('when projectConfig is missing', () => {
|
|
93
103
|
it('should return empty config', async () => {
|
|
94
104
|
find_up_1.default.mockReturnValueOnce(undefined);
|
|
95
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
105
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({ configFile: undefined });
|
|
96
106
|
expect(projectConfig).toEqual(undefined);
|
|
97
107
|
});
|
|
98
108
|
});
|
|
@@ -3,54 +3,52 @@ 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
|
-
ci?: boolean | undefined;
|
|
8
8
|
accessToken?: string | undefined;
|
|
9
|
-
assignees?: string[] | undefined;
|
|
10
9
|
author?: string | null | undefined;
|
|
11
10
|
autoAssign?: boolean | undefined;
|
|
12
|
-
|
|
13
|
-
files: string[];
|
|
14
|
-
directory: string;
|
|
15
|
-
logger: {
|
|
16
|
-
error: (message: string, meta?: unknown) => void;
|
|
17
|
-
warn: (message: string, meta?: unknown) => void;
|
|
18
|
-
info: (message: string, meta?: unknown) => void;
|
|
19
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
20
|
-
debug: (message: string, meta?: unknown) => void;
|
|
21
|
-
};
|
|
22
|
-
targetBranch: string;
|
|
23
|
-
}) => boolean | Promise<boolean>) | undefined;
|
|
11
|
+
assignees?: string[] | undefined;
|
|
24
12
|
autoMerge?: boolean | undefined;
|
|
25
13
|
autoMergeMethod?: string | undefined;
|
|
26
|
-
|
|
14
|
+
ci?: boolean | undefined;
|
|
27
15
|
cherrypickRef?: boolean | undefined;
|
|
28
|
-
|
|
16
|
+
configFile?: string | undefined;
|
|
29
17
|
details?: boolean | undefined;
|
|
30
18
|
editor?: string | undefined;
|
|
19
|
+
skipRemoteConfig?: boolean | undefined;
|
|
31
20
|
gitHostname?: string | undefined;
|
|
32
21
|
githubApiBaseUrlV3?: string | undefined;
|
|
33
22
|
githubApiBaseUrlV4?: string | undefined;
|
|
23
|
+
logFilePath?: string | undefined;
|
|
34
24
|
maxNumber?: number | undefined;
|
|
35
25
|
multiple?: boolean | undefined;
|
|
36
26
|
multipleBranches?: boolean | undefined;
|
|
37
27
|
multipleCommits?: boolean | undefined;
|
|
38
28
|
noVerify?: boolean | undefined;
|
|
39
29
|
prDescription?: string | undefined;
|
|
40
|
-
prFilter?: string | undefined;
|
|
41
30
|
prTitle?: string | undefined;
|
|
42
|
-
|
|
31
|
+
prFilter?: string | undefined;
|
|
43
32
|
pullNumber?: number | undefined;
|
|
44
|
-
repoName?: string | undefined;
|
|
45
|
-
repoOwner?: string | undefined;
|
|
46
|
-
resetAuthor?: boolean | undefined;
|
|
47
|
-
reviewers?: string[] | undefined;
|
|
48
33
|
sha?: string | undefined;
|
|
49
|
-
|
|
34
|
+
resetAuthor?: boolean | undefined;
|
|
35
|
+
repoOwner?: string | undefined;
|
|
36
|
+
repoName?: string | undefined;
|
|
50
37
|
sourceBranch?: string | undefined;
|
|
38
|
+
version?: boolean | undefined;
|
|
39
|
+
commitPaths?: string[] | undefined;
|
|
40
|
+
reviewers?: string[] | undefined;
|
|
51
41
|
sourcePRLabels?: string[] | undefined;
|
|
52
42
|
targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
53
43
|
targetBranches?: string[] | undefined;
|
|
54
44
|
targetPRLabels?: string[] | undefined;
|
|
45
|
+
publishStatusComment?: boolean | undefined;
|
|
46
|
+
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
47
|
+
files: string[];
|
|
48
|
+
directory: string;
|
|
49
|
+
logger: import("winston").Logger;
|
|
50
|
+
targetBranch: string;
|
|
51
|
+
}) => boolean | Promise<boolean>) | undefined;
|
|
52
|
+
backportBinary?: string | undefined;
|
|
55
53
|
branchLabelMapping?: Record<string, string> | undefined;
|
|
56
54
|
};
|
|
@@ -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));
|