* feat(setup): add github command for repo configuration (#45) Implements `core setup github` to configure GitHub repos with org standards including labels, webhooks, branch protection, and security settings. Supports dry-run mode, per-repo or all-repos operation, and selective sync of specific settings. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(setup): address CodeRabbit feedback on github command - Sort map keys for deterministic diff output in github_diff.go - Preserve partial results by adding changes before continue on errors - Reject conflicting --repo and --all flags with clear error message - Allow empty webhook URLs (skip instead of error) for optional env vars - Add content_type comparison in webhook sync - Add required_status_checks comparison in branch protection sync - Add DisableDependabotSecurityUpdates for bidirectional security control Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(setup): address additional CodeRabbit feedback - Use filepath.Join for OS-portable path construction in github_config.go - Fix stringSliceEqual to use frequency counting for proper duplicate handling - Simplify change accumulation with variadic append Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
81 lines
1.7 KiB
Go
81 lines
1.7 KiB
Go
package workspace
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/host-uk/core/pkg/cli"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func AddWorkspaceCommands(root *cobra.Command) {
|
|
wsCmd := &cobra.Command{
|
|
Use: "workspace",
|
|
Short: "Manage workspace configuration",
|
|
RunE: runWorkspaceInfo,
|
|
}
|
|
|
|
wsCmd.AddCommand(&cobra.Command{
|
|
Use: "active [package]",
|
|
Short: "Show or set the active package",
|
|
RunE: runWorkspaceActive,
|
|
})
|
|
|
|
root.AddCommand(wsCmd)
|
|
}
|
|
|
|
func runWorkspaceInfo(cmd *cobra.Command, args []string) error {
|
|
root, err := FindWorkspaceRoot()
|
|
if err != nil {
|
|
return cli.Err("not in a workspace")
|
|
}
|
|
|
|
config, err := LoadConfig(root)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
cli.Print("Active: %s\n", cli.ValueStyle.Render(config.Active))
|
|
cli.Print("Packages: %s\n", cli.DimStyle.Render(config.PackagesDir))
|
|
if len(config.DefaultOnly) > 0 {
|
|
cli.Print("Types: %s\n", cli.DimStyle.Render(strings.Join(config.DefaultOnly, ", ")))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func runWorkspaceActive(cmd *cobra.Command, args []string) error {
|
|
root, err := FindWorkspaceRoot()
|
|
if err != nil {
|
|
return cli.Err("not in a workspace")
|
|
}
|
|
|
|
config, err := LoadConfig(root)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// If no args, show active
|
|
if len(args) == 0 {
|
|
if config.Active == "" {
|
|
cli.Println("No active package set")
|
|
return nil
|
|
}
|
|
cli.Println(config.Active)
|
|
return nil
|
|
}
|
|
|
|
// Set active
|
|
target := args[0]
|
|
if target == config.Active {
|
|
cli.Print("Active package is already %s\n", cli.ValueStyle.Render(target))
|
|
return nil
|
|
}
|
|
|
|
config.Active = target
|
|
if err := SaveConfig(root, config); err != nil {
|
|
return err
|
|
}
|
|
|
|
cli.Print("Active package set to %s\n", cli.SuccessStyle.Render(target))
|
|
return nil
|
|
}
|