backport 6.0.0 → 6.1.3

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 (106) hide show
  1. package/README.md +179 -52
  2. package/dist/entrypoint.cli.js +2 -0
  3. package/dist/entrypoint.module.d.ts +16 -4
  4. package/dist/entrypoint.module.js +41 -13
  5. package/dist/entrypoint.module.private.test.d.ts +1 -0
  6. package/dist/entrypoint.module.private.test.js +34 -0
  7. package/dist/main.js +1 -2
  8. package/dist/options/ConfigOptions.d.ts +16 -6
  9. package/dist/options/cliArgs.d.ts +36 -37
  10. package/dist/options/cliArgs.js +25 -24
  11. package/dist/options/cliArgs.test.js +6 -10
  12. package/dist/options/config/config.d.ts +28 -52
  13. package/dist/options/config/config.js +2 -36
  14. package/dist/options/config/config.test.js +10 -27
  15. package/dist/options/config/getOptionsFromGit.d.ts +3 -2
  16. package/dist/options/config/getOptionsFromGit.js +1 -3
  17. package/dist/options/config/globalConfig.js +2 -5
  18. package/dist/options/config/globalConfig.test.js +0 -2
  19. package/dist/options/config/projectConfig.test.js +51 -14
  20. package/dist/options/config/readConfigFile.d.ts +52 -0
  21. package/dist/options/config/readConfigFile.js +28 -2
  22. package/dist/options/options.d.ts +55 -32
  23. package/dist/options/options.js +101 -7
  24. package/dist/options/options.test.js +248 -97
  25. package/dist/options/parseRequiredOptions.d.ts +3 -3
  26. package/dist/options/parseRequiredOptions.js +2 -4
  27. package/dist/options/parseRequiredOptions.test.js +6 -11
  28. package/dist/runSequentially.test.js +40 -78
  29. package/dist/services/git.d.ts +5 -2
  30. package/dist/services/git.js +11 -10
  31. package/dist/services/git.test.js +12 -9
  32. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
  33. package/dist/services/github/v3/addAssigneesToPullRequest.js +2 -3
  34. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +4 -5
  35. package/dist/services/github/v3/createPullRequest.js +10 -13
  36. package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
  37. package/dist/services/github/v3/createPullRequest.test.js +110 -0
  38. package/dist/services/github/v3/createStatusComment.js +12 -14
  39. package/dist/services/github/v3/createStatusComment.test.js +58 -29
  40. package/dist/services/github/v4/apiRequestV4.d.ts +1 -1
  41. package/dist/services/github/v4/apiRequestV4.js +1 -1
  42. package/dist/services/github/v4/enablePullRequestAutoMerge.js +1 -1
  43. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -1
  44. package/dist/services/github/v4/fetchAuthorId.d.ts +5 -2
  45. package/dist/services/github/v4/fetchAuthorId.js +5 -6
  46. package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
  47. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +8 -1
  48. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -1
  49. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +6 -3
  50. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +8 -1
  51. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +1 -1
  52. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -3
  53. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +12 -1
  54. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +6 -8
  55. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +10 -12
  56. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +5 -7
  57. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +3 -0
  58. package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +55 -0
  59. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +5 -5
  60. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +2 -6
  61. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -2
  62. package/dist/services/github/v4/fetchProjectConfig.d.ts +8 -0
  63. package/dist/services/github/v4/fetchProjectConfig.js +56 -0
  64. package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +1 -0
  65. package/dist/services/github/v4/fetchProjectConfig.private.test.js +52 -0
  66. package/dist/services/github/v4/fetchProjectConfig.test.d.ts +1 -0
  67. package/dist/services/github/v4/fetchProjectConfig.test.js +37 -0
  68. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +67 -0
  69. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +130 -0
  70. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
  71. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +130 -0
  72. package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +3 -1
  73. package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +22 -1
  74. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +4 -1
  75. package/dist/services/github/v4/getOptionsFromGithub/query.js +3 -0
  76. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +32 -15
  77. package/dist/services/sourceCommit/parseSourceCommit.d.ts +5 -1
  78. package/dist/services/sourceCommit/parseSourceCommit.js +2 -2
  79. package/dist/services/sourceCommit/parseSourceCommit.test.js +120 -5
  80. package/dist/test/inquirer.private.test.js +33 -36
  81. package/dist/test/integration/integration.private.test.js +114 -95
  82. package/dist/test/mockConfigFiles.d.ts +5 -0
  83. package/dist/test/mockConfigFiles.js +37 -0
  84. package/dist/test/nockHelpers.d.ts +1 -1
  85. package/dist/test/nockHelpers.js +4 -4
  86. package/dist/test/private/getDevAccessToken.js +1 -1
  87. package/dist/test/setupFiles/automatic-mocks.js +1 -29
  88. package/dist/ui/cherrypickAndCreatePullRequest.test.js +80 -28
  89. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -9
  90. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +13 -48
  91. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +222 -260
  92. package/dist/ui/getCommits.d.ts +1 -1
  93. package/dist/ui/getCommitsWithoutBackports.d.ts +11 -0
  94. package/dist/ui/getCommitsWithoutBackports.js +53 -0
  95. package/dist/ui/getCommitsWithoutBackports.test.d.ts +1 -0
  96. package/dist/ui/getCommitsWithoutBackports.test.js +259 -0
  97. package/dist/ui/getTargetBranches.d.ts +2 -1
  98. package/dist/ui/getTargetBranches.js +17 -1
  99. package/dist/ui/maybeSetupRepo.js +4 -3
  100. package/dist/ui/maybeSetupRepo.test.js +49 -3
  101. package/dist/utils/excludeUndefined.d.ts +6 -0
  102. package/dist/utils/excludeUndefined.js +7 -0
  103. package/dist/utils/excludeUndefined.test.d.ts +1 -0
  104. package/dist/utils/excludeUndefined.test.js +24 -0
  105. package/package.json +9 -8
  106. package/yarn.lock +98 -77
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* eslint-disable jest/no-commented-out-tests */
6
7
  const os_1 = __importDefault(require("os"));
