backport 8.9.2 → 8.9.4

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.
Files changed (35) hide show
  1. package/README.md +2 -2
  2. package/dist/entrypoint.module.private.test.js +51 -51
  3. package/dist/lib/cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.test.js +8 -8
  4. package/dist/lib/child-process-promisified.js +1 -0
  5. package/dist/lib/getTargetBranches.test.js +1 -1
  6. package/dist/lib/git.js +27 -12
  7. package/dist/lib/git.private.test.js +9 -9
  8. package/dist/lib/git.test.js +7 -7
  9. package/dist/lib/github/v3/createPullRequest.test.js +1 -1
  10. package/dist/lib/github/v3/createStatusComment.test.js +6 -6
  11. package/dist/lib/github/v4/apiRequestV4.test.js +5 -5
  12. package/dist/lib/github/v4/enablePullRequestAutoMerge.mutation.test.js +3 -3
  13. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +1 -1
  14. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +14 -4
  15. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +2 -2
  16. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -3
  17. package/dist/lib/github/v4/fetchCommits/fetchCommitsForRebaseAndMergeStrategy.js +14 -4
  18. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +2 -2
  19. package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +2 -2
  20. package/dist/lib/github/v4/validateTargetBranch.private.test.js +1 -1
  21. package/dist/lib/setupRepo.js +2 -0
  22. package/dist/lib/setupRepo.test.js +3 -3
  23. package/dist/options/cliArgs.test.js +3 -3
  24. package/dist/options/config/globalConfig.test.js +1 -1
  25. package/dist/options/config/readConfigFile.d.ts +1 -1
  26. package/dist/options/options.test.js +17 -17
  27. package/dist/scripts/postinstall.test.js +4 -4
  28. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +3 -3
  29. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +5 -5
  30. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +8 -8
  31. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +7 -7
  32. package/dist/utils/packageVersion.d.ts +1 -1
  33. package/dist/utils/packageVersion.js +1 -1
  34. package/package.json +24 -24
  35. package/yarn.lock +668 -575
@@ -21,8 +21,15 @@ async function fetchCommitsByPullNumber(options) {
21
21
  repository(owner: $repoOwner, name: $repoName) {
22
22
  pullRequest(number: $pullNumber) {
23
23
  # used to determine if "Rebase and Merge" strategy was used
24
- commits {
24
+ commits(last: 1) {
25
25
  totalCount
26
+ edges {
27
+ node {
28
+ commit {
29
+ message
30
+ }
31
+ }
32
+ }
26
33
  }
27
34
 
28
35
  mergeCommit {
@@ -67,9 +74,12 @@ async function fetchCommitsByPullNumber(options) {
67
74
  if (mergeCommit === null) {
68
75
  throw new BackportError_1.BackportError(`The PR #${pullNumber} is not merged`);
69
76
  }
70
- const possiblyRebaseAndMergeStrategy = pullRequestNode.commits.totalCount > 0 &&
71
- mergeCommit.history.edges.every((c) => c.node.committedDate === mergeCommit.committedDate);
72
- if (possiblyRebaseAndMergeStrategy) {
77
+ const lastCommitInPullRequest = pullRequestNode.commits.edges[0].node.commit;
78
+ const firstCommitInBaseBranch = mergeCommit.history.edges[0].node;
79
+ const isRebaseAndMergeStrategy = pullRequestNode.commits.totalCount > 0 &&
80
+ mergeCommit.history.edges.every((c) => c.node.committedDate === mergeCommit.committedDate) &&
81
+ lastCommitInPullRequest.message === firstCommitInBaseBranch.message;
82
+ if (isRebaseAndMergeStrategy) {
73
83
  const commits = await (0, fetchCommitsForRebaseAndMergeStrategy_1.fetchCommitsForRebaseAndMergeStrategy)(options, pullRequestNode.commits.totalCount);
74
84
  if (commits) {
75
85
  return commits;
@@ -144,7 +144,7 @@ describe('fetchCommitByPullNumber', () => {
144
144
  repoOwner: 'backport-org',
145
145
  sourceBranch: 'main',
146
146
  };
147
- await expect((0, fetchCommitByPullNumber_1.fetchCommitsByPullNumber)(options)).rejects.toThrowError(`The PR #11 is not merged`);
147
+ await expect((0, fetchCommitByPullNumber_1.fetchCommitsByPullNumber)(options)).rejects.toThrow(`The PR #11 is not merged`);
148
148
  });
149
149
  });
150
150
  describe('when PR does not exist', () => {
@@ -156,7 +156,7 @@ describe('fetchCommitByPullNumber', () => {
156
156
  repoOwner: 'backport-org',
157
157
  sourceBranch: 'main',
158
158
  };
159
- await expect((0, fetchCommitByPullNumber_1.fetchCommitsByPullNumber)(options)).rejects.toThrowError(`Could not resolve to a PullRequest with the number of 9999999999999. (Github API v4)`);
159
+ await expect((0, fetchCommitByPullNumber_1.fetchCommitsByPullNumber)(options)).rejects.toThrow(`Could not resolve to a PullRequest with the number of 9999999999999. (Github API v4)`);
160
160
  });
161
161
  });
162
162
  });
@@ -74,7 +74,7 @@ describe('fetchCommitBySha', () => {
74
74
  sha: 'cb6fbc0e1b406675724181a3e9f59459b5f8f892',
75
75
  },
76
76
  sourcePullRequest: {
77
- labels: ['Team:apm', 'release_note:skip', 'v7.9.0'],
77
+ labels: ['Team:APM', 'release_note:skip', 'v7.9.0'],
78
78
  number: 70740,
79
79
  url: 'https://github.com/elastic/kibana/pull/70740',
80
80
  mergeCommit: {
@@ -114,7 +114,7 @@ describe('fetchCommitBySha', () => {
114
114
  accessToken,
115
115
  sha: 'fc22f59',
116
116
  sourceBranch: 'main',
117
- })).rejects.toThrowError('No commit found on branch "main" with sha "fc22f59"');
117
+ })).rejects.toThrow('No commit found on branch "main" with sha "fc22f59"');
118
118
  });
