cloudcc-cli 2.2.3 → 2.2.4

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 (174) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/README.md +35 -0
  3. package/bin/cc.js +11 -36
  4. package/bin/index.js +33 -0
  5. package/bin/mcp-svc.js +13 -0
  6. package/java/com/cloudcc/core/TriggerInvoker.java +17 -1
  7. package/package.json +3 -2
  8. package/pom.xml +1 -0
  9. package/prompt/DevelopmentEnvironmentConstruction.ts +133 -0
  10. package/prompt/ccdk.ts +1190 -0
  11. package/prompt/ccprompt.ts +8 -0
  12. package/prompt/cloudccdev.ts +109 -0
  13. package/prompt/index.ts +52 -0
  14. package/prompt/objectInfo.ts +94 -0
  15. package/prompt/objectList.ts +25 -0
  16. package/prompt/openapi.ts +310 -0
  17. package/prompt/system.ts +14 -0
  18. package/prompt/vscodeExtension.ts +27 -0
  19. package/src/approval/approve.js +105 -0
  20. package/src/approval/get.js +245 -0
  21. package/src/approval/index.js +11 -0
  22. package/src/approval/reject.js +105 -0
  23. package/src/brief/get.js +51 -0
  24. package/src/brief/index.js +7 -0
  25. package/src/config/get.js +1 -1
  26. package/src/fields/create.js +204 -0
  27. package/src/fields/fields/A.js +23 -0
  28. package/src/fields/fields/AD.js +25 -0
  29. package/src/fields/fields/B.js +28 -0
  30. package/src/fields/fields/C.js +28 -0
  31. package/src/fields/fields/D.js +27 -0
  32. package/src/fields/fields/E.js +28 -0
  33. package/src/fields/fields/ENC.js +28 -0
  34. package/src/fields/fields/ENCD.js +28 -0
  35. package/src/fields/fields/F.js +27 -0
  36. package/src/fields/fields/FL.js +25 -0
  37. package/src/fields/fields/H.js +27 -0
  38. package/src/fields/fields/IMG.js +27 -0
  39. package/src/fields/fields/J.js +26 -0
  40. package/src/fields/fields/L.js +32 -0
  41. package/src/fields/fields/LT.js +28 -0
  42. package/src/fields/fields/M.js +29 -0
  43. package/src/fields/fields/MR.js +24 -0
  44. package/src/fields/fields/N.js +30 -0
  45. package/src/fields/fields/P.js +28 -0
  46. package/src/fields/fields/Q.js +35 -0
  47. package/src/fields/fields/S.js +30 -0
  48. package/src/fields/fields/SCORE.js +24 -0
  49. package/src/fields/fields/T.js +27 -0
  50. package/src/fields/fields/U.js +28 -0
  51. package/src/fields/fields/X.js +28 -0
  52. package/src/fields/fields/Y.js +33 -0
  53. package/src/fields/get.js +36 -0
  54. package/src/fields/index.js +9 -0
  55. package/src/mcp/MCP/345/234/272/346/231/257/346/250/241/346/213/237.md +8 -0
  56. package/src/mcp/index-sse-svc.js +126 -0
  57. package/src/mcp/index-streamable-svc.js +180 -0
  58. package/src/mcp/index.js +519 -115
  59. package/src/mcp/readme.md +75 -70
  60. package/src/mcp/tools/Approval/handler.js +349 -0
  61. package/src/mcp/tools/Class Creator/handler.js +37 -0
  62. package/src/mcp/tools/Class Detail Retriever/handler.js +33 -0
  63. package/src/mcp/tools/Class Detail Retriever/prompt.js +37 -0
  64. package/src/mcp/tools/Class Editor Guide/handler.js +72 -0
  65. package/src/mcp/tools/Class Editor Guide/prompt.js +468 -0
  66. package/src/mcp/tools/Class List Retriever/handler.js +36 -0
  67. package/src/mcp/tools/Class Publisher/handler.js +29 -0
  68. package/src/mcp/tools/Class Publisher/prompt.js +40 -0
  69. package/src/mcp/tools/Class Puller/handler.js +86 -0
  70. package/src/mcp/tools/Class Puller/prompt.js +49 -0
  71. package/src/mcp/tools/Client Script Creator/handler.js +179 -0
  72. package/src/mcp/tools/Client Script Detail Retriever/handler.js +53 -0
  73. package/src/mcp/tools/Client Script Editor Guide/handler.js +633 -0
  74. package/src/mcp/tools/Client Script List Retriever/handler.js +68 -0
  75. package/src/mcp/tools/Client Script Publisher/handler.js +54 -0
  76. package/src/mcp/tools/Client Script Puller/handler.js +73 -0
  77. package/src/mcp/tools/CloudCC Development Overview/handler.js +48 -0
  78. package/src/mcp/tools/CloudCC Development Overview/prompt.js +870 -0
  79. package/src/mcp/tools/Component Creator/handler.js +44 -0
  80. package/src/mcp/tools/Component Detail Retriever/handler.js +38 -0
  81. package/src/mcp/tools/Component Editor Guide/handler.js +76 -0
  82. package/src/mcp/tools/Component Editor Guide/prompt.js +519 -0
  83. package/src/mcp/tools/Component List Retriever/handler.js +43 -0
  84. package/src/mcp/tools/Component Publisher/handler.js +18 -0
  85. package/src/mcp/tools/Component Puller/handler.js +63 -0
  86. package/src/mcp/tools/{dev-env/fetcher.js → Dev Environment Creator/fetcher.js } +8 -8
  87. package/src/mcp/tools/{dev-env/prompt.js → Dev Environment Creator/prompt.js } +19 -2
  88. package/src/mcp/tools/Dev Environment Validator/handler.js +88 -0
  89. package/src/mcp/tools/Dev Environment Validator/prompt.js +193 -0
  90. package/src/mcp/tools/{key-guide/fetcher.js → Developer Key Setup Guide/fetcher.js } +7 -7
  91. package/src/mcp/tools/{key-guide/prompt.js → Developer Key Setup Guide/prompt.js } +3 -3
  92. package/src/mcp/tools/Object Creator/handler.js +34 -0
  93. package/src/mcp/tools/Object Fields Creator/handler.js +64 -0
  94. package/src/mcp/tools/Object Fields Retriever/handler.js +37 -0
  95. package/src/mcp/tools/Object Fields Retriever/prompt.js +10 -0
  96. package/src/mcp/tools/Object List Retriever/handler.js +43 -0
  97. package/src/mcp/tools/Object List Retriever/prompt.js +10 -0
  98. package/src/mcp/tools/Scheduled Class Creator/handler.js +37 -0
  99. package/src/mcp/tools/Scheduled Class Detail Retriever/handler.js +34 -0
  100. package/src/mcp/tools/Scheduled Class List Retriever/handler.js +52 -0
  101. package/src/mcp/tools/Scheduled Class Publisher/handler.js +30 -0
  102. package/src/mcp/tools/Scheduled Class Puller/handler.js +92 -0
  103. package/src/mcp/tools/Trigger Creator/handler.js +53 -0
  104. package/src/mcp/tools/Trigger Detail Retriever/handler.js +33 -0
  105. package/src/mcp/tools/Trigger Editor Guide/handler.js +58 -0
  106. package/src/mcp/tools/Trigger List Retriever/handler.js +49 -0
  107. package/src/mcp/tools/Trigger Publisher/handler.js +34 -0
  108. package/src/mcp/tools/Trigger Puller/handler.js +40 -0
  109. package/src/mcp/tools/ccdk/fetcher.js +3 -3
  110. package/src/mcp/tools/ccdk/prompt.js +2 -2
  111. package/src/mcp/tools/index.js +23 -0
  112. package/src/object/create.js +105 -0
  113. package/src/object/get.js +43 -4
  114. package/src/object/index.js +2 -1
  115. package/src/plugin/create1.js +8 -7
  116. package/src/plugin/detail.js +91 -0
  117. package/src/plugin/get.js +79 -0
  118. package/src/plugin/index.js +4 -1
  119. package/src/plugin/publish.js +13 -13
  120. package/src/plugin/publish1.js +30 -22
  121. package/src/plugin/pull.js +173 -0
  122. package/src/project/create.js +9 -9
  123. package/src/project/create1.js +31 -17
  124. package/src/recordType/get.js +4 -2
  125. package/src/script/create.js +7 -7
  126. package/src/script/detail.js +95 -0
  127. package/src/script/get.js +4 -2
  128. package/src/script/index.js +1 -0
  129. package/src/script/publish.js +14 -14
  130. package/src/script/pull.js +12 -12
  131. package/src/script/pullList.js +5 -3
  132. package/src/timer/create.js +7 -7
  133. package/src/timer/detail.js +84 -0
  134. package/src/timer/get.js +6 -3
  135. package/src/timer/publish.js +7 -7
  136. package/src/timer/pull.js +8 -8
  137. package/src/timer/pullList.js +5 -3
  138. package/src/token/get.js +1 -1
  139. package/src/triggers/create.js +7 -7
  140. package/src/triggers/detail.js +90 -0
  141. package/src/triggers/get.js +4 -2
  142. package/src/triggers/index.js +1 -0
  143. package/src/triggers/publish.js +7 -7
  144. package/src/triggers/pull.js +8 -8
  145. package/src/triggers/pullList.js +5 -3
  146. package/src/version/get.js +3 -3
  147. package/target/ccopenapi-0.0.3-classes.jar +0 -0
  148. package/target/ccopenapi-0.0.3.jar +0 -0
  149. package/target/maven-archiver/pom.properties +3 -0
  150. package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +18 -0
  151. package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +19 -0
  152. package/template/Appvue +2 -2
  153. package/template/index.js +30 -19
  154. package/tool/branch/index.js +1 -1
  155. package/tool/checkLange/checkLang.js +6 -6
  156. package/tool/checkLange/clearLang.js +1 -1
  157. package/utils/accessClass.js +23 -0
  158. package/utils/checkVersion.js +22 -20
  159. package/utils/config.js +18 -3
  160. package/utils/http.js +10 -10
  161. package/utils/utils.js +97 -32
  162. package/java/com/cloudcc/core/CCTriggerDemo.java +0 -25
  163. package/src/classes/create.js +0 -66
  164. package/src/classes/get.js +0 -22
  165. package/src/classes/index.js +0 -11
  166. package/src/classes/publish.js +0 -51
  167. package/src/classes/pull.js +0 -55
  168. package/src/classes/pullList.js +0 -44
  169. package/src/mcp/tools/classes/handler.js +0 -358
  170. package/src/mcp/tools/classes/prompt.js +0 -1261
  171. package/src/mcp/tools/plugin/handler.js +0 -92
  172. /package/src/mcp/tools/{plugin → Component Publisher}/prompt.js +0 -0
  173. /package/src/mcp/tools/{dev-env → Dev Environment Creator}/handler.js +0 -0
  174. /package/src/mcp/tools/{key-guide → Developer Key Setup Guide}/handler.js +0 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 注册所有 MCP 工具到服务器实例
