npm-update-package 0.53.0 → 0.55.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/README.md +47 -45
- package/dist/package.json +4 -6
- package/dist/src/file/canReadWrite.js +18 -0
- package/dist/src/file/index.js +1 -0
- package/dist/src/github/GitHub.js +3 -3
- package/dist/src/github/pull-request/creator/GitHubUrlOptimizer.js +20 -0
- package/dist/src/github/pull-request/creator/PackageDiffsSectionCreator.js +26 -0
- package/dist/src/github/pull-request/creator/PullRequestBodyCreator.js +5 -5
- package/dist/src/github/pull-request/creator/ReleaseNotesSectionCreator.js +18 -0
- package/dist/src/github/pull-request/creator/index.js +3 -0
- package/dist/src/main.js +10 -4
- package/dist/src/ncu/Ncu.js +2 -0
- package/dist/src/number/index.js +17 -0
- package/dist/src/number/range.js +10 -0
- package/dist/src/options/Options.js +5 -4
- package/dist/src/options/cliOptions.js +8 -2
- package/dist/src/package-manager/PackageManagerCreator.js +33 -0
- package/dist/src/package-manager/detectPackageManager.js +15 -0
- package/dist/src/package-manager/index.js +1 -1
- package/package.json +4 -6
- package/dist/src/github/pull-request/creator/createPackageDiffsSection.js +0 -22
- package/dist/src/github/pull-request/creator/createReleaseNotesSection.js +0 -14
- package/dist/src/github/pull-request/creator/optimizeGitHubUrl.js +0 -15
- package/dist/src/package-manager/createPackageManager.js +0 -15
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ CLI tool for creating pull requests to update npm packages
|
|
|
13
13
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
14
14
|
|
|
15
15
|
- [Usage](#usage)
|
|
16
|
+
- [Requirements](#requirements)
|
|
17
|
+
- [Supported platforms](#supported-platforms)
|
|
16
18
|
- [Options](#options)
|
|
17
19
|
- [assignees](#assignees)
|
|
18
20
|
- [commitMessage](#commitmessage)
|
|
@@ -24,6 +26,7 @@ CLI tool for creating pull requests to update npm packages
|
|
|
24
26
|
- [ignorePackages](#ignorepackages)
|
|
25
27
|
- [logLevel](#loglevel)
|
|
26
28
|
- [packageManager](#packagemanager)
|
|
29
|
+
- [prBodyGithubHost](#prbodygithubhost)
|
|
27
30
|
- [prBodyNotes](#prbodynotes)
|
|
28
31
|
- [prTitle](#prtitle)
|
|
29
32
|
- [reviewers](#reviewers)
|
|
@@ -32,7 +35,6 @@ CLI tool for creating pull requests to update npm packages
|
|
|
32
35
|
- [Use token of GitHub Actions](#use-token-of-github-actions)
|
|
33
36
|
- [Use token of GitHub App](#use-token-of-github-app)
|
|
34
37
|
- [Use Personal access token](#use-personal-access-token)
|
|
35
|
-
- [Use Yarn](#use-yarn)
|
|
36
38
|
- [Flow](#flow)
|
|
37
39
|
- [FAQ](#faq)
|
|
38
40
|
- [What is the purpose of npm-update-package?](#what-is-the-purpose-of-npm-update-package)
|
|
@@ -47,6 +49,17 @@ CLI tool for creating pull requests to update npm packages
|
|
|
47
49
|
npx npm-update-package --github-token $GITHUB_TOKEN
|
|
48
50
|
```
|
|
49
51
|
|
|
52
|
+
## Requirements
|
|
53
|
+
|
|
54
|
+
- Git
|
|
55
|
+
- Node.js
|
|
56
|
+
- npm or Yarn
|
|
57
|
+
|
|
58
|
+
## Supported platforms
|
|
59
|
+
|
|
60
|
+
- GitHub
|
|
61
|
+
- GitHub Enterprise
|
|
62
|
+
|
|
50
63
|
## Options
|
|
51
64
|
|
|
52
65
|
You can customize behavior via CLI options.
|
|
@@ -234,14 +247,14 @@ npx npm-update-package \
|
|
|
234
247
|
|
|
235
248
|
### packageManager
|
|
236
249
|
|
|
237
|
-
Package manager of your project.
|
|
250
|
+
Package manager of your project.
|
|
251
|
+
Since npm-update-package automatically determines which package manager to use, it is usually not necessary to specify this option.
|
|
238
252
|
|
|
239
253
|
|Name|Value|
|
|
240
254
|
|---|---|
|
|
241
255
|
|cli|`--package-manager`|
|
|
242
256
|
|type|string|
|
|
243
257
|
|required|false|
|
|
244
|
-
|default|`npm`|
|
|
245
258
|
|
|
246
259
|
Allowed values:
|
|
247
260
|
|
|
@@ -258,6 +271,25 @@ npx npm-update-package \
|
|
|
258
271
|
--package-manager yarn
|
|
259
272
|
```
|
|
260
273
|
|
|
274
|
+
### prBodyGithubHost
|
|
275
|
+
|
|
276
|
+
GitHub host of pull request body.
|
|
277
|
+
|
|
278
|
+
|Name|Value|
|
|
279
|
+
|---|---|
|
|
280
|
+
|cli|`--pr-body-github-host`|
|
|
281
|
+
|type|string|
|
|
282
|
+
|required|false|
|
|
283
|
+
|default|`togithub.com`|
|
|
284
|
+
|
|
285
|
+
Example:
|
|
286
|
+
|
|
287
|
+
```sh
|
|
288
|
+
npx npm-update-package \
|
|
289
|
+
--github-token $GITHUB_TOKEN \
|
|
290
|
+
--pr-body-github-host "github.example"
|
|
291
|
+
```
|
|
292
|
+
|
|
261
293
|
### prBodyNotes
|
|
262
294
|
|
|
263
295
|
Additional notes for Pull request body.
|
|
@@ -368,9 +400,10 @@ jobs:
|
|
|
368
400
|
- uses: actions/checkout@v2
|
|
369
401
|
- uses: actions/setup-node@v2
|
|
370
402
|
- run: |
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
403
|
+
npx npm-update-package \
|
|
404
|
+
--github-token $GITHUB_TOKEN \
|
|
405
|
+
--git-user-name $GIT_USER_NAME \
|
|
406
|
+
--git-user-email $GIT_USER_EMAIL
|
|
374
407
|
env:
|
|
375
408
|
GIT_USER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
|
|
376
409
|
GIT_USER_NAME: github-actions[bot]
|
|
@@ -399,9 +432,10 @@ jobs:
|
|
|
399
432
|
app_id: ${{ secrets.APP_ID }}
|
|
400
433
|
private_key: ${{ secrets.PRIVATE_KEY }}
|
|
401
434
|
- run: |
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
435
|
+
npx npm-update-package \
|
|
436
|
+
--github-token $GITHUB_TOKEN \
|
|
437
|
+
--git-user-name $GIT_USER_NAME \
|
|
438
|
+
--git-user-email $GIT_USER_EMAIL
|
|
405
439
|
env:
|
|
406
440
|
# TODO: Replace with your GitHub App's email
|
|
407
441
|
GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
|
|
@@ -426,9 +460,10 @@ jobs:
|
|
|
426
460
|
- uses: actions/checkout@v2
|
|
427
461
|
- uses: actions/setup-node@v2
|
|
428
462
|
- run: |
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
463
|
+
npx npm-update-package \
|
|
464
|
+
--github-token $GITHUB_TOKEN \
|
|
465
|
+
--git-user-name $GIT_USER_NAME \
|
|
466
|
+
--git-user-email $GIT_USER_EMAIL
|
|
432
467
|
env:
|
|
433
468
|
# TODO: Replace with your email
|
|
434
469
|
GIT_USER_EMAIL: 97961304+npm-update-package-bot@users.noreply.github.com
|
|
@@ -439,39 +474,6 @@ jobs:
|
|
|
439
474
|
|
|
440
475
|
See working example on [example-pat](https://github.com/npm-update-package/example-pat).
|
|
441
476
|
|
|
442
|
-
### Use Yarn
|
|
443
|
-
|
|
444
|
-
```yaml
|
|
445
|
-
name: npm-update-package
|
|
446
|
-
on:
|
|
447
|
-
schedule:
|
|
448
|
-
- cron: '0 0 * * *'
|
|
449
|
-
jobs:
|
|
450
|
-
npm-update-package:
|
|
451
|
-
runs-on: ubuntu-latest
|
|
452
|
-
steps:
|
|
453
|
-
- uses: actions/checkout@v2
|
|
454
|
-
- uses: actions/setup-node@v2
|
|
455
|
-
- name: Generate token
|
|
456
|
-
id: generate_token
|
|
457
|
-
uses: tibdex/github-app-token@v1
|
|
458
|
-
with:
|
|
459
|
-
app_id: ${{ secrets.APP_ID }}
|
|
460
|
-
private_key: ${{ secrets.PRIVATE_KEY }}
|
|
461
|
-
- run: |
|
|
462
|
-
git config user.name $GIT_USER_NAME
|
|
463
|
-
git config user.email $GIT_USER_EMAIL
|
|
464
|
-
npx npm-update-package --github-token $GITHUB_TOKEN --package-manager yarn
|
|
465
|
-
env:
|
|
466
|
-
# TODO: Replace with your GitHub App's email
|
|
467
|
-
GIT_USER_EMAIL: 97396142+npm-update-package[bot]@users.noreply.github.com
|
|
468
|
-
# TODO: Replace with your GitHub App's user name
|
|
469
|
-
GIT_USER_NAME: npm-update-package[bot]
|
|
470
|
-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
See working example on [example-yarn](https://github.com/npm-update-package/example-yarn).
|
|
474
|
-
|
|
475
477
|
## Flow
|
|
476
478
|
|
|
477
479
|
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.
|
|
3
|
+
"version": "0.55.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",
|
|
@@ -20,11 +20,10 @@
|
|
|
20
20
|
"fp-ts": "2.11.9",
|
|
21
21
|
"http-status-codes": "2.2.0",
|
|
22
22
|
"io-ts": "2.2.16",
|
|
23
|
-
"lodash": "4.14.2",
|
|
24
23
|
"log4js": "6.4.4",
|
|
25
24
|
"mustache": "4.1.0",
|
|
26
25
|
"node-fetch": "2.6.7",
|
|
27
|
-
"npm-check-updates": "12.5.
|
|
26
|
+
"npm-check-updates": "12.5.7",
|
|
28
27
|
"parse-github-url": "1.0.2",
|
|
29
28
|
"semver": "7.3.5",
|
|
30
29
|
"sleep-promise": "9.1.0",
|
|
@@ -34,13 +33,12 @@
|
|
|
34
33
|
"@jest/types": "27.4.2",
|
|
35
34
|
"@tsconfig/node12": "1.0.9",
|
|
36
35
|
"@types/jest": "27.4.1",
|
|
37
|
-
"@types/lodash": "4.14.181",
|
|
38
36
|
"@types/mustache": "4.1.2",
|
|
39
|
-
"@types/node": "12.20.
|
|
37
|
+
"@types/node": "12.20.47",
|
|
40
38
|
"@types/node-fetch": "2.6.1",
|
|
41
39
|
"@types/parse-github-url": "1.0.0",
|
|
42
40
|
"@types/semver": "7.3.9",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
44
42
|
"eslint": "8.12.0",
|
|
45
43
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
46
44
|
"eslint-plugin-import": "2.25.4",
|
|
@@ -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;
|
package/dist/src/file/index.js
CHANGED
|
@@ -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,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GitHub = void 0;
|
|
4
|
-
const
|
|
4
|
+
const number_1 = require("../number");
|
|
5
5
|
class GitHub {
|
|
6
6
|
constructor(octokit) {
|
|
7
7
|
this.octokit = octokit;
|
|
@@ -59,7 +59,7 @@ class GitHub {
|
|
|
59
59
|
}
|
|
60
60
|
async fetchBranches({ owner, repo }) {
|
|
61
61
|
const branches = [];
|
|
62
|
-
for (const page of (0,
|
|
62
|
+
for (const page of (0, number_1.range)(1, 11)) {
|
|
63
63
|
const { data } = await this.octokit.repos.listBranches({
|
|
64
64
|
owner,
|
|
65
65
|
repo,
|
|
@@ -83,7 +83,7 @@ class GitHub {
|
|
|
83
83
|
}
|
|
84
84
|
async fetchPullRequests({ owner, repo }) {
|
|
85
85
|
const pullRequests = [];
|
|
86
|
-
for (const page of (0,
|
|
86
|
+
for (const page of (0, number_1.range)(1, 11)) {
|
|
87
87
|
const { data } = await this.octokit.pulls.list({
|
|
88
88
|
owner,
|
|
89
89
|
repo,
|
|
@@ -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 =
|
|
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 =
|
|
36
|
+
const releaseNotesSection = this.releaseNotesSectionCreator.create(releases);
|
|
37
37
|
sections.push(releaseNotesSection);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -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,9 @@ 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("./GitHubUrlOptimizer"), exports);
|
|
18
|
+
__exportStar(require("./PackageDiffsSectionCreator"), exports);
|
|
17
19
|
__exportStar(require("./PullRequestBodyCreator"), exports);
|
|
18
20
|
__exportStar(require("./PullRequestCreator"), exports);
|
|
19
21
|
__exportStar(require("./PullRequestTitleCreator"), exports);
|
|
22
|
+
__exportStar(require("./ReleaseNotesSectionCreator"), exports);
|
package/dist/src/main.js
CHANGED
|
@@ -63,18 +63,24 @@ const main = async ({ options, logger }) => {
|
|
|
63
63
|
color: 'A00F21'
|
|
64
64
|
});
|
|
65
65
|
const branchFinder = new github_1.BranchFinder(branches);
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const packageManagerCreator = new package_manager_1.PackageManagerCreator({
|
|
67
|
+
options,
|
|
68
|
+
logger
|
|
69
69
|
});
|
|
70
|
+
const packageManager = await packageManagerCreator.create(terminal);
|
|
70
71
|
const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.prTitle);
|
|
71
72
|
const releasesFetcher = new github_1.ReleasesFetcher({
|
|
72
73
|
options,
|
|
73
74
|
packageManager
|
|
74
75
|
});
|
|
76
|
+
const githubUrlOptimizer = new github_1.GitHubUrlOptimizer(options);
|
|
77
|
+
const packageDiffsSectionCreator = new github_1.PackageDiffsSectionCreator(githubUrlOptimizer);
|
|
78
|
+
const releaseNotesSectionCreator = new github_1.ReleaseNotesSectionCreator(githubUrlOptimizer);
|
|
75
79
|
const pullRequestBodyCreator = new github_1.PullRequestBodyCreator({
|
|
76
80
|
options,
|
|
77
|
-
releasesFetcher
|
|
81
|
+
releasesFetcher,
|
|
82
|
+
packageDiffsSectionCreator,
|
|
83
|
+
releaseNotesSectionCreator
|
|
78
84
|
});
|
|
79
85
|
const pullRequestCreator = new github_1.PullRequestCreator({
|
|
80
86
|
github,
|
package/dist/src/ncu/Ncu.js
CHANGED
|
@@ -15,12 +15,14 @@ class Ncu {
|
|
|
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
|
|
@@ -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("./range"), exports);
|
|
@@ -19,10 +19,7 @@ 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
|
-
|
|
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)({
|
|
@@ -30,6 +27,10 @@ const Options = (0, io_ts_1.intersection)([
|
|
|
30
27
|
gitUserEmail: io_ts_1.string,
|
|
31
28
|
gitUserName: io_ts_1.string,
|
|
32
29
|
ignorePackages: (0, io_ts_1.array)(io_ts_1.string),
|
|
30
|
+
packageManager: (0, io_ts_1.union)([
|
|
31
|
+
(0, io_ts_1.literal)(package_manager_1.PackageManagerName.Npm),
|
|
32
|
+
(0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)
|
|
33
|
+
]),
|
|
33
34
|
prBodyNotes: io_ts_1.string,
|
|
34
35
|
reviewers: (0, io_ts_1.array)(io_ts_1.string)
|
|
35
36
|
})
|
|
@@ -80,8 +80,14 @@ exports.cliOptions = [
|
|
|
80
80
|
choices: [
|
|
81
81
|
package_manager_1.PackageManagerName.Npm,
|
|
82
82
|
package_manager_1.PackageManagerName.Yarn
|
|
83
|
-
]
|
|
84
|
-
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'pr-body-github-host',
|
|
87
|
+
description: 'GitHub host of pull request body',
|
|
88
|
+
type: OptionType_1.OptionType.String,
|
|
89
|
+
required: false,
|
|
90
|
+
default: 'togithub.com'
|
|
85
91
|
},
|
|
86
92
|
{
|
|
87
93
|
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 detectPackageManager_1 = require("./detectPackageManager");
|
|
5
|
+
const Npm_1 = require("./Npm");
|
|
6
|
+
const PackageManagerName_1 = require("./PackageManagerName");
|
|
7
|
+
const Yarn_1 = require("./Yarn");
|
|
8
|
+
class PackageManagerCreator {
|
|
9
|
+
constructor({ options, logger }) {
|
|
10
|
+
this.options = options;
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
}
|
|
13
|
+
async create(terminal) {
|
|
14
|
+
const packageManagerName = await this.getPackageManagerName();
|
|
15
|
+
this.logger.trace(`packageManagerName=${packageManagerName}`);
|
|
16
|
+
switch (packageManagerName) {
|
|
17
|
+
case PackageManagerName_1.PackageManagerName.Npm:
|
|
18
|
+
this.logger.info('Use npm as package manager');
|
|
19
|
+
return new Npm_1.Npm(terminal);
|
|
20
|
+
case PackageManagerName_1.PackageManagerName.Yarn:
|
|
21
|
+
this.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
|
+
this.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
17
|
__exportStar(require("./Npm"), exports);
|
|
19
18
|
__exportStar(require("./PackageManager"), exports);
|
|
19
|
+
__exportStar(require("./PackageManagerCreator"), exports);
|
|
20
20
|
__exportStar(require("./PackageManagerName"), exports);
|
|
21
21
|
__exportStar(require("./Yarn"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.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",
|
|
@@ -20,11 +20,10 @@
|
|
|
20
20
|
"fp-ts": "2.11.9",
|
|
21
21
|
"http-status-codes": "2.2.0",
|
|
22
22
|
"io-ts": "2.2.16",
|
|
23
|
-
"lodash": "4.14.2",
|
|
24
23
|
"log4js": "6.4.4",
|
|
25
24
|
"mustache": "4.1.0",
|
|
26
25
|
"node-fetch": "2.6.7",
|
|
27
|
-
"npm-check-updates": "12.5.
|
|
26
|
+
"npm-check-updates": "12.5.7",
|
|
28
27
|
"parse-github-url": "1.0.2",
|
|
29
28
|
"semver": "7.3.5",
|
|
30
29
|
"sleep-promise": "9.1.0",
|
|
@@ -34,13 +33,12 @@
|
|
|
34
33
|
"@jest/types": "27.4.2",
|
|
35
34
|
"@tsconfig/node12": "1.0.9",
|
|
36
35
|
"@types/jest": "27.4.1",
|
|
37
|
-
"@types/lodash": "4.14.181",
|
|
38
36
|
"@types/mustache": "4.1.2",
|
|
39
|
-
"@types/node": "12.20.
|
|
37
|
+
"@types/node": "12.20.47",
|
|
40
38
|
"@types/node-fetch": "2.6.1",
|
|
41
39
|
"@types/parse-github-url": "1.0.0",
|
|
42
40
|
"@types/semver": "7.3.9",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "5.18.0",
|
|
44
42
|
"eslint": "8.12.0",
|
|
45
43
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
46
44
|
"eslint-plugin-import": "2.25.4",
|
|
@@ -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,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;
|