npm-update-package 0.14.0 → 0.16.2
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 +19 -14
- package/dist/app.js +1 -1
- package/dist/git/index.js +3 -1
- package/dist/github/PullRequestCreator.js +3 -4
- package/dist/logger/LogLevel.js +2 -1
- package/dist/options/CLIOption.js +2 -0
- package/dist/options/OptionType.js +10 -0
- package/dist/options/Options.js +1 -1
- package/dist/options/cliOptions.js +73 -0
- package/dist/options/initOptions.js +6 -29
- package/dist/options/toCommanderOption.js +32 -0
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
CLI tool for creating pull request to update npm packages
|
|
7
7
|
|
|
8
|
-
## Caution
|
|
9
|
-
|
|
10
|
-
This package is currently under development, so the major version is 0 yet.
|
|
11
|
-
|
|
12
8
|
## Usage
|
|
13
9
|
|
|
14
10
|
```sh
|
|
@@ -53,7 +49,7 @@ Template strings such as `--branch-name` can embed variables like `{{packageName
|
|
|
53
49
|
|
|
54
50
|
Branch name template
|
|
55
51
|
|
|
56
|
-
-
|
|
52
|
+
- type: string
|
|
57
53
|
- variables:
|
|
58
54
|
- `currentVersion`
|
|
59
55
|
- `newVersion`
|
|
@@ -66,7 +62,7 @@ Branch name template
|
|
|
66
62
|
|
|
67
63
|
Commit message template
|
|
68
64
|
|
|
69
|
-
-
|
|
65
|
+
- type: string
|
|
70
66
|
- variables:
|
|
71
67
|
- `currentVersion`
|
|
72
68
|
- `newVersion`
|
|
@@ -79,17 +75,19 @@ Commit message template
|
|
|
79
75
|
|
|
80
76
|
GitHub token
|
|
81
77
|
|
|
82
|
-
-
|
|
78
|
+
- type: string
|
|
83
79
|
- required: true
|
|
84
80
|
|
|
85
81
|
### `--log-level`
|
|
86
82
|
|
|
87
83
|
Log level to show
|
|
88
84
|
|
|
89
|
-
-
|
|
90
|
-
|
|
91
|
-
- `
|
|
92
|
-
- `
|
|
85
|
+
- type: string
|
|
86
|
+
- allowed values:
|
|
87
|
+
- `off`: Do not output any logs.
|
|
88
|
+
- `error`: Output error logs.
|
|
89
|
+
- `info`: Output error/info logs.
|
|
90
|
+
- `debug`: Output error/info/debug logs.
|
|
93
91
|
- required: false
|
|
94
92
|
- default: `info`
|
|
95
93
|
|
|
@@ -97,7 +95,8 @@ Log level to show
|
|
|
97
95
|
|
|
98
96
|
Package manager of your project
|
|
99
97
|
|
|
100
|
-
-
|
|
98
|
+
- type: string
|
|
99
|
+
- allowed values:
|
|
101
100
|
- `npm`
|
|
102
101
|
- `yarn`
|
|
103
102
|
- required: false
|
|
@@ -107,7 +106,7 @@ Package manager of your project
|
|
|
107
106
|
|
|
108
107
|
Pull request body template
|
|
109
108
|
|
|
110
|
-
-
|
|
109
|
+
- type: string
|
|
111
110
|
- variables:
|
|
112
111
|
- `appName`
|
|
113
112
|
- `appVersion`
|
|
@@ -134,7 +133,7 @@ This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}
|
|
|
134
133
|
|
|
135
134
|
Pull request title template
|
|
136
135
|
|
|
137
|
-
-
|
|
136
|
+
- type: string
|
|
138
137
|
- variables:
|
|
139
138
|
- `currentVersion`
|
|
140
139
|
- `newVersion`
|
|
@@ -142,3 +141,9 @@ Pull request title template
|
|
|
142
141
|
- `updateType`
|
|
143
142
|
- required: false
|
|
144
143
|
- default: `chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}`
|
|
144
|
+
|
|
145
|
+
## FAQ
|
|
146
|
+
|
|
147
|
+
### Conflicts have occurred in PR. What should I do?
|
|
148
|
+
|
|
149
|
+
If conflicts have occurred in PR, close it and run npm-update-package again.
|
package/dist/app.js
CHANGED
package/dist/git/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Git = exports.CommitMessageCreator = exports.BranchNameCreator = void 0;
|
|
3
|
+
exports.GitRepository = exports.Git = exports.CommitMessageCreator = exports.BranchNameCreator = void 0;
|
|
4
4
|
var BranchNameCreator_1 = require("./BranchNameCreator");
|
|
5
5
|
Object.defineProperty(exports, "BranchNameCreator", { enumerable: true, get: function () { return BranchNameCreator_1.BranchNameCreator; } });
|
|
6
6
|
var CommitMessageCreator_1 = require("./CommitMessageCreator");
|
|
7
7
|
Object.defineProperty(exports, "CommitMessageCreator", { enumerable: true, get: function () { return CommitMessageCreator_1.CommitMessageCreator; } });
|
|
8
8
|
var Git_1 = require("./Git");
|
|
9
9
|
Object.defineProperty(exports, "Git", { enumerable: true, get: function () { return Git_1.Git; } });
|
|
10
|
+
var GitRepository_1 = require("./GitRepository");
|
|
11
|
+
Object.defineProperty(exports, "GitRepository", { enumerable: true, get: function () { return GitRepository_1.GitRepository; } });
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullRequestCreator = void 0;
|
|
4
|
-
// TODO: add test
|
|
5
4
|
class PullRequestCreator {
|
|
6
5
|
constructor({ github, gitRepo, githubRepo, pullRequestTitleCreator, pullRequestBodyCreator, logger }) {
|
|
7
6
|
this.github = github;
|
|
@@ -16,7 +15,7 @@ class PullRequestCreator {
|
|
|
16
15
|
this.logger.debug(`title=${title}`);
|
|
17
16
|
const body = this.pullRequestBodyCreator.create(outdatedPackage);
|
|
18
17
|
this.logger.debug(`body=${body}`);
|
|
19
|
-
const
|
|
18
|
+
const pullRequest = await this.github.createPullRequest({
|
|
20
19
|
owner: this.gitRepo.owner,
|
|
21
20
|
repo: this.gitRepo.name,
|
|
22
21
|
base: this.githubRepo.default_branch,
|
|
@@ -24,8 +23,8 @@ class PullRequestCreator {
|
|
|
24
23
|
title,
|
|
25
24
|
body
|
|
26
25
|
});
|
|
27
|
-
this.logger.debug(`
|
|
28
|
-
this.logger.info(`Pull request for ${outdatedPackage.name} has created. ${
|
|
26
|
+
this.logger.debug(`pullRequest=${JSON.stringify(pullRequest)}`);
|
|
27
|
+
this.logger.info(`Pull request for ${outdatedPackage.name} has created. ${pullRequest.html_url}`);
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
exports.PullRequestCreator = PullRequestCreator;
|
package/dist/logger/LogLevel.js
CHANGED
|
@@ -4,7 +4,8 @@ exports.isLogLevel = exports.LogLevel = void 0;
|
|
|
4
4
|
exports.LogLevel = {
|
|
5
5
|
Debug: 'debug',
|
|
6
6
|
Error: 'error',
|
|
7
|
-
Info: 'info'
|
|
7
|
+
Info: 'info',
|
|
8
|
+
Off: 'off'
|
|
8
9
|
};
|
|
9
10
|
const logLevels = Object.values(exports.LogLevel);
|
|
10
11
|
const isLogLevel = (value) => logLevels.includes(value);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOptionType = exports.OptionType = void 0;
|
|
4
|
+
exports.OptionType = {
|
|
5
|
+
String: 'string',
|
|
6
|
+
StringArray: 'string[]'
|
|
7
|
+
};
|
|
8
|
+
const optionTypes = Object.values(exports.OptionType);
|
|
9
|
+
const isOptionType = (value) => optionTypes.includes(value);
|
|
10
|
+
exports.isOptionType = isOptionType;
|
package/dist/options/Options.js
CHANGED
|
@@ -8,7 +8,7 @@ const Options = (0, io_ts_1.type)({
|
|
|
8
8
|
branchName: io_ts_1.string,
|
|
9
9
|
commitMessage: io_ts_1.string,
|
|
10
10
|
githubToken: io_ts_1.string,
|
|
11
|
-
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Error), (0, io_ts_1.literal)(logger_1.LogLevel.Info), (0, io_ts_1.literal)(logger_1.LogLevel.Debug)]),
|
|
11
|
+
logLevel: (0, io_ts_1.union)([(0, io_ts_1.literal)(logger_1.LogLevel.Off), (0, io_ts_1.literal)(logger_1.LogLevel.Error), (0, io_ts_1.literal)(logger_1.LogLevel.Info), (0, io_ts_1.literal)(logger_1.LogLevel.Debug)]),
|
|
12
12
|
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)]),
|
|
13
13
|
pullRequestBody: io_ts_1.string,
|
|
14
14
|
pullRequestTitle: io_ts_1.string
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cliOptions = void 0;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
|
+
const package_manager_1 = require("../package-manager");
|
|
6
|
+
const OptionType_1 = require("./OptionType");
|
|
7
|
+
exports.cliOptions = [
|
|
8
|
+
{
|
|
9
|
+
name: 'branch-name',
|
|
10
|
+
description: 'Branch name template',
|
|
11
|
+
type: OptionType_1.OptionType.String,
|
|
12
|
+
required: false,
|
|
13
|
+
default: 'npm-update-package/{{{packageName}}}/v{{newVersion}}'
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'commit-message',
|
|
17
|
+
description: 'Commit message template',
|
|
18
|
+
type: OptionType_1.OptionType.String,
|
|
19
|
+
required: false,
|
|
20
|
+
default: 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'github-token',
|
|
24
|
+
description: 'GitHub token',
|
|
25
|
+
type: OptionType_1.OptionType.String,
|
|
26
|
+
required: true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'log-level',
|
|
30
|
+
description: 'Log level to show',
|
|
31
|
+
type: OptionType_1.OptionType.String,
|
|
32
|
+
required: false,
|
|
33
|
+
choices: [
|
|
34
|
+
logger_1.LogLevel.Off,
|
|
35
|
+
logger_1.LogLevel.Error,
|
|
36
|
+
logger_1.LogLevel.Info,
|
|
37
|
+
logger_1.LogLevel.Debug
|
|
38
|
+
],
|
|
39
|
+
default: logger_1.LogLevel.Info
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'package-manager',
|
|
43
|
+
description: 'Package manager of your project',
|
|
44
|
+
type: OptionType_1.OptionType.String,
|
|
45
|
+
required: false,
|
|
46
|
+
choices: [
|
|
47
|
+
package_manager_1.PackageManagerName.Npm,
|
|
48
|
+
package_manager_1.PackageManagerName.Yarn
|
|
49
|
+
],
|
|
50
|
+
default: package_manager_1.PackageManagerName.Npm
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'pull-request-body',
|
|
54
|
+
description: 'Pull request body template',
|
|
55
|
+
type: OptionType_1.OptionType.String,
|
|
56
|
+
required: false,
|
|
57
|
+
default: `This PR updates these packages:
|
|
58
|
+
|
|
59
|
+
|package|type|current version|new version|
|
|
60
|
+
|---|---|---|---|
|
|
61
|
+
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'pull-request-title',
|
|
68
|
+
description: 'Pull request title template',
|
|
69
|
+
type: OptionType_1.OptionType.String,
|
|
70
|
+
required: false,
|
|
71
|
+
default: 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}'
|
|
72
|
+
}
|
|
73
|
+
];
|
|
@@ -3,38 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initOptions = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const app_1 = require("../app");
|
|
6
|
-
const
|
|
7
|
-
const package_manager_1 = require("../package-manager");
|
|
6
|
+
const cliOptions_1 = require("./cliOptions");
|
|
8
7
|
const Options_1 = require("./Options");
|
|
8
|
+
const toCommanderOption_1 = require("./toCommanderOption");
|
|
9
9
|
// TODO: add test
|
|
10
10
|
const initOptions = () => {
|
|
11
|
-
commander_1.program
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
.option
|
|
15
|
-
.requiredOption('--github-token <value>', 'GitHub token')
|
|
16
|
-
.addOption(new commander_1.Option('--log-level <value>', 'Log level to show')
|
|
17
|
-
.choices([
|
|
18
|
-
logger_1.LogLevel.Error,
|
|
19
|
-
logger_1.LogLevel.Info,
|
|
20
|
-
logger_1.LogLevel.Debug
|
|
21
|
-
])
|
|
22
|
-
.default(logger_1.LogLevel.Info))
|
|
23
|
-
.addOption(new commander_1.Option('--package-manager <value>', 'Package manager of your project')
|
|
24
|
-
.choices([
|
|
25
|
-
package_manager_1.PackageManagerName.Npm,
|
|
26
|
-
package_manager_1.PackageManagerName.Yarn
|
|
27
|
-
])
|
|
28
|
-
.default(package_manager_1.PackageManagerName.Npm))
|
|
29
|
-
.option('--pull-request-body <value>', 'Pull request body template', `This PR updates these packages:
|
|
30
|
-
|
|
31
|
-
|package|type|current version|new version|
|
|
32
|
-
|---|---|---|---|
|
|
33
|
-
|[{{{packageName}}}](https://www.npmjs.com/package/{{{packageName}}})|{{updateType}}|\`{{currentVersion}}\`|\`{{newVersion}}\`|
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`)
|
|
37
|
-
.option('--pull-request-title <value>', 'Pull request title template', 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}');
|
|
11
|
+
commander_1.program.version(app_1.app.version);
|
|
12
|
+
cliOptions_1.cliOptions
|
|
13
|
+
.map(toCommanderOption_1.toCommanderOption)
|
|
14
|
+
.forEach(option => commander_1.program.addOption(option));
|
|
38
15
|
commander_1.program.parse(process.argv);
|
|
39
16
|
const options = commander_1.program.opts();
|
|
40
17
|
if (!(0, Options_1.isOptions)(options)) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toCommanderOption = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const OptionType_1 = require("./OptionType");
|
|
6
|
+
// TODO: add test
|
|
7
|
+
const toCommanderOption = (cliOption) => {
|
|
8
|
+
const argument = createArgumentString(cliOption);
|
|
9
|
+
const option = new commander_1.Option(`--${cliOption.name} ${argument}`, cliOption.description);
|
|
10
|
+
if (cliOption.choices !== undefined) {
|
|
11
|
+
option.choices(cliOption.choices);
|
|
12
|
+
}
|
|
13
|
+
if (!cliOption.required && cliOption.default !== undefined) {
|
|
14
|
+
option.default(cliOption.default);
|
|
15
|
+
}
|
|
16
|
+
return option;
|
|
17
|
+
};
|
|
18
|
+
exports.toCommanderOption = toCommanderOption;
|
|
19
|
+
const createArgumentString = (cliOption) => {
|
|
20
|
+
const prefix = cliOption.required ? '<' : '[';
|
|
21
|
+
const suffix = cliOption.required ? '>' : ']';
|
|
22
|
+
const name = createArgumentNameString(cliOption.type);
|
|
23
|
+
return `${prefix}${name}${suffix}`;
|
|
24
|
+
};
|
|
25
|
+
const createArgumentNameString = (optionType) => {
|
|
26
|
+
switch (optionType) {
|
|
27
|
+
case OptionType_1.OptionType.String:
|
|
28
|
+
return 'value';
|
|
29
|
+
case OptionType_1.OptionType.StringArray:
|
|
30
|
+
return 'values...';
|
|
31
|
+
}
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "npm-update-package",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "CLI tool for creating pull request to update npm packages",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"io-ts": "2.2.16",
|
|
25
25
|
"log4js": "6.3.0",
|
|
26
26
|
"mustache": "4.1.0",
|
|
27
|
-
"npm-check-updates": "12.0.
|
|
27
|
+
"npm-check-updates": "12.0.5",
|
|
28
28
|
"parse-github-url": "1.0.2",
|
|
29
29
|
"semver": "7.3.5"
|
|
30
30
|
},
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"@types/node": "12.20.15",
|
|
37
37
|
"@types/parse-github-url": "1.0.0",
|
|
38
38
|
"@types/semver": "7.3.9",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
40
|
-
"eslint": "8.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "5.8.0",
|
|
40
|
+
"eslint": "8.5.0",
|
|
41
41
|
"eslint-config-standard-with-typescript": "21.0.1",
|
|
42
42
|
"eslint-plugin-import": "2.25.3",
|
|
43
43
|
"eslint-plugin-jest": "25.3.0",
|
|
44
44
|
"eslint-plugin-node": "11.1.0",
|
|
45
|
-
"eslint-plugin-promise": "
|
|
45
|
+
"eslint-plugin-promise": "6.0.0",
|
|
46
46
|
"eslint-plugin-tsdoc": "0.2.14",
|
|
47
47
|
"husky": "7.0.4",
|
|
48
48
|
"jest": "27.0.6",
|
|
49
|
-
"lint-staged": "12.1.
|
|
49
|
+
"lint-staged": "12.1.4",
|
|
50
50
|
"npm-run-all": "4.1.5",
|
|
51
51
|
"rimraf": "3.0.2",
|
|
52
|
-
"ts-jest": "27.1.
|
|
52
|
+
"ts-jest": "27.1.2",
|
|
53
53
|
"ts-node": "10.4.0",
|
|
54
|
-
"typescript": "4.5.
|
|
54
|
+
"typescript": "4.5.4",
|
|
55
55
|
"utility-types": "3.10.0"
|
|
56
56
|
},
|
|
57
57
|
"repository": {
|