npm-update-package 0.24.3 → 0.27.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 TS Examples
3
+ Copyright (c) 2020 TS Templates
4
4
  Copyright (c) 2021 npm-update-package
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
package/README.md CHANGED
@@ -44,9 +44,10 @@ Log level to show
44
44
  - required: false
45
45
  - allowed values
46
46
  - `off`: Do not output any logs.
47
- - `error`: Output error logs.
48
- - `info`: Output error/info logs.
49
- - `debug`: Output error/info/debug logs.
47
+ - `fatal`: Output fatal logs.
48
+ - `error`: Output fatal/error logs.
49
+ - `info`: Output fatal/error/info logs.
50
+ - `debug`: Output fatal/error/info/debug logs.
50
51
  - default: `info`
51
52
 
52
53
  ### `--package-manager`
@@ -73,6 +74,13 @@ Pull request title template
73
74
  - `level`: semver level (major/minor/patch)
74
75
  - default: `chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}`
75
76
 
77
+ ### `--reviewers`
78
+
79
+ User names to request reviews
80
+
81
+ - type: string[]
82
+ - required: false
83
+
76
84
  ## GitHub token
77
85
 
78
86
  GitHub token is required to run npm-update-package.
@@ -152,9 +160,9 @@ jobs:
152
160
  npx npm-update-package --github-token $GITHUB_TOKEN
153
161
  env:
154
162
  # TODO: Replace with your GitHub App's email
155
- GIT_USER_EMAIL: 97396142+npm-update-package-bot[bot]@users.noreply.github.com
163
+ GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
156
164
  # TODO: Replace with your GitHub App's user name
157
- GIT_USER_NAME: npm-update-package-bot[bot]
165
+ GIT_USER_NAME: npm-update-package[bot]
158
166
  GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
159
167
  ```
160
168
 
@@ -208,9 +216,9 @@ jobs:
208
216
  npx npm-update-package --github-token $GITHUB_TOKEN --package-manager yarn
209
217
  env:
210
218
  # TODO: Replace with your GitHub App's email
211
- GIT_USER_EMAIL: 97396142+npm-update-package-bot[bot]@users.noreply.github.com
219
+ GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
212
220
  # TODO: Replace with your GitHub App's user name
213
- GIT_USER_NAME: npm-update-package-bot[bot]
221
+ GIT_USER_NAME: npm-update-package[bot]
214
222
  GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
215
223
  ```
216
224
 
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.24.3',
6
+ version: '0.27.0',
7
7
  web: 'https://github.com/npm-update-package/npm-update-package'
8
8
  };
@@ -6,18 +6,32 @@ 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);
9
+ async addLabels({ owner, repo, issueNumber, labels }) {
10
+ const { data } = await this.octokit.issues.addLabels({
11
+ owner,
12
+ repo,
13
+ issue_number: issueNumber,
14
+ labels
15
+ });
11
16
  return data;
12
17
  }
