npm-update-package 0.27.0 → 0.28.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 +10 -5
- package/dist/app.js +1 -1
- package/dist/github/GitHub.js +18 -2
- 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 +46 -0
- package/dist/github/label/creator/index.js +13 -0
- package/dist/github/label/index.js +13 -0
- package/dist/main.js +10 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -238,19 +238,24 @@ if (All packages are up-to-date) then (yes)
|
|
|
238
238
|
else (no)
|
|
239
239
|
endif
|
|
240
240
|
|
|
241
|
-
:
|
|
242
|
-
:
|
|
241
|
+
:Fetch remote branches;
|
|
242
|
+
:Fetch pull requests;
|
|
243
|
+
|
|
244
|
+
if (Label does not exist) then (yes)
|
|
245
|
+
:Create label;
|
|
246
|
+
else (no)
|
|
247
|
+
endif
|
|
243
248
|
|
|
244
249
|
group OutdatedPackagesProcessor
|
|
245
250
|
while (Package exists) is (yes)
|
|
246
251
|
group OutdatedPackageProcessor
|
|
247
|
-
if (Remote branch
|
|
248
|
-
else (no)
|
|
252
|
+
if (Remote branch does not exist) then (yes)
|
|
249
253
|
:Create branch;
|
|
250
254
|
:Update package;
|
|
251
255
|
:Create pull request;
|
|
252
256
|
:Close old pull requests;
|
|
253
257
|
:Remove branch;
|
|
258
|
+
else (no)
|
|
254
259
|
endif
|
|
255
260
|
end group
|
|
256
261
|
endwhile (no)
|
|
@@ -263,7 +268,7 @@ end
|
|
|
263
268
|
```
|
|
264
269
|
-->
|
|
265
270
|
|
|
266
|
-
[](http://www.plantuml.com/plantuml/uml/VL1BJiCm4DtFATuoMVG2pQO82JP8L4WSm4scJSGa3fundzjJrqsJ5iJ6dtbFypuRDHSizaAd1ns2ZoDwrmsqVcI3ZzOuumQZgz_SWRKYwlOexaGk8xZ0YEFA_2fnIrZB0uflrf807XfYKKOn-9AElsvFj7vWgri4xhqnTi4DTSjQJVCnYY3mUsIrIV79xLZGU5OCti1VdTgDrFe-i3E696hrMpM7Upv7sfxjRuElMTK7-cmxOHHd84jeYKul2dzkc1S0oUdBCjN_ZcVFcLtbsUkOzay5LrV4PJSJ8buPNfgRuZAQx7mi1UPUW5Cp-SxXKbUd7ZA3Pe2kEBGv7h6N7m00)
|
|
267
272
|
|
|
268
273
|
## FAQ
|
|
269
274
|
|
package/dist/app.js
CHANGED
package/dist/github/GitHub.js
CHANGED
|
@@ -7,13 +7,12 @@ class GitHub {
|
|
|
7
7
|
this.octokit = octokit;
|
|
8
8
|
}
|
|
9
9
|
async addLabels({ owner, repo, issueNumber, labels }) {
|
|
10
|
-
|
|
10
|
+
await this.octokit.issues.addLabels({
|
|
11
11
|
owner,
|
|
12
12
|
repo,
|
|
13
13
|
issue_number: issueNumber,
|
|
14
14
|
labels
|
|
15
15
|
});
|
|
16
|
-
return data;
|
|
17
16
|
}
|
|
18
17
|
async closePullRequest({ owner, repo, pullNumber }) {
|
|
19
18
|
await this.octokit.pulls.update({
|
|
@@ -23,6 +22,15 @@ class GitHub {
|
|
|
23
22
|
state: 'closed'
|
|
24
23
|
});
|
|
25
24
|
}
|
|
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
|
+
}
|
|
26
34
|
async createPullRequest({ owner, repo, baseBranch, headBranch, title, body }) {
|
|
27
35
|
const { data } = await this.octokit.pulls.create({
|
|
28
36
|
owner,
|
|
@@ -50,6 +58,14 @@ class GitHub {
|
|
|
50
58
|
});
|
|
51
59
|
return data;
|
|
52
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
|
+
}
|
|
53
69
|
// TODO: fetch all pull requests with page option
|
|
54
70
|
async fetchPullRequests({ owner, repo }) {
|
|
55
71
|
const { data } = await this.octokit.pulls.list({
|
|
@@ -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,46 @@
|
|
|
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
|
+
const label = await this.fetchLabel(name);
|
|
14
|
+
if (label !== undefined) {
|
|
15
|
+
this.logger.info(`Skip creating ${name} label because it already exists.`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
await this.github.createLabel({
|
|
19
|
+
owner: this.gitRepo.owner,
|
|
20
|
+
repo: this.gitRepo.name,
|
|
21
|
+
name,
|
|
22
|
+
description,
|
|
23
|
+
color
|
|
24
|
+
});
|
|
25
|
+
this.logger.info(`${name} label has created.`);
|
|
26
|
+
}
|
|
27
|
+
async fetchLabel(name) {
|
|
28
|
+
try {
|
|
29
|
+
return await this.github.fetchLabel({
|
|
30
|
+
owner: this.gitRepo.owner,
|
|
31
|
+
repo: this.gitRepo.name,
|
|
32
|
+
name
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
if ((0, errors_1.isNotFoundError)(e)) {
|
|
37
|
+
this.logger.warn(e);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
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);
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.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",
|
|
@@ -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"
|
|
@@ -41,18 +42,18 @@
|
|
|
41
42
|
"eslint": "8.7.0",
|
|
42
43
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
43
44
|
"eslint-plugin-import": "2.25.4",
|
|
44
|
-
"eslint-plugin-jest": "
|
|
45
|
+
"eslint-plugin-jest": "26.0.0",
|
|
45
46
|
"eslint-plugin-node": "11.1.0",
|
|
46
47
|
"eslint-plugin-promise": "6.0.0",
|
|
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": {
|