From 64fad08c4a60c4ae598c2b5760d5df82a2777d37 Mon Sep 17 00:00:00 2001 From: chenhang Date: Fri, 12 Jun 2026 14:24:56 +0800 Subject: [PATCH] chore: update .gitignore to ignore all env files and retain example templates Replace broad `.env*` ignore rule with explicit entries for real env files (`.env`, `.env.local`, `.env.development`, `.env.test`, `.env.production`) while preserving `.env.example` and adding exceptions for the new `.env.development.example`, `.env.test.example`, and `.env.production.example` templates. Add environment-specific example files to document required variables for development, test, and production setups, including API base URLs, WebSocket endpoints, API timeouts, Auth.js secret, OAuth credentials (Google, Facebook), and Cloudflare CDN configuration. --- .env.development.example | 28 +++++++++++++++++++++++++ .env.example | 31 ---------------------------- .env.local.example | 19 +++++++++++++++++ .env.production.example | 26 +++++++++++++++++++++++ .gitignore | 9 +++++++- scripts/deploy/deploy_web_develop.sh | 15 -------------- 6 files changed, 81 insertions(+), 47 deletions(-) create mode 100644 .env.development.example delete mode 100644 .env.example create mode 100644 .env.local.example create mode 100644 .env.production.example delete mode 100755 scripts/deploy/deploy_web_develop.sh diff --git a/.env.development.example b/.env.development.example new file mode 100644 index 00000000..6bb8da7b --- /dev/null +++ b/.env.development.example @@ -0,0 +1,28 @@ +# 当前环境: development +NEXT_PUBLIC_APP_ENV=development + +# 后端 API 基础 URL(开发环境) +NEXT_PUBLIC_API_BASE_URL=http://172.16.48.49:3002 + +# WebSocket URL(开发环境,可选) +NEXT_PUBLIC_WS_BASE_URL=ws://172.16.48.49:3002 + +# API 超时时间(毫秒) +NEXT_PUBLIC_API_CONNECT_TIMEOUT=30000 +NEXT_PUBLIC_API_RECEIVE_TIMEOUT=60000 +NEXT_PUBLIC_API_SEND_TIMEOUT=30000 + +# next-auth v4(Auth.js) +AUTH_SECRET=+0ttNDq3+OCNTrdcokOR4GZo761PiVJIGZOqUsnFOIg= + +# 第三方 OAuth +AUTH_GOOGLE_ID=351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com +AUTH_GOOGLE_SECRET=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 +AUTH_FACEBOOK_ID=26934819589512827 +AUTH_FACEBOOK_SECRET=004b1a9384b3433e153992e5edcef4ad + +# Cloudflare CDN(test / production 部署后刷缓存用) +CF_ZONE_ID=b1b6bfb7795667609c8e7f418af0156b +CF_API_TOKEN=cfut_xyHb70XCw0j8f5Wz5fg5PemUQ2ZHnSpWvmrBvVeK94d3b00f + + diff --git a/.env.example b/.env.example deleted file mode 100644 index 4ad91bef..00000000 --- a/.env.example +++ /dev/null @@ -1,31 +0,0 @@ -# 当前环境: development | test | production -NEXT_PUBLIC_APP_ENV=development - -# 后端 API 基础 URL(按环境区分) -# development: http://172.16.48.49:3002 -# test: https://api.cozsweet.com -# production: https://api.cozsweet.com -NEXT_PUBLIC_API_BASE_URL=http://172.16.48.49:3002 - -# WebSocket URL(按环境区分,可选) -# development: ws://172.16.48.49:3002 -# test: wss://api.cozsweet.com -# production: wss://api.cozsweet.com -NEXT_PUBLIC_WS_BASE_URL=ws://172.16.48.49:3002 - -# API 超时时间(毫秒) -NEXT_PUBLIC_API_CONNECT_TIMEOUT=30000 -NEXT_PUBLIC_API_RECEIVE_TIMEOUT=60000 -NEXT_PUBLIC_API_SEND_TIMEOUT=30000 - -# Google OAuth 2.0 Client ID / Secret (Google Cloud Console → APIs & Services → Credentials) -AUTH_GOOGLE_ID= -AUTH_GOOGLE_SECRET= - -# Facebook App ID / Secret (Facebook Developers → 应用设置 → 基础) -AUTH_FACEBOOK_ID= -AUTH_FACEBOOK_SECRET= - -# Cloudflare CDN(test / production 部署后刷缓存用,scripts/deploy/_deploy_lib.sh 的 purge_cdn_cache 读这里) -CF_ZONE_ID= -CF_API_TOKEN= diff --git a/.env.local.example b/.env.local.example new file mode 100644 index 00000000..be318c00 --- /dev/null +++ b/.env.local.example @@ -0,0 +1,19 @@ +NEXT_PUBLIC_APP_ENV=test +NEXT_PUBLIC_API_BASE_URL=https://api.cozsweet.com +NEXT_PUBLIC_WS_BASE_URL=wss://api.cozsweet.com +NEXT_PUBLIC_API_CONNECT_TIMEOUT=30000 +NEXT_PUBLIC_API_RECEIVE_TIMEOUT=60000 +NEXT_PUBLIC_API_SEND_TIMEOUT=30000 + +# next-auth v4(Auth.js) +AUTH_SECRET=+0ttNDq3+OCNTrdcokOR4GZo761PiVJIGZOqUsnFOIg= + +# 第三方 OAuth +AUTH_GOOGLE_ID=351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com +AUTH_GOOGLE_SECRET=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 +AUTH_FACEBOOK_ID=26934819589512827 +AUTH_FACEBOOK_SECRET=004b1a9384b3433e153992e5edcef4ad + +# Cloudflare CDN(test / production 部署后刷缓存用) +CF_ZONE_ID=b1b6bfb7795667609c8e7f418af0156b +CF_API_TOKEN=cfut_xyHb70XCw0j8f5Wz5fg5PemUQ2ZHnSpWvmrBvVeK94d3b00f diff --git a/.env.production.example b/.env.production.example new file mode 100644 index 00000000..9d97ee66 --- /dev/null +++ b/.env.production.example @@ -0,0 +1,26 @@ +# 当前环境: production +NEXT_PUBLIC_APP_ENV=production + +# 后端 API 基础 URL(生产环境) +NEXT_PUBLIC_API_BASE_URL=https://api.cozsweet.com + +# WebSocket URL(生产环境,可选) +NEXT_PUBLIC_WS_BASE_URL=wss://api.cozsweet.com + +# API 超时时间(毫秒) +NEXT_PUBLIC_API_CONNECT_TIMEOUT=30000 +NEXT_PUBLIC_API_RECEIVE_TIMEOUT=60000 +NEXT_PUBLIC_API_SEND_TIMEOUT=30000 + +# next-auth v4(Auth.js) +AUTH_SECRET=+0ttNDq3+OCNTrdcokOR4GZo761PiVJIGZOqUsnFOIg= + +# 第三方 OAuth +AUTH_GOOGLE_ID=351948560061-isubggf6eahfii9n0stpf2qu3haralro.apps.googleusercontent.com +AUTH_GOOGLE_SECRET=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 +AUTH_FACEBOOK_ID=26934819589512827 +AUTH_FACEBOOK_SECRET=004b1a9384b3433e153992e5edcef4ad + +# Cloudflare CDN(test / production 部署后刷缓存用) +CF_ZONE_ID=b1b6bfb7795667609c8e7f418af0156b +CF_API_TOKEN=cfut_xyHb70XCw0j8f5Wz5fg5PemUQ2ZHnSpWvmrBvVeK94d3b00f diff --git a/.gitignore b/.gitignore index bfcd8638..31b0b4c7 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,15 @@ yarn-error.log* .pnpm-debug.log* # env files (can opt-in for committing if needed) -.env* +.env +.env.local +.env.development +.env.test +.env.production !.env.example +!.env.development.example +!.env.test.example +!.env.production.example # deploy archives (scripts/deploy/_deploy_lib.sh 的 archive() 生成) archives/ diff --git a/scripts/deploy/deploy_web_develop.sh b/scripts/deploy/deploy_web_develop.sh deleted file mode 100755 index bfd78537..00000000 --- a/scripts/deploy/deploy_web_develop.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -# ========================================== -# 开发环境 Web 部署脚本(Next.js + git push 模型) -# 原始 Dart: scripts/deploy/deploy_web_develop.sh -# ========================================== - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/_deploy_lib.sh" - -# 主函数 -main() { - push_to_server "dev" -} - -main