119
119
  it('throws if sha is invalid', async () => {
120
120
  await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
@@ -123,6 +123,6 @@ describe('fetchCommitBySha', () => {
123
123
  accessToken,
124
124
  sha: 'myCommitSha',
125
125
  sourceBranch: 'main',
126
- })).rejects.toThrowError('No commit found on branch "main" with sha "myCommitSha"');
126
+ })).rejects.toThrow('No commit found on branch "main" with sha "myCommitSha"');
127
127
  });
128
128
  });
@@ -10,7 +10,7 @@ const fetchCommitBySha_1 = require("./fetchCommitBySha");
10
10
  async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount) {
11
11
  const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', pullNumber, repoName, repoOwner, } = options;
12
12
  const query = (0, graphql_tag_1.default) `
13
- query CommitByPullNumber(
13
+ query CommitsForRebaseAndMergeStrategy(
14
14
  $repoOwner: String!
15
15
  $repoName: String!
16
16
  $pullNumber: Int!
@@ -18,6 +18,7 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount)
18
18
  ) {
19
19
  repository(owner: $repoOwner, name: $repoName) {
20
20
  pullRequest(number: $pullNumber) {
21
+ number
21
22
  commits(first: $commitsTotalCount) {
22
23
  totalCount
23
24
  edges {
@@ -37,6 +38,13 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount)
37
38
  oid
38
39
  message
39
40
  committedDate
41
+ associatedPullRequests(first: 1) {
42
+ edges {
43
+ node {
44
+ number
45
+ }
46
+ }
47
+ }
40
48
  }
41
49
  }
42
50
  }
@@ -66,9 +74,11 @@ async function fetchCommitsForRebaseAndMergeStrategy(options, commitsTotalCount)
66
74
  const commitsInPullRequest = pullRequestNode.commits.edges;
67
75
  const commitsInBaseBranch = pullRequestNode.mergeCommit.history.edges.reverse();
68
76
  const didUseRebaseAndMergeStrategy = commitsInBaseBranch.every((c, i) => {
69
- const hasIdenticalCommittedDate = c.node.committedDate === pullRequestNode.mergeCommit?.committedDate;
70
- const hasIdenticalCommitMessages = c.node.message === commitsInPullRequest[i].node.commit.message;
71
- return hasIdenticalCommittedDate && hasIdenticalCommitMessages;
77
+ const hasSameCommittedDate = c.node.committedDate === pullRequestNode.mergeCommit?.committedDate;
78
+ const hasSameCommitMessages = c.node.message === commitsInPullRequest[i].node.commit.message;
79
+ const hasSamePullNumber = c.node.associatedPullRequests.edges[0].node.number ===
80
+ pullRequestNode.number;
81
+ return hasSameCommittedDate && hasSameCommitMessages && hasSamePullNumber;
72
82
  });
73
83
  if (didUseRebaseAndMergeStrategy) {
74
84
  const commits = await Promise.all(commitsInBaseBranch.map((c) => (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha: c.node.oid })));
@@ -21,7 +21,7 @@ describe('getOptionsFromGithub', () => {
21
21
  repoName: 'backport-e2e',
22
22
  cwd: process.cwd(),
23
23
  };
24
- await expect((0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions)).rejects.toThrowError('Please check your access token and make sure it is valid.\nConfig: /myHomeDir/.backport/config.json');
24
+ await expect((0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions)).rejects.toThrow('Please check your access token and make sure it is valid.\nConfig: /myHomeDir/.backport/config.json');
25
25
  });
26
26
  });
27
27
  describe('is valid', () => {
@@ -94,7 +94,7 @@ describe('getOptionsFromGithub', () => {
94
94
  };
95
95
  await expect(async () => {
96
96
  await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
97
- }).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
97
+ }).rejects.toThrow('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
98
98
  });
99
99
  });
100
100
  });
@@ -14,7 +14,7 @@ describe('throwOnInvalidAccessToken', () => {
14
14
  repoOwner: 'elastic',
15
15
  repoName: 'kibana',
16
16
  error,
17
- })).toThrowError('Please check your access token and make sure it is valid');
17
+ })).toThrow('Please check your access token and make sure it is valid');
18
18
  });
19
19
  it('should handle SSO error', () => {
20
20
  const error = {
@@ -49,7 +49,7 @@ describe('throwOnInvalidAccessToken', () => {
49
49
  repoOwner: 'elastic',
50
50
  repoName: 'kibana',
51
51
  error,
52
- })).toThrowError(`The repository "elastic/kibana" doesn't exist`);
52
+ })).toThrow(`The repository "elastic/kibana" doesn't exist`);
53
53
  });
