cloudcc-cli 1.7.2 → 1.7.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 +1211 -1204
- package/bin/cc.js +49 -49
- package/bin/plugin.js +6 -6
- package/bin/project.js +6 -6
- package/core/core/ServiceResult.java +35 -35
- package/core/core/UserInfo.java +45 -45
- package/package.json +34 -34
- package/src/classes/create.js +40 -40
- package/src/classes/index.js +8 -8
- package/src/classes/publish.js +43 -43
- package/src/config/get.js +20 -20
- package/src/config/index.js +8 -8
- package/src/config/use.js +14 -14
- package/src/object/get.js +14 -14
- package/src/object/index.js +7 -7
- package/src/plugin/create.js +70 -70
- package/src/plugin/create1.js +58 -58
- package/src/plugin/index.js +8 -8
- package/src/plugin/publish.js +262 -262
- package/src/plugin/publish1.js +256 -256
- package/src/project/create.js +87 -87
- package/src/project/create1.js +109 -109
- package/src/project/index.js +7 -7
- package/src/recordType/get.js +13 -13
- package/src/recordType/index.js +7 -7
- package/src/script/create.js +29 -29
- package/src/script/index.js +8 -8
- package/src/script/publish.js +62 -62
- package/src/timer/create.js +26 -26
- package/src/timer/index.js +8 -8
- package/src/timer/publish.js +43 -43
- package/src/token/get.js +11 -11
- package/src/token/index.js +7 -7
- package/src/triggers/create.js +27 -27
- package/src/triggers/index.js +8 -8
- package/src/triggers/publish.js +48 -48
- package/template/Appvue +24 -24
- package/template/babelconfigjs +5 -5
- package/template/demojava +14 -14
- package/template/gitignore +11 -11
- package/template/index.js +57 -57
- package/template/indexhtml +21 -21
- package/template/indexvue +29 -29
- package/template/javaconfigjson +2 -2
- package/template/mainjs +13 -13
- package/template/package-lockjson +13952 -13952
- package/template/packagejson +42 -42
- package/template/vueconfigjs +21 -21
- package/tool/branch/index.js +25 -25
- package/tool/checkLange/checkLang.js +68 -68
- package/tool/checkLange/clearLang.js +85 -85
- package/utils/checkVersion.js +94 -94
- package/utils/config.js +18 -0
- package/utils/http.js +123 -123
- package/utils/utils.js +40 -58
package/utils/checkVersion.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
const config = require("../package.json")
|
|
3
|
-
const inquirer = require("inquirer")
|
|
4
|
-
const exec = require('child_process').execSync;
|
|
5
|
-
const chalk = require("chalk")
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function checkNpmVersion() {
|
|
9
|
-
let currentVersion = Number(config.version.replace(/\./g, ""));
|
|
10
|
-
let onlineVersionNum
|
|
11
|
-
let onlineVersion = '0.0.1'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmmirror.com`)
|
|
15
|
-
onlineVersion = onlineVersion.toString("utf8").trim();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
|
|
24
|
-
|
|
25
|
-
console.log(chalk.green(
|
|
26
|
-
`
|
|
27
|
-
********************************************************************************
|
|
28
|
-
* *
|
|
29
|
-
* CloudCC CLI *
|
|
30
|
-
* *
|
|
31
|
-
* Current Version:V${config.version} *
|
|
32
|
-
* Latest Version:V${onlineVersion} *
|
|
33
|
-
* *
|
|
34
|
-
* *
|
|
35
|
-
********************************************************************************
|
|
36
|
-
`
|
|
37
|
-
))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (onlineVersionNum - currentVersion > 0) {
|
|
41
|
-
return onlineVersion;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function askUpdate() {
|
|
48
|
-
console.log();
|
|
49
|
-
const prompt = [{
|
|
50
|
-
type: 'list',
|
|
51
|
-
message: 'Do you want to perform automatic upgrade?',
|
|
52
|
-
name: 'update',
|
|
53
|
-
choices: [
|
|
54
|
-
"Yes", 'No'
|
|
55
|
-
],
|
|
56
|
-
}];
|
|
57
|
-
return inquirer.prompt(prompt)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function update(onlineVersion) {
|
|
62
|
-
console.log()
|
|
63
|
-
console.log(chalk.green("Upgrading, estimated to be completed in 3 minutes, please wait..."));
|
|
64
|
-
console.log()
|
|
65
|
-
let os = process.platform
|
|
66
|
-
console.log(chalk.yellow(`If it fails to update automatically, please use the command to update:${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`));
|
|
67
|
-
exec(`${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`)
|
|
68
|
-
console.log()
|
|
69
|
-
console.log(chalk.green("Upgrade completed! Please re-run"));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
async function checkUpdate() {
|
|
74
|
-
let onlineVersion;
|
|
75
|
-
try {
|
|
76
|
-
onlineVersion = checkNpmVersion();
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.log("error", error)
|
|
79
|
-
onlineVersion = false;
|
|
80
|
-
}
|
|
81
|
-
if (onlineVersion) {
|
|
82
|
-
let res = await askUpdate()
|
|
83
|
-
if ("Yes" == res.update) {
|
|
84
|
-
update(onlineVersion)
|
|
85
|
-
return true;
|
|
86
|
-
} else {
|
|
87
|
-
return false
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return false
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
module.exports = { checkUpdate }
|
|
1
|
+
|
|
2
|
+
const config = require("../package.json")
|
|
3
|
+
const inquirer = require("inquirer")
|
|
4
|
+
const exec = require('child_process').execSync;
|
|
5
|
+
const chalk = require("chalk")
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function checkNpmVersion() {
|
|
9
|
+
let currentVersion = Number(config.version.replace(/\./g, ""));
|
|
10
|
+
let onlineVersionNum
|
|
11
|
+
let onlineVersion = '0.0.1'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
onlineVersion = exec(`npm view cloudcc-cli version --registry http://registry.npmmirror.com`)
|
|
15
|
+
onlineVersion = onlineVersion.toString("utf8").trim();
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
onlineVersionNum = Number(onlineVersion.replace(/\./g, ""));
|
|
24
|
+
|
|
25
|
+
console.log(chalk.green(
|
|
26
|
+
`
|
|
27
|
+
********************************************************************************
|
|
28
|
+
* *
|
|
29
|
+
* CloudCC CLI *
|
|
30
|
+
* *
|
|
31
|
+
* Current Version:V${config.version} *
|
|
32
|
+
* Latest Version:V${onlineVersion} *
|
|
33
|
+
* *
|
|
34
|
+
* *
|
|
35
|
+
********************************************************************************
|
|
36
|
+
`
|
|
37
|
+
))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if (onlineVersionNum - currentVersion > 0) {
|
|
41
|
+
return onlineVersion;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function askUpdate() {
|
|
48
|
+
console.log();
|
|
49
|
+
const prompt = [{
|
|
50
|
+
type: 'list',
|
|
51
|
+
message: 'Do you want to perform automatic upgrade?',
|
|
52
|
+
name: 'update',
|
|
53
|
+
choices: [
|
|
54
|
+
"Yes", 'No'
|
|
55
|
+
],
|
|
56
|
+
}];
|
|
57
|
+
return inquirer.prompt(prompt)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
function update(onlineVersion) {
|
|
62
|
+
console.log()
|
|
63
|
+
console.log(chalk.green("Upgrading, estimated to be completed in 3 minutes, please wait..."));
|
|
64
|
+
console.log()
|
|
65
|
+
let os = process.platform
|
|
66
|
+
console.log(chalk.yellow(`If it fails to update automatically, please use the command to update:${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`));
|
|
67
|
+
exec(`${'darwin' == os ? 'sudo' : ''} npm install -g cloudcc-cli@${onlineVersion} --registry http://registry.npmmirror.com`)
|
|
68
|
+
console.log()
|
|
69
|
+
console.log(chalk.green("Upgrade completed! Please re-run"));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
async function checkUpdate() {
|
|
74
|
+
let onlineVersion;
|
|
75
|
+
try {
|
|
76
|
+
onlineVersion = checkNpmVersion();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.log("error", error)
|
|
79
|
+
onlineVersion = false;
|
|
80
|
+
}
|
|
81
|
+
if (onlineVersion) {
|
|
82
|
+
let res = await askUpdate()
|
|
83
|
+
if ("Yes" == res.update) {
|
|
84
|
+
update(onlineVersion)
|
|
85
|
+
return true;
|
|
86
|
+
} else {
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
module.exports = { checkUpdate }
|
package/utils/config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
function getPackageJson_old(projectPath = process.cwd()) {
|
|
5
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(projectPath, "package.json")), 'utf8');
|
|
6
|
+
return packageJson.devConsoleConfig;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getPackageJson(projectPath = process.cwd()) {
|
|
10
|
+
let config = getPackageJson_old(projectPath);
|
|
11
|
+
if (!config) {
|
|
12
|
+
config = require(path.join(projectPath, "cloudcc-cli.config.js"))
|
|
13
|
+
config = config[config.use]
|
|
14
|
+
}
|
|
15
|
+
return config
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { getPackageJson }
|
package/utils/http.js
CHANGED
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
const https = require("https")
|
|
2
|
-
const http = require("http")
|
|
3
|
-
const axios = require("axios")
|
|
4
|
-
const { getPackageJson } = require("./
|
|
5
|
-
|
|
6
|
-
const httpsAgent = new https.Agent({
|
|
7
|
-
rejectUnauthorized: false,
|
|
8
|
-
})
|
|
9
|
-
const httpAgent = new http.Agent({
|
|
10
|
-
rejectUnauthorized: false,
|
|
11
|
-
})
|
|
12
|
-
axios.defaults.httpsAgent = httpsAgent
|
|
13
|
-
axios.defaults.httpAgent = httpAgent
|
|
14
|
-
|
|
15
|
-
const service = axios.create({
|
|
16
|
-
timeout: 60000,
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json; charset=utf-8',
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
service.interceptors.request.use(
|
|
24
|
-
config => {
|
|
25
|
-
if (global.accessToken) {
|
|
26
|
-
config.headers.accessToken = global.accessToken
|
|
27
|
-
}
|
|
28
|
-
return config
|
|
29
|
-
},
|
|
30
|
-
error => {
|
|
31
|
-
|
|
32
|
-
Promise.reject(error)
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
service.interceptors.response.use(
|
|
38
|
-
response => {
|
|
39
|
-
const code = response.data.code || 200
|
|
40
|
-
if (code !== 200) {
|
|
41
|
-
return Promise.reject(null == response.data.msg ? "Unknown exception" : response.data.msg)
|
|
42
|
-
} else {
|
|
43
|
-
return response.data;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
error => {
|
|
47
|
-
return Promise.reject(error)
|
|
48
|
-
}
|
|
49
|
-
)
|
|
50
|
-
const formateData = (data, header) => {
|
|
51
|
-
if (header) {
|
|
52
|
-
Object.assign(header, { source: getPackageJson().source || "cloudcc_cli" })
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
head: {
|
|
56
|
-
...header
|
|
57
|
-
},
|
|
58
|
-
body: {
|
|
59
|
-
...data
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
module.exports = {
|
|
64
|
-
get: (url, data = {}, responseType = '') => {
|
|
65
|
-
return service({
|
|
66
|
-
url: url,
|
|
67
|
-
method: 'get',
|
|
68
|
-
params: formateData(data),
|
|
69
|
-
responseType: responseType
|
|
70
|
-
})
|
|
71
|
-
},
|
|
72
|
-
getParams: (url, data = {}) => {
|
|
73
|
-
return service({
|
|
74
|
-
url: url,
|
|
75
|
-
method: 'get',
|
|
76
|
-
params: data,
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
post: (url, data = {}, header = { appVersion: "1.0.0" }, responseType = '') => {
|
|
80
|
-
return service({
|
|
81
|
-
url: url,
|
|
82
|
-
method: 'post',
|
|
83
|
-
data: formateData(data, header),
|
|
84
|
-
responseType: responseType
|
|
85
|
-
})
|
|
86
|
-
},
|
|
87
|
-
postParams: (url, data = {}) => {
|
|
88
|
-
return service({
|
|
89
|
-
url: url,
|
|
90
|
-
method: 'post',
|
|
91
|
-
params: data,
|
|
92
|
-
})
|
|
93
|
-
},
|
|
94
|
-
postNormal: (url, data = {}) => {
|
|
95
|
-
return service({
|
|
96
|
-
url: url,
|
|
97
|
-
method: 'post',
|
|
98
|
-
data: data
|
|
99
|
-
})
|
|
100
|
-
},
|
|
101
|
-
patch: (url, data = {}) => {
|
|
102
|
-
return service({
|
|
103
|
-
url: url,
|
|
104
|
-
method: 'patch',
|
|
105
|
-
data: formateData(data)
|
|
106
|
-
})
|
|
107
|
-
},
|
|
108
|
-
delete: (url, data = {}) => {
|
|
109
|
-
return service({
|
|
110
|
-
url: url,
|
|
111
|
-
method: 'delete',
|
|
112
|
-
data: formateData(data)
|
|
113
|
-
})
|
|
114
|
-
},
|
|
115
|
-
put: (url, data = {}) => {
|
|
116
|
-
return service({
|
|
117
|
-
url: url,
|
|
118
|
-
method: 'put',
|
|
119
|
-
data: formateData(data)
|
|
120
|
-
})
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}
|
|
1
|
+
const https = require("https")
|
|
2
|
+
const http = require("http")
|
|
3
|
+
const axios = require("axios")
|
|
4
|
+
const { getPackageJson } = require("./config")
|
|
5
|
+
|
|
6
|
+
const httpsAgent = new https.Agent({
|
|
7
|
+
rejectUnauthorized: false,
|
|
8
|
+
})
|
|
9
|
+
const httpAgent = new http.Agent({
|
|
10
|
+
rejectUnauthorized: false,
|
|
11
|
+
})
|
|
12
|
+
axios.defaults.httpsAgent = httpsAgent
|
|
13
|
+
axios.defaults.httpAgent = httpAgent
|
|
14
|
+
|
|
15
|
+
const service = axios.create({
|
|
16
|
+
timeout: 60000,
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
service.interceptors.request.use(
|
|
24
|
+
config => {
|
|
25
|
+
if (global.accessToken) {
|
|
26
|
+
config.headers.accessToken = global.accessToken
|
|
27
|
+
}
|
|
28
|
+
return config
|
|
29
|
+
},
|
|
30
|
+
error => {
|
|
31
|
+
|
|
32
|
+
Promise.reject(error)
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
service.interceptors.response.use(
|
|
38
|
+
response => {
|
|
39
|
+
const code = response.data.code || 200
|
|
40
|
+
if (code !== 200) {
|
|
41
|
+
return Promise.reject(null == response.data.msg ? "Unknown exception" : response.data.msg)
|
|
42
|
+
} else {
|
|
43
|
+
return response.data;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
error => {
|
|
47
|
+
return Promise.reject(error)
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
const formateData = (data, header) => {
|
|
51
|
+
if (header) {
|
|
52
|
+
Object.assign(header, { source: getPackageJson().source || "cloudcc_cli" })
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
head: {
|
|
56
|
+
...header
|
|
57
|
+
},
|
|
58
|
+
body: {
|
|
59
|
+
...data
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
module.exports = {
|
|
64
|
+
get: (url, data = {}, responseType = '') => {
|
|
65
|
+
return service({
|
|
66
|
+
url: url,
|
|
67
|
+
method: 'get',
|
|
68
|
+
params: formateData(data),
|
|
69
|
+
responseType: responseType
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
getParams: (url, data = {}) => {
|
|
73
|
+
return service({
|
|
74
|
+
url: url,
|
|
75
|
+
method: 'get',
|
|
76
|
+
params: data,
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
post: (url, data = {}, header = { appVersion: "1.0.0" }, responseType = '') => {
|
|
80
|
+
return service({
|
|
81
|
+
url: url,
|
|
82
|
+
method: 'post',
|
|
83
|
+
data: formateData(data, header),
|
|
84
|
+
responseType: responseType
|
|
85
|
+
})
|
|
86
|
+
},
|
|
87
|
+
postParams: (url, data = {}) => {
|
|
88
|
+
return service({
|
|
89
|
+
url: url,
|
|
90
|
+
method: 'post',
|
|
91
|
+
params: data,
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
postNormal: (url, data = {}) => {
|
|
95
|
+
return service({
|
|
96
|
+
url: url,
|
|
97
|
+
method: 'post',
|
|
98
|
+
data: data
|
|
99
|
+
})
|
|
100
|
+
},
|
|
101
|
+
patch: (url, data = {}) => {
|
|
102
|
+
return service({
|
|
103
|
+
url: url,
|
|
104
|
+
method: 'patch',
|
|
105
|
+
data: formateData(data)
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
delete: (url, data = {}) => {
|
|
109
|
+
return service({
|
|
110
|
+
url: url,
|
|
111
|
+
method: 'delete',
|
|
112
|
+
data: formateData(data)
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
put: (url, data = {}) => {
|
|
116
|
+
return service({
|
|
117
|
+
url: url,
|
|
118
|
+
method: 'put',
|
|
119
|
+
data: formateData(data)
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
package/utils/utils.js
CHANGED
|
@@ -1,58 +1,40 @@
|
|
|
1
|
-
const { getParams, postNormal } = require("./http")
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (res.result) {
|
|
42
|
-
global.accessToken = res.data.accessToken
|
|
43
|
-
return res.data.accessToken;
|
|
44
|
-
}
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function getPackageJson(projectPath = process.cwd()) {
|
|
50
|
-
let config = getPackageJson_old(projectPath);
|
|
51
|
-
if (!config) {
|
|
52
|
-
config = require(path.join(projectPath, "cloudcc-cli.config.js"))
|
|
53
|
-
config = config[config.use]
|
|
54
|
-
}
|
|
55
|
-
return config
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
module.exports = { getBusToken, getPackageJson }
|
|
1
|
+
const { getParams, postNormal } = require("./http")
|
|
2
|
+
const chalk = require("chalk")
|
|
3
|
+
const { getPackageJson } = require("./config")
|
|
4
|
+
|
|
5
|
+
async function getBaseUrl(devConfig) {
|
|
6
|
+
if ('private' == devConfig.version) {
|
|
7
|
+
global.apiSvc = devConfig.baseUrl + (devConfig.apiSvcPrefix || "/apitfs")
|
|
8
|
+
global.setupSvc = devConfig.baseUrl + (devConfig.setupSvcPrefix || "/ccsetup")
|
|
9
|
+
} else {
|
|
10
|
+
let u = "https://developer.apis.cloudcc.cn/oauth/apidomain?scope=cloudccCRM&orgId=" + devConfig.orgId
|
|
11
|
+
let res = await getParams(u)
|
|
12
|
+
global.apiSvc = res.orgapi_address
|
|
13
|
+
global.setupSvc = new URL(res.orgapi_address).origin + (devConfig.setupSvcPrefix || "/ccsetup")
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function getBusToken(path) {
|
|
18
|
+
let devConfig = getPackageJson(path);
|
|
19
|
+
if (!devConfig.username || !devConfig.safetyMark || !devConfig.clientId || !devConfig.openSecretKey || !devConfig.orgId) {
|
|
20
|
+
console.log(chalk.red('The security tag configuration is incorrect. Please check the documentation for configuration.'));
|
|
21
|
+
console.log();
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
let body = {
|
|
25
|
+
username: devConfig.username,
|
|
26
|
+
safetyMark: devConfig.safetyMark,
|
|
27
|
+
clientId: devConfig.clientId,
|
|
28
|
+
secretKey: devConfig.openSecretKey,
|
|
29
|
+
orgId: devConfig.orgId
|
|
30
|
+
}
|
|
31
|
+
await getBaseUrl(devConfig)
|
|
32
|
+
let res = await postNormal(global.apiSvc + "/api/cauth/token", body)
|
|
33
|
+
if (res.result) {
|
|
34
|
+
global.accessToken = res.data.accessToken
|
|
35
|
+
return res.data.accessToken;
|
|
36
|
+
}
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = { getBusToken }
|