cloudcc-cli 1.6.5 → 1.6.6

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 (46) hide show
  1. package/README.md +8 -0
  2. package/bin/cc.js +15 -15
  3. package/core/core/CCObject.java +48 -0
  4. package/core/core/CCService.java +806 -0
  5. package/core/core/CCTrigger.java +23 -0
  6. package/core/core/CCTriggerHandler.java +15 -0
  7. package/core/core/DevLogger.java +39 -0
  8. package/core/core/OperatationEnum.java +5 -0
  9. package/core/core/PeakInterf.java +6 -0
  10. package/core/core/PeakSvc.java +8 -0
  11. package/core/core/ServiceResult.java +35 -0
  12. package/core/core/TriggerInvoker.java +83 -0
  13. package/core/core/TriggerMethod.java +9 -0
  14. package/core/core/TriggerTimeEnum.java +5 -0
  15. package/core/core/UserInfo.java +45 -0
  16. package/core.zip +0 -0
  17. package/package.json +1 -1
  18. package/src/classes/create.js +5 -8
  19. package/src/classes/publish.js +8 -12
  20. package/src/config/get.js +1 -3
  21. package/src/config/use.js +1 -3
  22. package/src/object/get.js +4 -6
  23. package/src/plugin/create.js +10 -20
  24. package/src/plugin/create1.js +8 -16
  25. package/src/plugin/publish.js +44 -77
  26. package/src/plugin/publish1.js +42 -72
  27. package/src/project/create.js +12 -14
  28. package/src/project/create1.js +15 -17
  29. package/src/recordType/get.js +3 -6
  30. package/src/script/create.js +3 -6
  31. package/src/script/publish.js +10 -17
  32. package/src/timer/create.js +3 -6
  33. package/src/timer/publish.js +8 -12
  34. package/src/token/get.js +1 -3
  35. package/src/triggers/create.js +8 -16
  36. package/src/triggers/index.js +1 -1
  37. package/src/triggers/publish.js +10 -13
  38. package/template/index.js +10 -10
  39. package/template/indexvue +3 -3
  40. package/tool/branch/index.js +25 -0
  41. package/tool/checkLange/checkLang.js +68 -0
  42. package/tool/checkLange/clearLang.js +85 -0
  43. package/tool/checkLange/result.txt +0 -0
  44. package/utils/checkVersion.js +19 -30
  45. package/utils/http.js +5 -5
  46. package/utils/utils.js +19 -21
