@ranger1/dx 0.1.76 → 0.1.77
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 +2 -1
- package/lib/cli/help.js +4 -3
- package/lib/vercel-deploy.js +14 -27
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export function mergeLayeredDeployEnv(layeredEnv, manager, runtimeEnv = process.
|
|
|
8
8
|
'VERCEL_ORG_ID',
|
|
9
9
|
'VERCEL_PROJECT_ID_FRONT',
|
|
10
10
|
'VERCEL_PROJECT_ID_ADMIN',
|
|
11
|
+
'VERCEL_PROJECT_ID_MERCHANT',
|
|
11
12
|
'VERCEL_PROJECT_ID_TELEGRAM_BOT',
|
|
12
13
|
])
|
|
13
14
|
|
|
@@ -57,7 +58,7 @@ export function parseTelegramWebhookFlags(argv = []) {
|
|
|
57
58
|
export async function handleDeploy(cli, args) {
|
|
58
59
|
const target = args[0]
|
|
59
60
|
if (!target) {
|
|
60
|
-
logger.error('请指定部署目标: front, admin, all')
|
|
61
|
+
logger.error('请指定部署目标: front, admin, merchant, telegram-bot, all')
|
|
61
62
|
logger.info(`用法: ${cli.invocation} deploy <target> [环境标志]`)
|
|
62
63
|
logger.info(`示例: ${cli.invocation} deploy front --staging`)
|
|
63
64
|
process.exitCode = 1
|
package/lib/cli/help.js
CHANGED
|
@@ -21,7 +21,7 @@ export function showHelp() {
|
|
|
21
21
|
' 环境标志: --dev, --staging, --prod, --test, --e2e(未指定时默认 --dev)',
|
|
22
22
|
'',
|
|
23
23
|
' deploy <target> [环境标志] 部署前端到 Vercel',
|
|
24
|
-
' target: front, admin, telegram-bot, all',
|
|
24
|
+
' target: front, admin, merchant, telegram-bot, all',
|
|
25
25
|
' 环境标志: --dev, --staging, --prod(默认 --staging)',
|
|
26
26
|
'',
|
|
27
27
|
' install 安装依赖(使用 frozen-lockfile 确保版本一致)',
|
|
@@ -188,7 +188,7 @@ script 子命令:
|
|
|
188
188
|
dx deploy <target> [环境标志] [选项]
|
|
189
189
|
|
|
190
190
|
参数说明:
|
|
191
|
-
target: front, admin, telegram-bot, all
|
|
191
|
+
target: front, admin, merchant, telegram-bot, all
|
|
192
192
|
环境标志: --dev、--staging、--prod(默认 --staging)
|
|
193
193
|
|
|
194
194
|
Telegram Webhook(仅 target=telegram-bot 生效):
|
|
@@ -200,11 +200,12 @@ script 子命令:
|
|
|
200
200
|
常见示例:
|
|
201
201
|
dx deploy front --staging # 部署用户前端(staging)
|
|
202
202
|
dx deploy admin --prod # 部署管理后台(生产)
|
|
203
|
+
dx deploy merchant --staging # 部署商家前端(staging)
|
|
203
204
|
dx deploy telegram-bot --staging # 部署 Telegram Bot + 自动配置 Webhook
|
|
204
205
|
dx deploy telegram-bot --staging --webhook-path /webhook # 使用短路径(rewrite 到 /api/webhook)
|
|
205
206
|
dx deploy telegram-bot --prod --webhook-dry-run # 仅打印,不实际调用 Telegram
|
|
206
207
|
dx deploy telegram-bot --dev --no-strict-webhook # 开发环境显式降级为仅告警
|
|
207
|
-
dx deploy all --staging # 串行部署 front + admin
|
|
208
|
+
dx deploy all --staging # 串行部署 front + admin + merchant
|
|
208
209
|
`)
|
|
209
210
|
return
|
|
210
211
|
|
package/lib/vercel-deploy.js
CHANGED
|
@@ -5,7 +5,7 @@ import { envManager } from './env.js'
|
|
|
5
5
|
import { logger } from './logger.js'
|
|
6
6
|
|
|
7
7
|
const ALLOWED_ENVIRONMENTS = ['development', 'staging', 'production']
|
|
8
|
-
const VALID_TARGETS = ['front', 'admin', 'telegram-bot']
|
|
8
|
+
const VALID_TARGETS = ['front', 'admin', 'merchant', 'telegram-bot']
|
|
9
9
|
|
|
10
10
|
const TARGET_CONFIGS = {
|
|
11
11
|
front: {
|
|
@@ -22,6 +22,13 @@ const TARGET_CONFIGS = {
|
|
|
22
22
|
deployMode: 'prebuilt',
|
|
23
23
|
prebuiltCwd: '.'
|
|
24
24
|
},
|
|
25
|
+
merchant: {
|
|
26
|
+
configFile: 'vercel.merchant.json',
|
|
27
|
+
projectIdEnvVar: 'VERCEL_PROJECT_ID_MERCHANT',
|
|
28
|
+
deployCwd: '.',
|
|
29
|
+
deployMode: 'prebuilt',
|
|
30
|
+
prebuiltCwd: '.'
|
|
31
|
+
},
|
|
25
32
|
'telegram-bot': {
|
|
26
33
|
configFile: 'vercel.telegram-bot.json',
|
|
27
34
|
projectIdEnvVar: 'VERCEL_PROJECT_ID_TELEGRAM_BOT',
|
|
@@ -229,31 +236,10 @@ export async function deployPrebuiltWithFallback(options) {
|
|
|
229
236
|
baseArgs,
|
|
230
237
|
env,
|
|
231
238
|
cwd,
|
|
232
|
-
run = runVercel
|
|
233
|
-
cleanupArchiveParts = () => {
|
|
234
|
-
try {
|
|
235
|
-
execSync('rm -f .vercel/source.tgz.part*', { stdio: 'ignore', cwd: cwd || process.cwd() })
|
|
236
|
-
} catch {
|
|
237
|
-
// ignore
|
|
238
|
-
}
|
|
239
|
-
},
|
|
240
|
-
onMissingFiles = () => {
|
|
241
|
-
logger.warn('检测到 missing_files,自动使用 --archive=tgz 重试一次')
|
|
242
|
-
}
|
|
239
|
+
run = runVercel
|
|
243
240
|
} = options || {}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const result = await run(baseArgs, { env, cwd })
|
|
247
|
-
return { usedArchive: false, result }
|
|
248
|
-
} catch (e) {
|
|
249
|
-
if (!isMissingFilesError(e)) throw e
|
|
250
|
-
onMissingFiles(e)
|
|
251
|
-
cleanupArchiveParts()
|
|
252
|
-
const archiveArgs = baseArgs.slice()
|
|
253
|
-
archiveArgs.splice(2, 0, '--archive=tgz')
|
|
254
|
-
const result = await run(archiveArgs, { env, cwd })
|
|
255
|
-
return { usedArchive: true, result }
|
|
256
|
-
}
|
|
241
|
+
const result = await run(baseArgs, { env, cwd })
|
|
242
|
+
return { usedArchive: false, result }
|
|
257
243
|
}
|
|
258
244
|
|
|
259
245
|
export async function deployToVercel(target, options = {}) {
|
|
@@ -274,14 +260,14 @@ export async function deployToVercel(target, options = {}) {
|
|
|
274
260
|
}
|
|
275
261
|
|
|
276
262
|
const normalizedTarget = String(target || '').toLowerCase()
|
|
277
|
-
const targets = normalizedTarget === 'all' ? ['front', 'admin'] : [normalizedTarget]
|
|
263
|
+
const targets = normalizedTarget === 'all' ? ['front', 'admin', 'merchant'] : [normalizedTarget]
|
|
278
264
|
const projectRoot = process.cwd()
|
|
279
265
|
|
|
280
266
|
// 校验目标有效性
|
|
281
267
|
for (const t of targets) {
|
|
282
268
|
if (!VALID_TARGETS.includes(t)) {
|
|
283
269
|
logger.error(`不支持的部署目标: ${t}`)
|
|
284
|
-
logger.info('可用目标: front, admin, telegram-bot, all')
|
|
270
|
+
logger.info('可用目标: front, admin, merchant, telegram-bot, all')
|
|
285
271
|
process.exitCode = 1
|
|
286
272
|
return
|
|
287
273
|
}
|
|
@@ -306,6 +292,7 @@ export async function deployToVercel(target, options = {}) {
|
|
|
306
292
|
logger.info(' VERCEL_ORG_ID=team_xxx')
|
|
307
293
|
logger.info(' VERCEL_PROJECT_ID_FRONT=prj_xxx')
|
|
308
294
|
logger.info(' VERCEL_PROJECT_ID_ADMIN=prj_xxx')
|
|
295
|
+
logger.info(' VERCEL_PROJECT_ID_MERCHANT=prj_xxx')
|
|
309
296
|
logger.info(' VERCEL_PROJECT_ID_TELEGRAM_BOT=prj_xxx')
|
|
310
297
|
logger.info('')
|
|
311
298
|
logger.info('获取方式:')
|