add composer

This commit is contained in:
2025-11-17 10:16:27 +08:00
parent 6c6d5273ac
commit 8cff19ecca
10 changed files with 577 additions and 7 deletions

View File

@@ -90,7 +90,12 @@ func applyHubDefaults(h *HubConfig) {
h.CacheTTL = Duration(0)
}
if trimmed := strings.TrimSpace(h.Module); trimmed == "" {
h.Module = hubmodule.DefaultModuleKey()
typeKey := strings.ToLower(strings.TrimSpace(h.Type))
if meta, ok := hubmodule.Resolve(typeKey); ok {
h.Module = meta.Key
} else {
h.Module = hubmodule.DefaultModuleKey()
}
} else {
h.Module = strings.ToLower(trimmed)
}

View File

@@ -1,6 +1,7 @@
package config
import (
_ "github.com/any-hub/any-hub/internal/hubmodule/composer"
_ "github.com/any-hub/any-hub/internal/hubmodule/docker"
_ "github.com/any-hub/any-hub/internal/hubmodule/legacy"
_ "github.com/any-hub/any-hub/internal/hubmodule/npm"

View File

@@ -11,13 +11,14 @@ import (
)
var supportedHubTypes = map[string]struct{}{
"docker": {},
"npm": {},
"go": {},
"pypi": {},
"docker": {},
"npm": {},
"go": {},
"pypi": {},
"composer": {},
}
const supportedHubTypeList = "docker|npm|go|pypi"
const supportedHubTypeList = "docker|npm|go|pypi|composer"
// Validate 针对语义级别做进一步校验,防止非法配置启动服务。
func (c *Config) Validate() error {