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

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