backport 5.6.6 → 6.1.2
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 +186 -50
- package/dist/entrypoint.cli.js +3 -1
- package/dist/entrypoint.module.d.ts +18 -5
- package/dist/entrypoint.module.js +42 -12
- package/dist/entrypoint.module.private.test.d.ts +1 -0
- package/dist/entrypoint.module.private.test.js +34 -0
- package/dist/ink.d.ts +1 -0
- package/dist/ink.js +49 -0
- package/dist/main.d.ts +11 -6
- package/dist/main.js +40 -25
- package/dist/options/ConfigOptions.d.ts +28 -13
- package/dist/options/cliArgs.d.ts +36 -35
- package/dist/options/cliArgs.js +91 -52
- package/dist/options/cliArgs.test.js +35 -43
- package/dist/options/config/config.d.ts +35 -57
- package/dist/options/config/config.js +5 -39
- package/dist/options/config/config.test.js +11 -27
- package/dist/options/config/getOptionsFromGit.d.ts +3 -2
- package/dist/options/config/getOptionsFromGit.js +1 -3
- package/dist/options/config/globalConfig.d.ts +2 -51
- package/dist/options/config/globalConfig.js +9 -12
- package/dist/options/config/globalConfig.test.js +7 -5
- package/dist/options/config/projectConfig.d.ts +2 -51
- package/dist/options/config/projectConfig.js +2 -2
- package/dist/options/config/projectConfig.test.js +53 -16
- package/dist/options/config/readConfigFile.d.ts +44 -41
- package/dist/options/config/readConfigFile.js +30 -4
- package/dist/options/options.d.ts +59 -31
- package/dist/options/options.js +103 -10
- package/dist/options/options.test.js +266 -79
- package/dist/options/parseRequiredOptions.d.ts +19 -14
- package/dist/options/parseRequiredOptions.js +9 -15
- package/dist/options/parseRequiredOptions.test.js +30 -26
- package/dist/runSequentially.d.ts +20 -0
- package/dist/runSequentially.js +41 -0
- package/dist/runSequentially.test.d.ts +1 -0
- package/dist/runSequentially.test.js +196 -0
- package/dist/runWithOptions.js +7 -14
- package/dist/runWithOptions.test.js +138 -17
- package/dist/scripts/generate-gql.d.ts +1 -0
- package/dist/scripts/generate-gql.js +15 -0
- package/dist/scripts/postinstall.js +4 -4
- package/dist/scripts/postinstall.test.js +9 -2
- package/dist/scripts/runPostinstall.js +1 -1
- package/dist/services/HandledError.d.ts +11 -1
- package/dist/services/HandledError.js +2 -1
- package/dist/services/child-process-promisified.d.ts +1 -1
- package/dist/services/child-process-promisified.js +1 -1
- package/dist/services/env.js +5 -5
- package/dist/services/env.test.js +11 -4
- package/dist/services/fs-promisified.js +4 -4
- package/dist/services/getExpectedTarget.d.ts +9 -0
- package/dist/services/getExpectedTarget.js +77 -0
- package/dist/services/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/getExpectedTargetPullRequests.js +77 -0
- package/dist/services/git.d.ts +20 -6
- package/dist/services/git.integration.test.d.ts +1 -0
- package/dist/services/git.integration.test.js +168 -0
- package/dist/services/git.js +93 -67
- package/dist/services/git.test.js +68 -68
- package/dist/services/github/commitFormatters.d.ts +3 -7
- package/dist/services/github/commitFormatters.js +10 -19
- package/dist/services/github/commitFormatters.test.js +2 -24
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -8
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +6 -8
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +2 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/services/github/v3/addReviewersToPullRequest.js +34 -0
- package/dist/services/github/v3/createPullRequest.d.ts +3 -2
- package/dist/services/github/v3/createPullRequest.js +31 -25
- package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/services/github/v3/createPullRequest.test.js +110 -0
- package/dist/services/github/v3/createStatusComment.d.ts +11 -0
- package/dist/services/github/v3/createStatusComment.js +95 -0
- package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/services/github/v3/createStatusComment.test.js +209 -0
- package/dist/services/github/v4/FetchPullRequestId.js +1 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +2 -2
- package/dist/services/github/v4/apiRequestV4.js +6 -8
- package/dist/services/github/v4/apiRequestV4.test.js +7 -7
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +3 -4
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +9 -8
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +93 -33
- package/dist/services/github/v4/fetchAuthorId.d.ts +5 -2
- package/dist/services/github/v4/fetchAuthorId.js +6 -7
- package/dist/services/github/v4/fetchAuthorId.private.test.js +6 -9
- package/dist/services/github/v4/fetchCommitByPullNumber.js +11 -9
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommitBySha.js +14 -12
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +12 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +46 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +70 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +12 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +36 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +27 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +88 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +128 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +125 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +28 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +52 -0
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +3 -0
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +10 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +49 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +77 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +252 -0
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +2 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +78 -5
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
- package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
- package/dist/services/github/v4/fetchExistingPullRequest.js +2 -3
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -5
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +18 -19
- package/dist/services/github/v4/fetchMergedPullRequests.js +22 -69
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +8 -9
- package/dist/services/github/v4/fetchProjectConfig.d.ts +8 -0
- package/dist/services/github/v4/fetchProjectConfig.js +56 -0
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +1 -0
- package/dist/services/github/v4/fetchProjectConfig.test.js +37 -0
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +2 -3
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +3 -3
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +2 -2
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +4 -58
- package/dist/services/github/v4/getExistingTargetPullRequests.js +3 -58
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +67 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +130 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +130 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +19 -11
- package/dist/services/github/v4/getOptionsFromGithub/index.js +52 -22
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +46 -7
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +16 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +16 -15
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -7
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +1 -26
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +69 -32
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +39 -25
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +2 -0
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +1 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -15
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +7 -7
- package/dist/services/logger.d.ts +3 -3
- package/dist/services/logger.js +16 -15
- package/dist/services/prompt.test.d.ts +1 -0
- package/dist/services/prompt.test.js +87 -0
- package/dist/services/prompts.d.ts +10 -4
- package/dist/services/prompts.js +85 -22
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +92 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +413 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +21 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +67 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +5 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +20 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +201 -0
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +82 -0
- package/dist/services/sourceCommit/parseSourceCommit.js +96 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.js +229 -0
- package/dist/services/sourceCommit/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit/sourceCommit.js +86 -0
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/sourceCommit.test.js +287 -0
- package/dist/services/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit.js +86 -0
- package/dist/services/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit.test.js +280 -0
- package/dist/test/inquirer.private.test.js +55 -51
- package/dist/test/integration/createSpies.js +6 -6
- package/dist/test/integration/envConstants.js +5 -6
- package/dist/test/integration/helpers.js +1 -1
- package/dist/test/integration/integration.private.test.d.ts +1 -0
- package/dist/test/integration/integration.private.test.js +327 -0
- package/dist/test/integration/integration.test.js +28 -29
- package/dist/test/mockConfigFiles.d.ts +5 -0
- package/dist/test/mockConfigFiles.js +37 -0
- package/dist/test/nockHelpers.d.ts +1 -1
- package/dist/test/nockHelpers.js +7 -11
- package/dist/test/private/getDevAccessToken.js +1 -1
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
- package/dist/test/setupFiles/automatic-mocks.js +1 -51
- package/dist/types/Commit.d.ts +85 -0
- package/dist/types/Commit.js +139 -0
- package/dist/types/commitNode.d.ts +89 -0
- package/dist/types/commitNode.js +139 -0
- package/dist/types/commitNode.test.d.ts +1 -0
- package/dist/types/commitNode.test.js +255 -0
- package/dist/types/commitWithAssociatedPullRequests.d.ts +86 -0
- package/dist/types/commitWithAssociatedPullRequests.js +145 -0
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +346 -76
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +2 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +95 -67
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +468 -0
- package/dist/ui/getCommits.d.ts +1 -1
- package/dist/ui/getCommits.js +55 -25
- package/dist/ui/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/ui/getCommitsWithoutBackports.js +53 -0
- package/dist/ui/getTargetBranches.d.ts +3 -2
- package/dist/ui/getTargetBranches.js +33 -18
- package/dist/ui/getTargetBranches.test.js +75 -99
- package/dist/ui/getTargetBranchesFromLabels.d.ts +6 -0
- package/dist/ui/getTargetBranchesFromLabels.js +40 -0
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/ui/getTargetBranchesFromLabels.test.js +288 -0
- package/dist/ui/maybeSetupRepo.js +11 -10
- package/dist/ui/maybeSetupRepo.test.js +54 -4
- package/dist/utils/excludeUndefined.d.ts +6 -0
- package/dist/utils/excludeUndefined.js +7 -0
- package/dist/utils/excludeUndefined.test.d.ts +1 -0
- package/dist/utils/excludeUndefined.test.js +24 -0
- package/package.json +37 -51
- package/yarn.lock +2414 -2993
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import { Logger } from '../services/logger';
|
|
2
|
-
export interface
|
|
2
|
+
export interface TargetBranchChoice {
|
|
3
3
|
name: string;
|
|
4
4
|
checked?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare type
|
|
6
|
+
export declare type TargetBranchChoiceOrString = string | TargetBranchChoice;
|
|
7
7
|
declare type AutoFixConflictsHandler = ({ files, directory, logger, targetBranch, }: {
|
|
8
8
|
files: string[];
|
|
9
9
|
directory: string;
|
|
10
10
|
logger: Logger;
|
|
11
11
|
targetBranch: string;
|
|
12
12
|
}) => boolean | Promise<boolean>;
|
|
13
|
-
|
|
13
|
+
declare type Options = Partial<{
|
|
14
14
|
accessToken: string;
|
|
15
|
-
all: boolean;
|
|
16
15
|
assignees: string[];
|
|
17
|
-
author: string;
|
|
16
|
+
author: string | null;
|
|
18
17
|
autoAssign: boolean;
|
|
18
|
+
autoFixConflicts: AutoFixConflictsHandler;
|
|
19
19
|
autoMerge: boolean;
|
|
20
20
|
autoMergeMethod: string;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
backportBinary: string;
|
|
22
|
+
cherrypickRef: boolean;
|
|
23
23
|
ci: boolean;
|
|
24
|
+
commitPaths: string[];
|
|
25
|
+
details: boolean;
|
|
24
26
|
editor: string;
|
|
25
|
-
forceLocalConfig: boolean;
|
|
26
27
|
fork: boolean;
|
|
27
28
|
gitHostname: string;
|
|
28
29
|
githubApiBaseUrlV3: string;
|
|
@@ -32,22 +33,36 @@ export declare type ConfigOptions = Partial<{
|
|
|
32
33
|
multipleBranches: boolean;
|
|
33
34
|
multipleCommits: boolean;
|
|
34
35
|
noVerify: boolean;
|
|
35
|
-
path: string;
|
|
36
36
|
prDescription: string;
|
|
37
37
|
prFilter: string;
|
|
38
38
|
prTitle: string;
|
|
39
39
|
pullNumber: number;
|
|
40
|
+
repoName: string;
|
|
41
|
+
repoOwner: string;
|
|
40
42
|
resetAuthor: boolean;
|
|
43
|
+
reviewers: string[];
|
|
41
44
|
sha: string;
|
|
45
|
+
skipRemoteConfig: boolean;
|
|
42
46
|
sourceBranch: string;
|
|
43
47
|
sourcePRLabels: string[];
|
|
44
|
-
targetBranchChoices:
|
|
48
|
+
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
45
49
|
targetBranches: string[];
|
|
46
50
|
targetPRLabels: string[];
|
|
47
|
-
upstream: string;
|
|
48
|
-
username: string;
|
|
49
51
|
verbose: boolean;
|
|
50
|
-
|
|
52
|
+
}>;
|
|
53
|
+
export declare type ConfigFileOptions = Options & Partial<{
|
|
54
|
+
branchLabelMapping: Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Replaced by `repoOwner` and `repoName`
|
|
57
|
+
*/
|
|
58
|
+
upstream: string;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Replaced by `targetBranchChoices`
|
|
61
|
+
*/
|
|
62
|
+
branches: TargetBranchChoiceOrString[];
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated Replaced by `targetPRLabels`
|
|
65
|
+
*/
|
|
51
66
|
labels: string[];
|
|
52
67
|
}>;
|
|
53
68
|
export {};
|
|
@@ -2,39 +2,40 @@ export declare type OptionsFromCliArgs = ReturnType<typeof getOptionsFromCliArgs
|
|
|
2
2
|
export declare function getOptionsFromCliArgs(argv: readonly string[], { exitOnError }?: {
|
|
3
3
|
exitOnError?: boolean;
|
|
4
4
|
}): {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
editor
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
5
|
+
fork?: boolean | undefined;
|
|
6
|
+
verbose?: boolean | undefined;
|
|
7
|
+
accessToken?: string | undefined;
|
|
8
|
+
assignees?: string[] | undefined;
|
|
9
|
+
author?: string | null | undefined;
|
|
10
|
+
autoAssign?: boolean | undefined;
|
|
11
|
+
autoMerge?: boolean | undefined;
|
|
12
|
+
autoMergeMethod?: string | undefined;
|
|
13
|
+
cherrypickRef?: boolean | undefined;
|
|
14
|
+
ci?: boolean | undefined;
|
|
15
|
+
commitPaths?: string[] | undefined;
|
|
16
|
+
details?: boolean | undefined;
|
|
17
|
+
editor?: string | undefined;
|
|
18
|
+
gitHostname?: string | undefined;
|
|
19
|
+
githubApiBaseUrlV3?: string | undefined;
|
|
20
|
+
githubApiBaseUrlV4?: string | undefined;
|
|
21
|
+
maxNumber?: number | undefined;
|
|
22
|
+
multipleBranches?: boolean | undefined;
|
|
23
|
+
multipleCommits?: boolean | undefined;
|
|
24
|
+
noVerify?: boolean | undefined;
|
|
25
|
+
prDescription?: string | undefined;
|
|
26
|
+
prFilter?: string | undefined;
|
|
27
|
+
prTitle?: string | undefined;
|
|
28
|
+
pullNumber?: number | undefined;
|
|
29
|
+
repoName?: string | undefined;
|
|
30
|
+
repoOwner?: string | undefined;
|
|
31
|
+
resetAuthor?: boolean | undefined;
|
|
32
|
+
reviewers?: string[] | undefined;
|
|
33
|
+
sha?: string | undefined;
|
|
34
|
+
skipRemoteConfig?: boolean | undefined;
|
|
35
|
+
sourceBranch?: string | undefined;
|
|
36
|
+
sourcePRLabels?: string[] | undefined;
|
|
37
|
+
targetBranchChoices?: string[] | undefined;
|
|
38
|
+
targetBranches?: string[] | undefined;
|
|
39
|
+
targetPRLabels?: string[] | undefined;
|
|
40
|
+
mainline?: number | undefined;
|
|
40
41
|
};
|
package/dist/options/cliArgs.js
CHANGED
|
@@ -5,8 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getOptionsFromCliArgs = void 0;
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const excludeUndefined_1 = require("../utils/excludeUndefined");
|
|
8
9
|
function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
9
|
-
const yargsInstance = yargs_1.default(argv)
|
|
10
|
+
const yargsInstance = (0, yargs_1.default)(argv)
|
|
10
11
|
.parserConfiguration({
|
|
11
12
|
'strip-dashed': true,
|
|
12
13
|
'strip-aliased': true,
|
|
@@ -24,14 +25,11 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
24
25
|
description: 'List all commits',
|
|
25
26
|
alias: 'a',
|
|
26
27
|
type: 'boolean',
|
|
28
|
+
conflicts: 'author',
|
|
27
29
|
})
|
|
28
|
-
.option('
|
|
29
|
-
description: 'Show commits by specific author',
|
|
30
|
-
type: 'string',
|
|
31
|
-
})
|
|
32
|
-
.option('assignees', {
|
|
30
|
+
.option('assignee', {
|
|
33
31
|
description: 'Add assignees to the target pull request',
|
|
34
|
-
alias:
|
|
32
|
+
alias: 'assign',
|
|
35
33
|
type: 'array',
|
|
36
34
|
string: true,
|
|
37
35
|
conflicts: ['autoAssign'],
|
|
@@ -54,22 +52,28 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
54
52
|
description: 'Disable interactive prompts',
|
|
55
53
|
type: 'boolean',
|
|
56
54
|
})
|
|
57
|
-
.option('
|
|
58
|
-
description: '
|
|
55
|
+
.option('cherrypickRef', {
|
|
56
|
+
description: 'Append commit message with "(cherry picked from commit...)',
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
conflicts: ['noCherrypickRef'],
|
|
59
|
+
})
|
|
60
|
+
.option('details', {
|
|
61
|
+
description: 'Show details about each commit',
|
|
59
62
|
type: 'boolean',
|
|
60
63
|
})
|
|
61
64
|
.option('editor', {
|
|
62
65
|
description: 'Editor to be opened during conflict resolution',
|
|
63
66
|
type: 'string',
|
|
64
67
|
})
|
|
65
|
-
.option('
|
|
68
|
+
.option('skipRemoteConfig', {
|
|
66
69
|
description: 'Use local .backportrc.json config instead of loading from Github',
|
|
67
70
|
type: 'boolean',
|
|
68
71
|
})
|
|
69
|
-
// push target branch to {
|
|
72
|
+
// push target branch to {authenticatedUsername}/{repoName}
|
|
70
73
|
.option('fork', {
|
|
71
74
|
description: 'Create backports in fork or origin repo',
|
|
72
75
|
type: 'boolean',
|
|
76
|
+
conflicts: ['noFork'],
|
|
73
77
|
})
|
|
74
78
|
.option('gitHostname', {
|
|
75
79
|
hidden: true,
|
|
@@ -90,9 +94,10 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
90
94
|
description: 'Parent id of merge commit. Defaults to 1 when supplied without arguments',
|
|
91
95
|
type: 'number',
|
|
92
96
|
coerce: (mainline) => {
|
|
93
|
-
// `--mainline` (default to 1 when no parent is given)
|
|
94
97
|
if (mainline === undefined) {
|
|
95
|
-
return 1
|
|
98
|
+
// return 1 if `--mainline` is given without a value
|
|
99
|
+
// return undefined if --mainline is not supplied at all
|
|
100
|
+
return argv.includes('--mainline') ? 1 : undefined;
|
|
96
101
|
}
|
|
97
102
|
// use specified mainline parent
|
|
98
103
|
if (Number.isInteger(mainline)) {
|
|
@@ -125,25 +130,36 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
125
130
|
description: 'Backport multiple commits',
|
|
126
131
|
type: 'boolean',
|
|
127
132
|
conflicts: ['multiple'],
|
|
133
|
+
})
|
|
134
|
+
.option('noCherrypickRef', {
|
|
135
|
+
description: 'Do not append commit message with "(cherry picked from commit...)"',
|
|
136
|
+
type: 'boolean',
|
|
137
|
+
conflicts: ['cherrypickRef'],
|
|
128
138
|
})
|
|
129
139
|
.option('noVerify', {
|
|
130
|
-
description: '
|
|
140
|
+
description: 'Bypass the pre-commit and commit-msg hooks',
|
|
141
|
+
type: 'boolean',
|
|
142
|
+
})
|
|
143
|
+
.option('noFork', {
|
|
144
|
+
description: 'Create backports in the origin repo',
|
|
131
145
|
type: 'boolean',
|
|
146
|
+
conflicts: ['fork'],
|
|
132
147
|
})
|
|
133
148
|
.option('path', {
|
|
134
149
|
description: 'Only list commits touching files under the specified path',
|
|
135
150
|
alias: 'p',
|
|
151
|
+
type: 'array',
|
|
152
|
+
string: true,
|
|
153
|
+
})
|
|
154
|
+
.option('prDescription', {
|
|
155
|
+
description: 'Description to be added to pull request',
|
|
156
|
+
alias: 'description',
|
|
136
157
|
type: 'string',
|
|
137
158
|
})
|
|
138
159
|
.option('prTitle', {
|
|
139
160
|
description: 'Title of pull request',
|
|
140
161
|
alias: 'title',
|
|
141
162
|
type: 'string',
|
|
142
|
-
})
|
|
143
|
-
.option('prDescription', {
|
|
144
|
-
description: 'Description to be added to pull request',
|
|
145
|
-
alias: 'description',
|
|
146
|
-
type: 'string',
|
|
147
163
|
})
|
|
148
164
|
.option('prFilter', {
|
|
149
165
|
conflicts: ['pullNumber', 'sha'],
|
|
@@ -159,6 +175,19 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
159
175
|
.option('resetAuthor', {
|
|
160
176
|
description: 'Set yourself as commit author',
|
|
161
177
|
type: 'boolean',
|
|
178
|
+
})
|
|
179
|
+
.option('reviewer', {
|
|
180
|
+
description: 'Add reviewer to the target PR',
|
|
181
|
+
type: 'array',
|
|
182
|
+
string: true,
|
|
183
|
+
})
|
|
184
|
+
.option('repoOwner', {
|
|
185
|
+
description: 'Repository owner',
|
|
186
|
+
type: 'string',
|
|
187
|
+
})
|
|
188
|
+
.option('repoName', {
|
|
189
|
+
description: 'Repository name',
|
|
190
|
+
type: 'string',
|
|
162
191
|
})
|
|
163
192
|
.option('sha', {
|
|
164
193
|
conflicts: ['pullNumber', 'prFilter'],
|
|
@@ -170,47 +199,43 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
170
199
|
description: `Specify a non-default branch (normally "master") to backport from`,
|
|
171
200
|
type: 'string',
|
|
172
201
|
})
|
|
173
|
-
.option('
|
|
202
|
+
.option('sourcePRLabel', {
|
|
174
203
|
description: 'Add labels to the source (original) PR',
|
|
175
|
-
alias:
|
|
204
|
+
alias: 'sourcePrLabel',
|
|
176
205
|
type: 'array',
|
|
177
206
|
string: true,
|
|
178
207
|
})
|
|
179
|
-
.option('
|
|
208
|
+
.option('targetBranch', {
|
|
180
209
|
description: 'Branch(es) to backport to',
|
|
181
|
-
alias: ['
|
|
210
|
+
alias: ['branch', 'b'],
|
|
182
211
|
type: 'array',
|
|
183
|
-
string: true,
|
|
212
|
+
string: true, // ensure `6.0` is not coerced to `6`
|
|
184
213
|
})
|
|
185
|
-
.option('
|
|
214
|
+
.option('targetBranchChoice', {
|
|
186
215
|
description: 'List branches to backport to',
|
|
187
|
-
alias: 'targetBranchChoice',
|
|
188
216
|
type: 'array',
|
|
189
217
|
string: true,
|
|
190
218
|
})
|
|
191
|
-
.option('
|
|
219
|
+
.option('targetPRLabel', {
|
|
192
220
|
description: 'Add labels to the target (backport) PR',
|
|
193
|
-
alias: ['
|
|
221
|
+
alias: ['label', 'l'],
|
|
194
222
|
type: 'array',
|
|
195
223
|
string: true,
|
|
196
224
|
})
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
type: 'boolean',
|
|
201
|
-
})
|
|
202
|
-
.option('upstream', {
|
|
203
|
-
description: 'Name of repository',
|
|
204
|
-
alias: 'up',
|
|
205
|
-
type: 'string',
|
|
206
|
-
})
|
|
207
|
-
.option('username', {
|
|
208
|
-
description: 'Github username',
|
|
225
|
+
.option('author', {
|
|
226
|
+
description: 'Show commits by a specific user',
|
|
227
|
+
alias: 'author',
|
|
209
228
|
type: 'string',
|
|
229
|
+
conflicts: 'all',
|
|
210
230
|
})
|
|
211
231
|
.option('verbose', {
|
|
212
232
|
description: 'Show additional debug information',
|
|
213
233
|
type: 'boolean',
|
|
234
|
+
})
|
|
235
|
+
// cli-only
|
|
236
|
+
.option('verify', {
|
|
237
|
+
description: `Opposite of no-verify`,
|
|
238
|
+
type: 'boolean',
|
|
214
239
|
})
|
|
215
240
|
.alias('version', 'v')
|
|
216
241
|
.alias('version', 'V')
|
|
@@ -227,19 +252,33 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
227
252
|
throw new Error(msg);
|
|
228
253
|
});
|
|
229
254
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
255
|
+
const {
|
|
256
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
257
|
+
$0, _,
|
|
258
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
259
|
+
multiple, multipleBranches, multipleCommits, all, author,
|
|
260
|
+
// negations
|
|
261
|
+
verify, noVerify, noCherrypickRef, noFork,
|
|
262
|
+
// array types (should be renamed to plural form)
|
|
263
|
+
assignee, path, reviewer, sourcePRLabel, targetBranch, targetBranchChoice, targetPRLabel, ...restOptions } = yargsInstance.parseSync();
|
|
264
|
+
return (0, excludeUndefined_1.excludeUndefined)({
|
|
265
|
+
...restOptions,
|
|
266
|
+
author: all ? null : author,
|
|
234
267
|
// `multiple` is a cli-only flag to override `multipleBranches` and `multipleCommits`
|
|
235
|
-
multipleBranches: multiple
|
|
236
|
-
multipleCommits: multiple
|
|
237
|
-
//
|
|
238
|
-
|
|
268
|
+
multipleBranches: multiple ?? multipleBranches,
|
|
269
|
+
multipleCommits: multiple ?? multipleCommits,
|
|
270
|
+
// rename array types to plural
|
|
271
|
+
assignees: assignee,
|
|
272
|
+
commitPaths: path,
|
|
273
|
+
reviewers: reviewer,
|
|
274
|
+
sourcePRLabels: sourcePRLabel,
|
|
275
|
+
targetBranchChoices: targetBranchChoice,
|
|
276
|
+
targetBranches: targetBranch,
|
|
277
|
+
targetPRLabels: targetPRLabel,
|
|
278
|
+
// negations (cli-only flags)
|
|
279
|
+
cherrypickRef: noCherrypickRef === true ? false : restOptions.cherrypickRef,
|
|
280
|
+
fork: noFork === true ? false : restOptions.fork,
|
|
281
|
+
noVerify: verify ?? noVerify,
|
|
239
282
|
});
|
|
240
283
|
}
|
|
241
284
|
exports.getOptionsFromCliArgs = getOptionsFromCliArgs;
|
|
242
|
-
function excludeUndefined(obj) {
|
|
243
|
-
Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]);
|
|
244
|
-
return obj;
|
|
245
|
-
}
|
|
@@ -10,7 +10,7 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
10
10
|
'--githubApiBaseUrlV3',
|
|
11
11
|
'my api hostname',
|
|
12
12
|
];
|
|
13
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
13
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
14
14
|
expect(res.accessToken).toEqual('my access token');
|
|
15
15
|
expect('access-token' in res).toEqual(false);
|
|
16
16
|
expect(res.githubApiBaseUrlV3).toEqual('my api hostname');
|
|
@@ -20,16 +20,16 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
20
20
|
const argv = [
|
|
21
21
|
'--access-token',
|
|
22
22
|
'my access token',
|
|
23
|
-
'--
|
|
24
|
-
'
|
|
25
|
-
'--
|
|
26
|
-
'
|
|
23
|
+
'--repo-owner',
|
|
24
|
+
'elastic',
|
|
25
|
+
'--repo-name',
|
|
26
|
+
'kibana',
|
|
27
27
|
];
|
|
28
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
28
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
29
29
|
expect(res).toEqual({
|
|
30
30
|
accessToken: 'my access token',
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
repoOwner: 'elastic',
|
|
32
|
+
repoName: 'kibana',
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
});
|
|
@@ -46,114 +46,106 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
46
46
|
describe('sourcePRLabels', () => {
|
|
47
47
|
it('should handle all variations', () => {
|
|
48
48
|
const argv = [
|
|
49
|
-
'--sourcePRLabels',
|
|
50
|
-
'label a',
|
|
51
|
-
'--sourcePrLabels',
|
|
52
|
-
'label b',
|
|
53
|
-
'--source-pr-labels',
|
|
54
|
-
'label c',
|
|
55
49
|
'--sourcePRLabel',
|
|
56
|
-
'label d',
|
|
57
|
-
'--sourcePrLabel',
|
|
58
|
-
'label e',
|
|
59
|
-
'--source-pr-label',
|
|
60
|
-
'label f',
|
|
61
|
-
];
|
|
62
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
63
|
-
expect(res.sourcePRLabels).toEqual([
|
|
64
50
|
'label a',
|
|
51
|
+
'--sourcePrLabel',
|
|
65
52
|
'label b',
|
|
53
|
+
'--source-pr-label',
|
|
66
54
|
'label c',
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
]);
|
|
55
|
+
];
|
|
56
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
57
|
+
expect(res.sourcePRLabels).toEqual(['label a', 'label b', 'label c']);
|
|
71
58
|
});
|
|
72
59
|
});
|
|
73
60
|
describe('pullNumber', () => {
|
|
74
61
|
it('should accept `--pr` alias but only return the full representation (`pullNumber`)', () => {
|
|
75
62
|
const argv = ['--pr', '1337'];
|
|
76
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
63
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
77
64
|
expect(res.pullNumber).toEqual(1337);
|
|
78
65
|
//@ts-expect-error
|
|
79
66
|
expect(res.pr).toBe(undefined);
|
|
80
67
|
});
|
|
81
68
|
});
|
|
82
69
|
describe('assignees', () => {
|
|
83
|
-
it('
|
|
84
|
-
const argv = ['--
|
|
85
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
70
|
+
it('--assignee', () => {
|
|
71
|
+
const argv = ['--assignee', 'john'];
|
|
72
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
73
|
+
expect(res.assignees).toEqual(['john']);
|
|
74
|
+
});
|
|
75
|
+
it('--assign', () => {
|
|
76
|
+
const argv = ['--assign', 'john'];
|
|
77
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
86
78
|
expect(res.assignees).toEqual(['john']);
|
|
87
79
|
});
|
|
88
80
|
});
|
|
89
81
|
describe('multipleBranches', () => {
|
|
90
82
|
it('should be undefined by default', () => {
|
|
91
83
|
const argv = [];
|
|
92
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
84
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
93
85
|
expect(res.multipleBranches).toBe(undefined);
|
|
94
86
|
});
|
|
95
87
|
it('should set to true', () => {
|
|
96
88
|
const argv = ['--multiple-branches', 'true'];
|
|
97
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
89
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
98
90
|
expect(res.multipleBranches).toBe(true);
|
|
99
91
|
});
|
|
100
92
|
it('should set to false', () => {
|
|
101
93
|
const argv = ['--multiple-branches', 'false'];
|
|
102
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
94
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
103
95
|
expect(res.multipleBranches).toBe(false);
|
|
104
96
|
});
|
|
105
97
|
it('should respect `multiple` option', () => {
|
|
106
98
|
const argv = ['--multiple'];
|
|
107
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
99
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
108
100
|
expect(res.multipleBranches).toBe(true);
|
|
109
101
|
});
|
|
110
102
|
it('should conflict when using both', () => {
|
|
111
103
|
const argv = ['--multiple', '--multiple-branches', 'false'];
|
|
112
|
-
expect(() => cliArgs_1.getOptionsFromCliArgs(argv, { exitOnError: false })).toThrow('Arguments multiple and multipleBranches are mutually exclusive');
|
|
104
|
+
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv, { exitOnError: false })).toThrow('Arguments multiple and multipleBranches are mutually exclusive');
|
|
113
105
|
});
|
|
114
106
|
});
|
|
115
107
|
describe('noVerify', () => {
|
|
116
108
|
it('should be undefined by default', () => {
|
|
117
109
|
const argv = [];
|
|
118
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
110
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
119
111
|
expect(res.noVerify).toBe(undefined);
|
|
120
112
|
});
|
|
121
113
|
it('should set to false', () => {
|
|
122
114
|
const argv = ['--no-verify', 'false'];
|
|
123
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
115
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
124
116
|
expect(res.noVerify).toBe(false);
|
|
125
117
|
});
|
|
126
118
|
it('should set to true', () => {
|
|
127
119
|
const argv = ['--no-verify', 'true'];
|
|
128
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
120
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
129
121
|
expect(res.noVerify).toBe(true);
|
|
130
122
|
});
|
|
131
123
|
it('should be enabled by `verify`', () => {
|
|
132
124
|
const argv = ['--verify'];
|
|
133
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
125
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
134
126
|
expect(res.noVerify).toBe(true);
|
|
135
127
|
});
|
|
136
128
|
});
|
|
137
129
|
describe('mainline', () => {
|
|
138
130
|
it('should default to 1', () => {
|
|
139
131
|
const argv = ['--mainline'];
|
|
140
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
132
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
141
133
|
expect(res.mainline).toEqual(1);
|
|
142
134
|
});
|
|
143
135
|
it('should accept numbers', () => {
|
|
144
136
|
const argv = ['--mainline', '2'];
|
|
145
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
137
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
146
138
|
expect(res.mainline).toEqual(2);
|
|
147
139
|
});
|
|
148
140
|
it('should throw on invalid values', () => {
|
|
149
141
|
const argv = ['--mainline', 'foo'];
|
|
150
|
-
expect(() => cliArgs_1.getOptionsFromCliArgs(argv, { exitOnError: false })).toThrowError('--mainline must be an integer. Received: NaN');
|
|
142
|
+
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv, { exitOnError: false })).toThrowError('--mainline must be an integer. Received: NaN');
|
|
151
143
|
});
|
|
152
144
|
});
|
|
153
145
|
describe('targetBranches', () => {
|
|
154
146
|
it('should not coerce 6.0 to 6', () => {
|
|
155
147
|
const argv = ['-b', '6.0'];
|
|
156
|
-
const res = cliArgs_1.getOptionsFromCliArgs(argv);
|
|
148
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
157
149
|
expect(res.targetBranches).toEqual(['6.0']);
|
|
158
150
|
});
|
|
159
151
|
});
|