diff --git a/.github/workflows/shortest.yml b/.github/workflows/shortest.yml index ce268b75..9085a853 100644 --- a/.github/workflows/shortest.yml +++ b/.github/workflows/shortest.yml @@ -36,7 +36,7 @@ jobs: cp .vercel/.env.preview.local .env.local test -f .env.local || (echo ".env.local not created" && exit 1) - - name: Set up database + - name: Setup database run: | pnpm drizzle-kit generate pnpm db:migrate diff --git a/lib/db/cleanup.ts b/lib/db/cleanup.ts index 45a9a882..6772aee9 100644 --- a/lib/db/cleanup.ts +++ b/lib/db/cleanup.ts @@ -2,7 +2,7 @@ import dotenv from "dotenv"; import { sql } from "drizzle-orm"; import { db, client } from "@/lib/db/drizzle"; -dotenv.config(); +dotenv.config({ path: ".env.local" }); async function cleanup() { try { diff --git a/lib/db/drizzle.ts b/lib/db/drizzle.ts index c9da7336..e8e4695b 100644 --- a/lib/db/drizzle.ts +++ b/lib/db/drizzle.ts @@ -3,7 +3,8 @@ import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; import * as schema from "@/lib/db/schema"; -dotenv.config(); +// Load .env and .env.local +dotenv.config({ path: ".env.local" }); if (!process.env.POSTGRES_URL) { throw new Error("POSTGRES_URL environment variable is not set"); diff --git a/lib/db/migrate.ts b/lib/db/migrate.ts index b607db86..971039b4 100644 --- a/lib/db/migrate.ts +++ b/lib/db/migrate.ts @@ -4,7 +4,7 @@ import { migrate } from "drizzle-orm/postgres-js/migrator"; import { client, db } from "@/lib/db/drizzle"; -dotenv.config(); +dotenv.config({ path: ".env.local" }); async function main() { await migrate(db, { diff --git a/package.json b/package.json index 9bef43fc..5639b67f 100644 --- a/package.json +++ b/package.json @@ -6,18 +6,18 @@ "dev": "next dev --turbo", "build": "next build", "start": "next start", - "db:seed": "dotenv -e .env.local -- npx tsx lib/db/seed.ts", - "db:generate": "dotenv -e .env.local -- drizzle-kit generate", - "db:migrate": "dotenv -e .env.local -- npx tsx lib/db/migrate.ts", - "db:studio": "dotenv -e .env.local -- drizzle-kit studio", - "db:cleanup": "dotenv -e .env.local -- tsx lib/db/cleanup.ts", + "db:seed": "npx tsx lib/db/seed.ts", + "db:generate": "drizzle-kit generate", + "db:migrate": "npx tsx lib/db/migrate.ts", + "db:studio": "drizzle-kit studio", + "db:cleanup": "tsx lib/db/cleanup.ts", "stripe:webhooks": "stripe listen --forward-to http://localhost:3000/api/stripe/webhook", - "setup": "dotenv -e .env.local -- npx tsx lib/setup.ts", - "pkg:build": "dotenv -e .env.local -- cd packages/shortest && pnpm build", - "pkg:dev": "dotenv -e .env.local -- cd packages/shortest && pnpm dev", - "pkg:test": "dotenv -e .env.local -- cd packages/shortest && pnpm shortest", - "pkg:test:src": "dotenv -e .env.local -- npx tsx packages/shortest/src/cli/bin.ts", - "test": "dotenv -e .env.local -- pnpm shortest", + "setup": "npx tsx lib/setup.ts", + "pkg:build": "cd packages/shortest && pnpm build", + "pkg:dev": "cd packages/shortest && pnpm dev", + "pkg:test": "cd packages/shortest && pnpm shortest", + "pkg:test:src": "npx tsx packages/shortest/src/cli/bin.ts", + "test": "pnpm shortest", "lint": "eslint .", "lint:fix": "eslint . --fix", "typecheck": "tsc --noEmit --incremental" diff --git a/packages/shortest/src/browser/integrations/github.ts b/packages/shortest/src/browser/integrations/github.ts index f7cdc51f..8f858652 100644 --- a/packages/shortest/src/browser/integrations/github.ts +++ b/packages/shortest/src/browser/integrations/github.ts @@ -17,7 +17,6 @@ export class GitHubTool { constructor(secret?: string) { dotenv.config({ path: ".env.local" }); - dotenv.config({ path: ".env" }); this.totpSecret = secret || process.env.GITHUB_TOTP_SECRET || ""; diff --git a/packages/shortest/src/index.ts b/packages/shortest/src/index.ts index 5ed2a5d5..f1493644 100644 --- a/packages/shortest/src/index.ts +++ b/packages/shortest/src/index.ts @@ -41,7 +41,6 @@ if (!global.__shortest__) { // Attach to global scope global.expect = global.__shortest__.expect; - dotenv.config({ path: join(process.cwd(), ".env") }); dotenv.config({ path: join(process.cwd(), ".env.local") }); } @@ -65,7 +64,6 @@ function validateConfig(config: Partial) { export async function initialize() { if (globalConfig) return globalConfig; - dotenv.config({ path: join(process.cwd(), ".env") }); dotenv.config({ path: join(process.cwd(), ".env.local") }); const configFiles = [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 812fe2c4..dc9d96ff 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -204,9 +204,6 @@ importers: '@vitejs/plugin-react': specifier: ^4.3.1 version: 4.3.4(vite@6.0.6(@types/node@22.10.2)(jiti@1.21.7)(tsx@4.19.2)(yaml@2.6.1)) - dotenv-cli: - specifier: ^8.0.0 - version: 8.0.0 eslint: specifier: ^9.17.0 version: 9.17.0(jiti@1.21.7) @@ -3059,14 +3056,6 @@ packages: dot-case@3.0.4: resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} - dotenv-cli@8.0.0: - resolution: {integrity: sha512-aLqYbK7xKOiTMIRf1lDPbI+Y+Ip/wo5k3eyp6ePysVaSqbyxjyK3dK35BTxG+rmd7djf5q2UPs4noPNH+cj0Qw==} - hasBin: true - - dotenv-expand@10.0.0: - resolution: {integrity: sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==} - engines: {node: '>=12'} - dotenv@16.4.5: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} @@ -7711,15 +7700,6 @@ snapshots: no-case: 3.0.4 tslib: 2.4.1 - dotenv-cli@8.0.0: - dependencies: - cross-spawn: 7.0.6 - dotenv: 16.4.7 - dotenv-expand: 10.0.0 - minimist: 1.2.8 - - dotenv-expand@10.0.0: {} - dotenv@16.4.5: {} dotenv@16.4.7: {}