Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .golangci.bck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
linters:
enable-all: true
disable:
- varnamelen
- gomoddirectives
- nlreturn
- wsl
- depguard
- tenv # deprecated

issues:
exclude-rules:
- path: _test\.go
linters:
- funlen
- ireturn

- linters:
- lll
source: "^//go:generate "

- linters:
- gochecknoglobals
text: "Version is a global variable"
67 changes: 43 additions & 24 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
---
version: "2"
linters:
enable-all: true
disable:
- varnamelen
- gomoddirectives
- nlreturn
- wsl
- depguard
- tenv # deprecated

issues:
exclude-rules:
- path: _test\.go
linters:
- funlen
- ireturn

- linters:
- lll
source: "^//go:generate "

- linters:
- gochecknoglobals
text: "Version is a global variable"
default: all
disable:
- depguard
- gomoddirectives
- nlreturn
- varnamelen
- wsl
- noinlineerr
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- funlen
- ireturn
path: _test\.go
- linters:
- lll
source: '^//go:generate '
- linters:
- gochecknoglobals
text: Version is a global variable
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 4 additions & 0 deletions clienv/clienv.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func FromCLI(cCtx *cli.Context) *CliEnv {
if err != nil {
panic(err)
}

return &CliEnv{
stdout: cCtx.App.Writer,
stderr: cCtx.App.ErrWriter,
Expand Down Expand Up @@ -105,18 +106,21 @@ func (ce *CliEnv) GetNhostClient(ctx context.Context) (*nhostclient.Client, erro
if err != nil {
return nil, fmt.Errorf("failed to load session: %w", err)
}

ce.nhclient = nhostclient.New(
ce.authURL,
ce.graphqlURL,
graphql.WithAccessToken(session.Session.AccessToken),
)
}

return ce.nhclient, nil
}

func (ce *CliEnv) GetNhostPublicClient() (*nhostclient.Client, error) {
if ce.nhpublicclient == nil {
ce.nhpublicclient = nhostclient.New(ce.authURL, ce.graphqlURL)
}

return ce.nhpublicclient, nil
}
8 changes: 6 additions & 2 deletions clienv/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ func (ce *CliEnv) PromptMessage(msg string, a ...any) {

func (ce *CliEnv) PromptInput(hide bool) (string, error) {
reader := bufio.NewReader(os.Stdin)
var response string
var err error

var (
response string
err error
)

if !hide {
response, err = reader.ReadString('\n')
Expand All @@ -80,6 +83,7 @@ func (ce *CliEnv) PromptInput(hide bool) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to read input: %w", err)
}

response = string(output)
}

Expand Down
2 changes: 2 additions & 0 deletions clienv/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ func Table(columns ...Column) string {
strs := make([]string, len(columns))
for i, col := range columns {
c := make([]string, len(col.Rows)+1)

c[0] = listHeader(col.Header)
for i, row := range col.Rows {
c[i+1] = listItem(row)
}

strs[i] = list.Render(
lipgloss.JoinVertical(
lipgloss.Left,
Expand Down
4 changes: 3 additions & 1 deletion clienv/wf_app_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func getRemoteAppInfo(
if err != nil {
return nil, fmt.Errorf("failed to get nhost client: %w", err)
}

resp, err := cl.GetOrganizationsAndWorkspacesApps(
ctx,
)
Expand All @@ -42,7 +43,7 @@ func getRemoteAppInfo(
}
}

return nil, fmt.Errorf("failed to find app with subdomain: %s", subdomain) //nolint:goerr113
return nil, fmt.Errorf("failed to find app with subdomain: %s", subdomain) //nolint:err113
}

func (ce *CliEnv) GetAppInfo(
Expand All @@ -63,6 +64,7 @@ func (ce *CliEnv) GetAppInfo(
} else {
ce.Warnln("Failed to find linked project: %v", err)
ce.Infoln("Please run `nhost link` to link a project first")

return nil, err
}
}
Expand Down
18 changes: 14 additions & 4 deletions clienv/wf_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

func Printlist(ce *CliEnv, orgs *graphql.GetOrganizationsAndWorkspacesApps) error {
if len(orgs.GetWorkspaces())+len(orgs.GetOrganizations()) == 0 {
return errors.New("no apps found") //nolint:goerr113
return errors.New("no apps found") //nolint:err113
}

num := Column{
Expand Down Expand Up @@ -65,13 +65,14 @@ func Printlist(ce *CliEnv, orgs *graphql.GetOrganizationsAndWorkspacesApps) erro

func confirmApp(ce *CliEnv, app *graphql.AppSummaryFragment) error {
ce.PromptMessage("Enter project subdomain to confirm: ")

confirm, err := ce.PromptInput(false)
if err != nil {
return fmt.Errorf("failed to read input: %w", err)
}

if confirm != app.Subdomain {
return errors.New("input doesn't match the subdomain") //nolint:goerr113
return errors.New("input doesn't match the subdomain") //nolint:err113
}

return nil
Expand All @@ -82,15 +83,20 @@ func getApp(
idx string,
) (*graphql.AppSummaryFragment, error) {
x := 1

var app *graphql.AppSummaryFragment

OUTER:

for _, orgs := range orgs.GetOrganizations() {
for _, a := range orgs.GetApps() {
if strconv.Itoa(x) == idx {
a := a
app = a

break OUTER
}

x++
}
}
Expand All @@ -105,14 +111,16 @@ OUTER2:
if strconv.Itoa(x) == idx {
a := a
app = a

break OUTER2
}

x++
}
}

if app == nil {
return nil, errors.New("invalid input") //nolint:goerr113
return nil, errors.New("invalid input") //nolint:err113
}

return app, nil
Expand All @@ -123,20 +131,22 @@ func (ce *CliEnv) Link(ctx context.Context) (*graphql.AppSummaryFragment, error)
if err != nil {
return nil, fmt.Errorf("failed to get nhost client: %w", err)
}

orgs, err := cl.GetOrganizationsAndWorkspacesApps(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get workspaces: %w", err)
}

if len(orgs.GetWorkspaces())+len(orgs.GetOrganizations()) == 0 {
return nil, errors.New("no apps found") //nolint:goerr113
return nil, errors.New("no apps found") //nolint:err113
}

if err := Printlist(ce, orgs); err != nil {
return nil, err
}

ce.PromptMessage("Select the workspace # to link: ")

idx, err := ce.PromptInput(false)
if err != nil {
return nil, fmt.Errorf("failed to read workspace: %w", err)
Expand Down
Loading
Loading