backport 7.4.0 → 8.2.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 +15 -16
- package/dist/backportRun.d.ts +12 -6
- package/dist/backportRun.js +64 -62
- package/dist/entrypoint.cli.js +4 -8
- package/dist/entrypoint.module.d.ts +13 -6
- package/dist/entrypoint.module.js +14 -20
- package/dist/entrypoint.module.private.test.js +47 -346
- 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 +11 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +242 -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 +60 -0
- package/dist/lib/env.d.ts +9 -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 +210 -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 +138 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +566 -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/github/v4/validateTargetBranches.d.ts +14 -0
- package/dist/lib/github/v4/validateTargetBranches.js +46 -0
- package/dist/lib/github/v4/validateTargetBranches.private.test.d.ts +1 -0
- package/dist/lib/github/v4/validateTargetBranches.private.test.js +51 -0
- package/dist/lib/logger.d.ts +11 -0
- package/dist/lib/logger.js +80 -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 +4 -2
- package/dist/options/cliArgs.d.ts +14 -6
- package/dist/options/cliArgs.js +50 -22
- package/dist/options/cliArgs.test.js +128 -4
- package/dist/options/config/config.d.ts +5 -4
- package/dist/options/config/config.js +3 -5
- 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/readConfigFile.d.ts +5 -3
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +41 -5
- package/dist/options/options.js +24 -24
- package/dist/options/options.test.js +117 -55
- package/dist/runSequentially.d.ts +14 -9
- package/dist/runSequentially.js +27 -12
- 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 +2 -2
- package/dist/services/HandledError.js +7 -7
- 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 -123
- 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 -124
- 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 +16 -17
- package/dist/services/github/v3/createStatusComment.test.js +20 -9
- package/dist/services/github/v4/apiRequestV4.js +2 -2
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +5 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/services/logger.js +5 -1
- 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 +27 -25
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +53 -75
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +80 -0
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +199 -0
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +80 -0
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +198 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +28 -29
- 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.js +28 -21
- package/dist/test/handleUnbackportedPullRequests.private.test.js +11 -8
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +6 -2
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +4 -4
- 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 +19 -19
- package/yarn.lock +472 -701
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ The remaining documentation focuses on the Backport CLI tool (not the Github Act
|
|
|
33
33
|
npm install -g backport
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
After installation you should add an access token to the [global config](https://github.com/sqren/backport/blob/
|
|
36
|
+
After installation you should add an access token to the [global config](https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson) in `~/.backport/config.json`. See the [documentation](https://github.com/sqren/backport/blob/main/docs/configuration.md#accesstoken-required) for how the access token is generated.
|
|
37
37
|
|
|
38
38
|
## Quick start
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ After installation you should add an access token to the [global config](https:/
|
|
|
41
41
|
npm install backport
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Add a [project config](https://github.com/sqren/backport/blob/
|
|
44
|
+
Add a [project config](https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson) to the root of your repository:
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
47
|
// .backportrc.json
|
|
@@ -60,7 +60,7 @@ Add a [project config](https://github.com/sqren/backport/blob/master/docs/config
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Add personal access token to [global config](https://github.com/sqren/backport/blob/
|
|
63
|
+
Add personal access token to [global config](https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson):
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
66
|
// ~/.backport/config.json
|
|
@@ -79,7 +79,7 @@ _This will start an interactive prompt. You can use your keyboards arrow keys to
|
|
|
79
79
|
|
|
80
80
|
### Config options
|
|
81
81
|
|
|
82
|
-
See [configuration.md](https://github.com/sqren/backport/blob/
|
|
82
|
+
See [configuration.md](https://github.com/sqren/backport/blob/main/docs/configuration.md)
|
|
83
83
|
|
|
84
84
|
### CLI options
|
|
85
85
|
|
|
@@ -91,13 +91,13 @@ See [configuration.md](https://github.com/sqren/backport/blob/master/docs/config
|
|
|
91
91
|
| --author | | Filter commits by Github username. Opposite of `--all` | _Current user_ |
|
|
92
92
|
| --auto-assign | | Assign current user to the target PR | false |
|
|
93
93
|
| --branch | -b | Target branch to backport to | |
|
|
94
|
-
| --ci | | Disable interactive prompts | false |
|
|
95
94
|
| --config-file | | Custom path to project config file (.backportrc.json) | |
|
|
96
95
|
| --dir | | Clone repository into custom directory | ~/.backport/repositories/ |
|
|
97
96
|
| --dry-run | | Perform backport without pushing to Github | false |
|
|
98
97
|
| --editor | | Editor (eg. `code`) to open and resolve conflicts | nano |
|
|
99
98
|
| --fork | | Create backports in fork repo | true |
|
|
100
99
|
| --git-hostname | | Hostname for Git | github.com |
|
|
100
|
+
| --interactive | | Enable interactive prompts | true |
|
|
101
101
|
| --mainline | | Parent id of merge commit | 1 |
|
|
102
102
|
| --max-number | --number, -n | Number of commits to choose from | 10 |
|
|
103
103
|
| --multiple | | Multi-select for commits and branches | false |
|
|
@@ -124,7 +124,7 @@ See [configuration.md](https://github.com/sqren/backport/blob/master/docs/config
|
|
|
124
124
|
| --help | | Show help | |
|
|
125
125
|
| -v, --version | | Show version number | |
|
|
126
126
|
|
|
127
|
-
The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/
|
|
127
|
+
The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/main/docs/configuration.md).
|
|
128
128
|
|
|
129
129
|
## Backport Module API
|
|
130
130
|
|
|
@@ -153,8 +153,8 @@ Filter commits by pull request number
|
|
|
153
153
|
`sha` _string_<br/>
|
|
154
154
|
Filter commits by commit sha
|
|
155
155
|
|
|
156
|
-
`
|
|
157
|
-
|
|
156
|
+
`interactive` _boolean_<br/>
|
|
157
|
+
Enable interactive prompts
|
|
158
158
|
|
|
159
159
|
#### Example
|
|
160
160
|
|
|
@@ -162,14 +162,13 @@ Enabling this will disable the interactive prompts
|
|
|
162
162
|
import { backportRun } from 'backport';
|
|
163
163
|
|
|
164
164
|
const result = await backportRun({
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
autoMergeMethod: 'squash',
|
|
165
|
+
options: {
|
|
166
|
+
accessToken: 'very secret',
|
|
167
|
+
repoName: 'kibana',
|
|
168
|
+
repoOwner: 'elastic',
|
|
169
|
+
pullNumber: 121633,
|
|
170
|
+
interactive: false,
|
|
171
|
+
},
|
|
173
172
|
});
|
|
174
173
|
|
|
175
174
|
console.log(result);
|
package/dist/backportRun.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { BackportError } from './lib/BackportError';
|
|
2
|
+
import { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
3
|
import { ConfigFileOptions } from './options/ConfigOptions';
|
|
2
4
|
import { Result } from './runSequentially';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
export declare type BackportAbortResponse = {
|
|
6
|
+
status: 'aborted';
|
|
7
|
+
commits: Commit[];
|
|
8
|
+
error: BackportError;
|
|
9
|
+
errorMessage: string;
|
|
10
|
+
};
|
|
5
11
|
export declare type BackportSuccessResponse = {
|
|
6
12
|
status: 'success';
|
|
7
13
|
commits: Commit[];
|
|
@@ -10,12 +16,12 @@ export declare type BackportSuccessResponse = {
|
|
|
10
16
|
export declare type BackportFailureResponse = {
|
|
11
17
|
status: 'failure';
|
|
12
18
|
commits: Commit[];
|
|
13
|
-
error: Error |
|
|
19
|
+
error: Error | BackportError;
|
|
14
20
|
errorMessage: string;
|
|
15
21
|
};
|
|
16
|
-
export declare type BackportResponse = BackportSuccessResponse | BackportFailureResponse;
|
|
17
|
-
export declare function backportRun({ processArgs, optionsFromModule,
|
|
22
|
+
export declare type BackportResponse = BackportSuccessResponse | BackportFailureResponse | BackportAbortResponse;
|
|
23
|
+
export declare function backportRun({ processArgs, optionsFromModule, exitCodeOnFailure, }: {
|
|
18
24
|
processArgs: string[];
|
|
19
25
|
optionsFromModule?: ConfigFileOptions;
|
|
20
|
-
|
|
26
|
+
exitCodeOnFailure: boolean;
|
|
21
27
|
}): Promise<BackportResponse>;
|
package/dist/backportRun.js
CHANGED
|
@@ -5,56 +5,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.backportRun = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("./lib/BackportError");
|
|
9
|
+
const env_1 = require("./lib/env");
|
|
10
|
+
const getCommits_1 = require("./lib/getCommits");
|
|
11
|
+
const getTargetBranches_1 = require("./lib/getTargetBranches");
|
|
12
|
+
const createStatusComment_1 = require("./lib/github/v3/createStatusComment");
|
|
13
|
+
const apiRequestV4_1 = require("./lib/github/v4/apiRequestV4");
|
|
14
|
+
const logger_1 = require("./lib/logger");
|
|
15
|
+
const ora_1 = require("./lib/ora");
|
|
16
|
+
const setupRepo_1 = require("./lib/setupRepo");
|
|
17
|
+
const cliArgs_1 = require("./options/cliArgs");
|
|
9
18
|
const options_1 = require("./options/options");
|
|
10
19
|
const runSequentially_1 = require("./runSequentially");
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
spinner.start('Initializing...');
|
|
20
|
+
async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFailure, }) {
|
|
21
|
+
const { interactive, logFilePath } = (0, cliArgs_1.getRuntimeArguments)(processArgs, optionsFromModule);
|
|
22
|
+
const logger = (0, logger_1.initLogger)({ interactive, logFilePath });
|
|
23
|
+
let optionsFromCliArgs;
|
|
24
|
+
try {
|
|
25
|
+
optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
if (e instanceof Error) {
|
|
29
|
+
(0, logger_1.consoleLog)(e.message);
|
|
30
|
+
(0, logger_1.consoleLog)(`Run "backport --help" to see all options`);
|
|
31
|
+
return {
|
|
32
|
+
status: 'failure',
|
|
33
|
+
error: e,
|
|
34
|
+
errorMessage: e.message,
|
|
35
|
+
commits: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
throw e;
|
|
31
39
|
}
|
|
32
40
|
let options = null;
|
|
33
41
|
let commits = [];
|
|
42
|
+
const spinner = (0, ora_1.ora)(interactive).start('Initializing...');
|
|
34
43
|
try {
|
|
35
|
-
options = await (0, options_1.getOptions)(
|
|
44
|
+
options = await (0, options_1.getOptions)({ optionsFromCliArgs, optionsFromModule });
|
|
36
45
|
logger.info('Backporting options', options);
|
|
37
46
|
spinner.stop();
|
|
38
47
|
commits = await (0, getCommits_1.getCommits)(options);
|
|
39
48
|
logger.info('Commits', commits);
|
|
40
49
|
if (options.ls) {
|
|
41
|
-
return {
|
|
42
|
-
status: 'success',
|
|
43
|
-
commits,
|
|
44
|
-
results: [],
|
|
45
|
-
};
|
|
50
|
+
return { status: 'success', commits, results: [] };
|
|
46
51
|
}
|
|
47
52
|
const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
48
53
|
logger.info('Target branches', targetBranches);
|
|
49
|
-
|
|
50
|
-
(0, getGitConfigAuthor_1.getGitConfigAuthor)(options),
|
|
51
|
-
(0, setupRepo_1.setupRepo)(options),
|
|
52
|
-
]);
|
|
54
|
+
await (0, setupRepo_1.setupRepo)(options);
|
|
53
55
|
const results = await (0, runSequentially_1.runSequentially)({
|
|
54
56
|
options,
|
|
55
57
|
commits,
|
|
56
58
|
targetBranches,
|
|
57
|
-
gitConfigAuthor,
|
|
58
59
|
});
|
|
59
60
|
logger.info('Results', results);
|
|
60
61
|
const backportResponse = {
|
|
@@ -62,39 +63,48 @@ async function backportRun({ processArgs, optionsFromModule = {}, isCliMode, })
|
|
|
62
63
|
commits,
|
|
63
64
|
results,
|
|
64
65
|
};
|
|
65
|
-
await (0, createStatusComment_1.createStatusComment)({
|
|
66
|
-
options,
|
|
67
|
-
backportResponse,
|
|
68
|
-
});
|
|
66
|
+
await (0, createStatusComment_1.createStatusComment)({ options, backportResponse });
|
|
69
67
|
return backportResponse;
|
|
70
68
|
}
|
|
71
69
|
catch (e) {
|
|
72
70
|
spinner.stop();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
71
|
+
let backportResponse;
|
|
72
|
+
if (e instanceof BackportError_1.BackportError &&
|
|
73
|
+
e.errorContext.code === 'no-branches-exception') {
|
|
74
|
+
backportResponse = {
|
|
75
|
+
status: 'aborted',
|
|
76
|
+
commits,
|
|
77
|
+
error: e,
|
|
78
|
+
errorMessage: e.message,
|
|
79
|
+
};
|
|
80
|
+
// this will catch both BackportError and Error
|
|
84
81
|
}
|
|
85
|
-
if (
|
|
86
|
-
|
|
82
|
+
else if (e instanceof Error) {
|
|
83
|
+
backportResponse = {
|
|
84
|
+
status: 'failure',
|
|
85
|
+
commits,
|
|
86
|
+
error: e,
|
|
87
|
+
errorMessage: e.message,
|
|
88
|
+
};
|
|
87
89
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
else {
|
|
91
|
+
throw e;
|
|
92
|
+
}
|
|
93
|
+
if (options) {
|
|
94
|
+
await (0, createStatusComment_1.createStatusComment)({ options, backportResponse });
|
|
95
|
+
}
|
|
96
|
+
outputError({ e, logFilePath });
|
|
97
|
+
// only change exit code for failures while in cli mode
|
|
98
|
+
if (exitCodeOnFailure && backportResponse.status === 'failure') {
|
|
90
99
|
process.exitCode = 1;
|
|
91
100
|
}
|
|
101
|
+
logger.error('Unhandled exception', e);
|
|
92
102
|
return backportResponse;
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
exports.backportRun = backportRun;
|
|
96
106
|
function outputError({ e, logFilePath, }) {
|
|
97
|
-
if (e instanceof
|
|
107
|
+
if (e instanceof BackportError_1.BackportError || e instanceof apiRequestV4_1.GithubV4Exception) {
|
|
98
108
|
(0, logger_1.consoleLog)(e.message);
|
|
99
109
|
return;
|
|
100
110
|
}
|
|
@@ -104,15 +114,7 @@ function outputError({ e, logFilePath, }) {
|
|
|
104
114
|
(0, logger_1.consoleLog)(chalk_1.default.bold('⚠️ Ouch! An unhandled error occured 😿'));
|
|
105
115
|
(0, logger_1.consoleLog)(e.stack ? e.stack : e.message);
|
|
106
116
|
(0, logger_1.consoleLog)('Please open an issue in https://github.com/sqren/backport/issues or contact me directly on https://twitter.com/sorenlouv');
|
|
107
|
-
(0,
|
|
108
|
-
|
|
109
|
-
})}`));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function isCriticalError(e) {
|
|
113
|
-
if (e instanceof HandledError_1.HandledError &&
|
|
114
|
-
e.errorContext.code === 'no-branches-exception') {
|
|
115
|
-
return false;
|
|
117
|
+
const infoLogPath = (0, env_1.getLogfilePath)({ logFilePath, logLevel: 'info' });
|
|
118
|
+
(0, logger_1.consoleLog)(chalk_1.default.italic(`For additional details see the logs: ${infoLogPath}`));
|
|
116
119
|
}
|
|
117
|
-
return true;
|
|
118
120
|
}
|
package/dist/entrypoint.cli.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
7
3
|
const backportRun_1 = require("./backportRun");
|
|
4
|
+
const cliArgs_1 = require("./options/cliArgs");
|
|
8
5
|
const processArgs = process.argv.slice(2);
|
|
9
6
|
// this is the entrypoint when running from command line
|
|
10
|
-
(0, backportRun_1.backportRun)({ processArgs,
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
if (ci || ls) {
|
|
7
|
+
(0, backportRun_1.backportRun)({ processArgs, exitCodeOnFailure: true }).then((backportResponse) => {
|
|
8
|
+
const { interactive, ls } = (0, cliArgs_1.getRuntimeArguments)(processArgs);
|
|
9
|
+
if (!interactive || ls) {
|
|
14
10
|
// eslint-disable-next-line no-console
|
|
15
11
|
console.log(JSON.stringify(backportResponse));
|
|
16
12
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { BackportResponse } from './backportRun';
|
|
2
|
+
import type { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
3
|
import { ConfigFileOptions } from './options/ConfigOptions';
|
|
2
4
|
import { ValidConfigOptions } from './options/options';
|
|
3
|
-
|
|
4
|
-
export { BackportResponse } from './backportRun';
|
|
5
|
-
export {
|
|
6
|
-
export { Commit };
|
|
7
|
-
export {
|
|
5
|
+
export type { HandledErrorResult, SuccessResult, UnhandledErrorResult, } from './runSequentially';
|
|
6
|
+
export type { BackportAbortResponse, BackportFailureResponse, BackportResponse, BackportSuccessResponse, } from './backportRun';
|
|
7
|
+
export { BackportError } from './lib/BackportError';
|
|
8
|
+
export type { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
9
|
+
export type { ConfigFileOptions } from './options/ConfigOptions';
|
|
10
|
+
export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './lib/github/v4/fetchRemoteProjectConfig';
|
|
8
11
|
export { getGlobalConfig as getLocalGlobalConfig } from './options/config/globalConfig';
|
|
9
|
-
export declare function backportRun(options
|
|
12
|
+
export declare function backportRun({ options, processArgs, exitCodeOnFailure, }: {
|
|
13
|
+
options: ConfigFileOptions;
|
|
14
|
+
processArgs?: string[];
|
|
15
|
+
exitCodeOnFailure?: boolean;
|
|
16
|
+
}): Promise<BackportResponse>;
|
|
10
17
|
export declare function getCommits(options: {
|
|
11
18
|
accessToken: string;
|
|
12
19
|
repoName: string;
|
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = void 0;
|
|
3
|
+
exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = exports.BackportError = void 0;
|
|
4
4
|
const backportRun_1 = require("./backportRun");
|
|
5
|
-
const fetchCommitByPullNumber_1 = require("./
|
|
6
|
-
const fetchCommitBySha_1 = require("./
|
|
7
|
-
const fetchCommitsByAuthor_1 = require("./
|
|
8
|
-
const fetchPullRequestsBySearchQuery_1 = require("./
|
|
9
|
-
const getOptionsFromGithub_1 = require("./
|
|
10
|
-
const logger_1 = require("./
|
|
5
|
+
const fetchCommitByPullNumber_1 = require("./lib/github/v4/fetchCommits/fetchCommitByPullNumber");
|
|
6
|
+
const fetchCommitBySha_1 = require("./lib/github/v4/fetchCommits/fetchCommitBySha");
|
|
7
|
+
const fetchCommitsByAuthor_1 = require("./lib/github/v4/fetchCommits/fetchCommitsByAuthor");
|
|
8
|
+
const fetchPullRequestsBySearchQuery_1 = require("./lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery");
|
|
9
|
+
const getOptionsFromGithub_1 = require("./lib/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
10
|
+
const logger_1 = require("./lib/logger");
|
|
11
11
|
const excludeUndefined_1 = require("./utils/excludeUndefined");
|
|
12
|
-
var
|
|
12
|
+
var BackportError_1 = require("./lib/BackportError");
|
|
13
|
+
Object.defineProperty(exports, "BackportError", { enumerable: true, get: function () { return BackportError_1.BackportError; } });
|
|
14
|
+
var fetchRemoteProjectConfig_1 = require("./lib/github/v4/fetchRemoteProjectConfig");
|
|
13
15
|
Object.defineProperty(exports, "getRemoteProjectConfig", { enumerable: true, get: function () { return fetchRemoteProjectConfig_1.fetchRemoteProjectConfig; } });
|
|
14
16
|
var globalConfig_1 = require("./options/config/globalConfig");
|
|
15
17
|
Object.defineProperty(exports, "getLocalGlobalConfig", { enumerable: true, get: function () { return globalConfig_1.getGlobalConfig; } });
|
|
16
|
-
function backportRun(options,
|
|
17
|
-
// cli args will not automatically be forwarded when it is consumed as a module
|
|
18
|
-
// It is simple to forward args manually via `process.argv`:
|
|
19
|
-
//
|
|
20
|
-
// import { backportRun } from `backport
|
|
21
|
-
// const args = process.argv.slice(2);
|
|
22
|
-
// backportRun(options, args)
|
|
23
|
-
//
|
|
24
|
-
processArgs = []) {
|
|
18
|
+
function backportRun({ options, processArgs = [], exitCodeOnFailure = true, }) {
|
|
25
19
|
return (0, backportRun_1.backportRun)({
|
|
26
|
-
processArgs,
|
|
27
20
|
optionsFromModule: (0, excludeUndefined_1.excludeUndefined)(options),
|
|
28
|
-
|
|
21
|
+
processArgs,
|
|
22
|
+
exitCodeOnFailure,
|
|
29
23
|
});
|
|
30
24
|
}
|
|
31
25
|
exports.backportRun = backportRun;
|
|
32
26
|
async function getCommits(options) {
|
|
33
|
-
(0, logger_1.initLogger)({
|
|
27
|
+
(0, logger_1.initLogger)({ interactive: false, accessToken: options.accessToken });
|
|
34
28
|
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(options);
|
|
35
29
|
if (options.pullNumber) {
|
|
36
30
|
return [
|