File size: 884 Bytes
2415446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Canonical env template loading for init and Admin UI defaults."""

import importlib.resources
from pathlib import Path


def load_env_template() -> str:
    """Load the root ``.env.example`` template from wheel resources or checkout."""

    packaged = importlib.resources.files("free_claude_code.config").joinpath(
        "env.example"
    )
    if packaged.is_file():
        return packaged.read_text("utf-8")

    source_template = Path(__file__).resolve().parents[3] / ".env.example"
    if source_template.is_file():
        return source_template.read_text(encoding="utf-8")

    raise FileNotFoundError("Could not find bundled or source .env.example template.")


def load_env_template_or_empty() -> str:
    """Return the env template, or an empty template when unavailable."""

    try:
        return load_env_template()
    except FileNotFoundError:
        return ""