npm-update-package 0.45.15 → 0.46.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![npm version](https://badge.fury.io/js/npm-update-package.svg)](https://badge.fury.io/js/npm-update-package)
2
2
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
3
- ![eslint](https://github.com/npm-update-package/npm-update-package/actions/workflows/eslint.yml/badge.svg)
4
- ![test](https://github.com/npm-update-package/npm-update-package/actions/workflows/test.yml/badge.svg)
3
+ [![eslint](https://github.com/npm-update-package/npm-update-package/actions/workflows/eslint.yml/badge.svg)](https://github.com/npm-update-package/npm-update-package/actions/workflows/eslint.yml)
4
+ [![test](https://github.com/npm-update-package/npm-update-package/actions/workflows/test.yml/badge.svg)](https://github.com/npm-update-package/npm-update-package/actions/workflows/test.yml)
5
5
  ![Coverage:statements](docs/badge-statements.svg)
6
6
  ![Coverage:branches](docs/badge-branches.svg)
7
7
  ![Coverage:functions](docs/badge-functions.svg)
@@ -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.15",
3
+ "version": "0.46.1",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "badges": "jest-coverage-badges output docs",
@@ -23,7 +23,7 @@
23
23
  "http-status-codes": "2.2.0",
24
24
  "io-ts": "2.2.16",
25
25
  "lodash": "4.14.2",
26
- "log4js": "6.4.2",
26
+ "log4js": "6.4.3",
27
27
  "mustache": "4.1.0",
28
28
  "node-fetch": "2.6.7",
29
29
  "npm-check-updates": "12.5.3",
@@ -36,13 +36,13 @@
36
36
  "@jest/types": "27.4.2",
37
37
  "@tsconfig/node12": "1.0.9",
38
38
  "@types/jest": "27.4.0",
39
- "@types/lodash": "4.14.179",
39
+ "@types/lodash": "4.14.180",
40
40
  "@types/mustache": "4.1.2",
41
41
  "@types/node": "12.20.40",
42
42
  "@types/node-fetch": "2.6.1",
43
43
  "@types/parse-github-url": "1.0.0",
44
44
  "@types/semver": "7.3.9",
45
- "@typescript-eslint/eslint-plugin": "5.14.0",
45
+ "@typescript-eslint/eslint-plugin": "5.15.0",
46
46
  "eslint": "8.11.0",
47
47
  "eslint-config-standard-with-typescript": "21.0.1",
48
48
  "eslint-plugin-import": "2.25.4",
@@ -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,9 +5,8 @@ const Either_1 = require("fp-ts/lib/Either");
5
5
  const git_1 = require("../git");
6
6
  // TODO: add test
7
7
  class OutdatedPackageProcessor {
8
- constructor({ git, ncu, packageManager, pullRequestCreator, branchFinder, logger, commitMessageCreator, pullRequestFinder, pullRequestCloser }) {
8
+ constructor({ git, packageManager, pullRequestCreator, branchFinder, logger, commitMessageCreator, pullRequestFinder, pullRequestCloser, packageUpdater }) {
9
9
  this.git = git;
10
- this.ncu = ncu;
11
10
  this.packageManager = packageManager;
12
11
  this.pullRequestCreator = pullRequestCreator;
13
12
  this.branchFinder = branchFinder;
@@ -15,6 +14,7 @@ class OutdatedPackageProcessor {
15
14
  this.commitMessageCreator = commitMessageCreator;
16
15
  this.pullRequestFinder = pullRequestFinder;
17
16
  this.pullRequestCloser = pullRequestCloser;
17
+ this.packageUpdater = packageUpdater;
18
18
  }
19
19
  /**
20
20
  * Don't run in parallel because it includes file operations.
@@ -33,7 +33,7 @@ class OutdatedPackageProcessor {
33
33
  this.logger.info(`${branchName} branch has created.`);
34
34
  try {
35
35
  try {
36
- await this.updatePackage(outdatedPackage);
36
+ await this.packageUpdater.update(outdatedPackage);
37
37
  }
38
38
  catch (error) {
39
39
  this.logger.error(error);
@@ -66,13 +66,6 @@ class OutdatedPackageProcessor {
66
66
  this.logger.info(`${branchName} branch has removed.`);
67
67
  }
68
68
  }
69
- async updatePackage(outdatedPackage) {
70
- const updatedPackages = await this.ncu.update(outdatedPackage);
71
- if (updatedPackages.length !== 1) {
72
- throw new Error(`Failed to update ${outdatedPackage.name}.`);
73
- }
74
- await this.packageManager.install();
75
- }
76
69
  async closeOldPullRequests(outdatedPackage) {
77
70
  const pullRequests = this.pullRequestFinder.findByPackageName(outdatedPackage.name);
78
71
  this.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageUpdater = void 0;
4
+ class PackageUpdater {
5
+ constructor({ packageManager, ncu }) {
6
+ this.packageManager = packageManager;
7
+ this.ncu = ncu;
8
+ }
9
+ async update(outdatedPackage) {
10
+ const updatedPackages = await this.ncu.update(outdatedPackage);
11
+ if (updatedPackages.length !== 1) {
12
+ throw new Error(`Failed to update ${outdatedPackage.name}.`);
13
+ }
14
+ await this.packageManager.install();
15
+ }
16
+ }
17
+ exports.PackageUpdater = PackageUpdater;
@@ -18,4 +18,5 @@ __exportStar(require("./FailedResult"), exports);
18
18
  __exportStar(require("./OutdatedPackage"), exports);
19
19
  __exportStar(require("./OutdatedPackageProcessor"), exports);
20
20
  __exportStar(require("./OutdatedPackagesProcessor"), exports);
21
+ __exportStar(require("./PackageUpdater"), exports);
21
22
  __exportStar(require("./SucceededResult"), exports);
@@ -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,
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLogger = void 0;
4
4
  const log4js_1 = require("log4js");
5
- // TODO: add test
6
5
  const createLogger = (logLevel) => {
7
6
  const logger = (0, log4js_1.getLogger)();
8
7
  logger.level = logLevel;
package/dist/src/main.js CHANGED
@@ -77,21 +77,26 @@ 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);
84
85
  const pullRequestCloser = new github_1.PullRequestCloser(github);
86
+ const packageUpdater = new core_1.PackageUpdater({
87
+ packageManager,
88
+ ncu
89
+ });
85
90
  const outdatedPackageProcessor = new core_1.OutdatedPackageProcessor({
86
91
  git,
87
- ncu,
88
92
  packageManager,
89
93
  pullRequestCreator,
90
94
  branchFinder,
91
95
  logger,
92
96
  commitMessageCreator,
93
97
  pullRequestFinder,
94
- pullRequestCloser
98
+ pullRequestCloser,
99
+ packageUpdater
95
100
  });
96
101
  const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor({
97
102
  outdatedPackageProcessor,
@@ -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.15",
3
+ "version": "0.46.1",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "badges": "jest-coverage-badges output docs",
@@ -23,7 +23,7 @@
23
23
  "http-status-codes": "2.2.0",
24
24
  "io-ts": "2.2.16",
25
25
  "lodash": "4.14.2",
26
- "log4js": "6.4.2",
26
+ "log4js": "6.4.3",
27
27
  "mustache": "4.1.0",
28
28
  "node-fetch": "2.6.7",
29
29
  "npm-check-updates": "12.5.3",
@@ -36,13 +36,13 @@
36
36
  "@jest/types": "27.4.2",
37
37
  "@tsconfig/node12": "1.0.9",
38
38
  "@types/jest": "27.4.0",
39
- "@types/lodash": "4.14.179",
39
+ "@types/lodash": "4.14.180",
40
40
  "@types/mustache": "4.1.2",
41
41
  "@types/node": "12.20.40",
42
42
  "@types/node-fetch": "2.6.1",
43
43
  "@types/parse-github-url": "1.0.0",
44
44
  "@types/semver": "7.3.9",
45
- "@typescript-eslint/eslint-plugin": "5.14.0",
45
+ "@typescript-eslint/eslint-plugin": "5.15.0",
46
46
  "eslint": "8.11.0",
47
47
  "eslint-config-standard-with-typescript": "21.0.1",
48
48
  "eslint-plugin-import": "2.25.4",
@@ -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",