Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: rename module and move main pacakge to cmd/asdf #85

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAIN_PACKAGE_PATH := .
MAIN_PACKAGE_PATH := ./cmd/asdf
TARGET_DIR := .
TARGET := asdf
FULL_VERSION = $(shell ./scripts/asdf-version )
Expand Down Expand Up @@ -31,7 +31,7 @@ lint: fmt
revive -set_exit_status ./...

vet: fmt
go vet .
go vet ./...

run: build
${TARGET_DIR}/${TARGET}
Expand Down
29 changes: 14 additions & 15 deletions cmd/cmd.go → cli/cli.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This repo (github.com/asdf-vm/asdf-core-go) is temporary and will be archived in a couple weeks. All the changes in this repo will soon be merged into github.com/asdf-vm/asdf once most of the test code in main_test.go is passing.

Should we make this name github.com/asdf-vm/asdf? What's the difference between github.com/asdf-vm/asdf and asdf?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module name should match the import path that identifies the repo. If the plan is to move the code into another repo, then it should match the repo it's moved to. It can be renamed now or when it's moved. Alternatively, you can use a vanity URL, i.e. asdf-vm.com. Then people could, for example, use go install asdf-vm.com/cmd/asdf@latest to install the command. That would allow you to move repos without having to rename the module. I use a vanity URL, deedles.dev, for my personal projects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with github.com/asdf-vm/asdf since that is where this code will live in a few weeks. I don't expect many people to use this asdf-core-go repo, and if they do they'll hopefully see it's not ready for regular use. I've updated the repo description to make this clear.

"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"
)

Expand Down
6 changes: 2 additions & 4 deletions main.go → cmd/asdf/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
4 changes: 2 additions & 2 deletions main_test.go → cmd/asdf/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module asdf
module github.com/asdf-vm/asdf-core-go

go 1.21.5

Expand Down
1 change: 1 addition & 0 deletions internal/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
4 changes: 2 additions & 2 deletions internal/execenv/execenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions internal/execenv/execenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
3 changes: 1 addition & 2 deletions internal/git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions internal/help/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions internal/help/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions internal/hook/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions internal/info/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"strings"
"testing"

"asdf/internal/config"

"github.com/asdf-vm/asdf-core-go/internal/config"
"github.com/stretchr/testify/assert"
)

Expand Down
8 changes: 4 additions & 4 deletions internal/installs/installs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions internal/installs/installs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/installtest/installtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
3 changes: 1 addition & 2 deletions internal/pluginindex/pluginindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"path/filepath"
"time"

"asdf/internal/git"

"github.com/asdf-vm/asdf-core-go/internal/git"
"gopkg.in/ini.v1"
)

Expand Down
5 changes: 2 additions & 3 deletions internal/pluginindex/pluginindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
12 changes: 6 additions & 6 deletions internal/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions internal/plugins/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/resolve/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions internal/resolve/resolve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
15 changes: 7 additions & 8 deletions internal/shims/shims.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
13 changes: 6 additions & 7 deletions internal/shims/shims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/toolversions/toolversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Loading
Loading