cloudcc-cli 2.3.3 → 2.3.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/.claude/settings.json +28 -1
- package/.cursor/skills/cloudcc-cli-dev/SKILL.md +175 -0
- package/.cursor/skills/cloudcc-dev-skill/SKILL.md +71 -0
- package/README.md +65 -7
- package/bin/cc.js +106 -28
- package/bin/index.js +54 -53
- package/mcp/cliRunner.js +11 -4
- package/mcp/index.js +12 -2
- package/mcp/tools/CloudCC Development Overview/handler.js +1 -1
- package/mcp/tools/JSP Migrator/handler.js +46 -0
- package/package.json +4 -5
- package/src/button/create.js +169 -0
- package/src/button/delete.js +35 -0
- package/src/button/doc.js +36 -0
- package/src/button/docs/devguide.md +133 -0
- package/src/button/docs/introduction.md +60 -0
- package/src/button/get.js +60 -0
- package/src/button/index.js +20 -0
- package/src/classes/docs/introduction.md +0 -20
- package/src/fields/create.js +12 -0
- package/src/identityProvider/create.js +78 -0
- package/src/identityProvider/delete.js +61 -0
- package/src/identityProvider/doc.js +46 -0
- package/src/identityProvider/docs/devguide.md +107 -0
- package/src/identityProvider/docs/introduction.md +31 -0
- package/src/identityProvider/download.js +105 -0
- package/src/identityProvider/get.js +70 -0
- package/src/identityProvider/index.js +12 -0
- package/src/menu/create-object.js +1 -0
- package/src/menu/create-page.js +1 -0
- package/src/menu/create-script.js +1 -0
- package/src/menu/create-site.js +1 -0
- package/src/object/create.js +2 -1
- package/src/object/docs/devguide.md +1 -5
- package/src/permission/add.js +164 -0
- package/src/permission/assign.js +84 -0
- package/src/permission/docs/devguide.md +238 -0
- package/src/permission/docs/introduction.md +200 -0
- package/src/permission/get.js +107 -0
- package/src/permission/index.js +10 -0
- package/src/permission/remove.js +145 -0
- package/src/project/docs/devguide.md +7 -6
- package/src/role/create.js +2 -1
- package/src/role/delete.js +1 -0
- package/src/singleSignOn/delete.js +61 -0
- package/src/singleSignOn/doc.js +46 -0
- package/src/singleSignOn/docs/devguide.md +61 -0
- package/src/singleSignOn/docs/introduction.md +3 -0
- package/src/singleSignOn/get.js +70 -0
- package/src/singleSignOn/index.js +10 -0
- package/src/staticResource/docs/introduction.md +44 -1
- package/src/user/create.js +502 -19
- package/src/validationRule/create.js +153 -0
- package/src/validationRule/delete.js +60 -0
- package/src/validationRule/doc.js +46 -0
- package/src/validationRule/docs/devguide.md +76 -0
- package/src/validationRule/docs/introduction.md +122 -0
- package/src/validationRule/get.js +47 -0
- package/src/validationRule/index.js +10 -0
- package/src/version/actionHelp.js +25 -0
- package/src/version/docs.js +26 -0
- package/src/version/doctor.js +25 -0
- package/src/version/get.js +7 -1
- package/src/version/help.js +47 -0
- package/src/version/index.js +9 -2
- package/src/version/initHelp.js +13 -0
- package/src/version/listModuleCommands.js +241 -0
- package/src/version/stats.js +44 -0
- package/src/version/uninstall.js +30 -0
- package/src/version/update.js +13 -0
- package/utils/checkVersion.js +31 -2
- package/utils/commandStats.js +94 -0
- package/utils/formatReleaseNotes.js +312 -0
- package/utils/readmeReleases.js +69 -0
- package/.cloudcc-cache.json +0 -38
- package/.cursor/skills/cloudcc-cli-dev.zip +0 -0
- package/.cursor/skills/cloudcc-cli-usage/SKILL.md +0 -68
- package/build/component-CCPlugin1774500425584.common.js +0 -831
- package/build/component-CCPlugin1774500425584.common.js.map +0 -1
- package/build/component-CCPlugin1774500425584.css +0 -1
- package/build/component-CCPlugin1774500425584.umd.js +0 -874
- package/build/component-CCPlugin1774500425584.umd.js.map +0 -1
- package/build/component-CCPlugin1774500425584.umd.min.js +0 -8
- package/build/component-CCPlugin1774500425584.umd.min.js.map +0 -1
- package/build/demo.html +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
const { getPackageJson } = require("../../utils/config");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 删除验证规则
|
|
7
|
+
* 用法:cc delete validationRule <projectPath> <ruleId>
|
|
8
|
+
*/
|
|
9
|
+
async function remove(argvs) {
|
|
10
|
+
try {
|
|
11
|
+
const projectPath = argvs[2] || process.cwd();
|
|
12
|
+
const ruleId = argvs[3];
|
|
13
|
+
|
|
14
|
+
if (!ruleId) {
|
|
15
|
+
console.error();
|
|
16
|
+
console.error(chalk.red("Error: 缺少规则 ID"));
|
|
17
|
+
console.error(chalk.yellow("用法: cc delete validationRule <projectPath> <ruleId>"));
|
|
18
|
+
console.error();
|
|
19
|
+
throw new Error("缺少必需参数: ruleId");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const config = await getPackageJson(projectPath);
|
|
23
|
+
if (!config || !config.accessToken) {
|
|
24
|
+
console.error();
|
|
25
|
+
console.error(chalk.red("Error: 配置未找到或 accessToken 缺失"));
|
|
26
|
+
console.error();
|
|
27
|
+
throw new Error("配置未找到或 accessToken 缺失");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.error();
|
|
31
|
+
console.error(chalk.green(`Deleting validation rule (${ruleId}), please wait...`));
|
|
32
|
+
console.error();
|
|
33
|
+
|
|
34
|
+
const result = await postClass(
|
|
35
|
+
config.setupSvc + "/api/validateRule/delete",
|
|
36
|
+
{ id: ruleId },
|
|
37
|
+
config.accessToken
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (result && result.result) {
|
|
41
|
+
console.error();
|
|
42
|
+
console.error(chalk.green("Success! Validation rule deleted."));
|
|
43
|
+
console.error(chalk.blue("返回结果:"), JSON.stringify(result, null, 2));
|
|
44
|
+
console.error();
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const msg = result && (result.returnInfo || result.message) ? (result.returnInfo || result.message) : "Unknown error";
|
|
49
|
+
console.error();
|
|
50
|
+
console.error(chalk.red("Error: " + msg));
|
|
51
|
+
console.error();
|
|
52
|
+
throw new Error("Delete ValidationRule Failed: " + msg);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error();
|
|
55
|
+
console.error(chalk.red("验证规则删除失败:"), error);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = remove;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* validationRule 文档入口:正文均在 `docs/` 目录。
|
|
3
|
+
*/
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const DOCS_DIR = path.join(__dirname, "docs");
|
|
8
|
+
|
|
9
|
+
function readDocFile(basename) {
|
|
10
|
+
return fs.readFileSync(path.join(DOCS_DIR, `${basename}.md`), "utf8");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** 介绍文档:验证规则能力 */
|
|
14
|
+
function getIntroductionDoc() {
|
|
15
|
+
return readDocFile("introduction");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 开发指导:CLI 创建/查询/删除等 */
|
|
19
|
+
function getDevGuideDoc() {
|
|
20
|
+
return readDocFile("devguide");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* cc doc validationRule <introduction|devguide>
|
|
25
|
+
* @param {string[]} argvs [doc, type, introduction|devguide, ...]
|
|
26
|
+
*/
|
|
27
|
+
function doc(argvs) {
|
|
28
|
+
const subType = argvs[2];
|
|
29
|
+
const key = String(subType || "").trim().toLowerCase();
|
|
30
|
+
if (!key) {
|
|
31
|
+
throw new Error("cc doc validationRule 需要子命令:introduction 或 devguide");
|
|
32
|
+
}
|
|
33
|
+
if (key === "introduction") {
|
|
34
|
+
const content = getIntroductionDoc();
|
|
35
|
+
console.log(content);
|
|
36
|
+
return content;
|
|
37
|
+
}
|
|
38
|
+
if (key === "devguide") {
|
|
39
|
+
const content = getDevGuideDoc();
|
|
40
|
+
console.log(content);
|
|
41
|
+
return content;
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`doc 不支持的子命令: ${subType},请使用 introduction 或 devguide`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = doc;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# CloudCC 验证规则 CLI 命令说明
|
|
2
|
+
|
|
3
|
+
## 支持的命令
|
|
4
|
+
|
|
5
|
+
| 操作 | 说明 |
|
|
6
|
+
|------|------|
|
|
7
|
+
| `create` | 创建新验证规则 |
|
|
8
|
+
| `get` | 查询验证规则列表 |
|
|
9
|
+
| `delete` | 删除验证规则 |
|
|
10
|
+
|
|
11
|
+
## CLI 命令详解
|
|
12
|
+
|
|
13
|
+
### 创建验证规则
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cc create validationRule <path> <objectPrefix> [ruleName] [ruleContent] [errorMessage]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**参数说明:**
|
|
20
|
+
|
|
21
|
+
| 参数 | 必填 | 说明 |
|
|
22
|
+
|------|------|------|
|
|
23
|
+
| `path` | 是 | 项目路径,`.` 表示当前目录 |
|
|
24
|
+
| `objectPrefix` | 是 | 对象前缀,如 `b00` |
|
|
25
|
+
| `ruleName` | 否 | 规则名称(不传则交互式输入) |
|
|
26
|
+
| `ruleContent` | 否 | 规则内容,如 `Batch_Size__c__f==5`(不传则交互式输入) |
|
|
27
|
+
| `errorMessage` | 否 | 错误提示信息(不传则交互式输入) |
|
|
28
|
+
|
|
29
|
+
**示例:**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 交互式输入所有信息
|
|
33
|
+
cc create validationRule . "b00"
|
|
34
|
+
|
|
35
|
+
# 非交互式创建
|
|
36
|
+
cc create validationRule . "b00" "规则1" "Batch_Size__c__f==5" "数量必须是5"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 查询验证规则列表
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cc get validationRule <projectPath> <objectPrefix>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**参数说明:**
|
|
46
|
+
|
|
47
|
+
| 参数 | 必填 | 说明 |
|
|
48
|
+
|------|------|------|
|
|
49
|
+
| `projectPath` | 否 | 项目路径,默认当前目录 |
|
|
50
|
+
| `objectPrefix` | 是 | 对象前缀,如 `b00` |
|
|
51
|
+
|
|
52
|
+
**示例:**
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 获取对象 b00 的所有验证规则
|
|
56
|
+
cc get validationRule . "b00"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 删除验证规则
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cc delete validationRule <projectPath> <ruleId>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**参数说明:**
|
|
66
|
+
|
|
67
|
+
| 参数 | 必填 | 说明 |
|
|
68
|
+
|------|------|------|
|
|
69
|
+
| `projectPath` | 否 | 项目路径,默认当前目录 |
|
|
70
|
+
| `ruleId` | 是 | 规则 ID |
|
|
71
|
+
|
|
72
|
+
**示例:**
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cc delete validationRule . 202689E55795D38oAQlN
|
|
76
|
+
```
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# CloudCC 验证规则使用总结
|
|
2
|
+
|
|
3
|
+
验证规则(Validation Rule)用于在数据保存前进行校验,确保数据的完整性和正确性。当数据不符合规则时,系统会显示错误信息阻止保存。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 快速开始(CLI 命令)
|
|
8
|
+
|
|
9
|
+
### 支持的验证规则操作
|
|
10
|
+
|
|
11
|
+
| 操作 | 说明 |
|
|
12
|
+
|------|------|
|
|
13
|
+
| `create` | 创建新验证规则 |
|
|
14
|
+
| `get` | 查询验证规则列表 |
|
|
15
|
+
| `delete` | 删除验证规则 |
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## CLI 命令详解
|
|
20
|
+
|
|
21
|
+
### 创建验证规则
|
|
22
|
+
|
|
23
|
+
创建一个新的 CloudCC 验证规则。
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
cc create validationRule <path> <objectPrefix> [ruleName] [ruleContent] [errorMessage]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**参数说明:**
|
|
30
|
+
|
|
31
|
+
| 参数 | 必填 | 说明 |
|
|
32
|
+
|------|------|------|
|
|
33
|
+
| `path` | 是 | 项目路径,`.` 表示当前目录 |
|
|
34
|
+
| `objectPrefix` | 是 | 对象前缀,如 `b00` |
|
|
35
|
+
| `ruleName` | 否 | 规则名称(不传则交互式输入) |
|
|
36
|
+
| `ruleContent` | 否 | 规则内容,如 `Batch_Size__c__f==5`(不传则交互式输入) |
|
|
37
|
+
| `errorMessage` | 否 | 错误提示信息(不传则交互式输入) |
|
|
38
|
+
|
|
39
|
+
**示例:**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 交互式输入所有信息
|
|
43
|
+
cc create validationRule . "b00"
|
|
44
|
+
|
|
45
|
+
# 非交互式创建
|
|
46
|
+
cc create validationRule . "b00" "规则1" "Batch_Size__c__f==5" "数量必须是5"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### 查询验证规则列表
|
|
52
|
+
|
|
53
|
+
获取指定对象的所有验证规则列表。
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
cc get validationRule <projectPath> <objectPrefix>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**参数说明:**
|
|
60
|
+
|
|
61
|
+
| 参数 | 必填 | 说明 |
|
|
62
|
+
|------|------|------|
|
|
63
|
+
| `projectPath` | 否 | 项目路径,默认当前目录 |
|
|
64
|
+
| `objectPrefix` | 是 | 对象前缀,如 `b00` |
|
|
65
|
+
|
|
66
|
+
**示例:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# 获取对象 b00 的所有验证规则
|
|
70
|
+
cc get validationRule . "b00"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### 删除验证规则
|
|
76
|
+
|
|
77
|
+
删除指定的验证规则。
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
cc delete validationRule <projectPath> <ruleId>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**参数说明:**
|
|
84
|
+
|
|
85
|
+
| 参数 | 必填 | 说明 |
|
|
86
|
+
|------|------|------|
|
|
87
|
+
| `projectPath` | 否 | 项目路径,默认当前目录 |
|
|
88
|
+
| `ruleId` | 是 | 规则 ID |
|
|
89
|
+
|
|
90
|
+
**示例:**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# 删除指定规则
|
|
94
|
+
cc delete validationRule . 202689E55795D38oAQlN
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 完整工作流示例
|
|
100
|
+
|
|
101
|
+
### 场景:为订单对象创建验证规则
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# 1. 确认项目已初始化(有 cloudcc-cli.config.js)
|
|
105
|
+
cat cloudcc-cli.config.js
|
|
106
|
+
|
|
107
|
+
# 2. 查询对象现有的验证规则
|
|
108
|
+
cc get validationRule . "b00"
|
|
109
|
+
|
|
110
|
+
# 3. 创建新验证规则
|
|
111
|
+
cc create validationRule . "b00"
|
|
112
|
+
|
|
113
|
+
# 4. 验证规则创建成功
|
|
114
|
+
cc get validationRule . "b00"
|
|
115
|
+
|
|
116
|
+
# 5. 如需删除
|
|
117
|
+
# cc delete validationRule . <ruleId>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
*文档版本:1.0 | 最后更新:2026-03-27*
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { postClass } = require("../../utils/http");
|
|
2
|
+
const { getPackageJson } = require("../../utils/config");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 查询验证规则列表
|
|
6
|
+
* 用法:cc get validationRule <projectPath> <objectPrefix>
|
|
7
|
+
* 接口:POST /api/validateRule/queryByPrefix
|
|
8
|
+
* 参数:{ prefix: "b00" }
|
|
9
|
+
*/
|
|
10
|
+
async function get(argvs, isMcp = false) {
|
|
11
|
+
const projectPath = argvs[2] || process.cwd();
|
|
12
|
+
const objectPrefix = argvs[3];
|
|
13
|
+
|
|
14
|
+
if (!objectPrefix) {
|
|
15
|
+
const msg = "缺少对象前缀参数";
|
|
16
|
+
if (!isMcp) {
|
|
17
|
+
console.error(msg);
|
|
18
|
+
}
|
|
19
|
+
throw new Error("Get ValidationRule Failed: " + msg);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const body = { prefix: objectPrefix };
|
|
23
|
+
|
|
24
|
+
const config = await getPackageJson(projectPath);
|
|
25
|
+
const res = await postClass(
|
|
26
|
+
config.setupSvc + "/api/validateRule/queryByPrefix",
|
|
27
|
+
body,
|
|
28
|
+
config.accessToken
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (res && res.result) {
|
|
32
|
+
const data = res.data;
|
|
33
|
+
let rawList = [];
|
|
34
|
+
if (data && Array.isArray(data.list)) {
|
|
35
|
+
rawList = data.list;
|
|
36
|
+
}
|
|
37
|
+
if (!isMcp) {
|
|
38
|
+
console.log(JSON.stringify(rawList));
|
|
39
|
+
}
|
|
40
|
+
return rawList;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const msg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
|
|
44
|
+
throw new Error("Get ValidationRule Failed: " + msg);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = get;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const chalk = require("chalk")
|
|
2
|
+
const { getResourcesForAction } = require("./listModuleCommands")
|
|
3
|
+
|
|
4
|
+
function actionHelp(argvs) {
|
|
5
|
+
const action = argvs[0]
|
|
6
|
+
const list = getResourcesForAction(action)
|
|
7
|
+
console.error()
|
|
8
|
+
if (list.length === 0) {
|
|
9
|
+
console.error(chalk.yellow(`没有 resource 支持 action「${action}」。`))
|
|
10
|
+
console.error(chalk.gray("运行 ") + chalk.green("cc --help") + chalk.gray(" 查看全部命令。"))
|
|
11
|
+
console.error()
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
console.error(chalk.bold.cyan(`cc ${action}`) + chalk.gray(" <resource> [args...]"))
|
|
15
|
+
console.error()
|
|
16
|
+
console.error(chalk.yellow("可用的 resource:"))
|
|
17
|
+
for (const r of list) {
|
|
18
|
+
console.error(" " + chalk.green(r))
|
|
19
|
+
}
|
|
20
|
+
console.error()
|
|
21
|
+
console.error(chalk.gray("示例:") + chalk.green(`cc ${action} ${list[0]}`) + chalk.gray(" <后续参数见各模块文档>"))
|
|
22
|
+
console.error()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = actionHelp
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { spawn } = require("child_process")
|
|
2
|
+
const chalk = require("chalk")
|
|
3
|
+
|
|
4
|
+
const HELP_CENTER = "https://help.cloudcc.cn/"
|
|
5
|
+
|
|
6
|
+
function docs() {
|
|
7
|
+
const url = HELP_CENTER
|
|
8
|
+
try {
|
|
9
|
+
if (process.platform === "win32") {
|
|
10
|
+
spawn("cmd", ["/c", "start", "", url], { detached: true, stdio: "ignore" }).unref()
|
|
11
|
+
} else if (process.platform === "darwin") {
|
|
12
|
+
spawn("open", [url], { detached: true, stdio: "ignore" }).unref()
|
|
13
|
+
} else {
|
|
14
|
+
spawn("xdg-open", [url], { detached: true, stdio: "ignore" }).unref()
|
|
15
|
+
}
|
|
16
|
+
console.error()
|
|
17
|
+
console.error(chalk.green("已在浏览器打开:") + chalk.cyan(url))
|
|
18
|
+
console.error()
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error()
|
|
21
|
+
console.error(chalk.yellow("无法自动打开浏览器,请手动访问:"), chalk.cyan(url))
|
|
22
|
+
console.error()
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = docs
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const fs = require("fs")
|
|
2
|
+
const path = require("path")
|
|
3
|
+
const chalk = require("chalk")
|
|
4
|
+
const pkg = require("../../package.json")
|
|
5
|
+
|
|
6
|
+
function doctor() {
|
|
7
|
+
console.error()
|
|
8
|
+
console.error(chalk.bold.cyan("cc doctor") + chalk.gray(" — 环境自检"))
|
|
9
|
+
console.error()
|
|
10
|
+
console.error(chalk.green("✓") + " Node " + process.version)
|
|
11
|
+
console.error(chalk.green("✓") + " cloudcc-cli v" + pkg.version)
|
|
12
|
+
|
|
13
|
+
const cwd = process.cwd()
|
|
14
|
+
const configPath = path.join(cwd, "cloudcc-cli.config.js")
|
|
15
|
+
if (fs.existsSync(configPath)) {
|
|
16
|
+
console.error(chalk.green("✓") + " 当前目录存在 cloudcc-cli.config.js")
|
|
17
|
+
} else {
|
|
18
|
+
console.error(
|
|
19
|
+
chalk.yellow("○") + " 当前目录未找到 cloudcc-cli.config.js(若在本目录开发 CloudCC 项目,请先初始化或放入配置)"
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
console.error()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = doctor
|
package/src/version/get.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
const chalk = require("chalk")
|
|
2
2
|
const pkg = require("../../package.json")
|
|
3
|
+
const { getReleaseForExact, defaultReadmePath } = require("../../utils/readmeReleases")
|
|
4
|
+
const { printReleaseNotesBlocks } = require("../../utils/formatReleaseNotes")
|
|
3
5
|
|
|
4
6
|
function get() {
|
|
5
7
|
console.error()
|
|
6
|
-
console.error(chalk.green(`cloudcc-cli version: ${pkg.version}`))
|
|
8
|
+
console.error(chalk.green(`cloudcc-cli version: ${pkg.version}`))
|
|
9
|
+
const rel = getReleaseForExact(defaultReadmePath(), pkg.version)
|
|
10
|
+
if (rel) {
|
|
11
|
+
printReleaseNotesBlocks([rel], console.error)
|
|
12
|
+
}
|
|
7
13
|
console.error()
|
|
8
14
|
}
|
|
9
15
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const chalk = require("chalk")
|
|
2
|
+
const pkg = require("../../package.json")
|
|
3
|
+
const { getModuleGroups, describeActionLine } = require("./listModuleCommands")
|
|
4
|
+
|
|
5
|
+
function help() {
|
|
6
|
+
console.error()
|
|
7
|
+
console.error(chalk.bold.cyan("cloudcc-cli (cc)") + chalk.gray(` v${pkg.version}`))
|
|
8
|
+
console.error()
|
|
9
|
+
console.error(chalk.yellow("Usage:"))
|
|
10
|
+
console.error(" " + chalk.green("cc") + " <action> <resource> [args...]")
|
|
11
|
+
console.error()
|
|
12
|
+
console.error(chalk.yellow("Global:"))
|
|
13
|
+
console.error(" " + chalk.green("cc --help") + ", " + chalk.green("-h") + ", " + chalk.green("cc help") + " 显示本帮助")
|
|
14
|
+
console.error(" " + chalk.green("cc --version") + ", " + chalk.green("-v") + " 打印版本号")
|
|
15
|
+
console.error(" " + chalk.green("cc update") + " 升级全局 cloudcc-cli")
|
|
16
|
+
console.error(" " + chalk.green("cc uninstall") + " 卸载全局 cloudcc-cli")
|
|
17
|
+
console.error(" " + chalk.green("cc doctor") + " 环境自检(Node、配置、CLI 版本)")
|
|
18
|
+
console.error(" " + chalk.green("cc docs") + " 在浏览器打开 CloudCC 帮助中心")
|
|
19
|
+
console.error(" " + chalk.green("cc stats") + " 查看本地命令调用统计(默认开启," + chalk.gray("CLOUDCC_CLI_STATS=0") + " 可关闭)")
|
|
20
|
+
console.error(" " + chalk.green("cc init") + " [项目名] 等同于 cc create project")
|
|
21
|
+
console.error(" " + chalk.green("cc <action> -h") + " 查看该 action 下可用的 resource")
|
|
22
|
+
console.error()
|
|
23
|
+
console.error(chalk.yellow("模块 (resource)"))
|
|
24
|
+
console.error()
|
|
25
|
+
|
|
26
|
+
const groups = getModuleGroups()
|
|
27
|
+
for (const { resources, actions } of groups) {
|
|
28
|
+
const title = resources.join(" / ")
|
|
29
|
+
console.error(chalk.bold.white(" " + title))
|
|
30
|
+
const ex = resources[0]
|
|
31
|
+
for (const a of actions) {
|
|
32
|
+
const cmd = "cc " + a + " " + ex
|
|
33
|
+
const note = describeActionLine(ex, a)
|
|
34
|
+
console.error(" " + chalk.green(cmd) + " " + chalk.gray(note))
|
|
35
|
+
}
|
|
36
|
+
console.error()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.error(chalk.yellow("Examples:"))
|
|
40
|
+
console.error(" " + chalk.gray("cc doc object introduction"))
|
|
41
|
+
console.error(" " + chalk.gray("cc get object Account"))
|
|
42
|
+
console.error()
|
|
43
|
+
console.error(chalk.gray("Developer docs: https://help.cloudcc.cn/"))
|
|
44
|
+
console.error()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = help
|
package/src/version/index.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
const cc = {}
|
|
2
2
|
cc.get = require("./get")
|
|
3
|
+
cc.help = require("./help")
|
|
4
|
+
cc.update = require("./update")
|
|
5
|
+
cc.uninstall = require("./uninstall")
|
|
3
6
|
|
|
4
7
|
function Version(action, argvs) {
|
|
5
|
-
cc[action]
|
|
8
|
+
const fn = cc[action]
|
|
9
|
+
if (!fn) {
|
|
10
|
+
throw new Error(`version: unsupported action ${action}`)
|
|
11
|
+
}
|
|
12
|
+
return Promise.resolve(fn(argvs))
|
|
6
13
|
}
|
|
7
14
|
|
|
8
|
-
module.exports = Version
|
|
15
|
+
module.exports = Version
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const chalk = require("chalk")
|
|
2
|
+
|
|
3
|
+
function initHelp() {
|
|
4
|
+
console.error()
|
|
5
|
+
console.error(chalk.bold.cyan("cc init") + chalk.gray(" — 与 ") + chalk.green("cc create project") + chalk.gray(" 相同"))
|
|
6
|
+
console.error()
|
|
7
|
+
console.error(chalk.yellow("用法:"))
|
|
8
|
+
console.error(" " + chalk.green("cc init") + " [项目名]")
|
|
9
|
+
console.error(chalk.gray(" 不传项目名时进入交互式创建。"))
|
|
10
|
+
console.error()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = initHelp
|