3
+ * @param {McpServer} mcpServerInstance - MCP 服务器实例
4
+ */
5
+ function registerAllTools(mcpServerInstance) {
6
+ // ==================== Approval 审批工具 ====================
7
+ const approvalHandler = require('./Approval/handler.js');
8
+ approvalHandler.toolDefinitions.forEach(tool => {
9
+ mcpServerInstance.registerTool(
10
+ tool.name,
11
+ {
12
+ description: tool.description,
13
+ inputSchema: tool.inputSchema
14
+ },
15
+ tool.handler
16
+ );
17
+ });
18
+ }
19
+
20
+ module.exports = {
21
+ registerAllTools
22
+ };
23
+
@@ -0,0 +1,105 @@
1
+ const { postClass } = require("../../utils/http")
2
+ const { getPackageJson } = require("../../utils/config");
3
+ const briefGet = require("../brief/get");
4
+ const { labelToSlug } = require("../../utils/utils");
5
+ const chalk = require('chalk')
6
+
7
+ /**
8
+ * 将 label 转换为英文可用的 slug,用于生成 schemetableName
9
+ * 优先尝试使用 pinyin 包(如果安装),否则使用宽松的 ASCII slug 方案
10
+ */
11
+ // labelToSlug now lives in utils/utils.js
12
+
13
+
14
+ /**
15
+ * 保存自定义对象按钮配置
16
+ * @param {Array} argvs - 命令行参数数组
17
+ * @returns {Promise<Object>} 保存结果
18
+ */
19
+ async function create(argvs) {
20
+ try {
21
+ let path = argvs[2];
22
+ // 兼容两种调用方式:
23
+ // 1) cc object create <path> <nameLabel> <label>
24
+ // 2) cc object create <path> <label> (此时自动生成 nameLabel)
25
+ let label = argvs[3];
26
+ let nameLabel = argvs[4];
27
+ if (nameLabel == undefined) {
28
+ const slug = labelToSlug(label);
29
+ nameLabel = `${slug}_custom_object`;
30
+ }
31
+ let config = await getPackageJson(path);
32
+
33
+ // 从 brief/get 获取角色ID列表(仍使用原始 argv 参数: path 位于 argvs[2])
34
+ // 注意:brief/get 的接口返回是 { success, data } 的格式
35
+ let briefData = await briefGet(argvs);
36
+
37
+ if (!briefData.success) {
38
+ console.error("获取角色列表失败:", briefData.message);
39
+ throw new Error("获取角色列表失败");
40
+ }
41
+
42
+ // 提取所有角色的 ID 列表
43
+ const profileIdList = briefData.data.map(profile => profile.id);
44
+
45
+ // 构建 profileFieldArr,为每个 profileid 创建权限配置
46
+ const profileFieldArr = profileIdList.map((profileid) => {
47
+ // 第一个角色拥有所有权限(6个1),其余角色只有前4个权限
48
+ const isFirstProfile = profileIdList.indexOf(profileid) === 0;
49
+ const permission = isFirstProfile ? "1,1,1,1,1,1" : "1,1,1,1,0,0";
50
+
51
+ return {
52
+ profileid: profileid,
53
+ permission: permission
54
+ };
55
+ });
56
+
57
+ // 构建请求体
58
+ const requestBody = {
59
+ iscreatperm: "true",
60
+ profileFieldArr: profileFieldArr,
61
+ nameLabel: nameLabel,
62
+ obj: {
63
+ label: label,
64
+ schemetableName: nameLabel,
65
+ dataType: "V",
66
+ showFormat: "{yyyy}{mm}{dd}{000}",
67
+ beginIndex: "0",
68
+ isquickcreated: "false",
69
+ islbs: "false",
70
+ isreportcreated: "false"
71
+ }
72
+ };
73
+
74
+ // 显示创建进度
75
+ console.error();
76
+ console.error(chalk.green('Creating, please wait...'));
77
+ console.error();
78
+ // 发送请求到服务器
79
+ const result = await postClass(
80
+ config.setupSvc + "/api/customObject/saveButton",
81
+ requestBody,
82
+ config.accessToken
83
+ );
84
+ // API 返回结构中, result 字段决定调用是否成功
85
+ if (result && result.result) {
86
+ console.error();
87
+ console.error(chalk.green('Success!'));
88
+ console.error();
89
+ return result;
90
+ } else {
91
+ const msg = result && result.returnInfo ? result.returnInfo : 'Unknown error';
92
+ console.error();
93
+ console.error(chalk.red('Error:' + msg));
94
+ throw new Error('Create Custom Object Failed: ' + msg);
95
+ }
96
+ } catch (error) {
97
+ console.error();
98
+ console.error(chalk.red("自定义对象创建失败:"), error);
99
+ throw error;
100
+ }
101
+ }
102
+
103
+ module.exports = create;
104
+
105
+
package/src/object/get.js CHANGED
@@ -1,7 +1,10 @@
1
1
  const { postClass } = require("../../utils/http")
