feat: console help, examples and named loggers (SummerCMS v0.4.0)

Every command gets long help and examples, descriptions in imperative
sentence case, and a warn-only TestCommandsDocumented over bonfire.CheckDocs.
The plugin logs through a diary component logger instead of the process
default logger. Requires SummerCMS v0.4.0; command names and flags unchanged.
This commit is contained in:
Jakub Zych
2026-10-21 17:39:11 +02:00
parent f7eddd5572
commit 86564746de
9 changed files with 169 additions and 6 deletions

View File

@@ -72,6 +72,21 @@ func ImportWinter(app *backpack.App) bonfire.Command {
return bonfire.Command{
Name: "menu:import-winter",
Description: "Copy a WinterCMS menu and menu entry export into this application",
Long: `Copies the menus and menu entries of a WinterCMS site (the JSON lines that
scripts/winter-export-menus.sql and scripts/winter-export-entries.sql print),
keeping ids, nesting and order, and moves both id sequences past the copied
ids. Entry types are mapped (link to url, blog_categories to
all-journal-categories); --map old=new renames more types, and an empty new
name drops a type. Page entries, entries of an unknown type and entries
whose reference no longer exists are dropped with their subtree; the rules
of an admin save are applied to the copies (URLs, link targets, parents in
another menu). Every dropped, remapped or corrected entry is reported.
Run it once when an application moves from WinterCMS, --dry-run first:
--dry-run reports what would be kept, remapped and dropped and writes
nothing. Tables that already hold rows are refused unless --force is given,
which replaces them in the same transaction. It ends with "Copied N menus,
N entries kept, N remapped, N dropped."`,
Flags: []bonfire.Flag{
{Name: "menus", Description: "Menus export (JSON lines from scripts/winter-export-menus.sql)"},
{Name: "entries", Description: "Menu entries export (JSON lines from scripts/winter-export-entries.sql)"},
@@ -79,6 +94,11 @@ func ImportWinter(app *backpack.App) bonfire.Command {
{Name: "force", Description: "Replace the menus and entries the tables already hold", Bare: true},
{Name: "dry-run", Description: "Report what would be copied without writing", Bare: true},
},
Examples: []bonfire.Example{
{Command: "menu:import-winter --menus menus.jsonl --entries entries.jsonl --dry-run", Description: "Show what would be kept, remapped and dropped, without writing"},
{Command: "menu:import-winter --menus menus.jsonl --entries entries.jsonl --map blog_categories=", Description: "Copy the menus but drop the blog category entries"},
{Command: "menu:import-winter --menus menus.jsonl --entries entries.jsonl --force", Description: "Replace the menus and entries the tables already hold"},
},
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
maps, err := parseMaps(in.Flags("map"))
if err != nil {