github.com/hhsnopek/up@v0.1.1/internal/cli/deploy/deploy.go (about) 1 package deploy 2 3 import ( 4 "time" 5 6 "github.com/tj/kingpin" 7 8 "github.com/apex/up/internal/cli/root" 9 "github.com/apex/up/internal/stats" 10 "github.com/apex/up/internal/util" 11 ) 12 13 func init() { 14 cmd := root.Command("deploy", "Deploy the project.").Default() 15 stage := cmd.Arg("stage", "Target stage name.").Default("development").String() 16 cmd.Example(`up deploy`, "Deploy the project to the development stage.") 17 cmd.Example(`up deploy production`, "Deploy the project to the production stage.") 18 19 cmd.Action(func(_ *kingpin.ParseContext) error { 20 start := time.Now() 21 defer util.Pad()() 22 23 c := root.Config 24 25 stats.Track("Deploy", map[string]interface{}{ 26 "duration": time.Since(start) / time.Millisecond, 27 "type": c.Type, 28 "regions": c.Regions, 29 "stage": *stage, 30 "header_rules_count": len(c.Headers), 31 "redirect_rules_count": len(c.Redirects), 32 "inject_rules_count": len(c.Inject), 33 "has_cors": c.CORS != nil, 34 "has_logs": !c.Logs.Disable, 35 }) 36 37 go stats.Client.Flush() 38 39 if err := root.Project.Deploy(*stage); err != nil { 40 return err 41 } 42 43 return nil 44 }) 45 }