diff --git a/apps/mobile/package.json b/apps/mobile/package.json index e922da5..90bc771 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -15,7 +15,8 @@ "typecheck": "tsc --noEmit", "test": "vitest run", "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": { "@babel/runtime": "^7.29.2", diff --git a/apps/mobile/scripts/check-env.mjs b/apps/mobile/scripts/check-env.mjs new file mode 100644 index 0000000..396a3d6 --- /dev/null +++ b/apps/mobile/scripts/check-env.mjs @@ -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');