npm-update-package 0.27.0 → 0.28.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 CHANGED
@@ -238,8 +238,9 @@ if (All packages are up-to-date) then (yes)
238
238
  else (no)
239
239
  endif
240
240
 
241
- :Get remote branches;
242
- :Get pull requests;
241
+ :Fetch remote branches;
242
+ :Fetch pull requests;
243
+ :Create label;
243
244
 
244
245
  group OutdatedPackagesProcessor
245
246
  while (Package exists) is (yes)
@@ -263,7 +264,7 @@ end
263
264
  ```
264
265
  -->
265
266
 
266
- [![](http://www.plantuml.com/plantuml/svg/RL0vSiCm3EpnYYsbmX-m6cTIf8mdCta08y4M9n39yCZn-uYYJ4kPD3omm1uuXQXyJ9FGyg2hjybXKjhGyOaZR8g3YZp0gVvTNJbqHFg2va6abg0y8xb3j8VSsoAERD3yS6W9O3CGIs0qnhOq__I52hVdoKR6crUc7sVcKdL919u_4eUOrOgZvzN7UTKyUzjp2DRJrwY5qQm0-5lFSorqg0x-PRWJ03dGozPCPTadgIa0uFZeMTM9hjHUNTQuRQRRDkw2tH2nWM5b-9EweDdIvrPWMLwvIwYypf9_iKLtW7OzT9gFDCal)](http://www.plantuml.com/plantuml/uml/RL0vSiCm3EpnYYsbmX-m6cTIf8mdCta08y4M9n39yCZn-uYYJ4kPD3omm1uuXQXyJ9FGyg2hjybXKjhGyOaZR8g3YZp0gVvTNJbqHFg2va6abg0y8xb3j8VSsoAERD3yS6W9O3CGIs0qnhOq__I52hVdoKR6crUc7sVcKdL919u_4eUOrOgZvzN7UTKyUzjp2DRJrwY5qQm0-5lFSorqg0x-PRWJ03dGozPCPTadgIa0uFZeMTM9hjHUNTQuRQRRDkw2tH2nWM5b-9EweDdIvrPWMLwvIwYypf9_iKLtW7OzT9gFDCal)
267
+ [![](http://www.plantuml.com/plantuml/svg/RP3DReCm48Jl-nHpX4DU85nILMgFZIhr0HpO1AiBTkrrVzw-E3W4f5pusLcFlvb3L1Cq3KBN3xe4bpm6OqVQlxB29UsCSWTlsazpuTWGsJEg9v5b11COoU_KxV9k3UrvHFN7iIQ0nuvO8gCQNKtJdpqJxLzOsnw11wUCKp1ZssVlClT9P1A_4aVDq-V0HXbYJYmD5SYtWdOi6CVWMexH1VhfhJ2g8e1_xMHJmyO5wg73tG386T_NT8lBDjmI300APpdHpBCFd--ubTLi5jSvRuguo73IRKieQaRwNbymztbzpw5omoL_ngAxG9iTEaoFDCW_)](http://www.plantuml.com/plantuml/uml/RP3DReCm48Jl-nHpX4DU85nILMgFZIhr0HpO1AiBTkrrVzw-E3W4f5pusLcFlvb3L1Cq3KBN3xe4bpm6OqVQlxB29UsCSWTlsazpuTWGsJEg9v5b11COoU_KxV9k3UrvHFN7iIQ0nuvO8gCQNKtJdpqJxLzOsnw11wUCKp1ZssVlClT9P1A_4aVDq-V0HXbYJYmD5SYtWdOi6CVWMexH1VhfhJ2g8e1_xMHJmyO5wg73tG386T_NT8lBDjmI300APpdHpBCFd--ubTLi5jSvRuguo73IRKieQaRwNbymztbzpw5omoL_ngAxG9iTEaoFDCW_)
267
268
 
268
269
  ## FAQ
269
270
 
package/dist/app.js CHANGED
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.app = void 0;
4
4
  exports.app = {
5
5
  name: 'npm-update-package',
6
- version: '0.27.0',
6
+ version: '0.28.0',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
@@ -7,13 +7,12 @@ class GitHub {
7
7
  this.octokit = octokit;
8
8
  }
9
9
  async addLabels({ owner, repo, issueNumber, labels }) {
10
- const { data } = await this.octokit.issues.addLabels({
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);
@@ -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);
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.27.0",
3
+ "version": "0.28.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",
@@ -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.3.0",
26
+ "log4js": "6.4.0",
26
27
  "mustache": "4.1.0",
27
- "npm-check-updates": "12.1.0",
28
+ "npm-check-updates": "12.2.0",
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.2.1",
51
+ "lint-staged": "12.2.2",
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.4",
56
+ "typescript": "4.5.5",
56
57
  "utility-types": "3.10.0"
57
58
  },
58
59
  "repository": {