From 57e0b91f0dedb30752f4c38332de3404d4e3397a Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 18 Nov 2024 16:18:48 -0500 Subject: [PATCH] added .env and generation script for env.ts --- .env.example | 1 + .gitignore | 3 +++ package.json | 3 +++ packages/kit/src/env.ts | 1 - scripts/generate-env.js | 13 +++++++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .env.example delete mode 100644 packages/kit/src/env.ts create mode 100644 scripts/generate-env.js diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..32135bab --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DEVMODE=false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 059c5452..7f400b41 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ dist/ .cache package-lock.json coverage + +.env +packages/kit/src/env.ts diff --git a/package.json b/package.json index ba2fe48d..63c21807 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,9 @@ "license": "Apache-2.0", "sideEffects": false, "scripts": { + "copy-env": "((cp -n .env.example .env) || echo already exists)", + "generate-env": "node scripts/generate-env.js", + "postinstall": "pnpm run copy-env && pnpm run generate-env", "build": "turbo run build --filter={packages/*}", "build:clean": "turbo run build:clean", "dev": "turbo run dev --filter={packages/*}", diff --git a/packages/kit/src/env.ts b/packages/kit/src/env.ts deleted file mode 100644 index 24254c1b..00000000 --- a/packages/kit/src/env.ts +++ /dev/null @@ -1 +0,0 @@ -export const DEVMODE = false diff --git a/scripts/generate-env.js b/scripts/generate-env.js new file mode 100644 index 00000000..a6cfdf3f --- /dev/null +++ b/scripts/generate-env.js @@ -0,0 +1,13 @@ +const fs = require('fs') +const path = require('path') +const dotenv = require('dotenv') + +dotenv.config() + +const envFilePath = path.resolve(__dirname, '../packages/kit/src/env.ts') + +const envFileContent = `export const DEVMODE = ${process.env.DEVMODE}` + +fs.writeFileSync(envFilePath, envFileContent.trim(), 'utf8') + +console.log('env.ts file generated successfully')