Skip to content

Commit

Permalink
feat: moves config to $HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
awalias authored and soedirgo committed Mar 31, 2022
1 parent 91eead1 commit 6ca3529
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
6 changes: 1 addition & 5 deletions internal/functions/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ func Run(slug string, projectRefArg string) error {
var newFunctionBody string
{
fmt.Println("Bundling " + utils.Bold("supabase/functions/"+slug))

denoPath, err := xdg.ConfigFile("supabase/deno")
if err != nil {
return err
}
denoPath := xdg.Home + "/.supabase/deno"

cmd := exec.Command(denoPath, "bundle", "--quiet", "supabase/functions/"+slug+"/index.ts")
var outBuf, errBuf bytes.Buffer
Expand Down
4 changes: 2 additions & 2 deletions internal/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ Enter your access token: `)

// 2. Save access token
{
accessTokenPath, err := xdg.ConfigFile("supabase/access-token")
if err != nil {
if err := utils.MkdirIfNotExist(xdg.Home + "/.supabase"); err != nil {
return err
}
accessTokenPath := xdg.Home + "/.supabase/access-token"

if err := os.WriteFile(accessTokenPath, []byte(accessToken), 0600); err != nil {
return err
Expand Down
10 changes: 4 additions & 6 deletions internal/utils/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"github.com/adrg/xdg"
"github.com/supabase/cli/internal/utils"
)

// Update initial schemas in internal/utils/templates/initial_schemas when
Expand Down Expand Up @@ -178,10 +179,10 @@ func AssertIsLinked() error {
}

func InstallOrUpgradeDeno() error {
denoPath, err := xdg.ConfigFile("supabase/deno")
if err != nil {
if err := utils.MkdirIfNotExist(xdg.Home + "/.supabase"); err != nil {
return err
}
denoPath := xdg.Home + "/.supabase/deno"

if _, err := os.Stat(denoPath); err == nil {
// Upgrade Deno.
Expand Down Expand Up @@ -269,10 +270,7 @@ func LoadAccessToken() (string, error) {
return accessToken, nil
}

accessTokenPath, err := xdg.ConfigFile("supabase/access-token")
if err != nil {
return "", err
}
accessTokenPath := xdg.Home + "/.supabase/access-token"
accessToken, err := os.ReadFile(accessTokenPath)
if errors.Is(err, os.ErrNotExist) || string(accessToken) == "" {
return "", errors.New("Access token not provided. Supply an access token by running " + Aqua("supabase login") + " or setting the SUPABASE_ACCESS_TOKEN environment variable.")
Expand Down

0 comments on commit 6ca3529

Please sign in to comment.