backport 5.6.4 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -41
- 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 +33 -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 +56 -39
- package/dist/options/cliArgs.d.ts +38 -45
- package/dist/options/cliArgs.js +123 -104
- package/dist/options/cliArgs.test.js +106 -119
- package/dist/options/config/config.d.ts +56 -2
- package/dist/options/config/config.js +12 -6
- package/dist/options/config/config.test.js +11 -6
- package/dist/options/config/getOptionsFromGit.d.ts +4 -0
- package/dist/options/config/getOptionsFromGit.js +8 -0
- package/dist/options/config/globalConfig.d.ts +2 -1
- 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 -1
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +54 -17
- package/dist/options/config/readConfigFile.d.ts +53 -2
- package/dist/options/config/readConfigFile.js +31 -5
- package/dist/options/options.d.ts +67 -35
- package/dist/options/options.js +99 -16
- package/dist/options/options.test.js +214 -67
- package/dist/options/parseRequiredOptions.d.ts +71 -0
- package/dist/options/parseRequiredOptions.js +68 -0
- package/dist/options/parseRequiredOptions.test.d.ts +1 -0
- package/dist/options/parseRequiredOptions.test.js +122 -0
- 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 +192 -0
- package/dist/runWithOptions.js +7 -14
- package/dist/runWithOptions.test.js +142 -16
- 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 +2 -2
- 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 +23 -5
- package/dist/services/git.integration.test.d.ts +1 -0
- package/dist/services/git.integration.test.js +168 -0
- package/dist/services/git.js +133 -60
- package/dist/services/git.test.js +160 -53
- 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 +32 -26
- package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/services/github/v3/createPullRequest.test.js +78 -0
- package/dist/services/github/v3/createStatusComment.d.ts +11 -0
- package/dist/services/github/v3/createStatusComment.js +97 -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.d.ts +9 -0
- package/dist/services/github/v4/FetchPullRequestId.js +32 -0
- package/dist/services/github/v4/apiRequestV4.d.ts +2 -2
- package/dist/services/github/v4/apiRequestV4.js +9 -11
- package/dist/services/github/v4/apiRequestV4.test.js +7 -7
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +9 -0
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +28 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +9 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +51 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/services/github/v4/fetchAuthorId.d.ts +10 -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 +6 -6
- package/dist/services/github/v4/fetchCommitBySha.js +14 -12
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +7 -5
- 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 +3 -2
- package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +81 -8
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +1 -1
- package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +4 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +52 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +32 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +4 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +72 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +34 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +40 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +72 -0
- 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 +19 -20
- package/dist/services/github/v4/fetchMergedPullRequests.js +22 -68
- 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.d.ts +11 -0
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +35 -0
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +1 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +8 -6
- 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 +66 -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 +63 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.js +139 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +147 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +37 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.js +47 -0
- 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 +2 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +4 -1
- 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.d.ts +1 -1
- 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 +24 -24
- 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 +396 -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 +105 -61
- package/dist/test/integration/createSpies.d.ts +1 -1
- package/dist/test/integration/createSpies.js +21 -9
- 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 +317 -0
- package/dist/test/integration/integration.test.js +30 -31
- package/dist/test/mockConfigFiles.d.ts +5 -0
- package/dist/test/mockConfigFiles.js +37 -0
- package/dist/test/nockHelpers.d.ts +3 -3
- 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 +333 -76
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +11 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +138 -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/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 +2416 -2987
|
@@ -1,2 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function readConfigFile(filepath: string): Promise<
|
|
1
|
+
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
+
export declare function readConfigFile(filepath: string): Promise<ConfigFileOptions>;
|
|
3
|
+
export declare function withConfigMigrations({ upstream, labels, branches, ...config }: ConfigFileOptions): {
|
|
4
|
+
fork?: boolean | undefined;
|
|
5
|
+
verbose?: boolean | undefined;
|
|
6
|
+
accessToken?: string | undefined;
|
|
7
|
+
assignees?: string[] | undefined;
|
|
8
|
+
author?: string | null | undefined;
|
|
9
|
+
autoAssign?: boolean | undefined;
|
|
10
|
+
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
11
|
+
files: string[];
|
|
12
|
+
directory: string;
|
|
13
|
+
logger: {
|
|
14
|
+
error: (message: string, meta?: unknown) => void;
|
|
15
|
+
warn: (message: string, meta?: unknown) => void;
|
|
16
|
+
info: (message: string, meta?: unknown) => void;
|
|
17
|
+
verbose: (message: string, meta?: unknown) => void;
|
|
18
|
+
debug: (message: string, meta?: unknown) => void;
|
|
19
|
+
};
|
|
20
|
+
targetBranch: string;
|
|
21
|
+
}) => boolean | Promise<boolean>) | undefined;
|
|
22
|
+
autoMerge?: boolean | undefined;
|
|
23
|
+
autoMergeMethod?: string | undefined;
|
|
24
|
+
cherrypickRef?: boolean | undefined;
|
|
25
|
+
ci?: boolean | undefined;
|
|
26
|
+
commitPaths?: string[] | undefined;
|
|
27
|
+
details?: boolean | undefined;
|
|
28
|
+
editor?: string | undefined;
|
|
29
|
+
gitHostname?: string | undefined;
|
|
30
|
+
githubApiBaseUrlV3?: string | undefined;
|
|
31
|
+
githubApiBaseUrlV4?: string | undefined;
|
|
32
|
+
maxNumber?: number | undefined;
|
|
33
|
+
multiple?: boolean | undefined;
|
|
34
|
+
multipleBranches?: boolean | undefined;
|
|
35
|
+
multipleCommits?: boolean | undefined;
|
|
36
|
+
noVerify?: boolean | undefined;
|
|
37
|
+
prDescription?: string | undefined;
|
|
38
|
+
prFilter?: string | undefined;
|
|
39
|
+
prTitle?: string | undefined;
|
|
40
|
+
pullNumber?: number | undefined;
|
|
41
|
+
repoName?: string | undefined;
|
|
42
|
+
repoOwner?: string | undefined;
|
|
43
|
+
resetAuthor?: boolean | undefined;
|
|
44
|
+
reviewers?: string[] | undefined;
|
|
45
|
+
sha?: string | undefined;
|
|
46
|
+
skipRemoteConfig?: boolean | undefined;
|
|
47
|
+
sourceBranch?: string | undefined;
|
|
48
|
+
sourcePRLabels?: string[] | undefined;
|
|
49
|
+
targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
50
|
+
targetBranches?: string[] | undefined;
|
|
51
|
+
targetPRLabels?: string[] | undefined;
|
|
52
|
+
branchLabelMapping?: Record<string, string> | undefined;
|
|
53
|
+
};
|
|
@@ -3,18 +3,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readConfigFile = void 0;
|
|
6
|
+
exports.withConfigMigrations = exports.readConfigFile = void 0;
|
|
7
7
|
const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
|
8
8
|
const HandledError_1 = require("../../services/HandledError");
|
|
9
9
|
const fs_promisified_1 = require("../../services/fs-promisified");
|
|
10
|
+
const excludeUndefined_1 = require("../../utils/excludeUndefined");
|
|
10
11
|
async function readConfigFile(filepath) {
|
|
11
|
-
const fileContents = await fs_promisified_1.readFile(filepath, 'utf8');
|
|
12
|
-
const configWithoutComments = strip_json_comments_1.default(fileContents);
|
|
12
|
+
const fileContents = await (0, fs_promisified_1.readFile)(filepath, 'utf8');
|
|
13
|
+
const configWithoutComments = (0, strip_json_comments_1.default)(fileContents);
|
|
13
14
|
try {
|
|
14
|
-
return JSON.parse(configWithoutComments);
|
|
15
|
+
return withConfigMigrations(JSON.parse(configWithoutComments));
|
|
15
16
|
}
|
|
16
17
|
catch (e) {
|
|
17
|
-
throw new HandledError_1.HandledError(`"${filepath}" contains invalid JSON:\n\n${fileContents}
|
|
18
|
+
throw new HandledError_1.HandledError(`"${filepath}" contains invalid JSON:\n\n${fileContents}`);
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
exports.readConfigFile = readConfigFile;
|
|
22
|
+
// ensure backwards compatability when config options are renamed
|
|
23
|
+
function withConfigMigrations({ upstream, labels, branches, ...config }) {
|
|
24
|
+
const { repoName, repoOwner } = parseUpstream(upstream, config);
|
|
25
|
+
return (0, excludeUndefined_1.excludeUndefined)({
|
|
26
|
+
...config,
|
|
27
|
+
// `branches` was renamed `targetBranchChoices`
|
|
28
|
+
targetBranchChoices: config.targetBranchChoices ?? branches,
|
|
29
|
+
// `upstream` has been renamed to `repoOwner`/`repoName`
|
|
30
|
+
repoName,
|
|
31
|
+
repoOwner,
|
|
32
|
+
// `labels` was renamed `targetPRLabels`
|
|
33
|
+
targetPRLabels: config.targetPRLabels ?? labels,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.withConfigMigrations = withConfigMigrations;
|
|
37
|
+
function parseUpstream(upstream, config) {
|
|
38
|
+
if (upstream) {
|
|
39
|
+
const [repoOwner, repoName] = upstream.split('/');
|
|
40
|
+
return { repoOwner, repoName };
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
repoOwner: config.repoOwner,
|
|
44
|
+
repoName: config.repoName,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -1,15 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ConfigFileOptions, TargetBranchChoiceOrString } from './ConfigOptions';
|
|
2
|
+
export declare type ValidConfigOptions = Readonly<Awaited<ReturnType<typeof getOptions>>>;
|
|
3
|
+
export declare const defaultConfigOptions: {
|
|
4
|
+
assignees: string[];
|
|
5
|
+
autoAssign: boolean;
|
|
6
|
+
autoMerge: boolean;
|
|
7
|
+
autoMergeMethod: string;
|
|
8
|
+
cherrypickRef: boolean;
|
|
9
|
+
ci: boolean;
|
|
10
|
+
details: boolean;
|
|
11
|
+
fork: boolean;
|
|
12
|
+
maxNumber: number;
|
|
13
|
+
multipleBranches: boolean;
|
|
14
|
+
multipleCommits: boolean;
|
|
15
|
+
noVerify: boolean;
|
|
16
|
+
resetAuthor: boolean;
|
|
17
|
+
sourcePRLabels: string[];
|
|
18
|
+
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
19
|
+
targetBranches: string[];
|
|
20
|
+
targetPRLabels: string[];
|
|
21
|
+
verbose: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function getOptions(argv: string[], optionsFromModule?: ConfigFileOptions): Promise<{
|
|
6
24
|
accessToken: string;
|
|
7
|
-
username: string;
|
|
8
25
|
repoName: string;
|
|
9
26
|
repoOwner: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
fork: boolean;
|
|
28
|
+
verbose: boolean;
|
|
29
|
+
assignees: string[];
|
|
30
|
+
author: string | null;
|
|
31
|
+
autoAssign: boolean;
|
|
32
|
+
autoMerge: boolean;
|
|
33
|
+
autoMergeMethod: string;
|
|
34
|
+
cherrypickRef: boolean;
|
|
35
|
+
ci: boolean;
|
|
36
|
+
commitPaths: string[];
|
|
37
|
+
details: boolean;
|
|
38
|
+
editor?: string | undefined;
|
|
39
|
+
gitHostname?: string | undefined;
|
|
40
|
+
githubApiBaseUrlV3?: string | undefined;
|
|
41
|
+
githubApiBaseUrlV4?: string | undefined;
|
|
42
|
+
maxNumber: number;
|
|
43
|
+
multipleBranches: boolean;
|
|
44
|
+
multipleCommits: boolean;
|
|
45
|
+
noVerify: boolean;
|
|
46
|
+
prDescription?: string | undefined;
|
|
47
|
+
prFilter?: string | undefined;
|
|
48
|
+
prTitle?: string | undefined;
|
|
49
|
+
pullNumber?: number | undefined;
|
|
50
|
+
resetAuthor: boolean;
|
|
51
|
+
reviewers: string[];
|
|
52
|
+
sha?: string | undefined;
|
|
53
|
+
skipRemoteConfig?: boolean | undefined;
|
|
54
|
+
sourceBranch: string;
|
|
55
|
+
sourcePRLabels: string[];
|
|
56
|
+
targetBranchChoices: string[] | TargetBranchChoiceOrString[];
|
|
57
|
+
targetBranches: string[];
|
|
58
|
+
targetPRLabels: string[];
|
|
59
|
+
mainline?: number | undefined;
|
|
60
|
+
historicalBranchLabelMappings: {
|
|
61
|
+
branchLabelMapping: Record<string, string>;
|
|
62
|
+
committedDate: string;
|
|
63
|
+
}[];
|
|
64
|
+
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
13
65
|
files: string[];
|
|
14
66
|
directory: string;
|
|
15
67
|
logger: {
|
|
@@ -21,30 +73,10 @@ export declare function getOptions(argv: string[], optionsFromModule?: ConfigOpt
|
|
|
21
73
|
};
|
|
22
74
|
targetBranch: string;
|
|
23
75
|
}) => boolean | Promise<boolean>) | undefined;
|
|
24
|
-
|
|
25
|
-
branchLabelMapping
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ci: boolean;
|
|
31
|
-
dryRun: boolean;
|
|
32
|
-
editor: string | undefined;
|
|
33
|
-
fork: boolean;
|
|
34
|
-
gitHostname: string;
|
|
35
|
-
githubApiBaseUrlV3: string;
|
|
36
|
-
githubApiBaseUrlV4: string;
|
|
37
|
-
mainline: number | undefined;
|
|
38
|
-
maxNumber: number;
|
|
39
|
-
path: string | undefined;
|
|
40
|
-
prTitle: string;
|
|
41
|
-
prDescription: string | undefined;
|
|
42
|
-
prFilter: string | undefined;
|
|
43
|
-
pullNumber: number | undefined;
|
|
44
|
-
resetAuthor: boolean;
|
|
45
|
-
sha: string | undefined;
|
|
46
|
-
sourcePRLabels: string[];
|
|
47
|
-
targetBranches: string[];
|
|
48
|
-
targetPRLabels: string[];
|
|
49
|
-
verbose: boolean;
|
|
76
|
+
multiple?: boolean | undefined;
|
|
77
|
+
branchLabelMapping?: Record<string, string> | undefined;
|
|
78
|
+
upstream?: string | undefined;
|
|
79
|
+
branches?: TargetBranchChoiceOrString[] | undefined;
|
|
80
|
+
labels?: string[] | undefined;
|
|
81
|
+
authenticatedUsername: string;
|
|
50
82
|
}>;
|
package/dist/options/options.js
CHANGED
|
@@ -1,26 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptions = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.getOptions = exports.defaultConfigOptions = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const HandledError_1 = require("../services/HandledError");
|
|
6
|
+
const env_1 = require("../services/env");
|
|
7
|
+
const getOptionsFromGithub_1 = require("../services/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
5
8
|
const logger_1 = require("./../services/logger");
|
|
6
9
|
const cliArgs_1 = require("./cliArgs");
|
|
7
10
|
const config_1 = require("./config/config");
|
|
8
|
-
const
|
|
11
|
+
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson';
|
|
12
|
+
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson';
|
|
13
|
+
exports.defaultConfigOptions = {
|
|
14
|
+
assignees: [],
|
|
15
|
+
autoAssign: false,
|
|
16
|
+
autoMerge: false,
|
|
17
|
+
autoMergeMethod: 'merge',
|
|
18
|
+
cherrypickRef: true,
|
|
19
|
+
ci: false,
|
|
20
|
+
details: false,
|
|
21
|
+
fork: true,
|
|
22
|
+
maxNumber: 10,
|
|
23
|
+
multipleBranches: true,
|
|
24
|
+
multipleCommits: false,
|
|
25
|
+
noVerify: true,
|
|
26
|
+
resetAuthor: false,
|
|
27
|
+
sourcePRLabels: [],
|
|
28
|
+
targetBranchChoices: [],
|
|
29
|
+
targetBranches: [],
|
|
30
|
+
targetPRLabels: [],
|
|
31
|
+
verbose: false,
|
|
32
|
+
};
|
|
9
33
|
async function getOptions(argv, optionsFromModule) {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
34
|
+
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)(optionsFromModule);
|
|
35
|
+
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
36
|
+
// combined options from cli and config files
|
|
37
|
+
const combined = getCombinedOptions({
|
|
38
|
+
optionsFromConfigFiles,
|
|
39
|
+
optionsFromCliArgs,
|
|
40
|
+
});
|
|
12
41
|
// update logger
|
|
13
|
-
logger_1.updateLogger(
|
|
14
|
-
//
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
...
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
(0, logger_1.updateLogger)(combined);
|
|
43
|
+
// required
|
|
44
|
+
const accessToken = requireAccessToken(combined);
|
|
45
|
+
const repoName = requireRepoName(combined);
|
|
46
|
+
const repoOwner = requireRepoOwner(combined);
|
|
47
|
+
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)({
|
|
48
|
+
...combined,
|
|
49
|
+
// required props
|
|
50
|
+
accessToken,
|
|
51
|
+
repoName,
|
|
52
|
+
repoOwner,
|
|
53
|
+
});
|
|
54
|
+
const res = {
|
|
55
|
+
// default author
|
|
56
|
+
author: optionsFromGithub.authenticatedUsername,
|
|
57
|
+
// default values have lowest precedence
|
|
58
|
+
...exports.defaultConfigOptions,
|
|
59
|
+
// local config options override default options
|
|
60
|
+
...optionsFromConfigFiles,
|
|
61
|
+
// remote config options override local config options
|
|
62
|
+
...optionsFromGithub,
|
|
63
|
+
// cli args override the above
|
|
64
|
+
...optionsFromCliArgs,
|
|
65
|
+
// required properties
|
|
66
|
+
accessToken,
|
|
67
|
+
repoName,
|
|
68
|
+
repoOwner,
|
|
24
69
|
};
|
|
70
|
+
requireTargetBranch(res);
|
|
71
|
+
return res;
|
|
25
72
|
}
|
|
26
73
|
exports.getOptions = getOptions;
|
|
74
|
+
function getCombinedOptions({ optionsFromConfigFiles, optionsFromCliArgs, }) {
|
|
75
|
+
return {
|
|
76
|
+
...exports.defaultConfigOptions,
|
|
77
|
+
...optionsFromConfigFiles,
|
|
78
|
+
...optionsFromCliArgs,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function requireAccessToken(combinedOptions) {
|
|
82
|
+
// accessToken must be supplied in config or via cli args
|
|
83
|
+
if (!combinedOptions.accessToken) {
|
|
84
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
85
|
+
throw new HandledError_1.HandledError(`Please update your config file: ${globalConfigPath}.\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
86
|
+
}
|
|
87
|
+
return combinedOptions.accessToken;
|
|
88
|
+
}
|
|
89
|
+
function requireRepoName(combinedOptions) {
|
|
90
|
+
if (!combinedOptions.repoName) {
|
|
91
|
+
throw new HandledError_1.HandledError(`Please specify a repo name: "--repo-name kibana". \n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
92
|
+
}
|
|
93
|
+
return combinedOptions.repoName;
|
|
94
|
+
}
|
|
95
|
+
function requireRepoOwner(combinedOptions) {
|
|
96
|
+
if (!combinedOptions.repoOwner) {
|
|
97
|
+
throw new HandledError_1.HandledError(`Please specify a repo owner: "--repo-owner elastic". \n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
98
|
+
}
|
|
99
|
+
return combinedOptions.repoOwner;
|
|
100
|
+
}
|
|
101
|
+
function requireTargetBranch(config) {
|
|
102
|
+
// ensure `targetBranches` or `targetBranchChoices` are given
|
|
103
|
+
if ((0, lodash_1.isEmpty)(config.targetBranches) &&
|
|
104
|
+
(0, lodash_1.isEmpty)(config.targetBranchChoices) &&
|
|
105
|
+
// this is primarily necessary on CI where `targetBranches` and `targetBranchChoices` and not given
|
|
106
|
+
(0, lodash_1.isEmpty)(config.branchLabelMapping)) {
|
|
107
|
+
throw new HandledError_1.HandledError(`Please specify a target branch: "--branch 6.1". \n\n Read more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
108
|
+
}
|
|
109
|
+
}
|