Header menu logo UnionConfig

EnvFile Module

.env file operations: reading, comparing, masking, editing.

Types

Type Description

EnvFileEntry

A single entry in a .env file section

EnvFileSection

A section of entries in a .env file, grouped under a header

Functions and values

Function or value Description

compareConfigs before after

Full Usage: compareConfigs before after

Parameters:
    before : Map<string, string>
    after : Map<string, string>

Returns: (string * string * string) array

Compare two configs and return array of (key, oldValue, newValue) for changed entries Detects: new values, changed values, and deletions (old value present, new value empty/missing)

before : Map<string, string>
after : Map<string, string>
Returns: (string * string * string) array

defaultSections groupedDefs values

Full Usage: defaultSections groupedDefs values

Parameters:
    groupedDefs : (string * ConfigVarDef array) array
    values : Map<string, string>

Returns: EnvFileSection array

Build EnvFileSection array from grouped config var definitions and current values Groups with empty name become "Other". Uses Doc.Description as comment if non-empty. Missing values default to empty string.

groupedDefs : (string * ConfigVarDef array) array
values : Map<string, string>
Returns: EnvFileSection array

displayChanges changes

Full Usage: displayChanges changes

Parameters:
    changes : (string * string * string) array

Display config changes in a user-friendly format

changes : (string * string * string) array

maskValue key value

Full Usage: maskValue key value

Parameters:
    key : string
    value : string

Returns: string

Mask sensitive values for display (shows first 4 chars, rest as asterisks)

key : string
value : string
Returns: string

missingEntriesHeader defs values

Full Usage: missingEntriesHeader defs values

Parameters:
Returns: string list

Generate comment lines summarizing missing required config entries. Returns empty list when nothing is missing.

defs : ConfigVarDef array
values : Map<string, string>
Returns: string list

openInEditor editor path

Full Usage: openInEditor editor path

Parameters:
    editor : string
    path : string

Open a file in the given editor command

editor : string
path : string

readEnvFile path

Full Usage: readEnvFile path

Parameters:
    path : string

Returns: Map<string, string>

Read a .env-style configuration file into a Map Ignores comments (lines starting with #) and empty lines

path : string
Returns: Map<string, string>

secretKeyIndicators

Full Usage: secretKeyIndicators

Returns: string[]

Secret key indicators for masking sensitive values in output

Returns: string[]

writeEnvFile path headerLines sections

Full Usage: writeEnvFile path headerLines sections

Parameters:
    path : string
    headerLines : string list
    sections : EnvFileSection array

Write a sectioned .env file with optional header lines and sections Header lines are written as-is before sections. Each section gets a `# === Header ===` header line.

path : string
headerLines : string list
sections : EnvFileSection array

Type something to start searching.