From 92116b9e3fcdc39a02db74775f3861e79f788921 Mon Sep 17 00:00:00 2001 From: sunny Date: Tue, 1 Apr 2025 10:47:00 +0800 Subject: [PATCH] fix: Deploy script PROJECT_NAME is invalid --- scripts/deploy/index.ts | 6 +++++- wrangler.example.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/deploy/index.ts b/scripts/deploy/index.ts index a5683ba..a3024f8 100644 --- a/scripts/deploy/index.ts +++ b/scripts/deploy/index.ts @@ -16,7 +16,6 @@ const PROJECT_NAME = process.env.PROJECT_NAME || "moemail"; const DATABASE_NAME = process.env.DATABASE_NAME || "moemail-db"; const KV_NAMESPACE_NAME = process.env.KV_NAMESPACE_NAME || "moemail-kv"; const CUSTOM_DOMAIN = process.env.CUSTOM_DOMAIN; - const KV_NAMESPACE_ID = process.env.KV_NAMESPACE_ID; /** @@ -52,6 +51,11 @@ const setupConfigFile = (examplePath: string, targetPath: string) => { const configContent = readFileSync(examplePath, "utf-8"); const json = JSON.parse(configContent); + // 写入 pages 项目名称 + if (targetPath.split("/").at(-1) === "wrangler.json") { + json.name = PROJECT_NAME; + } + // 处理数据库配置 if (json.d1_databases && json.d1_databases.length > 0) { json.d1_databases[0].database_name = DATABASE_NAME; diff --git a/wrangler.example.json b/wrangler.example.json index a34d017..a936315 100644 --- a/wrangler.example.json +++ b/wrangler.example.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/wrangler/config-schema.json", - "name": "moemail", + "name": "${PROJECT_NAME}", "compatibility_date": "2024-03-20", "compatibility_flags": ["nodejs_compat"], "pages_build_output_dir": ".vercel/output/static",