npm-update-package 0.16.2 → 0.17.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
@@ -129,6 +129,13 @@ This PR updates these packages:
129
129
  This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
130
130
  ```
131
131
 
132
+ ### `--pull-request-labels`
133
+
134
+ Pull request labels
135
+
136
+ - type: string array
137
+ - required: false
138
+
132
139
  ### `--pull-request-title`
133
140
 
134
141
  Pull request title template
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.16.2',
6
+ version: '0.17.0',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
@@ -6,6 +6,10 @@ class GitHub {
6
6
  constructor(octokit) {
7
7
  this.octokit = octokit;
8
8
  }
9
+ async addLabels(params) {
10
+ const { data } = await this.octokit.issues.addLabels(params);
11
+ return data;
12
+ }
9
13
  async createPullRequest(params) {
10
14
  const { data } = await this.octokit.pulls.create(params);
11
15
  return data;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PullRequestCreator = void 0;
4
4
  class PullRequestCreator {
5
- constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger }) {
5
+ constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger, labels }) {
6
6
  this.github = github;
7
7
  this.gitRepo = gitRepo;
8
8
  this.githubRepo = githubRepo;
9
9
  this.pullRequestTitleCreator = pullRequestTitleCreator;
10
10
  this.pullRequestBodyCreator = pullRequestBodyCreator;
11
11
  this.logger = logger;
12
+ this.labels = labels;
12
13
  }
13
14
  async create({ outdatedPackage, branchName }) {
14
15
  const title = this.pullRequestTitleCreator.create(outdatedPackage);
@@ -24,6 +25,15 @@ class PullRequestCreator {
24
25
  body
25
26
  });
26
27
  this.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
28
+ if (this.labels !== undefined) {
29
+ const labels = await this.github.addLabels({
30
+ owner: this.gitRepo.owner,
31
+ repo: this.gitRepo.name,
32
+ issue_number: pullRequest.number,
33
+ labels: this.labels
34
+ });
35
+ this.logger.debug(`labels=${JSON.stringify(labels)}`);
36
+ }
27
37
  this.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
28
38
  }
29
39
  }
package/dist/main.js CHANGED
@@ -59,7 +59,8 @@ const main = async ({ options, logger }) => {
59
59
  githubRepo,
60
60
  pullRequestTitleCreator,
61
61
  pullRequestBodyCreator,
62
- logger
62
+ logger,
63
+ labels: options.pullRequestLabels
63
64
  });
64
65
  const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
65
66
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
@@ -4,13 +4,18 @@ 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.type)({
8
- branchName: io_ts_1.string,
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
- pullRequestBody: io_ts_1.string,
14
- pullRequestTitle: io_ts_1.string
15
- });
7
+ const Options = (0, io_ts_1.intersection)([
8
+ (0, io_ts_1.type)({
9
+ branchName: io_ts_1.string,
10
+ commitMessage: io_ts_1.string,
11
+ githubToken: io_ts_1.string,
12
+ 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)]),
13
+ 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)]),
14
+ pullRequestBody: io_ts_1.string,
15
+ pullRequestTitle: io_ts_1.string
16
+ }),
17
+ (0, io_ts_1.partial)({
18
+ pullRequestLabels: (0, io_ts_1.array)(io_ts_1.string)
19
+ })
20
+ ]);
16
21
  exports.isOptions = Options.is;
@@ -63,6 +63,12 @@ exports.cliOptions = [
63
63
  ---
64
64
  This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`
65
65
  },
66
+ {
67
+ name: 'pull-request-labels',
68
+ description: 'Pull request labels',
69
+ type: OptionType_1.OptionType.StringArray,
70
+ required: false
71
+ },
66
72
  {
67
73
  name: 'pull-request-title',
68
74
  description: 'Pull request title template',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.16.2",
3
+ "version": "0.17.0",
4
4
  "description": "CLI tool for creating pull request to update npm packages",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.build.json",