npm-update-package 0.6.1 → 0.7.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 +6 -0
- package/dist/app.js +1 -1
- package/dist/github/PullRequestCreator.js +3 -3
- package/dist/github/PullRequestTitleCreator.js +22 -0
- package/dist/github/index.js +3 -1
- package/dist/main.js +2 -0
- package/dist/options/Options.js +5 -2
- package/dist/options/initOptions.js +2 -1
- package/package.json +1 -1
- package/src/app.ts +1 -1
- package/src/github/PullRequestCreator.ts +6 -2
- package/src/github/PullRequestTitleCreator.test.ts +17 -0
- package/src/github/PullRequestTitleCreator.ts +19 -0
- package/src/github/index.ts +1 -0
- package/src/main.ts +3 -0
- package/src/options/Options.ts +5 -2
- package/src/options/initOptions.ts +1 -0
- package/dist/github/createPullRequestTitle.js +0 -10
- package/src/github/createPullRequestTitle.test.ts +0 -42
- package/src/github/createPullRequestTitle.ts +0 -8
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ You can customize behavior via command-line options.
|
|
|
44
44
|
|`--github-token`|GitHub token|✓|string|-|
|
|
45
45
|
|`--log-level`|Log level to show|-|`info`, `debug`|`info`|
|
|
46
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}}`|
|
|
47
48
|
|
|
48
49
|
### Templates
|
|
49
50
|
|
|
@@ -60,3 +61,8 @@ These variables are available:
|
|
|
60
61
|
- `currentVersion`
|
|
61
62
|
- `newVersion`
|
|
62
63
|
- `updateType`
|
|
64
|
+
- `--pull-request-title`
|
|
65
|
+
- `packageName`
|
|
66
|
+
- `currentVersion`
|
|
67
|
+
- `newVersion`
|
|
68
|
+
- `updateType`
|
package/dist/app.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullRequestCreator = void 0;
|
|
4
4
|
const createPullRequestBody_1 = require("./createPullRequestBody");
|
|
5
|
-
const createPullRequestTitle_1 = require("./createPullRequestTitle");
|
|
6
5
|
// TODO: add test
|
|
7
6
|
class PullRequestCreator {
|
|
8
|
-
constructor({ github, gitRepo, githubRepo, logger }) {
|
|
7
|
+
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, logger }) {
|
|
9
8
|
this.github = github;
|
|
10
9
|
this.gitRepo = gitRepo;
|
|
11
10
|
this.githubRepo = githubRepo;
|
|
11
|
+
this.pullRequestTitleCreator = pullRequestTitleCreator;
|
|
12
12
|
this.logger = logger;
|
|
13
13
|
}
|
|
14
14
|
async create({ outdatedPackage, branchName }) {
|
|
15
|
-
const title =
|
|
15
|
+
const title = this.pullRequestTitleCreator.create(outdatedPackage);
|
|
16
16
|
this.logger.debug(`title=${title}`);
|
|
17
17
|
const body = (0, createPullRequestBody_1.createPullRequestBody)(outdatedPackage);
|
|
18
18
|
this.logger.debug(`body=${body}`);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequestTitleCreator = void 0;
|
|
4
|
+
const mustache_1 = require("mustache");
|
|
5
|
+
class PullRequestTitleCreator {
|
|
6
|
+
constructor(template) {
|
|
7
|
+
this.template = template;
|
|
8
|
+
}
|
|
9
|
+
create(outdatedPackage) {
|
|
10
|
+
const packageName = outdatedPackage.name;
|
|
11
|
+
const currentVersion = outdatedPackage.currentVersion.version;
|
|
12
|
+
const newVersion = outdatedPackage.newVersion.version;
|
|
13
|
+
const updateType = outdatedPackage.type;
|
|
14
|
+
return (0, mustache_1.render)(this.template, {
|
|
15
|
+
packageName,
|
|
16
|
+
currentVersion,
|
|
17
|
+
newVersion,
|
|
18
|
+
updateType
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PullRequestTitleCreator = PullRequestTitleCreator;
|
package/dist/github/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RemoteBranchExistenceChecker = exports.PullRequestCreator = exports.GitHub = exports.createGitHub = void 0;
|
|
3
|
+
exports.RemoteBranchExistenceChecker = exports.PullRequestTitleCreator = exports.PullRequestCreator = 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
8
|
var PullRequestCreator_1 = require("./PullRequestCreator");
|
|
9
9
|
Object.defineProperty(exports, "PullRequestCreator", { enumerable: true, get: function () { return PullRequestCreator_1.PullRequestCreator; } });
|
|
10
|
+
var PullRequestTitleCreator_1 = require("./PullRequestTitleCreator");
|
|
11
|
+
Object.defineProperty(exports, "PullRequestTitleCreator", { enumerable: true, get: function () { return PullRequestTitleCreator_1.PullRequestTitleCreator; } });
|
|
10
12
|
var RemoteBranchExistenceChecker_1 = require("./RemoteBranchExistenceChecker");
|
|
11
13
|
Object.defineProperty(exports, "RemoteBranchExistenceChecker", { enumerable: true, get: function () { return RemoteBranchExistenceChecker_1.RemoteBranchExistenceChecker; } });
|
package/dist/main.js
CHANGED
|
@@ -54,10 +54,12 @@ const main = async ({ options, logger }) => {
|
|
|
54
54
|
terminal,
|
|
55
55
|
packageManager: options.packageManager
|
|
56
56
|
});
|
|
57
|
+
const pullRequestTitleCreator = new github_1.PullRequestTitleCreator(options.pullRequestTitle);
|
|
57
58
|
const pullRequestCreator = new github_1.PullRequestCreator({
|
|
58
59
|
github,
|
|
59
60
|
gitRepo,
|
|
60
61
|
githubRepo,
|
|
62
|
+
pullRequestTitleCreator,
|
|
61
63
|
logger
|
|
62
64
|
});
|
|
63
65
|
const branchNameCreator = new git_1.BranchNameCreator(options.branchName);
|
package/dist/options/Options.js
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isOptions = void 0;
|
|
4
4
|
const io_ts_1 = require("io-ts");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const package_manager_1 = require("../package-manager");
|
|
5
7
|
const Options = (0, io_ts_1.intersection)([
|
|
6
8
|
(0, io_ts_1.type)({
|
|
7
9
|
branchName: io_ts_1.string,
|
|
8
10
|
commitMessage: io_ts_1.string,
|
|
9
11
|
githubToken: io_ts_1.string,
|
|
10
|
-
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(
|
|
11
|
-
packageManager: (0, io_ts_1.union)([(0, io_ts_1.literal)(
|
|
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
|
+
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
|
+
pullRequestTitle: io_ts_1.string
|
|
12
15
|
}),
|
|
13
16
|
(0, io_ts_1.partial)({
|
|
14
17
|
gitUserEmail: io_ts_1.string,
|
|
@@ -26,7 +26,8 @@ const initOptions = () => {
|
|
|
26
26
|
package_manager_1.PackageManagerName.Npm,
|
|
27
27
|
package_manager_1.PackageManagerName.Yarn
|
|
28
28
|
])
|
|
29
|
-
.default(package_manager_1.PackageManagerName.Npm))
|
|
29
|
+
.default(package_manager_1.PackageManagerName.Npm))
|
|
30
|
+
.option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}');
|
|
30
31
|
commander_1.program.parse(process.argv);
|
|
31
32
|
const options = commander_1.program.opts();
|
|
32
33
|
if (!(0, Options_1.isOptions)(options)) {
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { GitRepository } from '../git'
|
|
|
2
2
|
import type { Logger } from '../logger'
|
|
3
3
|
import type { OutdatedPackage } from '../ncu'
|
|
4
4
|
import { createPullRequestBody } from './createPullRequestBody'
|
|
5
|
-
import { createPullRequestTitle } from './createPullRequestTitle'
|
|
6
5
|
import type { GitHub } from './GitHub'
|
|
6
|
+
import type { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
7
7
|
import type { Repository as GitHubRepository } from './Repository'
|
|
8
8
|
|
|
9
9
|
// TODO: add test
|
|
@@ -11,22 +11,26 @@ export class PullRequestCreator {
|
|
|
11
11
|
private readonly github: GitHub
|
|
12
12
|
private readonly gitRepo: GitRepository
|
|
13
13
|
private readonly githubRepo: GitHubRepository
|
|
14
|
+
private readonly pullRequestTitleCreator: PullRequestTitleCreator
|
|
14
15
|
private readonly logger: Logger
|
|
15
16
|
|
|
16
17
|
constructor ({
|
|
17
18
|
github,
|
|
18
19
|
gitRepo,
|
|
19
20
|
githubRepo,
|
|
21
|
+
pullRequestTitleCreator,
|
|
20
22
|
logger
|
|
21
23
|
}: {
|
|
22
24
|
github: GitHub
|
|
23
25
|
gitRepo: GitRepository
|
|
24
26
|
githubRepo: GitHubRepository
|
|
27
|
+
pullRequestTitleCreator: PullRequestTitleCreator
|
|
25
28
|
logger: Logger
|
|
26
29
|
}) {
|
|
27
30
|
this.github = github
|
|
28
31
|
this.gitRepo = gitRepo
|
|
29
32
|
this.githubRepo = githubRepo
|
|
33
|
+
this.pullRequestTitleCreator = pullRequestTitleCreator
|
|
30
34
|
this.logger = logger
|
|
31
35
|
}
|
|
32
36
|
|
|
@@ -37,7 +41,7 @@ export class PullRequestCreator {
|
|
|
37
41
|
outdatedPackage: OutdatedPackage
|
|
38
42
|
branchName: string
|
|
39
43
|
}): Promise<void> {
|
|
40
|
-
const title =
|
|
44
|
+
const title = this.pullRequestTitleCreator.create(outdatedPackage)
|
|
41
45
|
this.logger.debug(`title=${title}`)
|
|
42
46
|
|
|
43
47
|
const body = createPullRequestBody(outdatedPackage)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PackageVersion } from '../ncu'
|
|
2
|
+
import { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
3
|
+
|
|
4
|
+
describe('PullRequestTitleCreator', () => {
|
|
5
|
+
describe('create', () => {
|
|
6
|
+
it('returns commit message', () => {
|
|
7
|
+
const pullRequestTitleCreator = new PullRequestTitleCreator('chore(deps): {{updateType}} update {{{packageName}}} from {{currentVersion}} to v{{newVersion}}')
|
|
8
|
+
const actual = pullRequestTitleCreator.create({
|
|
9
|
+
name: '@typescript-eslint/eslint-plugin',
|
|
10
|
+
currentVersion: PackageVersion.of('1.0.0'),
|
|
11
|
+
newVersion: PackageVersion.of('2.0.0'),
|
|
12
|
+
type: 'major'
|
|
13
|
+
})
|
|
14
|
+
expect(actual).toBe('chore(deps): major update @typescript-eslint/eslint-plugin from 1.0.0 to v2.0.0')
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { render } from 'mustache'
|
|
2
|
+
import type { OutdatedPackage } from '../ncu'
|
|
3
|
+
|
|
4
|
+
export class PullRequestTitleCreator {
|
|
5
|
+
constructor (private readonly template: string) {}
|
|
6
|
+
|
|
7
|
+
create (outdatedPackage: OutdatedPackage): string {
|
|
8
|
+
const packageName = outdatedPackage.name
|
|
9
|
+
const currentVersion = outdatedPackage.currentVersion.version
|
|
10
|
+
const newVersion = outdatedPackage.newVersion.version
|
|
11
|
+
const updateType = outdatedPackage.type
|
|
12
|
+
return render(this.template, {
|
|
13
|
+
packageName,
|
|
14
|
+
currentVersion,
|
|
15
|
+
newVersion,
|
|
16
|
+
updateType
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/github/index.ts
CHANGED
|
@@ -3,5 +3,6 @@ export { createGitHub } from './createGitHub'
|
|
|
3
3
|
export { GitHub } from './GitHub'
|
|
4
4
|
export type { PullRequest } from './PullRequest'
|
|
5
5
|
export { PullRequestCreator } from './PullRequestCreator'
|
|
6
|
+
export { PullRequestTitleCreator } from './PullRequestTitleCreator'
|
|
6
7
|
export { RemoteBranchExistenceChecker } from './RemoteBranchExistenceChecker'
|
|
7
8
|
export type { Repository } from './Repository'
|
package/src/main.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
createGitHub,
|
|
9
9
|
PullRequestCreator,
|
|
10
|
+
PullRequestTitleCreator,
|
|
10
11
|
RemoteBranchExistenceChecker
|
|
11
12
|
} from './github'
|
|
12
13
|
import type { Logger } from './logger'
|
|
@@ -82,10 +83,12 @@ export const main = async ({
|
|
|
82
83
|
terminal,
|
|
83
84
|
packageManager: options.packageManager
|
|
84
85
|
})
|
|
86
|
+
const pullRequestTitleCreator = new PullRequestTitleCreator(options.pullRequestTitle)
|
|
85
87
|
const pullRequestCreator = new PullRequestCreator({
|
|
86
88
|
github,
|
|
87
89
|
gitRepo,
|
|
88
90
|
githubRepo,
|
|
91
|
+
pullRequestTitleCreator,
|
|
89
92
|
logger
|
|
90
93
|
})
|
|
91
94
|
const branchNameCreator = new BranchNameCreator(options.branchName)
|
package/src/options/Options.ts
CHANGED
|
@@ -7,14 +7,17 @@ import {
|
|
|
7
7
|
union
|
|
8
8
|
} from 'io-ts'
|
|
9
9
|
import type { TypeOf } from 'io-ts'
|
|
10
|
+
import { LogLevel } from '../logger'
|
|
11
|
+
import { PackageManagerName } from '../package-manager'
|
|
10
12
|
|
|
11
13
|
const Options = intersection([
|
|
12
14
|
type({
|
|
13
15
|
branchName: string,
|
|
14
16
|
commitMessage: string,
|
|
15
17
|
githubToken: string,
|
|
16
|
-
logLevel: union([literal(
|
|
17
|
-
packageManager: union([literal(
|
|
18
|
+
logLevel: union([literal(LogLevel.Info), literal(LogLevel.Debug)]),
|
|
19
|
+
packageManager: union([literal(PackageManagerName.Npm), literal(PackageManagerName.Yarn)]),
|
|
20
|
+
pullRequestTitle: string
|
|
18
21
|
}),
|
|
19
22
|
partial({
|
|
20
23
|
gitUserEmail: string,
|
|
@@ -33,6 +33,7 @@ export const initOptions = (): Options => {
|
|
|
33
33
|
])
|
|
34
34
|
.default(PackageManagerName.Npm)
|
|
35
35
|
)
|
|
36
|
+
.option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}')
|
|
36
37
|
program.parse(process.argv)
|
|
37
38
|
const options = program.opts()
|
|
38
39
|
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPullRequestTitle = void 0;
|
|
4
|
-
const createPullRequestTitle = (outdatedPackage) => {
|
|
5
|
-
const packageName = outdatedPackage.name;
|
|
6
|
-
const newVersion = outdatedPackage.newVersion.version;
|
|
7
|
-
const updateType = outdatedPackage.type;
|
|
8
|
-
return `chore(deps): ${updateType} update ${packageName} to v${newVersion}`;
|
|
9
|
-
};
|
|
10
|
-
exports.createPullRequestTitle = createPullRequestTitle;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { UpdateType, PackageVersion } from '../ncu'
|
|
2
|
-
import { createPullRequestTitle } from './createPullRequestTitle'
|
|
3
|
-
|
|
4
|
-
describe('createPullRequestTitle', () => {
|
|
5
|
-
const currentVersion = PackageVersion.of('1.0.0')
|
|
6
|
-
|
|
7
|
-
describe('if update type is patch', () => {
|
|
8
|
-
it('returns pull request title', () => {
|
|
9
|
-
const actual = createPullRequestTitle({
|
|
10
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
11
|
-
currentVersion,
|
|
12
|
-
newVersion: PackageVersion.of('1.0.1'),
|
|
13
|
-
type: UpdateType.Patch
|
|
14
|
-
})
|
|
15
|
-
expect(actual).toBe('chore(deps): patch update @typescript-eslint/eslint-plugin to v1.0.1')
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
describe('if update type is minor', () => {
|
|
20
|
-
it('returns pull request title', () => {
|
|
21
|
-
const actual = createPullRequestTitle({
|
|
22
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
23
|
-
currentVersion,
|
|
24
|
-
newVersion: PackageVersion.of('1.1.0'),
|
|
25
|
-
type: UpdateType.Minor
|
|
26
|
-
})
|
|
27
|
-
expect(actual).toBe('chore(deps): minor update @typescript-eslint/eslint-plugin to v1.1.0')
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
describe('if update type is major', () => {
|
|
32
|
-
it('returns pull request title', () => {
|
|
33
|
-
const actual = createPullRequestTitle({
|
|
34
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
35
|
-
currentVersion,
|
|
36
|
-
newVersion: PackageVersion.of('2.0.0'),
|
|
37
|
-
type: UpdateType.Major
|
|
38
|
-
})
|
|
39
|
-
expect(actual).toBe('chore(deps): major update @typescript-eslint/eslint-plugin to v2.0.0')
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
})
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OutdatedPackage } from '../ncu'
|
|
2
|
-
|
|
3
|
-
export const createPullRequestTitle = (outdatedPackage: OutdatedPackage): string => {
|
|
4
|
-
const packageName = outdatedPackage.name
|
|
5
|
-
const newVersion = outdatedPackage.newVersion.version
|
|
6
|
-
const updateType = outdatedPackage.type
|
|
7
|
-
return `chore(deps): ${updateType} update ${packageName} to v${newVersion}`
|
|
8
|
-
}
|