cloudcc-cli 2.2.2 → 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 +47 -0
  3. package/bin/cc.js +11 -35
  4. package/bin/index.js +33 -0
  5. package/bin/mcp-svc.js +13 -0
  6. package/bin/mcp.js +18 -0
  7. package/java/com/cloudcc/core/TriggerInvoker.java +17 -1
  8. package/package.json +16 -7
  9. package/pom.xml +1 -0
  10. package/prompt/DevelopmentEnvironmentConstruction.ts +133 -0
  11. package/prompt/ccdk.ts +1190 -0
  12. package/prompt/ccprompt.ts +8 -0
  13. package/prompt/cloudccdev.ts +109 -0
  14. package/prompt/index.ts +52 -0
  15. package/prompt/objectInfo.ts +94 -0
  16. package/prompt/objectList.ts +25 -0
  17. package/prompt/openapi.ts +310 -0
  18. package/prompt/system.ts +14 -0
  19. package/prompt/vscodeExtension.ts +27 -0
  20. package/src/approval/approve.js +105 -0
  21. package/src/approval/get.js +245 -0
  22. package/src/approval/index.js +11 -0
  23. package/src/approval/reject.js +105 -0
  24. package/src/brief/get.js +51 -0
  25. package/src/brief/index.js +7 -0
  26. package/src/config/get.js +1 -1
  27. package/src/fields/create.js +204 -0
  28. package/src/fields/fields/A.js +23 -0
  29. package/src/fields/fields/AD.js +25 -0
  30. package/src/fields/fields/B.js +28 -0
  31. package/src/fields/fields/C.js +28 -0
  32. package/src/fields/fields/D.js +27 -0
  33. package/src/fields/fields/E.js +28 -0
  34. package/src/fields/fields/ENC.js +28 -0
  35. package/src/fields/fields/ENCD.js +28 -0
  36. package/src/fields/fields/F.js +27 -0
  37. package/src/fields/fields/FL.js +25 -0
  38. package/src/fields/fields/H.js +27 -0
  39. package/src/fields/fields/IMG.js +27 -0
  40. package/src/fields/fields/J.js +26 -0
  41. package/src/fields/fields/L.js +32 -0
  42. package/src/fields/fields/LT.js +28 -0
  43. package/src/fields/fields/M.js +29 -0
  44. package/src/fields/fields/MR.js +24 -0
  45. package/src/fields/fields/N.js +30 -0
  46. package/src/fields/fields/P.js +28 -0
  47. package/src/fields/fields/Q.js +35 -0
  48. package/src/fields/fields/S.js +30 -0
  49. package/src/fields/fields/SCORE.js +24 -0
  50. package/src/fields/fields/T.js +27 -0
  51. package/src/fields/fields/U.js +28 -0
  52. package/src/fields/fields/X.js +28 -0
  53. package/src/fields/fields/Y.js +33 -0
  54. package/src/fields/get.js +36 -0
  55. package/src/fields/index.js +9 -0
  56. package/src/mcp/MCP/345/234/272/346/231/257/346/250/241/346/213/237.md +8 -0
  57. package/src/mcp/index-sse-svc.js +126 -0
  58. package/src/mcp/index-streamable-svc.js +180 -0
  59. package/src/mcp/index.js +631 -0
  60. package/src/mcp/readme.md +137 -0
  61. package/src/mcp/tools/Approval/handler.js +349 -0
  62. package/src/mcp/tools/Class Creator/handler.js +37 -0
  63. package/src/mcp/tools/Class Detail Retriever/handler.js +33 -0
  64. package/src/mcp/tools/Class Detail Retriever/prompt.js +37 -0
  65. package/src/mcp/tools/Class Editor Guide/handler.js +72 -0
  66. package/src/mcp/tools/Class Editor Guide/prompt.js +468 -0
  67. package/src/mcp/tools/Class List Retriever/handler.js +36 -0
  68. package/src/mcp/tools/Class Publisher/handler.js +29 -0
  69. package/src/mcp/tools/Class Publisher/prompt.js +40 -0
  70. package/src/mcp/tools/Class Puller/handler.js +86 -0
  71. package/src/mcp/tools/Class Puller/prompt.js +49 -0
  72. package/src/mcp/tools/Client Script Creator/handler.js +179 -0
  73. package/src/mcp/tools/Client Script Detail Retriever/handler.js +53 -0
  74. package/src/mcp/tools/Client Script Editor Guide/handler.js +633 -0
  75. package/src/mcp/tools/Client Script List Retriever/handler.js +68 -0
  76. package/src/mcp/tools/Client Script Publisher/handler.js +54 -0
  77. package/src/mcp/tools/Client Script Puller/handler.js +73 -0
  78. package/src/mcp/tools/CloudCC Development Overview/handler.js +48 -0
  79. package/src/mcp/tools/CloudCC Development Overview/prompt.js +870 -0
  80. package/src/mcp/tools/Component Creator/handler.js +44 -0
  81. package/src/mcp/tools/Component Detail Retriever/handler.js +38 -0
  82. package/src/mcp/tools/Component Editor Guide/handler.js +76 -0
  83. package/src/mcp/tools/Component Editor Guide/prompt.js +519 -0
  84. package/src/mcp/tools/Component List Retriever/handler.js +43 -0
  85. package/src/mcp/tools/Component Publisher/handler.js +18 -0
  86. package/src/mcp/tools/Component Publisher/prompt.js +659 -0
  87. package/src/mcp/tools/Component Puller/handler.js +63 -0
  88. package/src/mcp/tools/Dev Environment Creator/fetcher.js +500 -0
  89. package/src/mcp/tools/Dev Environment Creator/handler.js +92 -0
  90. package/src/mcp/tools/Dev Environment Creator/prompt.js +273 -0
  91. package/src/mcp/tools/Dev Environment Validator/handler.js +88 -0
  92. package/src/mcp/tools/Dev Environment Validator/prompt.js +193 -0
  93. package/src/mcp/tools/Developer Key Setup Guide/fetcher.js +278 -0
  94. package/src/mcp/tools/Developer Key Setup Guide/handler.js +43 -0
  95. package/src/mcp/tools/Developer Key Setup Guide/prompt.js +71 -0
  96. package/src/mcp/tools/Object Creator/handler.js +34 -0
  97. package/src/mcp/tools/Object Fields Creator/handler.js +64 -0
  98. package/src/mcp/tools/Object Fields Retriever/handler.js +37 -0
  99. package/src/mcp/tools/Object Fields Retriever/prompt.js +10 -0
  100. package/src/mcp/tools/Object List Retriever/handler.js +43 -0
  101. package/src/mcp/tools/Object List Retriever/prompt.js +10 -0
  102. package/src/mcp/tools/Scheduled Class Creator/handler.js +37 -0
  103. package/src/mcp/tools/Scheduled Class Detail Retriever/handler.js +34 -0
  104. package/src/mcp/tools/Scheduled Class List Retriever/handler.js +52 -0
  105. package/src/mcp/tools/Scheduled Class Publisher/handler.js +30 -0
  106. package/src/mcp/tools/Scheduled Class Puller/handler.js +92 -0
  107. package/src/mcp/tools/Trigger Creator/handler.js +53 -0
  108. package/src/mcp/tools/Trigger Detail Retriever/handler.js +33 -0
  109. package/src/mcp/tools/Trigger Editor Guide/handler.js +58 -0
  110. package/src/mcp/tools/Trigger List Retriever/handler.js +49 -0
  111. package/src/mcp/tools/Trigger Publisher/handler.js +34 -0
  112. package/src/mcp/tools/Trigger Puller/handler.js +40 -0
  113. package/src/mcp/tools/ccdk/fetcher.js +18 -0
  114. package/src/mcp/tools/ccdk/handler.js +98 -0
  115. package/src/mcp/tools/ccdk/prompt.js +453 -0
  116. package/src/mcp/tools/index.js +23 -0
  117. package/src/object/create.js +105 -0
  118. package/src/object/get.js +43 -4
  119. package/src/object/index.js +2 -1
  120. package/src/plugin/create.js +1 -2
  121. package/src/plugin/create1.js +9 -9
  122. package/src/plugin/detail.js +91 -0
  123. package/src/plugin/get.js +79 -0
  124. package/src/plugin/index.js +4 -1
  125. package/src/plugin/publish.js +13 -13
  126. package/src/plugin/publish1.js +33 -24
  127. package/src/plugin/pull.js +173 -0
  128. package/src/project/create.js +9 -9
  129. package/src/project/create1.js +31 -17
  130. package/src/recordType/get.js +4 -2
  131. package/src/script/create.js +7 -7
  132. package/src/script/detail.js +95 -0
  133. package/src/script/get.js +4 -2
  134. package/src/script/index.js +1 -0
  135. package/src/script/publish.js +14 -14
  136. package/src/script/pull.js +12 -12
  137. package/src/script/pullList.js +5 -3
  138. package/src/timer/create.js +7 -7
  139. package/src/timer/detail.js +84 -0
  140. package/src/timer/get.js +6 -3
  141. package/src/timer/publish.js +7 -7
  142. package/src/timer/pull.js +8 -8
  143. package/src/timer/pullList.js +5 -3
  144. package/src/token/get.js +1 -1
  145. package/src/triggers/create.js +7 -7
  146. package/src/triggers/detail.js +90 -0
  147. package/src/triggers/get.js +4 -2
  148. package/src/triggers/index.js +1 -0
  149. package/src/triggers/publish.js +7 -7
  150. package/src/triggers/pull.js +8 -8
  151. package/src/triggers/pullList.js +5 -3
  152. package/src/version/get.js +3 -3
  153. package/target/ccopenapi-0.0.3-classes.jar +0 -0
  154. package/target/ccopenapi-0.0.3.jar +0 -0
  155. package/target/maven-archiver/pom.properties +3 -0
  156. package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +18 -0
  157. package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +19 -0
  158. package/template/Appvue +452 -12
  159. package/template/index.js +30 -19
  160. package/tool/branch/index.js +1 -1
  161. package/tool/checkLange/checkLang.js +6 -6
  162. package/tool/checkLange/clearLang.js +1 -1
  163. package/utils/accessClass.js +23 -0
  164. package/utils/checkVersion.js +22 -20
  165. package/utils/config.js +18 -3
  166. package/utils/http.js +10 -10
  167. package/utils/utils.js +128 -40
  168. package/java/com/cloudcc/core/CCTriggerDemo.java +0 -25
  169. package/src/classes/create.js +0 -65
  170. package/src/classes/get.js +0 -21
  171. package/src/classes/index.js +0 -11
  172. package/src/classes/publish.js +0 -50
  173. package/src/classes/pull.js +0 -54
  174. package/src/classes/pullList.js +0 -44
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;
@@ -19,8 +19,7 @@ data() {
19
19
  compName: "cloudcc-demo-01",
20
20
 
21
21
  compDesc: "Component description information",
22
- },
23
- isLock: false,
22
+ }
24
23
  };
