npm-update-package 0.46.6 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.46.6",
3
+ "version": "0.48.0",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "badges": "jest-coverage-badges output docs",
@@ -12,7 +12,7 @@
12
12
  "prepare": "husky install",
13
13
  "prepublish": "npm-run-all lint test build",
14
14
  "start": "ts-node src/bin.ts",
15
- "test": "jest --passWithNoTests"
15
+ "test": "jest"
16
16
  },
17
17
  "bin": "dist/src/bin.js",
18
18
  "dependencies": {
@@ -46,7 +46,7 @@
46
46
  "eslint": "8.11.0",
47
47
  "eslint-config-standard-with-typescript": "21.0.1",
48
48
  "eslint-plugin-import": "2.25.4",
49
- "eslint-plugin-jest": "26.1.1",
49
+ "eslint-plugin-jest": "26.1.2",
50
50
  "eslint-plugin-node": "11.1.0",
51
51
  "eslint-plugin-promise": "6.0.0",
52
52
  "eslint-plugin-tsdoc": "0.2.14",
@@ -5,7 +5,7 @@ const Either_1 = require("fp-ts/lib/Either");
5
5
  const git_1 = require("../git");
6
6
  // TODO: add test
7
7
  class OutdatedPackageProcessor {
8
- constructor({ git, packageManager, pullRequestCreator, branchFinder, logger, commitMessageCreator, pullRequestFinder, pullRequestCloser, packageUpdater }) {
8
+ constructor({ git, packageManager, pullRequestCreator, branchFinder, logger, commitMessageCreator, pullRequestFinder, pullRequestsCloser, packageUpdater }) {
9
9
  this.git = git;
10
10
  this.packageManager = packageManager;
11
11
  this.pullRequestCreator = pullRequestCreator;
@@ -13,7 +13,7 @@ class OutdatedPackageProcessor {
13
13
  this.logger = logger;
14
14
  this.commitMessageCreator = commitMessageCreator;
15
15
  this.pullRequestFinder = pullRequestFinder;
16
- this.pullRequestCloser = pullRequestCloser;
16
+ this.pullRequestsCloser = pullRequestsCloser;
17
17
  this.packageUpdater = packageUpdater;
18
18
  }
19
19
  /**
@@ -69,10 +69,7 @@ class OutdatedPackageProcessor {
69
69
  async closeOldPullRequests(outdatedPackage) {
70
70
  const pullRequests = this.pullRequestFinder.findByPackageName(outdatedPackage.name);
71
71
  this.logger.debug(`pullRequests=${JSON.stringify(pullRequests)}`);
72
- await Promise.all(pullRequests.map(async (pullRequest) => {
73
- await this.pullRequestCloser.close(pullRequest);
74
- this.logger.info(`Pull request for ${outdatedPackage.name} has closed. ${pullRequest.html_url}`);
75
- }));
72
+ await this.pullRequestsCloser.close(pullRequests);
76
73
  }
77
74
  }
78
75
  exports.OutdatedPackageProcessor = OutdatedPackageProcessor;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutdatedPackagesProcessor = void 0;
4
- // TODO: add test
5
4
  class OutdatedPackagesProcessor {
6
5
  constructor({ outdatedPackageProcessor, logger }) {
7
6
  this.outdatedPackageProcessor = outdatedPackageProcessor;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PullRequestsCloser = void 0;
4
+ class PullRequestsCloser {
5
+ constructor({ pullRequestCloser, logger }) {
6
+ this.pullRequestCloser = pullRequestCloser;
7
+ this.logger = logger;
8
+ }
9
+ async close(pullRequests) {
10
+ await Promise.all(pullRequests.map(async (pullRequest) => {
11
+ await this.pullRequestCloser.close(pullRequest);
12
+ this.logger.info(`Pull request #${pullRequest.number} has closed. ${pullRequest.html_url}`);
13
+ }));
14
+ }
15
+ }
16
+ exports.PullRequestsCloser = PullRequestsCloser;
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./PullRequestCloser"), exports);
18
+ __exportStar(require("./PullRequestsCloser"), exports);
@@ -19,6 +19,8 @@ class PullRequestBodyCreator {
19
19
  const sections = [];
20
20
  const outdatedPackagesTable = this.createOutdatedPackagesTable(outdatedPackage);
21
21
  sections.push(`This PR updates these packages:\n\n${outdatedPackagesTable}`);
22
+ const diffSection = this.createDiffSection(outdatedPackage);
23
+ sections.push(diffSection);
22
24
  const gitRepo = await this.extractRepository(outdatedPackage);
23
25
  if ((gitRepo === null || gitRepo === void 0 ? void 0 : gitRepo.isGitHub) === true) {
24
26
  const releaseNotesSection = await this.createReleaseNotesSection({
@@ -39,6 +41,15 @@ class PullRequestBodyCreator {
39
41
  sections.push(`---\n${footer}`);
40
42
  return sections.join('\n\n');
41
43
  }
44
+ createDiffSection(outdatedPackage) {
45
+ const packageName = outdatedPackage.name;
46
+ const currentVersion = outdatedPackage.currentVersion.version;
47
+ const newVersion = outdatedPackage.newVersion.version;
48
+ return `## Package diffs
49
+
50
+ - [npmfs](https://npmfs.com/compare/${packageName}/${currentVersion}/${newVersion})
51
+ - [Renovate Bot Package Diff](https://renovatebot.com/diffs/npm/${packageName}/${currentVersion}/${newVersion})`;
52
+ }
42
53
  createFooter() {
43
54
  return `This PR has been generated by [${package_json_1.default.name}](${package_json_1.default.homepage}) v${package_json_1.default.version}`;
44
55
  }
@@ -51,11 +62,9 @@ class PullRequestBodyCreator {
51
62
  const currentVersionLink = `[\`${currentVersion}\`](https://www.npmjs.com/package/${packageName}/v/${currentVersion})`;
52
63
  const newVersion = outdatedPackage.newVersion.version;
53
64
  const newVersionLink = `[\`${newVersion}\`](https://www.npmjs.com/package/${packageName}/v/${newVersion})`;
54
- const diffLink = `[diff](https://renovatebot.com/diffs/npm/${packageName}/${currentVersion}/${newVersion})`;
55
- const version = `${currentVersionLink} -> ${newVersionLink} (${diffLink})`;
56
- return `|Package|Dependency type|Level|Version|
57
- |---|---|---|---|
58
- |${packageLink}|${dependencyType}|${level}|${version}|`;
65
+ return `|Package|Dependency type|Level|Current version|New version|
66
+ |---|---|---|---|---|
67
+ |${packageLink}|${dependencyType}|${level}|${currentVersionLink}|${newVersionLink}|`;
59
68
  }
60
69
  createNotesSection() {
61
70
  if (this.options.prBodyNotes === undefined) {
package/dist/src/main.js CHANGED
@@ -86,6 +86,10 @@ const main = async ({ options, logger }) => {
86
86
  const commitMessageCreator = new git_1.CommitMessageCreator(options.commitMessage);
87
87
  const pullRequestFinder = new github_1.PullRequestFinder(pullRequests);
88
88
  const pullRequestCloser = new github_1.PullRequestCloser(github);
89
+ const pullRequestsCloser = new github_1.PullRequestsCloser({
90
+ pullRequestCloser,
91
+ logger
92
+ });
89
93
  const packageUpdater = new core_1.PackageUpdater({
90
94
  packageManager,
91
95
  ncu
@@ -98,7 +102,7 @@ const main = async ({ options, logger }) => {
98
102
  logger,
99
103
  commitMessageCreator,
100
104
  pullRequestFinder,
101
- pullRequestCloser,
105
+ pullRequestsCloser,
102
106
  packageUpdater
103
107
  });
104
108
  const outdatedPackagesProcessor = new core_1.OutdatedPackagesProcessor({
@@ -0,0 +1,24 @@
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.createOptions = void 0;
7
+ const commander_1 = require("commander");
8
+ const package_json_1 = __importDefault(require("../../package.json"));
9
+ const Options_1 = require("./Options");
10
+ const toCommanderOption_1 = require("./toCommanderOption");
11
+ // TODO: add test
12
+ const createOptions = (cliOptions) => {
13
+ commander_1.program.version(package_json_1.default.version);
14
+ cliOptions
15
+ .map(toCommanderOption_1.toCommanderOption)
16
+ .forEach(option => commander_1.program.addOption(option));
17
+ commander_1.program.parse(process.argv);
18
+ const options = commander_1.program.opts();
19
+ if (!(0, Options_1.isOptions)(options)) {
20
+ throw new Error(`Failed to parse command-line options. options=${JSON.stringify(options)}`);
21
+ }
22
+ return options;
23
+ };
24
+ exports.createOptions = createOptions;
@@ -1,25 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.initOptions = void 0;
7
- const commander_1 = require("commander");
8
- const package_json_1 = __importDefault(require("../../package.json"));
9
4
  const cliOptions_1 = require("./cliOptions");
10
- const Options_1 = require("./Options");
11
- const toCommanderOption_1 = require("./toCommanderOption");
12
- // TODO: add test
5
+ const createOptions_1 = require("./createOptions");
13
6
  const initOptions = () => {
14
- commander_1.program.version(package_json_1.default.version);
15
- cliOptions_1.cliOptions
16
- .map(toCommanderOption_1.toCommanderOption)
17
- .forEach(option => commander_1.program.addOption(option));
18
- commander_1.program.parse(process.argv);
19
- const options = commander_1.program.opts();
20
- if (!(0, Options_1.isOptions)(options)) {
21
- throw new Error(`Failed to parse command-line options. options=${JSON.stringify(options)}`);
22
- }
23
- return options;
7
+ return (0, createOptions_1.createOptions)(cliOptions_1.cliOptions);
24
8
  };
25
9
  exports.initOptions = initOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "npm-update-package",
3
- "version": "0.46.6",
3
+ "version": "0.48.0",
4
4
  "description": "CLI tool for creating pull requests to update npm packages",
5
5
  "scripts": {
6
6
  "badges": "jest-coverage-badges output docs",
@@ -12,7 +12,7 @@
12
12
  "prepare": "husky install",
13
13
  "prepublish": "npm-run-all lint test build",
14
14
  "start": "ts-node src/bin.ts",
15
- "test": "jest --passWithNoTests"
15
+ "test": "jest"
16
16
  },
17
17
  "bin": "dist/src/bin.js",
18
18
  "dependencies": {
@@ -46,7 +46,7 @@
46
46
  "eslint": "8.11.0",
47
47
  "eslint-config-standard-with-typescript": "21.0.1",
48
48
  "eslint-plugin-import": "2.25.4",
49
- "eslint-plugin-jest": "26.1.1",
49
+ "eslint-plugin-jest": "26.1.2",
50
50
  "eslint-plugin-node": "11.1.0",
51
51
  "eslint-plugin-promise": "6.0.0",
52
52
  "eslint-plugin-tsdoc": "0.2.14",