npm-update-package 0.23.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,8 +31,7 @@ Commit message template
31
31
 
32
32
  ### `--github-token`
33
33
 
34
- GitHub token.
35
- See more in [GitHub token](#github-token) section.
34
+ [GitHub token](#github-token).
36
35
 
37
36
  - type: string
38
37
  - required: true
@@ -58,7 +57,7 @@ Package manager of your project
58
57
  - required: false
59
58
  - allowed values
60
59
  - `npm`: npm
61
- - `yarn`: Yarn
60
+ - `yarn`: Yarn (**It has not been tested yet.**)
62
61
  - default: `npm`
63
62
 
64
63
  ### `--pull-request-title`
@@ -77,13 +76,23 @@ Pull request title template
77
76
  ## GitHub token
78
77
 
79
78
  GitHub token is required to run npm-update-package.
80
- For example, the following tokens can be used.
79
+ Available tokens and permissions required for each token are as follows.
81
80
 
82
- |GitHub token|Owner|Author of pull requests|Trigger other actions|
81
+ - [GitHub Actions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)
82
+ - [GitHub App](https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps)
83
+ - Contents: Read & write
84
+ - Metadata: Read-only
85
+ - Pull requests: Read & write
86
+ - [Personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
87
+ - repo
88
+
89
+ Features of each token are as follows.
90
+
91
+ ||GitHub Actions|GitHub App|Personal access token|
83
92
  |---|---|---|---|
84
- |[GitHub Actions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)|GitHub|`github-actions`||
85
- |[GitHub App](https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps)|organization or personal account|app which issued the token|✓|
86
- |[Personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)|personal account|user who issued the token|✓|
93
+ |Owner of token|GitHub|organization or user|user|
94
+ |Author of pull requests|`github-actions`|app|user|
95
+ |Trigger other actions|-|✓|✓|
87
96
 
88
97
  We recommend using GitHub App for the following reasons.
89
98
 
@@ -93,20 +102,6 @@ We recommend using GitHub App for the following reasons.
93
102
 
94
103
  Creating a GitHub App may be tedious, but you only have to do it once the first time.
95
104
 
96
- ### Token of GitHub App
97
-
98
- These permissions are required.
99
-
100
- - Contents: Read-only
101
- - Metadata: Read-only
102
- - Pull requests: Read & write
103
-
104
- ### Personal access token
105
-
106
- These permissions are required.
107
-
108
- - repo
109
-
110
105
  ## Examples
111
106
 
112
107
  - Use token of GitHub Actions
package/dist/app.js CHANGED
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.app = void 0;
4
4
  exports.app = {
5
5
  name: 'npm-update-package',
6
- version: '0.23.0',
6
+ version: '0.24.1',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutdatedPackagesProcessor = void 0;
4
+ // TODO: add test
4
5
  class OutdatedPackagesProcessor {
5
6
  constructor({ outdatedPackageProcessor, logger }) {
6
7
  this.outdatedPackageProcessor = outdatedPackageProcessor;
@@ -20,6 +20,13 @@ class GitHub {
20
20
  const { data } = await this.octokit.pulls.create(params);
21
21
  return data;
22
22
  }
23
+ async deleteBranch({ owner, repo, branch }) {
24
+ await this.octokit.git.deleteRef({
25
+ owner,
26
+ repo,
27
+ ref: `heads/${branch}`
28
+ });
29
+ }
23
30
  // TODO: fetch all branches with page option
24
31
  async fetchBranches(params) {
25
32
  const { data } = await this.octokit.repos.listBranches({
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createGitHub = void 0;
4
4
  const createOctokit_1 = require("./createOctokit");
5
5
  const GitHub_1 = require("./GitHub");
6
- // TODO: add test
7
6
  const createGitHub = ({ repository, token }) => {
8
7
  const octokit = (0, createOctokit_1.createOctokit)({
9
8
  repository,
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createOctokit = void 0;
4
4
  const rest_1 = require("@octokit/rest");
5
5
  const app_1 = require("../app");
6
- // TODO: add test
7
6
  const createOctokit = ({ repository, token }) => {
8
7
  const auth = `token ${token}`;
9
8
  const userAgent = `${app_1.app.name}/${app_1.app.version}`;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PullRequestCloser = void 0;
4
- // TODO: Add test
5
4
  class PullRequestCloser {
6
5
  constructor(github) {
7
6
  this.github = github;
@@ -12,6 +11,11 @@ class PullRequestCloser {
12
11
  repo: pullRequest.base.repo.name,
13
12
  pull_number: pullRequest.number
14
13
  });
14
+ await this.github.deleteBranch({
15
+ owner: pullRequest.base.repo.owner.login,
16
+ repo: pullRequest.base.repo.name,
17
+ branch: pullRequest.head.ref
18
+ });
15
19
  }
16
20
  }
17
21
  exports.PullRequestCloser = PullRequestCloser;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPullRequestMetadata = void 0;
4
4
  const app_1 = require("../../../app");
5
- // TODO: Add test
6
5
  const createPullRequestMetadata = (outdatedPackages) => {
7
6
  return {
8
7
  version: app_1.app.version,
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toJSON = void 0;
4
- // TODO: Add test
5
4
  const toJSON = (value, options) => {
6
5
  var _a;
7
6
  const pretty = (_a = options === null || options === void 0 ? void 0 : options.pretty) !== null && _a !== void 0 ? _a : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.23.0",
3
+ "version": "0.24.1",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.build.json",
@@ -20,7 +20,7 @@
20
20
  "@octokit/rest": "18.12.0",
21
21
  "commander": "8.3.0",
22
22
  "execa": "5.1.1",
23
- "fp-ts": "2.11.7",
23
+ "fp-ts": "2.11.8",
24
24
  "io-ts": "2.2.16",
25
25
  "log4js": "6.3.0",
26
26
  "mustache": "4.1.0",
@@ -37,11 +37,11 @@
37
37
  "@types/node": "12.20.40",
38
38
  "@types/parse-github-url": "1.0.0",
39
39
  "@types/semver": "7.3.9",
40
- "@typescript-eslint/eslint-plugin": "5.9.1",
41
- "eslint": "8.6.0",
40
+ "@typescript-eslint/eslint-plugin": "5.10.0",
41
+ "eslint": "8.7.0",
42
42
  "eslint-config-standard-with-typescript": "21.0.1",
43
43
  "eslint-plugin-import": "2.25.4",
44
- "eslint-plugin-jest": "25.3.4",
44
+ "eslint-plugin-jest": "25.7.0",
45
45
  "eslint-plugin-node": "11.1.0",
46
46
  "eslint-plugin-promise": "6.0.0",
47
47
  "eslint-plugin-tsdoc": "0.2.14",