npm-update-package 0.45.16 → 0.46.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
@@ -22,6 +22,23 @@ npx npm-update-package --github-token $GITHUB_TOKEN
22
22
  You can customize behavior via command-line options.
23
23
  Some options can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
24
24
 
25
+ ### `--assignees`
26
+
27
+ User names to assign to pull request.
28
+
29
+ |Name|Value|
30
+ |---|---|
31
+ |type|string[]|
32
+ |required|false|
33
+
34
+ #### Example
35
+
36
+ ```sh
37
+ npx npm-update-package \
38
+ --github-token $GITHUB_TOKEN \
39
+ --assignees npm-update-package npm-update-package-bot
40
+ ```
41
+
25
42
  ### `--commit-message`
26
43
 
27
44
  Commit message template.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.45.16",
3
+ "version": "0.46.0",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "badges": "jest-coverage-badges output docs",
@@ -53,7 +53,7 @@
53
53
  "husky": "7.0.4",
54
54
  "jest": "27.4.7",
55
55
  "jest-coverage-badges": "1.1.2",
56
- "lint-staged": "12.3.5",
56
+ "lint-staged": "12.3.6",
57
57
  "npm-run-all": "4.1.5",
58
58
  "rimraf": "3.0.2",
59
59
  "ts-jest": "27.1.3",
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.readFile = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
- // TODO: add test
9
8
  const readFile = async (path) => {
10
9
  return await fs_1.default.promises.readFile(path, 'utf8');
11
10
  };
@@ -6,6 +6,14 @@ class GitHub {
6
6
  constructor(octokit) {
7
7
  this.octokit = octokit;
8
8
  }
9
+ async addAssignees({ owner, repo, issueNumber, assignees }) {
10
+ await this.octokit.issues.addAssignees({
11
+ owner,
12
+ repo,
13
+ issue_number: issueNumber,
14
+ assignees
15
+ });
16
+ }
9
17
  async addLabels({ owner, repo, issueNumber, labels }) {
10
18
  await this.octokit.issues.addLabels({
11
19
  owner,
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LabelCreator = void 0;
4
4
  const errors_1 = require("../../errors");
5
- // TODO: Add test
6
5
  class LabelCreator {
7
6
  constructor({ github, gitRepo, logger }) {
8
7
  this.github = github;
@@ -15,6 +14,14 @@ class LabelCreator {
15
14
  this.logger.info(`Skip creating ${name} label because it already exists.`);
16
15
  return;
17
16
  }
17
+ await this.createLabel({
18
+ name,
19
+ description,
20
+ color
21
+ });
22
+ this.logger.info(`${name} label has created.`);
23
+ }
24
+ async createLabel({ name, description, color }) {
18
25
  await this.github.createLabel({
19
26
  owner: this.gitRepo.owner,
20
27
  repo: this.gitRepo.name,
@@ -22,7 +29,6 @@ class LabelCreator {
22
29
  description,
23
30
  color
24
31
  });
25
- this.logger.info(`${name} label has created.`);
26
32
  }
27
33
  async fetchLabel(name) {
28
34
  try {
@@ -2,7 +2,7 @@
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, reviewers }) {
5
+ constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger, reviewers, assignees }) {
6
6
  this.github = github;
7
7
  this.gitRepo = gitRepo;
8
8
  this.githubRepo = githubRepo;
@@ -10,6 +10,7 @@ class PullRequestCreator {
10
10
  this.pullRequestBodyCreator = pullRequestBodyCreator;
11
11
  this.logger = logger;
12
12
  this.reviewers = reviewers;
13
+ this.assignees = assignees;
13
14
  }
14
15
  async create({ outdatedPackage, branchName }) {
15
16
  const title = this.pullRequestTitleCreator.create(outdatedPackage);
@@ -31,6 +32,14 @@ class PullRequestCreator {
31
32
  issueNumber: pullRequest.number,
32
33
  labels: ['npm-update-package']
33
34
  });
35
+ if (this.assignees !== undefined) {
36
+ await this.github.addAssignees({
37
+ owner: this.gitRepo.owner,
38
+ repo: this.gitRepo.name,
39
+ issueNumber: pullRequest.number,
40
+ assignees: this.assignees
41
+ });
42
+ }
34
43
  if (this.reviewers !== undefined) {
35
44
  await this.github.requestReviewers({
36
45
  owner: this.gitRepo.owner,
package/dist/src/main.js CHANGED
@@ -77,7 +77,8 @@ const main = async ({ options, logger }) => {
77
77
  pullRequestTitleCreator,
78
78
  pullRequestBodyCreator,
79
79
  logger,
80
- reviewers: options.reviewers
80
+ reviewers: options.reviewers,
81
+ assignees: options.assignees
81
82
  });
82
83
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
83
84
  const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
@@ -24,6 +24,7 @@ const Options = (0, io_ts_1.intersection)([
24
24
  prTitle: io_ts_1.string
25
25
  }),
26
26
  (0, io_ts_1.partial)({
27
+ assignees: (0, io_ts_1.array)(io_ts_1.string),
27
28
  ignorePackages: (0, io_ts_1.array)(io_ts_1.string),
28
29
  prBodyNotes: io_ts_1.string,
29
30
  reviewers: (0, io_ts_1.array)(io_ts_1.string)
@@ -5,6 +5,12 @@ const logger_1 = require("../logger");
5
5
  const package_manager_1 = require("../package-manager");
6
6
  const OptionType_1 = require("./OptionType");
7
7
  exports.cliOptions = [
8
+ {
9
+ name: 'assignees',
10
+ description: 'User names to assign to pull request',
11
+ type: OptionType_1.OptionType.StringArray,
12
+ required: false
13
+ },
8
14
  {
9
15
  name: 'commit-message',
10
16
  description: 'Commit message template',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.45.16",
3
+ "version": "0.46.0",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "badges": "jest-coverage-badges output docs",
@@ -53,7 +53,7 @@
53
53
  "husky": "7.0.4",
54
54
  "jest": "27.4.7",
55
55
  "jest-coverage-badges": "1.1.2",
56
- "lint-staged": "12.3.5",
56
+ "lint-staged": "12.3.6",
57
57
  "npm-run-all": "4.1.5",
58
58
  "rimraf": "3.0.2",
59
59
  "ts-jest": "27.1.3",