diff --git a/Makefile b/Makefile index bf1e5fe1..4b8ce38c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -MAIN_PACKAGE_PATH := . +MAIN_PACKAGE_PATH := ./cmd/asdf TARGET_DIR := . TARGET := asdf FULL_VERSION = $(shell ./scripts/asdf-version ) @@ -31,7 +31,7 @@ lint: fmt revive -set_exit_status ./... vet: fmt - go vet . + go vet ./... run: build ${TARGET_DIR}/${TARGET} diff --git a/cmd/cmd.go b/cli/cli.go similarity index 97% rename from cmd/cmd.go rename to cli/cli.go index 5dd036c5..4e3bd09e 100644 --- a/cmd/cmd.go +++ b/cli/cli.go @@ -1,5 +1,5 @@ -// Package cmd contains the asdf CLI command code -package cmd +// Package cli contains the asdf CLI command code +package cli import ( "errors" @@ -12,19 +12,18 @@ import ( "strings" "text/tabwriter" - "asdf/internal/config" - "asdf/internal/exec" - "asdf/internal/execenv" - "asdf/internal/execute" - "asdf/internal/help" - "asdf/internal/info" - "asdf/internal/installs" - "asdf/internal/plugins" - "asdf/internal/resolve" - "asdf/internal/shims" - "asdf/internal/toolversions" - "asdf/internal/versions" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/exec" + "github.com/asdf-vm/asdf-core-go/internal/execenv" + "github.com/asdf-vm/asdf-core-go/internal/execute" + "github.com/asdf-vm/asdf-core-go/internal/help" + "github.com/asdf-vm/asdf-core-go/internal/info" + "github.com/asdf-vm/asdf-core-go/internal/installs" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/resolve" + "github.com/asdf-vm/asdf-core-go/internal/shims" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/internal/versions" "github.com/urfave/cli/v2" ) diff --git a/main.go b/cmd/asdf/main.go similarity index 72% rename from main.go rename to cmd/asdf/main.go index df7ec11f..4324dbe3 100644 --- a/main.go +++ b/cmd/asdf/main.go @@ -1,14 +1,12 @@ // Main entrypoint for the CLI app package main -import ( - "asdf/cmd" -) +import "github.com/asdf-vm/asdf-core-go/cli" // Replaced with the real version during a typical build var version = "v-dev" // Placeholder for the real code func main() { - cmd.Execute(version) + cli.Execute(version) } diff --git a/main_test.go b/cmd/asdf/main_test.go similarity index 97% rename from main_test.go rename to cmd/asdf/main_test.go index d13b798d..7bf20ec9 100644 --- a/main_test.go +++ b/cmd/asdf/main_test.go @@ -123,8 +123,8 @@ func runBatsFile(t *testing.T, dir, filename string) { err := cmd.Run() if err != nil { // If command fails print both stderr and stdout - fmt.Println("stdout:", stdout.String()) - fmt.Println("stderr:", stderr.String()) + t.Log("stdout:", stdout.String()) + t.Log("stderr:", stderr.String()) t.Fatal("bats command failed to run test file successfully") return diff --git a/go.mod b/go.mod index 56b60633..a3dd3143 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module asdf +module github.com/asdf-vm/asdf-core-go go 1.21.5 diff --git a/internal/exec/exec_test.go b/internal/exec/exec_test.go index 50ba550f..ebe32229 100644 --- a/internal/exec/exec_test.go +++ b/internal/exec/exec_test.go @@ -14,6 +14,7 @@ func execit() int { cmdPath, _ := exec.LookPath(os.Args[1]) err := Exec(cmdPath, os.Args[2:], os.Environ()) if err != nil { + // TODO: Use testing logging system instead of direct printing. fmt.Printf("Err: %#+v\n", err.Error()) } diff --git a/internal/execenv/execenv.go b/internal/execenv/execenv.go index 28015895..85f45a50 100644 --- a/internal/execenv/execenv.go +++ b/internal/execenv/execenv.go @@ -7,8 +7,8 @@ import ( "os" "strings" - "asdf/internal/execute" - "asdf/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/execute" + "github.com/asdf-vm/asdf-core-go/internal/plugins" ) const execEnvCallbackName = "exec-env" diff --git a/internal/execenv/execenv_test.go b/internal/execenv/execenv_test.go index efda54aa..9bfee092 100644 --- a/internal/execenv/execenv_test.go +++ b/internal/execenv/execenv_test.go @@ -3,10 +3,9 @@ package execenv import ( "testing" - "asdf/internal/config" - "asdf/internal/plugins" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" ) diff --git a/internal/git/git_test.go b/internal/git/git_test.go index dfd4b945..e049d09c 100644 --- a/internal/git/git_test.go +++ b/internal/git/git_test.go @@ -5,8 +5,7 @@ import ( "path/filepath" "testing" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" "github.com/stretchr/testify/assert" diff --git a/internal/help/help.go b/internal/help/help.go index 3fc718f3..981bbd56 100644 --- a/internal/help/help.go +++ b/internal/help/help.go @@ -8,9 +8,9 @@ import ( "io" "os" - "asdf/internal/config" - "asdf/internal/plugins" - "asdf/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" ) //go:embed help.txt diff --git a/internal/help/help_test.go b/internal/help/help_test.go index 735aec0f..94c58226 100644 --- a/internal/help/help_test.go +++ b/internal/help/help_test.go @@ -6,10 +6,9 @@ import ( "strings" "testing" - "asdf/internal/config" - "asdf/internal/plugins" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" ) diff --git a/internal/hook/hook.go b/internal/hook/hook.go index ff7b2e19..18302cb6 100644 --- a/internal/hook/hook.go +++ b/internal/hook/hook.go @@ -6,8 +6,8 @@ import ( "io" "os" - "asdf/internal/config" - "asdf/internal/execute" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/execute" ) // Run gets a hook command from config and runs it with the provided arguments. diff --git a/internal/hook/hook_test.go b/internal/hook/hook_test.go index e1e93ebd..d80ec8c3 100644 --- a/internal/hook/hook_test.go +++ b/internal/hook/hook_test.go @@ -4,8 +4,7 @@ import ( "os/exec" "testing" - "asdf/internal/config" - + "github.com/asdf-vm/asdf-core-go/internal/config" "github.com/stretchr/testify/assert" ) diff --git a/internal/info/info.go b/internal/info/info.go index bc1b2e21..cdf6ebc0 100644 --- a/internal/info/info.go +++ b/internal/info/info.go @@ -7,9 +7,9 @@ import ( "os" "text/tabwriter" - "asdf/internal/config" - "asdf/internal/execute" - "asdf/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/execute" + "github.com/asdf-vm/asdf-core-go/internal/plugins" ) // Print info output to STDOUT diff --git a/internal/info/info_test.go b/internal/info/info_test.go index dc915830..a25b0a10 100644 --- a/internal/info/info_test.go +++ b/internal/info/info_test.go @@ -6,8 +6,7 @@ import ( "strings" "testing" - "asdf/internal/config" - + "github.com/asdf-vm/asdf-core-go/internal/config" "github.com/stretchr/testify/assert" ) diff --git a/internal/installs/installs.go b/internal/installs/installs.go index c0604614..b0c1e848 100644 --- a/internal/installs/installs.go +++ b/internal/installs/installs.go @@ -8,10 +8,10 @@ import ( "os" "path/filepath" - "asdf/internal/config" - "asdf/internal/data" - "asdf/internal/plugins" - "asdf/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/data" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" ) // Installed returns a slice of all installed versions for a given plugin diff --git a/internal/installs/installs_test.go b/internal/installs/installs_test.go index b41883f1..dded2eaf 100644 --- a/internal/installs/installs_test.go +++ b/internal/installs/installs_test.go @@ -5,12 +5,11 @@ import ( "path/filepath" "testing" - "asdf/internal/config" - "asdf/internal/installtest" - "asdf/internal/plugins" - "asdf/internal/toolversions" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/installtest" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" ) diff --git a/internal/installtest/installtest.go b/internal/installtest/installtest.go index e1e64c19..4e903786 100644 --- a/internal/installtest/installtest.go +++ b/internal/installtest/installtest.go @@ -9,8 +9,8 @@ import ( "path/filepath" "strings" - "asdf/internal/config" - "asdf/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" ) const ( diff --git a/internal/pluginindex/pluginindex.go b/internal/pluginindex/pluginindex.go index d826bf9f..0285b0f7 100644 --- a/internal/pluginindex/pluginindex.go +++ b/internal/pluginindex/pluginindex.go @@ -8,8 +8,7 @@ import ( "path/filepath" "time" - "asdf/internal/git" - + "github.com/asdf-vm/asdf-core-go/internal/git" "gopkg.in/ini.v1" ) diff --git a/internal/pluginindex/pluginindex_test.go b/internal/pluginindex/pluginindex_test.go index 5b4d45e6..1c8a5026 100644 --- a/internal/pluginindex/pluginindex_test.go +++ b/internal/pluginindex/pluginindex_test.go @@ -8,9 +8,8 @@ import ( "testing" "time" - "asdf/internal/git" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/git" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" ) diff --git a/internal/plugins/plugins.go b/internal/plugins/plugins.go index 12ab3a97..3b19df60 100644 --- a/internal/plugins/plugins.go +++ b/internal/plugins/plugins.go @@ -11,12 +11,12 @@ import ( "regexp" "strings" - "asdf/internal/config" - "asdf/internal/data" - "asdf/internal/execute" - "asdf/internal/git" - "asdf/internal/hook" - "asdf/internal/pluginindex" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/data" + "github.com/asdf-vm/asdf-core-go/internal/execute" + "github.com/asdf-vm/asdf-core-go/internal/git" + "github.com/asdf-vm/asdf-core-go/internal/hook" + "github.com/asdf-vm/asdf-core-go/internal/pluginindex" ) // NewPluginAlreadyExists generates a new PluginAlreadyExists error instance for diff --git a/internal/plugins/plugins_test.go b/internal/plugins/plugins_test.go index 98c5622e..380074b3 100644 --- a/internal/plugins/plugins_test.go +++ b/internal/plugins/plugins_test.go @@ -6,10 +6,9 @@ import ( "strings" "testing" - "asdf/internal/config" - "asdf/internal/data" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/data" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" ) diff --git a/internal/resolve/resolve.go b/internal/resolve/resolve.go index e76c55a9..20044957 100644 --- a/internal/resolve/resolve.go +++ b/internal/resolve/resolve.go @@ -9,9 +9,9 @@ import ( "path" "strings" - "asdf/internal/config" - "asdf/internal/plugins" - "asdf/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" ) // ToolVersions represents a tool along with versions specified for it diff --git a/internal/resolve/resolve_test.go b/internal/resolve/resolve_test.go index fe3159b6..4730f58c 100644 --- a/internal/resolve/resolve_test.go +++ b/internal/resolve/resolve_test.go @@ -6,10 +6,9 @@ import ( "path/filepath" "testing" - "asdf/internal/config" - "asdf/internal/plugins" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" ) diff --git a/internal/shims/shims.go b/internal/shims/shims.go index 2ec80745..b70e08ac 100644 --- a/internal/shims/shims.go +++ b/internal/shims/shims.go @@ -11,14 +11,13 @@ import ( "slices" "strings" - "asdf/internal/config" - "asdf/internal/hook" - "asdf/internal/installs" - "asdf/internal/paths" - "asdf/internal/plugins" - "asdf/internal/resolve" - "asdf/internal/toolversions" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/hook" + "github.com/asdf-vm/asdf-core-go/internal/installs" + "github.com/asdf-vm/asdf-core-go/internal/paths" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/resolve" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" "golang.org/x/sys/unix" ) diff --git a/internal/shims/shims_test.go b/internal/shims/shims_test.go index ed5afbc9..50e29f7f 100644 --- a/internal/shims/shims_test.go +++ b/internal/shims/shims_test.go @@ -8,13 +8,12 @@ import ( "strings" "testing" - "asdf/internal/config" - "asdf/internal/installs" - "asdf/internal/installtest" - "asdf/internal/plugins" - "asdf/internal/toolversions" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/installs" + "github.com/asdf-vm/asdf-core-go/internal/installtest" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" "golang.org/x/sys/unix" ) diff --git a/internal/toolversions/toolversions_test.go b/internal/toolversions/toolversions_test.go index 5de32b49..dbb0f741 100644 --- a/internal/toolversions/toolversions_test.go +++ b/internal/toolversions/toolversions_test.go @@ -104,7 +104,7 @@ func TestUnique(t *testing.T) { }) } -func TestfindToolVersionsInContent(t *testing.T) { +func TestFindToolVersionsInContent(t *testing.T) { t.Run("returns empty list with found false when empty content", func(t *testing.T) { versions, found := findToolVersionsInContent("", "ruby") assert.False(t, found) @@ -124,7 +124,7 @@ func TestfindToolVersionsInContent(t *testing.T) { }) } -func TestgetAllToolsAndVersionsInContent(t *testing.T) { +func TestGetAllToolsAndVersionsInContent(t *testing.T) { tests := []struct { desc string input string diff --git a/internal/versions/versions.go b/internal/versions/versions.go index 7e589ced..0805ced0 100644 --- a/internal/versions/versions.go +++ b/internal/versions/versions.go @@ -10,13 +10,13 @@ import ( "regexp" "strings" - "asdf/internal/config" - "asdf/internal/hook" - "asdf/internal/installs" - "asdf/internal/plugins" - "asdf/internal/resolve" - "asdf/internal/shims" - "asdf/internal/toolversions" + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/hook" + "github.com/asdf-vm/asdf-core-go/internal/installs" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/internal/resolve" + "github.com/asdf-vm/asdf-core-go/internal/shims" + "github.com/asdf-vm/asdf-core-go/internal/toolversions" ) const ( diff --git a/internal/versions/versions_test.go b/internal/versions/versions_test.go index c9a41d48..f11ea6e8 100644 --- a/internal/versions/versions_test.go +++ b/internal/versions/versions_test.go @@ -7,10 +7,9 @@ import ( "strings" "testing" - "asdf/internal/config" - "asdf/internal/plugins" - "asdf/repotest" - + "github.com/asdf-vm/asdf-core-go/internal/config" + "github.com/asdf-vm/asdf-core-go/internal/plugins" + "github.com/asdf-vm/asdf-core-go/repotest" "github.com/stretchr/testify/assert" )