@@ -0,0 +1,23 @@
1
+ package com.cloudcc.core;
2
+
3
+ public interface CCTrigger {
4
+ public void do_insert_before() throws Exception;
5
+
6
+ public void do_insert_after() throws Exception;
7
+
8
+ public void do_update_before() throws Exception;
9
+
10
+ public void do_update_after() throws Exception;
11
+ public void do_upsert_before() throws Exception;
12
+
13
+ public void do_upsert_after() throws Exception;
14
+
15
+ public void do_delete_before() throws Exception;
16
+
17
+ public void do_delete_after() throws Exception;
18
+ public void setRecordOldVal (String id);
19
+
20
+ public void do_approval() throws Exception;
21
+
22
+ public String getObjectApiName();
23
+ }
@@ -0,0 +1,15 @@
1
+ package com.cloudcc.core;
2
+
3
+ import java.util.Map;
4
+
5
+ public abstract class CCTriggerHandler extends CCService {
6
+ public Map record_new;
7
+ public Map record_old;
8
+ public ServiceResult trigger;
9
+ public CCTriggerHandler(Map triggernew, Map triggerold, ServiceResult svc, UserInfo uinfo){
10
+ super(uinfo);
11
+ this.record_new = triggernew;
12
+ this.record_old = triggerold;
13
+ this.trigger = svc;
14
+ }
15
+ }
@@ -0,0 +1,39 @@
1
+ package com.cloudcc.core;
2
+
3
+ /**
4
+ * @author jarry
5
+ *
6
+ * 系统日志输出
7
+ */
8
+ public class DevLogger {
9
+ UserInfo userInfo;
10
+ public DevLogger(UserInfo userInfo){
11
+ this.userInfo = userInfo;
12
+ }
13
+
14
+ /**
15
+ * info日志
16
+ * @param log
17
+ */
18
+ public static void devLogInfo(String log){
19
+ System.out.println("Info日志"+log);
20
+ }
21
+
22
+ /**
23
+ * Error日志
24
+ * @param log
25
+ */
26
+ public static void devLogError(String log){
27
+ System.out.println("Info日志"+log);
28
+ }
29
+
30
+ /**
31
+ * 异常日志
32
+ * @param log
33
+ * @param e
34
+ */
35
+ public static void devLogError(String log,Exception e){
36
+ System.out.println("Info日志"+log);
37
+ System.out.println(e);
38
+ }
39
+ }
@@ -0,0 +1,5 @@
1
+ package com.cloudcc.core;
2
+
3
+ public enum OperatationEnum {
4
+ INSERT,UPDATE,UPSERT,DELETE,APPROVE
5
+ }
@@ -0,0 +1,6 @@
1
+ package com.cloudcc.core;
2
+
3
+ public interface PeakInterf {
4
+ public UserInfo uinfo = new UserInfo();
5
+ public void execute();
6
+ }
@@ -0,0 +1,8 @@
1
+ package com.cloudcc.core;
2
+
3
+ import org.springframework.beans.factory.annotation.Autowired;
4
+
5
+ public class PeakSvc {
6
+ @Autowired
7
+ public CCService ccService;
8
+ }
@@ -0,0 +1,35 @@
1
+ package com.cloudcc.core;
2
+
3
+ import com.alibaba.fastjson.JSONObject;
4
+
5
+ import java.util.HashMap;
6
+
7
+ public class ServiceResult extends HashMap {
8
+ public String success;
9
+ public String message;
10
+ public String Id;
11
+
12
+ public void addErrorMessage(String msg) throws Exception{
13
+ this.put("message",msg);
14
+ this.put("success","false");
15
+ throw new Exception(msg);
16
+ }
17
+
18
+ public String getMessage(){
19
+ return (String)this.get("message");
20
+ }
21
+
22
+ public String getSuccess(){
23
+ return (String)this.get("success");
24
+ }
25
+ public String getId(){
26
+ return (String)this.get("id");
27
+ }
28
+
29
+ @Override
30
+ public String toString(){
31
+ JSONObject data = new JSONObject();
32
+ data.putAll(this);
33
+ return data.toString();
34
+ }
35
+ }
@@ -0,0 +1,83 @@
1
+ package com.cloudcc.core;
2
+
3
+ import com.cloudcc.core.CCObject;
4
+ import org.reflections.Reflections;
5
+
6
+ import java.lang.reflect.Constructor;
7
+ import java.lang.reflect.InvocationTargetException;
8
+ import java.util.Set;
9
+
10
+ public class TriggerInvoker {
11
+ UserInfo uinfo = null;
12
+ String operate = "";
13
+ String triggerTime = "";
14
+ public TriggerInvoker (UserInfo userInfo,String operate,String triggerTime){
15
+ this.uinfo = userInfo;
16
+ this.operate = operate;
17
+ this.triggerTime = triggerTime;
18
+ }
19
+ public TriggerInvoker(){
20
+
21
+ }
22
+ public ServiceResult handler(CCObject data) throws Exception{
23
+ String objectApiName = data.getObjectApiName();
24
+ ServiceResult sr = new ServiceResult();
25
+ Reflections ref = new Reflections("com.cloudcc.trigger");
26
+ Set<Class<? extends CCTrigger>> clsSets = ref.getSubTypesOf(CCTrigger.class);
27
+ for (Class<? extends CCTrigger> subCls : clsSets){
28
+ try {
29
+ Constructor cons = subCls.getConstructor(CCObject.class,CCObject.class,ServiceResult.class,UserInfo.class);
30
+ CCTrigger trigger = (CCTrigger) cons.newInstance(data,null,sr,uinfo);
31
+ String objectApiNameTmp = (String) trigger.getObjectApiName();
32
+ if (objectApiName != null && objectApiName.equals(objectApiNameTmp)) {
33
+ if ("before".equals(triggerTime) && "insert".equals(operate)) {
34
+ trigger.do_insert_before();
35
+ }
36
+ if ("after".equals(triggerTime) && "insert".equals(operate)) {
37
+ String id = (String)data.get("id");
38
+ trigger.setRecordOldVal(id);
39
+ trigger.do_insert_after();
40
+ }
41
+ if ("before".equals(triggerTime) && "update".equals(operate)) {
42
+ trigger.do_update_before();
43
+ }
44
+ if ("after".equals(triggerTime) && "update".equals(operate)) {
45
+ String id = (String)data.get("id");
46
+ trigger.setRecordOldVal(id);
47
+ trigger.do_update_after();
48
+ }
49
+ if ("before".equals(triggerTime) && "upsert".equals(operate)) {
50
+ trigger.do_upsert_before();
51
+ }
52
+ if ("after".equals(triggerTime) && "upsert".equals(operate)) {
53
+ String id = (String)data.get("id");
54
+ trigger.setRecordOldVal(id);
55
+ trigger.do_upsert_after();
56
+ }
57
+ if ("before".equals(triggerTime) && "delete".equals(operate)) {
58
+ trigger.do_delete_before();
59
+ }
60
+ if ("after".equals(triggerTime) && "delete".equals(operate)) {
61
+ String id = (String)data.get("id");
62
+ trigger.setRecordOldVal(id);
63
+ trigger.do_delete_after();
64
+ }
65
+ if ("approval".equals(operate)) {
66
+ trigger.do_approval();
67
+ }
68
+ }
69
+ } catch (NoSuchMethodException e) {
70
+ throw new RuntimeException(e);
71
+ } catch (InvocationTargetException e) {
72
+ throw new RuntimeException(e);
73
+ } catch (InstantiationException e) {
74
+ throw new RuntimeException(e);
75
+ } catch (IllegalAccessException e) {
76
+ throw new RuntimeException(e);
77
+ }catch (Exception ex) {
78
+ throw ex;
79
+ }
80
+ }
81
+ return sr;
82
+ }
83
+ }
@@ -0,0 +1,9 @@
1
+ package com.cloudcc.core;
2
+
3
+ public @interface TriggerMethod {
4
+ String name();
5
+ OperatationEnum operate();
6
+ TriggerTimeEnum triggerTime();
7
+ boolean isEnable() ;
8
+ String remark() default "";
9
+ }
@@ -0,0 +1,5 @@
1
+ package com.cloudcc.core;
2
+
3
+ public enum TriggerTimeEnum {
4
+ BEFORE,AFTER
5
+ }
@@ -0,0 +1,45 @@
1
+ package com.cloudcc.core;
2
+
3
+ import com.cloudcc.core.CCObject;
4
+
5
+ public class UserInfo extends CCObject{
6
+ public String binding;
7
+ public String getUserId() {
8
+ return (String)this.get("id");
9
+ }
10
+
11
+ public String getRoleId() {
12
+ return (String)this.get("role");
13
+ }
14
+
15
+ public UserInfo (String username,String pwd) throws Exception {
16
+ this.put("userName", username);
17
+ this.put("password", pwd);
18
+ }
19
+
20
+ public UserInfo() {
21
+
22
+ }
23
+
24
+ public String getLoginName(){
25
+ return (String)this.get("userName");
26
+ }
27
+ public String getProfileId() {
28
+ // TODO Auto-generated method stub
29
+ return (String)this.get("profileId");
30
+ }
31
+ public void setBinding(String bind){
32
+ this.binding = bind;
33
+ this.put("binding",bind);
34
+ }
35
+ public String getBinding(){
36
+ if (this.binding == null){
37
+ return (String)this.get("binding");
38
+ } else {
39
+ return this.binding;
40
+ }
41
+ }
42
+ public String getUserName() {
43
+ return (String)this.get("name");
44
+ }
45
+ }
package/core.zip ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -2,18 +2,15 @@ const { checkUpdate } = require("../../utils/checkVersion")
2
2
  const fs = require("fs");
