refactor(ninja): thread tags through upsertPluginMod
Extend upsertPluginMod signature to accept tags parameter (positional arg 7, between categories and private). Update the single call site to pass nil. Add tags serialization in writeMod, mirroring the categories pattern. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
d53c3d8325
commit
6bc0f98979
@ -385,7 +385,7 @@ func newPluginInitCmd() *cobra.Command {
|
|||||||
if private {
|
if private {
|
||||||
modScope = ""
|
modScope = ""
|
||||||
}
|
}
|
||||||
if err := upsertPluginMod(modScope, name, displayName, description, kind, cats, private); err != nil {
|
if err := upsertPluginMod(modScope, name, displayName, description, kind, cats, nil, private); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println("plugin.mod updated")
|
fmt.Println("plugin.mod updated")
|
||||||
@ -975,7 +975,7 @@ func submodulePaths(repoDir string) []string {
|
|||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
|
|
||||||
func upsertPluginMod(scope, name, displayName, description, kind string, categories []string, private bool) error {
|
func upsertPluginMod(scope, name, displayName, description, kind string, categories, tags []string, private bool) error {
|
||||||
const file = "plugin.mod"
|
const file = "plugin.mod"
|
||||||
existing, _ := os.ReadFile(file)
|
existing, _ := os.ReadFile(file)
|
||||||
mod, _ := core.ParseModFull(existing)
|
mod, _ := core.ParseModFull(existing)
|
||||||
@ -991,6 +991,7 @@ func upsertPluginMod(scope, name, displayName, description, kind string, categor
|
|||||||
mod.Plugin.Description = description
|
mod.Plugin.Description = description
|
||||||
mod.Plugin.Kind = kind
|
mod.Plugin.Kind = kind
|
||||||
mod.Plugin.Categories = categories
|
mod.Plugin.Categories = categories
|
||||||
|
mod.Plugin.Tags = tags
|
||||||
mod.Plugin.Private = private
|
mod.Plugin.Private = private
|
||||||
return writeMod(file, mod)
|
return writeMod(file, mod)
|
||||||
}
|
}
|
||||||
@ -1017,6 +1018,13 @@ func writeMod(path string, m *core.ModFile) error {
|
|||||||
}
|
}
|
||||||
b.WriteString(fmt.Sprintf("categories = [%s]\n", strings.Join(quoted, ", ")))
|
b.WriteString(fmt.Sprintf("categories = [%s]\n", strings.Join(quoted, ", ")))
|
||||||
}
|
}
|
||||||
|
if len(m.Plugin.Tags) > 0 {
|
||||||
|
quoted := make([]string, len(m.Plugin.Tags))
|
||||||
|
for i, t := range m.Plugin.Tags {
|
||||||
|
quoted[i] = fmt.Sprintf("%q", t)
|
||||||
|
}
|
||||||
|
b.WriteString(fmt.Sprintf("tags = [%s]\n", strings.Join(quoted, ", ")))
|
||||||
|
}
|
||||||
if m.Plugin.Private {
|
if m.Plugin.Private {
|
||||||
b.WriteString("private = true\n")
|
b.WriteString("private = true\n")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user