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')