npm-update-package 0.24.1 → 0.26.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 +66 -11
- package/dist/app.js +1 -1
- package/dist/github/GitHub.js +8 -0
- package/dist/github/pull-request/creator/PullRequestCreator.js +10 -1
- package/dist/main.js +2 -1
- package/dist/options/Options.js +12 -7
- package/dist/options/cliOptions.js +6 -0
- package/dist/package-manager/PackageManagerName.js +1 -1
- package/package.json +2 -2
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
|
|
@@ -57,7 +57,7 @@ Package manager of your project
|
|
|
57
57
|
- required: false
|
|
58
58
|
- allowed values
|
|
59
59
|
- `npm`: npm
|
|
60
|
-
- `yarn`: Yarn
|
|
60
|
+
- `yarn`: Yarn
|
|
61
61
|
- default: `npm`
|
|
62
62
|
|
|
63
63
|
### `--pull-request-title`
|
|
@@ -73,6 +73,13 @@ Pull request title template
|
|
|
73
73
|
- `level`: semver level (major/minor/patch)
|
|
74
74
|
- default: `chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}`
|
|
75
75
|
|
|
76
|
+
### `--reviewers`
|
|
77
|
+
|
|
78
|
+
User names to request reviews
|
|
79
|
+
|
|
80
|
+
- type: string[]
|
|
81
|
+
- required: false
|
|
82
|
+
|
|
76
83
|
## GitHub token
|
|
77
84
|
|
|
78
85
|
GitHub token is required to run npm-update-package.
|
|
@@ -104,7 +111,7 @@ Creating a GitHub App may be tedious, but you only have to do it once the first
|
|
|
104
111
|
|
|
105
112
|
## Examples
|
|
106
113
|
|
|
107
|
-
- Use token of GitHub Actions
|
|
114
|
+
- [Use token of GitHub Actions](https://github.com/npm-update-package/example-github-actions)
|
|
108
115
|
|
|
109
116
|
```yaml
|
|
110
117
|
name: npm-update-package
|
|
@@ -127,8 +134,7 @@ jobs:
|
|
|
127
134
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
128
135
|
```
|
|
129
136
|
|
|
130
|
-
|
|
131
|
-
- Use token of GitHub App
|
|
137
|
+
- [Use token of GitHub App](https://github.com/npm-update-package/example-github-app)
|
|
132
138
|
|
|
133
139
|
```yaml
|
|
134
140
|
name: npm-update-package
|
|
@@ -159,12 +165,61 @@ jobs:
|
|
|
159
165
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
160
166
|
```
|
|
161
167
|
|
|
162
|
-
|
|
168
|
+
- [Use Personal access token](https://github.com/npm-update-package/example-pat)
|
|
169
|
+
|
|
170
|
+
```yaml
|
|
171
|
+
name: npm-update-package
|
|
172
|
+
on:
|
|
173
|
+
schedule:
|
|
174
|
+
- cron: '0 0 * * *'
|
|
175
|
+
jobs:
|
|
176
|
+
npm-update-package:
|
|
177
|
+
runs-on: ubuntu-latest
|
|
178
|
+
steps:
|
|
179
|
+
- uses: actions/checkout@v2
|
|
180
|
+
- uses: actions/setup-node@v2
|
|
181
|
+
- run: |
|
|
182
|
+
git config user.name $GIT_USER_NAME
|
|
183
|
+
git config user.email $GIT_USER_EMAIL
|
|
184
|
+
npx npm-update-package --github-token $GITHUB_TOKEN
|
|
185
|
+
env:
|
|
186
|
+
# TODO: Replace with your email
|
|
187
|
+
GIT_USER_EMAIL: 97961304+npm-update-package-bot@users.noreply.github.com
|
|
188
|
+
# TODO: Replace with your name
|
|
189
|
+
GIT_USER_NAME: npm-update-package-bot
|
|
190
|
+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
- [Use Yarn](https://github.com/npm-update-package/example-yarn)
|
|
163
194
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
195
|
+
```yaml
|
|
196
|
+
name: npm-update-package
|
|
197
|
+
on:
|
|
198
|
+
schedule:
|
|
199
|
+
- cron: '0 0 * * *'
|
|
200
|
+
jobs:
|
|
201
|
+
npm-update-package:
|
|
202
|
+
runs-on: ubuntu-latest
|
|
203
|
+
steps:
|
|
204
|
+
- uses: actions/checkout@v2
|
|
205
|
+
- uses: actions/setup-node@v2
|
|
206
|
+
- name: Generate token
|
|
207
|
+
id: generate_token
|
|
208
|
+
uses: tibdex/github-app-token@v1
|
|
209
|
+
with:
|
|
210
|
+
app_id: ${{ secrets.APP_ID }}
|
|
211
|
+
private_key: ${{ secrets.PRIVATE_KEY }}
|
|
212
|
+
- run: |
|
|
213
|
+
git config user.name $GIT_USER_NAME
|
|
214
|
+
git config user.email $GIT_USER_EMAIL
|
|
215
|
+
npx npm-update-package --github-token $GITHUB_TOKEN --package-manager yarn
|
|
216
|
+
env:
|
|
217
|
+
# TODO: Replace with your GitHub App's email
|
|
218
|
+
GIT_USER_EMAIL: 97396142+npm-update-package-bot[bot]@users.noreply.github.com
|
|
219
|
+
# TODO: Replace with your GitHub App's user name
|
|
220
|
+
GIT_USER_NAME: npm-update-package-bot[bot]
|
|
221
|
+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
222
|
+
```
|
|
168
223
|
|
|
169
224
|
## Flow
|
|
170
225
|
|
package/dist/app.js
CHANGED
package/dist/github/GitHub.js
CHANGED
|
@@ -47,5 +47,13 @@ class GitHub {
|
|
|
47
47
|
const { data } = await this.octokit.repos.get(params);
|
|
48
48
|
return data;
|
|
49
49
|
}
|
|
50
|
+
async requestReviewers({ owner, repo, pullNumber, reviewers }) {
|
|
51
|
+
await this.octokit.pulls.requestReviewers({
|
|
52
|
+
owner,
|
|
53
|
+
repo,
|
|
54
|
+
pull_number: pullNumber,
|
|
55
|
+
reviewers
|
|
56
|
+
});
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
exports.GitHub = GitHub;
|
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PullRequestCreator = void 0;
|
|
4
4
|
const createPullRequestBody_1 = require("./createPullRequestBody");
|
|
5
5
|
class PullRequestCreator {
|
|
6
|
-
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger }) {
|
|
6
|
+
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger, reviewers }) {
|
|
7
7
|
this.github = github;
|
|
8
8
|
this.gitRepo = gitRepo;
|
|
9
9
|
this.githubRepo = githubRepo;
|
|
10
10
|
this.pullRequestTitleCreator = pullRequestTitleCreator;
|
|
11
11
|
this.logger = logger;
|
|
12
|
+
this.reviewers = reviewers;
|
|
12
13
|
}
|
|
13
14
|
async create({ outdatedPackage, branchName }) {
|
|
14
15
|
const title = this.pullRequestTitleCreator.create(outdatedPackage);
|
|
@@ -30,6 +31,14 @@ class PullRequestCreator {
|
|
|
30
31
|
issue_number: pullRequest.number,
|
|
31
32
|
labels: ['npm-update-package']
|
|
32
33
|
});
|
|
34
|
+
if (this.reviewers !== undefined) {
|
|
35
|
+
await this.github.requestReviewers({
|
|
36
|
+
owner: this.gitRepo.owner,
|
|
37
|
+
repo: this.gitRepo.name,
|
|
38
|
+
pullNumber: pullRequest.number,
|
|
39
|
+
reviewers: this.reviewers
|
|
40
|
+
});
|
|
41
|
+
}
|
|
33
42
|
return pullRequest;
|
|
34
43
|
}
|
|
35
44
|
}
|
package/dist/main.js
CHANGED
|
@@ -56,7 +56,8 @@ const main = async ({ options, logger }) => {
|
|
|
56
56
|
gitRepo,
|
|
57
57
|
githubRepo,
|
|
58
58
|
pullRequestTitleCreator,
|
|
59
|
-
logger
|
|
59
|
+
logger,
|
|
60
|
+
reviewers: options.reviewers
|
|
60
61
|
});
|
|
61
62
|
const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
|
|
62
63
|
const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
|
package/dist/options/Options.js
CHANGED
|
@@ -4,11 +4,16 @@ exports.isOptions = void 0;
|
|
|
4
4
|
const io_ts_1 = require("io-ts");
|
|
5
5
|
const logger_1 = require("../logger");
|
|
6
6
|
const package_manager_1 = require("../package-manager");
|
|
7
|
-
const Options = (0, io_ts_1.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const Options = (0, io_ts_1.intersection)([
|
|
8
|
+
(0, io_ts_1.type)({
|
|
9
|
+
commitMessage: io_ts_1.string,
|
|
10
|
+
githubToken: io_ts_1.string,
|
|
11
|
+
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Off), (0, io_ts_1.literal)(logger_1.LogLevel.Error), (0, io_ts_1.literal)(logger_1.LogLevel.Info), (0, io_ts_1.literal)(logger_1.LogLevel.Debug)]),
|
|
12
|
+
packageManager: (0, io_ts_1.union)([(0, io_ts_1.literal)(package_manager_1.PackageManagerName.Npm), (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)]),
|
|
13
|
+
pullRequestTitle: io_ts_1.string
|
|
14
|
+
}),
|
|
15
|
+
(0, io_ts_1.partial)({
|
|
16
|
+
reviewers: (0, io_ts_1.array)(io_ts_1.string)
|
|
17
|
+
})
|
|
18
|
+
]);
|
|
14
19
|
exports.isOptions = Options.is;
|
|
@@ -48,5 +48,11 @@ exports.cliOptions = [
|
|
|
48
48
|
type: OptionType_1.OptionType.String,
|
|
49
49
|
required: false,
|
|
50
50
|
default: 'chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'reviewers',
|
|
54
|
+
description: 'User names to request reviews',
|
|
55
|
+
type: OptionType_1.OptionType.StringArray,
|
|
56
|
+
required: false
|
|
51
57
|
}
|
|
52
58
|
];
|
|
@@ -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.26.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",
|
|
@@ -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",
|