leaf

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: 0BSD Imports: 6 Imported by: 0

Documentation

Overview

Package leaf handles the mapping between store targets and the concrete dotfiles on disk, plus dotenv parsing/serialization.

Filename convention (derived from a target's basepath directory + env + tier):

tier=buildtime -> <dir>/.env[.<env>]        (read by the build; NEXT_PUBLIC_*, etc.)
tier=runtime   -> <dir>/.dev.vars[.<env>]   (read by wrangler locally; pushed as secrets)

The sentinel env "_" (store.DefaultEnv) produces suffix-less files: .env and .dev.vars.

Index

Constants

View Source
const IgnoredHeader = "# ward-ignored variables below"

IgnoredHeader introduces the trailing block of ward-ignored variables in a generated leaf file. Variables below it are preserved (their parsed values re-serialized) and never captured into the store.

Variables

This section is empty.

Functions

func FileName

func FileName(tier store.Tier, env string) string

FileName returns the dotfile name (no directory) for a tier+env.

func Parse

func Parse(content string) (map[string]string, error)

Parse reads dotenv content into a flat map. It ignores blank lines and comment lines (leading '#'); the store is the source of truth for structure, so comments live only in *.example files and are intentionally dropped here. Surrounding single or double quotes on values are stripped. A leading "export " is tolerated.

func Path

func Path(basepath string, tier store.Tier, env string) string

Path returns the full path (dir joined with the derived filename) for a target basepath, tier, and env.

func Serialize

func Serialize(vals map[string]string) string

Serialize renders a flat map into deterministic dotenv content (keys sorted), quoting values that contain whitespace or characters that would otherwise be ambiguous. A generated-file header warns humans not to edit blindly.

func SerializeWithIgnored added in v0.0.4

func SerializeWithIgnored(vals, ignored map[string]string) string

SerializeWithIgnored renders the managed values followed by an ignored block. The ignored block (introduced by IgnoredHeader) is only emitted when there is at least one ignored variable to preserve, so files with no ignored variables look exactly as before.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL