Skip to content

Commit

Permalink
Align terms with registry
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Dec 6, 2024
1 parent dfe1539 commit dd7a9f0
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,33 @@ func (c *versionCmd) run(cmd *cobra.Command, _ []string) error {

details := consts.VersionDetails()
if exts := ext.GetAll(); len(exts) > 0 {
ext := make([]map[string]string, 0, len(exts))
type extInfo struct {
Module string `json:"module"`
Version string `json:"version"`
Imports []string `json:"imports"`
}

ext := make(map[string]extInfo)
for _, e := range exts {
ext = append(ext, map[string]string{
"name": e.Name,
"type": e.Type.String(),
"version": e.Version,
"path": e.Path,
})
if v, ok := ext[e.Path]; ok {
v.Imports = append(v.Imports, e.Name)
ext[e.Path] = v
continue
}

ext[e.Path] = extInfo{
Module: e.Path,
Version: e.Version,
Imports: []string{e.Name},
}
}

list := make([]extInfo, 0, len(ext))
for _, v := range ext {
list = append(list, v)
}

details["extensions"] = ext
details["extensions"] = list
}

jsonDetails, err := json.Marshal(details)
Expand Down

0 comments on commit dd7a9f0

Please sign in to comment.