cloudcc-cli 1.8.7 → 1.8.9

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.
Files changed (57) hide show
  1. package/README.md +1326 -1312
  2. package/bin/cc.js +49 -49
  3. package/bin/plugin.js +5 -5
  4. package/bin/project.js +5 -5
  5. package/core/core/ServiceResult.java +35 -35
  6. package/core/core/UserInfo.java +45 -45
  7. package/package.json +34 -34
  8. package/src/classes/create.js +43 -43
  9. package/src/classes/index.js +8 -8
  10. package/src/classes/publish.js +45 -45
  11. package/src/config/get.js +20 -20
  12. package/src/config/index.js +8 -8
  13. package/src/config/use.js +14 -14
  14. package/src/object/get.js +35 -35
  15. package/src/object/index.js +7 -7
  16. package/src/plugin/create.js +70 -70
  17. package/src/plugin/create1.js +58 -58
  18. package/src/plugin/index.js +8 -8
  19. package/src/plugin/publish.js +267 -267
  20. package/src/plugin/publish1.js +297 -297
  21. package/src/plugin/readme.md +6 -6
  22. package/src/project/create.js +83 -83
  23. package/src/project/create1.js +105 -105
  24. package/src/project/index.js +7 -7
  25. package/src/recordType/get.js +13 -13
  26. package/src/recordType/index.js +7 -7
  27. package/src/script/create.js +35 -35
  28. package/src/script/index.js +8 -8
  29. package/src/script/publish.js +71 -51
  30. package/src/timer/create.js +29 -29
  31. package/src/timer/index.js +8 -8
  32. package/src/timer/publish.js +47 -47
  33. package/src/token/get.js +11 -11
  34. package/src/token/index.js +7 -7
  35. package/src/triggers/create.js +39 -39
  36. package/src/triggers/index.js +8 -8
  37. package/src/triggers/publish.js +53 -53
  38. package/template/Appvue +24 -24
  39. package/template/babelconfigjs +5 -5
  40. package/template/demojava +14 -14
  41. package/template/gitignore +13 -13
  42. package/template/index.js +57 -57
  43. package/template/indexhtml +21 -21
  44. package/template/indexvue +29 -29
  45. package/template/javaconfigjson +2 -2
  46. package/template/mainjs +13 -13
  47. package/template/package-lockjson +13952 -13952
  48. package/template/packagejson +42 -42
  49. package/template/vueconfigjs +21 -21
  50. package/tool/branch/index.js +25 -25
  51. package/tool/checkLange/checkLang.js +68 -68
  52. package/tool/checkLange/clearLang.js +85 -85
  53. package/utils/cache.js +31 -31
  54. package/utils/checkVersion.js +107 -107
  55. package/utils/config.js +18 -18
  56. package/utils/http.js +123 -123
  57. package/utils/utils.js +95 -95
