Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Nov 20, 2023
1 parent f7bde97 commit 1c226b6
Show file tree
Hide file tree
Showing 10 changed files with 5,541 additions and 209 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.sst
dist
node_modules
61 changes: 54 additions & 7 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"os"
"time"

"github.com/briandowns/spinner"
"github.com/fatih/color"
"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
"github.com/sst/ion/pkg/global"
"github.com/sst/ion/pkg/project"

cli "github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -41,7 +43,7 @@ func main() {
return err
}
}
fmt.Println(color.CyanString("SST ❍ ION "), color.HiBlackString("ready!"))
fmt.Println(color.CyanString("SST ❍ Ion "), color.HiBlackString("ready!"))
return nil
},
Commands: []*cli.Command{
Expand All @@ -54,45 +56,74 @@ func main() {
if err != nil {
return err
}
fmt.Println("Deploying")
printHeader(p)

s := spinner.New(spinner.CharSets[14], 100*time.Millisecond)
s.Suffix = " Deploying..."
s.Start()
events, err := p.Stack.Deploy()
if err != nil {
return err
}

timing := make(map[string]time.Time)
outputs := make(map[string]interface{})
for evt := range events {
s.Disable()
if evt.ResourcePreEvent != nil {
if evt.ResourcePreEvent.Metadata.Type == "pulumi:pulumi:Stack" {
continue
}
if evt.ResourcePreEvent.Metadata.Op == apitype.OpSame {
fmt.Println("Not updating", evt.ResourcePreEvent.Metadata.Old.URN)
color.New(color.FgHiBlack).Print("| ")
color.New(color.FgHiBlack).Println("Skipping ", evt.ResourcePreEvent.Metadata.URN)
continue
}

timing[evt.ResourcePreEvent.Metadata.URN] = time.Now()
if evt.ResourcePreEvent.Metadata.Op == apitype.OpCreate {
fmt.Println("Creating", evt.ResourcePreEvent.Metadata.URN)
color.New(color.FgYellow).Print("| ")
color.New(color.FgHiBlack).Println("Creating ", evt.ResourcePreEvent.Metadata.URN)
continue
}

if evt.ResourcePreEvent.Metadata.Op == apitype.OpUpdate {
fmt.Println("Updating", evt.ResourcePreEvent.Metadata.URN)
color.New(color.FgYellow).Print("| ")
color.New(color.FgHiBlack).Println("Updating ", evt.ResourcePreEvent.Metadata.URN)
continue
}
}

if evt.ResOutputsEvent != nil {
if evt.ResOutputsEvent.Metadata.Type == "pulumi:pulumi:Stack" {
outputs = evt.ResOutputsEvent.Metadata.New.Outputs
continue
}
if evt.ResOutputsEvent.Metadata.Op == apitype.OpSame {
continue
}
duration := time.Since(timing[evt.ResOutputsEvent.Metadata.URN]).Milliseconds()
if evt.ResOutputsEvent.Metadata.Op == apitype.OpCreate {
fmt.Println("Created", evt.ResOutputsEvent.Metadata.URN, "in", duration, "ms")
color.New(color.FgGreen).Print("| ")
color.New(color.FgHiBlack).Println("Created ", evt.ResOutputsEvent.Metadata.URN, " in ", duration, "ms")
}
if evt.ResOutputsEvent.Metadata.Op == apitype.OpUpdate {
fmt.Println("Updated", evt.ResOutputsEvent.Metadata.URN, "in", duration, "ms")
color.New(color.Bold, color.FgGreen).Print("| ")
color.New(color.FgHiBlack).Println("Updated ", evt.ResOutputsEvent.Metadata.URN, " in ", duration, "ms")
}
}
s.Enable()
}
s.Stop()
color.New(color.FgGreen, color.Bold).Print("\n✔")
color.New(color.FgWhite, color.Bold).Println(" Deployed:")
for k, v := range outputs {
color.New(color.FgHiBlack).Print(" ")
color.New(color.FgWhite, color.Bold).Print(k)
color.New(color.FgHiBlack).Print(" = ")
color.New(color.FgWhite).Println(v)
}

return nil
},
},
Expand Down Expand Up @@ -213,3 +244,19 @@ func initProject() (*project.Project, error) {

return p, nil
}

func printHeader(p *project.Project) {
fmt.Println()
color.New(color.FgCyan, color.Bold).Print("➜ ")

color.New(color.FgWhite, color.Bold).Print("App: ")
color.New(color.FgHiBlack).Println(p.Name())

color.New(color.FgWhite, color.Bold).Print(" Stage: ")
color.New(color.FgHiBlack).Println(p.Stage())

color.New(color.FgWhite, color.Bold).Print(" Region: ")
color.New(color.FgHiBlack).Println(p.Region())

fmt.Println()
}
6 changes: 6 additions & 0 deletions examples/test-old/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"dependencies": {
"aws-cdk-lib": "2.101.1",
"sst": "2.36.1"
}
}
Loading

0 comments on commit 1c226b6

Please sign in to comment.