Skip to content

Commit e7982c1

Browse files
authored
UX improvements for the 'jf setup' & 'jf project init' commands (#274)
1 parent 04a3aac commit e7982c1

File tree

3 files changed

+60
-48
lines changed

3 files changed

+60
-48
lines changed

general/envsetup/envsetup.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
7+
"github.com/pkg/browser"
78
"net/http"
89
"net/url"
910
"strings"
@@ -18,8 +19,6 @@ import (
1819
ioUtils "github.com/jfrog/jfrog-client-go/utils/io"
1920
"github.com/jfrog/jfrog-client-go/utils/io/httputils"
2021
"github.com/jfrog/jfrog-client-go/utils/log"
21-
22-
"github.com/pkg/browser"
2322
)
2423

2524
const (
@@ -51,8 +50,10 @@ func NewEnvSetupCommand(url string) *EnvSetupCommand {
5150
}
5251

5352
func (ftc *EnvSetupCommand) Run() (err error) {
53+
fmt.Println("Thank you for installing JFrog CLI!")
54+
ftc.progress.SetHeadlineMsg("To complete your JFrog environment setup, please fill out the details in your browser")
55+
time.Sleep(5 * time.Second)
5456
browser.OpenURL(ftc.registrationURL + "?id=" + ftc.id.String())
55-
ftc.progress.SetHeadlineMsg("Thank you for installing JFrog CLI! To complete your JFrog environment setup, please fill out the details in your browser")
5657
server, err := ftc.getNewServerDetails()
5758
if err != nil {
5859
return
@@ -61,12 +62,16 @@ func (ftc *EnvSetupCommand) Run() (err error) {
6162
if err != nil {
6263
return err
6364
}
64-
fmt.Println("Your new JFrog environment is ready!")
65-
fmt.Println(" 1. CD into your code project directory")
66-
fmt.Println(" 2. Run \"jf project init\"")
67-
fmt.Println(" 3. Read more about how to get started at - ")
68-
fmt.Println("\t" + coreutils.GettingStartedGuideUrl)
69-
return nil
65+
message :=
66+
coreutils.PrintBold("Your new JFrog environment is ready!") +
67+
"\n" +
68+
"1. CD into your code project directory\n" +
69+
"2. Run \"jf project init\"\n" +
70+
"3. Read more about how to get started at -\n" +
71+
coreutils.PrintLink(coreutils.GettingStartedGuideUrl)
72+
73+
err = coreutils.PrintTable("", "", message)
74+
return
7075
}
7176

7277
func (ftc *EnvSetupCommand) CommandName() string {

general/project/projectinit.go

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"path/filepath"
77
"strings"
88

9-
"github.com/gookit/color"
109
artifactoryCommandsUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
1110
artifactoryUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
1211
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
@@ -71,20 +70,26 @@ func (pic *ProjectInitCommand) Run() (err error) {
7170
}
7271

7372
message :=
74-
bold("You're all set!") +
73+
coreutils.PrintBold("This project is initialized!\n") +
74+
coreutils.PrintBold("The project config is stored inside the .jfrog directory.") +
7575
"\n\n" +
76-
bold("The project config is stored inside the .jfrog directory.") +
77-
"\n\n" +
78-
title("Audit your code project for security vulnerabilities by running") +
76+
coreutils.PrintTitle("Audit your code project for security vulnerabilities by running") +
7977
"\n" +
8078
"jf audit\n\n" +
81-
title("Scan any software package on this machine for security vulnerabilities by running") +
79+
coreutils.PrintTitle("or if you're using VS Code, IntelliJ IDEA, WebStorm, PyCharm, Android Studio or GoLand") +
80+
"\n" +
81+
"Open the IDE\n" +
82+
"Install the JFrog extension or plugin\n" +
83+
"View the JFrog panel\n" +
84+
"\n" +
85+
coreutils.PrintTitle("Scan any software package on this machine for security vulnerabilities by running") +
8286
"\n" +
8387
"jf scan path/to/dir/or/package\n\n" +
88+
8489
pic.createBuildMessage(technologiesMap) +
85-
title("Read more using this link:") +
90+
coreutils.PrintTitle("Read more using this link:") +
8691
"\n" +
87-
link(coreutils.GettingStartedGuideUrl)
92+
coreutils.PrintLink(coreutils.GettingStartedGuideUrl)
8893
fmt.Println()
8994
err = coreutils.PrintTable("", "", message)
9095
fmt.Println()
@@ -111,51 +116,24 @@ func (pic *ProjectInitCommand) createBuildMessage(technologiesMap map[coreutils.
111116
case coreutils.Pypi:
112117
message +=
113118
"jf pip install\n" +
114-
"jf rt u path/to/package/file default-pypi-local" + comment(" # Publish your pip package") +
119+
"jf rt u path/to/package/file default-pypi-local" +
120+
coreutils.PrintComment(" # Publish your pip package") +
115121
"\n"
116122
}
117123
}
118124
}
119125
if message != "" {
120-
message = title("Build the code & deploy the packages by running") +
126+
message = coreutils.PrintTitle("Build the code & deploy the packages by running") +
121127
"\n" +
122128
message +
123129
"\n" +
124-
title("Publish the build-info to Artifactory") +
130+
coreutils.PrintTitle("Publish the build-info to Artifactory") +
125131
"\n" +
126132
"jf rt bp\n\n"
127133
}
128134
return message
129135
}
130136

131-
// Print the test to the console in green color.
132-
func title(str string) string {
133-
return colorStr(str, color.Green)
134-
}
135-
136-
// Print the test to the console in cyan color.
137-
func link(str string) string {
138-
return colorStr(str, color.Cyan)
139-
}
140-
141-
// Print the test to the console with bold style.
142-
func bold(str string) string {
143-
return colorStr(str, color.Bold)
144-
}
145-
146-
// Print the test to the console in gray color.
147-
func comment(str string) string {
148-
return colorStr(str, color.Gray)
149-
}
150-
151-
// Print the test to the console with the specified color.
152-
func colorStr(str string, c color.Color) string {
153-
if coreutils.IsTerminal() {
154-
return c.Render(str)
155-
}
156-
return str
157-
}
158-
159137
type BuildConfigFile struct {
160138
Version int `yaml:"version,omitempty"`
161139
ConfigType string `yaml:"type,omitempty"`

utils/coreutils/cmdutils.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"strconv"
55
"strings"
66

7+
"github.com/gookit/color"
78
"github.com/mattn/go-shellwords"
89

910
"github.com/jfrog/jfrog-client-go/utils/errorutils"
@@ -198,3 +199,31 @@ func ParseArgs(args []string) ([]string, error) {
198199
func isQuote(s string) bool {
199200
return len(s) > 0 && ((s[0] == '"' && s[len(s)-1] == '"') || (s[0] == '\'' && s[len(s)-1] == '\''))
200201
}
202+
203+
// Print the test to the console in green color.
204+
func PrintTitle(str string) string {
205+
return colorStr(str, color.Green)
206+
}
207+
208+
// Print the test to the console in cyan color.
209+
func PrintLink(str string) string {
210+
return colorStr(str, color.Cyan)
211+
}
212+
213+
// Print the test to the console with bold style.
214+
func PrintBold(str string) string {
215+
return colorStr(str, color.Bold)
216+
}
217+
218+
// Print the test to the console in gray color.
219+
func PrintComment(str string) string {
220+
return colorStr(str, color.Gray)
221+
}
222+
223+
// Print the test to the console with the specified color.
224+
func colorStr(str string, c color.Color) string {
225+
if IsTerminal() {
226+
return c.Render(str)
227+
}
228+
return str
229+
}

0 commit comments

Comments
 (0)