2
2
  const { getPackageJson } = require("../../utils/config")
3
3
 
4
- async function get(path, type, object) {
4
+ async function get(argvs, isMcp = false) {
5
+ let path = argvs[2]
6
+ let type = argvs[3]
7
+ let object = argvs[4]
5
8
  let res = [];
6
9
  let config = await getPackageJson(path);
7
10
  if ("fields" === type) {
@@ -9,10 +12,20 @@ async function get(path, type, object) {
9
12
  let fieldsResults = await postClass(config.setupSvc + "/api/fieldSetup/queryField", { prefix: object.objprefix }, config.accessToken)
10
13
  res = {
11
14
  ...object,
12
- fields: fieldsResults.data.stdFields.map((field) => {
15
+ stdFields: fieldsResults.data.stdFields.map((field) => {
13
16
  return {
14
17
  fieldname: field.labelName,
15
- apiname: field.schemefieldName
18
+ apiname: field.schemefieldName,
19
+ schemefieldType: field.schemefieldType,
20
+ id: field.id
21
+ }
22
+ }),
23
+ cusFields: fieldsResults.data.cusFields.map((field) => {
24
+ return {
25
+ fieldname: field.labelName,
26
+ apiname: field.schemefieldName,
27
+ schemefieldType: field.schemefieldType,
28
+ id: field.id
16
29
  }
17
30
  })
18
31
  }
@@ -47,6 +60,30 @@ async function get(path, type, object) {
47
60
  })
48
61
  })
49
62
 
63
+ } else if ("standard" === type) {
64
+ // get standard object only
65
+ let standardObjList = await postClass(config.setupSvc + "/api/customObject/standardObjList", {}, config.accessToken)
66
+ standardObjList.data.forEach((item) => {
67
+ res.push({
68
+ id: item.id,
69
+ label: item.objname,
70
+ objname: item.label,
71
+ objprefix: item.objprefix,
72
+ schemetableName: item.label
73
+ })
74
+ })
75
+ } else if ("custom" === type) {
76
+ // get custom object only
77
+ let customObjList = await postClass(config.setupSvc + "/api/customObject/list", {}, config.accessToken)
78
+ customObjList.data.objList.map((item) => {
79
+ res.push({
80
+ id: item.id,
81
+ label: item.objLabel,
82
+ objname: item.schemetable_name,
83
+ objprefix: item.prefix,
84
+ schemetableName: item.schemetableName
85
+ })
86
+ })
50
87
  } else {
51
88
  //get standar object
52
89
  let standardObjList = await postClass(config.setupSvc + "/api/customObject/standardObjList", {}, config.accessToken)
@@ -71,7 +108,9 @@ async function get(path, type, object) {
71
108
  })
72
109
  })
