npm-update-package 0.16.1 → 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/dist/app.js
CHANGED
|
@@ -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;
|
|
@@ -3,27 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.cliOptions = void 0;
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
const package_manager_1 = require("../package-manager");
|
|
6
|
+
const OptionType_1 = require("./OptionType");
|
|
6
7
|
exports.cliOptions = [
|
|
7
8
|
{
|
|
8
9
|
name: 'branch-name',
|
|
9
10
|
description: 'Branch name template',
|
|
11
|
+
type: OptionType_1.OptionType.String,
|
|
10
12
|
required: false,
|
|
11
13
|
default: 'npm-update-package/{{{packageName}}}/v{{newVersion}}'
|
|
12
14
|
},
|
|
13
15
|
{
|
|
14
16
|
name: 'commit-message',
|
|
15
17
|
description: 'Commit message template',
|
|
18
|
+
type: OptionType_1.OptionType.String,
|
|
16
19
|
required: false,
|
|
17
20
|
default: 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}'
|
|
18
21
|
},
|
|
19
22
|
{
|
|
20
23
|
name: 'github-token',
|
|
21
24
|
description: 'GitHub token',
|
|
25
|
+
type: OptionType_1.OptionType.String,
|
|
22
26
|
required: true
|
|
23
27
|
},
|
|
24
28
|
{
|
|
25
29
|
name: 'log-level',
|
|
26
30
|
description: 'Log level to show',
|
|
31
|
+
type: OptionType_1.OptionType.String,
|
|
27
32
|
required: false,
|
|
28
33
|
choices: [
|
|
29
34
|
logger_1.LogLevel.Off,
|
|
@@ -36,6 +41,7 @@ exports.cliOptions = [
|
|
|
36
41
|
{
|
|
37
42
|
name: 'package-manager',
|
|
38
43
|
description: 'Package manager of your project',
|
|
44
|
+
type: OptionType_1.OptionType.String,
|
|
39
45
|
required: false,
|
|
40
46
|
choices: [
|
|
41
47
|
package_manager_1.PackageManagerName.Npm,
|
|
@@ -46,6 +52,7 @@ exports.cliOptions = [
|
|
|
46
52
|
{
|
|
47
53
|
name: 'pull-request-body',
|
|
48
54
|
description: 'Pull request body template',
|
|
55
|
+
type: OptionType_1.OptionType.String,
|
|
49
56
|
required: false,
|
|
50
57
|
default: `This PR updates these packages:
|
|
51
58
|
|
|
@@ -59,6 +66,7 @@ This PR has been generated by [{{{appName}}}]({{{appWeb}}}) v{{appVersion}}`
|
|
|
59
66
|
{
|
|
60
67
|
name: 'pull-request-title',
|
|
61
68
|
description: 'Pull request title template',
|
|
69
|
+
type: OptionType_1.OptionType.String,
|
|
62
70
|
required: false,
|
|
63
71
|
default: 'chore(deps): {{updateType}} update {{{packageName}}} to v{{newVersion}}'
|
|
64
72
|
}
|
|
@@ -2,16 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toCommanderOption = void 0;
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
|
+
const OptionType_1 = require("./OptionType");
|
|
5
6
|
// TODO: add test
|
|
6
7
|
const toCommanderOption = (cliOption) => {
|
|
7
|
-
const
|
|
8
|
-
option.
|
|
8
|
+
const argument = createArgumentString(cliOption);
|
|
9
|
+
const option = new commander_1.Option(`--${cliOption.name} ${argument}`, cliOption.description);
|
|
9
10
|
if (cliOption.choices !== undefined) {
|
|
10
11
|
option.choices(cliOption.choices);
|
|
11
12
|
}
|
|
12
|
-
if (!cliOption.required) {
|
|
13
|
+
if (!cliOption.required && cliOption.default !== undefined) {
|
|
13
14
|
option.default(cliOption.default);
|
|
14
15
|
}
|
|
15
16
|
return option;
|
|
16
17
|
};
|
|
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
|
+
};
|