cloudcc-cli 2.0.1 → 2.0.3

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,18 @@
1
+ # ReleaseV2.0.3
2
+ #### Release Date: 2025-4-8
3
+ #### Release Scope: Full
4
+ #### Release Content
5
+ * Optimization
6
+ * Added CloudCCDev field initialization for configuration files and optimized error handling for obtaining plugin tokens
7
+
8
+
9
+ # ReleaseV2.0.2
10
+ #### Release Date: 2025-4-2
11
+ #### Release Scope: Full
12
+ #### Release Content
13
+ * Optimization
14
+ * Fix baseUrl Prefix
15
+
1
16
  # ReleaseV2.0.1
2
17
  #### Release Date: 2025-4-2
3
18
  #### Release Scope: Full
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -49,13 +49,14 @@ public class ${name}Test {
49
49
  `
50
50
  fs.writeFileSync(path.join(classesPath, name + ".java"), javaTmp)
51
51
  fs.writeFileSync(path.join(classesPath, name + "Test.java"), javaTestTmp)
52
- fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"${await getPackageJson().extandVersion || '2'}"}`)
52
+ let config = await getPackageJson();
53
+ fs.writeFileSync(path.join(classesPath, "config.json"), `{"name":"${name}","version":"${config.extandVersion || '2'}"}`)
53
54
  console.log()
54
55
  console.log(chalk.green("Successfully Created:" + name))
55
56
  console.log()
56
57
  } catch (e) {
57
58
  console.log()
58
- console.log(chalk.red("Creation Failed:" + e))
59
+ console.log(chalk.red("Creation Class Failed:" + e))
59
60
  console.log()
60
61
  }
61
62
  }
@@ -40,7 +40,7 @@ async function publish(name) {
40
40
  fs.writeFileSync(path.join(classPath, "config.json"), JSON.stringify(configContent))
41
41
  }
42
42
  } else {
43
- console.log(chalk.red('Failed:' + res.returnInfo));
43
+ console.log(chalk.red('Publish Class Failed:' + res.returnInfo));
44
44
  }
45
45
  }
46
46
  }
@@ -44,7 +44,7 @@ async function pull(name) {
44
44
  fs.writeFileSync(classPath + `${name}.java`, newContent, 'utf8');
45
45
 
46
46
  } else {
47
- console.log(chalk.red('Pull Fail:' + res.returnInfo));
47
+ console.log(chalk.red('Pull Class Failed:' + res.returnInfo));
48
48
  }
49
49
  }
50
50
  }
package/src/config/get.js CHANGED
@@ -2,7 +2,7 @@
2
2
  const { getPackageJson } = require("../../utils/config.js")
3
3
 
4
4
  async function get(projectPath = process.cwd()) {
5
- const config = await getPackageJson();
5
+ const config = await getPackageJson(projectPath);
6
6
  console.log(config);
7
7
  }
8
8
 
@@ -24,6 +24,7 @@ class Builder {
24
24
  let res = await checkUpdate();
25
25
  if (!res) {
26
26
  this.options.devConsoleConfig = await getPackageJson();
27
+ this.options.devConsoleConfig.CloudCCDev = "";
27
28
  this.options.pluginConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), `plugins/${name}/config.json`), 'utf8'));
28
29
  let config = this.options.devConsoleConfig
29
30
 
@@ -65,7 +66,7 @@ class Builder {
65
66
  return cache[cacheKey].token;
66
67
  }
67
68
 
68
- let res = await post((this.options.devConsoleConfig.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
69
+ let res = await post((this.options.devConsoleConfig.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo", { username: devConsoleConfig.username, secretKey: devConsoleConfig.secretKey });
69
70
  if (res.returnCode == 200) {
70
71
  cache[cacheKey] = {
71
72
  token: res.data.accessToken,
@@ -26,7 +26,7 @@ async function create(argvs) {
26
26
  console.log()
27
27
  } catch (e) {
28
28
  console.log()
29
- console.log(chalk.red("Creation Failed:" + e))
29
+ console.log(chalk.red("Creation Client Script Failed:" + e))
30
30
  console.log()
31
31
  }
32
32
  }
@@ -24,13 +24,14 @@ public class ${name} extends CCSchedule {
24
24
  }
25
25
  }`
26
26
  fs.writeFileSync(path.join(timerPath, name + ".java"), javaTmp)
27
- fs.writeFileSync(path.join(timerPath, "config.json"), `{"name":"${name}","version":"${await getPackageJson().extandVersion || '2'}"}`)
27
+ let config = await getPackageJson();
28
+ fs.writeFileSync(path.join(timerPath, "config.json"), `{"name":"${name}","version":"${config.extandVersion || '2'}"}`)
28
29
  console.log()
29
30
  console.log(chalk.green("Successfully Created:" + name))
30
31
  console.log()
31
32
  } catch (e) {
32
33
  console.log()
33
- console.log(chalk.red("Creation Failed:" + e))
34
+ console.log(chalk.red("Creation Schedule Failed:" + e))
34
35
  console.log()
35
36
  }
36
37
  }
@@ -17,7 +17,7 @@ async function create(argvs) {
17
17
  fs.mkdirSync(triggersPath, { recursive: true });
18
18
 
19
19
  const javaTmp =
20
- `package triggers.${body.schemetableName.toLowerCase()}.${body.name};
20
+ `package triggers.${body.schemetableName.toLowerCase()}.${body.name};
21
21
 
22
22
  import com.cloudcc.core.*;
23
23
 
@@ -30,7 +30,8 @@ public class ${body.name} extends CCTrigger {
30
30
  }`
31
31
 
32
32
  fs.writeFileSync(path.join(triggersPath, body.name + ".java"), javaTmp);
33
- body.version =await getPackageJson().extandVersion || "2";
33
+ let config = await getPackageJson();
34
+ body.version = config.extandVersion || "2";
34
35
  body.isactive = true;
35
36
  fs.writeFileSync(path.join(triggersPath, "config.json"), JSON.stringify(body));
36
37
  console.log();
@@ -38,7 +39,7 @@ public class ${body.name} extends CCTrigger {
38
39
  console.log();
39
40
  } catch (e) {
40
41
  console.log()
41
- console.log(chalk.red("Creation Failed:" + e))
42
+ console.log(chalk.red("Creation Trigger Failed:" + e))
42
43
  console.log()
43
44
  }
44
45
  }
@@ -107,7 +107,6 @@ function checkAndReplaceJar(projectPath = process.cwd()) {
107
107
  const templateLibPath = path.join(__dirname, '../template/lib');
108
108
 
109
109
  if (!fs.existsSync(projectLibPath)) {
110
- console.log(chalk.red('Project lib folder does not exist.'));
111
110
  return;
112
111
  }
113
112
 
package/utils/config.js CHANGED
@@ -21,9 +21,7 @@ function getPackageJson_old(projectPath = process.cwd()) {
21
21
  async function getPackageJson2(projectPath = process.cwd()) {
22
22
  let config = require(path.join(projectPath, "cloudcc-cli.config.js"))
23
23
  config = config[config.use]
24
- if (config.baseUrl && !config.baseUrl.includes("ccdomaingateway")) {
25
- config.baseUrl = config.baseUrl + "/ccdomaingateway"
26
- }
24
+ config.CloudCCDev = "";
27
25
  config = await getDevConsoleConfig(projectPath, config)
28
26
  return config
29
27
  }
@@ -40,10 +38,11 @@ async function getPackageJson3(projectPath = process.cwd()) {
40
38
  if (config && config.CloudCCDev) {
41
39
  const decryptedInfo = decryptCloudCCDevInfo(config.CloudCCDev);
42
40
  if (decryptedInfo) {
43
- config = { ...decryptedInfo, ...config }
44
- if (config.baseUrl && !config.baseUrl.includes("ccdomaingateway")) {
45
- config.baseUrl = config.baseUrl + "/ccdomaingateway"
41
+ if (decryptedInfo.baseUrl && !decryptedInfo.baseUrl.includes("ccdomaingateway")) {
42
+ decryptedInfo.baseUrl = decryptedInfo.baseUrl + "/ccdomaingateway"
46
43
  }
44
+ config = { ...decryptedInfo, ...config }
45
+ config.CloudCCDev = "";
47
46
  config = await getDevConsoleConfig(projectPath, config)
48
47
  }
49
48
  } else {
package/utils/utils.js CHANGED
@@ -43,18 +43,24 @@ async function getBaseUrl(config) {
43
43
  * @returns config
44
44
  */
45
45
  async function getPluginToken(config) {
46
- let res = await axios({
47
- method: 'post',
48
- url: (config.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo",
49
- data: formateData({ username: config.username, secretKey: config.secretKey }),
50
- headers: {
51
- 'Content-Type': 'application/json; charset=utf-8',
52
- },
53
- });
54
- if (res.data.returnCode == 200) {
55
- config.pluginToken = res.data.data.accessToken;
56
- } else {
57
- console.error(chalk.red(`Get Plugin Token Failed:`, res.data.returnInfo, "\nPrivate cloud, please check whether the baseUrl is configured correctly"));
46
+ const url = (config.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo";
47
+ try {
48
+ let res = await axios({
49
+ method: 'post',
50
+ url,
51
+ data: formateData({ username: config.username, secretKey: config.secretKey }),
52
+ headers: {
53
+ 'Content-Type': 'application/json; charset=utf-8',
54
+ },
55
+ });
56
+ if (res.data.returnCode == 200) {
57
+ config.pluginToken = res.data.data.accessToken;
58
+ } else {
59
+ console.error(chalk.red(`Get Plugin Token Failed:`, res.data.returnInfo, "\nPrivate cloud, please check whether the baseUrl is configured correctly\n" + url));
60
+ process.exit(1)
61
+ }
62
+ } catch (error) {
63
+ console.error(chalk.red(`Get Plugin Token Failed:`, error, "\nPrivate cloud, please check whether the baseUrl is configured correctly\n" + url));
58
64
  process.exit(1)
59
65
  }
60
66
  return config
@@ -72,19 +78,23 @@ async function getBusToken(config) {
72
78
  secretKey: config.openSecretKey,
73
79
  orgId: config.orgId
74
80
  }
75
-
76
- const res = await axios({
77
- method: 'post',
78
- url: config.apiSvc + "/api/cauth/token",
79
- headers: {
80
- 'Content-Type': 'application/json; charset=utf-8',
81
- },
82
- data: body
83
- });
84
- if (res.data.result) {
85
- config.accessToken = res.data.data.accessToken;
86
- } else {
87
- console.error(chalk.red(`Get OpenAPI Token Failed:`, res.data.returnInfo));
81
+ try {
82
+ const res = await axios({
83
+ method: 'post',
84
+ url: config.apiSvc + "/api/cauth/token",
85
+ headers: {
86
+ 'Content-Type': 'application/json; charset=utf-8',
87
+ },
88
+ data: body
89
+ });
90
+ if (res.data.result) {
91
+ config.accessToken = res.data.data.accessToken;
92
+ } else {
93
+ console.error(chalk.red(`Get OpenAPI Token Failed:`, res.data.returnInfo));
94
+ process.exit(1)
95
+ }
96
+ } catch (error) {
97
+ console.error(chalk.red(`Get OpenAPI Token Failed:`, error.message));
88
98
  process.exit(1)
89
99
  }
90
100
  }