cloudcc-cli 1.9.8 → 2.0.0
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 +17 -0
- package/java/com/cloudcc/core/CCSchedule.java +5 -0
- package/java/com/cloudcc/core/CCService.java +5 -5
- package/java/com/cloudcc/core/Tool.java +15 -238
- package/package.json +1 -1
- package/pom.xml +1 -1
- package/src/classes/create.js +1 -1
- package/src/classes/publish.js +22 -20
- package/src/classes/pull.js +25 -24
- package/src/config/get.js +3 -14
- package/src/object/get.js +67 -68
- package/src/plugin/publish.js +1 -1
- package/src/plugin/publish1.js +12 -37
- package/src/recordType/get.js +6 -8
- package/src/script/publish.js +1 -5
- package/src/script/pull.js +1 -9
- package/src/timer/create.js +11 -6
- package/src/timer/publish.js +21 -20
- package/src/timer/pull.js +25 -24
- package/src/triggers/create.js +11 -6
- package/src/triggers/publish.js +26 -25
- package/src/triggers/pull.js +24 -25
- package/template/lib/ccopenapi-0.0.2.jar +0 -0
- package/utils/checkVersion.js +55 -1
- package/utils/config.js +71 -8
- package/utils/http.js +25 -59
- package/utils/utils.js +140 -81
- package/template/lib/ccopenapi-0.0.1.jar +0 -0
package/src/object/get.js
CHANGED
|
@@ -1,79 +1,78 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
|
|
1
|
+
const { postClass } = require("../../utils/http")
|
|
2
|
+
const { getPackageJson } = require("../../utils/config")
|
|
4
3
|
|
|
5
4
|
async function get(path, type, object) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
19
|
-
}
|
|
20
|
-
} else if ("chat" === type) {
|
|
21
|
-
//get chat object
|
|
22
|
-
let standardObjList = await postNormal(global.setupSvc + "/api/customObject/standardObjList");
|
|
23
|
-
standardObjList.data.map((item) => {
|
|
24
|
-
res.push({
|
|
25
|
-
apiname: item.label,
|
|
26
|
-
objname: item.objname,
|
|
27
|
-
objprefix: item.objprefix
|
|
28
|
-
})
|
|
5
|
+
let res = [];
|
|
6
|
+
let config = await getPackageJson(path);
|
|
7
|
+
if ("fields" === type) {
|
|
8
|
+
object = JSON.parse(decodeURI(object))
|
|
9
|
+
let fieldsResults = await postClass(config.setupSvc + "/api/fieldSetup/queryField", { prefix: object.objprefix }, config.accessToken)
|
|
10
|
+
res = {
|
|
11
|
+
...object,
|
|
12
|
+
fields: fieldsResults.data.stdFields.map((field) => {
|
|
13
|
+
return {
|
|
14
|
+
fieldname: field.labelName,
|
|
15
|
+
apiname: field.schemefieldName
|
|
16
|
+
}
|
|
29
17
|
})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
}
|
|
19
|
+
} else if ("chat" === type) {
|
|
20
|
+
//get chat object
|
|
21
|
+
let standardObjList = await postClass(config.setupSvc + "/api/customObject/standardObjList", {}, config.accessToken);
|
|
22
|
+
standardObjList.data.map((item) => {
|
|
23
|
+
res.push({
|
|
24
|
+
apiname: item.label,
|
|
25
|
+
objname: item.objname,
|
|
26
|
+
objprefix: item.objprefix
|
|
38
27
|
})
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
schemetableName: item.schemetableName
|
|
48
|
-
})
|
|
28
|
+
})
|
|
29
|
+
//get custom object
|
|
30
|
+
let customObjList = await postClass(config.setupSvc + "/api/customObject/list", {}, config.accessToken)
|
|
31
|
+
customObjList.data.objList.map((item) => {
|
|
32
|
+
res.push({
|
|
33
|
+
apiname: item.schemetableName,
|
|
34
|
+
objname: item.objLabel,
|
|
35
|
+
objprefix: item.prefix,
|
|
49
36
|
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
37
|
+
})
|
|
38
|
+
} else if ("trigger" === type) {
|
|
39
|
+
//get trigger object
|
|
40
|
+
let triggerObjList = await postClass(config.setupSvc + "/api/trigger/newobjtrigger", {}, config.accessToken)
|
|
41
|
+
triggerObjList.data.targetObjList.map((item) => {
|
|
42
|
+
res.push({
|
|
43
|
+
id: item.id,
|
|
44
|
+
label: item.label,
|
|
45
|
+
objname: item.schemetable_name,
|
|
46
|
+
schemetableName: item.schemetableName
|
|
61
47
|
})
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
} else {
|
|
51
|
+
//get standar object
|
|
52
|
+
let standardObjList = await postClass(config.setupSvc + "/api/customObject/standardObjList", {}, config.accessToken)
|
|
53
|
+
standardObjList.data.forEach((item) => {
|
|
54
|
+
res.push({
|
|
55
|
+
id: item.id,
|
|
56
|
+
label: item.objname,
|
|
57
|
+
objname: item.label,
|
|
58
|
+
objprefix: item.objprefix,
|
|
59
|
+
schemetableName: item.label
|
|
72
60
|
})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
})
|
|
62
|
+
//get custom object
|
|
63
|
+
let customObjList = await postClass(config.setupSvc + "/api/customObject/list", {}, config.accessToken)
|
|
64
|
+
customObjList.data.objList.map((item) => {
|
|
65
|
+
res.push({
|
|
66
|
+
id: item.id,
|
|
67
|
+
label: item.objLabel,
|
|
68
|
+
objname: item.schemetable_name,
|
|
69
|
+
objprefix: item.prefix,
|
|
70
|
+
schemetableName: item.schemetableName
|
|
71
|
+
})
|
|
72
|
+
})
|
|
76
73
|
}
|
|
74
|
+
console.log(JSON.stringify(res));
|
|
75
|
+
return res
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
module.exports = get;
|
package/src/plugin/publish.js
CHANGED
|
@@ -22,7 +22,7 @@ class Builder {
|
|
|
22
22
|
async init() {
|
|
23
23
|
let res = await checkUpdate();
|
|
24
24
|
if (!res) {
|
|
25
|
-
this.options.devConsoleConfig = getPackageJson();
|
|
25
|
+
this.options.devConsoleConfig = await getPackageJson();
|
|
26
26
|
let config = this.options.devConsoleConfig
|
|
27
27
|
|
|
28
28
|
if ("private" != this.options.devConsoleConfig.version) {
|
package/src/plugin/publish1.js
CHANGED
|
@@ -3,7 +3,6 @@ const { post } = require('../../utils/http');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const chalk = require("chalk")
|
|
6
|
-
const { readCache, writeCache } = require("../../utils/cache")
|
|
7
6
|
|
|
8
7
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
9
8
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
@@ -24,17 +23,12 @@ class Builder {
|
|
|
24
23
|
async publish(name) {
|
|
25
24
|
let res = await checkUpdate();
|
|
26
25
|
if (!res) {
|
|
27
|
-
this.options.devConsoleConfig = getPackageJson();
|
|
26
|
+
this.options.devConsoleConfig = await getPackageJson();
|
|
28
27
|
this.options.pluginConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), `plugins/${name}/config.json`), 'utf8'));
|
|
29
28
|
let config = this.options.devConsoleConfig
|
|
30
29
|
|
|
31
30
|
if ("private" != this.options.devConsoleConfig.version) {
|
|
32
|
-
|
|
33
|
-
if (token) {
|
|
34
|
-
config = { "accessToken": token };
|
|
35
|
-
} else {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
31
|
+
config = { "accessToken": this.options.devConsoleConfig.pluginToken };
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
let answers = { buildFileName: `${name}/${name}.vue` }
|
|
@@ -59,33 +53,6 @@ class Builder {
|
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
|
|
62
|
-
async getToken(devConsoleConfig) {
|
|
63
|
-
const cache = readCache();
|
|
64
|
-
const cacheKey = `plugin_token_${devConsoleConfig.secretKey}`;
|
|
65
|
-
const now = Date.now();
|
|
66
|
-
const oneHour = 60 * 60 * 1000;
|
|
67
|
-
|
|
68
|
-
if (cache[cacheKey] &&
|
|
69
|
-
cache[cacheKey].token &&
|
|
70
|
-
cache[cacheKey].timestamp &&
|
|
71
|
-
(now - cache[cacheKey].timestamp) < oneHour) {
|
|
72
|
-
return cache[cacheKey].token;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let res = await post((this.options.devConsoleConfig.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
|
|
76
|
-
if (res.returnCode == 200) {
|
|
77
|
-
cache[cacheKey] = {
|
|
78
|
-
token: res.data.accessToken,
|
|
79
|
-
timestamp: now
|
|
80
|
-
};
|
|
81
|
-
writeCache(process.cwd(), cache);
|
|
82
|
-
return res.data.accessToken;
|
|
83
|
-
} else {
|
|
84
|
-
console.error(chalk.red(`Login failed`, JSON.stringify(res)));
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
56
|
getVueValue(buildFileName) {
|
|
90
57
|
let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
|
|
91
58
|
let vueData = vueContent + ""
|
|
@@ -96,8 +63,16 @@ class Builder {
|
|
|
96
63
|
}
|
|
97
64
|
vueData = vueData.split(/data\s*\(\s*\)/)[1].split(/isLock\s*:/)[0] + "isLock:false,};}";
|
|
98
65
|
vueData = "function data()" + vueData;
|
|
99
|
-
|
|
100
|
-
|
|
66
|
+
let data = {}
|
|
67
|
+
try {
|
|
68
|
+
data = eval(`(${vueData})`)()
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
console.log()
|
|
72
|
+
console.log(chalk.red("Error: The data function cannot contain reference variables."));
|
|
73
|
+
console.log()
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
101
76
|
if (!data.propObj) {
|
|
102
77
|
data.propObj = {};
|
|
103
78
|
data.propOption = {};
|
package/src/recordType/get.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
1
|
+
const { postClass } = require("../../utils/http")
|
|
2
|
+
const { getPackageJson } = require("../../utils/config")
|
|
3
3
|
|
|
4
4
|
async function get(path, prefix) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return res.data
|
|
10
|
-
}
|
|
5
|
+
let config = await getPackageJson();
|
|
6
|
+
let res = await postClass(config.apiSvc + "/api/batch/getRecordType", { prefix: prefix }, config.accessToken)
|
|
7
|
+
console.log(JSON.stringify(res.data.recordTypeList))
|
|
8
|
+
return res.data
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
module.exports = get;
|
package/src/script/publish.js
CHANGED
|
@@ -6,7 +6,6 @@ const chalk = require("chalk")
|
|
|
6
6
|
const { post } = require("../../utils/http")
|
|
7
7
|
const { getPackageJson } = require("../../utils/config.js")
|
|
8
8
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
9
|
-
const { getBusToken } = require("../../utils/utils")
|
|
10
9
|
|
|
11
10
|
function checkMainFunctionExists(content) {
|
|
12
11
|
const mainFunctionPattern = /^function\s+main\s*\(\$CCDK,\s*obj\)\s*\{/m;
|
|
@@ -39,10 +38,7 @@ async function publish(argvs) {
|
|
|
39
38
|
let configContentOld = JSON.parse(JSON.stringify(configContent))
|
|
40
39
|
|
|
41
40
|
if (scriptContent) {
|
|
42
|
-
let devConsoleConfig = getPackageJson()
|
|
43
|
-
if ("private" != devConsoleConfig.version) {
|
|
44
|
-
devConsoleConfig.accessToken = await getBusToken();
|
|
45
|
-
}
|
|
41
|
+
let devConsoleConfig = await getPackageJson()
|
|
46
42
|
console.log(chalk.green('Posting, please wait...'));
|
|
47
43
|
configContent.scriptContent = scriptContent.trim()
|
|
48
44
|
let res = await post((devConsoleConfig.baseUrl || BaseUrl) + "/devconsole/script/saveClientScript", configContent, devConsoleConfig)
|
package/src/script/pull.js
CHANGED
|
@@ -6,12 +6,7 @@ const chalk = require("chalk")
|
|
|
6
6
|
const { post } = require("../../utils/http.js")
|
|
7
7
|
const { getPackageJson } = require("../../utils/config.js")
|
|
8
8
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
9
|
-
const { getBusToken } = require("../../utils/utils.js")
|
|
10
9
|
|
|
11
|
-
function checkMainFunctionExists(content) {
|
|
12
|
-
const mainFunctionPattern = /^function\s+main\s*\(\$CCDK,\s*obj\)\s*\{/m;
|
|
13
|
-
return mainFunctionPattern.test(content);
|
|
14
|
-
}
|
|
15
10
|
|
|
16
11
|
async function pull(argvs) {
|
|
17
12
|
let namePath = argvs[2]
|
|
@@ -20,10 +15,7 @@ async function pull(argvs) {
|
|
|
20
15
|
if (!res) {
|
|
21
16
|
const srcPath = path.join(process.cwd(), `script/${namePath}/`);
|
|
22
17
|
|
|
23
|
-
let devConsoleConfig = getPackageJson()
|
|
24
|
-
if ("private" != devConsoleConfig.version) {
|
|
25
|
-
devConsoleConfig.accessToken = await getBusToken();
|
|
26
|
-
}
|
|
18
|
+
let devConsoleConfig = await getPackageJson()
|
|
27
19
|
console.log(chalk.green('Pulling, please wait...'));
|
|
28
20
|
let configContent = JSON.parse(fs.readFileSync(srcPath + "config.json", 'utf8'));
|
|
29
21
|
configContent = {
|
package/src/timer/create.js
CHANGED
|
@@ -11,15 +11,20 @@ async function create(name) {
|
|
|
11
11
|
try {
|
|
12
12
|
fs.mkdirSync(timerPath, { recursive: true })
|
|
13
13
|
|
|
14
|
-
const javaTmp =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const javaTmp =
|
|
15
|
+
`package schedule.${name};
|
|
16
|
+
|
|
17
|
+
import com.cloudcc.core.*;
|
|
18
|
+
|
|
19
|
+
public class ${name} extends CCSchedule {
|
|
20
|
+
public ${name}() {
|
|
21
|
+
// @SOURCE_CONTENT_START
|
|
22
|
+
System.out.print("hello World");
|
|
23
|
+
// @SOURCE_CONTENT_END
|
|
19
24
|
}
|
|
20
25
|
}`
|
|
21
26
|
fs.writeFileSync(path.join(timerPath, name + ".java"), javaTmp)
|
|
22
|
-
fs.writeFileSync(path.join(timerPath, "config.json"), `{"name":"${name}","version":"${getPackageJson().extandVersion || '2'}"}`)
|
|
27
|
+
fs.writeFileSync(path.join(timerPath, "config.json"), `{"name":"${name}","version":"${await getPackageJson().extandVersion || '2'}"}`)
|
|
23
28
|
console.log()
|
|
24
29
|
console.log(chalk.green("Successfully Created:" + name))
|
|
25
30
|
console.log()
|
package/src/timer/publish.js
CHANGED
|
@@ -2,10 +2,11 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
const { postNormal } = require("../../utils/http")
|
|
6
5
|
|
|
7
|
-
const {
|
|
6
|
+
const { javaContentRegular } = require("../../utils/utils")
|
|
8
7
|
|
|
8
|
+
const { getPackageJson } = require("../../utils/config")
|
|
9
|
+
const { postClass } = require("../../utils/http")
|
|
9
10
|
async function publish(name) {
|
|
10
11
|
let res = await checkUpdate();
|
|
11
12
|
if (!res) {
|
|
@@ -20,26 +21,26 @@ async function publish(name) {
|
|
|
20
21
|
|
|
21
22
|
let configContent = JSON.parse(fs.readFileSync(timerPath + "config.json", 'utf8'));
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
let body = {
|
|
25
|
+
"id": configContent.id,
|
|
26
|
+
"name": name,
|
|
27
|
+
"version": configContent.version || "2",
|
|
28
|
+
"source": encodeURIComponent(classContent.trim()),
|
|
29
|
+
"folderId": "wgd"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let config = await getPackageJson();
|
|
33
|
+
let res = await postClass(config.setupSvc + "/api/ccPeak/save", body, config.accessToken)
|
|
34
|
+
if (res.result) {
|
|
35
|
+
console.log(chalk.green('Success!'));
|
|
36
|
+
console.log();
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
38
|
+
if (!configContent.id) {
|
|
39
|
+
configContent.id = res.data
|
|
40
|
+
fs.writeFileSync(path.join(timerPath, "config.json"), JSON.stringify(configContent))
|
|
42
41
|
}
|
|
42
|
+
} else {
|
|
43
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}
|
package/src/timer/pull.js
CHANGED
|
@@ -2,9 +2,11 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
const { postNormal } = require("../../utils/http")
|
|
6
5
|
|
|
7
|
-
const {
|
|
6
|
+
const { javaContentRegular } = require("../../utils/utils")
|
|
7
|
+
|
|
8
|
+
const { getPackageJson } = require("../../utils/config")
|
|
9
|
+
const { postClass } = require("../../utils/http")
|
|
8
10
|
|
|
9
11
|
async function pull(name) {
|
|
10
12
|
let res = await checkUpdate();
|
|
@@ -17,31 +19,30 @@ async function pull(name) {
|
|
|
17
19
|
|
|
18
20
|
let configContent = JSON.parse(fs.readFileSync(timerPath + "config.json", 'utf8'));
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let newContent = '';
|
|
31
|
-
if (fullContent.includes("@SOURCE_CONTENT_START")) {
|
|
32
|
-
newContent = fullContent.replace(
|
|
33
|
-
javaContentRegular,
|
|
34
|
-
`// @SOURCE_CONTENT_START\n${res.data.trigger.source}\n// @SOURCE_CONTENT_END`
|
|
35
|
-
);
|
|
36
|
-
} else {
|
|
37
|
-
newContent = res.data.trigger.tsource;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fs.writeFileSync(timerPath + `${name}.java`, newContent, 'utf8');
|
|
22
|
+
let body = {
|
|
23
|
+
"id": configContent.id,
|
|
24
|
+
}
|
|
25
|
+
let config = await getPackageJson();
|
|
26
|
+
let res = await postClass(config.setupSvc + "/api/ccPeak/detail", body, config.accessToken)
|
|
27
|
+
if (res.result) {
|
|
28
|
+
console.log(chalk.green('Success!'));
|
|
29
|
+
console.log
|
|
30
|
+
let fullContent = fs.readFileSync(timerPath + `${name}.java`, 'utf8');
|
|
41
31
|
|
|
32
|
+
let newContent = '';
|
|
33
|
+
if (fullContent.includes("@SOURCE_CONTENT_START")) {
|
|
34
|
+
newContent = fullContent.replace(
|
|
35
|
+
javaContentRegular,
|
|
36
|
+
`// @SOURCE_CONTENT_START\n${res.data.trigger.source}\n// @SOURCE_CONTENT_END`
|
|
37
|
+
);
|
|
42
38
|
} else {
|
|
43
|
-
|
|
39
|
+
newContent = res.data.trigger.tsource;
|
|
44
40
|
}
|
|
41
|
+
|
|
42
|
+
fs.writeFileSync(timerPath + `${name}.java`, newContent, 'utf8');
|
|
43
|
+
|
|
44
|
+
} else {
|
|
45
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
}
|
package/src/triggers/create.js
CHANGED
|
@@ -16,16 +16,21 @@ async function create(argvs) {
|
|
|
16
16
|
fs.mkdirSync(objectFolderPath, { recursive: true });
|
|
17
17
|
fs.mkdirSync(triggersPath, { recursive: true });
|
|
18
18
|
|
|
19
|
-
const javaTmp =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const javaTmp =
|
|
20
|
+
`package triggers.${body.schemetableName.toLowerCase()}.${body.name};
|
|
21
|
+
|
|
22
|
+
import com.cloudcc.core.*;
|
|
23
|
+
|
|
24
|
+
public class ${body.name} extends CCTrigger {
|
|
25
|
+
public ${body.name}() {
|
|
26
|
+
// @SOURCE_CONTENT_START
|
|
27
|
+
System.out.print("hello World");
|
|
28
|
+
// @SOURCE_CONTENT_END
|
|
24
29
|
}
|
|
25
30
|
}`
|
|
26
31
|
|
|
27
32
|
fs.writeFileSync(path.join(triggersPath, body.name + ".java"), javaTmp);
|
|
28
|
-
body.version = getPackageJson().extandVersion || "2";
|
|
33
|
+
body.version =await getPackageJson().extandVersion || "2";
|
|
29
34
|
body.isactive = true;
|
|
30
35
|
fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(body));
|
|
31
36
|
console.log();
|
package/src/triggers/publish.js
CHANGED
|
@@ -2,8 +2,9 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
5
|
+
const { javaContentRegular } = require("../../utils/utils")
|
|
6
|
+
const { getPackageJson } = require("../../utils/config")
|
|
7
|
+
const { postClass } = require("../../utils/http")
|
|
7
8
|
|
|
8
9
|
async function publish(argvs) {
|
|
9
10
|
let namePath = argvs[2]
|
|
@@ -20,31 +21,31 @@ async function publish(argvs) {
|
|
|
20
21
|
let triggersContent = sourceMatch ? sourceMatch[1] : fullContent;
|
|
21
22
|
let configContent = JSON.parse(fs.readFileSync(triggersPath + "config.json", 'utf8'));
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
let body = {
|
|
25
|
+
"id": configContent.id,
|
|
26
|
+
"apiname": configContent.apiname,
|
|
27
|
+
"isactive": configContent.isactive,
|
|
28
|
+
"targetObjectId": configContent.targetObjectId,
|
|
29
|
+
"triggerTime": configContent.triggerTime,
|
|
30
|
+
"name": name,
|
|
31
|
+
"version": configContent.version || "2",
|
|
32
|
+
"triggerSource": encodeURIComponent(triggersContent.trim()),
|
|
33
|
+
"folderId": "wgd"
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let config = await getPackageJson();
|
|
37
|
+
let res = await postClass(config.setupSvc + "/api/triggerSetup/saveTrigger", body, config.accessToken)
|
|
38
|
+
if (res.result) {
|
|
39
|
+
console.log(chalk.green('Success!'));
|
|
40
|
+
console.log();
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
42
|
+
if (!configContent.id) {
|
|
43
|
+
configContent.id = res.data.id
|
|
44
|
+
configContent.apiname = res.data.apiname
|
|
45
|
+
fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(configContent))
|
|
47
46
|
}
|
|
47
|
+
} else {
|
|
48
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
}
|
package/src/triggers/pull.js
CHANGED
|
@@ -2,9 +2,9 @@ const { checkUpdate } = require("../../utils/checkVersion")
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path")
|
|
4
4
|
const chalk = require("chalk")
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
7
|
-
|
|
5
|
+
const { javaContentRegular } = require("../../utils/utils")
|
|
6
|
+
const { getPackageJson } = require("../../utils/config")
|
|
7
|
+
const { postClass } = require("../../utils/http")
|
|
8
8
|
async function pull(argvs) {
|
|
9
9
|
let namePath = argvs[2]
|
|
10
10
|
let name = namePath.split("/")[1]
|
|
@@ -16,31 +16,30 @@ async function pull(argvs) {
|
|
|
16
16
|
const triggersPath = path.join(process.cwd(), `triggers/${namePath}/`);
|
|
17
17
|
let configContent = JSON.parse(fs.readFileSync(triggersPath + "config.json", 'utf8'));
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
let fullContent = fs.readFileSync(triggersPath + `${name}.java`, 'utf8');
|
|
29
|
-
let newContent = '';
|
|
30
|
-
if (fullContent.includes("@SOURCE_CONTENT_START")) {
|
|
31
|
-
newContent = fullContent.replace(
|
|
32
|
-
javaContentRegular,
|
|
33
|
-
`// @SOURCE_CONTENT_START\n${res.data.trigger.triggerSource}\n// @SOURCE_CONTENT_END`
|
|
34
|
-
);
|
|
35
|
-
} else {
|
|
36
|
-
newContent = res.data.trigger.triggerSource;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
fs.writeFileSync(triggersPath + `${name}.java`, newContent);
|
|
19
|
+
let body = {
|
|
20
|
+
"id": configContent.id,
|
|
21
|
+
}
|
|
22
|
+
let config = await getPackageJson();
|
|
23
|
+
let res = await postClass(config.setupSvc + "/api/trigger/newobjtrigger", body, config.accessToken)
|
|
24
|
+
if (res.result) {
|
|
25
|
+
console.log(chalk.green('Success!'));
|
|
26
|
+
console.log();
|
|
40
27
|
|
|
28
|
+
let fullContent = fs.readFileSync(triggersPath + `${name}.java`, 'utf8');
|
|
29
|
+
let newContent = '';
|
|
30
|
+
if (fullContent.includes("@SOURCE_CONTENT_START")) {
|
|
31
|
+
newContent = fullContent.replace(
|
|
32
|
+
javaContentRegular,
|
|
33
|
+
`// @SOURCE_CONTENT_START\n${res.data.trigger.triggerSource}\n// @SOURCE_CONTENT_END`
|
|
34
|
+
);
|
|
41
35
|
} else {
|
|
42
|
-
|
|
36
|
+
newContent = res.data.trigger.triggerSource;
|
|
43
37
|
}
|
|
38
|
+
|
|
39
|
+
fs.writeFileSync(triggersPath + `${name}.java`, newContent);
|
|
40
|
+
|
|
41
|
+
} else {
|
|
42
|
+
console.log(chalk.red('Fail:' + res.returnInfo));
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
}
|
|
Binary file
|