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

Commit

Permalink
colors
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Nov 17, 2023
1 parent ea4896d commit 2abccd3
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 9 deletions.
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ aurs:
git_url: 'ssh://aur@aur.archlinux.org/sst-bin.git'
package: |-
install -Dm755 ./sst "${pkgdir}/usr/bin/sst"
pulumi plugin install resource aws
depends:
- pulumi
brews:
Expand Down
11 changes: 11 additions & 0 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"log/slog"
"os"

"github.com/fatih/color"
"github.com/sst/ion/pkg/global"
"github.com/sst/ion/pkg/project"
cli "github.com/urfave/cli/v2"
)
Expand All @@ -29,6 +31,15 @@ func main() {
Level: level,
})),
)

if global.NeedsPlugins() {
fmt.Println("new installation, installing dependencies...")
err := global.InstallPlugins()
if err != nil {
return err
}
}
fmt.Println(color.CyanString("SST ❍ ION "), color.HiBlackString("ready!"))
return nil
},
Commands: []*cli.Command{
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.42.2
github.com/aws/aws-sdk-go-v2/service/ssm v1.42.2
github.com/evanw/esbuild v0.19.5
github.com/fatih/color v1.16.0
github.com/google/uuid v1.4.0
github.com/urfave/cli/v2 v2.25.7
)
Expand All @@ -30,7 +31,9 @@ require (
github.com/aws/smithy-go v1.17.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/sys v0.14.0 // indirect
)
12 changes: 11 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/evanw/esbuild v0.19.5 h1:9ildZqajUJzDAwNf9MyQsLh2RdDRKTq3kcyyzhE39us=
github.com/evanw/esbuild v0.19.5/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
Expand All @@ -50,6 +52,11 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
Expand All @@ -59,8 +66,11 @@ github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
41 changes: 41 additions & 0 deletions pkg/global/global.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package global

import (
"log/slog"
"os"
"os/exec"
"path/filepath"
)

var configDir = (func() string {
home, err := os.UserConfigDir()
if err != nil {
panic(err)
}
return filepath.Join(home, "sst")
}())

func ConfigDir() string {
return configDir
}

func NeedsPlugins() bool {
files, err := os.ReadDir(filepath.Join(configDir, "plugins"))
if err != nil {
return true
}
slog.Info("plugins", "files", files)

if len(files) == 0 {
return true
}

return false
}

func InstallPlugins() error {
slog.Info("installing plugins")
cmd := exec.Command("pulumi", "plugin", "install", "resource", "aws")
cmd.Env = append(os.Environ(), "PULUMI_HOME="+configDir)
return cmd.Run()
}
9 changes: 3 additions & 6 deletions pkg/project/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"

"github.com/sst/ion/pkg/global"
"github.com/sst/ion/pkg/js"
)

Expand All @@ -21,14 +22,9 @@ func (s *stack) Login() error {
if err != nil {
return err
}
home, err := os.UserHomeDir()
if err != nil {
return err
}

credentialsPath := filepath.Join(
home,
".pulumi",
global.ConfigDir(),
"credentials.json",
)
data, err := os.ReadFile(credentialsPath)
Expand Down Expand Up @@ -97,6 +93,7 @@ func (s *stack) env() ([]string, error) {
return nil, err
}
return []string{
"PULUMI_HOME=" + global.ConfigDir(),
"PULUMI_CONFIG_PASSPHRASE=",
"AWS_ACCESS_KEY_ID=" + credentials.AccessKeyID,
"AWS_SECRET_ACCESS_KEY=" + credentials.SecretAccessKey,
Expand Down

0 comments on commit 2abccd3

Please sign in to comment.