From 4b5a2656df13181b637c59c29ff31751e11cf22a Mon Sep 17 00:00:00 2001 From: Clawd Date: Sun, 15 Feb 2026 17:44:46 -0800 Subject: fix: use project directory for static site .ship/ folder Previously, deployStatic() checked for .ship/Caddyfile in the current working directory instead of the project directory (opts.Dir). This caused stale Caddyfiles from previous deployments to be reused when deploying multiple static sites from the same working directory. Now .ship/ is created inside the project directory, so each site maintains its own configuration. --- cmd/ship/deploy.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/ship/deploy.go b/cmd/ship/deploy.go index 90dc846..414ade5 100644 --- a/cmd/ship/deploy.go +++ b/cmd/ship/deploy.go @@ -586,9 +586,12 @@ func deployStatic(st *state.State, opts DeployOptions) error { // Create local .ship directory and Caddyfile for static sites if it doesn't exist // (handles both initial deployment and migration of existing deployments) - if _, err := os.Stat(".ship/Caddyfile"); os.IsNotExist(err) { + shipDir := filepath.Join(opts.Dir, ".ship") + caddyfilePath := filepath.Join(shipDir, "Caddyfile") + + if _, err := os.Stat(caddyfilePath); os.IsNotExist(err) { fmt.Println("-> Creating local .ship directory...") - if err := os.MkdirAll(".ship", 0755); err != nil { + if err := os.MkdirAll(shipDir, 0755); err != nil { return fmt.Errorf("error creating .ship directory: %w", err) } @@ -600,14 +603,14 @@ func deployStatic(st *state.State, opts DeployOptions) error { if err != nil { return fmt.Errorf("error generating Caddy config: %w", err) } - if err := os.WriteFile(".ship/Caddyfile", []byte(caddyContent), 0644); err != nil { + if err := os.WriteFile(caddyfilePath, []byte(caddyContent), 0644); err != nil { return fmt.Errorf("error writing .ship/Caddyfile: %w", err) } } // Upload Caddyfile from .ship/Caddyfile fmt.Println("-> Installing Caddy config...") - caddyContent, err := os.ReadFile(".ship/Caddyfile") + caddyContent, err := os.ReadFile(caddyfilePath) if err != nil { return fmt.Errorf("error reading .ship/Caddyfile: %w", err) } -- cgit v1.2.3