Content Types¶
xfg supports different content types based on the target file extension.
JSON Files (.json)¶
Object content outputs as JSON with 2-space indentation:
Output:
JSON5 Files (.json5)¶
Object content outputs as plain JSON with 2-space indentation, the same as .json. header lines are written at the top as // comments (see the note under YAML Comments):
files:
config.json5:
header: "Do not edit manually"
content:
apiUrl: "https://api.example.com"
timeout: 5000
Output:
YAML Files (.yaml, .yml)¶
Object content outputs as YAML:
Output:
Strings are double-quoted. Multi-line strings in map values use the | block style; multi-line strings inside arrays stay double-quoted with \n.
YAML Comments¶
Add schema directives and header comments to YAML files:
files:
trivy.yaml:
schemaUrl: https://trivy.dev/latest/docs/references/configuration/config-file/
header: "Trivy security scanner configuration"
content:
exit-code: 1
Output:
# yaml-language-server: $schema=https://trivy.dev/latest/docs/references/configuration/config-file/
# Trivy security scanner configuration
exit-code: 1
A blank line separates the comments from the content. Multi-line headers are also supported:
files:
config.yaml:
header:
- "Auto-generated configuration"
- "Do not edit manually"
content:
version: 1
Note
header applies to YAML files (# lines) and .json5 files (// lines). schemaUrl applies to YAML files only. Both are ignored for .json files, and schemaUrl is ignored for .json5 files.
Text Files¶
Files with extensions other than .json, .json5, .yaml, or .yml are treated as text files. Use string or string array content:
String Content¶
Lines Array Content¶
Lines are joined with newlines in the output.
Empty Files¶
Omit content to create an empty file:
Validation Rules¶
.json,.json5,.yaml,.ymlfiles must have object content- Other file extensions must have string or string array content
- Mixing content types (e.g., object content in a
.txtfile) causes a validation error