npm-update-package 0.53.1 → 0.56.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 (39) hide show
  1. package/README.md +46 -42
  2. package/dist/package.json +5 -5
  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/file/canReadWrite.js +18 -0
  7. package/dist/src/file/index.js +1 -0
  8. package/dist/src/github/GitHub.js +6 -3
  9. package/dist/src/github/label/creator/LabelCreator.js +5 -5
  10. package/dist/src/github/pull-request/closer/PullRequestsCloser.js +3 -3
  11. package/dist/src/github/pull-request/creator/AssigneesAdder.js +23 -0
  12. package/dist/src/github/pull-request/creator/GitHubUrlOptimizer.js +20 -0
  13. package/dist/src/github/pull-request/creator/PackageDiffsSectionCreator.js +26 -0
  14. package/dist/src/github/pull-request/creator/PullRequestBodyCreator.js +5 -5
  15. package/dist/src/github/pull-request/creator/PullRequestCreator.js +13 -14
  16. package/dist/src/github/pull-request/creator/ReleaseNotesSectionCreator.js +18 -0
  17. package/dist/src/github/pull-request/creator/index.js +4 -0
  18. package/dist/src/logger/index.js +1 -2
  19. package/dist/src/logger/logger.js +5 -0
  20. package/dist/src/main.js +36 -40
  21. package/dist/src/ncu/Ncu.js +6 -4
  22. package/dist/src/options/Options.js +6 -4
  23. package/dist/src/options/cliOptions.js +14 -2
  24. package/dist/src/package-manager/PackageManagerCreator.js +33 -0
  25. package/dist/src/package-manager/detectPackageManager.js +15 -0
  26. package/dist/src/package-manager/index.js +3 -3
  27. package/dist/src/package-manager/{Npm.js → npm/Npm.js} +0 -0
  28. package/dist/src/package-manager/{NpmVersions.js → npm/NpmVersions.js} +0 -0
  29. package/dist/src/package-manager/npm/index.js +17 -0
  30. package/dist/src/package-manager/{Yarn.js → yarn/Yarn.js} +0 -0
  31. package/dist/src/package-manager/{YarnVersions.js → yarn/YarnVersions.js} +0 -0
  32. package/dist/src/package-manager/yarn/index.js +17 -0
  33. package/package.json +5 -5
  34. package/dist/src/github/pull-request/creator/createPackageDiffsSection.js +0 -22
  35. package/dist/src/github/pull-request/creator/createReleaseNotesSection.js +0 -14
  36. package/dist/src/github/pull-request/creator/optimizeGitHubUrl.js +0 -15
  37. package/dist/src/logger/Logger.js +0 -2
  38. package/dist/src/logger/createLogger.js +0 -10
  39. package/dist/src/package-manager/createPackageManager.js +0 -15
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,6 +27,7 @@ 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,7 +36,6 @@ CLI tool for creating pull requests to update npm packages
34
36
  - [Use token of GitHub Actions](#use-token-of-github-actions)
35
37
  - [Use token of GitHub App](#use-token-of-github-app)
36
38
  - [Use Personal access token](#use-personal-access-token)
37
- - [Use Yarn](#use-yarn)
38
39
  - [Flow](#flow)
39
40
  - [FAQ](#faq)
40
41
  - [What is the purpose of npm-update-package?](#what-is-the-purpose-of-npm-update-package)
@@ -80,7 +81,26 @@ Example:
80
81
  ```sh
81
82
  npx npm-update-package \
82
83
  --github-token $GITHUB_TOKEN \
83
- --assignees octocat mona
84
+ --assignees alice bob
85
+ ```
86
+
87
+ ### assigneesSampleSize
88
+
89
+ How many members to be assigned to assignees.
90
+
91
+ |Name|Value|
92
+ |---|---|
93
+ |cli|`--assignees-sample-size`|
94
+ |type|number|
95
+ |required|false|
96
+
97
+ Example:
98
+
99
+ ```sh
100
+ npx npm-update-package \
101
+ --github-token $GITHUB_TOKEN \
102
+ --assignees alice bob \
103
+ --assignees-sample-size 1
84
104
  ```
85
105
 
86
106
  ### commitMessage
@@ -165,7 +185,7 @@ Example:
165
185
  ```sh
166
186
  npx npm-update-package \
167
187
  --github-token $GITHUB_TOKEN \
168
- --git-user-email octocat@example.com
188
+ --git-user-email alice@example.com
169
189
  ```
170
190
 
171
191
  ### gitUserName
@@ -183,7 +203,7 @@ Example:
183
203
  ```sh
184
204
  npx npm-update-package \
185
205
  --github-token $GITHUB_TOKEN \
186
- --git-user-name octocat
206
+ --git-user-name alice
187
207
  ```
188
208
 
189
209
  ### githubToken
@@ -247,14 +267,14 @@ npx npm-update-package \
247
267
 
248
268
  ### packageManager
249
269
 
250
- Package manager of your project.
270
+ Package manager of your project.
271
+ Since npm-update-package automatically determines which package manager to use, it is usually not necessary to specify this option.
251
272
 
252
273
  |Name|Value|
253
274
  |---|---|
254
275
  |cli|`--package-manager`|
255
276
  |type|string|
256
277
  |required|false|
257
- |default|`npm`|
258
278
 
259
279
  Allowed values:
260
280
 
@@ -271,6 +291,25 @@ npx npm-update-package \
271
291
  --package-manager yarn
272
292
  ```
273
293
 
294
+ ### prBodyGithubHost
295
+
296
+ GitHub host of pull request body.
297
+
298
+ |Name|Value|
299
+ |---|---|
300
+ |cli|`--pr-body-github-host`|
301
+ |type|string|
302
+ |required|false|
303
+ |default|`togithub.com`|
304
+
305
+ Example:
306
+
307
+ ```sh
308
+ npx npm-update-package \
309
+ --github-token $GITHUB_TOKEN \
310
+ --pr-body-github-host "github.example"
311
+ ```
312
+
274
313
  ### prBodyNotes
275
314
 
276
315
  Additional notes for Pull request body.
@@ -333,7 +372,7 @@ Example:
333
372
  ```sh
334
373
  npx npm-update-package \
335
374
  --github-token $GITHUB_TOKEN \
336
- --reviewers octocat mona
375
+ --reviewers alice bob
337
376
  ```
338
377
 
339
378
  ## GitHub token
@@ -455,41 +494,6 @@ jobs:
455
494
 
456
495
  See working example on [example-pat](https://github.com/npm-update-package/example-pat).
457
496
 
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
497
  ## Flow
494
498
 
495
499
  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.53.1",
3
+ "version": "0.56.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,10 +40,10 @@
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",
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
  }
@@ -0,0 +1,18 @@
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.canReadWrite = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ // TODO: Add test
9
+ const canReadWrite = async (path) => {
10
+ try {
11
+ await fs_1.default.promises.access(path, fs_1.default.constants.R_OK | fs_1.default.constants.W_OK);
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ return true;
17
+ };
18
+ exports.canReadWrite = canReadWrite;
@@ -14,4 +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("./canReadWrite"), exports);
17
18
  __exportStar(require("./readFile"), exports);
@@ -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,22 @@
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 }) {
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
14
  }
15
15
  async create({ outdatedPackage, branchName }) {
16
16
  const title = this.pullRequestTitleCreator.create(outdatedPackage);
17
- this.logger.debug(`title=${title}`);
17
+ logger_1.logger.debug(`title=${title}`);
18
18
  const body = await this.pullRequestBodyCreator.create(outdatedPackage);
19
- this.logger.debug(`body=${body}`);
19
+ logger_1.logger.debug(`body=${body}`);
20
20
  const pullRequest = await this.github.createPullRequest({
21
21
  owner: this.gitRepo.owner,
22
22
  repo: this.gitRepo.name,
@@ -25,27 +25,26 @@ class PullRequestCreator {
25
25
  title,
26
26
  body
27
27
  });
28
- this.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
28
+ logger_1.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
29
29
  await this.github.addLabels({
30
30
  owner: this.gitRepo.owner,
31
31
  repo: this.gitRepo.name,
32
32
  issueNumber: pullRequest.number,
33
33
  labels: ['npm-update-package']
34
34
  });
35
- if (this.assignees !== undefined) {
36
- await this.github.addAssignees({
37
- owner: this.gitRepo.owner,
38
- repo: this.gitRepo.name,
35
+ if (this.options.assignees !== undefined) {
36
+ await this.assigneesAdder.add({
39
37
  issueNumber: pullRequest.number,
40
- assignees: this.assignees
38
+ assignees: this.options.assignees,
39
+ sampleSize: this.options.assigneesSampleSize
41
40
  });
42
41
  }
43
- if (this.reviewers !== undefined) {
42
+ if (this.options.reviewers !== undefined) {
44
43
  await this.github.requestReviewers({
45
44
  owner: this.gitRepo.owner,
46
45
  repo: this.gitRepo.name,
47
46
  pullNumber: pullRequest.number,
48
- reviewers: this.reviewers
47
+ reviewers: this.options.reviewers
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;
@@ -14,6 +14,10 @@ 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);
@@ -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,36 +60,39 @@ const main = async ({ options, logger }) => {
63
60
  color: 'A00F21'
64
61
  });
65
62
  const branchFinder = new github_1.BranchFinder(branches);
66
- const packageManager = (0, package_manager_1.createPackageManager)({
67
- terminal,
68
- packageManager: options.packageManager
69
- });
63
+ const packageManagerCreator = new package_manager_1.PackageManagerCreator(options);
64
+ const packageManager = await packageManagerCreator.create(terminal);
70
65
  const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.prTitle);
71
66
  const releasesFetcher = new github_1.ReleasesFetcher({
72
67
  options,
73
68
  packageManager
74
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);
75
73
  const pullRequestBodyCreator = new github_1.PullRequestBodyCreator({
76
74
  options,
77
- releasesFetcher
75
+ releasesFetcher,
76
+ packageDiffsSectionCreator,
77
+ releaseNotesSectionCreator
78
+ });
79
+ const assigneesAdder = new github_1.AssigneesAdder({
80
+ github,
81
+ gitRepo
78
82
  });
79
83
  const pullRequestCreator = new github_1.PullRequestCreator({
84
+ options,
80
85
  github,
81
86
  gitRepo,
82
87
  githubRepo,
83
88
  pullRequestTitleCreator,
84
89
  pullRequestBodyCreator,
85
- logger,
86
- reviewers: options.reviewers,
87
- assignees: options.assignees
90
+ assigneesAdder
88
91
  });
89
92
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
90
93
  const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
91
94
  const pullRequestCloser = new github_1.PullRequestCloser(github);
92
- const pullRequestsCloser = new github_1.PullRequestsCloser({
93
- pullRequestCloser,
94
- logger
95
- });
95
+ const pullRequestsCloser = new github_1.PullRequestsCloser(pullRequestCloser);
96
96
  const packageUpdater = new core_1.PackageUpdater({
97
97
  packageManager,
98
98
  ncu
@@ -102,7 +102,6 @@ const main = async ({ options, logger }) => {
102
102
  packageManager,
103
103
  pullRequestCreator,
104
104
  branchFinder,
105
- logger,
106
105
  commitMessageCreator,
107
106
  pullRequestFinder,
108
107
  pullRequestsCloser,
@@ -113,33 +112,30 @@ const main = async ({ options, logger }) => {
113
112
  git
114
113
  });
115
114
  await gitConfigInitializer.initialize();
116
- const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor({
117
- outdatedPackageProcessor,
118
- logger
119
- });
115
+ const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor(outdatedPackageProcessor);
120
116
  const results = await outdatedPackagesProcessor.process(outdatedPackages);
121
- logger.debug(`results=${JSON.stringify(results)}`);
117
+ logger_1.logger.debug(`results=${JSON.stringify(results)}`);
122
118
  const succeededResults = results.filter(Either_1.isRight).map(({ right }) => right);
123
- logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
119
+ logger_1.logger.debug(`succeededResults=${JSON.stringify(succeededResults)}`);
124
120
  const createdPackages = succeededResults
125
121
  .filter(({ created }) => created)
126
122
  .map(({ outdatedPackage }) => outdatedPackage);
127
- logger.debug(`createdPackages=${JSON.stringify(createdPackages)}`);
123
+ logger_1.logger.debug(`createdPackages=${JSON.stringify(createdPackages)}`);
128
124
  const skippedPackages = succeededResults
129
125
  .filter(({ skipped }) => skipped)
130
126
  .map(({ outdatedPackage }) => outdatedPackage);
131
- logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
127
+ logger_1.logger.debug(`skippedPackages=${JSON.stringify(skippedPackages)}`);
132
128
  const failedResults = results.filter(Either_1.isLeft).map(({ left }) => left);
133
- logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
129
+ logger_1.logger.debug(`failedResults=${JSON.stringify(failedResults)}`);
134
130
  const failedPackages = failedResults.map(({ outdatedPackage }) => outdatedPackage);
135
- logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
131
+ logger_1.logger.debug(`failedPackages=${JSON.stringify(failedPackages)}`);
136
132
  // TODO: Show as table
137
- logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
133
+ logger_1.logger.info(`Processed ${succeededResults.length + failedPackages.length} packages:
138
134
  - ${createdPackages.length} packages: created (${createdPackages.map(({ name }) => name).join(',')})
139
135
  - ${skippedPackages.length} packages: skipped: (${skippedPackages.map(({ name }) => name).join(',')})
140
136
  - ${failedPackages.length} packages: failed: (${failedPackages.map(({ name }) => name).join(',')})`);
141
137
  if (options.ignorePackages !== undefined) {
142
- logger.info(`Ignored ${options.ignorePackages.length} packages: ${options.ignorePackages.join(',')}`);
138
+ logger_1.logger.info(`Ignored ${options.ignorePackages.length} packages: ${options.ignorePackages.join(',')}`);
143
139
  }
144
140
  };
145
141
  exports.main = main;
@@ -4,23 +4,25 @@ 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({
18
+ packageManager: this.options.packageManager,
18
19
  jsonUpgraded: true,
19
20
  reject: this.options.ignorePackages
20
21
  });
21
22
  }
22
23
  async update(outdatedPackage) {
23
24
  return await this.run({
25
+ packageManager: this.options.packageManager,
24
26
  jsonUpgraded: true,
25
27
  filter: outdatedPackage.name,
26
28
  upgrade: true
@@ -30,9 +32,9 @@ class Ncu {
30
32
  // Read package.json before running ncu
31
33
  const json = await (0, file_1.readFile)('./package.json');
32
34
  const pkg = (0, package_json_1.parsePackageJson)(json);
33
- this.logger.debug(`pkg=${JSON.stringify(pkg)}`);
35
+ logger_1.logger.debug(`pkg=${JSON.stringify(pkg)}`);
34
36
  const result = await (0, npm_check_updates_1.run)(options);
35
- this.logger.debug(`result=${JSON.stringify(result)}`);
37
+ logger_1.logger.debug(`result=${JSON.stringify(result)}`);
36
38
  if (!(0, NcuResult_1.isNcuResult)(result)) {
37
39
  throw new Error('Failed to running ncu.');
38
40
  }
@@ -19,17 +19,19 @@ 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
- packageManager: (0, io_ts_1.union)([
23
- (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Npm),
24
- (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)
25
- ]),
22
+ prBodyGithubHost: io_ts_1.string,
26
23
  prTitle: io_ts_1.string
27
24
  }),
28
25
  (0, io_ts_1.partial)({
29
26
  assignees: (0, io_ts_1.array)(io_ts_1.string),
27
+ assigneesSampleSize: io_ts_1.number,
30
28
  gitUserEmail: io_ts_1.string,
31
29
  gitUserName: io_ts_1.string,
32
30
  ignorePackages: (0, io_ts_1.array)(io_ts_1.string),
31
+ packageManager: (0, io_ts_1.union)([
32
+ (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Npm),
33
+ (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)
34
+ ]),
33
35
  prBodyNotes: io_ts_1.string,
34
36
  reviewers: (0, io_ts_1.array)(io_ts_1.string)
35
37
  })
@@ -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',
@@ -80,8 +86,14 @@ exports.cliOptions = [
80
86
  choices: [
81
87
  package_manager_1.PackageManagerName.Npm,
82
88
  package_manager_1.PackageManagerName.Yarn
83
- ],
84
- default: package_manager_1.PackageManagerName.Npm
89
+ ]
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'
85
97
  },
86
98
  {
87
99
  name: 'pr-body-notes',
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PackageManagerCreator = void 0;
4
+ const logger_1 = require("../logger");
5
+ const detectPackageManager_1 = require("./detectPackageManager");
6
+ const npm_1 = require("./npm");
7
+ const PackageManagerName_1 = require("./PackageManagerName");
8
+ const yarn_1 = require("./yarn");
9
+ class PackageManagerCreator {
10
+ constructor(options) {
11
+ this.options = options;
12
+ }
13
+ async create(terminal) {
14
+ const packageManagerName = await this.getPackageManagerName();
15
+ logger_1.logger.trace(`packageManagerName=${packageManagerName}`);
16
+ switch (packageManagerName) {
17
+ case PackageManagerName_1.PackageManagerName.Npm:
18
+ logger_1.logger.info('Use npm as package manager');
19
+ return new npm_1.Npm(terminal);
20
+ case PackageManagerName_1.PackageManagerName.Yarn:
21
+ logger_1.logger.info('Use Yarn as package manager');
22
+ return new yarn_1.Yarn(terminal);
23
+ }
24
+ }
25
+ async getPackageManagerName() {
26
+ if (this.options.packageManager !== undefined) {
27
+ return this.options.packageManager;
28
+ }
29
+ logger_1.logger.info('Try to detect package manager from lock file.');
30
+ return await (0, detectPackageManager_1.detectPackageManager)();
31
+ }
32
+ }
33
+ exports.PackageManagerCreator = PackageManagerCreator;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectPackageManager = void 0;
4
+ const file_1 = require("../file");
5
+ const PackageManagerName_1 = require("./PackageManagerName");
6
+ const detectPackageManager = async () => {
7
+ if (await (0, file_1.canReadWrite)('package-lock.json')) {
8
+ return PackageManagerName_1.PackageManagerName.Npm;
9
+ }
10
+ if (await (0, file_1.canReadWrite)('yarn.lock')) {
11
+ return PackageManagerName_1.PackageManagerName.Yarn;
12
+ }
13
+ throw new Error('No lock file exists.');
14
+ };
15
+ exports.detectPackageManager = detectPackageManager;
@@ -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("./createPackageManager"), exports);
18
- __exportStar(require("./Npm"), exports);
17
+ __exportStar(require("./npm"), exports);
19
18
  __exportStar(require("./PackageManager"), exports);
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.53.1",
3
+ "version": "0.56.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,10 +40,10 @@
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",
@@ -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;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPackageManager = void 0;
4
- const Npm_1 = require("./Npm");
5
- const PackageManagerName_1 = require("./PackageManagerName");
6
- const Yarn_1 = require("./Yarn");
7
- const createPackageManager = ({ terminal, packageManager }) => {
8
- switch (packageManager) {
9
- case PackageManagerName_1.PackageManagerName.Npm:
10
- return new Npm_1.Npm(terminal);
11
- case PackageManagerName_1.PackageManagerName.Yarn:
12
- return new Yarn_1.Yarn(terminal);
13
- }
14
- };
15
- exports.createPackageManager = createPackageManager;