@aiot-toolkit/commander 2.0.3-beta.3 → 2.0.3-beta.5

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 CHANGED
@@ -111,12 +111,14 @@ ParamType 分为4类,继承自IParam
111
111
 
112
112
  参数基础结构
113
113
 
114
- | 属性 | 描述 | 类型 | 必填 |
115
- | -------------- | ------------------ | ------- | ----- |
116
- | name | 参数名称 | string | true |
117
- | description | 参数描述 | string | true |
118
- | defaultValue | 默认值 | any | false |
119
- | enableInquirer | 是否启用交互式询问 | boolean | false |
114
+ | 属性 | 描述 | 类型 | 必填 |
115
+ | ----------------- | ------------------------------------------- | ------- | ----- |
116
+ | name | 参数名称 | string | true |
117
+ | description | 参数描述 | string | true |
118
+ | defaultValue | 默认值 | any | false |
119
+ | enableInquirer | 是否启用交互式询问 | boolean | false |
120
+ | deprecated | 废弃的提示信息, 如果有值,表示此参数已废弃 | string | |
121
+ | deprecatedVersion | 废弃的版本号 | string | |
120
122
 
121
123
  #### 1. InputParam
122
124
 
package/lib/Command.js CHANGED
@@ -48,6 +48,7 @@ class Command {
48
48
  instance.action((...args) => __awaiter(this, void 0, void 0, function* () {
49
49
  let option = args[args.length - 2];
50
50
  if (paramList) {
51
+ // 检查询问式参数
51
52
  for (let item of paramList) {
52
53
  const { name, enableInquirer } = item;
53
54
  const cameName = shared_utils_1.StringUtil.hyphenedToCamel(name);
@@ -63,6 +64,17 @@ class Command {
63
64
  }
64
65
  }
65
66
  }
67
+ // 检查弃用的参数
68
+ const deprecatedList = paramList.filter((item) => item.deprecated);
69
+ deprecatedList.forEach((item) => {
70
+ const { name } = item;
71
+ const cameName = shared_utils_1.StringUtil.hyphenedToCamel(name);
72
+ if (option.hasOwnProperty(cameName)) {
73
+ shared_utils_1.ColorConsole.warn({ word: item.name }, 'is deprecated', ...(item.deprecatedVersion
74
+ ? [', will be removed in version:', { word: item.deprecatedVersion }]
75
+ : []), '.', { word: item.deprecated || '' });
76
+ }
77
+ });
66
78
  }
67
79
  yield action.apply(null, args);
68
80
  if (waiter) {
@@ -20,6 +20,14 @@ interface IParam {
20
20
  * 如果启用 且 未在命令中填写;则会进行询问
21
21
  */
22
22
  enableInquirer?: boolean;
23
+ /**
24
+ * 废弃信息, 如果有值,表示此参数已废弃
25
+ */
26
+ deprecated?: string;
27
+ /**
28
+ * 参数废弃的版本
29
+ */
30
+ deprecatedVersion?: string;
23
31
  }
24
32
  /**
25
33
  * 选项参数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/commander",
3
- "version": "2.0.3-beta.3",
3
+ "version": "2.0.3-beta.5",
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.3-beta.3",
23
+ "@aiot-toolkit/shared-utils": "2.0.3-beta.5",
24
24
  "@inquirer/prompts": "^3.0.3",
25
25
  "chalk": "^4.0.0",
26
26
  "commander": "^11.0.0"
27
27
  },
28
- "gitHead": "a4cad870b23d9e4142d22e59aa5618d7f123e1ab"
28
+ "gitHead": "d1772d1a3e1e3943deab519f2f1c03540cfd683b"
29
29
  }