npm-update-package 0.50.0 → 0.52.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 +97 -28
- package/dist/package.json +1 -1
- package/dist/src/github/pull-request/creator/PullRequestBodyCreator.js +1 -1
- package/dist/src/github/pull-request/creator/createPackageDiffsSection.js +1 -0
- package/dist/src/options/OptionType.js +1 -0
- package/dist/src/options/Options.js +1 -0
- package/dist/src/options/cliOptions.js +7 -0
- package/dist/src/options/parseBooleanOption.js +15 -0
- package/dist/src/options/parseNumberOption.js +12 -0
- package/dist/src/options/toCommanderOption.js +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,38 @@
|
|
|
7
7
|
|
|
8
8
|
CLI tool for creating pull requests to update npm packages
|
|
9
9
|
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
13
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
14
|
+
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Options](#options)
|
|
17
|
+
- [assignees](#assignees)
|
|
18
|
+
- [commitMessage](#commitmessage)
|
|
19
|
+
- [fetchReleaseNotes](#fetchreleasenotes)
|
|
20
|
+
- [fetchSleepTime](#fetchsleeptime)
|
|
21
|
+
- [githubToken](#githubtoken)
|
|
22
|
+
- [ignorePackages](#ignorepackages)
|
|
23
|
+
- [logLevel](#loglevel)
|
|
24
|
+
- [packageManager](#packagemanager)
|
|
25
|
+
- [prBodyNotes](#prbodynotes)
|
|
26
|
+
- [prTitle](#prtitle)
|
|
27
|
+
- [reviewers](#reviewers)
|
|
28
|
+
- [GitHub token](#github-token)
|
|
29
|
+
- [Examples](#examples)
|
|
30
|
+
- [Use token of GitHub Actions](#use-token-of-github-actions)
|
|
31
|
+
- [Use token of GitHub App](#use-token-of-github-app)
|
|
32
|
+
- [Use Personal access token](#use-personal-access-token)
|
|
33
|
+
- [Use Yarn](#use-yarn)
|
|
34
|
+
- [Flow](#flow)
|
|
35
|
+
- [FAQ](#faq)
|
|
36
|
+
- [What is the purpose of npm-update-package?](#what-is-the-purpose-of-npm-update-package)
|
|
37
|
+
- [What should I do if conflicts occurred in the pull request?](#what-should-i-do-if-conflicts-occurred-in-the-pull-request)
|
|
38
|
+
- [How to development](#how-to-development)
|
|
39
|
+
|
|
40
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
41
|
+
|
|
10
42
|
## Usage
|
|
11
43
|
|
|
12
44
|
```sh
|
|
@@ -15,19 +47,20 @@ npx npm-update-package --github-token $GITHUB_TOKEN
|
|
|
15
47
|
|
|
16
48
|
## Options
|
|
17
49
|
|
|
18
|
-
You can customize behavior via
|
|
50
|
+
You can customize behavior via CLI options.
|
|
19
51
|
Some options can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
|
|
20
52
|
|
|
21
|
-
###
|
|
53
|
+
### assignees
|
|
22
54
|
|
|
23
55
|
User names to assign to pull request.
|
|
24
56
|
|
|
25
57
|
|Name|Value|
|
|
26
58
|
|---|---|
|
|
59
|
+
|cli|`--assignees`|
|
|
27
60
|
|type|string[]|
|
|
28
61
|
|required|false|
|
|
29
62
|
|
|
30
|
-
|
|
63
|
+
Example:
|
|
31
64
|
|
|
32
65
|
```sh
|
|
33
66
|
npx npm-update-package \
|
|
@@ -35,17 +68,18 @@ npx npm-update-package \
|
|
|
35
68
|
--assignees octocat mona
|
|
36
69
|
```
|
|
37
70
|
|
|
38
|
-
###
|
|
71
|
+
### commitMessage
|
|
39
72
|
|
|
40
73
|
Commit message template.
|
|
41
74
|
|
|
42
75
|
|Name|Value|
|
|
43
76
|
|---|---|
|
|
77
|
+
|cli|`--commit-message`|
|
|
44
78
|
|type|string|
|
|
45
79
|
|required|false|
|
|
46
80
|
|default|`chore(deps): {{{level}}} update {{{packageName}}} to v{{{newVersion}}}`|
|
|
47
81
|
|
|
48
|
-
|
|
82
|
+
Available variables:
|
|
49
83
|
|
|
50
84
|
|Variable|Description|
|
|
51
85
|
|---|---|
|
|
@@ -55,7 +89,7 @@ Commit message template.
|
|
|
55
89
|
|`level`|Semver level (`major`/`minor`/`patch`)|
|
|
56
90
|
|`dependencyType`|Dependency type (`dependencies`/`devDependencies`/`peerDependencies`/`optionalDependencies`)|
|
|
57
91
|
|
|
58
|
-
|
|
92
|
+
Example:
|
|
59
93
|
|
|
60
94
|
```sh
|
|
61
95
|
npx npm-update-package \
|
|
@@ -63,17 +97,37 @@ npx npm-update-package \
|
|
|
63
97
|
--commit-message "chore({{{dependencyType}}}): {{{level}}} update {{{packageName}}} from {{{currentVersion}}} to v{{{newVersion}}}"
|
|
64
98
|
```
|
|
65
99
|
|
|
66
|
-
###
|
|
100
|
+
### fetchReleaseNotes
|
|
101
|
+
|
|
102
|
+
Whether to fetch release notes.
|
|
103
|
+
|
|
104
|
+
|Name|Value|
|
|
105
|
+
|---|---|
|
|
106
|
+
|cli|`--fetch-release-notes`|
|
|
107
|
+
|type|boolean|
|
|
108
|
+
|required|false|
|
|
109
|
+
|default|`true`|
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
npx npm-update-package \
|
|
115
|
+
--github-token $GITHUB_TOKEN \
|
|
116
|
+
--fetch-release-notes false
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### fetchSleepTime
|
|
67
120
|
|
|
68
121
|
Sleep time between fetching (ms).
|
|
69
122
|
|
|
70
123
|
|Name|Value|
|
|
71
124
|
|---|---|
|
|
125
|
+
|cli|`--fetch-sleep-time`|
|
|
72
126
|
|type|number|
|
|
73
127
|
|required|false|
|
|
74
128
|
|default|`1000`|
|
|
75
129
|
|
|
76
|
-
|
|
130
|
+
Example:
|
|
77
131
|
|
|
78
132
|
```sh
|
|
79
133
|
npx npm-update-package \
|
|
@@ -81,25 +135,27 @@ npx npm-update-package \
|
|
|
81
135
|
--fetch-sleep-time 2000
|
|
82
136
|
```
|
|
83
137
|
|
|
84
|
-
###
|
|
138
|
+
### githubToken
|
|
85
139
|
|
|
86
140
|
[GitHub token](#github-token).
|
|
87
141
|
|
|
88
142
|
|Name|Value|
|
|
89
143
|
|---|---|
|
|
144
|
+
|cli|`--github-token`|
|
|
90
145
|
|type|string|
|
|
91
146
|
|required|true|
|
|
92
147
|
|
|
93
|
-
###
|
|
148
|
+
### ignorePackages
|
|
94
149
|
|
|
95
150
|
Package names to ignore.
|
|
96
151
|
|
|
97
152
|
|Name|Value|
|
|
98
153
|
|---|---|
|
|
154
|
+
|cli|`--ignore-packages`|
|
|
99
155
|
|type|string[]|
|
|
100
156
|
|required|false|
|
|
101
157
|
|
|
102
|
-
|
|
158
|
+
Example:
|
|
103
159
|
|
|
104
160
|
```sh
|
|
105
161
|
npx npm-update-package \
|
|
@@ -107,17 +163,18 @@ npx npm-update-package \
|
|
|
107
163
|
--ignore-packages @types/jest jest
|
|
108
164
|
```
|
|
109
165
|
|
|
110
|
-
###
|
|
166
|
+
### logLevel
|
|
111
167
|
|
|
112
168
|
Log level to show.
|
|
113
169
|
|
|
114
170
|
|Name|Value|
|
|
115
171
|
|---|---|
|
|
172
|
+
|cli|`--log-level`|
|
|
116
173
|
|type|string|
|
|
117
174
|
|required|false|
|
|
118
175
|
|default|`info`|
|
|
119
176
|
|
|
120
|
-
|
|
177
|
+
Allowed values:
|
|
121
178
|
|
|
122
179
|
|Value|Description|
|
|
123
180
|
|---|---|
|
|
@@ -129,7 +186,7 @@ Log level to show.
|
|
|
129
186
|
|`debug`|Output fatal/error/warn/info/debug logs.|
|
|
130
187
|
|`trace`|Output fatal/error/warn/info/debug/trace logs.|
|
|
131
188
|
|
|
132
|
-
|
|
189
|
+
Example:
|
|
133
190
|
|
|
134
191
|
```sh
|
|
135
192
|
npx npm-update-package \
|
|
@@ -137,24 +194,25 @@ npx npm-update-package \
|
|
|
137
194
|
--log-level debug
|
|
138
195
|
```
|
|
139
196
|
|
|
140
|
-
###
|
|
197
|
+
### packageManager
|
|
141
198
|
|
|
142
199
|
Package manager of your project.
|
|
143
200
|
|
|
144
201
|
|Name|Value|
|
|
145
202
|
|---|---|
|
|
203
|
+
|cli|`--package-manager`|
|
|
146
204
|
|type|string|
|
|
147
205
|
|required|false|
|
|
148
206
|
|default|`npm`|
|
|
149
207
|
|
|
150
|
-
|
|
208
|
+
Allowed values:
|
|
151
209
|
|
|
152
210
|
|Value|Description|
|
|
153
211
|
|---|---|
|
|
154
212
|
|`npm`|npm|
|
|
155
213
|
|`yarn`|Yarn|
|
|
156
214
|
|
|
157
|
-
|
|
215
|
+
Example:
|
|
158
216
|
|
|
159
217
|
```sh
|
|
160
218
|
npx npm-update-package \
|
|
@@ -162,16 +220,17 @@ npx npm-update-package \
|
|
|
162
220
|
--package-manager yarn
|
|
163
221
|
```
|
|
164
222
|
|
|
165
|
-
###
|
|
223
|
+
### prBodyNotes
|
|
166
224
|
|
|
167
225
|
Additional notes for Pull request body.
|
|
168
226
|
|
|
169
227
|
|Name|Value|
|
|
170
228
|
|---|---|
|
|
229
|
+
|cli|`--pr-body-notes`|
|
|
171
230
|
|type|string|
|
|
172
231
|
|required|false|
|
|
173
232
|
|
|
174
|
-
|
|
233
|
+
Example:
|
|
175
234
|
|
|
176
235
|
```sh
|
|
177
236
|
npx npm-update-package \
|
|
@@ -179,17 +238,18 @@ npx npm-update-package \
|
|
|
179
238
|
--pr-body-notes "**:warning: Please see diff and release notes before merging.**"
|
|
180
239
|
```
|
|
181
240
|
|
|
182
|
-
###
|
|
241
|
+
### prTitle
|
|
183
242
|
|
|
184
243
|
Pull request title template.
|
|
185
244
|
|
|
186
245
|
|Name|Value|
|
|
187
246
|
|---|---|
|
|
247
|
+
|cli|`--pr-title`|
|
|
188
248
|
|type|string|
|
|
189
249
|
|required|false|
|
|
190
250
|
|default|`chore(deps): {{{level}}} update {{{packageName}}} to v{{{newVersion}}}`|
|
|
191
251
|
|
|
192
|
-
|
|
252
|
+
Available variables:
|
|
193
253
|
|
|
194
254
|
|Variable|Description|
|
|
195
255
|
|---|---|
|
|
@@ -199,7 +259,7 @@ Pull request title template.
|
|
|
199
259
|
|`level`|Semver level (`major`/`minor`/`patch`)|
|
|
200
260
|
|`dependencyType`|Dependency type (`dependencies`/`devDependencies`/`peerDependencies`/`optionalDependencies`)|
|
|
201
261
|
|
|
202
|
-
|
|
262
|
+
Example:
|
|
203
263
|
|
|
204
264
|
```sh
|
|
205
265
|
npx npm-update-package \
|
|
@@ -207,16 +267,17 @@ npx npm-update-package \
|
|
|
207
267
|
--pr-title "chore({{{dependencyType}}}): {{{level}}} update {{{packageName}}} from {{{currentVersion}}} to v{{{newVersion}}}"
|
|
208
268
|
```
|
|
209
269
|
|
|
210
|
-
###
|
|
270
|
+
### reviewers
|
|
211
271
|
|
|
212
272
|
User names to request reviews.
|
|
213
273
|
|
|
214
274
|
|Name|Value|
|
|
215
275
|
|---|---|
|
|
276
|
+
|cli|`--reviewers`|
|
|
216
277
|
|type|string[]|
|
|
217
278
|
|required|false|
|
|
218
279
|
|
|
219
|
-
|
|
280
|
+
Example:
|
|
220
281
|
|
|
221
282
|
```sh
|
|
222
283
|
npx npm-update-package \
|
|
@@ -255,7 +316,7 @@ Creating a GitHub App may be tedious, but you only have to do it once the first
|
|
|
255
316
|
|
|
256
317
|
## Examples
|
|
257
318
|
|
|
258
|
-
|
|
319
|
+
### Use token of GitHub Actions
|
|
259
320
|
|
|
260
321
|
```yaml
|
|
261
322
|
name: npm-update-package
|
|
@@ -278,7 +339,9 @@ jobs:
|
|
|
278
339
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
279
340
|
```
|
|
280
341
|
|
|
281
|
-
|
|
342
|
+
See working example on [example-github-actions](https://github.com/npm-update-package/example-github-actions).
|
|
343
|
+
|
|
344
|
+
### Use token of GitHub App
|
|
282
345
|
|
|
283
346
|
```yaml
|
|
284
347
|
name: npm-update-package
|
|
@@ -309,7 +372,9 @@ jobs:
|
|
|
309
372
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
310
373
|
```
|
|
311
374
|
|
|
312
|
-
|
|
375
|
+
See working example on [example-github-app](https://github.com/npm-update-package/example-github-app).
|
|
376
|
+
|
|
377
|
+
### Use Personal access token
|
|
313
378
|
|
|
314
379
|
```yaml
|
|
315
380
|
name: npm-update-package
|
|
@@ -334,7 +399,9 @@ jobs:
|
|
|
334
399
|
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
|
335
400
|
```
|
|
336
401
|
|
|
337
|
-
|
|
402
|
+
See working example on [example-pat](https://github.com/npm-update-package/example-pat).
|
|
403
|
+
|
|
404
|
+
### Use Yarn
|
|
338
405
|
|
|
339
406
|
```yaml
|
|
340
407
|
name: npm-update-package
|
|
@@ -365,6 +432,8 @@ jobs:
|
|
|
365
432
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
366
433
|
```
|
|
367
434
|
|
|
435
|
+
See working example on [example-yarn](https://github.com/npm-update-package/example-yarn).
|
|
436
|
+
|
|
368
437
|
## Flow
|
|
369
438
|
|
|
370
439
|
The following shows the process flow of npm-update-package.
|
package/dist/package.json
CHANGED
|
@@ -25,7 +25,7 @@ class PullRequestBodyCreator {
|
|
|
25
25
|
gitRepo
|
|
26
26
|
});
|
|
27
27
|
sections.push(diffSection);
|
|
28
|
-
if ((gitRepo === null || gitRepo === void 0 ? void 0 : gitRepo.isGitHub) === true) {
|
|
28
|
+
if (this.options.fetchReleaseNotes && (gitRepo === null || gitRepo === void 0 ? void 0 : gitRepo.isGitHub) === true) {
|
|
29
29
|
const releases = await this.releasesFetcher.fetch({
|
|
30
30
|
gitRepo,
|
|
31
31
|
packageName: outdatedPackage.name,
|
|
@@ -13,6 +13,7 @@ const createPackageDiffsSection = ({ outdatedPackage, gitRepo }) => {
|
|
|
13
13
|
links.push(`- [GitHub](${optimizedUrl})`);
|
|
14
14
|
}
|
|
15
15
|
links.push(`- [npmfs](https://npmfs.com/compare/${packageName}/${currentVersion}/${newVersion})`);
|
|
16
|
+
links.push(`- [Package Diff](https://diff.intrinsic.com/${packageName}/${currentVersion}/${newVersion})`);
|
|
16
17
|
links.push(`- [Renovate Bot Package Diff](https://renovatebot.com/diffs/npm/${packageName}/${currentVersion}/${newVersion})`);
|
|
17
18
|
return `## Package diffs
|
|
18
19
|
|
|
@@ -7,6 +7,7 @@ const package_manager_1 = require("../package-manager");
|
|
|
7
7
|
const Options = (0, io_ts_1.intersection)([
|
|
8
8
|
(0, io_ts_1.type)({
|
|
9
9
|
commitMessage: io_ts_1.string,
|
|
10
|
+
fetchReleaseNotes: io_ts_1.boolean,
|
|
10
11
|
fetchSleepTime: io_ts_1.number,
|
|
11
12
|
githubToken: io_ts_1.string,
|
|
12
13
|
logLevel: (0, io_ts_1.union)([
|
|
@@ -18,6 +18,13 @@ exports.cliOptions = [
|
|
|
18
18
|
required: false,
|
|
19
19
|
default: 'chore(deps): {{{level}}} update {{{packageName}}} to v{{{newVersion}}}'
|
|
20
20
|
},
|
|
21
|
+
{
|
|
22
|
+
name: 'fetch-release-notes',
|
|
23
|
+
description: 'Whether to fetch release notes',
|
|
24
|
+
type: OptionType_1.OptionType.Boolean,
|
|
25
|
+
required: false,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
21
28
|
{
|
|
22
29
|
name: 'fetch-sleep-time',
|
|
23
30
|
description: 'Sleep time between fetching (ms)',
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseBooleanOption = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const parseBooleanOption = (value) => {
|
|
6
|
+
switch (value) {
|
|
7
|
+
case 'true':
|
|
8
|
+
return true;
|
|
9
|
+
case 'false':
|
|
10
|
+
return false;
|
|
11
|
+
default:
|
|
12
|
+
throw new commander_1.InvalidArgumentError('Not a boolean.');
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.parseBooleanOption = parseBooleanOption;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseNumberOption = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const parseNumberOption = (value) => {
|
|
6
|
+
const number = Number(value);
|
|
7
|
+
if (Number.isNaN(number)) {
|
|
8
|
+
throw new commander_1.InvalidArgumentError('Not a number.');
|
|
9
|
+
}
|
|
10
|
+
return number;
|
|
11
|
+
};
|
|
12
|
+
exports.parseNumberOption = parseNumberOption;
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toCommanderOption = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const OptionType_1 = require("./OptionType");
|
|
6
|
+
const parseBooleanOption_1 = require("./parseBooleanOption");
|
|
7
|
+
const parseNumberOption_1 = require("./parseNumberOption");
|
|
6
8
|
const toCommanderOption = (cliOption) => {
|
|
7
9
|
const argument = createArgumentString(cliOption);
|
|
8
10
|
const option = new commander_1.Option(`--${cliOption.name} ${argument}`, cliOption.description);
|
|
@@ -12,8 +14,11 @@ const toCommanderOption = (cliOption) => {
|
|
|
12
14
|
if (!cliOption.required && cliOption.default !== undefined) {
|
|
13
15
|
option.default(cliOption.default);
|
|
14
16
|
}
|
|
17
|
+
if (cliOption.type === OptionType_1.OptionType.Boolean) {
|
|
18
|
+
option.argParser(parseBooleanOption_1.parseBooleanOption);
|
|
19
|
+
}
|
|
15
20
|
if (cliOption.type === OptionType_1.OptionType.Number) {
|
|
16
|
-
option.argParser(
|
|
21
|
+
option.argParser(parseNumberOption_1.parseNumberOption);
|
|
17
22
|
}
|
|
18
23
|
return option;
|
|
19
24
|
};
|
|
@@ -24,6 +29,8 @@ const createArgumentString = (cliOption) => {
|
|
|
24
29
|
};
|
|
25
30
|
const createArgumentNameString = (optionType) => {
|
|
26
31
|
switch (optionType) {
|
|
32
|
+
case OptionType_1.OptionType.Boolean:
|
|
33
|
+
return 'boolean';
|
|
27
34
|
case OptionType_1.OptionType.Number:
|
|
28
35
|
return 'number';
|
|
29
36
|
case OptionType_1.OptionType.String:
|