npm-update-package 0.7.0 → 0.8.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 +96 -20
- package/dist/app.js +1 -1
- package/dist/github/PullRequestBodyCreator.js +29 -0
- package/dist/github/PullRequestCreator.js +3 -3
- package/dist/github/index.js +3 -1
- package/dist/main.js +2 -0
- package/dist/options/Options.js +1 -0
- package/dist/options/initOptions.js +8 -0
- package/package.json +1 -1
- package/src/app.ts +1 -1
- package/src/github/PullRequestBodyCreator.test.ts +32 -0
- package/src/github/PullRequestBodyCreator.ts +26 -0
- package/src/github/PullRequestCreator.ts +6 -2
- package/src/github/PullRequestTitleCreator.test.ts +1 -1
- package/src/github/index.ts +1 -0
- package/src/main.ts +3 -0
- package/src/options/Options.ts +1 -0
- package/src/options/initOptions.ts +8 -0
- package/dist/github/createPullRequestBody.js +0 -19
- package/src/github/createPullRequestBody.test.ts +0 -64
- package/src/github/createPullRequestBody.ts +0 -17
package/README.md
CHANGED
|
@@ -33,36 +33,112 @@ npm-update-package --github-token $GITHUB_TOKEN
|
|
|
33
33
|
|
|
34
34
|
## Options
|
|
35
35
|
|
|
36
|
-
You can customize behavior via command-line options.
|
|
36
|
+
You can customize behavior via command-line options.
|
|
37
|
+
Template strings such as `--branch-name` can embed variables like `{{packageName}}`(HTML-escaped) or `{{{packageName}}}`(not HTML-escaped).
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|---|---|---|---|---|
|
|
40
|
-
|`--branch-name`|Branch name template|-|string|`npm-update-package/{{{packageName}}}/v{{newVersion}}`|
|
|
41
|
-
|`--commit-message`|Commit message template|-|string|`chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`|
|
|
42
|
-
|`--git-user-email`|User email of commit|-|string|-|
|
|
43
|
-
|`--git-user-name`|User name of commit|-|string|-|
|
|
44
|
-
|`--github-token`|GitHub token|✓|string|-|
|
|
45
|
-
|`--log-level`|Log level to show|-|`info`, `debug`|`info`|
|
|
46
|
-
|`--package-manager`|Package manager of your project|-|`npm`, `yarn`|`npm`|
|
|
47
|
-
|`--pull-request-title`|Pull request title template|-|string|`chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`|
|
|
39
|
+
### `--branch-name`
|
|
48
40
|
|
|
49
|
-
|
|
41
|
+
Branch name template
|
|
50
42
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- `--branch-name`
|
|
55
|
-
- `packageName`
|
|
43
|
+
- value: template string
|
|
44
|
+
- embeddable variables:
|
|
56
45
|
- `currentVersion`
|
|
57
46
|
- `newVersion`
|
|
58
|
-
- `updateType`
|
|
59
|
-
- `--commit-message`
|
|
60
47
|
- `packageName`
|
|
48
|
+
- `updateType`
|
|
49
|
+
- required: false
|
|
50
|
+
- default: `npm-update-package/{{{packageName}}}/v{{newVersion}}`
|
|
51
|
+
|
|
52
|
+
### `--commit-message`
|
|
53
|
+
|
|
54
|
+
Commit message template
|
|
55
|
+
|
|
56
|
+
- value: template string
|
|
57
|
+
- embeddable variables:
|
|
61
58
|
- `currentVersion`
|
|
62
59
|
- `newVersion`
|
|
60
|
+
- `packageName`
|
|
63
61
|
- `updateType`
|
|
64
|
-
-
|
|
62
|
+
- required: false
|
|
63
|
+
- default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
|
|
64
|
+
|
|
65
|
+
### `--git-user-email`
|
|
66
|
+
|
|
67
|
+
User email of commit
|
|
68
|
+
|
|
69
|
+
- value: string
|
|
70
|
+
- required: false
|
|
71
|
+
|
|
72
|
+
### `--git-user-name`
|
|
73
|
+
|
|
74
|
+
User name of commit
|
|
75
|
+
|
|
76
|
+
- value: string
|
|
77
|
+
- required: false
|
|
78
|
+
|
|
79
|
+
### `--github-token`
|
|
80
|
+
|
|
81
|
+
GitHub token
|
|
82
|
+
|
|
83
|
+
- value: string
|
|
84
|
+
- required: true
|
|
85
|
+
|
|
86
|
+
### `--log-level`
|
|
87
|
+
|
|
88
|
+
Log level to show
|
|
89
|
+
|
|
90
|
+
- value: string
|
|
91
|
+
- `info`
|
|
92
|
+
- `debug`
|
|
93
|
+
- required: false
|
|
94
|
+
- default: `info`
|
|
95
|
+
|
|
96
|
+
### `--package-manager`
|
|
97
|
+
|
|
98
|
+
Package manager of your project
|
|
99
|
+
|
|
100
|
+
- value: string
|
|
101
|
+
- `npm`
|
|
102
|
+
- `yarn`
|
|
103
|
+
- required: false
|
|
104
|
+
- default: `npm`
|
|
105
|
+
|
|
106
|
+
### `--pull-request-body`
|
|
107
|
+
|
|
108
|
+
Pull request body template
|
|
109
|
+
|
|
110
|
+
- value: template string
|
|
111
|
+
- embeddable variables:
|
|
112
|
+
- `appName`
|
|
113
|
+
- `appVersion`
|
|
114
|
+
- `appWeb`
|
|
115
|
+
- `currentVersion`
|
|
116
|
+
- `newVersion`
|
|
65
117
|
- `packageName`
|
|
118
|
+
- `updateType`
|
|
119
|
+
- required: false
|
|
120
|
+
- default:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
This PR updates these packages:
|
|
124
|
+
|
|
125
|
+
|package|type|current version|new version|
|
|
126
|
+
|---|---|---|---|
|
|
127
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### `--pull-request-title`
|
|
134
|
+
|
|
135
|
+
Pull request title template
|
|
136
|
+
|
|
137
|
+
- value: template string
|
|
138
|
+
- embeddable variables:
|
|
66
139
|
- `currentVersion`
|
|
67
140
|
- `newVersion`
|
|
141
|
+
- `packageName`
|
|
68
142
|
- `updateType`
|
|
143
|
+
- required: false
|
|
144
|
+
- default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
|
package/dist/app.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequestBodyCreator = void 0;
|
|
4
|
+
const mustache_1 = require("mustache");
|
|
5
|
+
const app_1 = require("../app");
|
|
6
|
+
class PullRequestBodyCreator {
|
|
7
|
+
constructor(template) {
|
|
8
|
+
this.template = template;
|
|
9
|
+
}
|
|
10
|
+
create(outdatedPackage) {
|
|
11
|
+
const appName = app_1.app.name;
|
|
12
|
+
const appVersion = app_1.app.version;
|
|
13
|
+
const appWeb = app_1.app.web;
|
|
14
|
+
const currentVersion = outdatedPackage.currentVersion.version;
|
|
15
|
+
const newVersion = outdatedPackage.newVersion.version;
|
|
16
|
+
const packageName = outdatedPackage.name;
|
|
17
|
+
const updateType = outdatedPackage.type;
|
|
18
|
+
return (0, mustache_1.render)(this.template, {
|
|
19
|
+
appName,
|
|
20
|
+
appVersion,
|
|
21
|
+
appWeb,
|
|
22
|
+
currentVersion,
|
|
23
|
+
newVersion,
|
|
24
|
+
packageName,
|
|
25
|
+
updateType
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.PullRequestBodyCreator = PullRequestBodyCreator;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullRequestCreator = void 0;
|
|
4
|
-
const createPullRequestBody_1 = require("./createPullRequestBody");
|
|
5
4
|
// TODO: add test
|
|
6
5
|
class PullRequestCreator {
|
|
7
|
-
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger }) {
|
|
6
|
+
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger }) {
|
|
8
7
|
this.github = github;
|
|
9
8
|
this.gitRepo = gitRepo;
|
|
10
9
|
this.githubRepo = githubRepo;
|
|
11
10
|
this.pullRequestTitleCreator = pullRequestTitleCreator;
|
|
11
|
+
this.pullRequestBodyCreator = pullRequestBodyCreator;
|
|
12
12
|
this.logger = logger;
|
|
13
13
|
}
|
|
14
14
|
async create({ outdatedPackage, branchName }) {
|
|
15
15
|
const title = this.pullRequestTitleCreator.create(outdatedPackage);
|
|
16
16
|
this.logger.debug(`title=${title}`);
|
|
17
|
-
const body =
|
|
17
|
+
const body = this.pullRequestBodyCreator.create(outdatedPackage);
|
|
18
18
|
this.logger.debug(`body=${body}`);
|
|
19
19
|
const createdPullRequest = await this.github.createPullRequest({
|
|
20
20
|
owner: this.gitRepo.owner,
|
package/dist/github/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoteBranchExistenceChecker = exports.PullRequestTitleCreator = exports.PullRequestCreator = exports.GitHub = exports.createGitHub = void 0;
|
|
3
|
+
exports.RemoteBranchExistenceChecker = exports.PullRequestTitleCreator = exports.PullRequestCreator = exports.PullRequestBodyCreator = exports.GitHub = exports.createGitHub = void 0;
|
|
4
4
|
var createGitHub_1 = require("./createGitHub");
|
|
5
5
|
Object.defineProperty(exports, "createGitHub", { enumerable: true, get: function () { return createGitHub_1.createGitHub; } });
|
|
6
6
|
var GitHub_1 = require("./GitHub");
|
|
7
7
|
Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () { return GitHub_1.GitHub; } });
|
|
8
|
+
var PullRequestBodyCreator_1 = require("./PullRequestBodyCreator");
|
|
9
|
+
Object.defineProperty(exports, "PullRequestBodyCreator", { enumerable: true, get: function () { return PullRequestBodyCreator_1.PullRequestBodyCreator; } });
|
|
8
10
|
var PullRequestCreator_1 = require("./PullRequestCreator");
|
|
9
11
|
Object.defineProperty(exports, "PullRequestCreator", { enumerable: true, get: function () { return PullRequestCreator_1.PullRequestCreator; } });
|
|
10
12
|
var PullRequestTitleCreator_1 = require("./PullRequestTitleCreator");
|
package/dist/main.js
CHANGED
|
@@ -55,11 +55,13 @@ const main = async ({ options, logger }) => {
|
|
|
55
55
|
packageManager: options.packageManager
|
|
56
56
|
});
|
|
57
57
|
const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.pullRequestTitle);
|
|
58
|
+
const pullRequestBodyCreator = new github_1.PullRequestBodyCreator(options.pullRequestBody);
|
|
58
59
|
const pullRequestCreator = new github_1.PullRequestCreator({
|
|
59
60
|
github,
|
|
60
61
|
gitRepo,
|
|
61
62
|
githubRepo,
|
|
62
63
|
pullRequestTitleCreator,
|
|
64
|
+
pullRequestBodyCreator,
|
|
63
65
|
logger
|
|
64
66
|
});
|
|
65
67
|
const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
|
package/dist/options/Options.js
CHANGED
|
@@ -11,6 +11,7 @@ const Options = (0, io_ts_1.intersection)([
|
|
|
11
11
|
githubToken: io_ts_1.string,
|
|
12
12
|
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Info), (0, io_ts_1.literal)(logger_1.LogLevel.Debug)]),
|
|
13
13
|
packageManager: (0, io_ts_1.union)([(0, io_ts_1.literal)(package_manager_1.PackageManagerName.Npm), (0, io_ts_1.literal)(package_manager_1.PackageManagerName.Yarn)]),
|
|
14
|
+
pullRequestBody: io_ts_1.string,
|
|
14
15
|
pullRequestTitle: io_ts_1.string
|
|
15
16
|
}),
|
|
16
17
|
(0, io_ts_1.partial)({
|
|
@@ -27,6 +27,14 @@ const initOptions = () => {
|
|
|
27
27
|
package_manager_1.PackageManagerName.Yarn
|
|
28
28
|
])
|
|
29
29
|
.default(package_manager_1.PackageManagerName.Npm))
|
|
30
|
+
.option('--pull-request-body <value>', 'Pull request body template', `This PR updates these packages:
|
|
31
|
+
|
|
32
|
+
|package|type|current version|new version|
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`)
|
|
30
38
|
.option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}');
|
|
31
39
|
commander_1.program.parse(process.argv);
|
|
32
40
|
const options = commander_1.program.opts();
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { app } from '../app'
|
|
2
|
+
import { PackageVersion } from '../ncu'
|
|
3
|
+
import { PullRequestBodyCreator } from './PullRequestBodyCreator'
|
|
4
|
+
|
|
5
|
+
describe('PullRequestBodyCreator', () => {
|
|
6
|
+
describe('create', () => {
|
|
7
|
+
it('returns pull request body', () => {
|
|
8
|
+
const pullRequestBodyCreator = new PullRequestBodyCreator(`This PR updates these packages:
|
|
9
|
+
|
|
10
|
+
|package|type|current version|new version|
|
|
11
|
+
|---|---|---|---|
|
|
12
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`)
|
|
16
|
+
const actual = pullRequestBodyCreator.create({
|
|
17
|
+
name: '@typescript-eslint/eslint-plugin',
|
|
18
|
+
currentVersion: PackageVersion.of('1.0.0'),
|
|
19
|
+
newVersion: PackageVersion.of('2.0.0'),
|
|
20
|
+
type: 'major'
|
|
21
|
+
})
|
|
22
|
+
expect(actual).toBe(`This PR updates these packages:
|
|
23
|
+
|
|
24
|
+
|package|type|current version|new version|
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|major|\`1.0.0\`|\`2.0.0\`|
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
This PR has been generated by [${app.name}](${app.web}) v${app.version}`)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render } from 'mustache'
|
|
2
|
+
import { app } from '../app'
|
|
3
|
+
import type { OutdatedPackage } from '../ncu'
|
|
4
|
+
|
|
5
|
+
export class PullRequestBodyCreator {
|
|
6
|
+
constructor (private readonly template: string) {}
|
|
7
|
+
|
|
8
|
+
create (outdatedPackage: OutdatedPackage): string {
|
|
9
|
+
const appName = app.name
|
|
10
|
+
const appVersion = app.version
|
|
11
|
+
const appWeb = app.web
|
|
12
|
+
const currentVersion = outdatedPackage.currentVersion.version
|
|
13
|
+
const newVersion = outdatedPackage.newVersion.version
|
|
14
|
+
const packageName = outdatedPackage.name
|
|
15
|
+
const updateType = outdatedPackage.type
|
|
16
|
+
return render(this.template, {
|
|
17
|
+
appName,
|
|
18
|
+
appVersion,
|
|
19
|
+
appWeb,
|
|
20
|
+
currentVersion,
|
|
21
|
+
newVersion,
|
|
22
|
+
packageName,
|
|
23
|
+
updateType
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { GitRepository } from '../git'
|
|
2
2
|
import type { Logger } from '../logger'
|
|
3
3
|
import type { OutdatedPackage } from '../ncu'
|
|
4
|
-
import { createPullRequestBody } from './createPullRequestBody'
|
|
5
4
|
import type { GitHub } from './GitHub'
|
|
5
|
+
import type { PullRequestBodyCreator } from './PullRequestBodyCreator'
|
|
6
6
|
import type { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
7
7
|
import type { Repository as GitHubRepository } from './Repository'
|
|
8
8
|
|
|
@@ -12,6 +12,7 @@ export class PullRequestCreator {
|
|
|
12
12
|
private readonly gitRepo: GitRepository
|
|
13
13
|
private readonly githubRepo: GitHubRepository
|
|
14
14
|
private readonly pullRequestTitleCreator: PullRequestTitleCreator
|
|
15
|
+
private readonly pullRequestBodyCreator: PullRequestBodyCreator
|
|
15
16
|
private readonly logger: Logger
|
|
16
17
|
|
|
17
18
|
constructor ({
|
|
@@ -19,18 +20,21 @@ export class PullRequestCreator {
|
|
|
19
20
|
gitRepo,
|
|
20
21
|
githubRepo,
|
|
21
22
|
pullRequestTitleCreator,
|
|
23
|
+
pullRequestBodyCreator,
|
|
22
24
|
logger
|
|
23
25
|
}: {
|
|
24
26
|
github: GitHub
|
|
25
27
|
gitRepo: GitRepository
|
|
26
28
|
githubRepo: GitHubRepository
|
|
27
29
|
pullRequestTitleCreator: PullRequestTitleCreator
|
|
30
|
+
pullRequestBodyCreator: PullRequestBodyCreator
|
|
28
31
|
logger: Logger
|
|
29
32
|
}) {
|
|
30
33
|
this.github = github
|
|
31
34
|
this.gitRepo = gitRepo
|
|
32
35
|
this.githubRepo = githubRepo
|
|
33
36
|
this.pullRequestTitleCreator = pullRequestTitleCreator
|
|
37
|
+
this.pullRequestBodyCreator = pullRequestBodyCreator
|
|
34
38
|
this.logger = logger
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -44,7 +48,7 @@ export class PullRequestCreator {
|
|
|
44
48
|
const title = this.pullRequestTitleCreator.create(outdatedPackage)
|
|
45
49
|
this.logger.debug(`title=${title}`)
|
|
46
50
|
|
|
47
|
-
const body =
|
|
51
|
+
const body = this.pullRequestBodyCreator.create(outdatedPackage)
|
|
48
52
|
this.logger.debug(`body=${body}`)
|
|
49
53
|
|
|
50
54
|
const createdPullRequest = await this.github.createPullRequest({
|
|
@@ -3,7 +3,7 @@ import { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
|
3
3
|
|
|
4
4
|
describe('PullRequestTitleCreator', () => {
|
|
5
5
|
describe('create', () => {
|
|
6
|
-
it('returns
|
|
6
|
+
it('returns pull request title', () => {
|
|
7
7
|
const pullRequestTitleCreator = new PullRequestTitleCreator('chore(deps): {{updateType}} update {{{packageName}}} from {{currentVersion}} to v{{newVersion}}')
|
|
8
8
|
const actual = pullRequestTitleCreator.create({
|
|
9
9
|
name: '@typescript-eslint/eslint-plugin',
|
package/src/github/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export type { Branch } from './Branch'
|
|
|
2
2
|
export { createGitHub } from './createGitHub'
|
|
3
3
|
export { GitHub } from './GitHub'
|
|
4
4
|
export type { PullRequest } from './PullRequest'
|
|
5
|
+
export { PullRequestBodyCreator } from './PullRequestBodyCreator'
|
|
5
6
|
export { PullRequestCreator } from './PullRequestCreator'
|
|
6
7
|
export { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
7
8
|
export { RemoteBranchExistenceChecker } from './RemoteBranchExistenceChecker'
|
package/src/main.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from './git'
|
|
7
7
|
import {
|
|
8
8
|
createGitHub,
|
|
9
|
+
PullRequestBodyCreator,
|
|
9
10
|
PullRequestCreator,
|
|
10
11
|
PullRequestTitleCreator,
|
|
11
12
|
RemoteBranchExistenceChecker
|
|
@@ -84,11 +85,13 @@ export const main = async ({
|
|
|
84
85
|
packageManager: options.packageManager
|
|
85
86
|
})
|
|
86
87
|
const pullRequestTitleCreator = new PullRequestTitleCreator(options.pullRequestTitle)
|
|
88
|
+
const pullRequestBodyCreator = new PullRequestBodyCreator(options.pullRequestBody)
|
|
87
89
|
const pullRequestCreator = new PullRequestCreator({
|
|
88
90
|
github,
|
|
89
91
|
gitRepo,
|
|
90
92
|
githubRepo,
|
|
91
93
|
pullRequestTitleCreator,
|
|
94
|
+
pullRequestBodyCreator,
|
|
92
95
|
logger
|
|
93
96
|
})
|
|
94
97
|
const branchNameCreator = new BranchNameCreator(options.branchName)
|
package/src/options/Options.ts
CHANGED
|
@@ -17,6 +17,7 @@ const Options = intersection([
|
|
|
17
17
|
githubToken: string,
|
|
18
18
|
logLevel: union([literal(LogLevel.Info), literal(LogLevel.Debug)]),
|
|
19
19
|
packageManager: union([literal(PackageManagerName.Npm), literal(PackageManagerName.Yarn)]),
|
|
20
|
+
pullRequestBody: string,
|
|
20
21
|
pullRequestTitle: string
|
|
21
22
|
}),
|
|
22
23
|
partial({
|
|
@@ -33,6 +33,14 @@ export const initOptions = (): Options => {
|
|
|
33
33
|
])
|
|
34
34
|
.default(PackageManagerName.Npm)
|
|
35
35
|
)
|
|
36
|
+
.option('--pull-request-body <value>', 'Pull request body template', `This PR updates these packages:
|
|
37
|
+
|
|
38
|
+
|package|type|current version|new version|
|
|
39
|
+
|---|---|---|---|
|
|
40
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`)
|
|
36
44
|
.option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}')
|
|
37
45
|
program.parse(process.argv)
|
|
38
46
|
const options = program.opts()
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPullRequestBody = void 0;
|
|
4
|
-
const app_1 = require("../app");
|
|
5
|
-
const createPullRequestBody = (outdatedPackage) => {
|
|
6
|
-
const packageName = outdatedPackage.name;
|
|
7
|
-
const currentVersion = outdatedPackage.currentVersion.version;
|
|
8
|
-
const newVersion = outdatedPackage.newVersion.version;
|
|
9
|
-
const updateType = outdatedPackage.type;
|
|
10
|
-
return `This PR updates these packages:
|
|
11
|
-
|
|
12
|
-
|package|type|current version|new version|
|
|
13
|
-
|---|---|---|---|
|
|
14
|
-
|[${packageName}](https://www.npmjs.com/package/${packageName})|${updateType}|\`${currentVersion}\`|\`${newVersion}\`|
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
This PR has been generated by [${app_1.app.name}](${app_1.app.web})`;
|
|
18
|
-
};
|
|
19
|
-
exports.createPullRequestBody = createPullRequestBody;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PackageVersion,
|
|
3
|
-
UpdateType
|
|
4
|
-
} from '../ncu'
|
|
5
|
-
import { createPullRequestBody } from './createPullRequestBody'
|
|
6
|
-
|
|
7
|
-
describe('createPullRequestBody', () => {
|
|
8
|
-
describe('if update type is patch', () => {
|
|
9
|
-
it('returns pull request body', () => {
|
|
10
|
-
const actual = createPullRequestBody({
|
|
11
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
12
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
13
|
-
newVersion: PackageVersion.of('1.0.1'),
|
|
14
|
-
type: UpdateType.Patch
|
|
15
|
-
})
|
|
16
|
-
expect(actual).toBe(`This PR updates these packages:
|
|
17
|
-
|
|
18
|
-
|package|type|current version|new version|
|
|
19
|
-
|---|---|---|---|
|
|
20
|
-
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|patch|\`1.0.0\`|\`1.0.1\`|
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
This PR has been generated by [npm-update-package](https://github.com/npm-update-package/npm-update-package)`)
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
describe('if update type is minor', () => {
|
|
28
|
-
it('returns pull request body', () => {
|
|
29
|
-
const actual = createPullRequestBody({
|
|
30
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
31
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
32
|
-
newVersion: PackageVersion.of('1.1.0'),
|
|
33
|
-
type: UpdateType.Minor
|
|
34
|
-
})
|
|
35
|
-
expect(actual).toBe(`This PR updates these packages:
|
|
36
|
-
|
|
37
|
-
|package|type|current version|new version|
|
|
38
|
-
|---|---|---|---|
|
|
39
|
-
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|minor|\`1.0.0\`|\`1.1.0\`|
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
This PR has been generated by [npm-update-package](https://github.com/npm-update-package/npm-update-package)`)
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
describe('if update type is major', () => {
|
|
47
|
-
it('returns pull request body', () => {
|
|
48
|
-
const actual = createPullRequestBody({
|
|
49
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
50
|
-
currentVersion: PackageVersion.of('1.0.0'),
|
|
51
|
-
newVersion: PackageVersion.of('2.0.0'),
|
|
52
|
-
type: UpdateType.Major
|
|
53
|
-
})
|
|
54
|
-
expect(actual).toBe(`This PR updates these packages:
|
|
55
|
-
|
|
56
|
-
|package|type|current version|new version|
|
|
57
|
-
|---|---|---|---|
|
|
58
|
-
|[@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)|major|\`1.0.0\`|\`2.0.0\`|
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
This PR has been generated by [npm-update-package](https://github.com/npm-update-package/npm-update-package)`)
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
})
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { app } from '../app'
|
|
2
|
-
import type { OutdatedPackage } from '../ncu'
|
|
3
|
-
|
|
4
|
-
export const createPullRequestBody = (outdatedPackage: OutdatedPackage): string => {
|
|
5
|
-
const packageName = outdatedPackage.name
|
|
6
|
-
const currentVersion = outdatedPackage.currentVersion.version
|
|
7
|
-
const newVersion = outdatedPackage.newVersion.version
|
|
8
|
-
const updateType = outdatedPackage.type
|
|
9
|
-
return `This PR updates these packages:
|
|
10
|
-
|
|
11
|
-
|package|type|current version|new version|
|
|
12
|
-
|---|---|---|---|
|
|
13
|
-
|[${packageName}](https://www.npmjs.com/package/${packageName})|${updateType}|\`${currentVersion}\`|\`${newVersion}\`|
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
This PR has been generated by [${app.name}](${app.web})`
|
|
17
|
-
}
|