54
54
  it('should handle insufficient permissions (oauth scopes)', () => {
55
55
  const error = {
@@ -10,7 +10,7 @@ describe('validateTargetBranch', () => {
10
10
  repoName: 'repo-with-target-branches',
11
11
  accessToken,
12
12
  };
13
- await expect(() => (0, validateTargetBranch_1.validateTargetBranch)({ ...options, branchName: 'foo' })).rejects.toThrowError('The branch "foo" does not exist');
13
+ await expect(() => (0, validateTargetBranch_1.validateTargetBranch)({ ...options, branchName: 'foo' })).rejects.toThrow('The branch "foo" does not exist');
14
14
  });
15
15
  it('resolves when branch is valid', async () => {
16
16
  const options = {
@@ -5,6 +5,7 @@ const del = require("del");
5
5
  const BackportError_1 = require("./BackportError");
6
6
  const env_1 = require("./env");
7
7
  const git_1 = require("./git");
8
+ const logger_1 = require("./logger");
8
9
  const ora_1 = require("./ora");
9
10
  async function setupRepo(options) {
10
11
  const repoPath = (0, env_1.getRepoPath)(options);
@@ -52,5 +53,6 @@ exports.setupRepo = setupRepo;
52
53
  async function getIsRepoCloned(options) {
53
54
  const repoPath = (0, env_1.getRepoPath)(options);
54
55
  const projectRoot = await (0, git_1.getGitProjectRootPath)(repoPath);
56
+ logger_1.logger.debug(`repoPath=${repoPath}, projectRoot=${projectRoot}`);
55
57
  return repoPath === projectRoot;
56
58
  }
@@ -59,7 +59,7 @@ describe('setupRepo', () => {
59
59
  repoOwner: 'elastic',
60
60
  cwd: '/path/to/source/repo',
61
61
  interactive: true,
62
- })).rejects.toThrowError('Simulated git clone failure');
62
+ })).rejects.toThrow('Simulated git clone failure');
63
63
  expect(del_1.default).toHaveBeenCalledWith('/myHomeDir/.backport/repositories/elastic/kibana', { force: true });
64
64
  });
