backport 6.3.0-beta-7 → 7.0.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.
@@ -79,6 +79,8 @@ describe('inquirer cli', () => {
79
79
  -b, --targetBranch, --branch Branch(es) to backport to [array]
80
80
  --targetBranchChoice List branches to backport to [array]
81
81
  -l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
82
+ --username User repo that branch will be pushed to. Defaults to the
83
+ authenticated user [string]
82
84
  --verbose Show additional debug information [boolean]
83
85
  --verify Opposite of no-verify [boolean]
84
86
  --help Show help [boolean]
@@ -4,7 +4,7 @@ const entrypoint_module_1 = require("./entrypoint.module");
4
4
  const getDevAccessToken_1 = require("./test/private/getDevAccessToken");
5
5
  describe('entrypoint.module', () => {
6
6
  it('getCommits', async () => {
7
- const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
7
+ const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
8
8
  const commits = await (0, entrypoint_module_1.getCommits)({
9
9
  accessToken: accessToken,
10
10
  repoName: 'backport-e2e',
@@ -262,7 +262,7 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
262
262
  string: true,
263
263
  })
264
264
  .option('username', {
265
- description: 'User repo that branch will be pushed to. Defaults to the authenticated user',
265
+ description: 'Defaults to the authenticated user ',
266
266
  type: 'string',
267
267
  })
268
268
  .option('verbose', {
@@ -139,6 +139,8 @@ function throwForRequiredOptions(options) {
139
139
  'username',
140
140
  ];
141
141
  // Disallow empty strings
142
+ // this is primarily an issue in Github actions where inputs default to empty strings instead of undefined
143
+ // in those cases failing early provides a better UX
142
144
  optionKeys.forEach((optionName) => {
143
145
  const option = options[optionName];
144
146
  if (option === '') {
@@ -62,11 +62,11 @@ describe('getOptions', () => {
62
62
  });
63
63
  await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects
64
64
  .toThrowErrorMatchingInlineSnapshot(`
65
- "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
66
- It must contain a valid \\"accessToken\\".
65
+ "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
66
+ It must contain a valid \\"accessToken\\".
67
67
 
68
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
69
- `);
68
+ Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
69
+ `);
70
70
  });
71
71
  it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
72
72
  mockProjectConfig({
@@ -81,6 +81,23 @@ describe('getOptions', () => {
81
81
  Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
82
82
  `);
83
83
  });
84
+ describe('whe option is an empty string', () => {
85
+ it('throws for "username"', async () => {
86
+ await expect(() => (0, options_1.getOptions)([], { username: '', author: 'sqren' })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"username\\" cannot be empty!"`);
87
+ });
88
+ it('throws for "author"', async () => {
89
+ await expect(() => (0, options_1.getOptions)([], { author: '' })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
90
+ });
91
+ it('throws for "accessToken"', async () => {
92
+ await expect(() => (0, options_1.getOptions)([], { accessToken: '' })).rejects
93
+ .toThrowErrorMatchingInlineSnapshot(`
94
+ "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
95
+ It must contain a valid \\"accessToken\\".
96
+
97
+ Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
98
+ `);
99
+ });
100
+ });
84
101
  describe('when repoName and repoOwner are missing', () => {
85
102
  beforeEach(() => {
86
103
  mockProjectConfig({ repoName: undefined, repoOwner: undefined });
@@ -89,10 +106,10 @@ describe('getOptions', () => {
89
106
  jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
90
107
  await expect(() => (0, options_1.getOptions)([], {})).rejects
91
108
  .toThrowErrorMatchingInlineSnapshot(`
92
- "Please specify a repo name: \\"--repo-name kibana\\".
109
+ "Please specify a repo name: \\"--repo-name kibana\\".
93
110
 
94
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
95
- `);
111
+ Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
112
+ `);
96
113
  });
97
114
  it('should get repoName from the remote', async () => {
98
115
  mockRepoOwnerAndName({
@@ -66,8 +66,8 @@ function getCommentBody({ options, pullNumber, backportResponse, }) {
66
66
  if (backportResponse.error instanceof HandledError_1.HandledError &&
67
67
  backportResponse.error.errorContext?.code === 'no-branches-exception') {
68
68
  return `## ⚪ Backport skipped
69
- The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
70
- ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
69
+ The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
70
+ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
71
71
  }
72
72
  return `## 💔 Backport failed
73
73
  The pull request could not be backported due to the following error:
@@ -365,8 +365,8 @@ describe('getCommentBody', () => {
365
365
  const params = getParams({ ci: true });
366
366
  expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
367
367
  "## ⚪ Backport skipped
368
- The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
369
-
368
+ The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
369
+
370
370
  ### Manual backport
371
371
  To create the backport manually run:
372
372
  \`\`\`
@@ -63,7 +63,7 @@ describe.skip('enablePullRequestAutoMerge', () => {
63
63
  let octokit;
64
64
  let options;
65
65
  beforeAll(async () => {
66
- const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
66
+ const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
67
67
  const randomString = crypto_1.default.randomBytes(4).toString('hex');
68
68
  branchName = `test-${randomString}`;
69
69
  options = {
@@ -22,13 +22,7 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
22
22
  };
23
23
  }
24
24
  return {
25
- repository: {
26
- name: 'kibana',
27
- owner: { login: 'elastic' },
28
- },
29
- committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
30
- sha: sourceCommit.sha ?? defaultSourceCommitSha,
31
- message: sourceCommit.message,
25
+ ...baseMockCommit,
32
26
  associatedPullRequests: {
33
27
  edges: [
34
28
  {
@@ -29,7 +29,7 @@ describe('backport e2e', () => {
29
29
  beforeAll(async () => {
30
30
  // set alternative homedir
31
31
  jest.spyOn(os_1.default, 'homedir').mockReturnValue(`${sandboxPath}/homedir`);
32
- accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
32
+ accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
33
33
  (0, mockConfigFiles_1.mockConfigFiles)({
34
34
  globalConfig: {},
35
35
  projectConfig: {},
@@ -8,7 +8,7 @@ jest.unmock('find-up');
8
8
  jest.setTimeout(15000);
9
9
  describe('Handle unbackported pull requests', () => {
10
10
  it('shows missing backports for PR number 8', async () => {
11
- const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
11
+ const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
12
12
  const commits = await (0, entrypoint_module_1.getCommits)({
13
13
  accessToken: accessToken,
14
14
  repoOwner: 'backport-org',
@@ -35,7 +35,7 @@ describe('Handle unbackported pull requests', () => {
35
35
  expect(commits[0]).toEqual(expectedCommit);
36
36
  });
37
37
  it('shows that backport failed because PR number 8 was not backported', async () => {
38
- const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
38
+ const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
39
39
  const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
40
40
  await (0, sandbox_1.resetSandbox)(sandboxPath);
41
41
  await (0, child_process_promisified_1.exec)('git init', { cwd: sandboxPath });
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "6.3.0-beta-6";
1
+ export declare const PACKAGE_VERSION = "7.0.0";
@@ -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 = '6.3.0-beta-6';
4
+ exports.PACKAGE_VERSION = '7.0.0';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "branches",
15
15
  "branching"
16
16
  ],
17
- "version": "6.3.0-beta-7",
17
+ "version": "7.0.0",
18
18
  "main": "./dist/entrypoint.module.js",
19
19
  "types": "dist/entrypoint.module.d.ts",
20
20
  "bin": {
@@ -23,12 +23,12 @@
23
23
  "license": "MIT",
24
24
  "scripts": {
25
25
  "postinstall": "test -f ./dist/scripts/runPostinstall.js && node ./dist/scripts/runPostinstall.js || echo 'Dist folder missing'",
26
- "postversion": "yarn extractPackageVersion && yarn build",
26
+ "version": "echo \"Bumping version\" && yarn extractPackageVersion && git add src/utils/packageVersion.ts && yarn build",
27
27
  "prepare": "husky install",
28
- "prepublishOnly": "yarn build",
28
+ "prepublishOnly": "yarn lint",
29
29
  "build": "tsc --project ./tsconfig.prod.json",
30
30
  "extractPackageVersion": "node -p \"'export const PACKAGE_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" | prettier > src/utils/packageVersion.ts",
31
- "lint": "tsc --project ./tsconfig.test.json && eslint './**/*.{ts,js}'",
31
+ "lint": "echo \"Running lint\" && tsc --project ./tsconfig.test.json && eslint './**/*.{ts,js}'",
32
32
  "start": "ts-node --transpile-only ./src/entrypoint.cli.ts",
33
33
  "test-all": "yarn lint && jest --config ./jest.config.all.js",
34
34
  "test-mutation": "jest --config ./jest.config.mutation.js",
@@ -91,24 +91,24 @@
91
91
  "@types/safe-json-stringify": "^1.1.2",
92
92
  "@types/yargs": "^17.0.8",
93
93
  "@types/yargs-parser": "^20.2.1",
94
- "@typescript-eslint/eslint-plugin": "^5.10.2",
95
- "@typescript-eslint/parser": "^5.10.2",
94
+ "@typescript-eslint/eslint-plugin": "^5.11.0",
95
+ "@typescript-eslint/parser": "^5.11.0",
96
96
  "eslint": "^8.8.0",
97
97
  "eslint-config-prettier": "^8.3.0",
98
98
  "eslint-plugin-import": "^2.25.4",
99
- "eslint-plugin-jest": "^26.0.0",
99
+ "eslint-plugin-jest": "^26.1.0",
100
100
  "eslint-plugin-prettier": "^4.0.0",
101
101
  "graphql": "^16.3.0",
102
102
  "graphql-config": "^4.1.0",
103
103
  "husky": "^7.0.4",
104
- "jest": "^27.4.7",
104
+ "jest": "^27.5.1",
105
105
  "jest-snapshot-serializer-ansi": "^1.0.0",
106
106
  "lint-staged": "^12.3.3",
107
107
  "nock": "^13.2.4",
108
108
  "prettier": "^2.5.1",
109
109
  "strip-ansi": "^6.0.1",
110
110
  "ts-jest": "^27.1.3",
111
- "ts-node": "^10.4.0",
111
+ "ts-node": "^10.5.0",
112
112
  "typescript": "^4.5.5"
113
113
  }
114
114
  }