@ranger1/dx 0.1.60 → 0.1.62

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.
@@ -86,8 +86,22 @@ export async function handleDeploy(cli, args) {
86
86
  })
87
87
  }
88
88
 
89
- // 仅在目标变量不存在或是占位符时才使用 .env 文件的值
89
+ // 默认仅在缺失/占位时覆盖,避免破坏显式传入的环境变量。
90
+ // 但对 Vercel 部署关键变量,强制使用当前环境层,确保不受 shell 残留值影响。
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
+
90
99
  for (const [key, value] of Object.entries(layeredEnv)) {
100
+ if (vercelCriticalKeys.has(key)) {
101
+ process.env[key] = value
102
+ continue
103
+ }
104
+
91
105
  const currentValue = process.env[key]
92
106
  if (!currentValue || envManager.isPlaceholderEnvValue(currentValue)) {
93
107
  process.env[key] = value
@@ -101,13 +101,17 @@ function listMissingConfigs(targetConfigs, projectRoot) {
101
101
  return missing
102
102
  }
103
103
 
104
- function appendTargetArgs(baseArgs, { orgId }) {
104
+ function appendTargetArgs(baseArgs, { orgId, token }) {
105
105
  const args = [...baseArgs]
106
106
 
107
107
  if (orgId) {
108
108
  args.push('--scope', orgId)
109
109
  }
110
110
 
111
+ if (token) {
112
+ args.push('--token', token)
113
+ }
114
+
111
115
  return args
112
116
  }
113
117
 
@@ -431,7 +435,8 @@ export async function deployToVercel(target, options = {}) {
431
435
  // 第一步:本地构建
432
436
  logger.step(`本地构建 ${t} (${environment})`)
433
437
  const buildArgs = appendTargetArgs(['build', '--local-config', configPath, '--yes'], {
434
- orgId
438
+ orgId,
439
+ token
435
440
  })
436
441
 
437
442
  // staging 和 production 环境需要 --prod 标志,确保构建产物与部署环境匹配
@@ -447,7 +452,8 @@ export async function deployToVercel(target, options = {}) {
447
452
  const baseDeployArgs = appendTargetArgs(
448
453
  ['deploy', '--prebuilt', '--local-config', configPath, '--yes'],
449
454
  {
450
- orgId
455
+ orgId,
456
+ token
451
457
  }
452
458
  )
453
459
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ranger1/dx",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {