prole/prole-app/Sources/ProleEnv.swift
chrisfu 197c72dd7a Refactor prole-app and establish temporary release process
- Moved prole-tools-app to prole-app at the project root to make it self-contained for transition to its own repository.
- Created prole-tools-app/dist/ directory to host build artifacts.
- Generated distribution artifacts (Prole Tools.app and Prole Tools.zip) using prole-app/build.sh package.
- Checked in the generated artifacts to prole-tools-app/dist/ (bypassing .gitignore for temporary release process).
Changes Summary
•
Renamed directory prole-tools-app/ to prole-app/.
•
Populated prole-tools-app/dist/ with the latest build output from prole-app/build.sh.
•
Staged all changes, including the forced addition of ignored artifacts in prole-tools-app/dist/.
2026-01-18 15:04:23 -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-mappings.conf exists
let pm = confDir().appendingPathComponent("port-mappings.conf")
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)
}
}
}