refactor: centralize environment variable handling with @tooling/env #82
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Greptile Overview
Greptile Summary
Centralized environment variable handling by creating a new
@tooling/envpackage with two key utilities:ensureEnv()for Vite configs andgetRuntimeEnv()for runtime environment access.Key Changes:
@tooling/envpackage withensureEnv()function that loads environment variables and validates them at build config time using jiti for dynamic importsgetRuntimeEnv()helper in@init/envthat consistently mergesimport.meta.envandprocess.envacross all environmentsensureEnv(mode)for early environment validation{ ...import.meta.env, ...process.env }) withgetRuntimeEnv()across all env.ts filesgetRuntimeEnv()for client-side environment accessBenefits:
Confidence Score: 5/5
Important Files Changed
ensureEnvutility to load environment variables in Vite configs using jiti for runtime importgetRuntimeEnvhelper to mergeimport.meta.envandprocess.envconsistentlygetRuntimeEnv()consistently for client-side environment accessensureEnv(mode)for early environment validationensureEnv()call at config initialization for Astro environment loadingensureEnv(mode)for Tauri environment validationSequence Diagram
sequenceDiagram participant ViteConfig as Vite Config participant EnsureEnv as ensureEnv() participant LoadEnv as Vite loadEnv() participant Jiti as jiti.import() participant EnvFile as env.ts participant CreateEnv as createEnv() participant GetRuntimeEnv as getRuntimeEnv() ViteConfig->>EnsureEnv: Call ensureEnv(mode) EnsureEnv->>LoadEnv: Load .env files LoadEnv-->>EnsureEnv: Return env vars EnsureEnv->>EnsureEnv: Object.assign(process.env, env) EnsureEnv->>Jiti: Import env.ts dynamically Jiti->>EnvFile: Execute env.ts EnvFile->>CreateEnv: Call createEnv() CreateEnv->>GetRuntimeEnv: Get runtime environment GetRuntimeEnv->>GetRuntimeEnv: Merge import.meta.env and process.env GetRuntimeEnv-->>CreateEnv: Return merged env CreateEnv->>CreateEnv: Validate environment variables CreateEnv-->>EnvFile: Return validated env EnvFile-->>Jiti: Module loaded Jiti-->>EnsureEnv: Import complete EnsureEnv-->>ViteConfig: Env validated