7
8
  const path_1 = require("path");
8
9
  const rest_1 = require("@octokit/rest");
@@ -11,6 +12,7 @@ const nock_1 = __importDefault(require("nock"));
11
12
  const options_1 = require("../../options/options");
12
13
  const runSequentially_1 = require("../../runSequentially");
13
14
  const getCommits_1 = require("../../ui/getCommits");
15
+ const mockConfigFiles_1 = require("../mockConfigFiles");
14
16
  const nockHelpers_1 = require("../nockHelpers");
15
17
  const getDevAccessToken_1 = require("../private/getDevAccessToken");
16
18
  jest.unmock('make-dir');
@@ -21,7 +23,7 @@ const HOMEDIR_PATH = (0, path_1.resolve)('./src/test/integration/mock-environmen
21
23
  const REPO_OWNER = 'backport-org';
22
24
  const REPO_NAME = 'integration-test';
23
25
  const BRANCH_NAME = 'backport/7.x/commit-5bf29b7d';
24
- const USERNAME = 'sqren';
26
+ const AUHTOR = 'sqren';
25
27
  describe('integration', () => {
26
28
  afterAll(() => {
27
29
  nock_1.default.cleanAll();
@@ -29,6 +31,10 @@ describe('integration', () => {
29
31
  beforeAll(() => {
30
32
  // set alternative homedir
31
33
  jest.spyOn(os_1.default, 'homedir').mockReturnValue(HOMEDIR_PATH);
34
+ (0, mockConfigFiles_1.mockConfigFiles)({
35
+ globalConfig: {},
36
+ projectConfig: {},
37
+ });
32
38
  });
33
39
  describe('when a single commit is backported', () => {
34
40
  let res;
@@ -45,9 +51,10 @@ describe('integration', () => {
45
51
  githubApiBaseUrlV3: 'https://api.foo.com',
46
52
  ci: true,
47
53
  sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
48
- username: USERNAME,
54
+ author: AUHTOR,
49
55
  accessToken,
50
- upstream: 'backport-org/integration-test',
56
+ repoOwner: 'backport-org',
57
+ repoName: 'integration-test',
51
58
  });
52
59
  const commits = await (0, getCommits_1.getCommits)(options);
53
60
  const targetBranches = ['7.x'];
@@ -65,14 +72,23 @@ describe('integration', () => {
65
72
  ]);
66
73
  });
67
74
  it('sends the correct http body when creating pull request', () => {
68
- expect(createPullRequestsMockCalls).toEqual([
69
- {
70
- base: '7.x',
71
- body: 'Backports the following commits to 7.x:\n - Add ❤️ emoji (5bf29b7d)',
72
- head: 'sqren:backport/7.x/commit-5bf29b7d',
73
- title: '[7.x] Add ❤️ emoji',
74
- },
75
- ]);
75
+ expect(createPullRequestsMockCalls).toMatchInlineSnapshot(`
76
+ Array [
77
+ Object {
78
+ "base": "7.x",
79
+ "body": "# Backport
80
+
81
+ This is an automatic backport to 7.x of:
82
+ - Add ❤️ emoji (5bf29b7d)
83
+
84
+ ### Questions ?
85
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
86
+ ",
87
+ "head": "sqren:backport/7.x/commit-5bf29b7d",
88
+ "title": "[7.x] Add ❤️ emoji",
89
+ },
90
+ ]
91
+ `);
76
92
  });
77
93
  it('should not create new branches in origin (backport-org/integration-test)', async () => {
78
94
  const branches = await getBranches({
@@ -85,7 +101,7 @@ describe('integration', () => {
85
101
  it('should create branch in the fork (sqren/integration-test)', async () => {
86
102
  const branches = await getBranches({
87
103
  accessToken,
88
- repoOwner: USERNAME,
104
+ repoOwner: AUHTOR,
89
105
  repoName: REPO_NAME,
90
106
  });
91
107
  expect(branches.map((b) => b.name)).toEqual([
@@ -97,82 +113,75 @@ describe('integration', () => {
97
113
  it('should have cherry picked the correct commit', async () => {
98
114
  const branches = await getBranches({
99
115
  accessToken,
100
- repoOwner: USERNAME,
116
+ repoOwner: AUHTOR,
101
117
  repoName: REPO_NAME,
102
118
  });
103
119
  const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
104
120
  expect(sha).toEqual('b68e4fcaaf4427fe1e902c718b3bb3f07b560fb5');
105
121
  });
106
122
  });
107
- // eslint-disable-next-line jest/no-disabled-tests
108
- describe.skip('when two commits are backported', () => {
109
- let createPullRequestsMockCalls;
110
- let res;
111
- let accessToken;
112
- beforeAll(async () => {
113
- accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
114
- await resetState(accessToken);
115
- createPullRequestsMockCalls = mockCreatePullRequest({
116
- number: 1337,
117
- html_url: 'myHtmlUrl',
118
- });
119
- const options = {
120
- githubApiBaseUrlV3: 'https://api.foo.com',
121
- ci: true,
122
- sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
123
- username: USERNAME,
124
- accessToken,
125
- upstream: 'backport-org/integration-test',
126
- };
127
- const commits = await (0, getCommits_1.getCommits)(options);
128
- const targetBranches = ['7.x'];
129
- res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
130
- });
131
- it('sends the correct http body when creating pull request', () => {
132
- expect(createPullRequestsMockCalls).toEqual([
133
- {
134
- base: '7.x',
135
- body: 'Backports the following commits to 7.x:\n - Add ❤️ emoji (5bf29b7d)',
136
- head: 'sqren:backport/7.x/commit-5bf29b7d',
137
- title: '[7.x] Add ❤️ emoji',
138
- },
139
- ]);
140
- });
141
- it('returns pull request', () => {
142
- expect(res).toEqual([
143
- { pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
144
- ]);
145
- });
146
- it('should not create new branches in origin (backport-org/integration-test)', async () => {
147
- const branches = await getBranches({
148
- accessToken,
149
- repoOwner: REPO_OWNER,
150
- repoName: REPO_NAME,
151
- });
152
- expect(branches.map((b) => b.name)).toEqual(['7.x', '* master']);
153
- });
154
- it('should create branch in the fork (sqren/integration-test)', async () => {
155
- const branches = await getBranches({
156
- accessToken,
157
- repoOwner: USERNAME,
158
- repoName: REPO_NAME,
159
- });
160
- expect(branches.map((b) => b.name)).toEqual([
161
- '7.x',
162
- 'backport/6.0/pr-85_commit-2e63475c',
163
- 'master',
164
- ]);
165
- });
166
- it('should have cherry picked the correct commit', async () => {
167
- const branches = await getBranches({
168
- accessToken,
169
- repoOwner: USERNAME,
170
- repoName: REPO_NAME,
171
- });
172
- const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
173
- expect(sha).toEqual('foo');
174
- });
175
- });
123
+ // describe.skip('when two commits are backported', () => {
124
+ // let createPullRequestsMockCalls: unknown[];
125
+ // let res: Awaited<ReturnType<typeof runSequentially>>;
126
+ // let accessToken: string;
127
+ // beforeAll(async () => {
128
+ // accessToken = await getDevAccessToken();
129
+ // await resetState(accessToken);
130
+ // createPullRequestsMockCalls = mockCreatePullRequest({
131
+ // number: 1337,
132
+ // html_url: 'myHtmlUrl',
133
+ // });
134
+ // const options = {
135
+ // githubApiBaseUrlV3: 'https://api.foo.com',
136
+ // ci: true,
137
+ // sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
138
+ // author: AUHTOR,
139
+ // accessToken,
140
+ // repoOwner: 'backport-org',
141
+ // reponame: 'integration-test',
142
+ // } as ValidConfigOptions;
143
+ // const commits = await getCommits(options);
144
+ // const targetBranches: string[] = ['7.x'];
145
+ // res = await runSequentially({ options, commits, targetBranches });
146
+ // });
147
+ // it('sends the correct http body when creating pull request', () => {
148
+ // expect(createPullRequestsMockCalls).toMatchInlineSnapshot();
149
+ // });
150
+ // it('returns pull request', () => {
151
+ // expect(res).toEqual([
152
+ // { pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
153
+ // ]);
154
+ // });
155
+ // it('should not create new branches in origin (backport-org/integration-test)', async () => {
156
+ // const branches = await getBranches({
157
+ // accessToken,
158
+ // repoOwner: REPO_OWNER,
159
+ // repoName: REPO_NAME,
160
+ // });
161
+ // expect(branches.map((b) => b.name)).toEqual(['7.x', '* master']);
162
+ // });
163
+ // it('should create branch in the fork (sqren/integration-test)', async () => {
164
+ // const branches = await getBranches({
165
+ // accessToken,
166
+ // repoOwner: AUHTOR,
167
+ // repoName: REPO_NAME,
168
+ // });
169
+ // expect(branches.map((b) => b.name)).toEqual([
170
+ // '7.x',
171
+ // 'backport/6.0/pr-85_commit-2e63475c',
172
+ // 'master',
173
+ // ]);
174
+ // });
175
+ // it('should have cherry picked the correct commit', async () => {
176
+ // const branches = await getBranches({
177
+ // accessToken,
178
+ // repoOwner: AUHTOR,
179
+ // repoName: REPO_NAME,
180
+ // });
181
+ // const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
182
+ // expect(sha).toEqual('foo');
183
+ // });
184
+ // });
176
185
  describe('when disabling fork mode', () => {
177
186
  let res;
178
187
  let accessToken;
@@ -185,12 +194,13 @@ describe('integration', () => {
185
194
  html_url: 'myHtmlUrl',
186
195
  });
187
196
  const options = await (0, options_1.getOptions)([], {
197
+ author: AUHTOR,
188
198
  githubApiBaseUrlV3: 'https://api.foo.com',
189
199
  ci: true,
190
200
  sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
191
- username: USERNAME,
192
201
  accessToken,
193
- upstream: 'backport-org/integration-test',
202
+ repoOwner: 'backport-org',
203
+ repoName: 'integration-test',
194
204
  fork: false,
195
205
  });
196
206
  const commits = await (0, getCommits_1.getCommits)(options);
@@ -198,14 +208,23 @@ describe('integration', () => {
198
208
  res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
199
209
  });
200
210
  it('sends the correct http body when creating pull request', () => {
201
- expect(createPullRequestsMockCalls).toEqual([
202
- {
203
- base: '7.x',
204
- body: 'Backports the following commits to 7.x:\n - Add ❤️ emoji (5bf29b7d)',
205
- head: 'backport-org:backport/7.x/commit-5bf29b7d',
206
- title: '[7.x] Add ❤️ emoji',
207
- },
208
- ]);
211
+ expect(createPullRequestsMockCalls).toMatchInlineSnapshot(`
212
+ Array [
213
+ Object {
214
+ "base": "7.x",
215
+ "body": "# Backport
216
+
217
+ This is an automatic backport to 7.x of:
218
+ - Add ❤️ emoji (5bf29b7d)
219
+
220
+ ### Questions ?
221
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
222
+ ",
223
+ "head": "backport-org:backport/7.x/commit-5bf29b7d",
224
+ "title": "[7.x] Add ❤️ emoji",
225
+ },
226
+ ]
227
+ `);
209
228
  });
210
229
  it('returns pull request', () => {
211
230
  expect(res).toEqual([
@@ -233,7 +252,7 @@ describe('integration', () => {
233
252
  it('should NOT create branch in the fork (sqren/integration-test)', async () => {
234
253
  const branches = await getBranches({
235
254
  accessToken,
236
- repoOwner: USERNAME,
255
+ repoOwner: AUHTOR,
237
256
  repoName: REPO_NAME,
238
257
  });
239
258
  expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
@@ -253,7 +272,7 @@ function mockCreatePullRequest(response) {
253
272
  const scope = (0, nock_1.default)('https://api.foo.com', { allowUnmocked: true })
254
273
  .post('/repos/backport-org/integration-test/pulls')
255
274
  .reply(200, response);
256
- return (0, nockHelpers_1.getNockCallsForScope)(scope);
275
+ return (0, nockHelpers_1.listenForCallsToNockScope)(scope);
257
276
  }
258
277
  async function getBranches({ accessToken, repoOwner, repoName, }) {
259
278
  // console.log(`fetch branches for ${repoOwner}`);
@@ -300,7 +319,7 @@ async function resetState(accessToken) {
300
319
  });
301
320
  await deleteBranch({
302
321
  accessToken,
303
- repoOwner: USERNAME,
322
+ repoOwner: AUHTOR,
304
323
  repoName: REPO_NAME,
305
324
  branchName: BRANCH_NAME,
306
325
  });
@@ -0,0 +1,5 @@
1
+ import { ConfigFileOptions } from '../options/ConfigOptions';
2
+ export declare function mockConfigFiles({ projectConfig, globalConfig, }: {
3
+ projectConfig: ConfigFileOptions;
4
+ globalConfig: ConfigFileOptions;
5
+ }): void;
@@ -0,0 +1,37 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.mockConfigFiles = void 0;
23
+ const fs = __importStar(require("../services/fs-promisified"));
24
+ function mockConfigFiles({ projectConfig, globalConfig, }) {
25
+ jest
26
+ .spyOn(fs, 'readFile')
27
+ //@ts-expect-error
28
+ .mockImplementation(async (filepath) => {
29
+ if (filepath === '/path/to/project/config') {
30
+ return JSON.stringify(projectConfig);
31
+ }
32
+ if (filepath.endsWith('.backport/config.json')) {
33
+ return JSON.stringify(globalConfig);
34
+ }
35
+ });
36
+ }
37
+ exports.mockConfigFiles = mockConfigFiles;
@@ -13,4 +13,4 @@ export declare function mockGqlRequest<T>({ name, statusCode, body, headers, api
13
13
  query: string;
14
14
  variables: string;
15
15
  }[];
16
- export declare function getNockCallsForScope(scope: nock.Scope): unknown[];
16
+ export declare function listenForCallsToNockScope(scope: nock.Scope): unknown[];
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getNockCallsForScope = exports.mockGqlRequest = void 0;
6
+ exports.listenForCallsToNockScope = exports.mockGqlRequest = void 0;
7
7
  const url_1 = require("url");
8
8
  const graphql_tag_1 = __importDefault(require("graphql-tag"));
9
9
  const nock_1 = __importDefault(require("nock"));
@@ -14,7 +14,7 @@ function mockGqlRequest({ name, statusCode, body, headers, apiBaseUrl, }) {
14
14
  const scope = (0, nock_1.default)(origin)
15
15
  .post(pathname, (body) => getGqlName(body.query) === name)
16
16
  .reply(statusCode, body, headers);
17
- return getNockCallsForScope(scope);
17
+ return listenForCallsToNockScope(scope);
18
18
  }
19
19
  exports.mockGqlRequest = mockGqlRequest;
20
20
  function getGqlName(query) {
@@ -24,11 +24,11 @@ function getGqlName(query) {
24
24
  // @ts-expect-error
25
25
  return obj.definitions[0].name.value;
26
26
  }
27
- function getNockCallsForScope(scope) {
27
+ function listenForCallsToNockScope(scope) {
28
28
  const calls = [];
29
29
  scope.on('request', (req, interceptor, body) => {
30
30
  calls.push(JSON.parse(body));
31
31
  });
32
32
  return calls;
33
33
  }
34
- exports.getNockCallsForScope = getNockCallsForScope;
34
+ exports.listenForCallsToNockScope = listenForCallsToNockScope;
@@ -18,7 +18,7 @@ async function getDevAccessToken() {
18
18
  return accessToken.trim();
19
19
  }
20
20
  catch (e) {
21
- throw new Error(`Missing username or accessToken in "${accessTokenFile}"`);
21
+ throw new Error(`Missing accessToken in "${accessTokenFile}"`);
22
22
  }
23
23
  }
24
24
  exports.getDevAccessToken = getDevAccessToken;
@@ -4,34 +4,6 @@
4
4
  * It will be run once per test file
5
5
  */
6
6
  /* eslint-disable @typescript-eslint/no-empty-function */
7
- jest.mock('../../services/fs-promisified', () => {
8
- return {
9
- writeFile: jest.fn(async () => 'fs.writeFile mock value'),
10
- readFile: jest.fn(async (filepath) => {
11
- // mock project config
12
- if (filepath === '/path/to/project/config') {
13
- return JSON.stringify({
14
- upstream: 'backport-org/backport-demo',
15
- targetBranchChoices: ['6.0', '5.9'],
16
- });
17
- }
18
- // mock global config
19
- if (filepath.endsWith('/.backport/config.json')) {
20
- return JSON.stringify({
21
- username: 'sqren',
22
- accessToken: 'myAccessToken',
23
- });
24
- }
25
- throw new Error(`Unknown filepath: "${filepath}"`);
26
- }),
27
- stat: jest.fn(async () => {
28
- return {
29
- isDirectory: () => { },
30
- };
31
- }),
32
- chmod: jest.fn(async () => 'fs.chmod mock value'),
33
- };
34
- });
35
7
  jest.mock('find-up', () => {
36
8
  return jest.fn(async () => '/path/to/project/config');
37
9
  });
@@ -56,9 +28,9 @@ jest.mock('ora', () => {
56
28
  jest.mock('../../services/logger', () => {
57
29
  const spy = jest.fn();
58
30
  return {
31
+ redactAccessToken: jest.fn((str) => str),
59
32
  consoleLog: jest.fn(),
60
33
  updateLogger: jest.fn(),
61
- redact: () => { },
62
34
  logger: {
63
35
  spy: spy,
64
36
  info: (msg, meta) => spy(`[INFO] ${msg}`, meta),