chore(mobile): check:env script lints .env.local against .env.example

This commit is contained in:
byGalax
2026-05-16 16:27:21 +02:00
parent 830dac4cdd
commit 1eea80c529
2 changed files with 40 additions and 1 deletions
+2 -1
View File
@@ -15,7 +15,8 @@
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest", "test:watch": "vitest",
"clean": "rm -rf .expo node_modules/.cache .turbo *.tsbuildinfo" "clean": "rm -rf .expo node_modules/.cache .turbo *.tsbuildinfo",
"check:env": "node scripts/check-env.mjs"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.29.2", "@babel/runtime": "^7.29.2",
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env node
// Compares apps/mobile/.env.example with .env.local. Surfaces missing keys
// so an onboarding dev doesn't ship a build that white-screens.
import { existsSync, readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const here = dirname(fileURLToPath(import.meta.url));
const mobileRoot = resolve(here, '..');
const examplePath = resolve(mobileRoot, '.env.example');
const localPath = resolve(mobileRoot, '.env.local');
if (!existsSync(localPath)) {
console.error('No .env.local found at ' + localPath);
console.error('Copy .env.example to .env.local and fill in values.');
process.exit(1);
}
function keysOf(path) {
return new Set(
readFileSync(path, 'utf8')
.split('\n')
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith('#'))
.map((line) => line.split('=', 1)[0]),
);
}
const exampleKeys = keysOf(examplePath);
const localKeys = keysOf(localPath);
const missing = [...exampleKeys].filter((k) => !localKeys.has(k));
if (missing.length > 0) {
console.error('Missing keys in .env.local: ' + missing.join(', '));
process.exit(1);
}
console.log('env-ok: all .env.example keys present in .env.local');