From 98b9af372025595e8a4255538e2836e019311474 Mon Sep 17 00:00:00 2001 From: bndw Date: Fri, 23 Jan 2026 20:54:46 -0800 Subject: Add deploy command and fix static site naming Static sites now default to using the domain as the name instead of the source directory basename, preventing conflicts when multiple sites use the same directory name (e.g., dist). Also fixes .gitignore to not exclude cmd/deploy/ directory. --- cmd/deploy/list.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 cmd/deploy/list.go (limited to 'cmd/deploy/list.go') diff --git a/cmd/deploy/list.go b/cmd/deploy/list.go new file mode 100644 index 0000000..b74cf35 --- /dev/null +++ b/cmd/deploy/list.go @@ -0,0 +1,58 @@ +package main + +import ( + "flag" + "fmt" + "os" + "text/tabwriter" + + "github.com/bdw/deploy/internal/config" + "github.com/bdw/deploy/internal/state" +) + +func runList(args []string) { + fs := flag.NewFlagSet("list", flag.ExitOnError) + host := fs.String("host", "", "VPS host (SSH config alias or user@host)") + fs.Parse(args) + + // Get host from flag or config + if *host == "" { + cfg, err := config.Load() + if err != nil { + fmt.Fprintf(os.Stderr, "Error loading config: %v\n", err) + os.Exit(1) + } + *host = cfg.Host + } + + if *host == "" { + fmt.Fprintf(os.Stderr, "Error: --host is required\n") + fs.Usage() + os.Exit(1) + } + + // Load state + st, err := state.Load() + if err != nil { + fmt.Fprintf(os.Stderr, "Error loading state: %v\n", err) + os.Exit(1) + } + + apps := st.ListApps(*host) + if len(apps) == 0 { + fmt.Printf("No deployments found for %s\n", *host) + return + } + + // Print table + w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0) + fmt.Fprintln(w, "NAME\tTYPE\tDOMAIN\tPORT") + for name, app := range apps { + port := "" + if app.Type == "app" { + port = fmt.Sprintf(":%d", app.Port) + } + fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", name, app.Type, app.Domain, port) + } + w.Flush() +} -- cgit v1.2.3