mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-10-15 12:15:11 +00:00
fix: read SDK version from meta/meta.go for plugin go.mod
- detectSDKInfo now returns SDK version from meta/meta.go - Generated plugin go.mod uses real version (v0.7.1) instead of v0.0.0 - Tag v0.7.1 created for SDK version management
This commit is contained in:
@ -90,7 +90,7 @@ func cmdInit(args []string) {
|
|||||||
|
|
||||||
// Detect SDK info for Go plugin go.mod
|
// Detect SDK info for Go plugin go.mod
|
||||||
if !isLua {
|
if !isLua {
|
||||||
sdkMod, goVer, sdkPath := detectSDKInfo()
|
sdkMod, goVer, sdkPath, sdkVer := detectSDKInfo()
|
||||||
sdkReplace := sdkPath
|
sdkReplace := sdkPath
|
||||||
// Make replace path absolute and use forward slashes
|
// Make replace path absolute and use forward slashes
|
||||||
if abs, err := filepath.Abs(sdkPath); err == nil {
|
if abs, err := filepath.Abs(sdkPath); err == nil {
|
||||||
@ -99,7 +99,7 @@ func cmdInit(args []string) {
|
|||||||
data.ModulePath = name
|
data.ModulePath = name
|
||||||
data.GoVersion = goVer
|
data.GoVersion = goVer
|
||||||
data.SDKModule = sdkMod
|
data.SDKModule = sdkMod
|
||||||
data.SDKVersion = "v0.0.0"
|
data.SDKVersion = "v" + sdkVer
|
||||||
data.SDKReplace = sdkReplace
|
data.SDKReplace = sdkReplace
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,8 +137,8 @@ func cmdInit(args []string) {
|
|||||||
fmt.Printf(" cd %s && plugindev build\n", dir)
|
fmt.Printf(" cd %s && plugindev build\n", dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
// detectSDKInfo reads the HomeAgent SDK's go.mod to get module path and go version.
|
// detectSDKInfo reads the HomeAgent SDK's go.mod and meta to get module path, go version, and SDK version.
|
||||||
func detectSDKInfo() (modulePath, goVersion, sdkPath string) {
|
func detectSDKInfo() (modulePath, goVersion, sdkPath, sdkVersion string) {
|
||||||
root := activeSDKRoot()
|
root := activeSDKRoot()
|
||||||
gomodPath := filepath.Join(root, "go.mod")
|
gomodPath := filepath.Join(root, "go.mod")
|
||||||
data, err := os.ReadFile(gomodPath)
|
data, err := os.ReadFile(gomodPath)
|
||||||
@ -163,7 +163,8 @@ func detectSDKInfo() (modulePath, goVersion, sdkPath string) {
|
|||||||
if goVersion == "" {
|
if goVersion == "" {
|
||||||
goVersion = "1.21"
|
goVersion = "1.21"
|
||||||
}
|
}
|
||||||
return modulePath, goVersion, root
|
sdkVersion = readMetaVersion(root)
|
||||||
|
return modulePath, goVersion, root, sdkVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeTemplate(path, content string, data TemplateData) {
|
func writeTemplate(path, content string, data TemplateData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user