npm-update-package 0.54.0 → 0.57.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.
Files changed (36) hide show
  1. package/README.md +64 -40
  2. package/dist/package.json +6 -6
  3. package/dist/src/bin.js +5 -8
  4. package/dist/src/core/OutdatedPackageProcessor.js +11 -11
  5. package/dist/src/core/OutdatedPackagesProcessor.js +3 -3
  6. package/dist/src/github/GitHub.js +6 -3
  7. package/dist/src/github/label/creator/LabelCreator.js +5 -5
  8. package/dist/src/github/pull-request/closer/PullRequestsCloser.js +3 -3
  9. package/dist/src/github/pull-request/creator/AssigneesAdder.js +23 -0
  10. package/dist/src/github/pull-request/creator/GitHubUrlOptimizer.js +20 -0
  11. package/dist/src/github/pull-request/creator/PackageDiffsSectionCreator.js +26 -0
  12. package/dist/src/github/pull-request/creator/PullRequestBodyCreator.js +5 -5
  13. package/dist/src/github/pull-request/creator/PullRequestCreator.js +16 -17
  14. package/dist/src/github/pull-request/creator/ReleaseNotesSectionCreator.js +18 -0
  15. package/dist/src/github/pull-request/creator/ReviewersAdder.js +23 -0
  16. package/dist/src/github/pull-request/creator/index.js +5 -0
  17. package/dist/src/logger/index.js +1 -2
  18. package/dist/src/logger/logger.js +5 -0
  19. package/dist/src/main.js +40 -40
  20. package/dist/src/ncu/Ncu.js +4 -4
  21. package/dist/src/options/Options.js +4 -1
  22. package/dist/src/options/cliOptions.js +19 -0
  23. package/dist/src/package-manager/PackageManagerCreator.js +10 -10
  24. package/dist/src/package-manager/index.js +2 -2
  25. package/dist/src/package-manager/{Npm.js → npm/Npm.js} +0 -0
  26. package/dist/src/package-manager/{NpmVersions.js → npm/NpmVersions.js} +0 -0
  27. package/dist/src/package-manager/npm/index.js +17 -0
  28. package/dist/src/package-manager/{Yarn.js → yarn/Yarn.js} +0 -0
  29. package/dist/src/package-manager/{YarnVersions.js → yarn/YarnVersions.js} +0 -0
  30. package/dist/src/package-manager/yarn/index.js +17 -0
  31. package/package.json +6 -6
  32. package/dist/src/github/pull-request/creator/createPackageDiffsSection.js +0 -22
  33. package/dist/src/github/pull-request/creator/createReleaseNotesSection.js +0 -14
  34. package/dist/src/github/pull-request/creator/optimizeGitHubUrl.js +0 -15
  35. package/dist/src/logger/Logger.js +0 -2
  36. package/dist/src/logger/createLogger.js +0 -10
