/**
 * .env.example Generator for React Frontend
 *
 * Generates example environment configuration
 */

import type { TemplateContext } from '@specverse/types';
import { getApiBaseUrl, getPathConfig } from '../../../shared/path-resolver.js';

export default function generateEnvExample(context: TemplateContext): string {
  const pathConfig = getPathConfig(context);
  const defaultApiUrl = getApiBaseUrl(pathConfig);

  return `# ─── Ports ────────────────────────────────────────────────────
# Running more than one SpecVerse project at once? Each project reads
# its own .env — copy this file to .env and bump the numbers so the
# projects don't collide.
#
# Suggested ranges (shared across the ecosystem):
#   3000-3049 : generated project backends (one per project)
#   3050-3099 : app-demo per-spec runtime backends
#   5173-5199 : vite frontends (one per project)
#   9000+     : app-demo Server Manager

# Backend (Fastify) port — read by \`npm run dev:backend\`.
PORT=3000

# Frontend (vite) port — read by \`npm run dev:frontend\`.
VITE_PORT=5173

# Frontend host — '0.0.0.0' if you want LAN access.
VITE_HOST=localhost

# ─── API wiring ────────────────────────────────────────────────
# Base URL for backend API. Used by the generated apiClient AND by
# vite's dev-server proxy (so /api and /ws requests from the browser
# are forwarded to your backend). Keep this in sync with PORT.
VITE_API_BASE_URL=${defaultApiUrl}

# API Path Prefix
VITE_API_PREFIX=/api

# Application Mode
VITE_APP_MODE=development
`;
}
