Skip to content

feat: generate typed definitions and runtime validation schemas from templates #7

Description

@hammadmajid

Problem

Application code frequently references environment variables via untyped string lookups (e.g. process.env.PORT or os.Getenv("PORT")), resulting in runtime crashes when required variables or types are invalid.

Proposed Solution

Add an exenv schema / exenv typegen command that reads .env.example (with annotations like @bool, @options, @required) and generates strongly-typed definition files or runtime schemas for target languages.

Expected Behavior

  • exenv schema --format typescript: Generates TypeScript declarations (env.d.ts) or Zod schema objects (env.schema.ts).
  • exenv schema --format go: Generates a Go struct with typed fields, default values, and validation methods.
  • exenv schema --format json: Exports a standard JSON Schema describing all environment variables, types, and constraints.

Acceptance Criteria

  • Generated code accurately reflects requiredness, default values, and allowed enum options.
  • Output files can be written to stdout or specified file paths.
  • Generates clean, idiomatic code without external runtime dependencies where possible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions