backport 7.3.6 → 8.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 +16 -21
- package/dist/backportRun.d.ts +18 -6
- package/dist/backportRun.js +70 -50
- package/dist/entrypoint.cli.js +4 -8
- package/dist/entrypoint.module.d.ts +13 -6
- package/dist/entrypoint.module.js +17 -19
- package/dist/entrypoint.module.private.test.js +129 -330
- package/dist/errors/BackportError.d.ts +19 -0
- package/dist/errors/BackportError.js +29 -0
- package/dist/lib/BackportError.d.ts +19 -0
- package/dist/lib/BackportError.js +29 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +13 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
- package/dist/lib/child-process-promisified.d.ts +25 -0
- package/dist/lib/child-process-promisified.js +58 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +33 -0
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +26 -0
- package/dist/lib/getCommits.d.ts +2 -0
- package/dist/lib/getCommits.js +75 -0
- package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/lib/getCommitsWithoutBackports.js +68 -0
- package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
- package/dist/lib/getGitConfigAuthor.d.ts +6 -0
- package/dist/lib/getGitConfigAuthor.js +15 -0
- package/dist/lib/getTargetBranches.d.ts +5 -0
- package/dist/lib/getTargetBranches.js +67 -0
- package/dist/lib/getTargetBranches.test.d.ts +1 -0
- package/dist/lib/getTargetBranches.test.js +206 -0
- package/dist/lib/git.d.ts +77 -0
- package/dist/lib/git.js +439 -0
- package/dist/lib/git.private.test.d.ts +1 -0
- package/dist/lib/git.private.test.js +618 -0
- package/dist/lib/git.test.d.ts +1 -0
- package/dist/lib/git.test.js +580 -0
- package/dist/lib/github/commitFormatters.d.ts +3 -0
- package/dist/lib/github/commitFormatters.js +17 -0
- package/dist/lib/github/commitFormatters.test.d.ts +1 -0
- package/dist/lib/github/commitFormatters.test.js +11 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
- package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
- package/dist/lib/github/v3/createPullRequest.js +91 -0
- package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/createPullRequest.test.js +377 -0
- package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
- package/dist/lib/github/v3/createStatusComment.js +136 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +461 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
- package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
- package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
- package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
- package/dist/lib/github/v4/apiRequestV4.js +71 -0
- package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
- package/dist/lib/github/v4/fetchAuthorId.js +28 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/lib/logger.d.ts +9 -0
- package/dist/lib/logger.js +74 -0
- package/dist/lib/ora.d.ts +2 -0
- package/dist/lib/ora.js +21 -0
- package/dist/lib/prompt.test.d.ts +1 -0
- package/dist/lib/prompt.test.js +139 -0
- package/dist/lib/prompts.d.ts +17 -0
- package/dist/lib/prompts.js +132 -0
- package/dist/lib/remoteConfig.d.ts +20 -0
- package/dist/lib/remoteConfig.js +52 -0
- package/dist/lib/sequentially.d.ts +1 -0
- package/dist/lib/sequentially.js +10 -0
- package/dist/lib/setupRepo.d.ts +2 -0
- package/dist/lib/setupRepo.js +56 -0
- package/dist/lib/setupRepo.test.d.ts +1 -0
- package/dist/lib/setupRepo.test.js +278 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
- package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/options/ConfigOptions.d.ts +6 -4
- package/dist/options/cliArgs.d.ts +16 -9
- package/dist/options/cliArgs.js +54 -28
- package/dist/options/cliArgs.test.js +128 -4
- package/dist/options/config/config.d.ts +7 -6
- package/dist/options/config/config.js +5 -7
- package/dist/options/config/config.test.js +0 -1
- package/dist/options/config/globalConfig.d.ts +5 -3
- package/dist/options/config/globalConfig.js +17 -14
- package/dist/options/config/projectConfig.d.ts +2 -2
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +19 -7
- package/dist/options/config/readConfigFile.d.ts +9 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +44 -9
- package/dist/options/options.js +22 -27
- package/dist/options/options.test.js +119 -58
- package/dist/runSequentially.d.ts +14 -7
- package/dist/runSequentially.js +26 -11
- package/dist/scripts/postinstall.js +4 -3
- package/dist/scripts/postinstall.test.js +6 -2
- package/dist/services/BackportError.d.ts +19 -0
- package/dist/services/BackportError.js +29 -0
- package/dist/services/HandledBackportError.d.ts +19 -0
- package/dist/services/HandledBackportError.js +29 -0
- package/dist/services/HandledError.d.ts +7 -3
- package/dist/services/HandledError.js +13 -13
- package/dist/services/child-process-promisified.d.ts +19 -3
- package/dist/services/child-process-promisified.js +46 -17
- package/dist/services/git.d.ts +6 -7
- package/dist/services/git.integration.test.js +381 -65
- package/dist/services/git.js +189 -127
- package/dist/services/git.private.test.d.ts +1 -0
- package/dist/services/git.private.test.js +618 -0
- package/dist/services/git.test.js +167 -158
- package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
- package/dist/services/github/v3/createPullRequest.js +4 -2
- package/dist/services/github/v3/createStatusComment.js +17 -17
- package/dist/services/github/v3/createStatusComment.test.js +22 -9
- package/dist/services/github/v4/apiRequestV4.js +8 -11
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +5 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +9 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -6
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +4 -7
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -7
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +9 -8
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/services/logger.d.ts +1 -4
- package/dist/services/logger.js +14 -19
- package/dist/services/test.d.ts +1 -0
- package/dist/services/test.js +23 -0
- package/dist/state.d.ts +0 -0
- package/dist/state.js +1 -0
- package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
- package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +450 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +27 -28
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +6 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +44 -23
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
- package/dist/test/e2e/module/entrypoint.module.mutation.test.d.ts +1 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +376 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +12 -10
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +17 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +11 -7
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.js +3 -3
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +3 -3
- package/dist/ui/setupRepo.test.js +98 -61
- package/dist/utils/isErrnoError.d.ts +2 -0
- package/dist/utils/isErrnoError.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +17 -17
- package/yarn.lock +461 -695
package/dist/options/cliArgs.js
CHANGED
|
@@ -3,11 +3,14 @@ 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.getOptionsFromCliArgs = void 0;
|
|
6
|
+
exports.getEarlyArguments = exports.getOptionsFromCliArgs = void 0;
|
|
7
7
|
const yargs_1 = __importDefault(require("yargs"));
|
|
8
|
+
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
8
9
|
const excludeUndefined_1 = require("../utils/excludeUndefined");
|
|
9
|
-
|
|
10
|
+
const options_1 = require("./options");
|
|
11
|
+
function getOptionsFromCliArgs(processArgs) {
|
|
10
12
|
const yargsInstance = (0, yargs_1.default)(processArgs)
|
|
13
|
+
.strict()
|
|
11
14
|
.parserConfiguration({
|
|
12
15
|
'strip-dashed': true,
|
|
13
16
|
'strip-aliased': true,
|
|
@@ -53,20 +56,25 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
53
56
|
alias: 'author',
|
|
54
57
|
type: 'string',
|
|
55
58
|
conflicts: 'all',
|
|
56
|
-
})
|
|
57
|
-
.option('ci', {
|
|
58
|
-
description: 'Disable interactive prompts',
|
|
59
|
-
type: 'boolean',
|
|
60
59
|
})
|
|
61
60
|
.option('cherrypickRef', {
|
|
62
61
|
description: 'Append commit message with "(cherry picked from commit...)',
|
|
63
62
|
type: 'boolean',
|
|
64
63
|
conflicts: ['noCherrypickRef'],
|
|
65
64
|
})
|
|
66
|
-
.option('
|
|
65
|
+
.option('cwd', {
|
|
66
|
+
hidden: true,
|
|
67
|
+
description: 'Path to source repo',
|
|
68
|
+
type: 'string',
|
|
69
|
+
})
|
|
70
|
+
.option('projectConfigFile', {
|
|
67
71
|
alias: 'config',
|
|
68
72
|
description: 'Path to project config',
|
|
69
73
|
type: 'string',
|
|
74
|
+
})
|
|
75
|
+
.option('globalConfigFile', {
|
|
76
|
+
description: 'Path to global config',
|
|
77
|
+
type: 'string',
|
|
70
78
|
})
|
|
71
79
|
.option('since', {
|
|
72
80
|
description: 'ISO-8601 date for filtering commits',
|
|
@@ -77,7 +85,7 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
77
85
|
type: 'string',
|
|
78
86
|
})
|
|
79
87
|
.option('dir', {
|
|
80
|
-
description: '
|
|
88
|
+
description: 'Path to temporary backport repo',
|
|
81
89
|
type: 'string',
|
|
82
90
|
})
|
|
83
91
|
.option('details', {
|
|
@@ -124,6 +132,12 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
124
132
|
.option('gitAuthorEmail', {
|
|
125
133
|
description: `Set commit author email`,
|
|
126
134
|
type: 'string',
|
|
135
|
+
})
|
|
136
|
+
.option('nonInteractive', {
|
|
137
|
+
alias: ['json'],
|
|
138
|
+
description: 'Disable interactive prompts and return response as JSON',
|
|
139
|
+
type: 'boolean',
|
|
140
|
+
conflicts: 'interactive',
|
|
127
141
|
})
|
|
128
142
|
.option('logFilePath', {
|
|
129
143
|
hidden: true,
|
|
@@ -180,6 +194,8 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
180
194
|
type: 'boolean',
|
|
181
195
|
conflicts: ['cherrypickRef'],
|
|
182
196
|
})
|
|
197
|
+
// cli-only
|
|
198
|
+
// negation of `publishStatusCommentOnSuccess` and `publishStatusCommentOnFailure`
|
|
183
199
|
.option('noStatusComment', {
|
|
184
200
|
description: "Don't publish status comment to Github",
|
|
185
201
|
type: 'boolean',
|
|
@@ -239,11 +255,13 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
239
255
|
conflicts: ['noFork'],
|
|
240
256
|
})
|
|
241
257
|
.option('repoOwner', {
|
|
258
|
+
hidden: true,
|
|
242
259
|
description: 'Repository owner',
|
|
243
260
|
type: 'string',
|
|
244
261
|
conflicts: ['repo'],
|
|
245
262
|
})
|
|
246
263
|
.option('repoName', {
|
|
264
|
+
hidden: true,
|
|
247
265
|
description: 'Repository name',
|
|
248
266
|
type: 'string',
|
|
249
267
|
conflicts: ['repo'],
|
|
@@ -285,10 +303,6 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
285
303
|
alias: ['label', 'l'],
|
|
286
304
|
type: 'array',
|
|
287
305
|
string: true,
|
|
288
|
-
})
|
|
289
|
-
.option('verbose', {
|
|
290
|
-
description: 'Show additional debug information',
|
|
291
|
-
type: 'boolean',
|
|
292
306
|
})
|
|
293
307
|
// cli-only
|
|
294
308
|
.option('verify', {
|
|
@@ -296,31 +310,28 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
296
310
|
type: 'boolean',
|
|
297
311
|
})
|
|
298
312
|
.alias('version', 'v')
|
|
299
|
-
.alias('version', 'V')
|
|
300
313
|
.help()
|
|
301
|
-
.epilogue('For bugs, feature requests or questions: https://github.com/sqren/backport/issues\nOr contact me directly: https://twitter.com/sorenlouv')
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
});
|
|
312
|
-
}
|
|
314
|
+
.epilogue('For bugs, feature requests or questions: https://github.com/sqren/backport/issues\nOr contact me directly: https://twitter.com/sorenlouv')
|
|
315
|
+
// don't kill process upon error
|
|
316
|
+
// and don't log error to console
|
|
317
|
+
.fail((msg, err) => {
|
|
318
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
319
|
+
if (err) {
|
|
320
|
+
throw err;
|
|
321
|
+
}
|
|
322
|
+
throw new Error(msg);
|
|
323
|
+
});
|
|
313
324
|
const {
|
|
314
325
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
315
326
|
$0, _,
|
|
316
327
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
317
328
|
multiple, multipleBranches, multipleCommits, all,
|
|
318
|
-
//
|
|
329
|
+
// shorthands
|
|
319
330
|
repo,
|
|
320
331
|
// filters
|
|
321
332
|
author, since, until,
|
|
322
333
|
// negations
|
|
323
|
-
noCherrypickRef, noFork, noStatusComment, noVerify, verify,
|
|
334
|
+
noCherrypickRef, noFork, noStatusComment, noVerify, verify, nonInteractive,
|
|
324
335
|
// array types (should be renamed to plural form)
|
|
325
336
|
assignee, path, reviewer, sourcePRLabel, targetBranch, targetBranchChoice, targetPRLabel, ...restOptions } = yargsInstance.parseSync();
|
|
326
337
|
const [repoOwner, repoName] = repo?.split('/') ?? [
|
|
@@ -351,7 +362,22 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
351
362
|
cherrypickRef: noCherrypickRef === true ? false : restOptions.cherrypickRef,
|
|
352
363
|
fork: noFork === true ? false : restOptions.fork,
|
|
353
364
|
noVerify: verify ?? noVerify,
|
|
354
|
-
|
|
365
|
+
publishStatusCommentOnSuccess: noStatusComment === true ? false : undefined,
|
|
366
|
+
publishStatusCommentOnFailure: noStatusComment === true ? false : undefined,
|
|
367
|
+
publishStatusCommentOnAbort: noStatusComment === true ? false : undefined,
|
|
368
|
+
interactive: nonInteractive === true ? false : undefined,
|
|
355
369
|
});
|
|
356
370
|
}
|
|
357
371
|
exports.getOptionsFromCliArgs = getOptionsFromCliArgs;
|
|
372
|
+
function getEarlyArguments(processArgs, optionsFromModule) {
|
|
373
|
+
const { nonInteractive, json, logFilePath, ls } = (0, yargs_parser_1.default)(processArgs);
|
|
374
|
+
const base = { ...options_1.defaultConfigOptions, ...optionsFromModule };
|
|
375
|
+
return {
|
|
376
|
+
interactive: nonInteractive === undefined && json === undefined
|
|
377
|
+
? base.interactive
|
|
378
|
+
: !(nonInteractive === true || json === true),
|
|
379
|
+
logFilePath,
|
|
380
|
+
ls,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
exports.getEarlyArguments = getEarlyArguments;
|
|
@@ -47,6 +47,27 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
47
47
|
expect(res.sourcePRLabels).toEqual(['label a', 'label b', 'label c']);
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
|
+
describe('reviewers', () => {
|
|
51
|
+
it('should handle all variations', () => {
|
|
52
|
+
const argv = ['--reviewer=peter'];
|
|
53
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
54
|
+
expect(res.reviewers).toEqual(['peter']);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('author', () => {
|
|
58
|
+
it('has a default author', () => {
|
|
59
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)([]);
|
|
60
|
+
expect(res.author).toEqual(undefined);
|
|
61
|
+
});
|
|
62
|
+
it('sets the author', () => {
|
|
63
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(['--author=sqren']);
|
|
64
|
+
expect(res.author).toEqual('sqren');
|
|
65
|
+
});
|
|
66
|
+
it('sets the author to null', () => {
|
|
67
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(['--all']);
|
|
68
|
+
expect(res.author).toEqual(null);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
50
71
|
describe('pullNumber', () => {
|
|
51
72
|
it('should accept `--pr` alias but only return the full representation (`pullNumber`)', () => {
|
|
52
73
|
const argv = ['--pr', '1337'];
|
|
@@ -91,7 +112,54 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
91
112
|
});
|
|
92
113
|
it('should conflict when using both', () => {
|
|
93
114
|
const argv = ['--multiple', '--multiple-branches', 'false'];
|
|
94
|
-
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv
|
|
115
|
+
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrow('Arguments multiple and multipleBranches are mutually exclusive');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('fork', () => {
|
|
119
|
+
it('--fork', () => {
|
|
120
|
+
const argv = ['--fork'];
|
|
121
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
122
|
+
expect(res.fork).toEqual(true);
|
|
123
|
+
});
|
|
124
|
+
it('--no-fork', () => {
|
|
125
|
+
const argv = ['--no-fork'];
|
|
126
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
127
|
+
expect(res.fork).toEqual(false);
|
|
128
|
+
});
|
|
129
|
+
it('defaults to undefined', () => {
|
|
130
|
+
const argv = [];
|
|
131
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
132
|
+
expect(res.fork).toEqual(undefined);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe('interactive', () => {
|
|
136
|
+
it('defaults to undefined', () => {
|
|
137
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)([]);
|
|
138
|
+
expect(res.interactive).toEqual(undefined);
|
|
139
|
+
});
|
|
140
|
+
it('noStatusComment', () => {
|
|
141
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(['--non-interactive']);
|
|
142
|
+
expect(res.interactive).toEqual(false);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
describe('publishStatusCommentOnFailure', () => {
|
|
146
|
+
it('defaults to undefined', () => {
|
|
147
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)([]);
|
|
148
|
+
expect(res.publishStatusCommentOnFailure).toEqual(undefined);
|
|
149
|
+
});
|
|
150
|
+
it('noStatusComment', () => {
|
|
151
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(['--noStatusComment']);
|
|
152
|
+
expect(res.publishStatusCommentOnFailure).toEqual(false);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe('publishStatusCommentOnSuccess', () => {
|
|
156
|
+
it('defaults to undefined', () => {
|
|
157
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)([]);
|
|
158
|
+
expect(res.publishStatusCommentOnSuccess).toEqual(undefined);
|
|
159
|
+
});
|
|
160
|
+
it('noStatusComment', () => {
|
|
161
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(['--noStatusComment']);
|
|
162
|
+
expect(res.publishStatusCommentOnSuccess).toEqual(false);
|
|
95
163
|
});
|
|
96
164
|
});
|
|
97
165
|
describe('noVerify', () => {
|
|
@@ -116,6 +184,16 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
116
184
|
expect(res.noVerify).toBe(true);
|
|
117
185
|
});
|
|
118
186
|
});
|
|
187
|
+
describe('cherrypickRef', () => {
|
|
188
|
+
it('should be undefined by default', () => {
|
|
189
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)([]);
|
|
190
|
+
expect(res.cherrypickRef).toBe(undefined);
|
|
191
|
+
});
|
|
192
|
+
it('can be disabled', () => {
|
|
193
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(['--no-cherrypick-ref']);
|
|
194
|
+
expect(res.cherrypickRef).toBe(false);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
119
197
|
describe('mainline', () => {
|
|
120
198
|
it('should default to 1', () => {
|
|
121
199
|
const argv = ['--mainline'];
|
|
@@ -129,7 +207,7 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
129
207
|
});
|
|
130
208
|
it('should throw on invalid values', () => {
|
|
131
209
|
const argv = ['--mainline', 'foo'];
|
|
132
|
-
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv
|
|
210
|
+
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrowError('--mainline must be an integer. Received: NaN');
|
|
133
211
|
});
|
|
134
212
|
});
|
|
135
213
|
describe('targetBranches', () => {
|
|
@@ -146,12 +224,18 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
146
224
|
expect(res.repoOwner).toEqual('elastic');
|
|
147
225
|
expect(res.repoName).toEqual('kibana');
|
|
148
226
|
});
|
|
227
|
+
it('accepts --repo-name and --repo-owner', () => {
|
|
228
|
+
const argv = ['--repo-owner=elastic', '--repo-name=kibana'];
|
|
229
|
+
const res = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
230
|
+
expect(res.repoOwner).toEqual('elastic');
|
|
231
|
+
expect(res.repoName).toEqual('kibana');
|
|
232
|
+
});
|
|
149
233
|
it('throw if both --repo and --repo-name is given', () => {
|
|
150
234
|
const argv = ['--repo', 'elastic/kibana', '--repo-name', 'foo'];
|
|
151
|
-
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv
|
|
235
|
+
expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrowError('Arguments repo and repoName are mutually exclusive');
|
|
152
236
|
});
|
|
153
237
|
});
|
|
154
|
-
describe('
|
|
238
|
+
describe('dateSince and dateUntil', () => {
|
|
155
239
|
it('should always be UTC time (configured globally in jest.config.js)', () => {
|
|
156
240
|
expect(new Date().getTimezoneOffset()).toBe(0);
|
|
157
241
|
});
|
|
@@ -180,3 +264,43 @@ describe('getOptionsFromCliArgs', () => {
|
|
|
180
264
|
});
|
|
181
265
|
});
|
|
182
266
|
});
|
|
267
|
+
describe('getEarlyArguments', () => {
|
|
268
|
+
describe('interactive', () => {
|
|
269
|
+
it('--non-interactive flag', () => {
|
|
270
|
+
const { interactive } = (0, cliArgs_1.getEarlyArguments)(['--non-interactive']);
|
|
271
|
+
expect(interactive).toEqual(false);
|
|
272
|
+
});
|
|
273
|
+
it('--json flag', () => {
|
|
274
|
+
const { interactive } = (0, cliArgs_1.getEarlyArguments)(['--json']);
|
|
275
|
+
expect(interactive).toEqual(false);
|
|
276
|
+
});
|
|
277
|
+
it('default', () => {
|
|
278
|
+
const { interactive } = (0, cliArgs_1.getEarlyArguments)([]);
|
|
279
|
+
expect(interactive).toEqual(true);
|
|
280
|
+
});
|
|
281
|
+
it('setting via module options', () => {
|
|
282
|
+
const { interactive } = (0, cliArgs_1.getEarlyArguments)([], { interactive: false });
|
|
283
|
+
expect(interactive).toEqual(false);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
describe('ls', () => {
|
|
287
|
+
it('by default', () => {
|
|
288
|
+
const { ls } = (0, cliArgs_1.getEarlyArguments)([]);
|
|
289
|
+
expect(ls).toEqual(undefined);
|
|
290
|
+
});
|
|
291
|
+
it('--ls flag', () => {
|
|
292
|
+
const { ls } = (0, cliArgs_1.getEarlyArguments)(['--ls']);
|
|
293
|
+
expect(ls).toEqual(true);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
describe('logFilePath', () => {
|
|
297
|
+
it('by default', () => {
|
|
298
|
+
const { logFilePath } = (0, cliArgs_1.getEarlyArguments)([]);
|
|
299
|
+
expect(logFilePath).toEqual(undefined);
|
|
300
|
+
});
|
|
301
|
+
it('--log-file-path flag', () => {
|
|
302
|
+
const { logFilePath } = (0, cliArgs_1.getEarlyArguments)(['--log-file-path']);
|
|
303
|
+
expect(logFilePath).toEqual(true);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
2
|
import { OptionsFromCliArgs } from '../cliArgs';
|
|
3
3
|
export declare type OptionsFromConfigFiles = Awaited<ReturnType<typeof getOptionsFromConfigFiles>>;
|
|
4
|
-
export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule,
|
|
4
|
+
export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule, }: {
|
|
5
5
|
optionsFromCliArgs: OptionsFromCliArgs;
|
|
6
6
|
optionsFromModule: ConfigFileOptions;
|
|
7
|
-
defaultConfigOptions: ConfigFileOptions;
|
|
8
7
|
}): Promise<{
|
|
9
8
|
accessToken?: string | undefined;
|
|
10
9
|
assignees?: string[] | undefined;
|
|
@@ -20,11 +19,10 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
20
19
|
autoMergeMethod?: string | undefined;
|
|
21
20
|
backportBinary?: string | undefined;
|
|
22
21
|
cherrypickRef?: boolean | undefined;
|
|
23
|
-
ci?: boolean | undefined;
|
|
24
22
|
commitPaths?: string[] | undefined;
|
|
25
|
-
configFile?: string | undefined;
|
|
26
23
|
details?: boolean | undefined;
|
|
27
24
|
dir?: string | undefined;
|
|
25
|
+
dryRun?: boolean | undefined;
|
|
28
26
|
editor?: string | undefined;
|
|
29
27
|
fork?: boolean | undefined;
|
|
30
28
|
gitAuthorEmail?: string | undefined;
|
|
@@ -32,6 +30,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
32
30
|
gitHostname?: string | undefined;
|
|
33
31
|
githubApiBaseUrlV3?: string | undefined;
|
|
34
32
|
githubApiBaseUrlV4?: string | undefined;
|
|
33
|
+
interactive?: boolean | undefined;
|
|
35
34
|
logFilePath?: string | undefined;
|
|
36
35
|
ls?: boolean | undefined;
|
|
37
36
|
maxNumber?: number | undefined;
|
|
@@ -41,8 +40,11 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
41
40
|
noVerify?: boolean | undefined;
|
|
42
41
|
prDescription?: string | undefined;
|
|
43
42
|
prFilter?: string | undefined;
|
|
43
|
+
projectConfigFile?: string | undefined;
|
|
44
44
|
prTitle?: string | undefined;
|
|
45
|
-
|
|
45
|
+
publishStatusCommentOnAbort?: boolean | undefined;
|
|
46
|
+
publishStatusCommentOnFailure?: boolean | undefined;
|
|
47
|
+
publishStatusCommentOnSuccess?: boolean | undefined;
|
|
46
48
|
pullNumber?: number | undefined;
|
|
47
49
|
repoForkOwner?: string | undefined;
|
|
48
50
|
repoName?: string | undefined;
|
|
@@ -56,7 +58,6 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
56
58
|
targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
57
59
|
targetBranches?: string[] | undefined;
|
|
58
60
|
targetPRLabels?: string[] | undefined;
|
|
59
|
-
verbose?: boolean | undefined;
|
|
60
61
|
help?: boolean | undefined;
|
|
61
62
|
version?: boolean | undefined;
|
|
62
63
|
v?: boolean | undefined;
|
|
@@ -3,14 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOptionsFromConfigFiles = void 0;
|
|
4
4
|
const globalConfig_1 = require("./globalConfig");
|
|
5
5
|
const projectConfig_1 = require("./projectConfig");
|
|
6
|
-
async function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule,
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
// ci: cli and module only flag
|
|
10
|
-
const configFile = optionsFromCliArgs.configFile ?? optionsFromModule.configFile;
|
|
6
|
+
async function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsFromModule, }) {
|
|
7
|
+
const projectConfigFile = optionsFromCliArgs.projectConfigFile ?? optionsFromModule.projectConfigFile;
|
|
8
|
+
const globalConfigFile = optionsFromCliArgs.globalConfigFile;
|
|
11
9
|
const [projectConfig, globalConfig] = await Promise.all([
|
|
12
|
-
(0, projectConfig_1.getProjectConfig)({
|
|
13
|
-
|
|
10
|
+
(0, projectConfig_1.getProjectConfig)({ projectConfigFile }),
|
|
11
|
+
(0, globalConfig_1.getGlobalConfig)({ globalConfigFile }),
|
|
14
12
|
]);
|
|
15
13
|
return {
|
|
16
14
|
...globalConfig,
|
|
@@ -18,7 +18,6 @@ describe('getOptionsFromConfigFiles', () => {
|
|
|
18
18
|
res = await (0, config_1.getOptionsFromConfigFiles)({
|
|
19
19
|
optionsFromCliArgs: {},
|
|
20
20
|
optionsFromModule: {},
|
|
21
|
-
defaultConfigOptions: { ci: false },
|
|
22
21
|
});
|
|
23
22
|
});
|
|
24
23
|
it('should return values from config files', () => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
-
export declare function getGlobalConfig(
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export declare function getGlobalConfig({ globalConfigFile, }?: {
|
|
3
|
+
globalConfigFile?: string;
|
|
4
|
+
}): Promise<ConfigFileOptions>;
|
|
5
|
+
export declare function createGlobalConfigAndFolderIfNotExist(globalConfigPath: string): Promise<boolean | undefined>;
|
|
6
|
+
export declare function createGlobalConfigIfNotExist(globalConfigPath: string, configTemplate: string): Promise<boolean | undefined>;
|
|
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createGlobalConfigIfNotExist = exports.createGlobalConfigAndFolderIfNotExist = exports.getGlobalConfig = void 0;
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const make_dir_1 = __importDefault(require("make-dir"));
|
|
9
|
-
const
|
|
10
|
-
const env_1 = require("../../
|
|
9
|
+
const BackportError_1 = require("../../lib/BackportError");
|
|
10
|
+
const env_1 = require("../../lib/env");
|
|
11
|
+
const isErrnoError_1 = require("../../utils/isErrnoError");
|
|
11
12
|
const readConfigFile_1 = require("./readConfigFile");
|
|
12
|
-
async function getGlobalConfig() {
|
|
13
|
-
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
13
|
+
async function getGlobalConfig({ globalConfigFile, } = {}) {
|
|
14
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)(globalConfigFile);
|
|
14
15
|
await createGlobalConfigAndFolderIfNotExist(globalConfigPath);
|
|
15
16
|
return (0, readConfigFile_1.readConfigFile)(globalConfigPath);
|
|
16
17
|
}
|
|
@@ -36,17 +37,19 @@ async function createGlobalConfigIfNotExist(globalConfigPath, configTemplate) {
|
|
|
36
37
|
return true;
|
|
37
38
|
}
|
|
38
39
|
catch (e) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
if ((0, isErrnoError_1.isErrnoError)(e)) {
|
|
41
|
+
// ignore error if file already exists
|
|
42
|
+
const FILE_ALREADY_EXISTS = 'EEXIST';
|
|
43
|
+
if (e.code === FILE_ALREADY_EXISTS) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// handle error if folder does not exist
|
|
47
|
+
const FOLDER_NOT_EXISTS = 'ENOENT';
|
|
48
|
+
if (e.code === FOLDER_NOT_EXISTS) {
|
|
49
|
+
throw new BackportError_1.BackportError(`The .backport folder (${globalConfigPath}) does not exist. `);
|
|
50
|
+
}
|
|
51
|
+
throw e;
|
|
43
52
|
}
|
|
44
|
-
// handle error if folder does not exist
|
|
45
|
-
const FOLDER_NOT_EXISTS = 'ENOENT';
|
|
46
|
-
if (e.code === FOLDER_NOT_EXISTS) {
|
|
47
|
-
throw new HandledError_1.HandledError(`The .backport folder (${globalConfigPath}) does not exist. `);
|
|
48
|
-
}
|
|
49
|
-
throw e;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
exports.createGlobalConfigIfNotExist = createGlobalConfigIfNotExist;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
-
export declare function getProjectConfig({
|
|
3
|
-
|
|
2
|
+
export declare function getProjectConfig({ projectConfigFile, }: {
|
|
3
|
+
projectConfigFile: string | undefined;
|
|
4
4
|
}): Promise<ConfigFileOptions | undefined>;
|
|
@@ -7,9 +7,9 @@ exports.getProjectConfig = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const find_up_1 = __importDefault(require("find-up"));
|
|
9
9
|
const readConfigFile_1 = require("../config/readConfigFile");
|
|
10
|
-
async function getProjectConfig({
|
|
11
|
-
const filepath =
|
|
12
|
-
? path_1.default.resolve(
|
|
10
|
+
async function getProjectConfig({ projectConfigFile, }) {
|
|
11
|
+
const filepath = projectConfigFile
|
|
12
|
+
? path_1.default.resolve(projectConfigFile)
|
|
13
13
|
: await (0, find_up_1.default)('.backportrc.json');
|
|
14
14
|
if (!filepath) {
|
|
15
15
|
return;
|
|
@@ -16,7 +16,9 @@ describe('getProjectConfig', () => {
|
|
|
16
16
|
repoOwner: 'elastic',
|
|
17
17
|
branches: ['6.x'],
|
|
18
18
|
}));
|
|
19
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
19
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
20
|
+
projectConfigFile: undefined,
|
|
21
|
+
});
|
|
20
22
|
expect(projectConfig?.targetBranchChoices).toEqual(['6.x']);
|
|
21
23
|
});
|
|
22
24
|
});
|
|
@@ -25,7 +27,9 @@ describe('getProjectConfig', () => {
|
|
|
25
27
|
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
26
28
|
labels: ['backport'],
|
|
27
29
|
}));
|
|
28
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
30
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
31
|
+
projectConfigFile: undefined,
|
|
32
|
+
});
|
|
29
33
|
expect(projectConfig?.targetPRLabels).toEqual(['backport']);
|
|
30
34
|
});
|
|
31
35
|
});
|
|
@@ -34,7 +38,9 @@ describe('getProjectConfig', () => {
|
|
|
34
38
|
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce(JSON.stringify({
|
|
35
39
|
upstream: 'elastic/kibana',
|
|
36
40
|
}));
|
|
37
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
41
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
42
|
+
projectConfigFile: undefined,
|
|
43
|
+
});
|
|
38
44
|
expect(projectConfig?.repoOwner).toEqual('elastic');
|
|
39
45
|
expect(projectConfig?.repoName).toEqual('kibana');
|
|
40
46
|
});
|
|
@@ -48,7 +54,9 @@ describe('getProjectConfig', () => {
|
|
|
48
54
|
targetBranchChoices: ['6.x'],
|
|
49
55
|
targetPRLabels: ['backport'],
|
|
50
56
|
}));
|
|
51
|
-
projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
57
|
+
projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
58
|
+
projectConfigFile: undefined,
|
|
59
|
+
});
|
|
52
60
|
});
|
|
53
61
|
it('should call findUp', () => {
|
|
54
62
|
expect(find_up_1.default).toHaveBeenCalledWith('.backportrc.json');
|
|
@@ -73,7 +81,7 @@ describe('getProjectConfig', () => {
|
|
|
73
81
|
targetPRLabels: ['backport'],
|
|
74
82
|
}));
|
|
75
83
|
projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
76
|
-
|
|
84
|
+
projectConfigFile: '/custom/path/to/project/.backportrc.json',
|
|
77
85
|
});
|
|
78
86
|
});
|
|
79
87
|
it('should not call findUp', () => {
|
|
@@ -95,14 +103,18 @@ describe('getProjectConfig', () => {
|
|
|
95
103
|
describe('when projectConfig is empty', () => {
|
|
96
104
|
it('should return empty config', async () => {
|
|
97
105
|
jest.spyOn(promises_1.default, 'readFile').mockResolvedValueOnce('{}');
|
|
98
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
106
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
107
|
+
projectConfigFile: undefined,
|
|
108
|
+
});
|
|
99
109
|
expect(projectConfig).toEqual({});
|
|
100
110
|
});
|
|
101
111
|
});
|
|
102
112
|
describe('when projectConfig is missing', () => {
|
|
103
113
|
it('should return empty config', async () => {
|
|
104
114
|
find_up_1.default.mockReturnValueOnce(undefined);
|
|
105
|
-
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
115
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)({
|
|
116
|
+
projectConfigFile: undefined,
|
|
117
|
+
});
|
|
106
118
|
expect(projectConfig).toEqual(undefined);
|
|
107
119
|
});
|
|
108
120
|
});
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
2
|
export declare function readConfigFile(filepath: string): Promise<ConfigFileOptions>;
|
|
3
3
|
export declare function withConfigMigrations({ upstream, labels, branches, ...config }: ConfigFileOptions): {
|
|
4
|
-
fork?: boolean | undefined;
|
|
5
|
-
dir?: string | undefined;
|
|
6
|
-
help?: boolean | undefined;
|
|
7
|
-
verbose?: boolean | undefined;
|
|
8
4
|
logFilePath?: string | undefined;
|
|
9
5
|
accessToken?: string | undefined;
|
|
10
6
|
author?: string | null | undefined;
|
|
@@ -12,17 +8,20 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
12
8
|
assignees?: string[] | undefined;
|
|
13
9
|
autoMerge?: boolean | undefined;
|
|
14
10
|
autoMergeMethod?: string | undefined;
|
|
15
|
-
ci?: boolean | undefined;
|
|
16
11
|
cherrypickRef?: boolean | undefined;
|
|
17
|
-
|
|
12
|
+
projectConfigFile?: string | undefined;
|
|
13
|
+
dir?: string | undefined;
|
|
18
14
|
details?: boolean | undefined;
|
|
15
|
+
dryRun?: boolean | undefined;
|
|
19
16
|
editor?: string | undefined;
|
|
20
17
|
skipRemoteConfig?: boolean | undefined;
|
|
18
|
+
fork?: boolean | undefined;
|
|
21
19
|
gitHostname?: string | undefined;
|
|
22
20
|
githubApiBaseUrlV3?: string | undefined;
|
|
23
21
|
githubApiBaseUrlV4?: string | undefined;
|
|
24
22
|
gitAuthorName?: string | undefined;
|
|
25
23
|
gitAuthorEmail?: string | undefined;
|
|
24
|
+
interactive?: boolean | undefined;
|
|
26
25
|
ls?: boolean | undefined;
|
|
27
26
|
maxNumber?: number | undefined;
|
|
28
27
|
multiple?: boolean | undefined;
|
|
@@ -47,7 +46,9 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
47
46
|
targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
48
47
|
targetBranches?: string[] | undefined;
|
|
49
48
|
targetPRLabels?: string[] | undefined;
|
|
50
|
-
|
|
49
|
+
publishStatusCommentOnSuccess?: boolean | undefined;
|
|
50
|
+
publishStatusCommentOnFailure?: boolean | undefined;
|
|
51
|
+
publishStatusCommentOnAbort?: boolean | undefined;
|
|
51
52
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
52
53
|
files: string[];
|
|
53
54
|
directory: string;
|
|
@@ -55,5 +56,6 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
55
56
|
targetBranch: string;
|
|
56
57
|
}) => boolean | Promise<boolean>) | undefined;
|
|
57
58
|
backportBinary?: string | undefined;
|
|
59
|
+
help?: boolean | undefined;
|
|
58
60
|
branchLabelMapping?: Record<string, string> | undefined;
|
|
59
61
|
};
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.withConfigMigrations = exports.readConfigFile = void 0;
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
|
9
|
-
const
|
|
9
|
+
const BackportError_1 = require("../../lib/BackportError");
|
|
10
10
|
const excludeUndefined_1 = require("../../utils/excludeUndefined");
|
|
11
11
|
async function readConfigFile(filepath) {
|
|
12
12
|
const fileContents = await (0, promises_1.readFile)(filepath, 'utf8');
|
|
@@ -15,7 +15,7 @@ async function readConfigFile(filepath) {
|
|
|
15
15
|
return withConfigMigrations(JSON.parse(configWithoutComments));
|
|
16
16
|
}
|
|
17
17
|
catch (e) {
|
|
18
|
-
throw new
|
|
18
|
+
throw new BackportError_1.BackportError(`"${filepath}" contains invalid JSON:\n\n${fileContents}`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
exports.readConfigFile = readConfigFile;
|