@cloudbase/cli 2.2.9 → 2.2.10
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/bin/tcb.js +6 -6
- package/package.json +2 -2
- package/.vscode/settings.json +0 -3
package/bin/tcb.js
CHANGED
|
@@ -184,12 +184,12 @@ async function main() {
|
|
|
184
184
|
if (errMsg.includes('Environment') && errMsg.includes('not found')) {
|
|
185
185
|
// 检查是否已经指定了 -r 或 --region 参数,如未指定则尝试获取地域信息
|
|
186
186
|
const regionSpecified = processArgv.indexOf('-r') !== -1 || processArgv.indexOf('--region') !== -1
|
|
187
|
-
const region = yargsParsedResult
|
|
187
|
+
const region = yargsParsedResult.r || yargsParsedResult.region
|
|
188
188
|
const multiRegionErrMsg = `\n此环境可能不属于当前账号,或为非${regionSupportedMap[region] || '上海'}地域环境,如需切换地域请追加参数(例:-r gz),请检查环境归属,参考多地域使用方法:https://docs.cloudbase.net/cli-v1/region.html`
|
|
189
189
|
if (!regionSpecified) {
|
|
190
190
|
|
|
191
191
|
// 从 -e 参数、--envId 参数和配置文件中获取环境 id
|
|
192
|
-
const envId = yargsParsedResult
|
|
192
|
+
const envId = yargsParsedResult.e || yargsParsedResult.envId || config.envId
|
|
193
193
|
|
|
194
194
|
// 调用 API 接口尝试查询环境信息
|
|
195
195
|
const predictRegion = await tryTellEnvRegion(envId)
|
|
@@ -246,8 +246,8 @@ async function main() {
|
|
|
246
246
|
async function tryTellEnvRegion(envId) {
|
|
247
247
|
// 依次调用不同地域的 API 接口查询环境信息
|
|
248
248
|
const fetchedRegion = await Promise.all(regionSupported.map(async region => {
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
249
|
+
const { EnvList = [] } = await fetchEnvInfoWithRegion(envId, region)
|
|
250
|
+
if (EnvList.length !== 0 && EnvList.find(item => item.EnvId === envId)) {
|
|
251
251
|
return res.EnvList[0].Region
|
|
252
252
|
}
|
|
253
253
|
return ''
|
|
@@ -264,14 +264,14 @@ async function main() {
|
|
|
264
264
|
|
|
265
265
|
// 在指定地域调用 API 接口查询环境信息
|
|
266
266
|
async function fetchEnvInfoWithRegion(envId, region) {
|
|
267
|
-
let commonCredential
|
|
267
|
+
let commonCredential = {}
|
|
268
268
|
const commonOpts = {
|
|
269
269
|
service: 'tcb',
|
|
270
270
|
version: '2019-09-24',
|
|
271
271
|
proxy: getProxy(),
|
|
272
272
|
timeout: 15000,
|
|
273
273
|
getCredential: async () => {
|
|
274
|
-
if (commonCredential
|
|
274
|
+
if (commonCredential.secretId && !isTokenExpired(commonCredential)) {
|
|
275
275
|
return commonCredential
|
|
276
276
|
}
|
|
277
277
|
const credential = await getCredentialWithoutCheck()
|
package/package.json
CHANGED
package/.vscode/settings.json
DELETED