提交 aaaf1cf1 编写于 作者: 雪洛's avatar 雪洛

feat: prefer UNI_CLOUD_PROVIDER over UNI_CLOUD_SPACES

上级 7639ccde
......@@ -106,22 +106,22 @@ function initUniStatistics(manifestJson: Record<string, any>) {
)
delete manifestJson.uniStatistics
}
if (!process.env.UNI_CLOUD_SPACES) {
if (!process.env.UNI_CLOUD_PROVIDER) {
return
}
let spaces = []
try {
spaces = JSON.parse(process.env.UNI_CLOUD_SPACES)
spaces = JSON.parse(process.env.UNI_CLOUD_PROVIDER)
} catch (e: any) {}
if (!isArray(spaces) || !spaces.length) {
return
}
const space = spaces[0] as {
provider?: string
id: string
name: string
provider: string
spaceId: string
spaceName: string
clientSecret?: string
apiEndpoint?: string
endpoint?: string
}
if (!space) {
return
......@@ -136,9 +136,9 @@ function initUniStatistics(manifestJson: Record<string, any>) {
}
uniStatistics.uniCloud = {
provider: space.provider,
spaceId: space.id,
spaceId: space.spaceId,
clientSecret: space.clientSecret,
endpoint: space.apiEndpoint,
endpoint: space.endpoint,
}
}
}
......@@ -13,8 +13,6 @@ import {
import { uniValidateFunctionPlugin } from './validateFunction'
process.env.UNI_CLOUD_PROVIDER = JSON.stringify([])
const uniCloudSpaces: {
provider?: string
id: string
......@@ -126,6 +124,17 @@ function checkUniModules() {
function initUniCloudEnv() {
checkUniModules()
if (process.env.UNI_CLOUD_PROVIDER) {
const spaces = JSON.parse(process.env.UNI_CLOUD_PROVIDER)
if (!isArray(spaces)) {
return
}
if (spaces.length) {
uniCloudSpaces.push(...spaces)
return
}
}
process.env.UNI_CLOUD_PROVIDER = JSON.stringify([])
if (!process.env.UNI_CLOUD_SPACES) {
return
}
......
......@@ -453,10 +453,10 @@ export const uni_cloud_config = () => {
export const get_space = (config) => {
const uniCloudConfig = uni_cloud_config()
const { spaceId, provider, clientSecret } = uniCloudConfig
const space_type = ['tcb', 'aliyun']
const space_type = ['tcb', 'tencent', 'aliyun']
const is_provider = space_type.indexOf(provider) !== -1
const is_aliyun = provider === 'aliyun' && spaceId && clientSecret
const is_tcb = provider === 'tcb' && spaceId
const is_tcb = (provider === 'tcb' || provider === 'tencent') && spaceId
if (is_provider && (is_aliyun || is_tcb)) {
return uniCloudConfig
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册