package/utils/utils.js CHANGED
@@ -1,96 +1,96 @@
1
- const { getParams, postNormal } = require("./http")
2
- const chalk = require("chalk")
3
- const { getPackageJson } = require("./config")
4
- const { readCache, writeCache } = require("./cache")
5
-
6
- async function getBaseUrl(path, devConfig) {
7
- const cache = readCache(path);
8
- const cacheKey = devConfig.secretKey;
9
- const now = Date.now();
10
- const oneHour = 60 * 60 * 1000;
11
-
12
- // Check if cache is valid
13
- if (cache[cacheKey] &&
14
- cache[cacheKey].apiSvc &&
15
- cache[cacheKey].setupSvc &&
16
- cache[cacheKey].timestamp &&
17
- (now - cache[cacheKey].timestamp) < oneHour) {
18
- global.apiSvc = cache[cacheKey].apiSvc;
19
- global.setupSvc = cache[cacheKey].setupSvc;
20
- return;
21
- }
22
-
23
- if (devConfig.baseUrl) {
24
- global.apiSvc = devConfig.baseUrl + (devConfig.apiSvcPrefix || "/apitfs")
25
- global.setupSvc = devConfig.baseUrl + (devConfig.setupSvcPrefix || "/setup")
26
- } else {
27
- let u = "https://developer.apis.cloudcc.cn/oauth/apidomain?scope=cloudccCRM&orgId=" + devConfig.orgId
28
- let res = await getParams(u)
29
- global.apiSvc = res.orgapi_address
30
- global.setupSvc = new URL(res.orgapi_address).origin + (devConfig.setupSvcPrefix || "/setup")
31
- }
32
-
33
- // Update cache with apiSvc and setupSvc
34
- cache[cacheKey] = {
35
- ...(cache[cacheKey] || {}),
36
- apiSvc: global.apiSvc,
37
- setupSvc: global.setupSvc,
38
- timestamp: now
39
- };
40
- writeCache(path, cache);
41
- }
42
-
43
- async function getBusToken(path = process.cwd()) {
44
- let devConfig = getPackageJson(path);
45
- if (!devConfig.username || !devConfig.safetyMark || !devConfig.clientId || !devConfig.openSecretKey || !devConfig.orgId) {
46
- console.log(chalk.red('The security tag configuration is incorrect. Please check the documentation for configuration.'));
47
- console.log();
48
- return false;
49
- }
50
-
51
- const cache = readCache(path);
52
- const cacheKey = devConfig.secretKey;
53
- const now = Date.now();
54
- const oneHour = 60 * 60 * 1000;
55
- // Check if cache is valid
56
- if (cache[cacheKey] &&
57
- cache[cacheKey].token &&
58
- cache[cacheKey].apiSvc &&
59
- cache[cacheKey].setupSvc &&
60
- cache[cacheKey].timestamp &&
61
- (now - cache[cacheKey].timestamp) < oneHour) {
62
- global.accessToken = cache[cacheKey].token;
63
- global.apiSvc = cache[cacheKey].apiSvc;
64
- global.setupSvc = cache[cacheKey].setupSvc;
65
- return cache[cacheKey].token;
66
- }
67
-
68
- let body = {
69
- username: devConfig.username,
70
- safetyMark: devConfig.safetyMark,
71
- clientId: devConfig.clientId,
72
- secretKey: devConfig.openSecretKey,
73
- orgId: devConfig.orgId
74
- }
75
- await getBaseUrl(path, devConfig)
76
- // return path
77
- let res = await postNormal(global.apiSvc + "/api/cauth/token", body)
78
- if (res.result) {
79
- global.accessToken = res.data.accessToken;
80
- // Update cache
81
- cache[cacheKey] = {
82
- token: res.data.accessToken,
83
- apiSvc: global.apiSvc,
84
- setupSvc: global.setupSvc,
85
- timestamp: now
86
- };
87
-
88
- writeCache(path, cache);
89
- return res.data.accessToken;
90
- } else {
91
- console.log(chalk.red(res.returnInfo));
92
- }
93
- return false;
94
- }
95
-
1
+ const { getParams, postNormal } = require("./http")
2
+ const chalk = require("chalk")
3
+ const { getPackageJson } = require("./config")
4
+ const { readCache, writeCache } = require("./cache")
5
+
6
+ async function getBaseUrl(path, devConfig) {
7
+ const cache = readCache(path);
8
+ const cacheKey = devConfig.secretKey;
9
+ const now = Date.now();
10
+ const oneHour = 60 * 60 * 1000;
11
+
12
+ // Check if cache is valid
13
+ if (cache[cacheKey] &&
14
+ cache[cacheKey].apiSvc &&
15
+ cache[cacheKey].setupSvc &&
16
+ cache[cacheKey].timestamp &&
17
+ (now - cache[cacheKey].timestamp) < oneHour) {
18
+ global.apiSvc = cache[cacheKey].apiSvc;
19
+ global.setupSvc = cache[cacheKey].setupSvc;
20
+ return;
21
+ }
22
+
23
+ if (devConfig.baseUrl) {
24
+ global.apiSvc = devConfig.baseUrl + (devConfig.apiSvcPrefix || "/apitfs")
25
+ global.setupSvc = devConfig.baseUrl + (devConfig.setupSvcPrefix || "/setup")
26
+ } else {
27
+ let u = "https://developer.apis.cloudcc.cn/oauth/apidomain?scope=cloudccCRM&orgId=" + devConfig.orgId
28
+ let res = await getParams(u)
29
+ global.apiSvc = res.orgapi_address
30
+ global.setupSvc = new URL(res.orgapi_address).origin + (devConfig.setupSvcPrefix || "/setup")
31
+ }
32
+
33
+ // Update cache with apiSvc and setupSvc
34
+ cache[cacheKey] = {
35
+ ...(cache[cacheKey] || {}),
36
+ apiSvc: global.apiSvc,
37
+ setupSvc: global.setupSvc,
38
+ timestamp: now
39
+ };
40
+ writeCache(path, cache);
41
+ }
42
+
43
+ async function getBusToken(path = process.cwd()) {
44
+ let devConfig = getPackageJson(path);
45
+ if (!devConfig.username || !devConfig.safetyMark || !devConfig.clientId || !devConfig.openSecretKey || !devConfig.orgId) {
46
+ console.log(chalk.red('The security tag configuration is incorrect. Please check the documentation for configuration.'));
47
+ console.log();
48
+ return false;
49
+ }
50
+
51
+ const cache = readCache(path);
52
+ const cacheKey = devConfig.secretKey;
53
+ const now = Date.now();
54
+ const oneHour = 60 * 60 * 1000;
55
+ // Check if cache is valid
56
+ if (cache[cacheKey] &&
57
+ cache[cacheKey].token &&
58
+ cache[cacheKey].apiSvc &&
59
+ cache[cacheKey].setupSvc &&
60
+ cache[cacheKey].timestamp &&
61
+ (now - cache[cacheKey].timestamp) < oneHour) {
62
+ global.accessToken = cache[cacheKey].token;
63
+ global.apiSvc = cache[cacheKey].apiSvc;
64
+ global.setupSvc = cache[cacheKey].setupSvc;
65
+ return cache[cacheKey].token;
66
+ }
67
+
68
+ let body = {
69
+ username: devConfig.username,
70
+ safetyMark: devConfig.safetyMark,
71
+ clientId: devConfig.clientId,
72
+ secretKey: devConfig.openSecretKey,
73
+ orgId: devConfig.orgId
74
+ }
75
+ await getBaseUrl(path, devConfig)
76
+ // return path
77
+ let res = await postNormal(global.apiSvc + "/api/cauth/token", body)
78
+ if (res.result) {
79
+ global.accessToken = res.data.accessToken;
80
+ // Update cache
81
+ cache[cacheKey] = {
82
+ token: res.data.accessToken,
83
+ apiSvc: global.apiSvc,
84
+ setupSvc: global.setupSvc,
85
+ timestamp: now
86
+ };
87
+
88
+ writeCache(path, cache);
89
+ return res.data.accessToken;
90
+ } else {
91
+ console.log(chalk.red(res.returnInfo));
92
+ }
93
+ return false;
94
+ }
95
+
96
96
  module.exports = { getBusToken }