Changeset 0.37.15 (#227)
This commit is contained in:
@@ -241,6 +241,33 @@ func (h *PackageHandler) InstallPackage(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// v0.37.15: Read script.star from archive if present.
|
||||
// Keeps the manifest clean — authors write a file, installer injects
|
||||
// it as _starlark_script for the sandbox runner.
|
||||
if _, hasInline := manifest["_starlark_script"]; !hasInline {
|
||||
for _, f := range zr.File {
|
||||
name := f.Name
|
||||
base := filepath.Base(name)
|
||||
if base == "script.star" && !f.FileInfo().IsDir() {
|
||||
rc, err := f.Open()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
data, err := io.ReadAll(rc)
|
||||
rc.Close()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
script := string(data)
|
||||
if strings.TrimSpace(script) != "" {
|
||||
manifest["_starlark_script"] = script
|
||||
log.Printf("[packages] Injected script.star (%d bytes) into manifest", len(data))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate required fields
|
||||
pkgID, _ := manifest["id"].(string)
|
||||
title, _ := manifest["title"].(string)
|
||||
|
||||
Reference in New Issue
Block a user