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

Commit 3985d22

Browse files
author
Mrinal Wahal
committed
tests: fixed vanilla pipeline test
1 parent 71f080b commit 3985d22

3 files changed

Lines changed: 37 additions & 83 deletions

File tree

cmd/link.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ var linkCmd = &cobra.Command{
139139
}
140140

141141
if contains(names, project.Name) {
142-
status.Errorln("App with that name already exists")
142+
status.Fatal("App with that name already exists")
143143
}
144144
}
145145

146146
// select the server location
147147
servers, err := nhost.Servers()
148148
if err != nil {
149149
log.Debug(err)
150-
log.Fatal("Failed to fetch list of servers")
150+
status.Fatal("Failed to fetch list of servers")
151151
}
152152

153153
// configure interactive prompt template
@@ -216,7 +216,7 @@ var linkCmd = &cobra.Command{
216216
project.ID, err = createProject(project.Name, selectedServer, User.ID, User.WorkspaceMembers[index].ID)
217217
if err != nil {
218218
log.Debug(err)
219-
log.Fatal("Failed to create a new app")
219+
status.Fatal("Failed to create a new app")
220220
}
221221

222222
}
@@ -227,10 +227,6 @@ var linkCmd = &cobra.Command{
227227
return
228228
}
229229

230-
// provide confirmation prompt
231-
log.Warn("If you linked to the wrong app, you could break your production environment.")
232-
status.Info("Therefore we need confirmation you are serious about this.")
233-
234230
// configure interative prompt
235231
confirmationPrompt := promptui.Prompt{
236232
Label: "Enter the app's name to confirm linking (case sensitive)",
@@ -242,14 +238,14 @@ var linkCmd = &cobra.Command{
242238
}
243239

244240
if strings.ToLower(response) != project.Name {
245-
log.Fatal("Invalid email. Linking aborted.")
241+
status.Fatal("Invalid email. Linking aborted.")
246242
}
247243
}
248244

249245
// update the project ID
250246
if err = updateNhostProject(project); err != nil {
251247
log.Debug(err)
252-
log.Fatal("Failed to update Nhost app configuration locally")
248+
status.Fatal("Failed to update Nhost app configuration locally")
253249
}
254250

255251
// project linking complete

cmd/root.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package cmd
2626