3
3
  const path = require("path")
4
4
  const chalk = require("chalk")
5
- /**
6
- * 创建文件
7
- * @param {string} name 文件名称
8
- */
5
+
9
6
  async function create(name) {
10
7
  let res = await checkUpdate();
11
8
  if (!res) {
12
9
  const classesPath = path.join(process.cwd(), "classes/" + name);
13
10
  try {
14
11
  fs.mkdirSync(classesPath, { recursive: true })
15
- const javaTmp = `
16
- public class ${name}{
12
+ const javaTmp =
13
+ `public class ${name}{
17
14
  private UserInfo userInfo;
18
15
 
19
16
  public ${name}(UserInfo userInfo){
@@ -30,11 +27,11 @@ public class ${name}{
30
27
  fs.writeFileSync(path.join(classesPath, name + ".java"), javaTmp)
31
28
  fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"3"}`)
32
29
  console.log()
33
- console.log(chalk.green("创建成功:" + name))
30
+ console.log(chalk.green("Successfully Created:" + name))
34
31
  console.log()
35
32
  } catch (e) {
36
33
  console.log()
37
- console.log(chalk.red("创建失败:" + e))
34
+ console.log(chalk.red("Creation Failed:" + e))
38
35
  console.log()
39
36
  }
40
37
  }
@@ -1,4 +1,4 @@
1
- // 检查cli版本更新功能
1
+
2
2
  const { checkUpdate } = require("../../utils/checkVersion")
3
3
  const fs = require("fs");
4
4
  const path = require("path")
@@ -6,20 +6,17 @@ const chalk = require("chalk")
6
6
  const { postNormal } = require("../../utils/http")
7
7
 
8
8
  const { getBusToken } = require("../../utils/utils")
9
- /**
10
- * 发布文件
11
- * @param {string} name 文件名称
12
- */
9
+
13
10
  async function publish(name) {
14
11
  let res = await checkUpdate();
15
12
  if (!res) {
16
13
  console.log();
17
- console.log(chalk.green('发布中,请稍后...'));
14
+ console.log(chalk.green('Posting, please wait...'));
18
15
  console.log();
19
16
  const classPath = path.join(process.cwd(), `classes/${name}/`);
20
17
  let classContent = fs.readFileSync(classPath + `${name}.java`, 'utf8');
21
18
  let configContent = JSON.parse(fs.readFileSync(classPath + "config.json", 'utf8'));
22
- // 获取token成功后,发布内容
19
+
23
20
  if (await getBusToken()) {
24
21
  let body = {
25
22
  "id": configContent.id,
@@ -28,18 +25,17 @@ async function publish(name) {
28
25
  "source": encodeURI(classContent),
29
26
  "folderId": "wgd"
30
27
  }
31
- let url = new URL(global.baseUrl).origin
32
- let res = await postNormal(url + "/setup/api/ccfag/save", body)
28
+ let res = await postNormal(global.setupSvc + "/api/ccfag/save", body)
33
29
  if (res.result) {
34
- console.log(chalk.green('发布成功!'));
30
+ console.log(chalk.green('Success!'));
35
31
  console.log();
36
- // 组件发布成功后,判断下配置文件是否有id,如果没有,那么将id存储到配置中
32
+
37
33
  if (!configContent.id) {
38
34
  configContent.id = res.data
39
35
  fs.writeFileSync(path.join(classPath, "config.json"), JSON.stringify(configContent))
40
36
  }
41
37
  } else {
42
- console.log(chalk.red('发布失败:' + res.returnInfo));
38
+ console.log(chalk.red('Fail:' + res.returnInfo));
43
39
  }
44
40
  }
45
41
  }
package/src/config/get.js CHANGED
@@ -1,9 +1,7 @@
1
1
 
2
2
  const chalk = require("chalk")
3
3
  const path = require("path")
4
- /**
5
- * 获取token
6
- */
4
+
7
5
  async function get(projectPath = process.cwd()) {
8
6
  let config = require(path.join(projectPath, "cloudcc-cli.config.js"))
9
7
  if (config) {
package/src/config/use.js CHANGED
@@ -1,8 +1,6 @@
1
1
  const path = require("path")
2
2
  const fs = require("fs")
3
- /**
4
- * 获取token
5
- */
3
+
6
4
  function use(env, projectPath = process.cwd()) {
7
5
  let config = require(path.join(projectPath, "cloudcc-cli.config.js"));
8
6
  config.use = env;
package/src/object/get.js CHANGED
@@ -1,13 +1,11 @@
1
1
  const { getBusToken } = require("../../utils/utils")
2
2
  const { postNormal } = require("../../utils/http")
3
- /**
4
- * 获取对象集合
5
- */
3
+
4
+
6
5
  async function get(path = process.cwd()) {
7
- // 获取token成功后,发布内容
6
+
8
7
  if (await getBusToken(path)) {
9
- let url = new URL(global.baseUrl).origin
10
- let res = await postNormal(url + "/setup/api/customObject/standardObjList")
8
+ let res = await postNormal(global.setupSvc + "/api/customObject/standardObjList")
11
9
  console.log(JSON.stringify(res.data))
12
10
  return res.data
13
11
  }
@@ -1,15 +1,10 @@
1
1
  const fs = require('fs');
2
2
  const inquirer = require("inquirer")
3
- // 检查cli版本更新功能
3
+
4
4
  const { checkUpdate } = require("../../utils/checkVersion")
5
5
  const temp = `<template>
6
6
  <div class="cc-container">
7
7
  <div>Hello CloudCC</div>
8
- <div>
9
- <a href="https://cloudccone.feishu.cn/wiki/JZ7CwcRfriU8taknCKCcwKEmncd">
10
- 开发者文档</a
11
- >
12
- </div>
13
8
  </div>
14
9
  </template>
15
10
 
@@ -18,12 +13,12 @@ export default {
18
13
  data() {
19
14
  return {
20
15
  componentInfo: {
21
- // 组件唯一标识,全局唯一
16
+
22
17
  component: "cloudcc-demo-01",
23
- // 组件名称,在页面编辑器显示的名字
18
+
24
19
  compName: "cloudcc-demo-01",
25
- // 组件描述信息
26
- compDesc: "组件描述信息",
20
+
21
+ compDesc: "Component description information",
27
22
  },
28
23
  isLock: false,
29
24
  };
@@ -37,13 +32,11 @@ padding: 8px;
37
32
  background: goldenrod;
38
33
  }
39
34
  </style>`
40
- /**
41
- * 创建组件模板文件
42
- */
35
+
43
36
  class Builder {
44
37
  constructor() {
45
38
  this.options = {
46
- // 开发配置信息
39
+
47
40
  devConsoleConfig: {
48
41
  },
49
42
  }
@@ -52,7 +45,7 @@ class Builder {
52
45
  async init() {
53
46
  let res = await checkUpdate();
54
47
  if (!res) {
55
- // 获得用户输入
48
+
56
49
  let answers;
57
50
  if (this.plugin) {
58
51
  answers = { buildFileName: this.plugin + "/demo.vue" }
@@ -63,16 +56,13 @@ class Builder {
63
56
  fs.writeFileSync(answers.buildFileName, temp);
64
57
  }
65
58
  }
66
- /**
67
- * 命令行交互
68
- * @returns 结果
69
- */
59
+
70
60
  ask() {
71
61
  const prompt = [];
72
62
  prompt.push({
73
63
  type: "input",
74
64
  name: "buildFileName",
75
- message: "请输入文件名,如index.vue",
65
+ message: "Please enter a file name, such as index.vue",
76
66
  })
77
67
  return inquirer.prompt(prompt)
78
68
  }
@@ -1,23 +1,15 @@
1
- // 检查cli版本更新功能
1
+
2
2
  const { checkUpdate } = require("../../utils/checkVersion")
3
3
  const fs = require("fs");
4
4
  const path = require("path")
5
5
  const chalk = require("chalk")
6
6
 
7
7
 
8
- /**
9
- * 创建文件
10
- * @param {string} name 文件名称
11
- */
8
+
12
9
  async function create(name) {
13
10
  const temp = `<template>
14
11
  <div class="cc-container">
15
12
  <div>Hello CloudCC</div>
16
- <div>
17
- <a href="https://cloudccone.feishu.cn/wiki/JZ7CwcRfriU8taknCKCcwKEmncd">
18
- 开发者文档</a
19
- >
20
- </div>
21
13
  </div>
22
14
  </template>
23
15
 
@@ -26,12 +18,12 @@ export default {
26
18
  data() {
27
19
  return {
28
20
  componentInfo: {
29
- // 组件唯一标识,全局唯一
21
+
30
22
  component: "${name}",
31
- // 组件名称,在页面编辑器显示的名字
23
+
32
24
  compName: "${name}",
33
- // 组件描述信息
34
- compDesc: "组件描述信息",
25
+
26
+ compDesc: "Component description information",
35
27
  },
36
28
  isLock: false,
37
29
  };
@@ -54,11 +46,11 @@ background: goldenrod;
54
46
  fs.writeFileSync(path.join(pluginPath, name + ".vue"), temp)
55
47
  fs.writeFileSync(path.join(pluginPath, "config.json"), `{"name":"${name}"}`)
56
48
  console.log()
57
- console.log(chalk.green("创建成功:" + name))
49
+ console.log(chalk.green("Successfully Created:" + name))
58
50
  console.log()
59
51
  } catch (e) {
60
52
  console.log()
61
- console.log(chalk.red("创建失败:" + e))
53
+ console.log(chalk.red("Creation Failed:" + e))
62
54
  console.log()
63
55
  }
64
56
  }