backport 6.1.3 → 6.2.1
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 +40 -37
- package/dist/backportRun.d.ts +14 -0
- package/dist/backportRun.js +75 -0
- package/dist/entrypoint.api.d.ts +22 -0
- package/dist/entrypoint.api.js +57 -0
- package/dist/entrypoint.api.private.test.d.ts +1 -0
- package/dist/entrypoint.api.private.test.js +37 -0
- package/dist/entrypoint.cli.js +3 -5
- package/dist/entrypoint.module.d.ts +6 -3
- package/dist/entrypoint.module.js +13 -7
- package/dist/entrypoint.module.private.test.js +4 -1
- package/dist/main.js +5 -1
- package/dist/options/ConfigOptions.d.ts +4 -0
- package/dist/options/cliArgs.d.ts +17 -11
- package/dist/options/cliArgs.js +36 -5
- package/dist/options/config/config.d.ts +10 -1
- package/dist/options/config/config.js +9 -3
- package/dist/options/config/config.test.js +27 -1
- package/dist/options/config/getProjectConfig.d.ts +0 -0
- package/dist/options/config/getProjectConfig.js +1 -0
- package/dist/options/config/globalConfig.d.ts +2 -2
- package/dist/options/config/globalConfig.js +16 -14
- package/dist/options/config/globalConfig.test.js +10 -4
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/projectConfig.test.js +35 -6
- package/dist/options/config/readConfigFile.d.ts +26 -22
- package/dist/options/options.d.ts +18 -9
- package/dist/options/options.js +11 -4
- package/dist/options/options.test.js +40 -35
- package/dist/react-components/0-loadOptions.d.ts +6 -0
- package/dist/react-components/0-loadOptions.js +45 -0
- package/dist/react-components/1-loadCommit.d.ts +8 -0
- package/dist/react-components/1-loadCommit.js +88 -0
- package/dist/react-components/1a-loadCommit.d.ts +5 -0
- package/dist/react-components/1a-loadCommit.js +76 -0
- package/dist/react-components/1b-commitChoices.d.ts +5 -0
- package/dist/react-components/1b-commitChoices.js +98 -0
- package/dist/react-components/2-commitChoices.d.ts +8 -0
- package/dist/react-components/2-commitChoices.js +96 -0
- package/dist/react-components/2-commitsPrompt.d.ts +8 -0
- package/dist/react-components/2-commitsPrompt.js +96 -0
- package/dist/react-components/2-targetBranchChoices.d.ts +9 -0
- package/dist/react-components/2-targetBranchChoices.js +109 -0
- package/dist/react-components/3-cherrypick.d.ts +1 -0
- package/dist/react-components/3-cherrypick.js +2 -0
- package/dist/react-components/App.d.ts +2 -0
- package/dist/react-components/App.js +35 -0
- package/dist/react-components/BackportStateContext.d.ts +33 -0
- package/dist/react-components/BackportStateContext.js +42 -0
- package/dist/react-components/CommitPrompt/2-commitsPrompt.d.ts +8 -0
- package/dist/react-components/CommitPrompt/2-commitsPrompt.js +96 -0
- package/dist/react-components/CommitPrompt/CommitPrompt.d.ts +8 -0
- package/dist/react-components/CommitPrompt/CommitPrompt.js +96 -0
- package/dist/react-components/CommitPrompt/getCommits.d.ts +2 -0
- package/dist/react-components/CommitPrompt/getCommits.js +27 -0
- package/dist/react-components/CommitPrompt.d.ts +8 -0
- package/dist/react-components/CommitPrompt.js +96 -0
- package/dist/react-components/CustomMultiSelect.d.ts +13 -0
- package/dist/react-components/CustomMultiSelect.js +21 -0
- package/dist/react-components/CustomMultiSelectItem.d.ts +5 -0
- package/dist/react-components/CustomMultiSelectItem.js +12 -0
- package/dist/react-components/CustomSelect.d.ts +14 -0
- package/dist/react-components/CustomSelect.js +34 -0
- package/dist/react-components/ErrorBoundary.d.ts +15 -0
- package/dist/react-components/ErrorBoundary.js +53 -0
- package/dist/react-components/MultiSelect.d.ts +7 -0
- package/dist/react-components/MultiSelect.js +16 -0
- package/dist/react-components/hooks/useAsync.d.ts +12 -0
- package/dist/react-components/hooks/useAsync.js +73 -0
- package/dist/runSequentially.test.js +11 -13
- package/dist/scripts/postinstall.js +3 -3
- package/dist/services/HandledError.d.ts +1 -1
- package/dist/services/backportRun/backportRun.ci.d.ts +6 -0
- package/dist/services/backportRun/backportRun.ci.js +81 -0
- package/dist/services/backportRun/backportRun.d.ts +14 -0
- package/dist/services/backportRun/backportRun.interactive.d.ts +1 -0
- package/dist/services/backportRun/backportRun.interactive.js +4 -0
- package/dist/services/backportRun/backportRun.js +14 -0
- package/dist/services/backportRun/backportState.d.ts +4 -0
- package/dist/services/backportRun/backportState.js +28 -0
- package/dist/services/backportRun/getCommits.d.ts +2 -0
- package/dist/services/backportRun/getCommits.js +20 -0
- package/dist/services/backportRun/runSequentially.d.ts +20 -0
- package/dist/services/backportRun/runSequentially.js +41 -0
- package/dist/services/backportRun/runSequentially.test.d.ts +1 -0
- package/dist/services/backportRun/runSequentially.test.js +199 -0
- package/dist/services/cherrypickAndCreateTargetPullRequest.d.ts +12 -0
- package/dist/services/cherrypickAndCreateTargetPullRequest.js +206 -0
- package/dist/services/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/services/cherrypickAndCreateTargetPullRequest.test.js +403 -0
- package/dist/services/env.d.ts +5 -4
- package/dist/services/env.js +13 -11
- package/dist/services/env.test.js +0 -6
- package/dist/services/getCommits.d.ts +2 -0
- package/dist/services/getCommits.js +38 -0
- package/dist/services/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/services/getCommitsWithoutBackports.js +68 -0
- package/dist/services/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/services/getCommitsWithoutBackports.test.js +259 -0
- package/dist/services/getTargetBranches.d.ts +5 -0
- package/dist/services/getTargetBranches.js +60 -0
- package/dist/services/getTargetBranches.test.d.ts +1 -0
- package/dist/services/getTargetBranches.test.js +180 -0
- package/dist/services/git.d.ts +2 -1
- package/dist/services/git.js +5 -3
- package/dist/services/github/v3/createPullRequest.js +8 -5
- package/dist/services/github/v3/createPullRequest.test.js +60 -10
- package/dist/services/github/v3/createStatusComment.d.ts +2 -2
- package/dist/services/github/v3/createStatusComment.js +40 -15
- package/dist/services/github/v3/createStatusComment.test.js +174 -86
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +78 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +64 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +5 -5
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +60 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +2 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +17 -10
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +72 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +6 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +8 -7
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +8 -0
- package/dist/services/github/v4/fetchProjectConfig.d.ts +1 -1
- package/dist/services/github/v4/fetchProjectConfig.js +3 -3
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +5 -5
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +56 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +4 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -7
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +16 -5
- package/dist/services/logger.d.ts +4 -2
- package/dist/services/logger.js +31 -32
- package/dist/services/maybeSetupRepo.d.ts +2 -0
- package/dist/services/maybeSetupRepo.js +33 -0
- package/dist/services/maybeSetupRepo.test.d.ts +1 -0
- package/dist/services/maybeSetupRepo.test.js +78 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +8 -2
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +20 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +1 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +72 -46
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +22 -8
- package/dist/services/sourceCommit/parseSourceCommit.js +29 -10
- package/dist/services/sourceCommit/parseSourceCommit.test.js +10 -2
- package/dist/test/backport-e2e.private.test.d.ts +1 -0
- package/dist/test/backport-e2e.private.test.js +325 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +1 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +43 -0
- package/dist/test/inquirer.private.test.js +3 -1
- package/dist/test/integration/integration.private.test.js +2 -2
- package/dist/test/nockHelpers.js +1 -3
- package/dist/test/setupFiles/automatic-mocks.js +1 -0
- package/dist/todo-delete.d.ts +1 -0
- package/dist/todo-delete.js +17 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +4 -3
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +9 -12
- package/dist/ui/getCommits.js +1 -1
- package/dist/ui/getCommitsWithoutBackports.js +17 -2
- package/dist/ui/maybeSetupRepo.js +0 -6
- package/dist/ui/maybeSetupRepo.test.js +8 -4
- package/dist/utils/redact.d.ts +1 -0
- package/dist/utils/redact.js +7 -0
- package/dist/utils/sequentially.d.ts +1 -0
- package/dist/utils/sequentially.js +10 -0
- package/package.json +11 -11
- package/yarn.lock +570 -436
|
@@ -22,7 +22,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const os_1 = __importDefault(require("os"));
|
|
25
26
|
const nock_1 = __importDefault(require("nock"));
|
|
27
|
+
const fs = __importStar(require("../services/fs-promisified"));
|
|
26
28
|
const logger = __importStar(require("../services/logger"));
|
|
27
29
|
const mockConfigFiles_1 = require("../test/mockConfigFiles");
|
|
28
30
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
@@ -45,6 +47,9 @@ describe('getOptions', () => {
|
|
|
45
47
|
});
|
|
46
48
|
beforeEach(() => {
|
|
47
49
|
(0, mockConfigFiles_1.mockConfigFiles)(defaultConfigs);
|
|
50
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
51
|
+
jest.spyOn(fs, 'writeFile').mockResolvedValue();
|
|
52
|
+
jest.spyOn(fs, 'chmod').mockResolvedValue();
|
|
48
53
|
});
|
|
49
54
|
describe('should throw', () => {
|
|
50
55
|
beforeEach(() => {
|
|
@@ -55,13 +60,13 @@ describe('getOptions', () => {
|
|
|
55
60
|
projectConfig: defaultConfigs.projectConfig,
|
|
56
61
|
globalConfig: { accessToken: undefined },
|
|
57
62
|
});
|
|
58
|
-
await expect(() => (0, options_1.getOptions)([])).rejects
|
|
63
|
+
await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects
|
|
59
64
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
66
|
+
It must contain a valid \\"accessToken\\".
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
69
|
+
`);
|
|
65
70
|
});
|
|
66
71
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
67
72
|
mockProjectConfig({
|
|
@@ -69,7 +74,7 @@ describe('getOptions', () => {
|
|
|
69
74
|
targetBranchChoices: undefined,
|
|
70
75
|
branchLabelMapping: undefined,
|
|
71
76
|
});
|
|
72
|
-
await expect(() => (0, options_1.getOptions)([])).rejects
|
|
77
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
73
78
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
74
79
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
75
80
|
|
|
@@ -78,7 +83,7 @@ describe('getOptions', () => {
|
|
|
78
83
|
});
|
|
79
84
|
it('when repoName is missing', async () => {
|
|
80
85
|
mockProjectConfig({ repoName: '' });
|
|
81
|
-
await expect(() => (0, options_1.getOptions)([])).rejects
|
|
86
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
82
87
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
83
88
|
"Please specify a repo name: \\"--repo-name kibana\\".
|
|
84
89
|
|
|
@@ -87,7 +92,7 @@ describe('getOptions', () => {
|
|
|
87
92
|
});
|
|
88
93
|
it('when repoOwner is missing', async () => {
|
|
89
94
|
mockProjectConfig({ repoOwner: '' });
|
|
90
|
-
await expect(() => (0, options_1.getOptions)([])).rejects
|
|
95
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
91
96
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
92
97
|
"Please specify a repo owner: \\"--repo-owner elastic\\".
|
|
93
98
|
|
|
@@ -97,7 +102,7 @@ describe('getOptions', () => {
|
|
|
97
102
|
});
|
|
98
103
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
99
104
|
mockGithubConfigOptions({ refName: 'backport' });
|
|
100
|
-
await expect((0, options_1.getOptions)([])).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
105
|
+
await expect((0, options_1.getOptions)([], {})).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
101
106
|
});
|
|
102
107
|
it('should merge config options and module options', async () => {
|
|
103
108
|
mockGithubConfigOptions({});
|
|
@@ -107,7 +112,7 @@ describe('getOptions', () => {
|
|
|
107
112
|
});
|
|
108
113
|
it('should call updateLogger', async () => {
|
|
109
114
|
mockGithubConfigOptions({});
|
|
110
|
-
await (0, options_1.getOptions)([]);
|
|
115
|
+
await (0, options_1.getOptions)([], {});
|
|
111
116
|
expect(logger.updateLogger).toHaveBeenCalledTimes(1);
|
|
112
117
|
});
|
|
113
118
|
it('should return options', async () => {
|
|
@@ -121,12 +126,13 @@ describe('getOptions', () => {
|
|
|
121
126
|
},
|
|
122
127
|
],
|
|
123
128
|
});
|
|
124
|
-
const options = await (0, options_1.getOptions)([]);
|
|
129
|
+
const options = await (0, options_1.getOptions)([], {});
|
|
125
130
|
expect(options).toEqual({
|
|
126
131
|
accessToken: 'abc',
|
|
127
132
|
assignees: [],
|
|
128
|
-
autoAssign: false,
|
|
129
133
|
authenticatedUsername: 'john.diller',
|
|
134
|
+
author: 'john.diller',
|
|
135
|
+
autoAssign: false,
|
|
130
136
|
autoMerge: false,
|
|
131
137
|
autoMergeMethod: 'merge',
|
|
132
138
|
backportBinary: 'backport',
|
|
@@ -136,6 +142,8 @@ describe('getOptions', () => {
|
|
|
136
142
|
cherrypickRef: true,
|
|
137
143
|
ci: false,
|
|
138
144
|
commitPaths: [],
|
|
145
|
+
dateSince: null,
|
|
146
|
+
dateUntil: null,
|
|
139
147
|
details: false,
|
|
140
148
|
editor: 'code',
|
|
141
149
|
fork: true,
|
|
@@ -150,6 +158,7 @@ describe('getOptions', () => {
|
|
|
150
158
|
multipleBranches: true,
|
|
151
159
|
multipleCommits: false,
|
|
152
160
|
noVerify: true,
|
|
161
|
+
publishStatusComment: true,
|
|
153
162
|
repoName: 'kibana',
|
|
154
163
|
repoOwner: 'elastic',
|
|
155
164
|
resetAuthor: false,
|
|
@@ -159,7 +168,6 @@ describe('getOptions', () => {
|
|
|
159
168
|
targetBranchChoices: ['7.9', '8.0'],
|
|
160
169
|
targetBranches: [],
|
|
161
170
|
targetPRLabels: [],
|
|
162
|
-
author: 'john.diller',
|
|
163
171
|
verbose: false,
|
|
164
172
|
});
|
|
165
173
|
});
|
|
@@ -168,14 +176,11 @@ describe('getOptions', () => {
|
|
|
168
176
|
mockGithubConfigOptions({ defaultBranchRef: 'some-default-branch' });
|
|
169
177
|
});
|
|
170
178
|
it('uses the `defaultBranchRef` as default', async () => {
|
|
171
|
-
const options = await (0, options_1.getOptions)([]);
|
|
179
|
+
const options = await (0, options_1.getOptions)([], {});
|
|
172
180
|
expect(options.sourceBranch).toBe('some-default-branch');
|
|
173
181
|
});
|
|
174
182
|
it('uses the sourceBranch given via cli instead of `defaultBranchRef`', async () => {
|
|
175
|
-
const options = await (0, options_1.getOptions)([
|
|
176
|
-
'--source-branch',
|
|
177
|
-
'cli-source-branch',
|
|
178
|
-
]);
|
|
183
|
+
const options = await (0, options_1.getOptions)(['--source-branch', 'cli-source-branch'], {});
|
|
179
184
|
expect(options.sourceBranch).toBe('cli-source-branch');
|
|
180
185
|
});
|
|
181
186
|
});
|
|
@@ -184,16 +189,16 @@ describe('getOptions', () => {
|
|
|
184
189
|
mockGithubConfigOptions({});
|
|
185
190
|
});
|
|
186
191
|
it('is enabled by default', async () => {
|
|
187
|
-
const { fork } = await (0, options_1.getOptions)([]);
|
|
192
|
+
const { fork } = await (0, options_1.getOptions)([], {});
|
|
188
193
|
expect(fork).toBe(true);
|
|
189
194
|
});
|
|
190
195
|
it('can be disabled via `--no-fork` flag', async () => {
|
|
191
|
-
const { fork } = await (0, options_1.getOptions)(['--no-fork']);
|
|
196
|
+
const { fork } = await (0, options_1.getOptions)(['--no-fork'], {});
|
|
192
197
|
expect(fork).toBe(false);
|
|
193
198
|
});
|
|
194
199
|
it('can be disabled via config file', async () => {
|
|
195
200
|
mockProjectConfig({ fork: false });
|
|
196
|
-
const { fork } = await (0, options_1.getOptions)([]);
|
|
201
|
+
const { fork } = await (0, options_1.getOptions)([], {});
|
|
197
202
|
expect(fork).toBe(false);
|
|
198
203
|
});
|
|
199
204
|
});
|
|
@@ -202,12 +207,12 @@ describe('getOptions', () => {
|
|
|
202
207
|
mockGithubConfigOptions({});
|
|
203
208
|
});
|
|
204
209
|
it('can be set via `--reviewer` flag', async () => {
|
|
205
|
-
const { reviewers } = await (0, options_1.getOptions)(['--reviewer', 'peter']);
|
|
210
|
+
const { reviewers } = await (0, options_1.getOptions)(['--reviewer', 'peter'], {});
|
|
206
211
|
expect(reviewers).toEqual(['peter']);
|
|
207
212
|
});
|
|
208
213
|
it('can be set via config file', async () => {
|
|
209
214
|
mockProjectConfig({ reviewers: ['john'] });
|
|
210
|
-
const { reviewers } = await (0, options_1.getOptions)([]);
|
|
215
|
+
const { reviewers } = await (0, options_1.getOptions)([], {});
|
|
211
216
|
expect(reviewers).toEqual(['john']);
|
|
212
217
|
});
|
|
213
218
|
});
|
|
@@ -216,15 +221,15 @@ describe('getOptions', () => {
|
|
|
216
221
|
mockGithubConfigOptions({});
|
|
217
222
|
});
|
|
218
223
|
it('is not enabled by default', async () => {
|
|
219
|
-
const { mainline } = await (0, options_1.getOptions)([]);
|
|
224
|
+
const { mainline } = await (0, options_1.getOptions)([], {});
|
|
220
225
|
expect(mainline).toBe(undefined);
|
|
221
226
|
});
|
|
222
227
|
it('can be set via `--mainline` flag', async () => {
|
|
223
|
-
const { mainline } = await (0, options_1.getOptions)(['--mainline']);
|
|
228
|
+
const { mainline } = await (0, options_1.getOptions)(['--mainline'], {});
|
|
224
229
|
expect(mainline).toBe(1);
|
|
225
230
|
});
|
|
226
231
|
it('accepts numeric values', async () => {
|
|
227
|
-
const { mainline } = await (0, options_1.getOptions)(['--mainline', '2']);
|
|
232
|
+
const { mainline } = await (0, options_1.getOptions)(['--mainline', '2'], {});
|
|
228
233
|
expect(mainline).toBe(2);
|
|
229
234
|
});
|
|
230
235
|
});
|
|
@@ -233,25 +238,25 @@ describe('getOptions', () => {
|
|
|
233
238
|
mockGithubConfigOptions({ viewerLogin: 'billy.bob' });
|
|
234
239
|
});
|
|
235
240
|
it('defaults to authenticated user', async () => {
|
|
236
|
-
const { author } = await (0, options_1.getOptions)([]);
|
|
241
|
+
const { author } = await (0, options_1.getOptions)([], {});
|
|
237
242
|
expect(author).toBe('billy.bob');
|
|
238
243
|
});
|
|
239
244
|
it('can be overridden via `--author` flag', async () => {
|
|
240
|
-
const { author } = await (0, options_1.getOptions)(['--author', 'john.doe']);
|
|
245
|
+
const { author } = await (0, options_1.getOptions)(['--author', 'john.doe'], {});
|
|
241
246
|
expect(author).toBe('john.doe');
|
|
242
247
|
});
|
|
243
248
|
it('can be reset via `--all` flag', async () => {
|
|
244
|
-
const { author } = await (0, options_1.getOptions)(['--all']);
|
|
249
|
+
const { author } = await (0, options_1.getOptions)(['--all'], {});
|
|
245
250
|
expect(author).toBe(null);
|
|
246
251
|
});
|
|
247
252
|
it('can be reset via config file (similar to `--all` flag)', async () => {
|
|
248
253
|
mockProjectConfig({ author: null });
|
|
249
|
-
const { author } = await (0, options_1.getOptions)([]);
|
|
254
|
+
const { author } = await (0, options_1.getOptions)([], {});
|
|
250
255
|
expect(author).toBe(null);
|
|
251
256
|
});
|
|
252
257
|
it('can be overridden via config file', async () => {
|
|
253
258
|
mockProjectConfig({ author: 'jane.doe' });
|
|
254
|
-
const { author } = await (0, options_1.getOptions)([]);
|
|
259
|
+
const { author } = await (0, options_1.getOptions)([], {});
|
|
255
260
|
expect(author).toBe('jane.doe');
|
|
256
261
|
});
|
|
257
262
|
});
|
|
@@ -260,21 +265,21 @@ describe('getOptions', () => {
|
|
|
260
265
|
mockGithubConfigOptions({});
|
|
261
266
|
});
|
|
262
267
|
it('should default to true', async () => {
|
|
263
|
-
const { cherrypickRef } = await (0, options_1.getOptions)([]);
|
|
268
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([], {});
|
|
264
269
|
expect(cherrypickRef).toBe(true);
|
|
265
270
|
});
|
|
266
271
|
it('should negate with `noCherrypickRef` cli arg', async () => {
|
|
267
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref']);
|
|
272
|
+
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref'], {});
|
|
268
273
|
expect(cherrypickRef).toBe(false);
|
|
269
274
|
});
|
|
270
275
|
it('should be settable via config file', async () => {
|
|
271
276
|
mockProjectConfig({ cherrypickRef: false });
|
|
272
|
-
const { cherrypickRef } = await (0, options_1.getOptions)([]);
|
|
277
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([], {});
|
|
273
278
|
expect(cherrypickRef).toBe(false);
|
|
274
279
|
});
|
|
275
280
|
it('cli args overwrites config', async () => {
|
|
276
281
|
mockProjectConfig({ cherrypickRef: false });
|
|
277
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--cherrypick-ref']);
|
|
282
|
+
const { cherrypickRef } = await (0, options_1.getOptions)(['--cherrypick-ref'], {});
|
|
278
283
|
expect(cherrypickRef).toBe(true);
|
|
279
284
|
});
|
|
280
285
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.LoadOptions = void 0;
|
|
26
|
+
const ink_1 = require("ink");
|
|
27
|
+
const ink_spinner_1 = __importDefault(require("ink-spinner"));
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const options_1 = require("../options/options");
|
|
30
|
+
const BackportStateContext_1 = require("./BackportStateContext");
|
|
31
|
+
function LoadOptions({ argv, optionsFromModule, }) {
|
|
32
|
+
const { setBackportView } = (0, BackportStateContext_1.useBackportStateContext)();
|
|
33
|
+
(0, react_1.useEffect)(() => {
|
|
34
|
+
(0, options_1.getOptions)(argv, optionsFromModule).then((options) => {
|
|
35
|
+
setBackportView({
|
|
36
|
+
viewName: '1a-load-single-commit',
|
|
37
|
+
options,
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}, [argv, optionsFromModule, setBackportView]);
|
|
41
|
+
return (react_1.default.createElement(ink_1.Text, null,
|
|
42
|
+
react_1.default.createElement(ink_spinner_1.default, { type: "dots" }),
|
|
43
|
+
"\u00A0Initializing..."));
|
|
44
|
+
}
|
|
45
|
+
exports.LoadOptions = LoadOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AsyncStatus } from '../hooks/useAsync';
|
|
3
|
+
import { ValidConfigOptions } from '../options/options';
|
|
4
|
+
export declare function CommitPrompt({ options, optionsStatus, optionsError, }: {
|
|
5
|
+
options?: ValidConfigOptions;
|
|
6
|
+
optionsStatus: AsyncStatus;
|
|
7
|
+
optionsError: Error | null;
|
|
8
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.CommitPrompt = void 0;
|
|
26
|
+
const ink_multi_select_1 = __importDefault(require("ink-multi-select"));
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
const useAsync_1 = require("../hooks/useAsync");
|
|
29
|
+
const fetchCommitByPullNumber_1 = require("../services/github/v4/fetchCommits/fetchCommitByPullNumber");
|
|
30
|
+
const fetchCommitBySha_1 = require("../services/github/v4/fetchCommits/fetchCommitBySha");
|
|
31
|
+
const logger_1 = require("../services/logger");
|
|
32
|
+
const BackportStateContext_1 = require("./BackportStateContext");
|
|
33
|
+
function CommitPrompt({ options, optionsStatus, optionsError, }) {
|
|
34
|
+
const { setBackportState } = (0, BackportStateContext_1.useBackportStateContext)();
|
|
35
|
+
const [choices, setChoices] = (0, react_1.useState)([]);
|
|
36
|
+
const [loadingStatus, setLoadingStatus] = (0, react_1.useState)('loading');
|
|
37
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
async function fetch() {
|
|
40
|
+
if (!options) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const commit = await getCommit(options);
|
|
44
|
+
if (commit) {
|
|
45
|
+
setBackportState({
|
|
46
|
+
view: '3-target-branches-prompt',
|
|
47
|
+
commits: [commit],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
fetch()
|
|
52
|
+
.then(() => {
|
|
53
|
+
setLoadingStatus('success');
|
|
54
|
+
})
|
|
55
|
+
.catch((e) => {
|
|
56
|
+
setLoadingStatus('failure');
|
|
57
|
+
setError(e);
|
|
58
|
+
});
|
|
59
|
+
}, [options]);
|
|
60
|
+
// console.log({ optionsStatus, loadingStatus });
|
|
61
|
+
if (optionsStatus !== 'success') {
|
|
62
|
+
return (react_1.default.createElement(useAsync_1.ShowAsyncStatus, { text: "Initializing", status: optionsStatus, error: optionsError }));
|
|
63
|
+
}
|
|
64
|
+
if (loadingStatus !== 'success') {
|
|
65
|
+
return (react_1.default.createElement(useAsync_1.ShowAsyncStatus, { text: "Loading commits", status: loadingStatus, error: error }));
|
|
66
|
+
}
|
|
67
|
+
logger_1.logger.info(`tester: ${optionsStatus}, ${loadingStatus}, ${choices.length}`);
|
|
68
|
+
const handleSubmit = (items) => {
|
|
69
|
+
console.log(items);
|
|
70
|
+
};
|
|
71
|
+
const items = choices.map((c) => ({
|
|
72
|
+
label: c.originalMessage,
|
|
73
|
+
value: c.originalMessage,
|
|
74
|
+
}));
|
|
75
|
+
return react_1.default.createElement(ink_multi_select_1.default, { items: items, onSubmit: handleSubmit });
|
|
76
|
+
}
|
|
77
|
+
exports.CommitPrompt = CommitPrompt;
|
|
78
|
+
function getCommit(options) {
|
|
79
|
+
if (options.sha) {
|
|
80
|
+
return (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha: options.sha });
|
|
81
|
+
}
|
|
82
|
+
if (options.pullNumber) {
|
|
83
|
+
return (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
84
|
+
...options,
|
|
85
|
+
pullNumber: options.pullNumber, // must extract pullNumber to satisfy the ts gods
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.LoadCommit = void 0;
|
|
26
|
+
const ink_1 = require("ink");
|
|
27
|
+
const ink_spinner_1 = __importDefault(require("ink-spinner"));
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const commitFormatters_1 = require("../services/github/commitFormatters");
|
|
30
|
+
const fetchCommitByPullNumber_1 = require("../services/github/v4/fetchCommits/fetchCommitByPullNumber");
|
|
31
|
+
const fetchCommitBySha_1 = require("../services/github/v4/fetchCommits/fetchCommitBySha");
|
|
32
|
+
const BackportStateContext_1 = require("./BackportStateContext");
|
|
33
|
+
function LoadCommit({ options }) {
|
|
34
|
+
const [fetchError, setFetchError] = (0, react_1.useState)(null);
|
|
35
|
+
const { setBackportView } = (0, BackportStateContext_1.useBackportStateContext)();
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
getCommit(options)
|
|
38
|
+
.then((commit) => {
|
|
39
|
+
if (commit) {
|
|
40
|
+
setBackportView({
|
|
41
|
+
viewName: '2-target-branches-prompt',
|
|
42
|
+
options,
|
|
43
|
+
commits: [commit],
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setBackportView({
|
|
48
|
+
viewName: '1b-display-commit-choices',
|
|
49
|
+
options,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.catch((e) => setFetchError(e));
|
|
54
|
+
}, [options, setBackportView]);
|
|
55
|
+
if (fetchError) {
|
|
56
|
+
return react_1.default.createElement(ink_1.Text, null, fetchError.message);
|
|
57
|
+
}
|
|
58
|
+
return (react_1.default.createElement(ink_1.Text, null,
|
|
59
|
+
react_1.default.createElement(ink_spinner_1.default, { type: "dots" }),
|
|
60
|
+
"\u00A0",
|
|
61
|
+
options.sha
|
|
62
|
+
? `Loading commit ${(0, commitFormatters_1.getShortSha)(options.sha)}`
|
|
63
|
+
: `Loading pull request #${options.pullNumber}`));
|
|
64
|
+
}
|
|
65
|
+
exports.LoadCommit = LoadCommit;
|
|
66
|
+
async function getCommit(options) {
|
|
67
|
+
if (options.sha) {
|
|
68
|
+
return (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha: options.sha });
|
|
69
|
+
}
|
|
70
|
+
if (options.pullNumber) {
|
|
71
|
+
return (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
72
|
+
...options,
|
|
73
|
+
pullNumber: options.pullNumber, // must extract pullNumber to satisfy the ts gods
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.CommitChoices = void 0;
|
|
26
|
+
const ink_1 = require("ink");
|
|
27
|
+
const ink_spinner_1 = __importDefault(require("ink-spinner"));
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const commitFormatters_1 = require("../services/github/commitFormatters");
|
|
30
|
+
const fetchCommitsByAuthor_1 = require("../services/github/v4/fetchCommits/fetchCommitsByAuthor");
|
|
31
|
+
const fetchPullRequestBySearchQuery_1 = require("../services/github/v4/fetchCommits/fetchPullRequestBySearchQuery");
|
|
32
|
+
const BackportStateContext_1 = require("./BackportStateContext");
|
|
33
|
+
const CustomSelect_1 = require("./CustomSelect");
|
|
34
|
+
function CommitChoices({ options }) {
|
|
35
|
+
const { setBackportView } = (0, BackportStateContext_1.useBackportStateContext)();
|
|
36
|
+
const [choices, setChoices] = (0, react_1.useState)([]);
|
|
37
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
38
|
+
const [fetchError, setFetchError] = (0, react_1.useState)(null);
|
|
39
|
+
const [showHint, setShowHint] = (0, react_1.useState)(false);
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
async function fetch() {
|
|
42
|
+
try {
|
|
43
|
+
setIsLoading(true);
|
|
44
|
+
const commitChoices = options.prFilter
|
|
45
|
+
? await (0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)(options)
|
|
46
|
+
: await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(options);
|
|
47
|
+
setChoices(commitChoices);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
setFetchError(e);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setIsLoading(false);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
fetch();
|
|
57
|
+
}, [options]);
|
|
58
|
+
if (isLoading) {
|
|
59
|
+
return (react_1.default.createElement(ink_1.Text, null,
|
|
60
|
+
react_1.default.createElement(ink_spinner_1.default, { type: "dots" }),
|
|
61
|
+
"\u00A0",
|
|
62
|
+
options.prFilter
|
|
63
|
+
? 'Loading pull requests matching filter'
|
|
64
|
+
: `Loading commits from branch "${options.sourceBranch}"...`));
|
|
65
|
+
}
|
|
66
|
+
if (fetchError) {
|
|
67
|
+
return react_1.default.createElement(ink_1.Text, null, fetchError.message);
|
|
68
|
+
}
|
|
69
|
+
const onMultiSubmit = (selectedItems) => {
|
|
70
|
+
if (selectedItems.length === 0) {
|
|
71
|
+
setShowHint(true);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const commits = selectedItems.map((item) => item.value);
|
|
75
|
+
setBackportView({
|
|
76
|
+
viewName: '2-target-branches-prompt',
|
|
77
|
+
options,
|
|
78
|
+
commits,
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const onSingleSelect = (selectedItem) => {
|
|
82
|
+
const commit = selectedItem.value;
|
|
83
|
+
setBackportView({
|
|
84
|
+
viewName: '2-target-branches-prompt',
|
|
85
|
+
options,
|
|
86
|
+
commits: [commit],
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const items = choices.map((c) => ({
|
|
90
|
+
label: (0, commitFormatters_1.getFirstLine)(c.originalMessage),
|
|
91
|
+
value: c,
|
|
92
|
+
key: c.originalMessage,
|
|
93
|
+
}));
|
|
94
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
95
|
+
showHint ? react_1.default.createElement(ink_1.Text, null, "Please use space to select an item") : null,
|
|
96
|
+
react_1.default.createElement(CustomSelect_1.CustomSelect, { isMultiSelect: options.multipleCommits, items: items, onMultiSubmit: onMultiSubmit, onSingleSelect: onSingleSelect })));
|
|
97
|
+
}
|
|
98
|
+
exports.CommitChoices = CommitChoices;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ValidConfigOptions } from '../../options/options';
|
|
3
|
+
import { AsyncStatus } from '../hooks/useAsync';
|
|
4
|
+
export declare function CommitPrompt({ options, optionsStatus, optionsError, }: {
|
|
5
|
+
options?: ValidConfigOptions;
|
|
6
|
+
optionsStatus: AsyncStatus;
|
|
7
|
+
optionsError: Error | null;
|
|
8
|
+
}): JSX.Element;
|