65
65
  });
@@ -112,7 +112,7 @@ describe('setupRepo', () => {
112
112
  });
113
113
  expect(spinnerTextSpy.mock.calls.map((call) => call[0]))
114
114
  .toMatchInlineSnapshot(`
115
- Array [
115
+ [
116
116
  "0% Cloning repository from github.com (one-time operation)",
117
117
  "1% Cloning repository from github.com (one-time operation)",
118
118
  "9% Cloning repository from github.com (one-time operation)",
@@ -269,7 +269,7 @@ describe('setupRepo', () => {
269
269
  cwd: '/myHomeDir/.backport/repositories/owner/repo/foo',
270
270
  dir: '/myHomeDir/.backport/repositories/owner/repo',
271
271
  interactive: true,
272
- })).rejects.toThrowError('Refusing to clone repo into "/myHomeDir/.backport/repositories/owner/repo" when current working directory is "/myHomeDir/.backport/repositories/owner/repo/foo". Please change backport directory via `--dir` option or run backport from another location');
272
+ })).rejects.toThrow('Refusing to clone repo into "/myHomeDir/.backport/repositories/owner/repo" when current working directory is "/myHomeDir/.backport/repositories/owner/repo/foo". Please change backport directory via `--dir` option or run backport from another location');
273
273
  });
274
274
  });
275
275
  });
@@ -112,7 +112,7 @@ describe('getOptionsFromCliArgs', () => {
112
112
  });
113
113
  it('should conflict when using both', () => {
114
114
  const argv = ['--multiple', '--multiple-branches', 'false'];
115
- expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrowError('Arguments multiple and multipleBranches are mutually exclusive');
115
+ expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrow('Arguments multiple and multipleBranches are mutually exclusive');
116
116
  });
117
117
  });
118
118
  describe('fork', () => {
@@ -207,7 +207,7 @@ describe('getOptionsFromCliArgs', () => {
207
207
  });
208
208
  it('should throw on invalid values', () => {
209
209
  const argv = ['--mainline', 'foo'];
210
- expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrowError('--mainline must be an integer. Received: NaN');
210
+ expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrow('--mainline must be an integer. Received: NaN');
211
211
  });
212
212
  });
213
213
  describe('targetBranches', () => {
@@ -232,7 +232,7 @@ describe('getOptionsFromCliArgs', () => {
232
232
  });
233
233
  it('throw if both --repo and --repo-name is given', () => {
234
234
  const argv = ['--repo', 'elastic/kibana', '--repo-name', 'foo'];
235
- expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrowError('Arguments repo and repoName are mutually exclusive');
235
+ expect(() => (0, cliArgs_1.getOptionsFromCliArgs)(argv)).toThrow('Arguments repo and repoName are mutually exclusive');
236
236
  });
237
237
  });
238
238
  describe('dateSince and dateUntil', () => {
@@ -55,7 +55,7 @@ describe('config', () => {
55
55
  const err = new Error();
56
56
  err.code = 'ENOENT';
57
57
  jest.spyOn(promises_1.default, 'writeFile').mockRejectedValueOnce(err);
58
- await expect(() => (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/global/config.json', 'myConfigTemplate')).rejects.toThrowError('The .backport folder (/path/to/global/config.json) does not exist.');
58
+ await expect(() => (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/global/config.json', 'myConfigTemplate')).rejects.toThrow('The .backport folder (/path/to/global/config.json) does not exist.');
59
59
  });
60
60
  });
61
61
  });
@@ -3,6 +3,7 @@ export declare function readConfigFile(filepath: string): Promise<ConfigFileOpti
3
3
  export declare function withConfigMigrations({ upstream, labels, branches, ...config }: ConfigFileOptions): {
4
4
  fork?: boolean | undefined;
5
5
  dir?: string | undefined;
6
+ multiple?: boolean | undefined;
6
7
  help?: boolean | undefined;
7
8
  interactive?: boolean | undefined;
8
9
  accessToken?: string | undefined;
@@ -26,7 +27,6 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
26
27
  ls?: boolean | undefined;
27
28
  signoff?: boolean | undefined;
28
29
  maxNumber?: number | undefined;
29
- multiple?: boolean | undefined;
30
30
  multipleBranches?: boolean | undefined;
31
31
  multipleCommits?: boolean | undefined;
32
32
  noVerify?: boolean | undefined;
@@ -68,11 +68,11 @@ describe('getOptions', () => {
68
68
  optionsFromCliArgs: {},
69
69
  optionsFromModule: {},
70
70
  })).rejects.toThrowErrorMatchingInlineSnapshot(`
71
- "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
72
- It must contain a valid \\"accessToken\\".
71
+ "Please update your config file: "/myHomeDir/.backport/config.json".
72
+ It must contain a valid "accessToken".
73
73
 
74
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
75
- `);
74
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
75
+ `);
76
76
  });
