Files
skillshare/internal/version/skill.go
T
Willie 092fb14f8a feat: add web dashboard with embedded React SPA (skillshare ui)
Single-binary web UI for visual skill management — React 19 + Vite
frontend embedded via go:embed, Go net/http REST API backend (30+
endpoints). Includes dashboard, skills browser, targets, sync, collect,
search, install, config editor, backup/restore, and git sync pages.

Also adds Bitbucket/GitLab URL parsing for install, git operations
library, skill version checking, CI frontend build steps, Docker
sandbox support, and website docs for the ui command.
2026-02-08 05:08:30 +08:00

59 lines
1.3 KiB
Go

package version
import (
"bufio"
"net/http"
"path/filepath"
"strings"
"time"
"skillshare/internal/utils"
)
// SkillSourceURL is the raw URL to the official skillshare skill's SKILL.md.
const SkillSourceURL = "https://raw.githubusercontent.com/runkids/skillshare/main/skills/skillshare/SKILL.md"
// ReadLocalSkillVersion reads the "version" field from source/skillshare/SKILL.md.
func ReadLocalSkillVersion(sourceDir string) string {
skillFile := filepath.Join(sourceDir, "skillshare", "SKILL.md")
return utils.ParseFrontmatterField(skillFile, "version")
}
// FetchRemoteSkillVersion fetches the latest skill version from GitHub (3s timeout).
func FetchRemoteSkillVersion() string {
client := &http.Client{Timeout: 3 * time.Second}
resp, err := client.Get(SkillSourceURL)
if err != nil {
return ""
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return ""
}
scanner := bufio.NewScanner(resp.Body)
inFrontmatter := false
for scanner.Scan() {
line := scanner.Text()
if line == "---" {
if !inFrontmatter {
inFrontmatter = true
continue
}
break
}
if inFrontmatter && strings.HasPrefix(line, "version:") {
parts := strings.SplitN(line, ":", 2)
if len(parts) == 2 {
return strings.TrimSpace(parts[1])
}
}
}
return ""
}