73
110
  }
74
- console.log(JSON.stringify(res));
111
+ if (!isMcp) {
112
+ console.log(JSON.stringify(res));
113
+ }
75
114
  return res
76
115
  }
77
116
 
@@ -1,7 +1,8 @@
1
1
  const cc = {}
2
2
  cc.get = require("./get")
3
+ cc.create = require("./create")
3
4
  function main(action, argvs) {
4
- cc[action](argvs[2], argvs[3], argvs[4])
5
+ cc[action](argvs)
5
6
  }
6
7
 
7
8
  module.exports = main;
@@ -6,7 +6,8 @@ const chalk = require("chalk")
6
6
 
7
7
 
8
8
 
9
- async function create(name) {
9
+ async function create(argvs) {
10
+ const name = argvs[2];
10
11
  const temp = `<template>
11
12
  <div class="cc-container">
12
13
  <HelloWorld />
@@ -62,13 +63,13 @@ export default {};
62
63
  fs.mkdirSync(path.join(pluginPath, "components"), { recursive: true })
63
64
  fs.writeFileSync(path.join(pluginPath, "components", "HelloWorld.vue"), temp1)
64
65
  fs.writeFileSync(path.join(pluginPath, "config.json"), `{"component":"component-${name}","compName":"compName-${name}","compDesc":"Component description information"}`)
65
- console.log()
66
- console.log(chalk.green("Successfully Created:" + name))
67
- console.log()
66
+ console.error()
67
+ console.error(chalk.green("Successfully Created:" + name))
68
+ console.error()
68
69
  } catch (e) {
69
- console.log()
70
- console.log(chalk.red("Creation Failed:" + e))
71
- console.log()
70
+ console.error()
71
+ console.error(chalk.red("Creation Failed:" + e))
72
+ console.error()
72
73
  }
73
74
  }
74
75
  }
@@ -0,0 +1,91 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { getPackageJson } = require("../../utils/config");
4
+ const { post } = require("../../utils/http");
5
+ const BaseUrl = "https://developer.apis.cloudcc.cn";
6
+
7
+ /**
8
+ * 获取自定义组件详情
9
+ * - 如果提供了 pluginName,从本地查询
10
+ * - 如果提供了 pluginId,从线上查询
11
+ * - 如果都没有,返回错误
12
+ */
13
+ async function detail(argvs) {
14
+ const pluginName = argvs[2];
15
+ const pluginId = argvs[3];
16
+ const projectPath = argvs[4] || process.cwd();
17
+
18
+ // 如果提供了 pluginName,从本地查询
19
+ if (pluginName && pluginName !== '') {
20
+ const pluginPath = path.join(projectPath, `plugins/${pluginName}/`);
21
+ const configPath = path.join(pluginPath, 'config.json');
22
+ const vueFilePath = path.join(pluginPath, `${pluginName}.vue`);
23
+
24
+ // 检查本地文件是否存在
25
+ if (!fs.existsSync(configPath) || !fs.existsSync(vueFilePath)) {
26
+ throw new Error(`Plugin not found in local directory: ${pluginPath}`);
27
+ }
28
+
29
+ try {
30
+ const configContent = JSON.parse(fs.readFileSync(configPath, 'utf8'));
31
+ const vueContent = fs.readFileSync(vueFilePath, 'utf8');
32
+
33
+ return {
34
+ name: pluginName,
35
+ component: configContent.component || `component-${pluginName}`,
36
+ compName: configContent.compName || pluginName,
37
+ compDesc: configContent.compDesc || '',
38
+ id: configContent.id || null,
39
+ source: vueContent,
40
+ config: configContent,
41
+ published: !!configContent.id,
42
+ fromLocal: true
43
+ };
44
+ } catch (e) {
45
+ throw new Error(`Failed to read plugin files: ${e.message}`);
46
+ }
47
+ }
48
+
49
+ // 如果提供了 pluginId,从线上查询
50
+ if (pluginId && pluginId !== '') {
51
+ try {
52
+ const config = await getPackageJson(projectPath);
53
+ if (!config || !config.accessToken) {
54
+ throw new Error('Configuration not found or accessToken is missing');
55
+ }
56
+
57
+ const devSvcDispatch = config.devSvcDispatch || '/devconsole';
58
+ const baseUrl = config.baseUrl || BaseUrl;
59
+ const header = {
60
+ "appType": "lightning-setup",
61
+ "appVersion": "0.0.1",
62
+ "accessToken": config.accessToken,
63
+ "source": "lightning-setup",
64
+ "version": "public"
65
+ };
66
+ const body = {
67
+ "id": pluginId
68
+ };
69
+ const res = await post(
70
+ `${baseUrl}${devSvcDispatch}/custom/pc/1.0/post/detailCustomComp`,
71
+ body,
72
+ header
73
+ );
74
+ if (res && res.returnCode == 200 && res.data) {
75
+ return {
76
+ ...res.data,
77
+ fromLocal: false
78
+ };
79
+ } else {
80
+ throw new Error('Get Plugin Details Failed: ' + (res?.returnInfo || 'Unknown error'));
81
+ }
82
+ } catch (error) {
83
+ throw new Error('Get Plugin Details Failed: ' + error.message);
84
+ }
85
+ }
86
+
87
+ // 既没有 pluginName 也没有 pluginId,报错
88
+ throw new Error('Either plugin name or id must be provided');
89
+ }
90
+
91
+ module.exports = detail;
@@ -0,0 +1,79 @@
1
+ const { post } = require("../../utils/http");
2
+ const { getPackageJson } = require("../../utils/config");
3
+ const BaseUrl = "https://developer.apis.cloudcc.cn";
4
+
5
+ /**
6
+ * 获取自定义组件列表(仅从线上获取)
7
+ */
8
+ async function get(argvs, isMcp = false) {
9
+ const projectPath = argvs[2];
10
+ try {
11
+ const devConsoleConfig = await getPackageJson(projectPath);
12
+ console.error("devConsoleConfig.accessToken", devConsoleConfig);
13
+ if (!devConsoleConfig) {
14
+ throw new Error('Configuration not found');
15
+ }
16
+
17
+ // 设置请求头
18
+ const devSvcDispatch = devConsoleConfig.devSvcDispatch || '/devconsole';
19
+ const baseUrl = devConsoleConfig.baseUrl || BaseUrl;
20
+
21
+ // 构建请求体(分页参数)
22
+ const body = {
23
+ "pageNo": 1,
24
+ "pageSize": 2000,
25
+ "condition": {
26
+ "compName": "",
27
+ "dtBegin": "",
28
+ "dtEnd": ""
29
+ }
30
+ }
31
+ const header = {
32
+ "appType": "lightning-setup",
33
+ "appVersion": "0.0.1",
34
+ "accessToken": devConsoleConfig.accessToken,
35
+ "source": "lightning-setup",
36
+ "version": "public"
37
+ };
38
+ // 调用接口获取组件列表
39
+ const res = await post(`${baseUrl}${devSvcDispatch}/custom/pc/1.0/post/pageCustomComp`, body, header);
40
+ if (res.returnCode == 200 && res.data && res.data.list) {
41
+ // 映射服务器数据
42
+ const plugins = res.data.list.map(item => ({
43
+ name: item.compUniName || item.name,
44
+ component: item.compUniName || item.component,
45
+ compName: item.compLabel || item.compName,
46
+ compDesc: item.compDesc || '',
47
+ id: item.id,
48
+ version: item.version || null,
49
+ category: item.category || null,
50
+ bizType: item.bizType || null,
51
+ createBy: item.createBy || null,
52
+ createDate: item.createDate || null,
53
+ lastModifyBy: item.lastModifyBy || null,
54
+ lastModifyDate: item.lastModifyDate || null,
55
+ orgId: item.orgId || null,
56
+ orgName: item.orgName || null,
57
+ isEnabled: item.isEnabled !== undefined ? item.isEnabled : null,
58
+ isDeleted: item.isDeleted !== undefined ? item.isDeleted : null,
59
+ disableReason: item.disableReason || null,
60
+ belongOrgFlag: item.belongOrgFlag || null,
61
+ loadModel: item.loadModel || null,
62
+ apiName: item.apiName || null,
63
+ vueData: item.vueData || null,
64
+ fromLocal: false
65
+ }));
66
+ if (!isMcp) {
67
+ console.log(JSON.stringify(plugins));
68
+ }
69
+ return plugins;
70
+ } else {
71
+ throw new Error(res.returnInfo || 'Failed to get plugin list');
72
+ }
73
+ } catch (error) {
74
+ console.error('Get Plugin List Failed:', error.message);
75
+ throw new Error('Get Plugin List Failed: ' + error.message);
76
+ }
77
+ }
78
+
79
+ module.exports = get;
@@ -1,8 +1,11 @@
1
1
  const cc = {}
2
2
  cc.create = require("./create1")
3
3
  cc.publish = require("./publish1")
4
+ cc.get = require("./get")
5
+ cc.detail = require("./detail")
6
+ cc.pull = require("./pull")
4
7
  function Plugin(action, argvs) {
5
- cc[action](argvs[2])
8
+ cc[action](argvs)
6
9
  }
7
10
 
8
11
  module.exports = Plugin;
@@ -84,9 +84,9 @@ class Builder {
84
84
 
85
85
  if (!vueContent.includes("scoped")) {
86
86
 
87
- console.log()
88
- console.log(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
89
- console.log()
87
+ console.error()
88
+ console.error(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
89
+ console.error()
90
90
  }
91
91
 
92
92
  vueData = vueData.split(/data\s*\(\s*\)/)[1].split(/isLock\s*:/)[0] + "isLock:false,};}";
@@ -208,15 +208,15 @@ class Builder {
208
208
 
209
209
 
210
210
  build(obj, config, plginTemp) {
211
- console.log(chalk.green('Compiling, Please Wait...'));
211
+ console.error(chalk.green('Compiling, Please Wait...'));
212
212
  exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugin/${plginTemp}.js`, async (error, stdout, stderr) => {
213
213
  if (error) {
214
- console.log('Compilation Failed:', error);
215
- console.log(chalk.red('Compilation Failed:' + stdout));
214
+ console.error('Compilation Failed:', error);
215
+ console.error(chalk.red('Compilation Failed:' + stdout));
216
216
  return;
217
217
  } else {
218
- console.log(chalk.green('Compilation Successful!'));
219
- console.log();
218
+ console.error(chalk.green('Compilation Successful!'));
219
+ console.error();
220
220
  await this.upload(obj, config)
221
221
  fs.unlinkSync(`plugin/${plginTemp}.js`);
222
222
  }
@@ -226,8 +226,8 @@ class Builder {
226
226
  async upload(obj, header) {
227
227
  const now = new Date();
228
228
  const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
229
- console.log(chalk.green(timeStr));
230
- console.log(chalk.green('Posting, please wait...'));
229
+ console.error(chalk.green(timeStr));
230
+ console.error(chalk.green('Posting, please wait...'));
231
231
  let jsContent = "";
232
232
  try {
233
233
  jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
@@ -253,11 +253,11 @@ class Builder {
253
253
  body, header);
254
254
  if (res.returnCode == 200) {
255
255
  console.error(chalk.green(`Success!`));
256
- console.log();
256
+ console.error();
257
257
  } else {
258
- console.log("res", res);
258
+ console.error("res", res);
259
259
  console.error(chalk.red(`Fail: ${res.returnInfo}`));
260
- console.log();
260
+ console.error();
261
261
  }
262
262
  return res;
263
263
  }
@@ -21,7 +21,8 @@ class Builder {
21
21
  }
22
22
  this.plugin = process.argv.splice(2)[0]
23
23
  }
24
- async publish(name) {
24
+ async publish(argvs) {
25
+ const name = argvs[2];
25
26
  let res = await checkUpdate();
26
27
  if (!res) {
27
28
  this.options.devConsoleConfig = await getPackageJson();
@@ -40,14 +41,14 @@ class Builder {
40
41
  let item = dirs[i]
41
42
  let obj = this.getVueValue(item);
42
43
  if (obj) {
43
- this.initPluginFile(item, obj.component, "plginTemp" + i);
44
+ this.initPluginFile(item, obj, "plginTemp" + i);
44
45
  this.build(obj, config, "plginTemp" + i)
45
46
  }
46
47
  }
47
48
  } else {
48
49
  let obj = this.getVueValue(answers.buildFileName);
49
50
  if (obj) {
50
- this.initPluginFile(answers.buildFileName, obj.component, "plginTemp");
51
+ this.initPluginFile(answers.buildFileName, obj, "plginTemp");
51
52
  this.build(obj, config, "plginTemp")
52
53
  }
53
54
  }
@@ -83,9 +84,9 @@ class Builder {
83
84
  let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
84
85
  let vueData = vueContent + ""
85
86
  if (!vueContent.includes("scoped")) {
86
- console.log()
87
- console.log(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
88
- console.log()
87
+ console.error()
88
+ console.error(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
89
+ console.error()
89
90
  }
90
91
 
91
92
  // 提取 data() 函数的返回对象
@@ -166,6 +167,7 @@ class Builder {
166
167
  let category;
167
168
  let loadModel = "lazy";
168
169
  let belongOrgFlag = this.options.devConsoleConfig.belongOrgFlag || "custom"
170
+ let buildVersion = this.options.devConsoleConfig.buildVersion || "v1";
169
171
  if (data.componentInfo) {
170
172
  component = data.componentInfo.component
171
173
  compName = data.componentInfo.compName
@@ -174,6 +176,7 @@ class Builder {
174
176
  category = data.componentInfo.category
175
177
  loadModel = data.componentInfo.loadModel
176
178
  belongOrgFlag = data.componentInfo.belongOrgFlag
179
+ buildVersion = data.componentInfo.buildVersion
177
180
  } else {
178
181
  component = this.options.pluginConfig.component
179
182
  compName = this.options.pluginConfig.compName
@@ -201,7 +204,7 @@ class Builder {
201
204
  const content = fs.readFileSync(configPath, 'utf8');
202
205
  allDependencies[configFile] = content;
203
206
  } catch (err) {
204
- console.log(chalk.yellow(`Warning: Cannot read ${configFile}:`, err.message));
207
+ console.error(chalk.yellow(`Warning: Cannot read ${configFile}:`, err.message));
205
208
  }
206
209
  }
207
210
  }
@@ -210,10 +213,10 @@ class Builder {
210
213
  // try {
211
214
  // const outputPath = path.join(process.cwd(), 'dependencies-output.json');
212
215
  // fs.writeFileSync(outputPath, JSON.stringify(allDependencies, null, 2), 'utf8');
213
- // console.log(chalk.green(`Dependencies collected and saved to: ${outputPath}`));
214
- // console.log(chalk.cyan(`Total files: ${Object.keys(allDependencies).length}`));
216
+ // console.error(chalk.green(`Dependencies collected and saved to: ${outputPath}`));
217
+ // console.error(chalk.cyan(`Total files: ${Object.keys(allDependencies).length}`));
215
218
  // } catch (err) {
216
- // console.log(chalk.yellow('Warning: Failed to write dependencies output file:', err.message));
219
+ // console.error(chalk.yellow('Warning: Failed to write dependencies output file:', err.message));
217
220
  // }
218
221
 
219
222
  return {
@@ -226,12 +229,17 @@ class Builder {
226
229
  category,
227
230
  loadModel,
228
231
  belongOrgFlag,
232
+ buildVersion,
229
233
  dependencies: allDependencies
230
234
  }
231
235
  };
232
236
 
233
- initPluginFile(buildFileName, component, plginTemp) {
234
- this.initPluginFile1(buildFileName, component, plginTemp)
237
+ initPluginFile(buildFileName, obj, plginTemp) {
238
+ if ("v2" == obj.buildVersion) {
239
+ this.initPluginFile2(buildFileName, obj.component, plginTemp)
240
+ } else {
241
+ this.initPluginFile1(buildFileName, obj.component, plginTemp)
242
+ }
235
243
  }
236
244
 
237
245
  initPluginFile1(buildFileName, component, plginTemp) {
@@ -268,15 +276,15 @@ class Builder {
268
276
 
269
277
 
270
278
  build(obj, config, plginTemp) {
271
- console.log(chalk.green('Compiling, Please Wait...'));
279
+ console.error(chalk.green('Compiling, Please Wait...'));
272
280
  exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugins/${plginTemp}.js`, async (error, stdout, stderr) => {
273
281
  if (error) {
274
- console.log('Compilation Failed:', error);
275
- console.log(chalk.red('Compilation Failed:' + stdout));
282
+ console.error('Compilation Failed:', error);
283
+ console.error(chalk.red('Compilation Failed:' + stdout));
276
284
  return;
277
285
  } else {
278
- console.log(chalk.green('Compilation Successful!'));
279
- console.log();
286
+ console.error(chalk.green('Compilation Successful!'));
287
+ console.error();
280
288
  await this.upload(obj, config)
281
289
  fs.unlinkSync(`plugins/${plginTemp}.js`);
282
290
  }
@@ -286,8 +294,8 @@ class Builder {
286
294
  async upload(obj, header) {
287
295
  const now = new Date();
288
296
  const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
289
- console.log(chalk.green(timeStr));
290
- console.log(chalk.green('Posting, please wait...'));
297
+ console.error(chalk.green(timeStr));
298
+ console.error(chalk.green('Posting, please wait...'));
291
299
  let jsContent = "";
292
300
  try {
293
301
  jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
@@ -316,11 +324,11 @@ class Builder {
316
324
  body, header);
317
325
  if (res.returnCode == 200) {
318
326
  console.error(chalk.green(`Success!`));
319
- console.log();
327
+ console.error();
320
328
  } else {
321
- console.log("res", res);
329
+ console.error("res", res);
322
330
  console.error(chalk.red(`Fail: ${res.returnInfo}`));
323
- console.log();
331
+ console.error();
324
332
  throw new Error('Publish Class Failed: ' + res.returnInfo);
325
333
  }
326
334
  return res;