77
77
  it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
78
78
  mockProjectConfig({
@@ -81,34 +81,34 @@ describe('getOptions', () => {
81
81
  branchLabelMapping: undefined,
82
82
  });
83
83
  await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
84
- "Please specify a target branch: \\"--branch 6.1\\".
84
+ "Please specify a target branch: "--branch 6.1".
85
85
 
86
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
87
- `);
86
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
87
+ `);
88
88
  });
89
89
  describe('whe option is an empty string', () => {
90
90
  it('throws for "username"', async () => {
91
91
  await expect(() => (0, options_1.getOptions)({
92
92
  optionsFromCliArgs: {},
93
93
  optionsFromModule: { repoForkOwner: '', author: 'sqren' },
94
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"repoForkOwner\\" cannot be empty!"`);
94
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`""repoForkOwner" cannot be empty!"`);
95
95
  });
96
96
  it('throws for "author"', async () => {
97
97
  await expect(() => (0, options_1.getOptions)({
98
98
  optionsFromCliArgs: {},
99
99
  optionsFromModule: { author: '' },
100
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
100
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`""author" cannot be empty!"`);
101
101
  });
102
102
  it('throws for "accessToken"', async () => {
103
103
  await expect(() => (0, options_1.getOptions)({
104
104
  optionsFromCliArgs: {},
105
105
  optionsFromModule: { accessToken: '' },
106
106
  })).rejects.toThrowErrorMatchingInlineSnapshot(`
107
- "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
108
- It must contain a valid \\"accessToken\\".
107
+ "Please update your config file: "/myHomeDir/.backport/config.json".
108
+ It must contain a valid "accessToken".
109
109
 
110
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
111
- `);
110
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
111
+ `);
112
112
  });
113
113
  });
114
114
  describe('when repoName and repoOwner are missing', () => {
@@ -118,10 +118,10 @@ describe('getOptions', () => {
118
118
  it('should throw if there are no remotes', async () => {
119
119
  jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
120
120
  await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
121
- "Please specify a repository: \\"--repo elastic/kibana\\".
121
+ "Please specify a repository: "--repo elastic/kibana".
122
122
 
123
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
124
- `);
123
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
124
+ `);
125
125
  });
126
126
  it('should get repoName from the remote', async () => {
127
127
  mockRepoOwnerAndName({
@@ -154,7 +154,7 @@ describe('getOptions', () => {
154
154
  });
155
155
  it('should ensure that "backport" branch does not exist', async () => {
156
156
  mockGithubConfigOptions({ hasBackportBranch: true });
157
- await expect((0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
157
+ await expect((0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrow('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
158
158
  });
159
159
  it('should merge config options and module options', async () => {
160
160
  mockGithubConfigOptions({});
@@ -42,8 +42,8 @@ describe('postinstall', () => {
42
42
  .spyOn(globalConfig, 'createGlobalConfigAndFolderIfNotExist')
43
43
  .mockResolvedValueOnce(true);
44
44
  await (0, postinstall_1.postinstall)();
45
- expect(createGlobalConfigAndFolderIfNotExistSpy).toBeCalledTimes(1);
46
- expect(logger.consoleLog).toBeCalledWith('Global config successfully created in /myHomeDir/.backport/config.json');
45
+ expect(createGlobalConfigAndFolderIfNotExistSpy).toHaveBeenCalledTimes(1);
46
+ expect(logger.consoleLog).toHaveBeenCalledWith('Global config successfully created in /myHomeDir/.backport/config.json');
47
47
  });
48
48
  it('should not create global config if it already exists', async () => {
49
49
  const consoleSpy = jest.spyOn(console, 'log');
@@ -51,7 +51,7 @@ describe('postinstall', () => {
51
51
  .spyOn(globalConfig, 'createGlobalConfigAndFolderIfNotExist')
52
52
  .mockResolvedValueOnce(false);
53
53
  await (0, postinstall_1.postinstall)();
54
- expect(createGlobalConfigAndFolderIfNotExistSpy).toBeCalledTimes(1);
55
- expect(consoleSpy).toBeCalledTimes(0);
54
+ expect(createGlobalConfigAndFolderIfNotExistSpy).toHaveBeenCalledTimes(1);
55
+ expect(consoleSpy).toHaveBeenCalledTimes(0);
56
56
  });
57
57
  });
@@ -21,9 +21,9 @@ describe('different-merge-strategies', () => {
21
21
  ], { waitForString: 'Select commit', timeoutSeconds: 4 });
22
22
  expect(output).toMatchInlineSnapshot(`
23
23
  "? Select commit (Use arrow keys)
24
- ❯ 1. Downsides with \\"Rebase and merge\\"
25
- 2. Add description for \\"Rebase and merge\\"
26
- 3. Add \\"Rebase and merge\\" header
24
+ ❯ 1. Downsides with "Rebase and merge"
25
+ 2. Add description for "Rebase and merge"
26
+ 3. Add "Rebase and merge" header
27
27
  4. Create rebase-and-merge.txt
28
28
  5. Merge pull request #9 from backport-org/many-merge-commits
29
29
  6. Merge strategy: Eighth of many merges
@@ -60,8 +60,8 @@ describe('entrypoint cli', () => {
60
60
  --autoAssign Auto assign the target pull request to yourself [boolean]
61
61
  --autoMerge Enable auto-merge for created pull requests [boolean]
62
62
  --autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
63
- merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
64
- --cherrypickRef Append commit message with \\"(cherry picked from commit...)
63
+ merge [string] [choices: "merge", "rebase", "squash"]
64
+ --cherrypickRef Append commit message with "(cherry picked from commit...)
65
65
  [boolean]
66
66
  --projectConfigFile, --config Path to project config [string]
67
67
  --globalConfigFile Path to global config [string]
@@ -88,8 +88,8 @@ describe('entrypoint cli', () => {
88
88
  --multiple Select multiple branches/commits [boolean]
89
89
  --multipleBranches Backport to multiple branches [boolean]
90
90
  --multipleCommits Backport multiple commits [boolean]
91
- --noCherrypickRef Do not append commit message with \\"(cherry picked from
92
- commit...)\\" [boolean]
91
+ --noCherrypickRef Do not append commit message with "(cherry picked from
92
+ commit...)" [boolean]
93
93
  --noStatusComment Don't publish status comment to Github [boolean]
94
94
  --noVerify Bypass the pre-commit and commit-msg hooks [boolean]
95
95
  --noFork Create backports in the origin repo [boolean]
@@ -107,7 +107,7 @@ describe('entrypoint cli', () => {
107
107
  Defaults to the currently authenticated user [string]
108
108
  --repo Repo owner and name [string]
109
109
  --sha, --commit Commit sha to backport [string]
110
- --sourceBranch Specify a non-default branch (normally \\"master\\") to backport
110
+ --sourceBranch Specify a non-default branch (normally "master") to backport
111
111
  from [string]
112
112
  --sourcePRLabel, --sourcePrLabel Add labels to the source (original) PR [array]
113
113
  -b, --targetBranch, --branch Branch(es) to backport to [array]
@@ -14,17 +14,17 @@ describe('interactive error handling', () => {
14
14
  `--accessToken=${accessToken}`,
15
15
  ]);
16
16
  expect(output).toMatchInlineSnapshot(`
17
- "Please specify a target branch: \\"--branch 6.1\\".
17
+ "Please specify a target branch: "--branch 6.1".
18
18
 
19
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
20
- `);
19
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
20
+ `);
21
21
  });
22
22
  it('when supplying invalid argument', async () => {
23
23
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--foo`]);
24
24
  expect(output).toMatchInlineSnapshot(`
25
- "Unknown argument: foo
26
- Run \\"backport --help\\" to see all options"
27
- `);
25
+ "Unknown argument: foo
26
+ Run "backport --help" to see all options"
27
+ `);
28
28
  });
29
29
  it('when access token is invalid', async () => {
30
30
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
@@ -41,7 +41,7 @@ describe('interactive error handling', () => {
41
41
  '--author=sqren',
42
42
  `--accessToken=${accessToken}`,
43
43
  ]);
44
- expect(output).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
44
+ expect(output).toMatchInlineSnapshot(`"The repository "foo/bar" doesn't exist"`);
45
45
  });
46
46
  it(`when given branch is invalid`, async () => {
47
47
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
@@ -76,7 +76,7 @@ describe('interactive error handling', () => {
76
76
  The commit could not be backported due to conflicts
77
77
 
78
78
  Please fix the conflicts in <BACKPORT_DIR>
79
- Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to \\"7.x\\":
79
+ Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to "7.x":
80
80
  - Change Barca to Braithwaite (#8) (backport missing)
81
81
  https://github.com/backport-org/repo-with-conflicts/pull/8
82
82
 
@@ -23,11 +23,11 @@ describe('non interactive (json) error handling', () => {
23
23
  expect(code).toBe(1);
24
24
  expect(backportResult.status).toBe('failure');
25
25
  expect(errorMessage).toMatchInlineSnapshot(`
26
- "Please update your config file: \\"<GLOBAL_CONFIG_FILE>\\".
27
- It must contain a valid \\"accessToken\\".
26
+ "Please update your config file: "<GLOBAL_CONFIG_FILE>".
27
+ It must contain a valid "accessToken".
28
28
 
29
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
30
- `);
29
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
30
+ `);
31
31
  });
32
32
  it('when target branches cannot be inferred from pull request', async () => {
33
33
  const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
@@ -54,10 +54,10 @@ describe('non interactive (json) error handling', () => {
54
54
  const backportResult = JSON.parse(output);
55
55
  expect(backportResult.status).toBe('failure');
56
56
  expect(backportResult.errorMessage).toMatchInlineSnapshot(`
57
- "Please specify a target branch: \\"--branch 6.1\\".
57
+ "Please specify a target branch: "--branch 6.1".
58
58
 
59
- Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
60
- `);
59
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
60
+ `);
61
61
  });
62
62
  it(`when argument is invalid`, async () => {
63
63
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)(['--json', '--foo'], {});
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "8.9.2";
1
+ export declare const PACKAGE_VERSION = "8.9.4";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = '8.9.2';
4
+ exports.PACKAGE_VERSION = '8.9.4';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "branches",
15
15
  "branching"
16
16
  ],
17
- "version": "8.9.2",
17
+ "version": "8.9.4",
18
18
  "main": "./dist/entrypoint.module.js",
19
19
  "types": "dist/entrypoint.module.d.ts",
20
20
  "bin": {
@@ -30,9 +30,9 @@
30
30
  "lint-and-test": "yarn tsc && yarn lint && yarn test-all",
31
31
  "lint": "echo \"Running lint\" && eslint './**/*.{ts,js}'",
32
32
  "start": "ts-node --transpile-only ./src/entrypoint.cli.ts",
33
- "test-all": "jest --config ./jest.config.all.js",
34
- "test-mutation": "jest --config ./jest.config.mutation.js",
35
- "test-private": "jest --config ./jest.config.private.js",
33
+ "test-all": "jest --config ./jest.config.all.ts",
34
+ "test-mutation": "jest --config ./jest.config.mutation.ts",
35
+ "test-private": "jest --config ./jest.config.private.ts",
36
36
  "test": "jest"
37
37
  },
38
38
  "lint-staged": {
@@ -63,13 +63,13 @@
63
63
  "node": ">=16.0.0"
64
64
  },
65
65
  "dependencies": {
66
- "@octokit/rest": "^19.0.3",
66
+ "@octokit/rest": "^19.0.4",
67
67
  "axios": "^0.27.2",
68
68
  "dedent": "^0.7.0",
69
69
  "del": "^6.1.1",
70
- "dotenv": "^16.0.1",
70
+ "dotenv": "^16.0.2",
71
71
  "find-up": "^5.0.0",
72
- "graphql": "^16.5.0",
72
+ "graphql": "^16.6.0",
73
73
  "graphql-tag": "^2.12.6",
74
74
  "inquirer": "^8.2.3",
75
75
  "lodash": "^4.17.21",
@@ -79,37 +79,37 @@
79
79
  "strip-json-comments": "^3.1.1",
80
80
  "terminal-link": "^2.1.1",
81
81
  "utility-types": "^3.10.0",
82
- "winston": "^3.8.1",
82
+ "winston": "^3.8.2",
83
83
  "yargs": "^17.5.1",
84
- "yargs-parser": "^21.0.1"
84
+ "yargs-parser": "^21.1.1"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/core-js": "^2.5.5",
88
88
  "@types/dedent": "^0.7.0",
89
- "@types/inquirer": "^8.2.1",
90
- "@types/jest": "^28.1.4",
91
- "@types/lodash": "^4.14.182",
92
- "@types/node": "^18.0.3",
89
+ "@types/inquirer": "^9.0.1",
90
+ "@types/jest": "^29.0.3",
91
+ "@types/lodash": "^4.14.185",
92
+ "@types/node": "^18.7.21",
93
93
  "@types/safe-json-stringify": "^1.1.2",
94
- "@types/yargs": "^17.0.10",
94
+ "@types/yargs": "^17.0.13",
95
95
  "@types/yargs-parser": "^21.0.0",
96
- "@typescript-eslint/eslint-plugin": "^5.30.6",
97
- "@typescript-eslint/parser": "^5.30.6",
98
- "eslint": "^8.19.0",
96
+ "@typescript-eslint/eslint-plugin": "^5.38.0",
97
+ "@typescript-eslint/parser": "^5.38.0",
98
+ "eslint": "^8.24.0",
99
99
  "eslint-config-prettier": "^8.5.0",
100
100
  "eslint-plugin-import": "^2.26.0",
101
- "eslint-plugin-jest": "^26.5.3",
101
+ "eslint-plugin-jest": "^27.0.4",
102
102
  "eslint-plugin-prettier": "^4.2.1",
103
- "graphql-config": "^4.3.1",
103
+ "graphql-config": "^4.3.5",
104
104
  "husky": "^8.0.1",
105
- "jest": "^28.1.2",
105
+ "jest": "^29.0.3",
106
106
  "jest-snapshot-serializer-ansi": "^1.0.0",
107
107
  "lint-staged": "^13.0.3",
108
- "nock": "^13.2.8",
108
+ "nock": "^13.2.9",
109
109
  "prettier": "^2.7.1",
110
110
  "strip-ansi": "^6.0.1",
111
- "ts-jest": "^28.0.5",
112
- "ts-node": "^10.8.2",
113
- "typescript": "^4.7.4"
111
+ "ts-jest": "^29.0.2",
112
+ "ts-node": "^10.9.1",
113
+ "typescript": "^4.8.3"
114
114
  }
115
115
  }