cloudcc-cli 1.6.4 → 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.
- package/README.md +1176 -1161
- package/bin/cc.js +49 -49
- package/bin/plugin.js +6 -6
- package/bin/project.js +6 -6
- package/core/core/CCObject.java +48 -0
- package/core/core/CCService.java +806 -0
- package/core/core/CCTrigger.java +23 -0
- package/core/core/CCTriggerHandler.java +15 -0
- package/core/core/DevLogger.java +39 -0
- package/core/core/OperatationEnum.java +5 -0
- package/core/core/PeakInterf.java +6 -0
- package/core/core/PeakSvc.java +8 -0
- package/core/core/ServiceResult.java +35 -0
- package/core/core/TriggerInvoker.java +83 -0
- package/core/core/TriggerMethod.java +9 -0
- package/core/core/TriggerTimeEnum.java +5 -0
- package/core/core/UserInfo.java +45 -0
- package/core.zip +0 -0
- package/package.json +34 -34
- package/src/classes/create.js +40 -43
- package/src/classes/index.js +8 -8
- package/src/classes/publish.js +43 -47
- package/src/config/get.js +20 -22
- package/src/config/index.js +8 -8
- package/src/config/use.js +14 -16
- package/src/object/get.js +14 -16
- package/src/object/index.js +7 -7
- package/src/plugin/create.js +70 -80
- package/src/plugin/create1.js +58 -66
- package/src/plugin/index.js +8 -8
- package/src/plugin/publish.js +265 -298
- package/src/plugin/publish1.js +256 -286
- package/src/project/create.js +87 -89
- package/src/project/create1.js +109 -111
- package/src/project/index.js +7 -7
- package/src/recordType/get.js +13 -16
- package/src/recordType/index.js +7 -7
- package/src/script/create.js +29 -32
- package/src/script/index.js +8 -8
- package/src/script/publish.js +62 -69
- package/src/timer/create.js +26 -29
- package/src/timer/index.js +8 -8
- package/src/timer/publish.js +43 -47
- package/src/token/get.js +11 -13
- package/src/token/index.js +7 -7
- package/src/triggers/create.js +27 -35
- package/src/triggers/index.js +8 -8
- package/src/triggers/publish.js +48 -51
- package/template/Appvue +29 -29
- package/template/babelconfigjs +5 -5
- package/template/demojava +14 -14
- package/template/gitignore +11 -11
- package/template/index.js +57 -57
- package/template/indexhtml +21 -21
- package/template/indexvue +34 -34
- package/template/javaconfigjson +2 -2
- package/template/mainjs +13 -13
- package/template/package-lockjson +12115 -12115
- package/template/packagejson +42 -42
- package/template/vueconfigjs +26 -26
- package/tool/branch/index.js +25 -0
- package/tool/checkLange/checkLang.js +68 -0
- package/tool/checkLange/clearLang.js +85 -0
- package/tool/checkLange/result.txt +0 -0
- package/utils/checkVersion.js +94 -105
- package/utils/http.js +122 -122
- package/utils/utils.js +57 -59
|
@@ -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,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,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,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cloudcc-cli",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "cloudcc-cli",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"cloudcc",
|
|
7
|
-
"cloudcc-cli"
|
|
8
|
-
],
|
|
9
|
-
"main": "./bin",
|
|
10
|
-
"author": "cloudcc",
|
|
11
|
-
"license": "ISC",
|
|
12
|
-
"bin": {
|
|
13
|
-
"cloudccCreate": "bin/project.js",
|
|
14
|
-
"cloudccBuild": "bin/plugin.js",
|
|
15
|
-
"cc": "bin/cc.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"cc-pull": "git fetch --tags -f && git pull",
|
|
19
|
-
"publish-lib": "npm publish --registry https://registry.npmjs.org && curl https://npmmirror.com/sync/cloudcc-cli"
|
|
20
|
-
},
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"axios": "^0.21.4",
|
|
23
|
-
"boxen": "^4.0.0",
|
|
24
|
-
"chalk": "^2.4.2",
|
|
25
|
-
"crypto-js": "^4.1.1",
|
|
26
|
-
"dayjs": "^1.10.7",
|
|
27
|
-
"fs-extra": "^11.2.0",
|
|
28
|
-
"inquirer": "^8.1.0",
|
|
29
|
-
"marked": "^5.0.1",
|
|
30
|
-
"mem-fs": "^2.2.1",
|
|
31
|
-
"mem-fs-editor": "^9.0.1",
|
|
32
|
-
"vue-custom-element": "^3.3.0",
|
|
33
|
-
"vue-template-compiler": "^2.6.14"
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "cloudcc-cli",
|
|
3
|
+
"version": "1.6.6",
|
|
4
|
+
"description": "cloudcc-cli",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudcc",
|
|
7
|
+
"cloudcc-cli"
|
|
8
|
+
],
|
|
9
|
+
"main": "./bin",
|
|
10
|
+
"author": "cloudcc",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"bin": {
|
|
13
|
+
"cloudccCreate": "bin/project.js",
|
|
14
|
+
"cloudccBuild": "bin/plugin.js",
|
|
15
|
+
"cc": "bin/cc.js"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"cc-pull": "git fetch --tags -f && git pull",
|
|
19
|
+
"publish-lib": "npm publish --registry https://registry.npmjs.org && curl https://npmmirror.com/sync/cloudcc-cli"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"axios": "^0.21.4",
|
|
23
|
+
"boxen": "^4.0.0",
|
|
24
|
+
"chalk": "^2.4.2",
|
|
25
|
+
"crypto-js": "^4.1.1",
|
|
26
|
+
"dayjs": "^1.10.7",
|
|
27
|
+
"fs-extra": "^11.2.0",
|
|
28
|
+
"inquirer": "^8.1.0",
|
|
29
|
+
"marked": "^5.0.1",
|
|
30
|
+
"mem-fs": "^2.2.1",
|
|
31
|
+
"mem-fs-editor": "^9.0.1",
|
|
32
|
+
"vue-custom-element": "^3.3.0",
|
|
33
|
+
"vue-template-compiler": "^2.6.14"
|
|
34
|
+
}
|
|
35
35
|
}
|
package/src/classes/create.js
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path")
|
|
4
|
-
const chalk = require("chalk")
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
public
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.log(
|
|
34
|
-
console.log()
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = create;
|
|
1
|
+
const { checkUpdate } = require("../../utils/checkVersion")
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path")
|
|
4
|
+
const chalk = require("chalk")
|
|
5
|
+
|
|
6
|
+
async function create(name) {
|
|
7
|
+
let res = await checkUpdate();
|
|
8
|
+
if (!res) {
|
|
9
|
+
const classesPath = path.join(process.cwd(), "classes/" + name);
|
|
10
|
+
try {
|
|
11
|
+
fs.mkdirSync(classesPath, { recursive: true })
|
|
12
|
+
const javaTmp =
|
|
13
|
+
`public class ${name}{
|
|
14
|
+
private UserInfo userInfo;
|
|
15
|
+
|
|
16
|
+
public ${name}(UserInfo userInfo){
|
|
17
|
+
this.userInfo = userInfo;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
public String demo(String str){
|
|
22
|
+
str = "demo";
|
|
23
|
+
return str;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
27
|
+
fs.writeFileSync(path.join(classesPath, name + ".java"), javaTmp)
|
|
28
|
+
fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"3"}`)
|
|
29
|
+
console.log()
|
|
30
|
+
console.log(chalk.green("Successfully Created:" + name))
|
|
31
|
+
console.log()
|
|
32
|
+
} catch (e) {
|
|
33
|
+
console.log()
|
|
34
|
+
console.log(chalk.red("Creation Failed:" + e))
|
|
35
|
+
console.log()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = create;
|
package/src/classes/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const cc = {}
|
|
2
|
-
cc.create = require("./create")
|
|
3
|
-
cc.publish = require("./publish")
|
|
4
|
-
function Classes(action, argvs) {
|
|
5
|
-
cc[action](argvs[2])
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
module.exports = Classes;
|
|
1
|
+
const cc = {}
|
|
2
|
+
cc.create = require("./create")
|
|
3
|
+
cc.publish = require("./publish")
|
|
4
|
+
function Classes(action, argvs) {
|
|
5
|
+
cc[action](argvs[2])
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = Classes;
|
package/src/classes/publish.js
CHANGED
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path")
|
|
5
|
-
const chalk = require("chalk")
|
|
6
|
-
const { postNormal } = require("../../utils/http")
|
|
7
|
-
|
|
8
|
-
const { getBusToken } = require("../../utils/utils")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
module.exports = publish;
|
|
1
|
+
|
|
2
|
+
const { checkUpdate } = require("../../utils/checkVersion")
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path")
|
|
5
|
+
const chalk = require("chalk")
|
|
6
|
+
const { postNormal } = require("../../utils/http")
|
|
7
|
+
|
|
8
|
+
const { getBusToken } = require("../../utils/utils")
|
|
9
|
+
|
|
10
|
+
async function publish(name) {
|
|
11
|
+
let res = await checkUpdate();
|
|
12
|
+
if (!res) {
|
|
13
|
+
console.log();
|
|
14
|
+
console.log(chalk.green('Posting, please wait...'));
|
|
15
|
+
console.log();
|
|
16
|
+
const classPath = path.join(process.cwd(), `classes/${name}/`);
|
|
17
|
+
let classContent = fs.readFileSync(classPath + `${name}.java`, 'utf8');
|
|
18
|
+
let configContent = JSON.parse(fs.readFileSync(classPath + "config.json", 'utf8'));
|
|
19
|
+
|
|
20
|
+
if (await getBusToken()) {
|
|
21
|
+
let body = {
|
|
22
|
+
"id": configContent.id,
|
|
23
|
+
"name": name,
|
|
24
|
+
"version": configContent.version,
|
|
25
|
+
"source": encodeURI(classContent),
|
|
26
|
+
"folderId": "wgd"
|
|
27
|
+
}
|
|
28
|
+
let res = await postNormal(global.setupSvc + "/api/ccfag/save", body)
|
|
29
|
+
if (res.result) {
|
|
30
|
+
console.log(chalk.green('Success!'));
|
|
31
|
+
console.log();
|
|
32
|
+
|
|
33
|
+
if (!configContent.id) {
|
|
34
|
+
configContent.id = res.data
|
|
35
|
+
fs.writeFileSync(path.join(classPath, "config.json"), JSON.stringify(configContent))
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
module.exports = publish;
|
package/src/config/get.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
const chalk = require("chalk")
|
|
3
|
-
const path = require("path")
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
console.log(
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
module.exports = get;
|
|
1
|
+
|
|
2
|
+
const chalk = require("chalk")
|
|
3
|
+
const path = require("path")
|
|
4
|
+
|
|
5
|
+
async function get(projectPath = process.cwd()) {
|
|
6
|
+
let config = require(path.join(projectPath, "cloudcc-cli.config.js"))
|
|
7
|
+
if (config) {
|
|
8
|
+
console.log();
|
|
9
|
+
Object.keys(config).map((item) => {
|
|
10
|
+
if (item == config.use) {
|
|
11
|
+
console.log(chalk.green(`*${item}`));
|
|
12
|
+
} else if ("use" != item) {
|
|
13
|
+
console.log(item);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
console.log();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = get;
|
package/src/config/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const cc = {}
|
|
2
|
-
cc.use = require("./use")
|
|
3
|
-
cc.get = require("./get")
|
|
4
|
-
function main(action, argvs) {
|
|
5
|
-
cc[action](argvs[2], argvs[3])
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
module.exports = main;
|
|
1
|
+
const cc = {}
|
|
2
|
+
cc.use = require("./use")
|
|
3
|
+
cc.get = require("./get")
|
|
4
|
+
function main(action, argvs) {
|
|
5
|
+
cc[action](argvs[2], argvs[3])
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module.exports = main;
|
package/src/config/use.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
const path = require("path")
|
|
2
|
-
const fs = require("fs")
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
module.exports = use;
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const fs = require("fs")
|
|
3
|
+
|
|
4
|
+
function use(env, projectPath = process.cwd()) {
|
|
5
|
+
let config = require(path.join(projectPath, "cloudcc-cli.config.js"));
|
|
6
|
+
config.use = env;
|
|
7
|
+
fs.writeFileSync(path.join(projectPath, "cloudcc-cli.config.js"),
|
|
8
|
+
`module.exports =
|
|
9
|
+
${JSON.stringify(config)}
|
|
10
|
+
`
|
|
11
|
+
, 'utf8');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = use;
|