npm-update-package 0.23.1 → 0.24.2

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
@@ -14,7 +14,7 @@ npx npm-update-package --github-token $GITHUB_TOKEN
14
14
  ## Options
15
15
 
16
16
  You can customize behavior via command-line options.
17
- Template strings such as `--commit-message` can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
17
+ Some options can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
18
18
 
19
19
  ### `--commit-message`
20
20
 
@@ -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`
@@ -81,7 +80,7 @@ Available tokens and permissions required for each token are as follows.
81
80
 
82
81
  - [GitHub Actions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)
83
82
  - [GitHub App](https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps)
84
- - Contents: Read-only
83
+ - Contents: Read & write
85
84
  - Metadata: Read-only
86
85
  - Pull requests: Read & write
87
86
  - [Personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
@@ -105,7 +104,7 @@ Creating a GitHub App may be tedious, but you only have to do it once the first
105
104
 
106
105
  ## Examples
107
106
 
108
- - Use token of GitHub Actions
107
+ - [Use token of GitHub Actions](https://github.com/npm-update-package/example-github-actions)
109
108
 
110
109
  ```yaml
111
110
  name: npm-update-package
@@ -128,8 +127,7 @@ jobs:
128
127
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129
128
  ```
130
129
 
131
-
132
- - Use token of GitHub App
130
+ - [Use token of GitHub App](https://github.com/npm-update-package/example-github-app)
133
131
 
134
132
  ```yaml
135
133
  name: npm-update-package
@@ -160,12 +158,30 @@ jobs:
160
158
  GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
161
159
  ```
162
160
 
163
- Actual working examples can be seen in these repositories.
161
+ - [Use Personal access token](https://github.com/npm-update-package/example-pat)
164
162
 
165
- |Repository|Package manager|GitHub token|
166
- |---|---|---|
167
- |[example-github-actions](https://github.com/npm-update-package/example-github-actions)|npm|GitHub Actions|
168
- |[example-github-app](https://github.com/npm-update-package/example-github-app)|npm|GitHub App|
163
+ ```yaml
164
+ name: npm-update-package
165
+ on:
166
+ schedule:
167
+ - cron: '0 0 * * *'
168
+ jobs:
169
+ npm-update-package:
170
+ runs-on: ubuntu-latest
171
+ steps:
172
+ - uses: actions/checkout@v2
173
+ - uses: actions/setup-node@v2
174
+ - run: |
175
+ git config user.name $GIT_USER_NAME
176
+ git config user.email $GIT_USER_EMAIL
177
+ npx npm-update-package --github-token $GITHUB_TOKEN
178
+ env:
179
+ # TODO: Replace with your email
180
+ GIT_USER_EMAIL: 97961304+npm-update-package-bot@users.noreply.github.com
181
+ # TODO: Replace with your name
182
+ GIT_USER_NAME: npm-update-package-bot
183
+ GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
184
+ ```
169
185
 
170
186
  ## Flow
171
187
 
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.1',
6
+ version: '0.24.2',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
@@ -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,
@@ -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;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isPackageManagerName = exports.PackageManagerName = void 0;
4
4
  exports.PackageManagerName = {
5
5
  Npm: 'npm',
6
- Yarn: 'Yarn'
6
+ Yarn: 'yarn'
7
7
  };
8
8
  const packageManagerNames = Object.values(exports.PackageManagerName);
9
9
  const isPackageManagerName = (value) => packageManagerNames.includes(value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.23.1",
3
+ "version": "0.24.2",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.build.json",
@@ -37,7 +37,7 @@
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",
40
+ "@typescript-eslint/eslint-plugin": "5.10.0",
41
41
  "eslint": "8.7.0",
42
42
  "eslint-config-standard-with-typescript": "21.0.1",
43
43
  "eslint-plugin-import": "2.25.4",
@@ -47,7 +47,7 @@
47
47
  "eslint-plugin-tsdoc": "0.2.14",
48
48
  "husky": "7.0.4",
49
49
  "jest": "27.4.7",
50
- "lint-staged": "12.1.7",
50
+ "lint-staged": "12.2.0",
51
51
  "npm-run-all": "4.1.5",
52
52
  "rimraf": "3.0.2",
53
53
  "ts-jest": "27.1.3",