Repository: exercism/cli
Pull request #1166 (2024-09-14 14:16:18)

Fix URL in no token error message

github-actions[bot]: Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use [this link](https://forum.exercism.org/new-topic?title=Fix%20URL%20in%20no%20token%20error%20message&body=null&category=support ) to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read [this blog post](https://exercism.org/blog/contribution-guidelines-nov-2023).

---

_Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it._
IsaacG: Forum thread: https://forum.exercism.org/t/cli-no-token-message-tells-the-user-to-go-to-a-incorrect-url

Patch:
diff --git a/config/config.go b/config/config.go
index b9b1883..e705950 100644
--- a/config/config.go
+++ b/config/config.go
@@ -12,7 +12,7 @@ import (
 )
 
 var (
-	defaultBaseURL = "https://api.exercism.io/v1"
+	defaultBaseURL = "https://exercism.org"
 
 	// DefaultDirName is the default name used for config and workspace directories.
 	DefaultDirName string
@@ -122,7 +122,7 @@ func InferSiteURL(apiURL string) string {
 		apiURL = defaultBaseURL
 	}
 	if apiURL == "https://api.exercism.io/v1" {
-		return "https://exercism.io"
+		return "https://exercism.org"
 	}
 	re := regexp.MustCompile("^(https?://[^/]*).*")
 	return re.ReplaceAllString(apiURL, "$1")
@@ -130,5 +130,5 @@ func InferSiteURL(apiURL string) string {
 
 // SettingsURL provides a link to where the user can find their API token.
 func SettingsURL(apiURL string) string {
-	return fmt.Sprintf("%s%s", InferSiteURL(apiURL), "/my/settings")
+	return fmt.Sprintf("%s%s", InferSiteURL(apiURL), "/settings/api_cli")
 }


Test patch:
diff --git a/cmd/download_test.go b/cmd/download_test.go
index d957297..a3e5658 100644
--- a/cmd/download_test.go
+++ b/cmd/download_test.go
@@ -26,7 +26,7 @@ func TestDownloadWithoutToken(t *testing.T) {
 	if assert.Error(t, err) {
 		assert.Regexp(t, "Welcome to Exercism", err.Error())
 		// It uses the default base API url to infer the host
-		assert.Regexp(t, "exercism.io/my/settings", err.Error())
+		assert.Regexp(t, "exercism.org/settings/api_cli", err.Error())
 	}
 }
 
diff --git a/cmd/submit_test.go b/cmd/submit_test.go
index 2a12d0b..c974794 100644
--- a/cmd/submit_test.go
+++ b/cmd/submit_test.go
@@ -28,7 +28,7 @@ func TestSubmitWithoutToken(t *testing.T) {
 	err := runSubmit(cfg, pflag.NewFlagSet("fake", pflag.PanicOnError), []string{})
 	if assert.Error(t, err) {
 		assert.Regexp(t, "Welcome to Exercism", err.Error())
-		assert.Regexp(t, "exercism.io/my/settings", err.Error())
+		assert.Regexp(t, "exercism.org/settings/api_cli", err.Error())
 	}
 }
 
diff --git a/config/config_test.go b/config/config_test.go
index e9d29f9..2df6ce1 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -10,11 +10,11 @@ func TestInferSiteURL(t *testing.T) {
 	testCases := []struct {
 		api, url string
 	}{
-		{"https://api.exercism.io/v1", "https://exercism.io"},
+		{"https://api.exercism.io/v1", "https://exercism.org"},
 		{"https://v2.exercism.io/api/v1", "https://v2.exercism.io"},
 		{"https://mentors-beta.exercism.io/api/v1", "https://mentors-beta.exercism.io"},
 		{"http://localhost:3000/api/v1", "http://localhost:3000"},
-		{"", "https://exercism.io"},            // use the default
+		{"", "https://exercism.org"},           // use the default
 		{"http://whatever", "http://whatever"}, // you're on your own, pal
 	}