backport 6.3.0-beta-6 → 6.3.0-beta-10
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/dist/entrypoint.cli.e2e.private.test.js +2 -0
- package/dist/options/options.js +42 -14
- package/dist/options/options.test.js +24 -7
- package/dist/services/github/v3/createStatusComment.js +2 -2
- package/dist/services/github/v3/createStatusComment.test.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -4
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/dist/utils/packageVersion.ts +1 -0
- package/package.json +4 -4
|
@@ -79,6 +79,8 @@ describe('inquirer cli', () => {
|
|
|
79
79
|
-b, --targetBranch, --branch Branch(es) to backport to [array]
|
|
80
80
|
--targetBranchChoice List branches to backport to [array]
|
|
81
81
|
-l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
|
|
82
|
+
--username User repo that branch will be pushed to. Defaults to the
|
|
83
|
+
authenticated user [string]
|
|
82
84
|
--verbose Show additional debug information [boolean]
|
|
83
85
|
--verify Opposite of no-verify [boolean]
|
|
84
86
|
--help Show help [boolean]
|
package/dist/options/options.js
CHANGED
|
@@ -47,7 +47,7 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
47
47
|
defaultConfigOptions,
|
|
48
48
|
});
|
|
49
49
|
// combined options from cli and config files
|
|
50
|
-
const combined =
|
|
50
|
+
const combined = getMergedOptionsFromConfigAndCli({
|
|
51
51
|
optionsFromConfigFiles,
|
|
52
52
|
optionsFromCliArgs,
|
|
53
53
|
});
|
|
@@ -61,7 +61,7 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
61
61
|
repoName,
|
|
62
62
|
repoOwner,
|
|
63
63
|
});
|
|
64
|
-
const
|
|
64
|
+
const options = {
|
|
65
65
|
// default author
|
|
66
66
|
author: optionsFromGithub.authenticatedUsername,
|
|
67
67
|
// default values have lowest precedence
|
|
@@ -77,8 +77,8 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
77
77
|
repoName,
|
|
78
78
|
repoOwner,
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
return
|
|
80
|
+
throwForRequiredOptions(options);
|
|
81
|
+
return options;
|
|
82
82
|
}
|
|
83
83
|
exports.getOptions = getOptions;
|
|
84
84
|
async function getRequiredOptions(combined) {
|
|
@@ -109,19 +109,47 @@ async function getRequiredOptions(combined) {
|
|
|
109
109
|
repoOwner: gitRemote.repoOwner,
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function throwForRequiredOptions(options) {
|
|
113
|
+
// ensure `targetBranches` or `targetBranchChoices` are given
|
|
114
|
+
if ((0, lodash_1.isEmpty)(options.targetBranches) &&
|
|
115
|
+
(0, lodash_1.isEmpty)(options.targetBranchChoices) &&
|
|
116
|
+
// this is primarily necessary on CI where `targetBranches` and `targetBranchChoices` and not given
|
|
117
|
+
(0, lodash_1.isEmpty)(options.branchLabelMapping)) {
|
|
118
|
+
throw new HandledError_1.HandledError(`Please specify a target branch: "--branch 6.1".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
119
|
+
}
|
|
120
|
+
const optionKeys = [
|
|
121
|
+
'accessToken',
|
|
122
|
+
'author',
|
|
123
|
+
'autoMergeMethod',
|
|
124
|
+
'backportBinary',
|
|
125
|
+
'configFile',
|
|
126
|
+
'dir',
|
|
127
|
+
'editor',
|
|
128
|
+
'gitHostname',
|
|
129
|
+
'githubApiBaseUrlV3',
|
|
130
|
+
'githubApiBaseUrlV4',
|
|
131
|
+
'logFilePath',
|
|
132
|
+
'prDescription',
|
|
133
|
+
'prFilter',
|
|
134
|
+
'prTitle',
|
|
135
|
+
'repoName',
|
|
136
|
+
'repoOwner',
|
|
137
|
+
'sha',
|
|
138
|
+
'sourceBranch',
|
|
139
|
+
'username',
|
|
140
|
+
];
|
|
141
|
+
// Disallow empty strings
|
|
142
|
+
optionKeys.forEach((optionName) => {
|
|
143
|
+
const option = options[optionName];
|
|
144
|
+
if (option === '') {
|
|
145
|
+
throw new HandledError_1.HandledError(`"${optionName}" cannot be empty!`);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function getMergedOptionsFromConfigAndCli({ optionsFromConfigFiles, optionsFromCliArgs, }) {
|
|
113
150
|
return {
|
|
114
151
|
...defaultConfigOptions,
|
|
115
152
|
...optionsFromConfigFiles,
|
|
116
153
|
...optionsFromCliArgs,
|
|
117
154
|
};
|
|
118
155
|
}
|
|
119
|
-
function requireTargetBranch(config) {
|
|
120
|
-
// ensure `targetBranches` or `targetBranchChoices` are given
|
|
121
|
-
if ((0, lodash_1.isEmpty)(config.targetBranches) &&
|
|
122
|
-
(0, lodash_1.isEmpty)(config.targetBranchChoices) &&
|
|
123
|
-
// this is primarily necessary on CI where `targetBranches` and `targetBranchChoices` and not given
|
|
124
|
-
(0, lodash_1.isEmpty)(config.branchLabelMapping)) {
|
|
125
|
-
throw new HandledError_1.HandledError(`Please specify a target branch: "--branch 6.1".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -62,11 +62,11 @@ describe('getOptions', () => {
|
|
|
62
62
|
});
|
|
63
63
|
await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects
|
|
64
64
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
66
|
+
It must contain a valid \\"accessToken\\".
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
69
|
+
`);
|
|
70
70
|
});
|
|
71
71
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
72
72
|
mockProjectConfig({
|
|
@@ -81,6 +81,23 @@ describe('getOptions', () => {
|
|
|
81
81
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
82
82
|
`);
|
|
83
83
|
});
|
|
84
|
+
describe('whe option is an empty string', () => {
|
|
85
|
+
it('throws for "username"', async () => {
|
|
86
|
+
await expect(() => (0, options_1.getOptions)([], { username: '', author: 'sqren' })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"username\\" cannot be empty!"`);
|
|
87
|
+
});
|
|
88
|
+
it('throws for "author"', async () => {
|
|
89
|
+
await expect(() => (0, options_1.getOptions)([], { author: '' })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
|
|
90
|
+
});
|
|
91
|
+
it('throws for "accessToken"', async () => {
|
|
92
|
+
await expect(() => (0, options_1.getOptions)([], { accessToken: '' })).rejects
|
|
93
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
94
|
+
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
95
|
+
It must contain a valid \\"accessToken\\".
|
|
96
|
+
|
|
97
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
98
|
+
`);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
84
101
|
describe('when repoName and repoOwner are missing', () => {
|
|
85
102
|
beforeEach(() => {
|
|
86
103
|
mockProjectConfig({ repoName: undefined, repoOwner: undefined });
|
|
@@ -89,10 +106,10 @@ describe('getOptions', () => {
|
|
|
89
106
|
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
90
107
|
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
91
108
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
92
|
-
|
|
109
|
+
"Please specify a repo name: \\"--repo-name kibana\\".
|
|
93
110
|
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
112
|
+
`);
|
|
96
113
|
});
|
|
97
114
|
it('should get repoName from the remote', async () => {
|
|
98
115
|
mockRepoOwnerAndName({
|
|
@@ -66,8 +66,8 @@ function getCommentBody({ options, pullNumber, backportResponse, }) {
|
|
|
66
66
|
if (backportResponse.error instanceof HandledError_1.HandledError &&
|
|
67
67
|
backportResponse.error.errorContext?.code === 'no-branches-exception') {
|
|
68
68
|
return `## ⚪ Backport skipped
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
|
|
70
|
+
${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
71
71
|
}
|
|
72
72
|
return `## 💔 Backport failed
|
|
73
73
|
The pull request could not be backported due to the following error:
|
|
@@ -365,8 +365,8 @@ describe('getCommentBody', () => {
|
|
|
365
365
|
const params = getParams({ ci: true });
|
|
366
366
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
367
367
|
"## ⚪ Backport skipped
|
|
368
|
-
|
|
369
|
-
|
|
368
|
+
The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
|
|
369
|
+
|
|
370
370
|
### Manual backport
|
|
371
371
|
To create the backport manually run:
|
|
372
372
|
\`\`\`
|
|
@@ -9,10 +9,6 @@ const logger_1 = require("../../../logger");
|
|
|
9
9
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
10
10
|
const throwOnInvalidAccessToken_1 = require("../throwOnInvalidAccessToken");
|
|
11
11
|
const query_1 = require("./query");
|
|
12
|
-
// fetches the default source branch for the repo (normally "master")
|
|
13
|
-
// startup checks:
|
|
14
|
-
// - verify the access token
|
|
15
|
-
// - ensure no branch named "backport" exists
|
|
16
12
|
async function getOptionsFromGithub(options) {
|
|
17
13
|
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
18
14
|
let res;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "6.3.0-beta-
|
|
1
|
+
export declare const PACKAGE_VERSION = "6.3.0-beta-10";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
exports.PACKAGE_VERSION = "6.3.0-beta-7";
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"branches",
|
|
15
15
|
"branching"
|
|
16
16
|
],
|
|
17
|
-
"version": "6.3.0-beta-
|
|
17
|
+
"version": "6.3.0-beta-10",
|
|
18
18
|
"main": "./dist/entrypoint.module.js",
|
|
19
19
|
"types": "dist/entrypoint.module.d.ts",
|
|
20
20
|
"bin": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"postinstall": "test -f ./dist/scripts/runPostinstall.js && node ./dist/scripts/runPostinstall.js || echo 'Dist folder missing'",
|
|
26
|
-
"
|
|
26
|
+
"version": "echo \"Bumping version\" && yarn extractPackageVersion && git add src/utils/packageVersion.ts && yarn build",
|
|
27
27
|
"prepare": "husky install",
|
|
28
|
-
"prepublishOnly": "yarn
|
|
28
|
+
"prepublishOnly": "yarn lint",
|
|
29
29
|
"build": "tsc --project ./tsconfig.prod.json",
|
|
30
30
|
"extractPackageVersion": "node -p \"'export const PACKAGE_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" | prettier > src/utils/packageVersion.ts",
|
|
31
|
-
"lint": "tsc --project ./tsconfig.test.json && eslint './**/*.{ts,js}'",
|
|
31
|
+
"lint": "echo \"Running lint\" && tsc --project ./tsconfig.test.json && eslint './**/*.{ts,js}'",
|
|
32
32
|
"start": "ts-node --transpile-only ./src/entrypoint.cli.ts",
|
|
33
33
|
"test-all": "yarn lint && jest --config ./jest.config.all.js",
|
|
34
34
|
"test-mutation": "jest --config ./jest.config.mutation.js",
|