@aiot-toolkit/commander 2.0.6-beta.13 → 2.0.6-beta.15

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.
Files changed (2) hide show
  1. package/lib/Command.js +5 -9
  2. package/package.json +3 -3
package/lib/Command.js CHANGED
@@ -32,7 +32,6 @@ class Command {
32
32
  _commander.program.parse();
33
33
  }
34
34
  static registeCommand(command) {
35
- var _this = this;
36
35
  const {
37
36
  name,
38
37
  description,
@@ -44,7 +43,7 @@ class Command {
44
43
  const instance = name ? _commander.program.command(name).description(description) : _commander.program;
45
44
 
46
45
  // 设置argument
47
- argumentList?.forEach(item => {
46
+ argumentList === null || argumentList === void 0 || argumentList.forEach(item => {
48
47
  const {
49
48
  name,
50
49
  description,
@@ -54,7 +53,7 @@ class Command {
54
53
  });
55
54
 
56
55
  // 设置option
57
- paramList?.forEach(item => {
56
+ paramList === null || paramList === void 0 || paramList.forEach(item => {
58
57
  const {
59
58
  type,
60
59
  name,
@@ -66,10 +65,7 @@ class Command {
66
65
  });
67
66
 
68
67
  // 设置交互式问题
69
- instance.action(async function () {
70
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
71
- args[_key] = arguments[_key];
72
- }
68
+ instance.action(async (...args) => {
73
69
  let option = args[args.length - 2];
74
70
  if (paramList) {
75
71
  // 检查询问式参数
@@ -83,7 +79,7 @@ class Command {
83
79
  const haveSet = valueSource && valueSource !== 'default';
84
80
  // 如果启用询问,且未已显式设置值,则通过询问收集参数
85
81
  if (enableInquirer && !haveSet) {
86
- const result = await _this.collectParam(item);
82
+ const result = await this.collectParam(item);
87
83
  if (result) {
88
84
  for (let key in result) {
89
85
  option[key] = result[key];
@@ -139,7 +135,7 @@ class Command {
139
135
  } = param;
140
136
  result = await (0, _prompts.input)({
141
137
  message: description,
142
- default: defaultValue?.toString(),
138
+ default: defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString(),
143
139
  ...(validate ? {
144
140
  validate
145
141
  } : {})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/commander",
3
- "version": "2.0.6-beta.13",
3
+ "version": "2.0.6-beta.15",
4
4
  "description": "A tool that generates complete commands with configuration",
5
5
  "keywords": [
6
6
  "aiot",
@@ -20,10 +20,10 @@
20
20
  "test": "node ./__tests__/commander.test.js"
21
21
  },
22
22
  "dependencies": {
23
- "@aiot-toolkit/shared-utils": "2.0.6-beta.13",
23
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.15",
24
24
  "@inquirer/prompts": "^3.0.3",
25
25
  "chalk": "^4.0.0",
26
26
  "commander": "^11.0.0"
27
27
  },
28
- "gitHead": "a565cdee8e827a67b4043d9f872b7a6d933630db"
28
+ "gitHead": "8a927aec513af6d004f88e21d85bba0ef2dcac90"
29
29
  }