Simplify admin publishing pipeline

This commit is contained in:
yarnom 2026-06-03 18:18:50 +08:00
parent 13e7e4026d
commit 9186801c7f
37 changed files with 750 additions and 3367 deletions

View file

@ -20,8 +20,11 @@ type Config struct {
RepoRoot string
PostsDir string
SiteDir string
AssetsDir string
StaticDir string
AdminDir string
LogFile string
LogMaxBytes int64
LogMaxBackups int
DeepSeek DeepSeekConfig
LocalLLM LocalLLMConfig
SlugProvider string
@ -89,9 +92,9 @@ func LoadConfig() Config {
siteDir = filepath.Join(repoRoot, "frontend", "site")
}
assetsDir := os.Getenv("OSAET_ASSETS_DIR")
if assetsDir == "" {
assetsDir = filepath.Join(siteDir, "public", "assets")
staticDir := os.Getenv("OSAET_STATIC_DIR")
if staticDir == "" {
staticDir = filepath.Join(repoRoot, "dist", "site")
}
adminDir := os.Getenv("OSAET_ADMIN_DIR")
@ -99,6 +102,11 @@ func LoadConfig() Config {
adminDir = filepath.Join(repoRoot, "frontend", "admin", "dist", "admin", "browser")
}
logFile := os.Getenv("OSAET_LOG_FILE")
if logFile == "" {
logFile = filepath.Join(repoRoot, ".osaet", "logs", "osaet-admin.log")
}
local := loadLocalConfig(repoRoot)
databaseURL := firstNonEmpty(os.Getenv("DATABASE_URL"), local.Database.PostgresDSN)
@ -118,8 +126,11 @@ func LoadConfig() Config {
RepoRoot: repoRoot,
PostsDir: postsDir,
SiteDir: siteDir,
AssetsDir: assetsDir,
StaticDir: staticDir,
AdminDir: adminDir,
LogFile: logFile,
LogMaxBytes: int64(firstNonZeroInt(envInt("OSAET_LOG_MAX_BYTES"), 10*1024*1024)),
LogMaxBackups: firstNonZeroInt(envInt("OSAET_LOG_MAX_BACKUPS"), 5),
SlugProvider: firstNonEmpty(os.Getenv("OSAET_SLUG_PROVIDER"), local.Slug.Provider, "deepseek"),
DeepSeek: DeepSeekConfig{
APIKey: deepSeekAPIKey,
@ -236,8 +247,8 @@ func (c Config) Validate() error {
if c.SiteDir == "" {
return errors.New("site dir is required")
}
if c.AssetsDir == "" {
return errors.New("assets dir is required")
if c.StaticDir == "" {
return errors.New("static dir is required")
}
return nil
}