@ranger1/dx 0.1.62 → 0.1.63
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/lib/cli/commands/deploy.js +32 -21
- package/package.json +1 -1
|
@@ -2,6 +2,36 @@ import { logger } from '../../logger.js'
|
|
|
2
2
|
import { envManager } from '../../env.js'
|
|
3
3
|
import { validateEnvironment } from '../../validate-env.js'
|
|
4
4
|
|
|
5
|
+
export function mergeLayeredDeployEnv(layeredEnv, manager, runtimeEnv = process.env) {
|
|
6
|
+
const vercelCriticalKeys = new Set([
|
|
7
|
+
'VERCEL_TOKEN',
|
|
8
|
+
'VERCEL_ORG_ID',
|
|
9
|
+
'VERCEL_PROJECT_ID_FRONT',
|
|
10
|
+
'VERCEL_PROJECT_ID_ADMIN',
|
|
11
|
+
'VERCEL_PROJECT_ID_TELEGRAM_BOT',
|
|
12
|
+
])
|
|
13
|
+
|
|
14
|
+
for (const [key, value] of Object.entries(layeredEnv)) {
|
|
15
|
+
if (vercelCriticalKeys.has(key)) {
|
|
16
|
+
const currentValue = runtimeEnv[key]
|
|
17
|
+
const currentUsable =
|
|
18
|
+
currentValue !== undefined && currentValue !== null && !manager.isPlaceholderEnvValue(currentValue)
|
|
19
|
+
const incomingIsPlaceholder = manager.isPlaceholderEnvValue(value)
|
|
20
|
+
|
|
21
|
+
// 保留外部显式注入的真实凭据,避免被 .env.<env> 的占位符回退污染。
|
|
22
|
+
if (currentUsable && incomingIsPlaceholder) continue
|
|
23
|
+
|
|
24
|
+
runtimeEnv[key] = value
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const currentValue = runtimeEnv[key]
|
|
29
|
+
if (!currentValue || manager.isPlaceholderEnvValue(currentValue)) {
|
|
30
|
+
runtimeEnv[key] = value
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
5
35
|
export function parseTelegramWebhookFlags(argv = []) {
|
|
6
36
|
const args = Array.isArray(argv) ? argv : []
|
|
7
37
|
|
|
@@ -86,27 +116,8 @@ export async function handleDeploy(cli, args) {
|
|
|
86
116
|
})
|
|
87
117
|
}
|
|
88
118
|
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
const vercelCriticalKeys = new Set([
|
|
92
|
-
'VERCEL_TOKEN',
|
|
93
|
-
'VERCEL_ORG_ID',
|
|
94
|
-
'VERCEL_PROJECT_ID_FRONT',
|
|
95
|
-
'VERCEL_PROJECT_ID_ADMIN',
|
|
96
|
-
'VERCEL_PROJECT_ID_TELEGRAM_BOT',
|
|
97
|
-
])
|
|
98
|
-
|
|
99
|
-
for (const [key, value] of Object.entries(layeredEnv)) {
|
|
100
|
-
if (vercelCriticalKeys.has(key)) {
|
|
101
|
-
process.env[key] = value
|
|
102
|
-
continue
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const currentValue = process.env[key]
|
|
106
|
-
if (!currentValue || envManager.isPlaceholderEnvValue(currentValue)) {
|
|
107
|
-
process.env[key] = value
|
|
108
|
-
}
|
|
109
|
-
}
|
|
119
|
+
// 默认仅在缺失/占位时覆盖;Vercel 关键变量额外避免“真实值被占位符覆盖”的回退污染。
|
|
120
|
+
mergeLayeredDeployEnv(layeredEnv, envManager, process.env)
|
|
110
121
|
envManager.syncEnvironments(environment)
|
|
111
122
|
|
|
112
123
|
const { deployToVercel } = await import('../../vercel-deploy.js')
|