Files
skillshare/internal/install/context.go
T
Willie e48a301623 feat: add azure_hosts config for Azure DevOps Server on-premises
Add azure_hosts config parameter (analogous to gitlab_hosts) that allows
users to register self-hosted Azure DevOps Server hostnames so they
receive proper URL parsing without appending .git to clone URLs.

- Add AzureHosts field to Config and ProjectConfig structs
- Add SKILLSHARE_AZURE_HOSTS env var support with merge semantics
- Generalize hostname validation into shared normalizeHostList/mergeHostsFromEnv
- Add azureOnPremPattern regex and parseAzureOnPrem for /_git/ URL routing
- Add isAzureHost for config-based host detection (no auto-detect)
- Update TrackName to handle on-prem Azure DevOps clone URLs
- Wire AzureHosts through InstallContext, ParseOptions, and Server
- Add JSON Schema, UI fieldDocs, and website documentation
- Add 19 new tests covering config, source parsing, and server

Closes #147
2026-05-05 18:33:07 +08:00

74 lines
2.2 KiB
Go

package install
import "strings"
// SkillEntryDTO is a dependency-free copy of config.SkillEntry, used to avoid
// a circular import between install and config. The cmd layer converts
// config.SkillEntry → SkillEntryDTO before passing data through InstallContext.
type SkillEntryDTO struct {
Name string
Source string
Tracked bool
Group string
Branch string
}
// FullName returns the full relative path for the skill entry.
// If Group is set, returns "group/name"; otherwise returns Name.
func (s SkillEntryDTO) FullName() string {
if s.Group != "" {
return s.Group + "/" + s.Name
}
return s.Name
}
// EffectiveParts returns the effective (group, bareName) for this entry.
// If Group is set, returns (Group, Name).
// For backward compat, if Name contains "/" and Group is empty,
// splits at the last "/" to derive group and bare name.
func (s SkillEntryDTO) EffectiveParts() (group, name string) {
if s.Group != "" {
return s.Group, s.Name
}
if idx := strings.LastIndex(s.Name, "/"); idx >= 0 {
return s.Name[:idx], s.Name[idx+1:]
}
return "", s.Name
}
// InstallContext abstracts the behavioral differences between global and
// project install modes so that InstallFromConfig can be written once.
type InstallContext interface {
// SourcePath returns the skills directory
// (e.g. ~/.config/skillshare/skills or .skillshare/skills).
SourcePath() string
// ConfigSkills returns the remote skill entries from the config file.
ConfigSkills() []SkillEntryDTO
// Reconcile performs post-install config reconciliation
// (e.g. ReconcileGlobalSkills or ReconcileProjectSkills).
Reconcile() error
// PostInstallSkill is a per-skill hook called after a successful install.
// For example, project mode uses this to update .skillshare/.gitignore.
PostInstallSkill(displayName string) error
// Mode returns "global" or "project".
Mode() string
// GitLabHosts returns extra hostnames to treat as GitLab instances.
GitLabHosts() []string
// AzureHosts returns extra hostnames to treat as Azure DevOps on-premises instances.
AzureHosts() []string
}
// ConfigInstallResult summarises the outcome of InstallFromConfig.
type ConfigInstallResult struct {
Installed int
Skipped int
InstalledSkills []string
FailedSkills []string
}