From f904500e2dfdc8ae90afef9d04bdf9312701d781 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Mon, 20 Oct 2025 16:42:43 +0200 Subject: [PATCH] refactor: remove check-env-vars.js and update lint script to streamline environment checks --- apps/infoalloggi/check-env-vars.js | 50 ------------------------------ apps/infoalloggi/headers/lint.js | 6 ++-- apps/infoalloggi/package.json | 2 +- apps/infoalloggi/tsconfig.json | 1 - 4 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 apps/infoalloggi/check-env-vars.js diff --git a/apps/infoalloggi/check-env-vars.js b/apps/infoalloggi/check-env-vars.js deleted file mode 100644 index 2904558..0000000 --- a/apps/infoalloggi/check-env-vars.js +++ /dev/null @@ -1,50 +0,0 @@ -const fs = require("node:fs"); -const YAML = require("yaml"); - -const ciFilepath = ".github/workflows/ci.yml"; -const envFilepath = "src/env.mjs"; - -const ignoreEnvs = ["NODE_ENV", "SKIP_ENV_VALIDATION"]; - -// ANSI escape codes for colors -const colors = { - red: "\x1b[31m%s\x1b[0m", - green: "\x1b[32m%s\x1b[0m", - yellow: "\x1b[33m%s\x1b[0m", -}; - -console.log(); -console.log(colors.yellow, "Environment variables checker:"); -// Read CI file content -try { - const ciContent = fs.readFileSync(ciFilepath, "utf8"); - const ciData = YAML.parse(ciContent); - - // Read env file content - const envContent = fs.readFileSync(envFilepath, "utf8"); - const envRegex = /process\.env\.([A-Z_0-9]+)/g; - const declaredEnvs = []; - - let match = envRegex.exec(envContent); - while (match !== null) { - declaredEnvs.push(match[1]); - match = envRegex.exec(envContent); // Re-assign at the end of the loop - } - - // Remove ignored environment variables from the list of declared environment variables - const filteredEnvs = declaredEnvs.filter((env) => !ignoreEnvs.includes(env)); - - // Check for missing env variables in CI file - const missingEnvs = filteredEnvs.filter((env) => !ciData.env[env]); - - if (missingEnvs.length > 0) { - console.error( - colors.red, - `Missing environment variables in ${ciFilepath}: ${missingEnvs.join(", ")}`, - ); - } else { - console.log(colors.green, "No missing environment variables found."); - } -} catch (error) { - console.error(colors.red, `Error processing files: ${error.message}`); -} diff --git a/apps/infoalloggi/headers/lint.js b/apps/infoalloggi/headers/lint.js index fed41b4..20da331 100644 --- a/apps/infoalloggi/headers/lint.js +++ b/apps/infoalloggi/headers/lint.js @@ -1,6 +1,6 @@ console.log( - "\x1b[33m%s\x1b[0m", - ` + "\x1b[33m%s\x1b[0m", + ` _ _ _ | | (_) | | | | _ _ __ | |_ @@ -8,6 +8,6 @@ console.log( | |____| | | | | |_ \\_____/|_|_| |_|\\__| -🔍 Linting and Env Checks... +🔍 Linting ... `, ); diff --git a/apps/infoalloggi/package.json b/apps/infoalloggi/package.json index c210761..8fa63c4 100644 --- a/apps/infoalloggi/package.json +++ b/apps/infoalloggi/package.json @@ -9,7 +9,7 @@ "email": "cross-env NEXT_PUBLIC_BASE_URL='https://localhost:3000' email dev --port 3500", "idev": "cross-env NODE_OPTIONS='--inspect' next dev --turbopack", "knip": "knip --no-exit-code", - "lint": "node ./headers/lint.js && biome lint && node check-env-vars.js", + "lint": "node ./headers/lint.js && biome lint", "pg-typegen": "node ./headers/pg-typegen.js && npx kanel", "start": "next start", "stripe-dev": "stripe listen --forward-to https://localhost:3000/api/stripe-webhook", diff --git a/apps/infoalloggi/tsconfig.json b/apps/infoalloggi/tsconfig.json index 643fbc3..9790eef 100644 --- a/apps/infoalloggi/tsconfig.json +++ b/apps/infoalloggi/tsconfig.json @@ -35,7 +35,6 @@ "node_modules", "out", "dist", - "check-env-vars.js", "headers", "kyselyRules", ".kanelrc.js"