25
24
  },
26
25
  };
@@ -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 />
@@ -28,8 +29,7 @@ data() {
28
29
  compName: "compName-${name}",
29
30
 
30
31
  compDesc: "Component description information",
31
- },
32
- isLock: false,
32
+ }
33
33
  };
34
34
  },
35
35
  };
@@ -63,13 +63,13 @@ export default {};
63
63
  fs.mkdirSync(path.join(pluginPath, "components"), { recursive: true })
64
64
  fs.writeFileSync(path.join(pluginPath, "components", "HelloWorld.vue"), temp1)
65
65
  fs.writeFileSync(path.join(pluginPath, "config.json"), `{"component":"component-${name}","compName":"compName-${name}","compDesc":"Component description information"}`)
66
- console.log()
67
- console.log(chalk.green("Successfully Created:" + name))
68
- console.log()
66
+ console.error()
67
+ console.error(chalk.green("Successfully Created:" + name))
68
+ console.error()
69
69
  } catch (e) {
70
- console.log()
71
- console.log(chalk.red("Creation Failed:" + e))
72
- console.log()
70
+ console.error()
71
+ console.error(chalk.red("Creation Failed:" + e))
72
+ console.error()
73
73
  }
74
74
  }
75
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,12 @@ 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();
332
+ throw new Error('Publish Class Failed: ' + res.returnInfo);
324
333
  }
325
334
  return res;
326
335
  }
@@ -332,9 +341,9 @@ class Builder {
332
341
  }
333
342
  }
334
343
 
335
- function publish(argvs) {
344
+ async function publish(argvs) {
336
345
  let p = new Builder()
337
- p.publish(argvs)
346
+ await p.publish(argvs)
338
347
  }
339
348
 
340
349
  module.exports = publish;