Skip to main content

Crate cuenv_codegen

Crate cuenv_codegen 

Source
Expand description

§cuenv-codegen

CUE-powered code generation and project scaffolding from CUE templates.

This crate provides a code generation system that:

  • Uses schema-wrapped code blocks (e.g., schema.#TypeScript, schema.#JSON)
  • Supports managed (always regenerated) and scaffold (generate once) file modes
  • Integrates with cuenv sync codegen command

§How it works

A Codegen configuration is a CUE-based template that defines multiple files to generate for a project. Define your files in CUE with type-safe schemas, then sync them with cuenv sync codegen.

§Example

schema.#Project & {
    name: "my-service"
    codegen: {
        files: {
            "package.json": schema.#JSON & {
                mode: "managed"
                content: """{"name": "my-service"}"""
            }
        }
    }
}

Re-exports§

pub use codegen::Codegen;
pub use generator::GenerateOptions;
pub use generator::Generator;

Modules§

codegen
CUE Codegen loading and evaluation
config
Formatter configuration generation
formatter
Code formatting integration
generator
File generation engine

Enums§

CodegenError
Errors that can occur during code generation

Type Aliases§

Result
Result type for codegen operations