cloudcc-cli 2.0.2 → 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,11 @@
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
+
1
9
  # ReleaseV2.0.2
2
10
  #### Release Date: 2025-4-2
3
11
  #### Release Scope: Full
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "cloudcc-cli",
5
5
  "keywords": [
6
6
  "cloudcc",
@@ -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,
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) {
41
+ if (decryptedInfo.baseUrl && !decryptedInfo.baseUrl.includes("ccdomaingateway")) {
42
+ decryptedInfo.baseUrl = decryptedInfo.baseUrl + "/ccdomaingateway"
43
+ }
43
44
  config = { ...decryptedInfo, ...config }
44
- // if (config.baseUrl && !config.baseUrl.includes("ccdomaingateway")) {
45
- // config.baseUrl = config.baseUrl + "/ccdomaingateway"
46
- // }
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