13
- async closePullRequest(params) {
18
+ async closePullRequest({ owner, repo, pullNumber }) {
14
19
  await this.octokit.pulls.update({
15
- ...params,
20
+ owner,
21
+ repo,
22
+ pull_number: pullNumber,
16
23
  state: 'closed'
17
24
  });
18
25
  }
19
- async createPullRequest(params) {
20
- const { data } = await this.octokit.pulls.create(params);
26
+ async createPullRequest({ owner, repo, baseBranch, headBranch, title, body }) {
27
+ const { data } = await this.octokit.pulls.create({
28
+ owner,
29
+ repo,
30
+ base: baseBranch,
31
+ head: headBranch,
32
+ title,
33
+ body
34
+ });
21
35
  return data;
22
36
  }
23
37
  async deleteBranch({ owner, repo, branch }) {
@@ -28,24 +42,37 @@ class GitHub {
28
42
  });
29
43
  }
30
44
  // TODO: fetch all branches with page option
31
- async fetchBranches(params) {
45
+ async fetchBranches({ owner, repo }) {
32
46
  const { data } = await this.octokit.repos.listBranches({
33
- ...params,
47
+ owner,
48
+ repo,
34
49
  per_page: 100
35
50
  });
36
51
  return data;
37
52
  }
38
53
  // TODO: fetch all pull requests with page option
39
- async fetchPullRequests(params) {
54
+ async fetchPullRequests({ owner, repo }) {
40
55
  const { data } = await this.octokit.pulls.list({
41
- ...params,
56
+ owner,
57
+ repo,
42
58
  per_page: 100
43
59
  });
44
60
  return data;
45
61
  }
46
- async fetchRepository(params) {
47
- const { data } = await this.octokit.repos.get(params);
62
+ async fetchRepository({ owner, repo }) {
63
+ const { data } = await this.octokit.repos.get({
64
+ owner,
65
+ repo
66
+ });
48
67
  return data;
49
68
  }
69
+ async requestReviewers({ owner, repo, pullNumber, reviewers }) {
70
+ await this.octokit.pulls.requestReviewers({
71
+ owner,
72
+ repo,
73
+ pull_number: pullNumber,
74
+ reviewers
75
+ });
76
+ }
50
77
  }
51
78
  exports.GitHub = GitHub;
@@ -9,7 +9,7 @@ class PullRequestCloser {
9
9
  await this.github.closePullRequest({
10
10
  owner: pullRequest.base.repo.owner.login,
11
11
  repo: pullRequest.base.repo.name,
12
- pull_number: pullRequest.number
12
+ pullNumber: pullRequest.number
13
13
  });
14
14
  await this.github.deleteBranch({
15
15
  owner: pullRequest.base.repo.owner.login,
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PullRequestCreator = void 0;
4
4
  const createPullRequestBody_1 = require("./createPullRequestBody");
5
5
  class PullRequestCreator {
6
- constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger }) {
6
+ constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger, reviewers }) {
7
7
  this.github = github;
8
8
  this.gitRepo = gitRepo;
9
9
  this.githubRepo = githubRepo;
10
10
  this.pullRequestTitleCreator = pullRequestTitleCreator;
11
11
  this.logger = logger;
12
+ this.reviewers = reviewers;
12
13
  }
13
14
  async create({ outdatedPackage, branchName }) {
14
15
  const title = this.pullRequestTitleCreator.create(outdatedPackage);
@@ -18,8 +19,8 @@ class PullRequestCreator {
18
19
  const pullRequest = await this.github.createPullRequest({
19
20
  owner: this.gitRepo.owner,
20
21
  repo: this.gitRepo.name,
21
- base: this.githubRepo.default_branch,
22
- head: branchName,
22
+ baseBranch: this.githubRepo.default_branch,
23
+ headBranch: branchName,
23
24
  title,
24
25
  body
25
26
  });
@@ -27,9 +28,17 @@ class PullRequestCreator {
27
28
  await this.github.addLabels({
28
29
  owner: this.gitRepo.owner,
29
30
  repo: this.gitRepo.name,
30
- issue_number: pullRequest.number,
31
+ issueNumber: pullRequest.number,
31
32
  labels: ['npm-update-package']
32
33
  });
34
+ if (this.reviewers !== undefined) {
35
+ await this.github.requestReviewers({
36
+ owner: this.gitRepo.owner,
37
+ repo: this.gitRepo.name,
38
+ pullNumber: pullRequest.number,
39
+ reviewers: this.reviewers
40
+ });
41
+ }
33
42
  return pullRequest;
34
43
  }
35
44
  }
@@ -4,6 +4,7 @@ exports.isLogLevel = exports.LogLevel = void 0;
4
4
  exports.LogLevel = {
5
5
  Debug: 'debug',
6
6
  Error: 'error',
7
+ Fatal: 'fatal',
7
8
  Info: 'info',
8
9
  Off: 'off'
9
10
  };
package/dist/main.js CHANGED
@@ -56,7 +56,8 @@ const main = async ({ options, logger }) => {
56
56
  gitRepo,
57
57
  githubRepo,
58
58
  pullRequestTitleCreator,
59
- logger
59
+ logger,
60
+ reviewers: options.reviewers
60
61
  });
61
62
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
62
63
  const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
@@ -4,11 +4,16 @@ 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
- commitMessage: io_ts_1.string,
9
- githubToken: io_ts_1.string,
10
- 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)]),
11
- 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)]),
12
- pullRequestTitle: io_ts_1.string
13
- });
7
+ const Options = (0, io_ts_1.intersection)([
8
+ (0, io_ts_1.type)({
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.Fatal), (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
+ pullRequestTitle: io_ts_1.string
14
+ }),
15
+ (0, io_ts_1.partial)({
16
+ reviewers: (0, io_ts_1.array)(io_ts_1.string)
17
+ })
18
+ ]);
14
19
  exports.isOptions = Options.is;
@@ -25,6 +25,7 @@ exports.cliOptions = [
25
25
  required: false,
26
26
  choices: [
27
27
  logger_1.LogLevel.Off,
28
+ logger_1.LogLevel.Fatal,
28
29
  logger_1.LogLevel.Error,
29
30
  logger_1.LogLevel.Info,
30
31
  logger_1.LogLevel.Debug
@@ -48,5 +49,11 @@ exports.cliOptions = [
48
49
  type: OptionType_1.OptionType.String,
49
50
  required: false,
50
51
  default: 'chore(deps): {{level}} update {{{packageName}}} to v{{newVersion}}'
52
+ },
53
+ {
54
+ name: 'reviewers',
55
+ description: 'User names to request reviews',
56
+ type: OptionType_1.OptionType.StringArray,
57
+ required: false
51
58
  }
52
59
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.24.3",
3
+ "version": "0.27.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",
@@ -47,7 +47,7 @@
47
47
  "eslint-plugin-tsdoc": "0.2.14",
48
48
  "husky": "7.0.4",
49
49
  "jest": "27.4.7",
50
- "lint-staged": "12.2.0",
50
+ "lint-staged": "12.2.1",
51
51
  "npm-run-all": "4.1.5",
52
52
  "rimraf": "3.0.2",
53
53
  "ts-jest": "27.1.3",