Files
panel/tools/module-meta-dump/main.go
T
2026-07-15 01:06:16 -07:00

46 lines
1.3 KiB
Go

// Command module-meta-dump loads ./modules via the same loader the
// controller uses (module.LoadDir) and prints the WI-07 UI-metadata
// enrichment as JSON — used by controller/.test/wi07-diff-maps.mjs to
// prove the manifest-derived values match the dashboard's old inline
// maps. Run from the repo root: go run ./tools/module-meta-dump
package main
import (
"encoding/json"
"fmt"
"os"
module "github.com/dbledeez/panel/pkg/module"
)
type meta struct {
ID string `json:"id"`
Ports []module.Port `json:"ports,omitempty"`
BrowseableRoots []module.BrowseableRoot `json:"browseable_roots,omitempty"`
ReadyPattern string `json:"ready_pattern,omitempty"`
Appearance *module.Appearance `json:"appearance,omitempty"`
}
func main() {
dir := "./modules"
if len(os.Args) > 1 {
dir = os.Args[1]
}
ms, err := module.LoadDir(dir)
if err != nil {
fmt.Fprintln(os.Stderr, "load:", err)
os.Exit(1)
}
out := map[string]meta{}
for _, m := range ms {
e := meta{ID: m.ID, Ports: m.Ports, ReadyPattern: m.ReadyPattern, Appearance: m.Appearance}
if m.Runtime.Docker != nil {
e.BrowseableRoots = m.Runtime.Docker.BrowseableRoots
}
out[m.ID] = e
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
enc.Encode(out)
}