From a8d6234b88042fc26dddc7ea7d017db782460e26 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sat, 25 Apr 2026 15:00:39 +0800 Subject: [PATCH] feat(env): add environment variable management script and update database copy command - Introduced a new script `mv-env.sh` to manage environment variable files, copying `.env.prod` if it exists, otherwise falling back to `.env.example`. - Updated the `cp:db` command in `package.json` to utilize the new script for improved environment configuration handling. These changes enhance the project's environment setup process, ensuring the correct environment variables are used during deployment. --- package.json | 2 +- scripts/mv-env.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 scripts/mv-env.sh diff --git a/package.json b/package.json index f724c4b..09784c6 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "build": "bun run sync:vditor && nuxt build && bun run cp:db && bun --elide-lines=0 --filter drizzle-pkg build", "dev": "bun run sync:vditor && nuxt dev", "sync:vditor": "sh scripts/sync-vditor-assets.sh", - "cp:db": "cp build-files/run.sh .output/run.sh && cp .env.example .output/.env && cp -r build-files/migrate/* .output/server/ && cp build-files/seed.js .output/server/seed.js", + "cp:db": "cp build-files/run.sh .output/run.sh && sh scripts/mv-env.sh && cp -r build-files/migrate/* .output/server/ && cp build-files/seed.js .output/server/seed.js", "migrate:test": "sh scripts/migrate-test.sh", "db:migrate": "bun --elide-lines=0 --filter drizzle-pkg migrate", "db:generate": "bun --elide-lines=0 --filter drizzle-pkg generate", diff --git a/scripts/mv-env.sh b/scripts/mv-env.sh new file mode 100644 index 0000000..d1d74cd --- /dev/null +++ b/scripts/mv-env.sh @@ -0,0 +1,5 @@ +if [ -f .env.prod ]; then + cp .env.prod .output/.env +else + cp .env.example .output/.env +fi \ No newline at end of file