cloudcc-cli 1.7.9 → 1.8.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 +7 -0
- package/package.json +1 -1
- package/src/script/create.js +8 -2
- package/src/script/publish.js +3 -2
- package/src/triggers/create.js +14 -7
- package/src/triggers/publish.js +3 -2
package/README.md
CHANGED
package/package.json
CHANGED
package/src/script/create.js
CHANGED
|
@@ -7,9 +7,15 @@ async function create(argvs) {
|
|
|
7
7
|
let res = await checkUpdate();
|
|
8
8
|
if (!res) {
|
|
9
9
|
let body = JSON.parse(decodeURI(argvs[2]))
|
|
10
|
-
const
|
|
10
|
+
const baseScriptPath = path.join(process.cwd(), "script");
|
|
11
|
+
const objectFolderPath = path.join(baseScriptPath, body.objId);
|
|
12
|
+
const filePath = path.join(objectFolderPath, body.scriptName);
|
|
13
|
+
|
|
11
14
|
try {
|
|
12
|
-
|
|
15
|
+
// 确保对象文件夹和脚本文件夹都存在
|
|
16
|
+
fs.mkdirSync(objectFolderPath, { recursive: true });
|
|
17
|
+
fs.mkdirSync(filePath, { recursive: true });
|
|
18
|
+
|
|
13
19
|
const fileTmp =
|
|
14
20
|
`function main($CCDK, obj){
|
|
15
21
|
console.log("hello World")
|
package/src/script/publish.js
CHANGED
|
@@ -9,10 +9,11 @@ const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
|
9
9
|
const { getBusToken } = require("../../utils/utils")
|
|
10
10
|
|
|
11
11
|
async function publish(argvs) {
|
|
12
|
-
let
|
|
12
|
+
let namePath = argvs[2]
|
|
13
|
+
let name = namePath.split("/")[1]
|
|
13
14
|
let res = await checkUpdate();
|
|
14
15
|
if (!res) {
|
|
15
|
-
const srcPath = path.join(process.cwd(), `script/${
|
|
16
|
+
const srcPath = path.join(process.cwd(), `script/${namePath}/`);
|
|
16
17
|
let classContent = fs.readFileSync(srcPath + `${name}.js`, 'utf8').replace(/\s+/g, '').replace(/\n/g, '').match(/\{([\s\S]*?)\}/)[1];
|
|
17
18
|
let configContent = JSON.parse(fs.readFileSync(srcPath + "config.json", 'utf8'));
|
|
18
19
|
let configContentOld = JSON.parse(JSON.stringify(configContent))
|
package/src/triggers/create.js
CHANGED
|
@@ -7,17 +7,24 @@ async function create(argvs) {
|
|
|
7
7
|
let res = await checkUpdate();
|
|
8
8
|
if (!res) {
|
|
9
9
|
let body = JSON.parse(decodeURI(argvs[2]))
|
|
10
|
-
const
|
|
10
|
+
const baseTriggersPath = path.join(process.cwd(), "triggers");
|
|
11
|
+
const objectFolderPath = path.join(baseTriggersPath, body.targetObjectId);
|
|
12
|
+
const triggersPath = path.join(objectFolderPath, body.name);
|
|
13
|
+
|
|
11
14
|
try {
|
|
12
|
-
|
|
15
|
+
// 确保对象文件夹和触发器文件夹都存在
|
|
16
|
+
fs.mkdirSync(objectFolderPath, { recursive: true });
|
|
17
|
+
fs.mkdirSync(triggersPath, { recursive: true });
|
|
18
|
+
|
|
13
19
|
const javaTmp = `// @SOURCE_CONTENT_START
|
|
14
20
|
System.out.print("hello World");
|
|
15
21
|
// @SOURCE_CONTENT_END`
|
|
16
|
-
|
|
17
|
-
fs.writeFileSync(path.join(triggersPath, "
|
|
18
|
-
|
|
19
|
-
console.log(
|
|
20
|
-
console.log()
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync(path.join(triggersPath, body.name + ".java"), javaTmp);
|
|
24
|
+
fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(body));
|
|
25
|
+
console.log();
|
|
26
|
+
console.log(chalk.green("Successfully Created:" + body.name));
|
|
27
|
+
console.log();
|
|
21
28
|
} catch (e) {
|
|
22
29
|
console.log()
|
|
23
30
|
console.log(chalk.red("Creation Failed:" + e))
|
package/src/triggers/publish.js
CHANGED
|
@@ -6,13 +6,14 @@ const { postNormal } = require("../../utils/http")
|
|
|
6
6
|
const { getBusToken } = require("../../utils/utils")
|
|
7
7
|
|
|
8
8
|
async function publish(argvs) {
|
|
9
|
-
let
|
|
9
|
+
let namePath = argvs[2]
|
|
10
|
+
let name = namePath.split("/")[1]
|
|
10
11
|
let res = await checkUpdate();
|
|
11
12
|
if (!res) {
|
|
12
13
|
console.log();
|
|
13
14
|
console.log(chalk.green('Posting, please wait...'));
|
|
14
15
|
console.log();
|
|
15
|
-
const triggersPath = path.join(process.cwd(), `triggers/${
|
|
16
|
+
const triggersPath = path.join(process.cwd(), `triggers/${namePath}/`);
|
|
16
17
|
let fullContent = fs.readFileSync(triggersPath + `${name}.java`, 'utf8');
|
|
17
18
|
|
|
18
19
|
// 提取标记之间的内容
|