package/README.md CHANGED
@@ -17,6 +17,7 @@ CLI tool for creating pull requests to update npm packages
17
17
  - [Supported platforms](#supported-platforms)
18
18
  - [Options](#options)
19
19
  - [assignees](#assignees)
20
+ - [assigneesSampleSize](#assigneessamplesize)
20
21
  - [commitMessage](#commitmessage)
21
22
  - [fetchReleaseNotes](#fetchreleasenotes)
22
23
  - [fetchSleepTime](#fetchsleeptime)
@@ -26,15 +27,16 @@ CLI tool for creating pull requests to update npm packages
26
27
  - [ignorePackages](#ignorepackages)
27
28
  - [logLevel](#loglevel)
28
29
  - [packageManager](#packagemanager)
30
+ - [prBodyGithubHost](#prbodygithubhost)
29
31
  - [prBodyNotes](#prbodynotes)
30
32
  - [prTitle](#prtitle)
31
33
  - [reviewers](#reviewers)
34
+ - [reviewersSampleSize](#reviewerssamplesize)
32
35
  - [GitHub token](#github-token)
33
36
  - [Examples](#examples)
34
37
  - [Use token of GitHub Actions](#use-token-of-github-actions)
35
38
  - [Use token of GitHub App](#use-token-of-github-app)
36
39
  - [Use Personal access token](#use-personal-access-token)
37
- - [Use Yarn](#use-yarn)
38
40
  - [Flow](#flow)
39
41
  - [FAQ](#faq)
40
42
  - [What is the purpose of npm-update-package?](#what-is-the-purpose-of-npm-update-package)
@@ -80,7 +82,26 @@ Example:
80
82
  ```sh
81
83
  npx npm-update-package \
82
84
  --github-token $GITHUB_TOKEN \
83
- --assignees octocat mona
85
+ --assignees alice bob
86
+ ```
87
+
88
+ ### assigneesSampleSize
89
+
90
+ How many members to be assigned to assignees.
91
+
92
+ |Name|Value|
93
+ |---|---|
94
+ |cli|`--assignees-sample-size`|
95
+ |type|number|
96
+ |required|false|
97
+
98
+ Example:
99
+
100
+ ```sh
101
+ npx npm-update-package \
102
+ --github-token $GITHUB_TOKEN \
103
+ --assignees alice bob \
104
+ --assignees-sample-size 1
84
105
  ```
85
106
 
86
107
  ### commitMessage
@@ -165,7 +186,7 @@ Example:
165
186
  ```sh
166
187
  npx npm-update-package \
167
188
  --github-token $GITHUB_TOKEN \
168
- --git-user-email octocat@example.com
189
+ --git-user-email alice@example.com
169
190
  ```
170
191
 
171
192
  ### gitUserName
@@ -183,7 +204,7 @@ Example:
183
204
  ```sh
184
205
  npx npm-update-package \
185
206
  --github-token $GITHUB_TOKEN \
186
- --git-user-name octocat
207
+ --git-user-name alice
187
208
  ```
188
209
 
189
210
  ### githubToken
@@ -271,6 +292,25 @@ npx npm-update-package \
271
292
  --package-manager yarn
272
293
  ```
273
294
 
295
+ ### prBodyGithubHost
296
+
297
+ GitHub host of pull request body.
298
+
299
+ |Name|Value|
300
+ |---|---|
301
+ |cli|`--pr-body-github-host`|
302
+ |type|string|
303
+ |required|false|
304
+ |default|`togithub.com`|
305
+
306
+ Example:
307
+
308
+ ```sh
309
+ npx npm-update-package \
310
+ --github-token $GITHUB_TOKEN \
311
+ --pr-body-github-host "github.example"
312
+ ```
313
+
274
314
  ### prBodyNotes
275
315
 
276
316
  Additional notes for Pull request body.
@@ -333,7 +373,26 @@ Example:
333
373
  ```sh
334
374
  npx npm-update-package \
335
375
  --github-token $GITHUB_TOKEN \
336
- --reviewers octocat mona
376
+ --reviewers alice bob
377
+ ```
378
+
379
+ ### reviewersSampleSize
380
+
381
+ How many members to be assigned to reviewers.
382
+
383
+ |Name|Value|
384
+ |---|---|
385
+ |cli|`--reviewers-sample-size`|
386
+ |type|number|
387
+ |required|false|
388
+
389
+ Example:
390
+
391
+ ```sh
392
+ npx npm-update-package \
393
+ --github-token $GITHUB_TOKEN \
394
+ --reviewers alice bob \
395
+ --reviewers-sample-size 1
337
396
  ```
338
397
 
339
398
  ## GitHub token
@@ -455,41 +514,6 @@ jobs:
455
514
 
456
515
  See working example on [example-pat](https://github.com/npm-update-package/example-pat).
457
516
 
458
- ### Use Yarn
459
-
460
- ```yaml
461
- name: npm-update-package
462
- on:
463
- schedule:
464
- - cron: '0 0 * * *'
465
- jobs:
466
- npm-update-package:
467
- runs-on: ubuntu-latest
468
- steps:
469
- - uses: actions/checkout@v2
470
- - uses: actions/setup-node@v2
471
- - name: Generate token
472
- id: generate_token
473
- uses: tibdex/github-app-token@v1
474
- with:
475
- app_id: ${{ secrets.APP_ID }}
476
- private_key: ${{ secrets.PRIVATE_KEY }}
477
- - run: |
478
- npx npm-update-package \
479
- --github-token $GITHUB_TOKEN \
480
- --git-user-name $GIT_USER_NAME \
481
- --git-user-email $GIT_USER_EMAIL \
482
- --package-manager yarn
483
- env:
484
- # TODO: Replace with your GitHub App's email
485
- GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
486
- # TODO: Replace with your GitHub App's user name
487
- GIT_USER_NAME: npm-update-package[bot]
488
- GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
489
- ```
490
-
491
- See working example on [example-yarn](https://github.com/npm-update-package/example-yarn).
492
-
493
517
  ## Flow
494
518
 
495
519
  The following shows the process flow of npm-update-package.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.54.0",
3
+ "version": "0.57.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",
@@ -24,9 +24,9 @@
24
24
  "log4js": "6.4.4",
25
25
  "mustache": "4.1.0",
26
26
  "node-fetch": "2.6.7",
27
- "npm-check-updates": "12.5.5",
27
+ "npm-check-updates": "12.5.8",
28
28
  "parse-github-url": "1.0.2",
29
- "semver": "7.3.5",
29
+ "semver": "7.3.6",
30
30
  "sleep-promise": "9.1.0",
31
31
  "type-guards": "0.15.0"
32
32
  },
@@ -40,14 +40,14 @@
40
40
  "@types/node-fetch": "2.6.1",
41
41
  "@types/parse-github-url": "1.0.0",
42
42
  "@types/semver": "7.3.9",
43
- "@typescript-eslint/eslint-plugin": "5.17.0",
43
+ "@typescript-eslint/eslint-plugin": "5.18.0",
44
44
  "eslint": "8.12.0",
45
45
  "eslint-config-standard-with-typescript": "21.0.1",
46
- "eslint-plugin-import": "2.25.4",
46
+ "eslint-plugin-import": "2.26.0",
47
47
  "eslint-plugin-jest": "26.1.3",
48
48
  "eslint-plugin-node": "11.1.0",
49
49
  "eslint-plugin-promise": "6.0.0",
50
- "eslint-plugin-tsdoc": "0.2.14",
50
+ "eslint-plugin-tsdoc": "0.2.15",
51
51
  "husky": "7.0.4",
52
52
  "jest": "27.4.7",
53
53
  "lint-staged": "12.3.7",
package/dist/src/bin.js CHANGED
@@ -9,16 +9,13 @@ const logger_1 = require("./logger");
9
9
  const main_1 = require("./main");
10
10
  const options_1 = require("./options");
11
11
  const options = (0, options_1.initOptions)();
12
- const logger = (0, logger_1.createLogger)(options.logLevel);
13
- logger.info(`Start ${package_json_1.default.name} v${package_json_1.default.version}`);
14
- (0, main_1.main)({
15
- options,
16
- logger
17
- })
12
+ logger_1.logger.level = options.logLevel;
13
+ logger_1.logger.info(`Start ${package_json_1.default.name} v${package_json_1.default.version}`);
14
+ (0, main_1.main)(options)
18
15
  .then(() => {
19
- logger.info(`End ${package_json_1.default.name} v${package_json_1.default.version}`);
16
+ logger_1.logger.info(`End ${package_json_1.default.name} v${package_json_1.default.version}`);
20
17
  })
21
18
  .catch((error) => {
22
- logger.fatal(error);
19
+ logger_1.logger.fatal(error);
23
20
  throw error;
24
21
  });
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutdatedPackageProcessor = void 0;
4
4
  const Either_1 = require("fp-ts/lib/Either");
5
5
  const git_1 = require("../git");
6
+ const logger_1 = require("../logger");
6
7
  // TODO: Add test
7
8
  // TODO: Split into multiple classes and functions
8
9
  class OutdatedPackageProcessor {
9
- constructor({ git, packageManager, pullRequestCreator, branchFinder, logger, commitMessageCreator, pullRequestFinder, pullRequestsCloser, packageUpdater }) {
10
+ constructor({ git, packageManager, pullRequestCreator, branchFinder, commitMessageCreator, pullRequestFinder, pullRequestsCloser, packageUpdater }) {
10
11
  this.git = git;
11
12
  this.packageManager = packageManager;
12
13
  this.pullRequestCreator = pullRequestCreator;
13
14
  this.branchFinder = branchFinder;
14
- this.logger = logger;
15
15
  this.commitMessageCreator = commitMessageCreator;
16
16
  this.pullRequestFinder = pullRequestFinder;
17
17
  this.pullRequestsCloser = pullRequestsCloser;
@@ -22,38 +22,38 @@ class OutdatedPackageProcessor {
22
22
  */
23
23
  async process(outdatedPackage) {
24
24
  const branchName = (0, git_1.createBranchName)(outdatedPackage);
25
- this.logger.debug(`branchName=${branchName}`);
25
+ logger_1.logger.debug(`branchName=${branchName}`);
26
26
  if (this.branchFinder.findByName(branchName) !== undefined) {
27
- this.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
27
+ logger_1.logger.info(`Skip ${outdatedPackage.name} because ${branchName} branch already exists on remote.`);
28
28
  return (0, Either_1.right)({
29
29
  outdatedPackage,
30
30
  skipped: true
31
31
  });
32
32
  }
33
33
  await this.git.createBranch(branchName);
34
- this.logger.info(`${branchName} branch has created.`);
34
+ logger_1.logger.info(`${branchName} branch has created.`);
35
35
  try {
36
36
  try {
37
37
  await this.packageUpdater.update(outdatedPackage);
38
38
  }
39
39
  catch (error) {
40
- this.logger.error(error);
40
+ logger_1.logger.error(error);
41
41
  return (0, Either_1.left)({
42
42
  outdatedPackage,
43
43
  error
44
44
  });
45
45
  }
46
- this.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
46
+ logger_1.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
47
47
  await this.git.add(this.packageManager.packageFile, this.packageManager.lockFile);
48
48
  const message = this.commitMessageCreator.create(outdatedPackage);
49
- this.logger.debug(`message=${message}`);
49
+ logger_1.logger.debug(`message=${message}`);
50
50
  await this.git.commit(message);
51
51
  await this.git.push(branchName);
52
52
  const pullRequest = await this.pullRequestCreator.create({
53
53
  outdatedPackage,
54
54
  branchName
55
55
  });
56
- this.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
56
+ logger_1.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
57
57
  await this.closeOldPullRequests(outdatedPackage);
58
58
  return (0, Either_1.right)({
59
59
  outdatedPackage,
@@ -64,12 +64,12 @@ class OutdatedPackageProcessor {
64
64
  await this.git.restore(this.packageManager.packageFile, this.packageManager.lockFile);
65
65
  await this.git.switch('-');
66
66
  await this.git.removeBranch(branchName);
67
- this.logger.info(`${branchName} branch has removed.`);
67
+ logger_1.logger.info(`${branchName} branch has removed.`);
68
68
  }
69
69
  }
70
70
  async closeOldPullRequests(outdatedPackage) {
71
71
  const pullRequests = this.pullRequestFinder.findByPackageName(outdatedPackage.name);
72
- this.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
72
+ logger_1.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
73
73
  await this.pullRequestsCloser.close(pullRequests);
74
74
  }
75
75
  }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutdatedPackagesProcessor = void 0;
4
+ const logger_1 = require("../logger");
4
5
  class OutdatedPackagesProcessor {
5
- constructor({ outdatedPackageProcessor, logger }) {
6
+ constructor(outdatedPackageProcessor) {
6
7
  this.outdatedPackageProcessor = outdatedPackageProcessor;
7
- this.logger = logger;
8
8
  }
9
9
  async process(outdatedPackages) {
10
10
  const results = [];
11
11
  for (const outdatedPackage of outdatedPackages) {
12
- this.logger.debug(`outdatedPackage=${JSON.stringify(outdatedPackage)}`);
12
+ logger_1.logger.debug(`outdatedPackage=${JSON.stringify(outdatedPackage)}`);
13
13
  const result = await this.outdatedPackageProcessor.process(outdatedPackage);
14
14
  results.push(result);
15
15
  }
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.GitHub = void 0;
4
- const lodash_1 = require("lodash");
7
+ const range_1 = __importDefault(require("lodash/range"));
5
8
  class GitHub {
6
9
  constructor(octokit) {
7
10
  this.octokit = octokit;
@@ -59,7 +62,7 @@ class GitHub {
59
62
  }
60
63
  async fetchBranches({ owner, repo }) {
61
64
  const branches = [];
62
- for (const page of (0, lodash_1.range)(1, 11)) {
65
+ for (const page of (0, range_1.default)(1, 11)) {
63
66
  const { data } = await this.octokit.repos.listBranches({
64
67
  owner,
65
68
  repo,
@@ -83,7 +86,7 @@ class GitHub {
83
86
  }
84
87
  async fetchPullRequests({ owner, repo }) {
85
88
  const pullRequests = [];
86
- for (const page of (0, lodash_1.range)(1, 11)) {
89
+ for (const page of (0, range_1.default)(1, 11)) {
87
90
  const { data } = await this.octokit.pulls.list({
88
91
  owner,
89
92
  repo,
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LabelCreator = void 0;
4
+ const logger_1 = require("../../../logger");
4
5
  const errors_1 = require("../../errors");
5
6
  // TODO: Split into multiple classes and functions
6
7
  class LabelCreator {
7
- constructor({ github, gitRepo, logger }) {
8
+ constructor({ github, gitRepo }) {
8
9
  this.github = github;
9
10
  this.gitRepo = gitRepo;
10
- this.logger = logger;
11
11
  }
12
12
  async create({ name, description, color }) {
13
13
  const label = await this.fetchLabel(name);
14
14
  if (label !== undefined) {
15
- this.logger.info(`Skip creating ${name} label because it already exists.`);
15
+ logger_1.logger.info(`Skip creating ${name} label because it already exists.`);
16
16
  return;
17
17
  }
18
18
  await this.createLabel({
@@ -20,7 +20,7 @@ class LabelCreator {
20
20
  description,
21
21
  color
22
22
  });
23
- this.logger.info(`${name} label has created.`);
23
+ logger_1.logger.info(`${name} label has created.`);
24
24
  }
25
25
  async createLabel({ name, description, color }) {
26
26
  await this.github.createLabel({
@@ -41,7 +41,7 @@ class LabelCreator {
41
41
  }
42
42
  catch (e) {
43
43
  if ((0, errors_1.isNotFoundError)(e)) {
44
- this.logger.warn(e);
44
+ logger_1.logger.warn(e);
45
45
  return undefined;
46
46
  }
47
47
  else {
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PullRequestsCloser = void 0;
4
+ const logger_1 = require("../../../logger");
4
5
  class PullRequestsCloser {
5
- constructor({ pullRequestCloser, logger }) {
6
+ constructor(pullRequestCloser) {
6
7
  this.pullRequestCloser = pullRequestCloser;
7
- this.logger = logger;
8
8
  }
9
9
  async close(pullRequests) {
10
10
  await Promise.all(pullRequests.map(async (pullRequest) => {
11
11
  await this.pullRequestCloser.close(pullRequest);
12
- this.logger.info(`Pull request #${pullRequest.number} has closed. ${pullRequest.html_url}`);
12
+ logger_1.logger.info(`Pull request #${pullRequest.number} has closed. ${pullRequest.html_url}`);
13
13
  }));
14
14
  }
15
15
  }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AssigneesAdder = void 0;
7
+ const shuffle_1 = __importDefault(require("lodash/shuffle"));
8
+ // TODO: Add test
9
+ class AssigneesAdder {
10
+ constructor({ github, gitRepo }) {
11
+ this.github = github;
12
+ this.gitRepo = gitRepo;
13
+ }
14
+ async add({ issueNumber, assignees, sampleSize }) {
15
+ await this.github.addAssignees({
16
+ owner: this.gitRepo.owner,
17
+ repo: this.gitRepo.name,
18
+ issueNumber,
19
+ assignees: sampleSize !== undefined ? (0, shuffle_1.default)(assignees).slice(0, sampleSize) : assignees
20
+ });
21
+ }
22
+ }
23
+ exports.AssigneesAdder = AssigneesAdder;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitHubUrlOptimizer = void 0;
4
+ const url_1 = require("url");
5
+ class GitHubUrlOptimizer {
6
+ constructor(options) {
7
+ this.options = options;
8
+ }
9
+ /**
10
+ * Convert URL to prevent linking to other repositories.
11
+ */
12
+ optimize(url) {
13
+ const newUrl = url instanceof url_1.URL ? url : new url_1.URL(url);
14
+ if (newUrl.host === 'github.com') {
15
+ newUrl.host = this.options.prBodyGithubHost;
16
+ }
17
+ return newUrl;
18
+ }
19
+ }
20
+ exports.GitHubUrlOptimizer = GitHubUrlOptimizer;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageDiffsSectionCreator = void 0;
4
+ class PackageDiffsSectionCreator {
5
+ constructor(gitHubUrlOptimizer) {
6
+ this.gitHubUrlOptimizer = gitHubUrlOptimizer;
7
+ }
8
+ create({ outdatedPackage, gitRepo }) {
9
+ const packageName = outdatedPackage.name;
10
+ const currentVersion = outdatedPackage.currentVersion.version;
11
+ const newVersion = outdatedPackage.newVersion.version;
12
+ const links = [];
13
+ if ((gitRepo === null || gitRepo === void 0 ? void 0 : gitRepo.isGitHub) === true) {
14
+ const url = `${gitRepo.url.toString()}/compare/v${currentVersion}...v${newVersion}`;
15
+ const optimizedUrl = this.gitHubUrlOptimizer.optimize(url).toString();
16
+ links.push(`- [GitHub](${optimizedUrl})`);
17
+ }
18
+ links.push(`- [npmfs](https://npmfs.com/compare/${packageName}/${currentVersion}/${newVersion})`);
19
+ links.push(`- [Package Diff](https://diff.intrinsic.com/${packageName}/${currentVersion}/${newVersion})`);
20
+ links.push(`- [Renovate Bot Package Diff](https://renovatebot.com/diffs/npm/${packageName}/${currentVersion}/${newVersion})`);
21
+ return `## Package diffs
22
+
23
+ ${links.join('\n')}`;
24
+ }
25
+ }
26
+ exports.PackageDiffsSectionCreator = PackageDiffsSectionCreator;
@@ -7,20 +7,20 @@ const createFooter_1 = require("./createFooter");
7
7
  const createMetadataSection_1 = require("./createMetadataSection");
8
8
  const createNotesSection_1 = require("./createNotesSection");
9
9
  const createOutdatedPackagesTable_1 = require("./createOutdatedPackagesTable");
10
- const createPackageDiffsSection_1 = require("./createPackageDiffsSection");
11
- const createReleaseNotesSection_1 = require("./createReleaseNotesSection");
12
10
  // TODO: Split into multiple classes and functions
13
11
  class PullRequestBodyCreator {
14
- constructor({ options, releasesFetcher }) {
12
+ constructor({ options, releasesFetcher, packageDiffsSectionCreator, releaseNotesSectionCreator }) {
15
13
  this.options = options;
16
14
  this.releasesFetcher = releasesFetcher;
15
+ this.packageDiffsSectionCreator = packageDiffsSectionCreator;
16
+ this.releaseNotesSectionCreator = releaseNotesSectionCreator;
17
17
  }
18
18
  async create(outdatedPackage) {
19
19
  const sections = [];
20
20
  const outdatedPackagesTable = (0, createOutdatedPackagesTable_1.createOutdatedPackagesTable)(outdatedPackage);
21
21
  sections.push(`This PR updates these packages:\n\n${outdatedPackagesTable}`);
22
22
  const gitRepo = await this.extractRepository(outdatedPackage);
23
- const diffSection = (0, createPackageDiffsSection_1.createPackageDiffsSection)({
23
+ const diffSection = this.packageDiffsSectionCreator.create({
24
24
  outdatedPackage,
25
25
  gitRepo
26
26
  });
@@ -33,7 +33,7 @@ class PullRequestBodyCreator {
33
33
  to: outdatedPackage.newVersion
34
34
  });
35
35
  if (releases.length > 0) {
36
- const releaseNotesSection = (0, createReleaseNotesSection_1.createReleaseNotesSection)(releases);
36
+ const releaseNotesSection = this.releaseNotesSectionCreator.create(releases);
37
37
  sections.push(releaseNotesSection);
38
38
  }
39
39
  }
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PullRequestCreator = void 0;
4
+ const logger_1 = require("../../../logger");
4
5
  class PullRequestCreator {
5
- constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger, reviewers, assignees }) {
6
+ constructor({ options, github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, assigneesAdder, reviewersAdder }) {
7
+ this.options = options;
6
8
  this.github = github;
7
9
  this.gitRepo = gitRepo;
8
10
  this.githubRepo = githubRepo;
9
11
  this.pullRequestTitleCreator = pullRequestTitleCreator;
10
12
  this.pullRequestBodyCreator = pullRequestBodyCreator;
11
- this.logger = logger;
12
- this.reviewers = reviewers;
13
- this.assignees = assignees;
13
+ this.assigneesAdder = assigneesAdder;
14
+ this.reviewersAdder = reviewersAdder;
14
15
  }
15
16
  async create({ outdatedPackage, branchName }) {
16
17
  const title = this.pullRequestTitleCreator.create(outdatedPackage);
17
- this.logger.debug(`title=${title}`);
18
+ logger_1.logger.debug(`title=${title}`);
18
19
  const body = await this.pullRequestBodyCreator.create(outdatedPackage);
19
- this.logger.debug(`body=${body}`);
20
+ logger_1.logger.debug(`body=${body}`);
20
21
  const pullRequest = await this.github.createPullRequest({
21
22
  owner: this.gitRepo.owner,
22
23
  repo: this.gitRepo.name,
@@ -25,27 +26,25 @@ class PullRequestCreator {
25
26
  title,
26
27
  body
27
28
  });
28
- this.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
29
+ logger_1.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
29
30
  await this.github.addLabels({
30
31
  owner: this.gitRepo.owner,
31
32
  repo: this.gitRepo.name,
32
33
  issueNumber: pullRequest.number,
33
34
  labels: ['npm-update-package']
34
35
  });
35
- if (this.assignees !== undefined) {
36
- await this.github.addAssignees({
37
- owner: this.gitRepo.owner,
38
- repo: this.gitRepo.name,
36
+ if (this.options.assignees !== undefined) {
37
+ await this.assigneesAdder.add({
39
38
  issueNumber: pullRequest.number,
40
- assignees: this.assignees
39
+ assignees: this.options.assignees,
40
+ sampleSize: this.options.assigneesSampleSize
41
41
  });
42
42
  }
43
- if (this.reviewers !== undefined) {
44
- await this.github.requestReviewers({
45
- owner: this.gitRepo.owner,
46
- repo: this.gitRepo.name,
43
+ if (this.options.reviewers !== undefined) {
44
+ await this.reviewersAdder.add({
47
45
  pullNumber: pullRequest.number,
48
- reviewers: this.reviewers
46
+ reviewers: this.options.reviewers,
47
+ sampleSize: this.options.reviewersSampleSize
49
48
  });
50
49
  }
51
50
  return pullRequest;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReleaseNotesSectionCreator = void 0;
4
+ class ReleaseNotesSectionCreator {
5
+ constructor(gitHubUrlOptimizer) {
6
+ this.gitHubUrlOptimizer = gitHubUrlOptimizer;
7
+ }
8
+ create(releases) {
9
+ const items = releases.map(({ tag, url }) => {
10
+ const optimizedUrl = this.gitHubUrlOptimizer.optimize(url).toString();
11
+ return `- [${tag}](${optimizedUrl})`;
12
+ });
13
+ return `## Release notes
14
+
15
+ ${items.join('\n')}`;
16
+ }
17
+ }
18
+ exports.ReleaseNotesSectionCreator = ReleaseNotesSectionCreator;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ReviewersAdder = void 0;
7
+ const shuffle_1 = __importDefault(require("lodash/shuffle"));
8
+ // TODO: Add test
9
+ class ReviewersAdder {
10
+ constructor({ github, gitRepo }) {
11
+ this.github = github;
12
+ this.gitRepo = gitRepo;
13
+ }
14
+ async add({ pullNumber, reviewers, sampleSize }) {
15
+ await this.github.requestReviewers({
16
+ owner: this.gitRepo.owner,
17
+ repo: this.gitRepo.name,
18
+ pullNumber,
19
+ reviewers: sampleSize !== undefined ? (0, shuffle_1.default)(reviewers).slice(0, sampleSize) : reviewers
20
+ });
21
+ }
22
+ }
23
+ exports.ReviewersAdder = ReviewersAdder;
@@ -14,6 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AssigneesAdder"), exports);
18
+ __exportStar(require("./GitHubUrlOptimizer"), exports);
19
+ __exportStar(require("./PackageDiffsSectionCreator"), exports);
17
20
  __exportStar(require("./PullRequestBodyCreator"), exports);
18
21
  __exportStar(require("./PullRequestCreator"), exports);
19
22
  __exportStar(require("./PullRequestTitleCreator"), exports);
23
+ __exportStar(require("./ReleaseNotesSectionCreator"), exports);
24
+ __exportStar(require("./ReviewersAdder"), exports);
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./createLogger"), exports);
18
- __exportStar(require("./Logger"), exports);
17
+ __exportStar(require("./logger"), exports);
19
18
  __exportStar(require("./LogLevel"), exports);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ const log4js_1 = require("log4js");
5
+ exports.logger = (0, log4js_1.getLogger)();
package/dist/src/main.js CHANGED
@@ -5,31 +5,29 @@ const Either_1 = require("fp-ts/lib/Either");
5
5
  const core_1 = require("./core");
6
6
  const git_1 = require("./git");
7
7
  const github_1 = require("./github");
8
+ const logger_1 = require("./logger");
8
9
  const ncu_1 = require("./ncu");
9
10
  const package_manager_1 = require("./package-manager");
10
11
  const terminal_1 = require("./terminal");
11
12
  // TODO: Add test
12
- const main = async ({ options, logger }) => {
13
- logger.debug(`options=${JSON.stringify({
13
+ const main = async (options) => {
14
+ logger_1.logger.debug(`options=${JSON.stringify({
14
15
  ...options,
15
16
  githubToken: options.githubToken !== '' ? '***' : ''
16
17
  })}`);
17
- const ncu = new ncu_1.Ncu({
18
- options,
19
- logger
20
- });
18
+ const ncu = new ncu_1.Ncu(options);
21
19
  const outdatedPackages = await ncu.check();
22
- logger.debug(`outdatedPackages=${JSON.stringify(outdatedPackages)}`);
20
+ logger_1.logger.debug(`outdatedPackages=${JSON.stringify(outdatedPackages)}`);
23
21
  if (outdatedPackages.length === 0) {
24
- logger.info('All packages are up-to-date.');
22
+ logger_1.logger.info('All packages are up-to-date.');
25
23
  return;
26
24
  }
27
- logger.info(`There are ${outdatedPackages.length} outdated packages.`);
25
+ logger_1.logger.info(`There are ${outdatedPackages.length} outdated packages.`);
28
26
  const terminal = new terminal_1.Terminal();
29
27
  const git = new git_1.Git(terminal);
30
28
  const remoteUrl = await git.getRemoteUrl();
31
29
  const gitRepo = git_1.GitRepository.of(remoteUrl);
32
- logger.debug(`gitRepo=${JSON.stringify(gitRepo)}`);
30
+ logger_1.logger.debug(`gitRepo=${JSON.stringify(gitRepo)}`);
33
31
  if (gitRepo === undefined) {
34
32
  throw new Error(`Failed to parse remote url. URL=${remoteUrl}`);
35
33
  }
@@ -41,21 +39,20 @@ const main = async ({ options, logger }) => {
41
39
  owner: gitRepo.owner,
42
40
  repo: gitRepo.name
43
41
  });
44
- logger.debug(`githubRepo=${JSON.stringify(githubRepo)}`);
42
+ logger_1.logger.debug(`githubRepo=${JSON.stringify(githubRepo)}`);
45
43
  const branches = await github.fetchBranches({
46
44
  owner: gitRepo.owner,
47
45
  repo: gitRepo.name
48
46
  });
49
- logger.debug(`branches=${JSON.stringify(branches)}`);
47
+ logger_1.logger.debug(`branches=${JSON.stringify(branches)}`);
50
48
  const pullRequests = await github.fetchPullRequests({
51
49
  owner: gitRepo.owner,
52
50
  repo: gitRepo.name
53
51
  });
54
- logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
52
+ logger_1.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
55
53
  const labelCreator = new github_1.LabelCreator({
56
54
  github,
57
- gitRepo,
58
- logger
55
+ gitRepo
59
56
  });
60
57
  await labelCreator.create({
61
58
  name: 'npm-update-package',
@@ -63,37 +60,44 @@ const main = async ({ options, logger }) => {
63
60
  color: 'A00F21'
64
61
  });
65
62
  const branchFinder = new github_1.BranchFinder(branches);
66
- const packageManagerCreator = new package_manager_1.PackageManagerCreator({
67
- options,
68
- logger
69
- });
63
+ const packageManagerCreator = new package_manager_1.PackageManagerCreator(options);
70
64
  const packageManager = await packageManagerCreator.create(terminal);
71
65
  const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.prTitle);
72
66
  const releasesFetcher = new github_1.ReleasesFetcher({
73
67
  options,
74
68
  packageManager
75
69
  });
70
+ const githubUrlOptimizer = new github_1.GitHubUrlOptimizer(options);
71
+ const packageDiffsSectionCreator = new github_1.PackageDiffsSectionCreator(githubUrlOptimizer);
72
+ const releaseNotesSectionCreator = new github_1.ReleaseNotesSectionCreator(githubUrlOptimizer);
76
73
  const pullRequestBodyCreator = new github_1.PullRequestBodyCreator({
77
74
  options,
78
- releasesFetcher
75
+ releasesFetcher,
76
+ packageDiffsSectionCreator,
77
+ releaseNotesSectionCreator
78
+ });
79
+ const assigneesAdder = new github_1.AssigneesAdder({
80
+ github,
81
+ gitRepo
82
+ });
83
+ const reviewersAdder = new github_1.ReviewersAdder({
84
+ github,
85
+ gitRepo
79
86
  });
80
87
  const pullRequestCreator = new github_1.PullRequestCreator({
88
+ options,
81
89
  github,
82
90
  gitRepo,
83
91
  githubRepo,
84
92
  pullRequestTitleCreator,
85
93
  pullRequestBodyCreator,
86
- logger,
87
- reviewers: options.reviewers,
88
- assignees: options.assignees
94
+ assigneesAdder,
95
+ reviewersAdder
89
96
  });
90
97
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
91
98
  const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
92
99
  const pullRequestCloser = new github_1.PullRequestCloser(github);
93
- const pullRequestsCloser = new github_1.PullRequestsCloser({
94
- pullRequestCloser,
95
- logger
96
- });
100
+ const pullRequestsCloser = new github_1.PullRequestsCloser(pullRequestCloser);
97
101
  const packageUpdater = new core_1.PackageUpdater({
98
102
  packageManager,
99
103
  ncu
@@ -103,7 +107,6 @@ const main = async ({ options, logger }) => {
103
107
  packageManager,
104
108
  pullRequestCreator,
105
109
  branchFinder,
106
- logger,
107
110
  commitMessageCreator,
108
111
  pullRequestFinder,
109
112
  pullRequestsCloser,
@@ -114,33 +117,30 @@ const main = async ({ options, logger }) => {
114
117
  git
115
118
  });
116
119
  await gitConfigInitializer.initialize();
117
- const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor({
118
- outdatedPackageProcessor,
119
- logger
120
- });
120
+ const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor(outdatedPackageProcessor);
121
121
  const results = await outdatedPackagesProcessor.process(outdatedPackages);
122
- logger.debug(`results=${JSON.stringify(results)}`);
122
+ logger_1.logger.debug(`results=${JSON.stringify(results)}`);
123
123
  const succeededResults = results.filter(Either_1.isRight).map(({ right }) => right);
124
- logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
124
+ logger_1.logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
125
125
  const createdPackages = succeededResults
126
126
  .filter(({ created }) => created)
127
127
  .map(({ outdatedPackage }) => outdatedPackage);
128
- logger.debug(`createdPackages=${JSON.stringify(createdPackages)}`);
128
+ logger_1.logger.debug(`createdPackages=${JSON.stringify(createdPackages)}`);
129
129
  const skippedPackages = succeededResults
130
130
  .filter(({ skipped }) => skipped)
131
131
  .map(({ outdatedPackage }) => outdatedPackage);
132
- logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
132
+ logger_1.logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
133
133
  const failedResults = results.filter(Either_1.isLeft).map(({ left }) => left);
134
- logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
134
+ logger_1.logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
135
135
  const failedPackages = failedResults.map(({ outdatedPackage }) => outdatedPackage);
136
- logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
136
+ logger_1.logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
137
137
  // TODO: Show as table
138
- logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
138
+ logger_1.logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
139
139
  - ${createdPackages.length} packages: created (${createdPackages.map(({ name }) => name).join(',')})
140
140
  - ${skippedPackages.length} packages: skipped: (${skippedPackages.map(({ name }) => name).join(',')})
141
141
  - ${failedPackages.length} packages: failed: (${failedPackages.map(({ name }) => name).join(',')})`);
142
142
  if (options.ignorePackages !== undefined) {
143
- logger.info(`Ignored ${options.ignorePackages.length} packages: ${options.ignorePackages.join(',')}`);
143
+ logger_1.logger.info(`Ignored ${options.ignorePackages.length} packages: ${options.ignorePackages.join(',')}`);
144
144
  }
145
145
  };
146
146
  exports.main = main;
@@ -4,14 +4,14 @@ exports.Ncu = void 0;
4
4
  const npm_check_updates_1 = require("npm-check-updates");
5
5
  const type_guards_1 = require("type-guards");
6
6
  const file_1 = require("../file");
7
+ const logger_1 = require("../logger");
7
8
  const package_json_1 = require("../package-json");
8
9
  const semver_1 = require("../semver");
9
10
  const NcuResult_1 = require("./NcuResult");
10
11
  // TODO: Add test
11
12
  class Ncu {
12
- constructor({ options, logger }) {
13
+ constructor(options) {
13
14
  this.options = options;
14
- this.logger = logger;
15
15
  }
16
16
  async check() {
17
17
  return await this.run({
@@ -32,9 +32,9 @@ class Ncu {
32
32
  // Read package.json before running ncu
33
33
  const json = await (0, file_1.readFile)('./package.json');
34
34
  const pkg = (0, package_json_1.parsePackageJson)(json);
35
- this.logger.debug(`pkg=${JSON.stringify(pkg)}`);
35
+ logger_1.logger.debug(`pkg=${JSON.stringify(pkg)}`);
36
36
  const result = await (0, npm_check_updates_1.run)(options);
37
- this.logger.debug(`result=${JSON.stringify(result)}`);
37
+ logger_1.logger.debug(`result=${JSON.stringify(result)}`);
38
38
  if (!(0, NcuResult_1.isNcuResult)(result)) {
39
39
  throw new Error('Failed to running ncu.');
40
40
  }
@@ -19,10 +19,12 @@ const Options = (0, io_ts_1.intersection)([
19
19
  (0, io_ts_1.literal)(logger_1.LogLevel.Debug),
20
20
  (0, io_ts_1.literal)(logger_1.LogLevel.Trace)
21
21
  ]),
22
+ prBodyGithubHost: io_ts_1.string,
22
23
  prTitle: io_ts_1.string
23
24
  }),
24
25
  (0, io_ts_1.partial)({
25
26
  assignees: (0, io_ts_1.array)(io_ts_1.string),
27
+ assigneesSampleSize: io_ts_1.number,
26
28
  gitUserEmail: io_ts_1.string,
27
29
  gitUserName: io_ts_1.string,
28
30
  ignorePackages: (0, io_ts_1.array)(io_ts_1.string),
@@ -31,7 +33,8 @@ const Options = (0, io_ts_1.intersection)([
31
33
  (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)
32
34
  ]),
33
35
  prBodyNotes: io_ts_1.string,
34
- reviewers: (0, io_ts_1.array)(io_ts_1.string)
36
+ reviewers: (0, io_ts_1.array)(io_ts_1.string),
37
+ reviewersSampleSize: io_ts_1.number
35
38
  })
36
39
  ]);
37
40
  exports.isOptions = Options.is;
@@ -11,6 +11,12 @@ exports.cliOptions = [
11
11
  type: OptionType_1.OptionType.StringArray,
12
12
  required: false
13
13
  },
14
+ {
15
+ name: 'assignees-sample-size',
16
+ description: 'How many members to be assigned to assignees',
17
+ type: OptionType_1.OptionType.Number,
18
+ required: false
19
+ },
14
20
  {
15
21
  name: 'commit-message',
16
22
  description: 'Commit message template',
@@ -82,6 +88,13 @@ exports.cliOptions = [
82
88
  package_manager_1.PackageManagerName.Yarn
83
89
  ]
84
90
  },
91
+ {
92
+ name: 'pr-body-github-host',
93
+ description: 'GitHub host of pull request body',
94
+ type: OptionType_1.OptionType.String,
95
+ required: false,
96
+ default: 'togithub.com'
97
+ },
85
98
  {
86
99
  name: 'pr-body-notes',
87
100
  description: 'Additional notes for Pull request body',
@@ -100,5 +113,11 @@ exports.cliOptions = [
100
113
  description: 'User names to request reviews',
101
114
  type: OptionType_1.OptionType.StringArray,
102
115
  required: false
116
+ },
117
+ {
118
+ name: 'reviewers-sample-size',
119
+ description: 'How many members to be assigned to reviewers',
120
+ type: OptionType_1.OptionType.Number,
121
+ required: false
103
122
  }
104
123
  ];
@@ -1,32 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageManagerCreator = void 0;
4
+ const logger_1 = require("../logger");
4
5
  const detectPackageManager_1 = require("./detectPackageManager");
5
- const Npm_1 = require("./Npm");
6
+ const npm_1 = require("./npm");
6
7
  const PackageManagerName_1 = require("./PackageManagerName");
7
- const Yarn_1 = require("./Yarn");
8
+ const yarn_1 = require("./yarn");
8
9
  class PackageManagerCreator {
9
- constructor({ options, logger }) {
10
+ constructor(options) {
10
11
  this.options = options;
11
- this.logger = logger;
12
12
  }
13
13
  async create(terminal) {
14
14
  const packageManagerName = await this.getPackageManagerName();
15
- this.logger.trace(`packageManagerName=${packageManagerName}`);
15
+ logger_1.logger.trace(`packageManagerName=${packageManagerName}`);
16
16
  switch (packageManagerName) {
17
17
  case PackageManagerName_1.PackageManagerName.Npm:
18
- this.logger.info('Use npm as package manager');
19
- return new Npm_1.Npm(terminal);
18
+ logger_1.logger.info('Use npm as package manager');
19
+ return new npm_1.Npm(terminal);
20
20
  case PackageManagerName_1.PackageManagerName.Yarn:
21
- this.logger.info('Use Yarn as package manager');
22
- return new Yarn_1.Yarn(terminal);
21
+ logger_1.logger.info('Use Yarn as package manager');
22
+ return new yarn_1.Yarn(terminal);
23
23
  }
24
24
  }
25
25
  async getPackageManagerName() {
26
26
  if (this.options.packageManager !== undefined) {
27
27
  return this.options.packageManager;
28
28
  }
29
- this.logger.info('Try to detect package manager from lock file.');
29
+ logger_1.logger.info('Try to detect package manager from lock file.');
30
30
  return await (0, detectPackageManager_1.detectPackageManager)();
31
31
  }
32
32
  }
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Npm"), exports);
17
+ __exportStar(require("./npm"), exports);
18
18
  __exportStar(require("./PackageManager"), exports);
19
19
  __exportStar(require("./PackageManagerCreator"), exports);
20
20
  __exportStar(require("./PackageManagerName"), exports);
21
- __exportStar(require("./Yarn"), exports);
21
+ __exportStar(require("./yarn"), exports);
File without changes
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Npm"), exports);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Yarn"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.54.0",
3
+ "version": "0.57.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",
@@ -24,9 +24,9 @@
24
24
  "log4js": "6.4.4",
25
25
  "mustache": "4.1.0",
26
26
  "node-fetch": "2.6.7",
27
- "npm-check-updates": "12.5.5",
27
+ "npm-check-updates": "12.5.8",
28
28
  "parse-github-url": "1.0.2",
29
- "semver": "7.3.5",
29
+ "semver": "7.3.6",
30
30
  "sleep-promise": "9.1.0",
31
31
  "type-guards": "0.15.0"
32
32
  },
@@ -40,14 +40,14 @@
40
40
  "@types/node-fetch": "2.6.1",
41
41
  "@types/parse-github-url": "1.0.0",
42
42
  "@types/semver": "7.3.9",
43
- "@typescript-eslint/eslint-plugin": "5.17.0",
43
+ "@typescript-eslint/eslint-plugin": "5.18.0",
44
44
  "eslint": "8.12.0",
45
45
  "eslint-config-standard-with-typescript": "21.0.1",
46
- "eslint-plugin-import": "2.25.4",
46
+ "eslint-plugin-import": "2.26.0",
47
47
  "eslint-plugin-jest": "26.1.3",
48
48
  "eslint-plugin-node": "11.1.0",
49
49
  "eslint-plugin-promise": "6.0.0",
50
- "eslint-plugin-tsdoc": "0.2.14",
50
+ "eslint-plugin-tsdoc": "0.2.15",
51
51
  "husky": "7.0.4",
52
52
  "jest": "27.4.7",
53
53
  "lint-staged": "12.3.7",
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPackageDiffsSection = void 0;
4
- const optimizeGitHubUrl_1 = require("./optimizeGitHubUrl");
5
- const createPackageDiffsSection = ({ outdatedPackage, gitRepo }) => {
6
- const packageName = outdatedPackage.name;
7
- const currentVersion = outdatedPackage.currentVersion.version;
8
- const newVersion = outdatedPackage.newVersion.version;
9
- const links = [];
10
- if ((gitRepo === null || gitRepo === void 0 ? void 0 : gitRepo.isGitHub) === true) {
11
- const url = `${gitRepo.url.toString()}/compare/v${currentVersion}...v${newVersion}`;
12
- const optimizedUrl = (0, optimizeGitHubUrl_1.optimizeGitHubUrl)(url).toString();
13
- links.push(`- [GitHub](${optimizedUrl})`);
14
- }
15
- links.push(`- [npmfs](https://npmfs.com/compare/${packageName}/${currentVersion}/${newVersion})`);
16
- links.push(`- [Package Diff](https://diff.intrinsic.com/${packageName}/${currentVersion}/${newVersion})`);
17
- links.push(`- [Renovate Bot Package Diff](https://renovatebot.com/diffs/npm/${packageName}/${currentVersion}/${newVersion})`);
18
- return `## Package diffs
19
-
20
- ${links.join('\n')}`;
21
- };
22
- exports.createPackageDiffsSection = createPackageDiffsSection;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createReleaseNotesSection = void 0;
4
- const optimizeGitHubUrl_1 = require("./optimizeGitHubUrl");
5
- const createReleaseNotesSection = (releases) => {
6
- const items = releases.map(({ tag, url }) => {
7
- const optimizedUrl = (0, optimizeGitHubUrl_1.optimizeGitHubUrl)(url).toString();
8
- return `- [${tag}](${optimizedUrl})`;
9
- });
10
- return `## Release notes
11
-
12
- ${items.join('\n')}`;
13
- };
14
- exports.createReleaseNotesSection = createReleaseNotesSection;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimizeGitHubUrl = void 0;
4
- const url_1 = require("url");
5
- /**
6
- * Convert URL to prevent linking to other repositories.
7
- */
8
- const optimizeGitHubUrl = (url) => {
9
- const newUrl = url instanceof url_1.URL ? url : new url_1.URL(url);
10
- if (newUrl.host === 'github.com') {
11
- newUrl.host = 'togithub.com';
12
- }
13
- return newUrl;
14
- };
15
- exports.optimizeGitHubUrl = optimizeGitHubUrl;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLogger = void 0;
4
- const log4js_1 = require("log4js");
5
- const createLogger = (logLevel) => {
6
- const logger = (0, log4js_1.getLogger)();
7
- logger.level = logLevel;
8
- return logger;
9
- };
10
- exports.createLogger = createLogger;