npm-update-package 0.22.4 → 0.24.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 CHANGED
@@ -22,17 +22,16 @@ Commit message template
22
22
 
23
23
  - type: string
24
24
  - required: false
25
- - variables:
26
- - `currentVersion`
27
- - `newVersion`
28
- - `packageName`
29
- - `updateType`
30
- - default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
25
+ - variables
26
+ - `currentVersion`: current package version
27
+ - `newVersion`: new package version
28
+ - `packageName`: package name
29
+ - `level`: semver level (major/minor/patch)
30
+ - default: `chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}`
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
@@ -43,7 +42,7 @@ Log level to show
43
42
 
44
43
  - type: string
45
44
  - required: false
46
- - allowed values:
45
+ - allowed values
47
46
  - `off`: Do not output any logs.
48
47
  - `error`: Output error logs.
49
48
  - `info`: Output error/info logs.
@@ -56,9 +55,9 @@ Package manager of your project
56
55
 
57
56
  - type: string
58
57
  - required: false
59
- - allowed values:
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`
@@ -67,23 +66,33 @@ Pull request title template
67
66
 
68
67
  - type: string
69
68
  - required: false
70
- - variables:
71
- - `currentVersion`
72
- - `newVersion`
73
- - `packageName`
74
- - `updateType`
75
- - default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
69
+ - variables
70
+ - `currentVersion`: current package version
71
+ - `newVersion`: new package version
72
+ - `packageName`: package name
73
+ - `level`: semver level (major/minor/patch)
74
+ - default: `chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}`
76
75
 
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-only
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.22.4',
6
+ version: '0.24.0',
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;
@@ -10,13 +10,12 @@ class CommitMessageCreator {
10
10
  const packageName = outdatedPackage.name;
11
11
  const currentVersion = outdatedPackage.currentVersion.version;
12
12
  const newVersion = outdatedPackage.newVersion.version;
13
- // TODO: rename to level
14
- const updateType = outdatedPackage.level;
13
+ const level = outdatedPackage.level;
15
14
  return (0, mustache_1.render)(this.template, {
16
15
  packageName,
17
16
  currentVersion,
18
17
  newVersion,
19
- updateType
18
+ level
20
19
  });
21
20
  }
22
21
  }
@@ -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;
@@ -10,13 +10,12 @@ class PullRequestTitleCreator {
10
10
  const packageName = outdatedPackage.name;
11
11
  const currentVersion = outdatedPackage.currentVersion.version;
12
12
  const newVersion = outdatedPackage.newVersion.version;
13
- // TODO: rename to level
14
- const updateType = outdatedPackage.level;
13
+ const level = outdatedPackage.level;
15
14
  return (0, mustache_1.render)(this.template, {
16
15
  packageName,
17
16
  currentVersion,
18
17
  newVersion,
19
- updateType
18
+ level
20
19
  });
21
20
  }
22
21
  }
@@ -13,10 +13,9 @@ const createPullRequestBody = (outdatedPackage) => {
13
13
  const packageName = outdatedPackage.name;
14
14
  const level = outdatedPackage.level;
15
15
  const metadata = (0, json_1.toJSON)((0, metadata_1.createPullRequestMetadata)([outdatedPackage]), { pretty: true });
16
- // TODO: rename type to level
17
16
  return `This PR updates these packages:
18
17
 
19
- |package|type|current version|new version|
18
+ |Package|Level|Current version|New version|
20
19
  |---|---|---|---|
21
20
  |[${packageName}](https://www.npmjs.com/package/${packageName})|${level}|\`${currentVersion}\`|\`${newVersion}\`|
22
21
 
@@ -9,8 +9,7 @@ const PullRequestMetadata = (0, io_ts_1.type)({
9
9
  name: io_ts_1.string,
10
10
  currentVersion: io_ts_1.string,
11
11
  newVersion: io_ts_1.string,
12
- // TODO: rename to level
13
- type: (0, io_ts_1.union)([(0, io_ts_1.literal)(semver_1.SemVerLevel.Major), (0, io_ts_1.literal)(semver_1.SemVerLevel.Minor), (0, io_ts_1.literal)(semver_1.SemVerLevel.Patch)])
12
+ level: (0, io_ts_1.union)([(0, io_ts_1.literal)(semver_1.SemVerLevel.Major), (0, io_ts_1.literal)(semver_1.SemVerLevel.Minor), (0, io_ts_1.literal)(semver_1.SemVerLevel.Patch)])
14
13
  }))
15
14
  });
16
15
  exports.isPullRequestMetadata = PullRequestMetadata.is;
@@ -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,
@@ -10,7 +9,7 @@ const createPullRequestMetadata = (outdatedPackages) => {
10
9
  name,
11
10
  currentVersion: currentVersion.version,
12
11
  newVersion: newVersion.version,
13
- type: level
12
+ level
14
13
  }))
15
14
  };
16
15
  };
@@ -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;
@@ -10,7 +10,7 @@ exports.cliOptions = [
10
10
  description: 'Commit message template',
11
11
  type: OptionType_1.OptionType.String,
12
12
  required: false,
13
- default: 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}'
13
+ default: 'chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}'
14
14
  },
15
15
  {
16
16
  name: 'github-token',
@@ -47,6 +47,6 @@ exports.cliOptions = [
47
47
  description: 'Pull request title template',
48
48
  type: OptionType_1.OptionType.String,
49
49
  required: false,
50
- default: 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}'
50
+ default: 'chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}'
51
51
  }
52
52
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.22.4",
3
+ "version": "0.24.0",
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",
@@ -50,7 +50,7 @@
50
50
  "lint-staged": "12.1.7",
51
51
  "npm-run-all": "4.1.5",
52
52
  "rimraf": "3.0.2",
53
- "ts-jest": "27.1.2",
53
+ "ts-jest": "27.1.3",
54
54
  "ts-node": "10.4.0",
55
55
  "typescript": "4.5.4",
56
56
  "utility-types": "3.10.0"