cloudcc-cli 2.3.4 → 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 +22 -1
- package/.cursor/skills/cloudcc-cli-dev/SKILL.md +175 -0
- package/.cursor/skills/cloudcc-dev-skill/SKILL.md +71 -0
- package/README.md +54 -7
- package/bin/cc.js +106 -28
- package/bin/index.js +54 -55
- 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 +3 -4
- 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/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/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/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/validationRule/create.js +2 -2
- 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 -54
- package/.cursor/skills/cloudcc-cli-dev.zip +0 -0
- package/.cursor/skills/cloudcc-dev-usage/SKILL.md +0 -68
- package/build/component-cc-cc-dd.common.js +0 -831
- package/build/component-cc-cc-dd.common.js.map +0 -1
- package/build/component-cc-cc-dd.css +0 -1
- package/build/component-cc-cc-dd.umd.js +0 -874
- package/build/component-cc-cc-dd.umd.js.map +0 -1
- package/build/component-cc-cc-dd.umd.min.js +0 -8
- package/build/component-cc-cc-dd.umd.min.js.map +0 -1
- package/build/demo.html +0 -1
- package/plugins/cc-cc-dd/cc-cc-dd.vue +0 -32
- package/plugins/cc-cc-dd/components/HelloWorld.vue +0 -11
- package/plugins/cc-cc-dd/config.json +0 -6
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
const { getPackageJson } = require("../../utils/config");
|
|
4
|
+
const inquirer = require('inquirer');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 获取权限集已分配的用户列表
|
|
8
|
+
* @param {Object} config - 项目配置
|
|
9
|
+
* @param {string} permsetId - 权限集ID
|
|
10
|
+
* @returns {Promise<Array>} 已分配用户列表
|
|
11
|
+
*/
|
|
12
|
+
async function getAssignedUsers(config, permsetId) {
|
|
13
|
+
const res = await postClass(
|
|
14
|
+
config.setupSvc + "/api/permissionGroup/queryUserlistBypermsetsid",
|
|
15
|
+
{ id: permsetId },
|
|
16
|
+
config.accessToken
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
if (res && res.result && res.data) {
|
|
20
|
+
return res.data.userlist || [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
throw new Error("获取已分配用户列表失败");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 删除权限集分配用户
|
|
28
|
+
* 用法:cc remove permission <projectPath> <permsetId> [userIds...]
|
|
29
|
+
* 如果不指定 userIds,会进入交互式选择
|
|
30
|
+
* @param {Array} argvs - 命令行参数数组
|
|
31
|
+
* @param {boolean} isMcp - 是否为MCP模式
|
|
32
|
+
* @returns {Promise<Object>} 删除结果
|
|
33
|
+
*/
|
|
34
|
+
async function remove(argvs, isMcp = false) {
|
|
35
|
+
try {
|
|
36
|
+
const projectPath = argvs[2] || process.cwd();
|
|
37
|
+
const permsetId = argvs[3];
|
|
38
|
+
// 从第4个参数开始是用户ID
|
|
39
|
+
let userIds = argvs.slice(4);
|
|
40
|
+
|
|
41
|
+
if (!permsetId) {
|
|
42
|
+
console.error();
|
|
43
|
+
console.error(chalk.red('Error: 缺少权限集ID'));
|
|
44
|
+
console.error('用法: cc remove permission <path> <permsetId> [userId1] [userId2] ...');
|
|
45
|
+
console.error('示例:');
|
|
46
|
+
console.error(' cc remove permission . "cac20258F0E4ABBnTxwi" # 交互式选择用户');
|
|
47
|
+
console.error(' cc remove permission . "cac20258F0E4ABBnTxwi" "00520260C00C6FEfsMnT" # 直接指定用户ID');
|
|
48
|
+
console.error();
|
|
49
|
+
throw new Error('缺少必需参数: permsetId');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const config = await getPackageJson(projectPath);
|
|
53
|
+
|
|
54
|
+
// 如果没有指定用户ID,进入交互式选择
|
|
55
|
+
if (userIds.length === 0) {
|
|
56
|
+
console.log();
|
|
57
|
+
console.log(chalk.blue('正在获取已分配用户列表...'));
|
|
58
|
+
|
|
59
|
+
const userList = await getAssignedUsers(config, permsetId);
|
|
60
|
+
|
|
61
|
+
if (userList.length === 0) {
|
|
62
|
+
console.log(chalk.yellow("该权限集没有分配任何用户"));
|
|
63
|
+
return { success: false, message: "该权限集没有分配任何用户" };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 交互式选择用户
|
|
67
|
+
const choices = userList.map(user => ({
|
|
68
|
+
name: `${user.name || '未命名'} (${user.loginname || ''}) - ${user.id}`,
|
|
69
|
+
value: user.id,
|
|
70
|
+
short: user.name || user.id
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
const { selectedUsers } = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: 'checkbox',
|
|
76
|
+
name: 'selectedUsers',
|
|
77
|
+
message: '请选择要删除的用户(使用空格键选择,回车确认):',
|
|
78
|
+
choices: choices,
|
|
79
|
+
validate: (input) => input.length > 0 || '请至少选择一个用户'
|
|
80
|
+
}
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
userIds = selectedUsers;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (userIds.length === 0) {
|
|
87
|
+
console.log(chalk.yellow("未选择任何用户"));
|
|
88
|
+
return { success: false, message: "未选择任何用户" };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 确认删除
|
|
92
|
+
const { confirm } = await inquirer.prompt([
|
|
93
|
+
{
|
|
94
|
+
type: 'confirm',
|
|
95
|
+
name: 'confirm',
|
|
96
|
+
message: `确定要从权限集中移除 ${userIds.length} 个用户吗?`,
|
|
97
|
+
default: false
|
|
98
|
+
}
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
if (!confirm) {
|
|
102
|
+
console.log(chalk.yellow("已取消操作"));
|
|
103
|
+
return { success: false, message: "用户取消操作" };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log();
|
|
107
|
+
console.log(chalk.blue(`正在从权限集 ${permsetId} 移除 ${userIds.length} 个用户...`));
|
|
108
|
+
|
|
109
|
+
const res = await postClass(
|
|
110
|
+
config.setupSvc + "/api/permissionGroup/deleteUsersetup",
|
|
111
|
+
{
|
|
112
|
+
id: permsetId,
|
|
113
|
+
ids: userIds.join(',')
|
|
114
|
+
},
|
|
115
|
+
config.accessToken
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
if (res && res.result) {
|
|
119
|
+
if (!isMcp) {
|
|
120
|
+
console.log();
|
|
121
|
+
console.log(chalk.green('✓ 用户移除成功'));
|
|
122
|
+
console.log(` 权限集ID: ${permsetId}`);
|
|
123
|
+
console.log(` 移除用户数: ${userIds.length}`);
|
|
124
|
+
console.log();
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
permsetId: permsetId,
|
|
129
|
+
userCount: userIds.length,
|
|
130
|
+
userIds: userIds
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const msg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
|
|
135
|
+
throw new Error("移除用户失败: " + msg);
|
|
136
|
+
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (!isMcp) {
|
|
139
|
+
console.error(chalk.red("Error: " + error.message));
|
|
140
|
+
}
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = remove;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
1. 安装 Node 与 npm,并切换 npm 源
|
|
19
19
|
2. 安装 `cloudcc-cli` 全局依赖
|
|
20
20
|
3. 安装 VS Code 与 CloudCC 插件
|
|
21
|
-
4. 配置本地 MCP(`
|
|
21
|
+
4. 配置本地 MCP(`node` 运行 `bin/mcp.js`)
|
|
22
22
|
5. 使用 CLI 创建模板项目并安装依赖
|
|
23
23
|
6. 通过 CRM 获取开发者密钥、安全标记并写入 `cloudcc-cli.config.js`
|
|
24
24
|
7. 视情况配置私有云与多环境参数
|
|
@@ -109,15 +109,16 @@ sudo npm ls -g --depth=0
|
|
|
109
109
|
|
|
110
110
|
---
|
|
111
111
|
|
|
112
|
-
## 5. 安装并配置本地 MCP
|
|
112
|
+
## 5. 安装并配置本地 MCP
|
|
113
113
|
|
|
114
|
-
在支持 MCP 的开发工具中(如 Cursor),需要在 MCP
|
|
114
|
+
在支持 MCP 的开发工具中(如 Cursor),需要在 MCP 配置文件中添加(使用 `node` 启动包内脚本,**将 `args` 中的路径换成本机全局安装后的绝对路径**):
|
|
115
115
|
|
|
116
116
|
```json
|
|
117
117
|
{
|
|
118
118
|
"mcpServers": {
|
|
119
119
|
"cloudcc-cli": {
|
|
120
|
-
"command": "
|
|
120
|
+
"command": "node",
|
|
121
|
+
"args": ["<npm-global>/cloudcc-cli/bin/mcp.js"]
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
}
|
|
@@ -126,7 +127,7 @@ sudo npm ls -g --depth=0
|
|
|
126
127
|
说明:
|
|
127
128
|
|
|
128
129
|
- `cloudcc-cli`:MCP 服务器标识,用于在工具中调用 CloudCC 相关能力
|
|
129
|
-
- `command
|
|
130
|
+
- `command` / `args`:通过 Node 执行 `cloudcc-cli` 包内的 `bin/mcp.js`(全局安装后路径一般为 `$(npm root -g)/cloudcc-cli/bin/mcp.js`,请粘贴为绝对路径)
|
|
130
131
|
|
|
131
132
|
---
|
|
132
133
|
|
|
@@ -351,7 +352,7 @@ module.exports = {
|
|
|
351
352
|
- [ ] npm 源已切换到 `https://registry.npmmirror.com`
|
|
352
353
|
- [ ] 已全局安装 `cloudcc-cli` 并验证
|
|
353
354
|
- [ ] 已安装 VS Code 与 CloudCC 插件(或已按官方指引配置 Cursor)
|
|
354
|
-
- [ ] MCP 已配置 `cloudcc-cli
|
|
355
|
+
- [ ] MCP 已配置 `cloudcc-cli`(`node` + `bin/mcp.js`)
|
|
355
356
|
- [ ] 已通过 `cc create project` 创建模板项目并成功 `npm i` + `npm run serve`
|
|
356
357
|
- [ ] 已创建开发者账号并确认「代码管理」权限开启
|
|
357
358
|
- [ ] 已获取开发者密钥与安全标记并正确配置 `cloudcc-cli.config.js`
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
const { getPackageJson } = require("../../utils/config");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 删除单点登录记录
|
|
7
|
+
* 接口: /spconfig/delete
|
|
8
|
+
* 用法:cc delete singleSignOn <projectPath> <id>
|
|
9
|
+
*/
|
|
10
|
+
async function remove(argvs) {
|
|
11
|
+
try {
|
|
12
|
+
const projectPath = argvs[2] || process.cwd();
|
|
13
|
+
const id = argvs[3];
|
|
14
|
+
|
|
15
|
+
if (!id) {
|
|
16
|
+
console.error();
|
|
17
|
+
console.error(chalk.red("Error: 缺少单点登录记录 id"));
|
|
18
|
+
console.error(chalk.yellow("用法: cc delete singleSignOn <projectPath> <id>"));
|
|
19
|
+
console.error(chalk.yellow("示例: cc delete singleSignOn . 20246DB16F11EDF4KHWd"));
|
|
20
|
+
console.error();
|
|
21
|
+
throw new Error("缺少必需参数: id");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const config = await getPackageJson(projectPath);
|
|
25
|
+
if (!config || !config.accessToken) {
|
|
26
|
+
console.error();
|
|
27
|
+
console.error(chalk.red("Error: 配置未找到或 accessToken 缺失"));
|
|
28
|
+
console.error();
|
|
29
|
+
throw new Error("配置未找到或 accessToken 缺失");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.error();
|
|
33
|
+
console.error(chalk.green(`Deleting single sign on record (${id}), please wait...`));
|
|
34
|
+
console.error();
|
|
35
|
+
|
|
36
|
+
const result = await postClass(
|
|
37
|
+
config.setupSvc + "/api/spconfig/delete",
|
|
38
|
+
{ id: id },
|
|
39
|
+
config.accessToken
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (result && result.result) {
|
|
43
|
+
console.error();
|
|
44
|
+
console.error(chalk.green("Success! Single sign on record deleted."));
|
|
45
|
+
console.error();
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const msg = result && (result.returnInfo || result.message) ? (result.returnInfo || result.message) : "Unknown error";
|
|
50
|
+
console.error();
|
|
51
|
+
console.error(chalk.red("Error: " + msg));
|
|
52
|
+
console.error();
|
|
53
|
+
throw new Error("Delete SingleSignOn Failed: " + msg);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error();
|
|
56
|
+
console.error(chalk.red("单点登录记录删除失败:"), error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = remove;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* singleSignOn 文档入口:正文均在 `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 singleSignOn <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 singleSignOn 需要子命令: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,61 @@
|
|
|
1
|
+
# CloudCC 单点登录 CLI 命令说明
|
|
2
|
+
|
|
3
|
+
## 支持的命令
|
|
4
|
+
|
|
5
|
+
| 操作 | 说明 |
|
|
6
|
+
|------|------|
|
|
7
|
+
| `get` | 查询单点登录配置列表 |
|
|
8
|
+
| `delete` | 删除单点登录记录 |
|
|
9
|
+
|
|
10
|
+
## CLI 命令详解
|
|
11
|
+
|
|
12
|
+
### 查询单点登录配置列表
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
cc get singleSignOn <projectPath> [encodedCondJson]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
**参数说明:**
|
|
19
|
+
|
|
20
|
+
| 参数 | 必填 | 说明 |
|
|
21
|
+
|------|------|------|
|
|
22
|
+
| `projectPath` | 否 | 项目路径,默认当前目录 |
|
|
23
|
+
| `encodedCondJson` | 否 | URI 编码后的查询条件 JSON |
|
|
24
|
+
|
|
25
|
+
**查询条件参数:**
|
|
26
|
+
|
|
27
|
+
| 参数名 | 类型 | 说明 |
|
|
28
|
+
|--------|------|------|
|
|
29
|
+
| `start` | number | 起始位置,默认 0 |
|
|
30
|
+
| `limit` | number | 每页条数,默认 30 |
|
|
31
|
+
| `keyword` | string | 搜索关键词 |
|
|
32
|
+
|
|
33
|
+
**示例:**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 获取所有单点登录配置
|
|
37
|
+
cc get singleSignOn .
|
|
38
|
+
|
|
39
|
+
# 带查询条件(搜索关键词)
|
|
40
|
+
cc get singleSignOn . '%7B%22keyword%22%3A%22test%22%2C%22limit%22%3A50%7D'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 删除单点登录记录
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cc delete singleSignOn <projectPath> <id>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**参数说明:**
|
|
50
|
+
|
|
51
|
+
| 参数 | 必填 | 说明 |
|
|
52
|
+
|------|------|------|
|
|
53
|
+
| `projectPath` | 否 | 项目路径,默认当前目录 |
|
|
54
|
+
| `id` | 是 | 单点登录记录 id(从列表接口获取)|
|
|
55
|
+
|
|
56
|
+
**示例:**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 删除单点登录记录
|
|
60
|
+
cc delete singleSignOn . 20246DB16F11EDF4KHWd
|
|
61
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const { postClass } = require("../../utils/http");
|
|
2
|
+
const { getPackageJson } = require("../../utils/config");
|
|
3
|
+
const chalk = require("chalk");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 查询单点登录配置列表
|
|
7
|
+
* 接口: /spconfig/list
|
|
8
|
+
* 用法:cc get singleSignOn <projectPath> [encodedCondJson]
|
|
9
|
+
*/
|
|
10
|
+
async function get(argvs, isMcp = false) {
|
|
11
|
+
const projectPath = argvs[2] || process.cwd();
|
|
12
|
+
const condArg = argvs[3];
|
|
13
|
+
|
|
14
|
+
let body = {};
|
|
15
|
+
if (condArg) {
|
|
16
|
+
try {
|
|
17
|
+
body = JSON.parse(decodeURI(condArg));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
try {
|
|
20
|
+
body = JSON.parse(condArg);
|
|
21
|
+
} catch (e2) {
|
|
22
|
+
throw new Error("Get SingleSignOn Failed: encodedCondJson 解析失败,请传 encodeURI(JSON.stringify(...))");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const config = await getPackageJson(projectPath);
|
|
28
|
+
|
|
29
|
+
const res = await postClass(
|
|
30
|
+
config.setupSvc + "/api/spconfig/list",
|
|
31
|
+
{
|
|
32
|
+
start: 0,
|
|
33
|
+
limit: 30,
|
|
34
|
+
keyword: "",
|
|
35
|
+
...body
|
|
36
|
+
},
|
|
37
|
+
config.accessToken
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (res && res.result) {
|
|
41
|
+
const data = res.data;
|
|
42
|
+
let rawList = [];
|
|
43
|
+
if (Array.isArray(data)) {
|
|
44
|
+
rawList = data;
|
|
45
|
+
} else if (data && Array.isArray(data.list)) {
|
|
46
|
+
rawList = data.list;
|
|
47
|
+
} else if (data && Array.isArray(data.data)) {
|
|
48
|
+
rawList = data.data;
|
|
49
|
+
} else if (data && typeof data === "object") {
|
|
50
|
+
rawList = Object.keys(data)
|
|
51
|
+
.filter((key) => /list$/i.test(key) && Array.isArray(data[key]))
|
|
52
|
+
.flatMap((key) =>
|
|
53
|
+
data[key].map((item) => ({
|
|
54
|
+
...item,
|
|
55
|
+
__group: key
|
|
56
|
+
}))
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!isMcp) {
|
|
61
|
+
console.log(JSON.stringify(rawList, null, 2));
|
|
62
|
+
}
|
|
63
|
+
return rawList;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const msg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
|
|
67
|
+
throw new Error("Get SingleSignOn Failed: " + msg);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = get;
|
|
@@ -1,3 +1,46 @@
|
|
|
1
1
|
# CloudCC 静态资源介绍
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 1. 模块定位
|
|
4
|
+
|
|
5
|
+
静态资源用于统一托管前端开发中需要复用的文件资源(如图片、字体、JS/CSS 文件、压缩包等)。
|
|
6
|
+
当资源不适合直接内嵌在代码中时,可上传到静态资源库,再通过平台提供的访问链接在组件、页面、脚本中引用。
|
|
7
|
+
|
|
8
|
+
## 2. 典型使用场景
|
|
9
|
+
|
|
10
|
+
- 自定义组件引用公共图片、图标、字体文件
|
|
11
|
+
- 自定义页面加载第三方前端库(如工具函数、样式文件)
|
|
12
|
+
- 多个业务功能共享同一份资源,避免重复上传与多处维护
|
|
13
|
+
|
|
14
|
+
## 3. 控制台入口
|
|
15
|
+
|
|
16
|
+
1. 登录 CloudCC 系统
|
|
17
|
+
2. 点击右上角头像,进入「开发者平台」(当前仅管理员简档可见)
|
|
18
|
+
3. 在左侧菜单进入:`扩展 -> 静态资源`
|
|
19
|
+
|
|
20
|
+
## 4. 核心操作流程
|
|
21
|
+
|
|
22
|
+
### 4.1 新建静态资源
|
|
23
|
+
|
|
24
|
+
1. 点击「新建」
|
|
25
|
+
2. 填写必要信息(名称/标签、描述等)
|
|
26
|
+
3. 上传资源文件并保存
|
|
27
|
+
|
|
28
|
+
### 4.2 获取访问链接并应用
|
|
29
|
+
|
|
30
|
+
1. 在资源列表中找到目标资源
|
|
31
|
+
2. 点击复制图标获取资源访问链接
|
|
32
|
+
3. 在组件/页面/脚本中使用该链接
|
|
33
|
+
|
|
34
|
+
## 5. 关键约束与注意事项
|
|
35
|
+
|
|
36
|
+
- 单个上传文件大小上限为 `5MB`
|
|
37
|
+
- 建议使用可读性强、可维护的命名规范,便于检索和复用
|
|
38
|
+
- 发布前应验证访问链接可用性,避免页面出现 404 或加载失败
|
|
39
|
+
- 建议在团队内约定资源分类(如 `img/`、`font/`、`vendor/`)与版本策略
|
|
40
|
+
|
|
41
|
+
## 6. 设计建议(面向实施)
|
|
42
|
+
|
|
43
|
+
- **先复用后新增**:优先检查资源库中是否已有同类资源,减少冗余
|
|
44
|
+
- **按用途分层管理**:将业务资源与公共资源分开,降低变更影响
|
|
45
|
+
- **关注性能**:对图片进行压缩,避免引入过大的静态文件影响加载速度
|
|
46
|
+
- **建立变更记录**:重大资源替换建议记录版本和影响范围,便于回滚与排查
|
|
@@ -121,12 +121,12 @@ async function create(argvs) {
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const saveRes = await postClass(
|
|
124
|
-
config.setupSvc + "/api/validateRule/
|
|
124
|
+
config.setupSvc + "/api/validateRule/save",
|
|
125
125
|
validateData,
|
|
126
126
|
config.accessToken
|
|
127
127
|
);
|
|
128
128
|
|
|
129
|
-
if (saveRes && saveRes.result) {
|
|
129
|
+
if (saveRes && (saveRes.result === true || saveRes.result === "true" || saveRes.returnCode === "1")) {
|
|
130
130
|
console.error();
|
|
131
131
|
console.error(chalk.green('Success! Validation rule created.'));
|
|
132
132
|
console.error(` 规则名称: ${ruleName}`);
|
|
@@ -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
|