npm-update-package 0.4.0 → 0.5.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/{FUNDING.yml → .github/FUNDING.yml} +0 -0
- package/README.md +6 -0
- package/dist/app.js +1 -1
- package/dist/commit-message-creator/CommitMessageCreator.js +22 -0
- package/dist/commit-message-creator/index.js +5 -0
- package/dist/main.js +4 -1
- package/dist/options/Options.js +1 -0
- package/dist/options/initOptions.js +1 -0
- package/dist/outdated-package-processor/OutdatedPackageProcessor.js +3 -3
- package/package.json +1 -1
- package/src/app.ts +1 -1
- package/src/commit-message-creator/CommitMessageCreator.test.ts +17 -0
- package/src/commit-message-creator/CommitMessageCreator.ts +19 -0
- package/src/commit-message-creator/index.ts +1 -0
- package/src/main.ts +4 -1
- package/src/options/Options.ts +1 -0
- package/src/options/initOptions.ts +1 -0
- package/src/outdated-package-processor/OutdatedPackageProcessor.ts +7 -3
- package/dist/outdated-package-processor/createCommitMessage.js +0 -10
- package/src/outdated-package-processor/createCommitMessage.test.ts +0 -43
- package/src/outdated-package-processor/createCommitMessage.ts +0 -8
|
File without changes
|
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ You can customize behavior via command-line options.
|
|
|
38
38
|
|Option|Description|Required|Value|Default|
|
|
39
39
|
|---|---|---|---|---|
|
|
40
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}}`|
|
|
41
42
|
|`--git-user-email`|User email of commit|-|string|-|
|
|
42
43
|
|`--git-user-name`|User name of commit|-|string|-|
|
|
43
44
|
|`--github-token`|GitHub token|✓|string|-|
|
|
@@ -54,3 +55,8 @@ These variables are available:
|
|
|
54
55
|
- `currentVersion`
|
|
55
56
|
- `newVersion`
|
|
56
57
|
- `updateType`
|
|
58
|
+
- `--commit-message`
|
|
59
|
+
- `packageName`
|
|
60
|
+
- `currentVersion`
|
|
61
|
+
- `newVersion`
|
|
62
|
+
- `updateType`
|
package/dist/app.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommitMessageCreator = void 0;
|
|
4
|
+
const mustache_1 = require("mustache");
|
|
5
|
+
class CommitMessageCreator {
|
|
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.CommitMessageCreator = CommitMessageCreator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommitMessageCreator = void 0;
|
|
4
|
+
var CommitMessageCreator_1 = require("./CommitMessageCreator");
|
|
5
|
+
Object.defineProperty(exports, "CommitMessageCreator", { enumerable: true, get: function () { return CommitMessageCreator_1.CommitMessageCreator; } });
|
package/dist/main.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.main = void 0;
|
|
4
4
|
const branch_name_creator_1 = require("./branch-name-creator");
|
|
5
|
+
const commit_message_creator_1 = require("./commit-message-creator");
|
|
5
6
|
const git_1 = require("./git");
|
|
6
7
|
const github_1 = require("./github");
|
|
7
8
|
const ncu_1 = require("./ncu");
|
|
@@ -57,6 +58,7 @@ const main = async ({ options, logger }) => {
|
|
|
57
58
|
logger
|
|
58
59
|
});
|
|
59
60
|
const branchNameCreator = new branch_name_creator_1.BranchNameCreator(options.branchName);
|
|
61
|
+
const commitMessageCreator = new commit_message_creator_1.CommitMessageCreator(options.commitMessage);
|
|
60
62
|
const outdatedPackageProcessor = new outdated_package_processor_1.OutdatedPackageProcessor({
|
|
61
63
|
committer,
|
|
62
64
|
git,
|
|
@@ -65,7 +67,8 @@ const main = async ({ options, logger }) => {
|
|
|
65
67
|
pullRequestCreator,
|
|
66
68
|
remoteBranchExistenceChecker,
|
|
67
69
|
logger,
|
|
68
|
-
branchNameCreator
|
|
70
|
+
branchNameCreator,
|
|
71
|
+
commitMessageCreator
|
|
69
72
|
});
|
|
70
73
|
const outdatedPackagesProcessor = new outdated_packages_processor_1.OutdatedPackagesProcessor({
|
|
71
74
|
outdatedPackageProcessor,
|
package/dist/options/Options.js
CHANGED
|
@@ -5,6 +5,7 @@ const io_ts_1 = require("io-ts");
|
|
|
5
5
|
exports.Options = (0, io_ts_1.intersection)([
|
|
6
6
|
(0, io_ts_1.type)({
|
|
7
7
|
branchName: io_ts_1.string,
|
|
8
|
+
commitMessage: io_ts_1.string,
|
|
8
9
|
githubToken: io_ts_1.string,
|
|
9
10
|
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)('info'), (0, io_ts_1.literal)('debug')]),
|
|
10
11
|
packageManager: (0, io_ts_1.union)([(0, io_ts_1.literal)('npm'), (0, io_ts_1.literal)('yarn')])
|
|
@@ -10,6 +10,7 @@ const initOptions = () => {
|
|
|
10
10
|
commander_1.program
|
|
11
11
|
.version(app_1.app.version)
|
|
12
12
|
.option('--branch-name <value>', 'Branch name template', 'npm-update-package/{{{packageName}}}/v{{newVersion}}')
|
|
13
|
+
.option('--commit-message <value>', 'Commit message template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}')
|
|
13
14
|
.option('--git-user-email <value>', 'User email of commit')
|
|
14
15
|
.option('--git-user-name <value>', 'User name of commit')
|
|
15
16
|
.requiredOption('--github-token <value>', 'GitHub token')
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OutdatedPackageProcessor = void 0;
|
|
4
|
-
const createCommitMessage_1 = require("./createCommitMessage");
|
|
5
4
|
// TODO: add test
|
|
6
5
|
class OutdatedPackageProcessor {
|
|
7
|
-
constructor({ committer, git, ncu, packageManager, pullRequestCreator, remoteBranchExistenceChecker, logger, branchNameCreator }) {
|
|
6
|
+
constructor({ committer, git, ncu, packageManager, pullRequestCreator, remoteBranchExistenceChecker, logger, branchNameCreator, commitMessageCreator }) {
|
|
8
7
|
this.committer = committer;
|
|
9
8
|
this.git = git;
|
|
10
9
|
this.ncu = ncu;
|
|
@@ -13,6 +12,7 @@ class OutdatedPackageProcessor {
|
|
|
13
12
|
this.remoteBranchExistenceChecker = remoteBranchExistenceChecker;
|
|
14
13
|
this.logger = logger;
|
|
15
14
|
this.branchNameCreator = branchNameCreator;
|
|
15
|
+
this.commitMessageCreator = commitMessageCreator;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Don't run in parallel because it includes file operations.
|
|
@@ -36,7 +36,7 @@ class OutdatedPackageProcessor {
|
|
|
36
36
|
await this.packageManager.install();
|
|
37
37
|
this.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`);
|
|
38
38
|
await this.git.add(...this.packageManager.packageFiles);
|
|
39
|
-
const message =
|
|
39
|
+
const message = this.commitMessageCreator.create(outdatedPackage);
|
|
40
40
|
this.logger.debug(`message=${message}`);
|
|
41
41
|
await this.committer.commit(message);
|
|
42
42
|
await this.git.push(branchName);
|
package/package.json
CHANGED
package/src/app.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PackageVersion } from '../values'
|
|
2
|
+
import { CommitMessageCreator } from './CommitMessageCreator'
|
|
3
|
+
|
|
4
|
+
describe('CommitMessageCreator', () => {
|
|
5
|
+
describe('create', () => {
|
|
6
|
+
it('returns commit message', () => {
|
|
7
|
+
const commitMessageCreator = new CommitMessageCreator('chore(deps): {{updateType}} update {{{packageName}}} from {{currentVersion}} to v{{newVersion}}')
|
|
8
|
+
const actual = commitMessageCreator.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 '../types'
|
|
3
|
+
|
|
4
|
+
export class CommitMessageCreator {
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CommitMessageCreator } from './CommitMessageCreator'
|
package/src/main.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BranchNameCreator } from './branch-name-creator'
|
|
2
|
+
import { CommitMessageCreator } from './commit-message-creator'
|
|
2
3
|
import {
|
|
3
4
|
Committer,
|
|
4
5
|
Git
|
|
@@ -77,6 +78,7 @@ export const main = async ({
|
|
|
77
78
|
logger
|
|
78
79
|
})
|
|
79
80
|
const branchNameCreator = new BranchNameCreator(options.branchName)
|
|
81
|
+
const commitMessageCreator = new CommitMessageCreator(options.commitMessage)
|
|
80
82
|
const outdatedPackageProcessor = new OutdatedPackageProcessor({
|
|
81
83
|
committer,
|
|
82
84
|
git,
|
|
@@ -85,7 +87,8 @@ export const main = async ({
|
|
|
85
87
|
pullRequestCreator,
|
|
86
88
|
remoteBranchExistenceChecker,
|
|
87
89
|
logger,
|
|
88
|
-
branchNameCreator
|
|
90
|
+
branchNameCreator,
|
|
91
|
+
commitMessageCreator
|
|
89
92
|
})
|
|
90
93
|
const outdatedPackagesProcessor = new OutdatedPackagesProcessor({
|
|
91
94
|
outdatedPackageProcessor,
|
package/src/options/Options.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { TypeOf } from 'io-ts'
|
|
|
11
11
|
export const Options = intersection([
|
|
12
12
|
type({
|
|
13
13
|
branchName: string,
|
|
14
|
+
commitMessage: string,
|
|
14
15
|
githubToken: string,
|
|
15
16
|
logLevel: union([literal('info'), literal('debug')]),
|
|
16
17
|
packageManager: union([literal('npm'), literal('yarn')])
|
|
@@ -15,6 +15,7 @@ export const initOptions = (): Options => {
|
|
|
15
15
|
program
|
|
16
16
|
.version(app.version)
|
|
17
17
|
.option('--branch-name <value>', 'Branch name template', 'npm-update-package/{{{packageName}}}/v{{newVersion}}')
|
|
18
|
+
.option('--commit-message <value>', 'Commit message template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}')
|
|
18
19
|
.option('--git-user-email <value>', 'User email of commit')
|
|
19
20
|
.option('--git-user-name <value>', 'User name of commit')
|
|
20
21
|
.requiredOption('--github-token <value>', 'GitHub token')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BranchNameCreator } from '../branch-name-creator'
|
|
2
|
+
import type { CommitMessageCreator } from '../commit-message-creator'
|
|
2
3
|
import type {
|
|
3
4
|
Committer,
|
|
4
5
|
Git
|
|
@@ -14,7 +15,6 @@ import type {
|
|
|
14
15
|
OutdatedPackage,
|
|
15
16
|
Result
|
|
16
17
|
} from '../types'
|
|
17
|
-
import { createCommitMessage } from './createCommitMessage'
|
|
18
18
|
|
|
19
19
|
// TODO: add test
|
|
20
20
|
export class OutdatedPackageProcessor {
|
|
@@ -26,6 +26,7 @@ export class OutdatedPackageProcessor {
|
|
|
26
26
|
private readonly remoteBranchExistenceChecker: RemoteBranchExistenceChecker
|
|
27
27
|
private readonly logger: Logger
|
|
28
28
|
private readonly branchNameCreator: BranchNameCreator
|
|
29
|
+
private readonly commitMessageCreator: CommitMessageCreator
|
|
29
30
|
|
|
30
31
|
constructor ({
|
|
31
32
|
committer,
|
|
@@ -35,7 +36,8 @@ export class OutdatedPackageProcessor {
|
|
|
35
36
|
pullRequestCreator,
|
|
36
37
|
remoteBranchExistenceChecker,
|
|
37
38
|
logger,
|
|
38
|
-
branchNameCreator
|
|
39
|
+
branchNameCreator,
|
|
40
|
+
commitMessageCreator
|
|
39
41
|
}: {
|
|
40
42
|
committer: Committer
|
|
41
43
|
git: Git
|
|
@@ -45,6 +47,7 @@ export class OutdatedPackageProcessor {
|
|
|
45
47
|
remoteBranchExistenceChecker: RemoteBranchExistenceChecker
|
|
46
48
|
logger: Logger
|
|
47
49
|
branchNameCreator: BranchNameCreator
|
|
50
|
+
commitMessageCreator: CommitMessageCreator
|
|
48
51
|
}) {
|
|
49
52
|
this.committer = committer
|
|
50
53
|
this.git = git
|
|
@@ -54,6 +57,7 @@ export class OutdatedPackageProcessor {
|
|
|
54
57
|
this.remoteBranchExistenceChecker = remoteBranchExistenceChecker
|
|
55
58
|
this.logger = logger
|
|
56
59
|
this.branchNameCreator = branchNameCreator
|
|
60
|
+
this.commitMessageCreator = commitMessageCreator
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
/**
|
|
@@ -84,7 +88,7 @@ export class OutdatedPackageProcessor {
|
|
|
84
88
|
this.logger.info(`${outdatedPackage.name} has updated from v${outdatedPackage.currentVersion.version} to v${outdatedPackage.newVersion.version}`)
|
|
85
89
|
|
|
86
90
|
await this.git.add(...this.packageManager.packageFiles)
|
|
87
|
-
const message =
|
|
91
|
+
const message = this.commitMessageCreator.create(outdatedPackage)
|
|
88
92
|
this.logger.debug(`message=${message}`)
|
|
89
93
|
|
|
90
94
|
await this.committer.commit(message)
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCommitMessage = void 0;
|
|
4
|
-
const createCommitMessage = (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.createCommitMessage = createCommitMessage;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { UpdateType } from '../enums'
|
|
2
|
-
import { PackageVersion } from '../values'
|
|
3
|
-
import { createCommitMessage } from './createCommitMessage'
|
|
4
|
-
|
|
5
|
-
describe('createCommitMessage', () => {
|
|
6
|
-
const currentVersion = PackageVersion.of('1.0.0')
|
|
7
|
-
|
|
8
|
-
describe('if update type is patch', () => {
|
|
9
|
-
it('returns commit message', () => {
|
|
10
|
-
const actual = createCommitMessage({
|
|
11
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
12
|
-
currentVersion,
|
|
13
|
-
newVersion: PackageVersion.of('1.0.1'),
|
|
14
|
-
type: UpdateType.Patch
|
|
15
|
-
})
|
|
16
|
-
expect(actual).toBe('chore(deps): patch update @typescript-eslint/eslint-plugin to v1.0.1')
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe('if update type is minor', () => {
|
|
21
|
-
it('returns commit message', () => {
|
|
22
|
-
const actual = createCommitMessage({
|
|
23
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
24
|
-
currentVersion,
|
|
25
|
-
newVersion: PackageVersion.of('1.1.0'),
|
|
26
|
-
type: UpdateType.Minor
|
|
27
|
-
})
|
|
28
|
-
expect(actual).toBe('chore(deps): minor update @typescript-eslint/eslint-plugin to v1.1.0')
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
describe('if update type is major', () => {
|
|
33
|
-
it('returns commit message', () => {
|
|
34
|
-
const actual = createCommitMessage({
|
|
35
|
-
name: '@typescript-eslint/eslint-plugin',
|
|
36
|
-
currentVersion,
|
|
37
|
-
newVersion: PackageVersion.of('2.0.0'),
|
|
38
|
-
type: UpdateType.Major
|
|
39
|
-
})
|
|
40
|
-
expect(actual).toBe('chore(deps): major update @typescript-eslint/eslint-plugin to v2.0.0')
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OutdatedPackage } from '../types'
|
|
2
|
-
|
|
3
|
-
export const createCommitMessage = (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
|
-
}
|