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
|
@@ -5,9 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
/* eslint-disable jest/no-commented-out-tests */
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
|
-
const path_1 = require("path");
|
|
9
8
|
const rest_1 = require("@octokit/rest");
|
|
10
|
-
const del = require("del");
|
|
11
9
|
const nock_1 = __importDefault(require("nock"));
|
|
12
10
|
const options_1 = require("../options/options");
|
|
13
11
|
const runSequentially_1 = require("../runSequentially");
|
|
@@ -15,22 +13,23 @@ const getCommits_1 = require("../ui/getCommits");
|
|
|
15
13
|
const mockConfigFiles_1 = require("./mockConfigFiles");
|
|
16
14
|
const nockHelpers_1 = require("./nockHelpers");
|
|
17
15
|
const getDevAccessToken_1 = require("./private/getDevAccessToken");
|
|
18
|
-
|
|
19
|
-
jest.unmock('del');
|
|
16
|
+
const sandbox_1 = require("./sandbox");
|
|
20
17
|
jest.setTimeout(10000);
|
|
21
|
-
const
|
|
22
|
-
const HOMEDIR_PATH = (0, path_1.resolve)('./src/test/tmp-mock-environments/backport-e2e/homedir');
|
|
18
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
23
19
|
const REPO_OWNER = 'backport-org';
|
|
24
20
|
const REPO_NAME = 'integration-test';
|
|
25
|
-
const
|
|
26
|
-
const
|
|
21
|
+
const BRANCH_WITH_ONE_COMMIT = 'backport/7.x/commit-5bf29b7d';
|
|
22
|
+
const BRANCH_WITH_TWO_COMMITS = 'backport/7.x/commit-5bf29b7d_commit-59d6ff1c';
|
|
23
|
+
const AUTHOR = 'sqren';
|
|
27
24
|
describe('backport e2e', () => {
|
|
25
|
+
let accessToken;
|
|
28
26
|
afterAll(() => {
|
|
29
27
|
nock_1.default.cleanAll();
|
|
30
28
|
});
|
|
31
|
-
beforeAll(() => {
|
|
29
|
+
beforeAll(async () => {
|
|
32
30
|
// set alternative homedir
|
|
33
|
-
jest.spyOn(os_1.default, 'homedir').mockReturnValue(
|
|
31
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue(`${sandboxPath}/homedir`);
|
|
32
|
+
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
34
33
|
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
35
34
|
globalConfig: {},
|
|
36
35
|
projectConfig: {},
|
|
@@ -38,23 +37,21 @@ describe('backport e2e', () => {
|
|
|
38
37
|
});
|
|
39
38
|
describe('when a single commit is backported', () => {
|
|
40
39
|
let res;
|
|
41
|
-
let accessToken;
|
|
42
40
|
let createPullRequestsMockCalls;
|
|
43
41
|
beforeAll(async () => {
|
|
44
|
-
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
45
42
|
await resetState(accessToken);
|
|
46
43
|
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
47
44
|
number: 1337,
|
|
48
45
|
html_url: 'myHtmlUrl',
|
|
49
46
|
});
|
|
50
47
|
const options = await (0, options_1.getOptions)([], {
|
|
51
|
-
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
52
|
-
ci: true,
|
|
53
|
-
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
54
|
-
author: AUHTOR,
|
|
55
48
|
accessToken,
|
|
56
|
-
|
|
49
|
+
author: AUTHOR,
|
|
50
|
+
ci: true,
|
|
51
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
57
52
|
repoName: 'integration-test',
|
|
53
|
+
repoOwner: 'backport-org',
|
|
54
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
58
55
|
});
|
|
59
56
|
const commits = await (0, getCommits_1.getCommits)(options);
|
|
60
57
|
const targetBranches = ['7.x'];
|
|
@@ -78,9 +75,11 @@ describe('backport e2e', () => {
|
|
|
78
75
|
"base": "7.x",
|
|
79
76
|
"body": "# Backport
|
|
80
77
|
|
|
81
|
-
This
|
|
78
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
82
79
|
- Add ❤️ emoji (5bf29b7d)
|
|
83
80
|
|
|
81
|
+
<!--- Backport version: 1.2.3 -->
|
|
82
|
+
|
|
84
83
|
### Questions ?
|
|
85
84
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
86
85
|
"head": "sqren:backport/7.x/commit-5bf29b7d",
|
|
@@ -100,107 +99,117 @@ describe('backport e2e', () => {
|
|
|
100
99
|
it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
101
100
|
const branches = await getBranches({
|
|
102
101
|
accessToken,
|
|
103
|
-
repoOwner:
|
|
102
|
+
repoOwner: AUTHOR,
|
|
104
103
|
repoName: REPO_NAME,
|
|
105
104
|
});
|
|
106
105
|
expect(branches.map((b) => b.name)).toEqual([
|
|
107
106
|
'7.x',
|
|
108
|
-
|
|
107
|
+
BRANCH_WITH_ONE_COMMIT,
|
|
109
108
|
'master',
|
|
110
109
|
]);
|
|
111
110
|
});
|
|
112
|
-
|
|
111
|
+
});
|
|
112
|
+
describe('when two commits are backported', () => {
|
|
113
|
+
let createPullRequestsMockCalls;
|
|
114
|
+
let res;
|
|
115
|
+
beforeAll(async () => {
|
|
116
|
+
await resetState(accessToken);
|
|
117
|
+
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
118
|
+
number: 1337,
|
|
119
|
+
html_url: 'myHtmlUrl',
|
|
120
|
+
});
|
|
121
|
+
const options = await (0, options_1.getOptions)([], {
|
|
122
|
+
accessToken,
|
|
123
|
+
author: AUTHOR,
|
|
124
|
+
ci: true,
|
|
125
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
126
|
+
repoName: 'integration-test',
|
|
127
|
+
repoOwner: 'backport-org',
|
|
128
|
+
});
|
|
129
|
+
const commits = [
|
|
130
|
+
...(await (0, getCommits_1.getCommits)({
|
|
131
|
+
...options,
|
|
132
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
133
|
+
})),
|
|
134
|
+
...(await (0, getCommits_1.getCommits)({
|
|
135
|
+
...options,
|
|
136
|
+
sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
|
|
137
|
+
})),
|
|
138
|
+
];
|
|
139
|
+
const targetBranches = ['7.x'];
|
|
140
|
+
res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
|
|
141
|
+
});
|
|
142
|
+
it('contains both commits in the pull request body', () => {
|
|
143
|
+
expect(createPullRequestsMockCalls).toMatchInlineSnapshot(`
|
|
144
|
+
Array [
|
|
145
|
+
Object {
|
|
146
|
+
"base": "7.x",
|
|
147
|
+
"body": "# Backport
|
|
148
|
+
|
|
149
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
150
|
+
- Add ❤️ emoji (5bf29b7d)
|
|
151
|
+
- Add family emoji (#2) (59d6ff1c)
|
|
152
|
+
|
|
153
|
+
<!--- Backport version: 1.2.3 -->
|
|
154
|
+
|
|
155
|
+
### Questions ?
|
|
156
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
157
|
+
"head": "sqren:backport/7.x/commit-5bf29b7d_commit-59d6ff1c",
|
|
158
|
+
"title": "[7.x] Add ❤️ emoji | Add family emoji (#2)",
|
|
159
|
+
},
|
|
160
|
+
]
|
|
161
|
+
`);
|
|
162
|
+
});
|
|
163
|
+
it('returns the pull request response', () => {
|
|
164
|
+
expect(res).toEqual([
|
|
165
|
+
{
|
|
166
|
+
didUpdate: false,
|
|
167
|
+
pullRequestNumber: 1337,
|
|
168
|
+
status: 'success',
|
|
169
|
+
pullRequestUrl: 'myHtmlUrl',
|
|
170
|
+
targetBranch: '7.x',
|
|
171
|
+
},
|
|
172
|
+
]);
|
|
173
|
+
});
|
|
174
|
+
it('should not create new branches in origin (backport-org/integration-test)', async () => {
|
|
113
175
|
const branches = await getBranches({
|
|
114
176
|
accessToken,
|
|
115
|
-
repoOwner:
|
|
177
|
+
repoOwner: REPO_OWNER,
|
|
178
|
+
repoName: REPO_NAME,
|
|
179
|
+
});
|
|
180
|
+
expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
|
|
181
|
+
});
|
|
182
|
+
it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
183
|
+
const branches = await getBranches({
|
|
184
|
+
accessToken,
|
|
185
|
+
repoOwner: AUTHOR,
|
|
116
186
|
repoName: REPO_NAME,
|
|
117
187
|
});
|
|
118
|
-
|
|
119
|
-
|
|
188
|
+
expect(branches.map((b) => b.name)).toEqual([
|
|
189
|
+
'7.x',
|
|
190
|
+
BRANCH_WITH_TWO_COMMITS,
|
|
191
|
+
'master',
|
|
192
|
+
]);
|
|
120
193
|
});
|
|
121
194
|
});
|
|
122
|
-
// describe.skip('when two commits are backported', () => {
|
|
123
|
-
// let createPullRequestsMockCalls: unknown[];
|
|
124
|
-
// let res: Awaited<ReturnType<typeof runSequentially>>;
|
|
125
|
-
// let accessToken: string;
|
|
126
|
-
// beforeAll(async () => {
|
|
127
|
-
// accessToken = await getDevAccessToken();
|
|
128
|
-
// await resetState(accessToken);
|
|
129
|
-
// createPullRequestsMockCalls = mockCreatePullRequest({
|
|
130
|
-
// number: 1337,
|
|
131
|
-
// html_url: 'myHtmlUrl',
|
|
132
|
-
// });
|
|
133
|
-
// const options = {
|
|
134
|
-
// githubApiBaseUrlV3: 'https://api.foo.com',
|
|
135
|
-
// ci: true,
|
|
136
|
-
// sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
137
|
-
// author: AUHTOR,
|
|
138
|
-
// accessToken,
|
|
139
|
-
// repoOwner: 'backport-org',
|
|
140
|
-
// reponame: 'integration-test',
|
|
141
|
-
// } as ValidConfigOptions;
|
|
142
|
-
// const commits = await getCommits(options);
|
|
143
|
-
// const targetBranches: string[] = ['7.x'];
|
|
144
|
-
// res = await runSequentially({ options, commits, targetBranches });
|
|
145
|
-
// });
|
|
146
|
-
// it('sends the correct http body when creating pull request', () => {
|
|
147
|
-
// expect(createPullRequestsMockCalls).toMatchInlineSnapshot();
|
|
148
|
-
// });
|
|
149
|
-
// it('returns pull request', () => {
|
|
150
|
-
// expect(res).toEqual([
|
|
151
|
-
// { pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
|
|
152
|
-
// ]);
|
|
153
|
-
// });
|
|
154
|
-
// it('should not create new branches in origin (backport-org/integration-test)', async () => {
|
|
155
|
-
// const branches = await getBranches({
|
|
156
|
-
// accessToken,
|
|
157
|
-
// repoOwner: REPO_OWNER,
|
|
158
|
-
// repoName: REPO_NAME,
|
|
159
|
-
// });
|
|
160
|
-
// expect(branches.map((b) => b.name)).toEqual(['7.x', '* master']);
|
|
161
|
-
// });
|
|
162
|
-
// it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
163
|
-
// const branches = await getBranches({
|
|
164
|
-
// accessToken,
|
|
165
|
-
// repoOwner: AUHTOR,
|
|
166
|
-
// repoName: REPO_NAME,
|
|
167
|
-
// });
|
|
168
|
-
// expect(branches.map((b) => b.name)).toEqual([
|
|
169
|
-
// '7.x',
|
|
170
|
-
// 'backport/6.0/pr-85_commit-2e63475c',
|
|
171
|
-
// 'master',
|
|
172
|
-
// ]);
|
|
173
|
-
// });
|
|
174
|
-
// it('should have cherry picked the correct commit', async () => {
|
|
175
|
-
// const branches = await getBranches({
|
|
176
|
-
// accessToken,
|
|
177
|
-
// repoOwner: AUHTOR,
|
|
178
|
-
// repoName: REPO_NAME,
|
|
179
|
-
// });
|
|
180
|
-
// const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
181
|
-
// expect(sha).toEqual('foo');
|
|
182
|
-
// });
|
|
183
|
-
// });
|
|
184
195
|
describe('when disabling fork mode', () => {
|
|
185
196
|
let res;
|
|
186
|
-
let accessToken;
|
|
187
197
|
let createPullRequestsMockCalls;
|
|
188
198
|
beforeAll(async () => {
|
|
189
|
-
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
190
199
|
await resetState(accessToken);
|
|
191
200
|
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
192
201
|
number: 1337,
|
|
193
202
|
html_url: 'myHtmlUrl',
|
|
194
203
|
});
|
|
195
204
|
const options = await (0, options_1.getOptions)([], {
|
|
196
|
-
author: AUHTOR,
|
|
197
|
-
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
198
|
-
ci: true,
|
|
199
|
-
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
200
205
|
accessToken,
|
|
201
|
-
|
|
202
|
-
|
|
206
|
+
author: AUTHOR,
|
|
207
|
+
ci: true,
|
|
203
208
|
fork: false,
|
|
209
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
210
|
+
repoName: 'integration-test',
|
|
211
|
+
repoOwner: 'backport-org',
|
|
212
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
204
213
|
});
|
|
205
214
|
const commits = await (0, getCommits_1.getCommits)(options);
|
|
206
215
|
const targetBranches = ['7.x'];
|
|
@@ -213,9 +222,11 @@ describe('backport e2e', () => {
|
|
|
213
222
|
"base": "7.x",
|
|
214
223
|
"body": "# Backport
|
|
215
224
|
|
|
216
|
-
This
|
|
225
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
217
226
|
- Add ❤️ emoji (5bf29b7d)
|
|
218
227
|
|
|
228
|
+
<!--- Backport version: 1.2.3 -->
|
|
229
|
+
|
|
219
230
|
### Questions ?
|
|
220
231
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
221
232
|
"head": "backport-org:backport/7.x/commit-5bf29b7d",
|
|
@@ -243,27 +254,18 @@ describe('backport e2e', () => {
|
|
|
243
254
|
});
|
|
244
255
|
expect(branches.map((b) => b.name)).toEqual([
|
|
245
256
|
'7.x',
|
|
246
|
-
|
|
257
|
+
BRANCH_WITH_ONE_COMMIT,
|
|
247
258
|
'master',
|
|
248
259
|
]);
|
|
249
260
|
});
|
|
250
261
|
it('should NOT create branch in the fork (sqren/integration-test)', async () => {
|
|
251
262
|
const branches = await getBranches({
|
|
252
263
|
accessToken,
|
|
253
|
-
repoOwner:
|
|
264
|
+
repoOwner: AUTHOR,
|
|
254
265
|
repoName: REPO_NAME,
|
|
255
266
|
});
|
|
256
267
|
expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
|
|
257
268
|
});
|
|
258
|
-
it('should cherry pick the correct commit', async () => {
|
|
259
|
-
const branches = await getBranches({
|
|
260
|
-
accessToken,
|
|
261
|
-
repoOwner: REPO_OWNER,
|
|
262
|
-
repoName: REPO_NAME,
|
|
263
|
-
});
|
|
264
|
-
const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
265
|
-
expect(sha).toEqual('b68e4fcaaf4427fe1e902c718b3bb3f07b560fb5');
|
|
266
|
-
});
|
|
267
269
|
});
|
|
268
270
|
});
|
|
269
271
|
function mockCreatePullRequest(response) {
|
|
@@ -309,17 +311,37 @@ async function deleteBranch({ accessToken, repoOwner, repoName, branchName, }) {
|
|
|
309
311
|
}
|
|
310
312
|
}
|
|
311
313
|
async function resetState(accessToken) {
|
|
312
|
-
await
|
|
314
|
+
const ownerBranches = await getBranches({
|
|
313
315
|
accessToken,
|
|
314
316
|
repoOwner: REPO_OWNER,
|
|
315
317
|
repoName: REPO_NAME,
|
|
316
|
-
branchName: BRANCH_NAME,
|
|
317
318
|
});
|
|
318
|
-
|
|
319
|
+
// delete all branches except master and 7.x
|
|
320
|
+
await Promise.all(ownerBranches
|
|
321
|
+
.filter((b) => b.name !== 'master' && b.name !== '7.x')
|
|
322
|
+
.map((b) => {
|
|
323
|
+
return deleteBranch({
|
|
324
|
+
accessToken,
|
|
325
|
+
repoOwner: REPO_OWNER,
|
|
326
|
+
repoName: REPO_NAME,
|
|
327
|
+
branchName: b.name,
|
|
328
|
+
});
|
|
329
|
+
}));
|
|
330
|
+
const forkBranches = await getBranches({
|
|
319
331
|
accessToken,
|
|
320
|
-
repoOwner:
|
|
332
|
+
repoOwner: AUTHOR,
|
|
321
333
|
repoName: REPO_NAME,
|
|
322
|
-
branchName: BRANCH_NAME,
|
|
323
334
|
});
|
|
324
|
-
|
|
335
|
+
// delete all branches except master and 7.x
|
|
336
|
+
await Promise.all(forkBranches
|
|
337
|
+
.filter((b) => b.name !== 'master' && b.name !== '7.x')
|
|
338
|
+
.map((b) => {
|
|
339
|
+
return deleteBranch({
|
|
340
|
+
accessToken,
|
|
341
|
+
repoOwner: AUTHOR,
|
|
342
|
+
repoName: REPO_NAME,
|
|
343
|
+
branchName: b.name,
|
|
344
|
+
});
|
|
345
|
+
}));
|
|
346
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
325
347
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path_1 = require("path");
|
|
4
3
|
const entrypoint_module_1 = require("../entrypoint.module");
|
|
4
|
+
const child_process_promisified_1 = require("../services/child-process-promisified");
|
|
5
5
|
const getDevAccessToken_1 = require("./private/getDevAccessToken");
|
|
6
|
+
const sandbox_1 = require("./sandbox");
|
|
6
7
|
jest.unmock('find-up');
|
|
7
8
|
jest.setTimeout(15000);
|
|
8
9
|
describe('Handle unbackported pull requests', () => {
|
|
@@ -14,30 +15,43 @@ describe('Handle unbackported pull requests', () => {
|
|
|
14
15
|
repoName: 'repo-with-conflicts',
|
|
15
16
|
pullNumber: 8,
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const expectedCommit = {
|
|
19
|
+
sourceCommit: {
|
|
20
|
+
committedDate: '2021-12-16T00:03:34Z',
|
|
21
|
+
message: 'Change Barca to Braithwaite (#8)',
|
|
22
|
+
sha: '343402a748be2375325b2730fa979bcea5b96ba1',
|
|
23
|
+
},
|
|
24
|
+
sourcePullRequest: {
|
|
25
|
+
number: 8,
|
|
26
|
+
url: 'https://github.com/backport-org/repo-with-conflicts/pull/8',
|
|
27
|
+
mergeCommit: {
|
|
28
|
+
message: 'Change Barca to Braithwaite (#8)',
|
|
29
|
+
sha: '343402a748be2375325b2730fa979bcea5b96ba1',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
24
32
|
sourceBranch: 'main',
|
|
25
|
-
|
|
33
|
+
expectedTargetPullRequests: [{ branch: '7.x', state: 'MISSING' }],
|
|
34
|
+
};
|
|
35
|
+
expect(commits[0]).toEqual(expectedCommit);
|
|
26
36
|
});
|
|
27
37
|
it('shows that backport failed because PR number 8 was not backported', async () => {
|
|
28
38
|
const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
39
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
40
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
41
|
+
await (0, child_process_promisified_1.exec)('git init', { cwd: sandboxPath });
|
|
29
42
|
const result = await (0, entrypoint_module_1.backportRun)({
|
|
30
43
|
accessToken: accessToken,
|
|
31
44
|
repoOwner: 'backport-org',
|
|
32
45
|
repoName: 'repo-with-conflicts',
|
|
33
46
|
pullNumber: 12,
|
|
34
47
|
targetBranches: ['7.x'],
|
|
35
|
-
dir:
|
|
48
|
+
dir: sandboxPath,
|
|
36
49
|
ci: true,
|
|
37
50
|
publishStatusComment: false,
|
|
38
51
|
});
|
|
39
|
-
|
|
52
|
+
const commit =
|
|
40
53
|
//@ts-expect-error
|
|
41
|
-
result.results[0].error.
|
|
54
|
+
result.results[0].error.errorContext?.commitsWithoutBackports[0].commit;
|
|
55
|
+
expect(commit.sourcePullRequest?.number).toBe(8);
|
|
42
56
|
});
|
|
43
57
|
});
|
|
@@ -1,29 +1,13 @@
|
|
|
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
6
|
exports.mockConfigFiles = void 0;
|
|
23
|
-
const
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
24
8
|
function mockConfigFiles({ projectConfig, globalConfig, }) {
|
|
25
9
|
jest
|
|
26
|
-
.spyOn(
|
|
10
|
+
.spyOn(promises_1.default, 'readFile')
|
|
27
11
|
//@ts-expect-error
|
|
28
12
|
.mockImplementation(async (filepath) => {
|
|
29
13
|
if (filepath === '/path/to/project/config') {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
export declare function mockOra(): void;
|
|
3
|
+
export declare function getOraMock(): {
|
|
4
|
+
start: () => any;
|
|
5
|
+
succeed: () => jest.Mock<any, any>;
|
|
6
|
+
stop: () => jest.Mock<any, any>;
|
|
7
|
+
fail: () => jest.Mock<any, any>;
|
|
8
|
+
stopAndPersist: () => jest.Mock<any, any>;
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getOraMock = exports.mockOra = void 0;
|
|
5
|
+
const oraMock = {
|
|
6
|
+
start: () => oraMock,
|
|
7
|
+
succeed: () => jest.fn(),
|
|
8
|
+
stop: () => jest.fn(),
|
|
9
|
+
fail: () => jest.fn(),
|
|
10
|
+
stopAndPersist: () => jest.fn(),
|
|
11
|
+
set text(value) { },
|
|
12
|
+
};
|
|
13
|
+
function mockOra() {
|
|
14
|
+
const ora = jest.fn(() => oraMock);
|
|
15
|
+
//@ts-expect-error
|
|
16
|
+
ora.oraMock = oraMock;
|
|
17
|
+
jest.mock('ora', () => ora);
|
|
18
|
+
}
|
|
19
|
+
exports.mockOra = mockOra;
|
|
20
|
+
function getOraMock() {
|
|
21
|
+
return oraMock;
|
|
22
|
+
}
|
|
23
|
+
exports.getOraMock = getOraMock;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
export declare function getDevAccessToken(): string;
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDevAccessToken = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (accessToken) {
|
|
10
|
-
return accessToken;
|
|
11
|
-
}
|
|
12
|
-
// get credentials from config file
|
|
13
|
-
const accessTokenFile = './src/test/private/accessToken.txt';
|
|
14
|
-
try {
|
|
15
|
-
const accessToken = await fs_1.promises.readFile(accessTokenFile, {
|
|
16
|
-
encoding: 'utf-8',
|
|
17
|
-
});
|
|
18
|
-
return accessToken.trim();
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
throw new Error(`Missing accessToken in "${accessTokenFile}"`);
|
|
4
|
+
require("dotenv/config");
|
|
5
|
+
function getDevAccessToken() {
|
|
6
|
+
const accessToken = process.env.ACCESS_TOKEN;
|
|
7
|
+
if (!accessToken) {
|
|
8
|
+
throw new Error('Please create ".env" file containing: `ACCESS_TOKEN="ghp_very_secret"`');
|
|
22
9
|
}
|
|
10
|
+
return accessToken;
|
|
23
11
|
}
|
|
24
12
|
exports.getDevAccessToken = getDevAccessToken;
|
|
@@ -22,24 +22,22 @@ 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
|
-
exports.
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
(0,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"\u00A0Initializing..."));
|
|
25
|
+
exports.resetSandbox = exports.getSandboxPath = void 0;
|
|
26
|
+
const path_1 = __importStar(require("path"));
|
|
27
|
+
const del_1 = __importDefault(require("del"));
|
|
28
|
+
const make_dir_1 = __importDefault(require("make-dir"));
|
|
29
|
+
jest.unmock('make-dir');
|
|
30
|
+
jest.unmock('del');
|
|
31
|
+
function getSandboxPath({ filename, specname, }) {
|
|
32
|
+
const baseFilename = getFilenameWithoutExtension(filename);
|
|
33
|
+
return (0, path_1.resolve)(`${__dirname}/_tmp_sandbox_/${baseFilename}${specname ? `/${specname}` : ''}`);
|
|
34
|
+
}
|
|
35
|
+
exports.getSandboxPath = getSandboxPath;
|
|
36
|
+
async function resetSandbox(sandboxPath) {
|
|
37
|
+
await (0, del_1.default)(sandboxPath);
|
|
38
|
+
await (0, make_dir_1.default)(sandboxPath);
|
|
39
|
+
}
|
|
40
|
+
exports.resetSandbox = resetSandbox;
|
|
41
|
+
function getFilenameWithoutExtension(filename) {
|
|
42
|
+
return path_1.default.basename(filename, path_1.default.extname(filename));
|
|
44
43
|
}
|
|
45
|
-
exports.LoadOptions = LoadOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,27 +3,42 @@
|
|
|
3
3
|
* This file is included in `setupFiles` in jest.config.js
|
|
4
4
|
* It will be run once per test file
|
|
5
5
|
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const packageVersionModule = __importStar(require("../../utils/packageVersion"));
|
|
27
|
+
const mocks_1 = require("../mocks");
|
|
6
28
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
7
29
|
jest.mock('find-up', () => {
|
|
8
30
|
return jest.fn(async () => '/path/to/project/config');
|
|
9
31
|
});
|
|
32
|
+
// @ts-expect-error
|
|
33
|
+
// eslint-disable-next-line no-import-assign
|
|
34
|
+
packageVersionModule.PACKAGE_VERSION = '1.2.3';
|
|
10
35
|
jest.mock('make-dir', () => {
|
|
11
36
|
return jest.fn(() => Promise.resolve('/some/path'));
|
|
12
37
|
});
|
|
13
38
|
jest.mock('del', () => {
|
|
14
39
|
return jest.fn(async (path) => `Attempted to delete ${path}`);
|
|
15
40
|
});
|
|
16
|
-
|
|
17
|
-
const ora = {
|
|
18
|
-
start: () => ({
|
|
19
|
-
succeed: () => { },
|
|
20
|
-
stop: () => { },
|
|
21
|
-
fail: () => { },
|
|
22
|
-
stopAndPersist: () => { },
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
return jest.fn(() => ora);
|
|
26
|
-
});
|
|
41
|
+
(0, mocks_1.mockOra)();
|
|
27
42
|
// silence logger
|
|
28
43
|
jest.mock('../../services/logger', () => {
|
|
29
44
|
const spy = jest.fn();
|
|
@@ -37,6 +52,7 @@ jest.mock('../../services/logger', () => {
|
|
|
37
52
|
info: (msg, meta) => spy(`[INFO] ${msg}`, meta),
|
|
38
53
|
verbose: (msg, meta) => spy(`[VERBOSE] ${msg}`, meta),
|
|
39
54
|
warn: (msg, meta) => spy(`[WARN] ${msg}`, meta),
|
|
55
|
+
error: (msg, meta) => spy(`[ERROR] ${msg}`, meta),
|
|
40
56
|
debug: (msg, meta) => spy(`[DEBUG] ${msg}`, meta),
|
|
41
57
|
},
|
|
42
58
|
};
|