npm-update-package 0.26.0 → 0.28.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/LICENSE +1 -1
- package/README.md +12 -10
- package/dist/app.js +1 -1
- package/dist/github/GitHub.js +48 -13
- package/dist/github/errors/NotFoundError.js +10 -0
- package/dist/github/errors/index.js +13 -0
- package/dist/github/index.js +2 -0
- package/dist/github/label/creator/LabelCreator.js +37 -0
- package/dist/github/label/creator/index.js +13 -0
- package/dist/github/label/index.js +13 -0
- package/dist/github/pull-request/closer/PullRequestCloser.js +1 -1
- package/dist/github/pull-request/creator/PullRequestCreator.js +3 -3
- package/dist/logger/LogLevel.js +1 -0
- package/dist/main.js +10 -0
- package/dist/options/Options.js +1 -1
- package/dist/options/cliOptions.js +1 -0
- package/package.json +6 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -44,9 +44,10 @@ Log level to show
|
|
|
44
44
|
- required: false
|
|
45
45
|
- allowed values
|
|
46
46
|
- `off`: Do not output any logs.
|
|
47
|
-
- `
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
47
|
+
- `fatal`: Output fatal logs.
|
|
48
|
+
- `error`: Output fatal/error logs.
|
|
49
|
+
- `info`: Output fatal/error/info logs.
|
|
50
|
+
- `debug`: Output fatal/error/info/debug logs.
|
|
50
51
|
- default: `info`
|
|
51
52
|
|
|
52
53
|
### `--package-manager`
|
|
@@ -159,9 +160,9 @@ jobs:
|
|
|
159
160
|
npx npm-update-package --github-token $GITHUB_TOKEN
|
|
160
161
|
env:
|
|
161
162
|
# TODO: Replace with your GitHub App's email
|
|
162
|
-
GIT_USER_EMAIL: 97396142+npm-update-package
|
|
163
|
+
GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
|
|
163
164
|
# TODO: Replace with your GitHub App's user name
|
|
164
|
-
GIT_USER_NAME: npm-update-package
|
|
165
|
+
GIT_USER_NAME: npm-update-package[bot]
|
|
165
166
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
166
167
|
```
|
|
167
168
|
|
|
@@ -215,9 +216,9 @@ jobs:
|
|
|
215
216
|
npx npm-update-package --github-token $GITHUB_TOKEN --package-manager yarn
|
|
216
217
|
env:
|
|
217
218
|
# TODO: Replace with your GitHub App's email
|
|
218
|
-
GIT_USER_EMAIL: 97396142+npm-update-package
|
|
219
|
+
GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
|
|
219
220
|
# TODO: Replace with your GitHub App's user name
|
|
220
|
-
GIT_USER_NAME: npm-update-package
|
|
221
|
+
GIT_USER_NAME: npm-update-package[bot]
|
|
221
222
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
222
223
|
```
|
|
223
224
|
|
|
@@ -237,8 +238,9 @@ if (All packages are up-to-date) then (yes)
|
|
|
237
238
|
else (no)
|
|
238
239
|
endif
|
|
239
240
|
|
|
240
|
-
:
|
|
241
|
-
:
|
|
241
|
+
:Fetch remote branches;
|
|
242
|
+
:Fetch pull requests;
|
|
243
|
+
:Create label;
|
|
242
244
|
|
|
243
245
|
group OutdatedPackagesProcessor
|
|
244
246
|
while (Package exists) is (yes)
|
|
@@ -262,7 +264,7 @@ end
|
|
|
262
264
|
```
|
|
263
265
|
-->
|
|
264
266
|
|
|
265
|
-
[](http://www.plantuml.com/plantuml/uml/RP3DReCm48Jl-nHpX4DU85nILMgFZIhr0HpO1AiBTkrrVzw-E3W4f5pusLcFlvb3L1Cq3KBN3xe4bpm6OqVQlxB29UsCSWTlsazpuTWGsJEg9v5b11COoU_KxV9k3UrvHFN7iIQ0nuvO8gCQNKtJdpqJxLzOsnw11wUCKp1ZssVlClT9P1A_4aVDq-V0HXbYJYmD5SYtWdOi6CVWMexH1VhfhJ2g8e1_xMHJmyO5wg73tG386T_NT8lBDjmI300APpdHpBCFd--ubTLi5jSvRuguo73IRKieQaRwNbymztbzpw5omoL_ngAxG9iTEaoFDCW_)
|
|
266
268
|
|
|
267
269
|
## FAQ
|
|
268
270
|
|
package/dist/app.js
CHANGED
package/dist/github/GitHub.js
CHANGED
|
@@ -6,18 +6,40 @@ class GitHub {
|
|
|
6
6
|
constructor(octokit) {
|
|
7
7
|
this.octokit = octokit;
|
|
8
8
|
}
|
|
9
|
-
async addLabels(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
async addLabels({ owner, repo, issueNumber, labels }) {
|
|
10
|
+
await this.octokit.issues.addLabels({
|
|
11
|
+
owner,
|
|
12
|
+
repo,
|
|
13
|
+
issue_number: issueNumber,
|
|
14
|
+
labels
|
|
15
|
+
});
|
|
12
16
|
}
|
|
13
|
-
async closePullRequest(
|
|
17
|
+
async closePullRequest({ owner, repo, pullNumber }) {
|
|
14
18
|
await this.octokit.pulls.update({
|
|
15
|
-
|
|
19
|
+
owner,
|
|
20
|
+
repo,
|
|
21
|
+
pull_number: pullNumber,
|
|
16
22
|
state: 'closed'
|
|
17
23
|
});
|
|
18
24
|
}
|
|
19
|
-
async
|
|
20
|
-
|
|
25
|
+
async createLabel({ owner, repo, name, description, color }) {
|
|
26
|
+
await this.octokit.issues.createLabel({
|
|
27
|
+
owner,
|
|
28
|
+
repo,
|
|
29
|
+
name,
|
|
30
|
+
description,
|
|
31
|
+
color
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async createPullRequest({ owner, repo, baseBranch, headBranch, title, body }) {
|
|
35
|
+
const { data } = await this.octokit.pulls.create({
|
|
36
|
+
owner,
|
|
37
|
+
repo,
|
|
38
|
+
base: baseBranch,
|
|
39
|
+
head: headBranch,
|
|
40
|
+
title,
|
|
41
|
+
body
|
|
42
|
+
});
|
|
21
43
|
return data;
|
|
22
44
|
}
|
|
23
45
|
async deleteBranch({ owner, repo, branch }) {
|
|
@@ -28,23 +50,36 @@ class GitHub {
|
|
|
28
50
|
});
|
|
29
51
|
}
|
|
30
52
|
// TODO: fetch all branches with page option
|
|
31
|
-
async fetchBranches(
|
|
53
|
+
async fetchBranches({ owner, repo }) {
|
|
32
54
|
const { data } = await this.octokit.repos.listBranches({
|
|
33
|
-
|
|
55
|
+
owner,
|
|
56
|
+
repo,
|
|
34
57
|
per_page: 100
|
|
35
58
|
});
|
|
36
59
|
return data;
|
|
37
60
|
}
|
|
61
|
+
async fetchLabel({ owner, repo, name }) {
|
|
62
|
+
const { data } = await this.octokit.issues.getLabel({
|
|
63
|
+
owner,
|
|
64
|
+
repo,
|
|
65
|
+
name
|
|
66
|
+
});
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
38
69
|
// TODO: fetch all pull requests with page option
|
|
39
|
-
async fetchPullRequests(
|
|
70
|
+
async fetchPullRequests({ owner, repo }) {
|
|
40
71
|
const { data } = await this.octokit.pulls.list({
|
|
41
|
-
|
|
72
|
+
owner,
|
|
73
|
+
repo,
|
|
42
74
|
per_page: 100
|
|
43
75
|
});
|
|
44
76
|
return data;
|
|
45
77
|
}
|
|
46
|
-
async fetchRepository(
|
|
47
|
-
const { data } = await this.octokit.repos.get(
|
|
78
|
+
async fetchRepository({ owner, repo }) {
|
|
79
|
+
const { data } = await this.octokit.repos.get({
|
|
80
|
+
owner,
|
|
81
|
+
repo
|
|
82
|
+
});
|
|
48
83
|
return data;
|
|
49
84
|
}
|
|
50
85
|
async requestReviewers({ owner, repo, pullNumber, reviewers }) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNotFoundError = void 0;
|
|
4
|
+
const request_error_1 = require("@octokit/request-error");
|
|
5
|
+
const http_status_codes_1 = require("http-status-codes");
|
|
6
|
+
// TODO: Add test
|
|
7
|
+
const isNotFoundError = (value) => {
|
|
8
|
+
return value instanceof request_error_1.RequestError && value.status === http_status_codes_1.StatusCodes.NOT_FOUND;
|
|
9
|
+
};
|
|
10
|
+
exports.isNotFoundError = isNotFoundError;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./NotFoundError"), exports);
|
package/dist/github/index.js
CHANGED
|
@@ -12,4 +12,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./branch"), exports);
|
|
14
14
|
__exportStar(require("./createGitHub"), exports);
|
|
15
|
+
__exportStar(require("./errors"), exports);
|
|
16
|
+
__exportStar(require("./label"), exports);
|
|
15
17
|
__exportStar(require("./pull-request"), exports);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LabelCreator = void 0;
|
|
4
|
+
const errors_1 = require("../../errors");
|
|
5
|
+
// TODO: Add test
|
|
6
|
+
class LabelCreator {
|
|
7
|
+
constructor({ github, gitRepo, logger }) {
|
|
8
|
+
this.github = github;
|
|
9
|
+
this.gitRepo = gitRepo;
|
|
10
|
+
this.logger = logger;
|
|
11
|
+
}
|
|
12
|
+
async create({ name, description, color }) {
|
|
13
|
+
try {
|
|
14
|
+
await this.github.fetchLabel({
|
|
15
|
+
owner: this.gitRepo.owner,
|
|
16
|
+
repo: this.gitRepo.name,
|
|
17
|
+
name
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
if ((0, errors_1.isNotFoundError)(e)) {
|
|
22
|
+
await this.github.createLabel({
|
|
23
|
+
owner: this.gitRepo.owner,
|
|
24
|
+
repo: this.gitRepo.name,
|
|
25
|
+
name,
|
|
26
|
+
description,
|
|
27
|
+
color
|
|
28
|
+
});
|
|
29
|
+
this.logger.info(`${name} label has created.`);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.LabelCreator = LabelCreator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./LabelCreator"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./creator"), exports);
|
|
@@ -9,7 +9,7 @@ class PullRequestCloser {
|
|
|
9
9
|
await this.github.closePullRequest({
|
|
10
10
|
owner: pullRequest.base.repo.owner.login,
|
|
11
11
|
repo: pullRequest.base.repo.name,
|
|
12
|
-
|
|
12
|
+
pullNumber: pullRequest.number
|
|
13
13
|
});
|
|
14
14
|
await this.github.deleteBranch({
|
|
15
15
|
owner: pullRequest.base.repo.owner.login,
|
|
@@ -19,8 +19,8 @@ class PullRequestCreator {
|
|
|
19
19
|
const pullRequest = await this.github.createPullRequest({
|
|
20
20
|
owner: this.gitRepo.owner,
|
|
21
21
|
repo: this.gitRepo.name,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
baseBranch: this.githubRepo.default_branch,
|
|
23
|
+
headBranch: branchName,
|
|
24
24
|
title,
|
|
25
25
|
body
|
|
26
26
|
});
|
|
@@ -28,7 +28,7 @@ class PullRequestCreator {
|
|
|
28
28
|
await this.github.addLabels({
|
|
29
29
|
owner: this.gitRepo.owner,
|
|
30
30
|
repo: this.gitRepo.name,
|
|
31
|
-
|
|
31
|
+
issueNumber: pullRequest.number,
|
|
32
32
|
labels: ['npm-update-package']
|
|
33
33
|
});
|
|
34
34
|
if (this.reviewers !== undefined) {
|
package/dist/logger/LogLevel.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -45,6 +45,16 @@ const main = async ({ options, logger }) => {
|
|
|
45
45
|
repo: gitRepo.name
|
|
46
46
|
});
|
|
47
47
|
logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
|
|
48
|
+
const labelCreator = new github_1.LabelCreator({
|
|
49
|
+
github,
|
|
50
|
+
gitRepo,
|
|
51
|
+
logger
|
|
52
|
+
});
|
|
53
|
+
await labelCreator.create({
|
|
54
|
+
name: 'npm-update-package',
|
|
55
|
+
description: 'Created by npm-update-package',
|
|
56
|
+
color: 'A00F21'
|
|
57
|
+
});
|
|
48
58
|
const branchFinder = new github_1.BranchFinder(branches);
|
|
49
59
|
const packageManager = (0, package_manager_1.createPackageManager)({
|
|
50
60
|
terminal,
|
package/dist/options/Options.js
CHANGED
|
@@ -8,7 +8,7 @@ const Options = (0, io_ts_1.intersection)([
|
|
|
8
8
|
(0, io_ts_1.type)({
|
|
9
9
|
commitMessage: io_ts_1.string,
|
|
10
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)]),
|
|
11
|
+
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Off), (0, io_ts_1.literal)(logger_1.LogLevel.Fatal), (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
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
13
|
pullRequestTitle: io_ts_1.string
|
|
14
14
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "CLI tool for creating pull requests to update npm packages",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
"commander": "8.3.0",
|
|
22
22
|
"execa": "5.1.1",
|
|
23
23
|
"fp-ts": "2.11.8",
|
|
24
|
+
"http-status-codes": "2.2.0",
|
|
24
25
|
"io-ts": "2.2.16",
|
|
25
|
-
"log4js": "6.
|
|
26
|
+
"log4js": "6.4.1",
|
|
26
27
|
"mustache": "4.1.0",
|
|
27
|
-
"npm-check-updates": "12.1
|
|
28
|
+
"npm-check-updates": "12.2.1",
|
|
28
29
|
"parse-github-url": "1.0.2",
|
|
29
30
|
"semver": "7.3.5",
|
|
30
31
|
"type-guards": "0.15.0"
|
|
@@ -47,12 +48,12 @@
|
|
|
47
48
|
"eslint-plugin-tsdoc": "0.2.14",
|
|
48
49
|
"husky": "7.0.4",
|
|
49
50
|
"jest": "27.4.7",
|
|
50
|
-
"lint-staged": "12.
|
|
51
|
+
"lint-staged": "12.3.1",
|
|
51
52
|
"npm-run-all": "4.1.5",
|
|
52
53
|
"rimraf": "3.0.2",
|
|
53
54
|
"ts-jest": "27.1.3",
|
|
54
55
|
"ts-node": "10.4.0",
|
|
55
|
-
"typescript": "4.5.
|
|
56
|
+
"typescript": "4.5.5",
|
|
56
57
|
"utility-types": "3.10.0"
|
|
57
58
|
},
|
|
58
59
|
"repository": {
|