From b6164d8944330564e9911e47f36d82620986c8c5 Mon Sep 17 00:00:00 2001 From: Christopher Ehrlich Date: Tue, 19 Jul 2022 14:06:36 +0200 Subject: [PATCH] fix: missing DATABASE_URL (#222) --- .github/workflows/PR-CI.yml | 4 +--- src/installers/envVars.ts | 8 +++++++- template/addons/prisma/schema.prisma | 3 +-- template/base/.env-example | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/PR-CI.yml b/.github/workflows/PR-CI.yml index 24dd524032..bd0f252a59 100644 --- a/.github/workflows/PR-CI.yml +++ b/.github/workflows/PR-CI.yml @@ -5,7 +5,7 @@ name: PR-CI on: pull_request: branches: ["*"] - + jobs: install-deps: runs-on: ubuntu-latest @@ -31,7 +31,6 @@ jobs: if: steps.pnpm-cache.outputs.cache-hit != 'true' - run: pnpm install - lint: runs-on: ubuntu-latest name: Run ESLint @@ -125,5 +124,4 @@ jobs: # has to be scaffolded outside the CLI project so that no lint/tsconfig are leaking # through. this way it ensures that it is the app's configs that are being used - run: pnpm start -y ../ci-test-app - - run: mv ../ci-test-app/.env-example ../ci-test-app/.env - run: cd ../ci-test-app && pnpm build diff --git a/src/installers/envVars.ts b/src/installers/envVars.ts index 47df283317..409c63be0f 100644 --- a/src/installers/envVars.ts +++ b/src/installers/envVars.ts @@ -31,5 +31,11 @@ export const envVariablesInstaller: Installer = async ({ const envSchemaSrc = path.join(envAssetDir, envFile); const envSchemaDest = path.join(projectDir, "src/server/env-schema.mjs"); - await fs.copy(envSchemaSrc, envSchemaDest, { overwrite: true }); + const envExample = path.join(projectDir, ".env-example"); + const envDest = path.join(projectDir, ".env"); + + await Promise.all([ + fs.copy(envSchemaSrc, envSchemaDest, { overwrite: true }), + fs.rename(envExample, envDest), + ]); }; diff --git a/template/addons/prisma/schema.prisma b/template/addons/prisma/schema.prisma index 90cd79af9a..34ba4eb7d5 100644 --- a/template/addons/prisma/schema.prisma +++ b/template/addons/prisma/schema.prisma @@ -7,8 +7,7 @@ generator client { datasource db { provider = "sqlite" - url = "file:./db.sqlite" - // url = env("DATABASE_URL") + url = env("DATABASE_URL") } model Example { diff --git a/template/base/.env-example b/template/base/.env-example index 2a25fe514f..bc003984c4 100644 --- a/template/base/.env-example +++ b/template/base/.env-example @@ -1,7 +1,7 @@ # Note that not all variables here might be in use for your selected configuration # Prisma -DATABASE_URL=postgresql://postgres:@localhost:5832/db +DATABASE_URL=file:./db.sqlite # Next Auth NEXTAUTH_SECRET=