Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit ae3130d

Browse files
committed
updating CLI to use v1.4.0-rc2 of the core
1 parent 93ad6dc commit ae3130d

File tree

4 files changed

+146
-89
lines changed

4 files changed

+146
-89
lines changed

cmd/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"fmt"
55
"os"
6+
"path"
67

78
"github.com/gookit/color"
89
"github.com/spf13/cobra"
@@ -95,15 +96,22 @@ func initConfig() {
9596
// Use config file from the flag.
9697
viper.SetConfigFile(cfgFile)
9798
} else {
98-
// Find home directory.
99+
// add current working directory
99100
pwd, err := os.Getwd()
100101
if err != nil {
101102
fmt.Println(err)
102103
os.Exit(1)
103104
}
104105

106+
confDir, err := os.UserConfigDir()
107+
if err != nil {
108+
fmt.Println(err)
109+
os.Exit(1)
110+
}
111+
105112
// Search config in home directory with name ".cli" (without extension).
106113
viper.AddConfigPath(pwd)
114+
viper.AddConfigPath(path.Join(confDir, "backend"))
107115
viper.SetConfigName(".backend")
108116
}
109117

cmd/server.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package cmd
33
import (
44
"fmt"
55
"net/http"
6-
"os"
76
"time"
87

98
staticbackend "github.com/staticbackendhq/core"
9+
sbconfig "github.com/staticbackendhq/core/config"
1010

1111
"github.com/gookit/color"
1212
"github.com/spf13/cobra"
@@ -24,20 +24,6 @@ var (
2424
verbose bool
2525
)
2626

27-
func init() {
28-
// initialize minimum env variables
29-
//TODO: find another way to provide config to server
30-
os.Setenv("SB_FROM_CLI", "yes")
31-
os.Setenv("APP_ENV", "dev")
32-
os.Setenv("DATA_STORE", "mem")
33-
os.Setenv("JWT_SECRET", "fromcli")
34-
os.Setenv("MAIL_PROVIDER", "dev")
35-
os.Setenv("STORAGE_PROVIDER", "local")
36-
os.Setenv("FROM_EMAIL", "[email protected]")
37-
os.Setenv("FROM_NAME", "from cli")
38-
os.Setenv("LOCAL_STORAGE_URL", "http://localhost:8099")
39-
}
40-
4127
// serverCmd represents the server command
4228
var serverCmd = &cobra.Command{
4329
Use: "server",
@@ -71,7 +57,15 @@ There are some limitations that you can learn more about here.
7157
)
7258
go createCustomer(uri, f.Value.String())
7359

74-
staticbackend.Start("mem", f.Value.String())
60+
c := sbconfig.AppConfig{
61+
FromCLI: "yes",
62+
Port: f.Value.String(),
63+
DatabaseURL: "mem",
64+
DataStore: "mem",
65+
LocalStorageURL: "http://localhost:8099",
66+
}
67+
68+
staticbackend.Start(c)
7569
},
7670
}
7771

go.mod

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/staticbackendhq/cli
22

3-
go 1.13
3+
go 1.18
44

55
require (
66
github.com/google/uuid v1.3.0
@@ -9,10 +9,70 @@ require (
99
github.com/spf13/cobra v1.1.1
1010
github.com/spf13/viper v1.7.0
1111
github.com/staticbackendhq/backend-go v0.0.0-20201215215817-6e321a842def
12-
github.com/staticbackendhq/core v1.2.1
13-
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
12+
github.com/staticbackendhq/core v1.4.0-rc2
13+
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
1414
)
1515

16-
replace github.com/staticbackendhq/backend-go => ../backend-go
16+
require (
17+
cloud.google.com/go v0.75.0 // indirect
18+
github.com/aws/aws-sdk-go v1.27.2 // indirect
19+
github.com/cespare/xxhash/v2 v2.1.1 // indirect
20+
github.com/chromedp/cdproto v0.0.0-20211126220118-81fa0469ad77 // indirect
21+
github.com/chromedp/chromedp v0.7.6 // indirect
22+
github.com/chromedp/sysutil v1.0.0 // indirect
23+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
24+
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
25+
github.com/dop251/goja v0.0.0-20210804101310-32956a348b49 // indirect
26+
github.com/fsnotify/fsnotify v1.4.9 // indirect
27+
github.com/gbrlsnchs/jwt/v3 v3.0.0-rc.1 // indirect
28+
github.com/go-co-op/gocron v1.6.2 // indirect
29+
github.com/go-redis/redis/v8 v8.4.4 // indirect
30+
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
31+
github.com/gobwas/httphead v0.1.0 // indirect
32+
github.com/gobwas/pool v0.2.1 // indirect
33+
github.com/gobwas/ws v1.1.0 // indirect
34+
github.com/golang/protobuf v1.4.3 // indirect
35+
github.com/golang/snappy v0.0.4 // indirect
36+
github.com/hashicorp/hcl v1.0.0 // indirect
37+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
38+
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
39+
github.com/josharian/intern v1.0.0 // indirect
40+
github.com/klauspost/compress v1.13.6 // indirect
41+
github.com/lib/pq v1.10.4 // indirect
42+
github.com/magefile/mage v1.9.0 // indirect
43+
github.com/magiconair/properties v1.8.1 // indirect
44+
github.com/mailru/easyjson v0.7.7 // indirect
45+
github.com/markbates/goth v1.73.0 // indirect
46+
github.com/mitchellh/mapstructure v1.1.2 // indirect
47+
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
48+
github.com/mrjones/oauth v0.0.0-20180629183705-f4e24b6d100c // indirect
49+
github.com/pelletier/go-toml v1.2.0 // indirect
50+
github.com/pkg/errors v0.9.1 // indirect
51+
github.com/robfig/cron/v3 v3.0.1 // indirect
52+
github.com/spf13/afero v1.8.1 // indirect
53+
github.com/spf13/cast v1.3.0 // indirect
54+
github.com/spf13/jwalterweatherman v1.0.0 // indirect
55+
github.com/spf13/pflag v1.0.5 // indirect
56+
github.com/stripe/stripe-go/v72 v72.94.0 // indirect
57+
github.com/subosito/gotenv v1.2.0 // indirect
58+
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
59+
github.com/xdg-go/scram v1.1.1 // indirect
60+
github.com/xdg-go/stringprep v1.0.3 // indirect
61+
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
62+
go.mongodb.org/mongo-driver v1.10.0 // indirect
63+
go.opentelemetry.io/otel v0.15.0 // indirect
64+
golang.org/x/image v0.0.0-20190802002840-cff245a6509b // indirect
65+
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
66+
golang.org/x/oauth2 v0.0.0-20220628200809-02e64fa58f26 // indirect
67+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
68+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
69+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
70+
golang.org/x/text v0.3.7 // indirect
71+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
72+
google.golang.org/appengine v1.6.7 // indirect
73+
google.golang.org/protobuf v1.25.0 // indirect
74+
gopkg.in/ini.v1 v1.51.0 // indirect
75+
gopkg.in/yaml.v2 v2.4.0 // indirect
76+
)
1777

18-
replace github.com/staticbackendhq/core => ../core
78+
replace github.com/staticbackendhq/backend-go => ../backend-go

0 commit comments

Comments
 (0)