cloudcc-cli 2.3.0 → 2.3.1
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/.cloudcc-cache.json +4 -52
- package/.cursor/skills/cloudcc-cli-dev/BACKEND_CLASS.md +15 -1
- package/.cursor/skills/cloudcc-cli-dev/BACKEND_SCHEDULE.md +82 -8
- package/.cursor/skills/cloudcc-cli-dev/BACKEND_TRIGGER.md +13 -0
- package/.cursor/skills/cloudcc-cli-dev/CLI_CHEATSHEET.md +234 -77
- package/.cursor/skills/cloudcc-cli-dev/CUSTOM-SETTING-API.md +37 -216
- package/.cursor/skills/cloudcc-cli-dev/INSTALL_AND_BOOTSTRAP.md +9 -6
- package/.cursor/skills/cloudcc-cli-dev/OBJECTS_AND_FIELDS.md +99 -5
- package/.cursor/skills/cloudcc-cli-dev/REQUIREMENTS_BREAKDOWN.md +15 -0
- package/.cursor/skills/cloudcc-cli-dev/SKILL.md +29 -7
- package/.cursor/skills/cloudcc-cli-dev/STATIC-RESOURCE-API.md +60 -0
- package/.cursor/skills/cloudcc-cli-dev/VUE_CUSTOM_PAGE.md +216 -0
- package/.cursor/skills/cloudcc-cli-dev/docs//350/207/252/345/256/232/344/271/211/351/241/265/351/235/242.md +228 -0
- package/README.md +11 -0
- package/bin/index.js +3 -0
- package/package.json +2 -2
- package/src/application/delete.js +59 -0
- package/src/application/get.js +31 -5
- package/src/application/index.js +1 -0
- package/src/classes/delete.js +43 -0
- package/src/classes/detail.js +14 -7
- package/src/classes/index.js +1 -0
- package/src/customPage/create.js +74 -12
- package/src/customPage/delete.js +2 -2
- package/src/customPage/get.js +1 -1
- package/src/customSetting/create.js +27 -0
- package/src/customSetting/delete.js +26 -0
- package/src/customSetting/detail.js +24 -0
- package/src/customSetting/get.js +25 -0
- package/src/customSetting/index.js +4 -0
- package/src/fields/delete.js +52 -0
- package/src/fields/index.js +1 -0
- package/src/menu/create-page.js +16 -25
- package/src/menu/create.js +9 -3
- package/src/menu/delete.js +59 -0
- package/src/menu/get.js +56 -0
- package/src/menu/index.js +2 -0
- package/src/object/delete.js +51 -0
- package/src/object/index.js +1 -0
- package/src/plugin/detail.js +14 -6
- package/src/plugin/publish1.js +3 -3
- package/src/recordType/get.js +1 -1
- package/src/scheduleJob/delete.js +26 -0
- package/src/scheduleJob/detail.js +23 -0
- package/src/scheduleJob/get.js +26 -0
- package/src/scheduleJob/index.js +10 -0
- package/src/staticResource/count.js +25 -0
- package/src/staticResource/delete.js +26 -0
- package/src/staticResource/detail.js +24 -0
- package/src/staticResource/doc.js +106 -0
- package/src/staticResource/get.js +25 -0
- package/src/staticResource/index.js +12 -0
- package/src/timer/delete.js +43 -0
- package/src/timer/index.js +1 -0
- package/src/triggers/delete.js +46 -0
- package/src/triggers/index.js +1 -0
- package/test/application.cli.test.js +49 -8
- package/test/classes.cli.test.js +9 -3
- package/test/customSetting.cli.test.js +84 -0
- package/test/fields.cli.test.js +18 -3
- package/test/menu.cli.test.js +34 -4
- package/test/object.cli.test.js +17 -1
- package/test/scheduleJob.cli.test.js +52 -0
- package/test/staticResource.cli.test.js +78 -0
- package/test/timer.cli.test.js +8 -2
- package/test/trigger.cli.test.js +8 -2
- package/build/component-cc-test-001.common.js +0 -831
- package/build/component-cc-test-001.common.js.map +0 -1
- package/build/component-cc-test-001.css +0 -1
- package/build/component-cc-test-001.umd.js +0 -874
- package/build/component-cc-test-001.umd.js.map +0 -1
- package/build/component-cc-test-001.umd.min.js +0 -8
- package/build/component-cc-test-001.umd.min.js.map +0 -1
- package/build/demo.html +0 -1
- package/classes/CCdd/CCdd.java +0 -22
- package/classes/CCdd/CCddTest.java +0 -11
- package/classes/CCdd/config.json +0 -1
- package/core.zip +0 -0
- package/plugins/cc-test-001/cc-test-001.vue +0 -32
- package/plugins/cc-test-001/components/HelloWorld.vue +0 -11
- package/plugins/cc-test-001/config.json +0 -6
- package/schedule/CCdd/CCdd.java +0 -11
- package/schedule/CCdd/config.json +0 -1
- package/target/ccopenapi-0.0.4-classes.jar +0 -0
- package/target/ccopenapi-0.0.4.jar +0 -0
- package/target/classes/CCdd/CCdd.class +0 -0
- package/target/classes/CCdd/CCddTest.class +0 -0
- package/target/classes/CCdd/config.json +0 -1
- package/target/maven-archiver/pom.properties +0 -3
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -20
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -19
- /package/{docs → .cursor/skills/cloudcc-cli-dev/docs}/CloudCC/350/207/252/345/256/232/344/271/211/347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216.md" +0 -0
- /package/{docs → .cursor/skills/cloudcc-cli-dev/docs}/cloudcc/345/256/232/346/227/266/344/275/234/344/270/232.md" +0 -0
- /package/{docs → .cursor/skills/cloudcc-cli-dev/docs}/cloudcc/345/256/232/346/227/266/347/261/273.md" +0 -0
- /package/{docs → .cursor/skills/cloudcc-cli-dev/docs}//350/207/252/345/256/232/344/271/211/347/261/273.md" +0 -0
- /package/{docs → .cursor/skills/cloudcc-cli-dev/docs}//350/247/246/345/217/221/345/231/250/347/261/273.md" +0 -0
package/src/classes/detail.js
CHANGED
|
@@ -4,7 +4,14 @@ const path = require("path")
|
|
|
4
4
|
const { getPackageJson } = require("../../utils/config")
|
|
5
5
|
const { postClass } = require("../../utils/http")
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function outputResult(result, isMcp) {
|
|
8
|
+
if (!isMcp) {
|
|
9
|
+
console.log(JSON.stringify(result));
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function detail(name, id, isMcp = false) {
|
|
8
15
|
// 如果有 name,优先查询本地
|
|
9
16
|
if (name && name !== '') {
|
|
10
17
|
const classPath = path.join(process.cwd(), `classes/${name}/`);
|
|
@@ -15,14 +22,14 @@ async function detail(name, id) {
|
|
|
15
22
|
if (fs.existsSync(configPath) && fs.existsSync(javaFilePath)) {
|
|
16
23
|
let configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
17
24
|
let javaContent = fs.readFileSync(javaFilePath, 'utf8');
|
|
18
|
-
return {
|
|
25
|
+
return outputResult({
|
|
19
26
|
name: configContent.name,
|
|
20
27
|
version: configContent.version,
|
|
21
28
|
id: configContent.id || null,
|
|
22
29
|
source: javaContent,
|
|
23
30
|
published: !!configContent.id,
|
|
24
31
|
fromLocal: true
|
|
25
|
-
};
|
|
32
|
+
}, isMcp);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
// 本地文件不完整,从服务器拉取
|
|
@@ -44,10 +51,10 @@ async function detail(name, id) {
|
|
|
44
51
|
let res = await postClass(config.setupSvc + "/api/ccfag/detail", body, config.accessToken)
|
|
45
52
|
|
|
46
53
|
if (res.result) {
|
|
47
|
-
return {
|
|
54
|
+
return outputResult({
|
|
48
55
|
...res.data.trigger,
|
|
49
56
|
fromLocal: false
|
|
50
|
-
};
|
|
57
|
+
}, isMcp);
|
|
51
58
|
} else {
|
|
52
59
|
throw new Error('Get Class Details Failed: ' + res.returnInfo);
|
|
53
60
|
}
|
|
@@ -62,10 +69,10 @@ async function detail(name, id) {
|
|
|
62
69
|
let res = await postClass(config.setupSvc + "/api/ccfag/detail", body, config.accessToken)
|
|
63
70
|
|
|
64
71
|
if (res.result) {
|
|
65
|
-
return {
|
|
72
|
+
return outputResult({
|
|
66
73
|
...res.data.trigger,
|
|
67
74
|
fromLocal: false
|
|
68
|
-
};
|
|
75
|
+
}, isMcp);
|
|
69
76
|
} else {
|
|
70
77
|
throw new Error('Get Class Details Failed: ' + res.returnInfo);
|
|
71
78
|
}
|
package/src/classes/index.js
CHANGED
package/src/customPage/create.js
CHANGED
|
@@ -6,17 +6,18 @@ const BaseUrl = 'https://developer.apis.cloudcc.cn';
|
|
|
6
6
|
/**
|
|
7
7
|
* 新建自定义页面
|
|
8
8
|
*
|
|
9
|
-
* 用法:cc customPage
|
|
9
|
+
* 用法:cc create customPage <pageLabel> <pageApi> <pluginId|compLabel> [projectPath]
|
|
10
10
|
*/
|
|
11
11
|
async function createCustomPage(argvs) {
|
|
12
12
|
const pageLabel = argvs[2];
|
|
13
13
|
const pageApi = argvs[3];
|
|
14
|
-
const
|
|
14
|
+
const pluginIdentifier = argvs[4];
|
|
15
|
+
const projectPath = argvs[5] || process.cwd();
|
|
15
16
|
|
|
16
|
-
if (!pageLabel || !pageApi) {
|
|
17
|
+
if (!pageLabel || !pageApi || !pluginIdentifier) {
|
|
17
18
|
console.error();
|
|
18
|
-
console.error(chalk.red('Error: pageLabel and
|
|
19
|
-
console.error(chalk.yellow('Usage: cc customPage
|
|
19
|
+
console.error(chalk.red('Error: pageLabel, pageApi and pluginId/compLabel are required'));
|
|
20
|
+
console.error(chalk.yellow('Usage: cc create customPage <pageLabel> <pageApi> <pluginId|compLabel> [projectPath]'));
|
|
20
21
|
console.error();
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
@@ -39,20 +40,81 @@ async function createCustomPage(argvs) {
|
|
|
39
40
|
version: 'public',
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
// 先通过 listCustomComp 获取组件列表,再按组件标识匹配目标组件
|
|
44
|
+
const listRes = await post(
|
|
45
|
+
`${baseUrl}${devSvcDispatch}/custom/pc/1.0/post/listCustomComp`,
|
|
46
|
+
{ orgId: config.orgId || '' },
|
|
47
|
+
header
|
|
48
|
+
);
|
|
49
|
+
if (!listRes || String(listRes.returnCode) !== '200') {
|
|
50
|
+
throw new Error('Create Custom Page Failed: list custom components failed');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const groupedCompMap = listRes.data || {};
|
|
54
|
+
const compList = Array.isArray(groupedCompMap['label.dev.bizType.custom'])
|
|
55
|
+
? groupedCompMap['label.dev.bizType.custom']
|
|
56
|
+
: [];
|
|
57
|
+
if (compList.length === 0) {
|
|
58
|
+
throw new Error('Create Custom Page Failed: no custom components found');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let pluginDetail = compList.find(item =>
|
|
62
|
+
item &&
|
|
63
|
+
(item.id === pluginIdentifier || item.compLabel === pluginIdentifier || item.compUniName === pluginIdentifier)
|
|
64
|
+
);
|
|
65
|
+
if (!pluginDetail) {
|
|
66
|
+
throw new Error(`Create Custom Page Failed: component "${pluginIdentifier}" not found in custom component list`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let vueData = {};
|
|
70
|
+
try {
|
|
71
|
+
vueData = pluginDetail.vueData ? JSON.parse(pluginDetail.vueData) : {};
|
|
72
|
+
} catch (e) {
|
|
73
|
+
throw new Error('Create Custom Page Failed: plugin vueData is not valid JSON');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const randomId = (len = 10) => Math.random().toString(36).slice(2, 2 + len);
|
|
77
|
+
const itemId = randomId(10);
|
|
78
|
+
const compUniName = pluginDetail.compUniName || pluginDetail.component || pluginDetail.name;
|
|
79
|
+
const compLabel = pluginDetail.compLabel || pluginDetail.compName || compUniName;
|
|
80
|
+
const compDesc = pluginDetail.compDesc || '';
|
|
81
|
+
const templatePropObj = vueData.propObj && typeof vueData.propObj === 'object' ? vueData.propObj : {};
|
|
82
|
+
|
|
83
|
+
const pageContentItem = {
|
|
84
|
+
...vueData,
|
|
85
|
+
id: itemId,
|
|
86
|
+
comId: pluginDetail.id,
|
|
87
|
+
name: compUniName,
|
|
88
|
+
componentInfo: {
|
|
89
|
+
...(vueData.componentInfo || {}),
|
|
90
|
+
component: compUniName,
|
|
91
|
+
compName: compLabel,
|
|
92
|
+
compDesc,
|
|
93
|
+
},
|
|
94
|
+
propObj: {
|
|
95
|
+
...templatePropObj,
|
|
96
|
+
id: itemId,
|
|
97
|
+
key: templatePropObj.key || randomId(4),
|
|
98
|
+
pageApi,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
42
102
|
const body = {
|
|
43
103
|
id: '',
|
|
44
104
|
pageLabel,
|
|
45
105
|
pageApi,
|
|
46
|
-
pageContent:
|
|
47
|
-
orgId: config.orgId || '',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
106
|
+
pageContent: JSON.stringify([pageContentItem]),
|
|
107
|
+
orgId: pluginDetail.orgId || config.orgId || '',
|
|
108
|
+
compList: [{
|
|
109
|
+
id: pluginDetail.id,
|
|
110
|
+
compUniName,
|
|
111
|
+
}],
|
|
112
|
+
canvasStyleData: JSON.stringify({ width: 100, height: 100, scale: 100, unit: '%', pageApi }),
|
|
51
113
|
isTemplate: 0,
|
|
52
114
|
};
|
|
53
115
|
|
|
54
116
|
console.error();
|
|
55
|
-
console.error(chalk.green(`Creating custom page "${pageLabel}" (api: ${pageApi}), please wait...`));
|
|
117
|
+
console.error(chalk.green(`Creating custom page "${pageLabel}" (api: ${pageApi}, component: ${pluginIdentifier}), please wait...`));
|
|
56
118
|
|
|
57
119
|
const res = await post(
|
|
58
120
|
`${baseUrl}${devSvcDispatch}/custom/pc/1.0/post/insertCustomPage`,
|
|
@@ -60,7 +122,7 @@ async function createCustomPage(argvs) {
|
|
|
60
122
|
header
|
|
61
123
|
);
|
|
62
124
|
|
|
63
|
-
if (res && res.returnCode
|
|
125
|
+
if (res && String(res.returnCode) === '200') {
|
|
64
126
|
const id = res.data?.id || res.data || '';
|
|
65
127
|
console.error(chalk.green(`Success! Custom page created.${id ? ' ID: ' + id : ''}`));
|
|
66
128
|
console.error();
|
package/src/customPage/delete.js
CHANGED
|
@@ -6,7 +6,7 @@ const BaseUrl = 'https://developer.apis.cloudcc.cn';
|
|
|
6
6
|
/**
|
|
7
7
|
* 删除自定义页面
|
|
8
8
|
*
|
|
9
|
-
* 用法:cc customPage
|
|
9
|
+
* 用法:cc delete customPage <id> [projectPath]
|
|
10
10
|
*/
|
|
11
11
|
async function deleteCustomPage(argvs) {
|
|
12
12
|
const id = argvs[2];
|
|
@@ -15,7 +15,7 @@ async function deleteCustomPage(argvs) {
|
|
|
15
15
|
if (!id) {
|
|
16
16
|
console.error();
|
|
17
17
|
console.error(chalk.red('Error: Custom page ID is required'));
|
|
18
|
-
console.error(chalk.yellow('Usage: cc customPage
|
|
18
|
+
console.error(chalk.yellow('Usage: cc delete customPage <id> [projectPath]'));
|
|
19
19
|
console.error();
|
|
20
20
|
return;
|
|
21
21
|
}
|
package/src/customPage/get.js
CHANGED
|
@@ -6,7 +6,7 @@ const BaseUrl = 'https://developer.apis.cloudcc.cn';
|
|
|
6
6
|
/**
|
|
7
7
|
* 获取自定义页面列表
|
|
8
8
|
*
|
|
9
|
-
* 用法:cc customPage
|
|
9
|
+
* 用法:cc get customPage [pageNo] [pageSize] [projectPath]
|
|
10
10
|
*/
|
|
11
11
|
async function listCustomPage(argvs) {
|
|
12
12
|
const pageNo = parseInt(argvs[2], 10) || 1;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { getPackageJson } = require("../../utils/config");
|
|
3
|
+
const { postClass } = require("../../utils/http");
|
|
4
|
+
|
|
5
|
+
async function create(projectPath = process.cwd(), encodedBodyJson) {
|
|
6
|
+
if (!encodedBodyJson) {
|
|
7
|
+
throw new Error("Create Custom Setting Failed: encodedBodyJson is required");
|
|
8
|
+
}
|
|
9
|
+
const body = JSON.parse(decodeURI(encodedBodyJson));
|
|
10
|
+
const config = await getPackageJson(projectPath);
|
|
11
|
+
console.error();
|
|
12
|
+
console.error(chalk.green("Creating custom setting, please wait..."));
|
|
13
|
+
console.error();
|
|
14
|
+
const res = await postClass(
|
|
15
|
+
config.setupSvc + "/api/customsetting/save",
|
|
16
|
+
body,
|
|
17
|
+
config.accessToken
|
|
18
|
+
);
|
|
19
|
+
if (res && res.result) {
|
|
20
|
+
console.error(chalk.green("Success! Custom setting saved."));
|
|
21
|
+
console.error();
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
24
|
+
throw new Error("Create Custom Setting Failed: " + (res?.returnInfo || res?.message || "Unknown error"));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = create;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { getPackageJson } = require("../../utils/config");
|
|
3
|
+
const { postClass } = require("../../utils/http");
|
|
4
|
+
|
|
5
|
+
async function remove(projectPath = process.cwd(), id) {
|
|
6
|
+
if (!id) {
|
|
7
|
+
throw new Error("Delete Custom Setting Failed: id is required");
|
|
8
|
+
}
|
|
9
|
+
const config = await getPackageJson(projectPath);
|
|
10
|
+
console.error();
|
|
11
|
+
console.error(chalk.green(`Deleting custom setting (${id}), please wait...`));
|
|
12
|
+
console.error();
|
|
13
|
+
const res = await postClass(
|
|
14
|
+
config.setupSvc + "/api/customsetting/deleteobj",
|
|
15
|
+
{ id },
|
|
16
|
+
config.accessToken
|
|
17
|
+
);
|
|
18
|
+
if (res && res.result) {
|
|
19
|
+
console.error(chalk.green("Success! Custom setting deleted."));
|
|
20
|
+
console.error();
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Delete Custom Setting Failed: " + (res?.returnInfo || res?.message || "Unknown error"));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = remove;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { getPackageJson } = require("../../utils/config");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
|
|
4
|
+
async function detail(projectPath = process.cwd(), id, isMcp = false) {
|
|
5
|
+
if (!id) {
|
|
6
|
+
throw new Error("Custom Setting detail requires id");
|
|
7
|
+
}
|
|
8
|
+
const config = await getPackageJson(projectPath);
|
|
9
|
+
const res = await postClass(
|
|
10
|
+
config.setupSvc + "/api/customsetting/detail",
|
|
11
|
+
{ id },
|
|
12
|
+
config.accessToken
|
|
13
|
+
);
|
|
14
|
+
if (res && res.result) {
|
|
15
|
+
const data = res.data || {};
|
|
16
|
+
if (!isMcp) {
|
|
17
|
+
console.log(JSON.stringify(data));
|
|
18
|
+
}
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
throw new Error("Get Custom Setting Detail Failed: " + (res?.returnInfo || res?.message || "Unknown error"));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = detail;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { getPackageJson } = require("../../utils/config");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
|
|
4
|
+
async function get(projectPath = process.cwd(), encodedCondJson, isMcp = false) {
|
|
5
|
+
let body = {};
|
|
6
|
+
if (encodedCondJson) {
|
|
7
|
+
body = JSON.parse(decodeURI(encodedCondJson));
|
|
8
|
+
}
|
|
9
|
+
const config = await getPackageJson(projectPath);
|
|
10
|
+
const res = await postClass(
|
|
11
|
+
config.setupSvc + "/api/customsetting/list",
|
|
12
|
+
body,
|
|
13
|
+
config.accessToken
|
|
14
|
+
);
|
|
15
|
+
if (res && res.result) {
|
|
16
|
+
const list = res?.data?.objList || [];
|
|
17
|
+
if (!isMcp) {
|
|
18
|
+
console.log(JSON.stringify(list));
|
|
19
|
+
}
|
|
20
|
+
return list;
|
|
21
|
+
}
|
|
22
|
+
throw new Error("Get Custom Setting Failed: " + (res?.returnInfo || res?.message || "Unknown error"));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = get;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
const { getPackageJson } = require("../../utils/config");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 删除字段(彻底删除)
|
|
7
|
+
* 用法:cc delete fields <projectPath> <fieldId> <objid>
|
|
8
|
+
*/
|
|
9
|
+
async function remove(argvs) {
|
|
10
|
+
const projectPath = argvs[2] || process.cwd();
|
|
11
|
+
const id = argvs[3];
|
|
12
|
+
const objid = argvs[4];
|
|
13
|
+
|
|
14
|
+
if (!id || !objid) {
|
|
15
|
+
console.error();
|
|
16
|
+
console.error(chalk.red("Error: fieldId and objid are required"));
|
|
17
|
+
console.error(chalk.yellow("Usage: cc delete fields <projectPath> <fieldId> <objid>"));
|
|
18
|
+
console.error();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const config = await getPackageJson(projectPath);
|
|
23
|
+
if (!config || !config.accessToken) {
|
|
24
|
+
console.error();
|
|
25
|
+
console.error(chalk.red("Error: Configuration not found or accessToken is missing"));
|
|
26
|
+
console.error();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.error();
|
|
31
|
+
console.error(chalk.green(`Deleting field (${id}) from object (${objid}), please wait...`));
|
|
32
|
+
console.error();
|
|
33
|
+
|
|
34
|
+
const res = await postClass(
|
|
35
|
+
config.setupSvc + "/api/fieldSetup/deleteFieldCompletely",
|
|
36
|
+
{ id, objid },
|
|
37
|
+
config.accessToken
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (res && res.result) {
|
|
41
|
+
console.error(chalk.green("Success! Field deleted."));
|
|
42
|
+
console.error();
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const errMsg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
|
|
47
|
+
console.error(chalk.red(`Fail: ${errMsg}`));
|
|
48
|
+
console.error();
|
|
49
|
+
throw new Error("Delete Field Failed: " + errMsg);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = remove;
|
package/src/fields/index.js
CHANGED
package/src/menu/create-page.js
CHANGED
|
@@ -11,22 +11,25 @@ const { buildCommonMenuFields } = require('./common');
|
|
|
11
11
|
*/
|
|
12
12
|
async function createPageMenu(argvs) {
|
|
13
13
|
try {
|
|
14
|
-
// 命令行参数格式:cc create menu page <path> <
|
|
15
|
-
// argvs: ['create', 'menu', 'page', '.', '
|
|
14
|
+
// 命令行参数格式:cc create menu page <path> <pageApi> <tabName> <pname> [tabStyle] [mobileimg] [cloudccservicetab] [mobileurl]
|
|
15
|
+
// argvs: ['create', 'menu', 'page', '.', 'contract-assistant', '标签名', '菜单名称', ...]
|
|
16
16
|
let path = argvs[3]; // 路径 (argvs[3])
|
|
17
|
-
let
|
|
17
|
+
let pageApi = argvs[4]; // 自定义页面 pageApi,例如 contract-assistant
|
|
18
18
|
let tabName = argvs[5]; // 标签名称
|
|
19
|
-
let
|
|
20
|
-
let
|
|
21
|
-
let
|
|
19
|
+
let pname = argvs[6]; // 菜单名称
|
|
20
|
+
let tabStyle = argvs[7] || "cloudtab145"; // 标签样式图标,默认 cloudtab145
|
|
21
|
+
let mobileimg = argvs[8] || "cloudcc01"; // 移动端图标,默认 cloudcc01
|
|
22
|
+
let cloudccservicetab = argvs[9] || "cloudccservicetab_1"; // 服务标签图标,默认 cloudccservicetab_1
|
|
23
|
+
let mobileurl = argvs[10] || ""; // 移动端地址,默认空字符串
|
|
22
24
|
|
|
23
|
-
if (!
|
|
25
|
+
if (!pageApi || !tabName || !pname) {
|
|
24
26
|
console.error();
|
|
25
27
|
console.error(chalk.red('Error: 缺少必需参数'));
|
|
26
|
-
console.error('用法: cc create menu page <path> <
|
|
28
|
+
console.error('用法: cc create menu page <path> <pageApi> <tabName> <pname> [tabStyle] [mobileimg] [cloudccservicetab] [mobileurl]');
|
|
27
29
|
console.error();
|
|
28
|
-
throw new Error('缺少必需参数:
|
|
30
|
+
throw new Error('缺少必需参数: pageApi、tabName 和 pname');
|
|
29
31
|
}
|
|
32
|
+
const lightningPage = pageApi.endsWith("#lightning") ? pageApi : `${pageApi}#lightning`;
|
|
30
33
|
|
|
31
34
|
let config = await getPackageJson(path);
|
|
32
35
|
|
|
@@ -54,22 +57,10 @@ async function createPageMenu(argvs) {
|
|
|
54
57
|
visited_2: "1",
|
|
55
58
|
allOrSome: "some",
|
|
56
59
|
type: "page",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
field: "Select",
|
|
62
|
-
required: "right",
|
|
63
|
-
hint: "label.customer.tab.step1.selectonepage",
|
|
64
|
-
rules: [
|
|
65
|
-
{
|
|
66
|
-
required: true,
|
|
67
|
-
message: "请选择页面",
|
|
68
|
-
trigger: "blur"
|
|
69
|
-
}
|
|
70
|
-
],
|
|
71
|
-
value: pageId
|
|
72
|
-
},
|
|
60
|
+
pageType: "customPage",
|
|
61
|
+
lightningPage: lightningPage,
|
|
62
|
+
mobileurl: mobileurl,
|
|
63
|
+
pname: pname,
|
|
73
64
|
...commonFields,
|
|
74
65
|
profileIds: profileIds,
|
|
75
66
|
};
|
package/src/menu/create.js
CHANGED
|
@@ -7,7 +7,9 @@ const createSiteMenu = require('./create-site');
|
|
|
7
7
|
/**
|
|
8
8
|
* 创建自定义菜单(标签页)
|
|
9
9
|
* 支持类型:object(自定义对象)、page(自定义页面)、script(自定义脚本)、site(站点)
|
|
10
|
-
* 命令格式:
|
|
10
|
+
* 命令格式:
|
|
11
|
+
* - object/script/site: cc create menu <type> <path> <resourceId> <tabName> [tabStyle] [mobileimg] [cloudccservicetab]
|
|
12
|
+
* - page: cc create menu page <path> <pageApi> <tabName> <pname> [tabStyle] [mobileimg] [cloudccservicetab] [mobileurl]
|
|
11
13
|
* @param {Array} argvs - 命令行参数数组
|
|
12
14
|
* @returns {Promise<Object>} 创建结果
|
|
13
15
|
*/
|
|
@@ -24,10 +26,14 @@ async function create(argvs) {
|
|
|
24
26
|
console.error();
|
|
25
27
|
console.error(chalk.red('Error: 无效的菜单类型'));
|
|
26
28
|
console.error(`支持的菜单类型: ${validTypes.join(', ')}`);
|
|
27
|
-
console.error('用法:
|
|
29
|
+
console.error('用法:');
|
|
30
|
+
console.error(' cc create menu object <path> <objectId> <tabName> [tabStyle] [mobileimg] [cloudccservicetab]');
|
|
31
|
+
console.error(' cc create menu page <path> <pageApi> <tabName> <pname> [tabStyle] [mobileimg] [cloudccservicetab] [mobileurl]');
|
|
32
|
+
console.error(' cc create menu script <path> <scriptId> <tabName> [tabStyle] [mobileimg] [cloudccservicetab]');
|
|
33
|
+
console.error(' cc create menu site <path> <siteId> <tabName> [tabStyle] [mobileimg] [cloudccservicetab]');
|
|
28
34
|
console.error('示例:');
|
|
29
35
|
console.error(' cc create menu object . <objectId> "我的对象菜单"');
|
|
30
|
-
console.error(' cc create menu page .
|
|
36
|
+
console.error(' cc create menu page . contract-assistant "我的页面标签" my_page_menu');
|
|
31
37
|
console.error(' cc create menu script . <scriptId> "我的脚本菜单"');
|
|
32
38
|
console.error(' cc create menu site . <siteId> "我的站点菜单"');
|
|
33
39
|
console.error();
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
const { getPackageJson } = require("../../utils/config");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 删除自定义菜单(标签页)
|
|
7
|
+
* 用法:cc delete menu <projectPath> <tabId>
|
|
8
|
+
*/
|
|
9
|
+
async function remove(argvs) {
|
|
10
|
+
try {
|
|
11
|
+
const projectPath = argvs[2] || process.cwd();
|
|
12
|
+
const tabId = argvs[3];
|
|
13
|
+
|
|
14
|
+
if (!tabId) {
|
|
15
|
+
console.error();
|
|
16
|
+
console.error(chalk.red("Error: 缺少菜单 ID"));
|
|
17
|
+
console.error(chalk.yellow("用法: cc delete menu <projectPath> <tabId>"));
|
|
18
|
+
console.error();
|
|
19
|
+
throw new Error("缺少必需参数: tabId");
|
|
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 menu (${tabId}), please wait...`));
|
|
32
|
+
console.error();
|
|
33
|
+
|
|
34
|
+
const result = await postClass(
|
|
35
|
+
config.setupSvc + "/api/customTab/deleteTab",
|
|
36
|
+
{ id: tabId },
|
|
37
|
+
config.accessToken
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
if (result && result.result) {
|
|
41
|
+
console.error();
|
|
42
|
+
console.error(chalk.green("Success! Menu deleted."));
|
|
43
|
+
console.error();
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const msg = result && (result.returnInfo || result.message) ? (result.returnInfo || result.message) : "Unknown error";
|
|
48
|
+
console.error();
|
|
49
|
+
console.error(chalk.red("Error: " + msg));
|
|
50
|
+
console.error();
|
|
51
|
+
throw new Error("Delete Menu Failed: " + msg);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error();
|
|
54
|
+
console.error(chalk.red("菜单删除失败:"), error);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = remove;
|
package/src/menu/get.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { postClass } = require("../../utils/http");
|
|
2
|
+
const { getPackageJson } = require("../../utils/config");
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 查询自定义菜单(标签页)列表
|
|
6
|
+
* 用法:cc get menu <projectPath> [encodedCondJson]
|
|
7
|
+
*/
|
|
8
|
+
async function get(argvs, isMcp = false) {
|
|
9
|
+
const projectPath = argvs[2] || process.cwd();
|
|
10
|
+
const condArg = argvs[3];
|
|
11
|
+
|
|
12
|
+
let body = {};
|
|
13
|
+
if (condArg) {
|
|
14
|
+
try {
|
|
15
|
+
body = JSON.parse(decodeURI(condArg));
|
|
16
|
+
} catch (e) {
|
|
17
|
+
throw new Error("Get Menu Failed: encodedCondJson 解析失败,请传 encodeURI(JSON.stringify(...))");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const config = await getPackageJson(projectPath);
|
|
22
|
+
const res = await postClass(
|
|
23
|
+
config.setupSvc + "/api/customTab/queryTabList",
|
|
24
|
+
body,
|
|
25
|
+
config.accessToken
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (res && res.result) {
|
|
29
|
+
const data = res.data;
|
|
30
|
+
let rawList = [];
|
|
31
|
+
if (Array.isArray(data)) {
|
|
32
|
+
rawList = data;
|
|
33
|
+
} else if (data && Array.isArray(data.list)) {
|
|
34
|
+
rawList = data.list;
|
|
35
|
+
} else if (data && typeof data === "object") {
|
|
36
|
+
// 兼容 queryTabList 返回的分组结构:botlist/objectlist/objlist/pagelist/scriptlist...
|
|
37
|
+
rawList = Object.keys(data)
|
|
38
|
+
.filter((key) => /list$/i.test(key) && Array.isArray(data[key]))
|
|
39
|
+
.flatMap((key) =>
|
|
40
|
+
data[key].map((item) => ({
|
|
41
|
+
...item,
|
|
42
|
+
__group: key
|
|
43
|
+
}))
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (!isMcp) {
|
|
47
|
+
console.log(JSON.stringify(rawList));
|
|
48
|
+
}
|
|
49
|
+
return rawList;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const msg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
|
|
53
|
+
throw new Error("Get Menu Failed: " + msg);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = get;
|
package/src/menu/index.js
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const chalk = require("chalk");
|
|
2
|
+
const { postClass } = require("../../utils/http");
|
|
3
|
+
const { getPackageJson } = require("../../utils/config");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 删除自定义对象
|
|
7
|
+
* 用法:cc delete object <projectPath> <objid>
|
|
8
|
+
*/
|
|
9
|
+
async function remove(argvs) {
|
|
10
|
+
const projectPath = argvs[2] || process.cwd();
|
|
11
|
+
const objid = argvs[3];
|
|
12
|
+
|
|
13
|
+
if (!objid) {
|
|
14
|
+
console.error();
|
|
15
|
+
console.error(chalk.red("Error: objid is required"));
|
|
16
|
+
console.error(chalk.yellow("Usage: cc delete object <projectPath> <objid>"));
|
|
17
|
+
console.error();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const config = await getPackageJson(projectPath);
|
|
22
|
+
if (!config || !config.accessToken) {
|
|
23
|
+
console.error();
|
|
24
|
+
console.error(chalk.red("Error: Configuration not found or accessToken is missing"));
|
|
25
|
+
console.error();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.error();
|
|
30
|
+
console.error(chalk.green(`Deleting custom object (${objid}), please wait...`));
|
|
31
|
+
console.error();
|
|
32
|
+
|
|
33
|
+
const res = await postClass(
|
|
34
|
+
config.setupSvc + "/api/customObject/deleteLogic",
|
|
35
|
+
{ objid },
|
|
36
|
+
config.accessToken
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (res && res.result) {
|
|
40
|
+
console.error(chalk.green("Success! Custom object deleted."));
|
|
41
|
+
console.error();
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const errMsg = res && (res.returnInfo || res.message) ? (res.returnInfo || res.message) : "Unknown error";
|
|
46
|
+
console.error(chalk.red(`Fail: ${errMsg}`));
|
|
47
|
+
console.error();
|
|
48
|
+
throw new Error("Delete Custom Object Failed: " + errMsg);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = remove;
|