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 CHANGED
@@ -1,3 +1,10 @@
1
+ # ReleaseV1.8.0
2
+ #### 发布日期:2025-1-20
3
+ #### 发布范围:全量
4
+ #### 发布内容
5
+ * 优化
6
+ * 创建触发器和客户端脚本添加文件夹
7
+
1
8
  # ReleaseV1.7.9
2
9
  #### 发布日期:2025-1-15
3
10
  #### 发布范围:全量
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "1.7.9",
3
+ "version": "1.8.0",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -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 filePath = path.join(process.cwd(), "script/" + body.scriptName);
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
- fs.mkdirSync(filePath, { recursive: true })
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")
@@ -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 name = argvs[2]
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/${name}/`);
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))
@@ -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 triggersPath = path.join(process.cwd(), "triggers/" + body.name);
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
- fs.mkdirSync(triggersPath, { recursive: true })
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
- fs.writeFileSync(path.join(triggersPath, body.name + ".java"), javaTmp)
17
- fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(body))
18
- console.log()
19
- console.log(chalk.green("Successfully Created:" + body.name))
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))
@@ -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 name = argvs[2]
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/${name}/`);
16
+ const triggersPath = path.join(process.cwd(), `triggers/${namePath}/`);
16
17
  let fullContent = fs.readFileSync(triggersPath + `${name}.java`, 'utf8');
17
18
 
18
19
  // 提取标记之间的内容