prole/prole-app/Sources/ProleEnv.swift
chrisfu d2efb835b0 Refactor project structure and update initialization scripts
- Moved files from 'prole/' subdirectory to root level or appropriate subdirectories (tests, authority, infrastructure) to flatten the project structure.

- Updated 'install.py' and initialization scripts in 'etc/' to reflect the new directory layout.

- Added 'etc/repair_pipeline.sh' for automated pipeline repairs.

- Updated configuration files including 'conf/prole.cfg' and 'env.sh'.

- Integrated ArgoCD manifests in 'k8s/argocd/'.

- Updated 'prole-app' environment and properties.

- Moved and updated test scripts for better organization and reliability.

- Added 'tests/silent_install_test.sh' for automated installation testing.
2026-02-14 13:44:49 -08:00

40 lines
1.5 KiB
Swift

import Foundation
enum ProleEnv {
static func proleHome() -> URL {
let env = ProcessInfo.processInfo.environment
let home = env["HOME"] ?? NSHomeDirectory()
let proleHome = env["PROLE_HOME"] ?? home
return URL(fileURLWithPath: proleHome, isDirectory: true)
}
static func logsDir() -> URL {
return proleHome().appendingPathComponent("logs", isDirectory: true)
}
static func confDir() -> URL {
return proleHome().appendingPathComponent("conf", isDirectory: true)
}
static func bootstrap() {
let fm = FileManager.default
// Ensure base, logs, conf
for dir in [proleHome(), logsDir(), confDir()] {
try? fm.createDirectory(at: dir, withIntermediateDirectories: true)
}
// Ensure conf/port-mapping.cfg exists
let pm = confDir().appendingPathComponent("port-mapping.cfg")
if !fm.fileExists(atPath: pm.path) {
let tpl = """
# Port mappings for Prole Tools (read by scripts).
# Format examples:
# grafana: local=3000 remote=80 ns=default svc=prometheus-community-grafana address=0.0.0.0
# db: local=5432 remote=5432 ns=default svc=prole-db-rw address=0.0.0.0
# Add your mappings below. One mapping per line as key=value tokens.
"""
try? tpl.trimmingCharacters(in: .whitespacesAndNewlines).appending("\n").write(to: pm, atomically: true, encoding: .utf8)
}
}
}