2727
import (
2828
"fmt"
29+
"os"
2930
"path/filepath"
3031
"strings"
3132

@@ -163,7 +164,9 @@ func init() {
163164
// when this action is called directly.
164165
rootCmd.PersistentFlags().StringVarP(&logger.LOG_FILE, "log-file", "f", "", "Write logs to given file")
165166
rootCmd.PersistentFlags().BoolVarP(&logger.DEBUG, "debug", "d", false, "Show debugging level logs")
166-
rootCmd.PersistentFlags().StringVar(&path, "path", "", "Current working directory to execute CLI in")
167+
168+
path, _ := os.Getwd()
169+
rootCmd.PersistentFlags().StringVar(&path, "path", path, "Current working directory to execute CLI in")
167170
}
168171

169172
/*

nhost/vars.go

Lines changed: 28 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ var (
1717
API string
1818

1919
// fetch current working directory
20-
NHOST_DIR string
21-
DOT_NHOST string
22-
DOT_NHOST_ROOT = filepath.Join(util.WORKING_DIR, ".nhost")
20+
NHOST_DIR string
21+
DOT_NHOST string
2322

2423
// initialize the names of all Nhost services in the stack
2524
SERVICES []string
@@ -73,7 +72,7 @@ var (
7372
GITIGNORE string
7473

7574
// path for .nhost/nhost.yaml file
76-
INFO_PATH = filepath.Join(DOT_NHOST_ROOT, "nhost.yaml")
75+
INFO_PATH string
7776

7877
// path for express NPM modules
7978
NODE_MODULES_PATH string
@@ -91,118 +90,74 @@ var (
9190
// Initialize Nhost variables for runtime
9291
func Init() {
9392

94-
if DOMAIN == "" {
95-
DOMAIN = "nhost.run"
96-
}
93+
DOMAIN = "nhost.run"
9794

98-
if API == "" {
99-
API = fmt.Sprintf("https://%s/v1/functions", DOMAIN)
100-
}
95+
API = fmt.Sprintf("https://%s/v1/functions", DOMAIN)
10196

10297
// fetch current working directory
103-
if NHOST_DIR == "" {
104-
NHOST_DIR = filepath.Join(util.WORKING_DIR, "nhost")
105-
}
98+
NHOST_DIR = filepath.Join(util.WORKING_DIR, "nhost")
10699

107-
if DOT_NHOST == "" {
108-
DOT_NHOST, _ = GetDotNhost()
109-
}
100+
INFO_PATH = filepath.Join(util.WORKING_DIR, ".nhost", "nhost.yaml")
101+
102+
DOT_NHOST, _ = GetDotNhost()
110103

111104
// initialize the names of all Nhost services in the stack
112-
if SERVICES == nil {
113-
SERVICES = []string{"hasura", "auth", "storage", "mailhog", "postgres", "minio"}
114-
}
105+
SERVICES = []string{"hasura", "auth", "storage", "mailhog", "postgres", "minio"}
115106

116107
// find user's home directory
117-
if HOME == "" {
118-
HOME, _ = os.UserHomeDir()
119-
}
108+
HOME, _ = os.UserHomeDir()
120109

121110
// Nhost root directory for HOME
122-
if ROOT == "" {
123-
ROOT = filepath.Join(HOME, ".nhost")
124-
}
111+
ROOT = filepath.Join(HOME, ".nhost")
125112

126113
// authentication file location
127-
if AUTH_PATH == "" {
128-
AUTH_PATH = filepath.Join(ROOT, "auth.json")
129-
}
114+
AUTH_PATH = filepath.Join(ROOT, "auth.json")
130115

131116
// path for migrations
132-
if MIGRATIONS_DIR == "" {
133-
MIGRATIONS_DIR = filepath.Join(NHOST_DIR, "migrations")
134-
}
117+
MIGRATIONS_DIR = filepath.Join(NHOST_DIR, "migrations")
135118

136119
// path for metadata
137-
if METADATA_DIR == "" {
138-
METADATA_DIR = filepath.Join(NHOST_DIR, "metadata")
139-
}
120+
METADATA_DIR = filepath.Join(NHOST_DIR, "metadata")
140121

141122
// default Nhost database
142-
if DATABASE == "" {
143-
DATABASE = "default"
144-
}
123+
DATABASE = "default"
145124

146125
// path for seeds
147-
if SEEDS_DIR == "" {
148-
SEEDS_DIR = filepath.Join(NHOST_DIR, "seeds")
149-
}
126+
SEEDS_DIR = filepath.Join(NHOST_DIR, "seeds")
150127

151128
// path for frontend
152-
if WEB_DIR == "" {
153-
WEB_DIR = filepath.Join(util.WORKING_DIR, "web")
154-
}
129+
WEB_DIR = filepath.Join(util.WORKING_DIR, "web")
155130

156131
// path for API code
157-
if API_DIR == "" {
158-
API_DIR = filepath.Join(util.WORKING_DIR, "functions")
159-
}
132+
API_DIR = filepath.Join(util.WORKING_DIR, "functions")
160133

161134
// path for email templates
162-
if EMAILS_DIR == "" {
163-
EMAILS_DIR = filepath.Join(NHOST_DIR, "emails")
164-
}
135+
EMAILS_DIR = filepath.Join(NHOST_DIR, "emails")
165136

166137
// path for legacy migrations
167-
if LEGACY_DIR == "" {
168-
LEGACY_DIR = filepath.Join(DOT_NHOST, "legacy")
169-
}
138+
LEGACY_DIR = filepath.Join(DOT_NHOST, "legacy")
170139

171140
// path for local git directory
172-
if GIT_DIR == "" {
173-
GIT_DIR = filepath.Join(util.WORKING_DIR, ".git")
174-
}
141+
GIT_DIR = filepath.Join(util.WORKING_DIR, ".git")
175142

176143
// path for .env.development
177-
if ENV_FILE == "" {
178-
ENV_FILE = filepath.Join(util.WORKING_DIR, ".env.development")
179-
}
144+
ENV_FILE = filepath.Join(util.WORKING_DIR, ".env.development")
180145

181146
// path for .config.yaml file
182-
if CONFIG_PATH == "" {
183-
CONFIG_PATH = filepath.Join(NHOST_DIR, "config.yaml")
184-
}
147+
CONFIG_PATH = filepath.Join(NHOST_DIR, "config.yaml")
185148

186149
// path for .gitignore file
187-
if GITIGNORE == "" {
188-
GITIGNORE = filepath.Join(util.WORKING_DIR, ".gitignore")
189-
}
150+
GITIGNORE = filepath.Join(util.WORKING_DIR, ".gitignore")
190151

191152
// path for express NPM modules
192-
if NODE_MODULES_PATH == "" {
193-
NODE_MODULES_PATH = filepath.Join(ROOT, "node_modules")
194-
}
153+
NODE_MODULES_PATH = filepath.Join(ROOT, "node_modules")
195154

196155
// package repository to download latest release from
197-
if REPOSITORY == "" {
198-
REPOSITORY = "nhost/cli"
199-
}
156+
REPOSITORY = "nhost/cli"
200157

201158
// initialize the project prefix
202159
// PREFIX = filepath.Base(util.WORKING_DIR)
203-
if PREFIX == "" {
204-
PREFIX = "nhost"
205-
}
160+
PREFIX = "nhost"
206161

207162
// mandatorily required locations
208163
LOCATIONS = Required{

0 commit comments

Comments
 (0)