npm-update-package 0.23.2 → 0.24.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.
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
|
-
|
|
17
|
+
Some options can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
|
|
18
18
|
|
|
19
19
|
### `--commit-message`
|
|
20
20
|
|
|
@@ -31,7 +31,7 @@ Commit message template
|
|
|
31
31
|
|
|
32
32
|
### `--github-token`
|
|
33
33
|
|
|
34
|
-
[GitHub token](#github-token)
|
|
34
|
+
[GitHub token](#github-token)
|
|
35
35
|
|
|
36
36
|
- type: string
|
|
37
37
|
- required: true
|
|
@@ -80,7 +80,7 @@ Available tokens and permissions required for each token are as follows.
|
|
|
80
80
|
|
|
81
81
|
- [GitHub Actions](https://docs.github.com/en/actions/security-guides/automatic-token-authentication)
|
|
82
82
|
- [GitHub App](https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps)
|
|
83
|
-
- Contents: Read
|
|
83
|
+
- Contents: Read & write
|
|
84
84
|
- Metadata: Read-only
|
|
85
85
|
- Pull requests: Read & write
|
|
86
86
|
- [Personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
|
|
@@ -104,7 +104,7 @@ Creating a GitHub App may be tedious, but you only have to do it once the first
|
|
|
104
104
|
|
|
105
105
|
## Examples
|
|
106
106
|
|
|
107
|
-
- Use token of GitHub Actions
|
|
107
|
+
- [Use token of GitHub Actions](https://github.com/npm-update-package/example-github-actions)
|
|
108
108
|
|
|
109
109
|
```yaml
|
|
110
110
|
name: npm-update-package
|
|
@@ -127,8 +127,7 @@ jobs:
|
|
|
127
127
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
- Use token of GitHub App
|
|
130
|
+
- [Use token of GitHub App](https://github.com/npm-update-package/example-github-app)
|
|
132
131
|
|
|
133
132
|
```yaml
|
|
134
133
|
name: npm-update-package
|
|
@@ -159,12 +158,61 @@ jobs:
|
|
|
159
158
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
160
159
|
```
|
|
161
160
|
|
|
162
|
-
|
|
161
|
+
- [Use Personal access token](https://github.com/npm-update-package/example-pat)
|
|
162
|
+
|
|
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
|
+
```
|
|
185
|
+
|
|
186
|
+
- [Use Yarn](https://github.com/npm-update-package/example-yarn)
|
|
163
187
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
188
|
+
```yaml
|
|
189
|
+
name: npm-update-package
|
|
190
|
+
on:
|
|
191
|
+
schedule:
|
|
192
|
+
- cron: '0 0 * * *'
|
|
193
|
+
jobs:
|
|
194
|
+
npm-update-package:
|
|
195
|
+
runs-on: ubuntu-latest
|
|
196
|
+
steps:
|
|
197
|
+
- uses: actions/checkout@v2
|
|
198
|
+
- uses: actions/setup-node@v2
|
|
199
|
+
- name: Generate token
|
|
200
|
+
id: generate_token
|
|
201
|
+
uses: tibdex/github-app-token@v1
|
|
202
|
+
with:
|
|
203
|
+
app_id: ${{ secrets.APP_ID }}
|
|
204
|
+
private_key: ${{ secrets.PRIVATE_KEY }}
|
|
205
|
+
- run: |
|
|
206
|
+
git config user.name $GIT_USER_NAME
|
|
207
|
+
git config user.email $GIT_USER_EMAIL
|
|
208
|
+
npx npm-update-package --github-token $GITHUB_TOKEN --package-manager yarn
|
|
209
|
+
env:
|
|
210
|
+
# TODO: Replace with your GitHub App's email
|
|
211
|
+
GIT_USER_EMAIL: 97396142+npm-update-package-bot[bot]@users.noreply.github.com
|
|
212
|
+
# TODO: Replace with your GitHub App's user name
|
|
213
|
+
GIT_USER_NAME: npm-update-package-bot[bot]
|
|
214
|
+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
215
|
+
```
|
|
168
216
|
|
|
169
217
|
## Flow
|
|
170
218
|
|
package/dist/app.js
CHANGED
package/dist/github/GitHub.js
CHANGED
|
@@ -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({
|
|
@@ -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: '
|
|
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.
|
|
3
|
+
"version": "0.24.3",
|
|
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.
|
|
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.
|
|
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",
|