A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
create .env generation script
Amruth Pillaif9b6aefffe1a
diff --git a/.env.example b/.env.exampleindex 47f0c9f15..1692f9f6f 100644--- a/.env.example+++ b/.env.example@@ -11,7 +11,7 @@ POSTGRES_PASSWORD=postgres# ServerSECRET_KEY=-POSTGRES_HOST=postgres+POSTGRES_HOST=localhostPOSTGRES_PORT=5432POSTGRES_SSL_CERT=JWT_SECRET=diff --git a/.eslintrc.json b/.eslintrc.jsonindex fb1370756..93f268448 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -14,6 +14,7 @@// TypeScript ESLint"@typescript-eslint/no-unused-vars": "off","@typescript-eslint/no-explicit-any": "off",+ "@typescript-eslint/no-non-null-assertion": "off","@typescript-eslint/interface-name-prefix": "off","@typescript-eslint/explicit-function-return-type": "off","@typescript-eslint/explicit-module-boundary-types": "off"diff --git a/.gitpod.yml b/.gitpod.ymlindex 748c4b59b..5d8b461db 100644--- a/.gitpod.yml+++ b/.gitpod.yml@@ -2,18 +2,12 @@ tasks:- name: Run PostgreSQL Databasecommand: docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres- - name: Restore Environment Variables+ - name: Generate Environment Variablescommand: |if [ -f .env ]; then- echo "Found .env in workspace"+ echo "Found .env in workspace, skipping generation"else- if [ -z "${DOTENV}" ]; then- echo "Setting example .env"- cp .env.gitpod .env- else- echo "Restoring .env from Gitpod"- echo "${DOTENV}" | base64 -d > .env- fi+ pnpm generate-envfi- name: Install Project Dependenciesdiff --git a/package.json b/package.jsonindex df99d5365..ab977ac46 100644--- a/package.json+++ b/package.json@@ -4,10 +4,11 @@"private": true,"scripts": {"dev": "env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run dev",- "lint": "turbo run lint","build": "env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run build","start": "env-cmd --silent cross-var cross-env VERSION=$npm_package_version turbo run start",- "format": "prettier --write ."+ "generate-env": "ts-node ./scripts/generate-env.ts",+ "format": "prettier --write .",+ "lint": "turbo run lint"},"workspaces": ["schema",@@ -18,15 +19,18 @@"cross-env": "^7.0.3","cross-var": "^1.1.0","env-cmd": "^10.1.0",- "turbo": "^1.6.3"+ "turbo": "^1.6.3",+ "uuid": "^9.0.0"},"devDependencies": {+ "@types/node": "^18.11.15","@typescript-eslint/eslint-plugin": "^5.46.1","@typescript-eslint/parser": "^5.46.1","eslint": "^8.29.0","eslint-plugin-import": "^2.26.0","eslint-plugin-simple-import-sort": "^8.0.0","prettier": "^2.8.1",+ "ts-node": "^10.9.1","typescript": "^4.9.4"},"resolutions": {diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex dec3f33f4..058077ec2 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -8,6 +8,7 @@ importers:.:specifiers:+ '@types/node': ^18.11.15'@typescript-eslint/eslint-plugin': ^5.46.1'@typescript-eslint/parser': ^5.46.1cross-env: ^7.0.3@@ -17,20 +18,25 @@ importers:eslint-plugin-import: ^2.26.0eslint-plugin-simple-import-sort: ^8.0.0prettier: ^2.8.1+ ts-node: ^10.9.1turbo: ^1.6.3typescript: ^4.9.4+ uuid: ^9.0.0dependencies:cross-env: 7.0.3cross-var: 1.1.0env-cmd: 10.1.0turbo: 1.6.3+ uuid: 9.0.0devDependencies:+ '@types/node': 18.11.15'@typescript-eslint/eslint-plugin': 5.46.1_imrg37k3svwu377c6q7gkarwmi'@typescript-eslint/parser': 5.46.1_ha6vam6werchizxrnqvarmz2zueslint: 8.29.0eslint-plugin-import: 2.26.0_z7hwuz3w5sq2sbhy7d4iqrnsvqeslint-plugin-simple-import-sort: [email protected]prettier: 2.8.1+ ts-node: 10.9.1_ewfw2lwfc3dwdvz7r6yz2ssqyitypescript: 4.9.4client:diff --git a/scripts/generate-env.ts b/scripts/generate-env.tsindex eb065f93f..401eb024b 100644--- a/scripts/generate-env.ts+++ b/scripts/generate-env.ts@@ -1 +1,66 @@-console.log('Hello, World!');+import { randomBytes } from 'crypto';+import fs from 'fs/promises';++const envMap = {+ TZ: 'UTC',+ PUBLIC_URL: '',+ PUBLIC_SERVER_URL: '',+ PUBLIC_GOOGLE_CLIENT_ID: '',+ POSTGRES_DB: 'postgres',+ POSTGRES_USER: 'postgres',+ POSTGRES_PASSWORD: 'postgres',+ SECRET_KEY: '',+ POSTGRES_HOST: 'localhost',+ POSTGRES_PORT: '5432',+ POSTGRES_SSL_CERT: '',+ JWT_SECRET: '',+ JWT_EXPIRY_TIME: '604800',+ GOOGLE_CLIENT_SECRET: '',+ GOOGLE_API_KEY: '',+ MAIL_FROM_NAME: '',+ MAIL_FROM_EMAIL: '',+ MAIL_HOST: '',+ MAIL_PORT: '',+ MAIL_USERNAME: '',+ MAIL_PASSWORD: '',+ STORAGE_BUCKET: '',+ STORAGE_REGION: '',+ STORAGE_ENDPOINT: '',+ STORAGE_URL_PREFIX: '',+ STORAGE_ACCESS_KEY: '',+ STORAGE_SECRET_KEY: '',+ PDF_DELETION_TIME: '345600000',+ PUBLIC_FLAG_DISABLE_SIGNUPS: 'false',+};++const main = async () => {+ // URLs+ // If running in a Gitpod environment, auto generated the URLs+ if (process.env.GITPOD_WORKSPACE_URL) {+ const baseUrl = new URL(process.env.GITPOD_WORKSPACE_URL!);++ envMap['PUBLIC_SERVER_URL'] = `https://3100-${baseUrl}`;+ envMap['PUBLIC_URL'] = `https://3000-${baseUrl}`;+ }+ // Otherwise, fallback to localhost+ else {+ envMap['PUBLIC_SERVER_URL'] = 'https://localhost:3100';+ envMap['PUBLIC_URL'] = 'https://localhost:3000';+ }++ // Secret Key+ envMap['SECRET_KEY'] = randomBytes(20).toString('hex');+ envMap['JWT_SECRET'] = randomBytes(40).toString('hex');++ const envFile = Object.entries(envMap)+ .reduce((acc, [key, value]) => {+ acc.push(`${key}=${value}`);++ return acc;+ }, [] as string[])+ .join('\n');++ await fs.writeFile('.env', envFile);+};++main();