Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #92 from asdf-vm/DeedleFake-rename-module-and-use-…
Browse files Browse the repository at this point in the history
…cmd-dir

feat(golang-rewrite): rename module and move `main` pacakge to `cmd/asdf`
  • Loading branch information
Stratus3D committed Dec 18, 2024
2 parents 7896be1 + 5d5d04f commit f0d74ec
Show file tree
Hide file tree
Showing 31 changed files with 134 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
go-version: '1.21.5'
- name: Install dependencies
run: go get .
run: go get ./...
- name: Install gofumpt for formatting
run: go install mvdan.cc/gofumpt@latest
- name: Run 'gofumpt'
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Run 'revive'
run: revive -set_exit_status ./...
- name: Vet
run: go vet
run: go vet ./...
- name: Install staticcheck for linting
run: go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
go-version: '1.21.5'
- run: scripts/install_dependencies.bash
- name: Install dependencies
run: go get .
run: go get ./...
- name: Run Go tests
run: go test -coverprofile=/tmp/coverage.out -bench= -race ./...

Expand Down
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
33 changes: 16 additions & 17 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 @@ -13,21 +13,20 @@ import (
"strings"
"text/tabwriter"

"asdf/internal/config"
"asdf/internal/exec"
"asdf/internal/execenv"
"asdf/internal/execute"
"asdf/internal/help"
"asdf/internal/hook"
"asdf/internal/info"
"asdf/internal/installs"
"asdf/internal/pluginindex"
"asdf/internal/plugins"
"asdf/internal/resolve"
"asdf/internal/shims"
"asdf/internal/toolversions"
"asdf/internal/versions"

"github.com/asdf-vm/asdf/internal/config"
"github.com/asdf-vm/asdf/internal/exec"
"github.com/asdf-vm/asdf/internal/execenv"
"github.com/asdf-vm/asdf/internal/execute"
"github.com/asdf-vm/asdf/internal/help"
"github.com/asdf-vm/asdf/internal/hook"
"github.com/asdf-vm/asdf/internal/info"
"github.com/asdf-vm/asdf/internal/installs"
"github.com/asdf-vm/asdf/internal/pluginindex"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/internal/resolve"
"github.com/asdf-vm/asdf/internal/shims"
"github.com/asdf-vm/asdf/internal/toolversions"
"github.com/asdf-vm/asdf/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/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)
}
6 changes: 3 additions & 3 deletions main_test.go → cmd/asdf/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestBatsTests(t *testing.T) {
func runBatsFile(t *testing.T, dir, filename string) {
t.Helper()

cmd := exec.Command("bats", "--verbose-run", fmt.Sprintf("test/%s", filename))
cmd := exec.Command("bats", "--verbose-run", fmt.Sprintf("../../test/%s", filename))

// Capture stdout and stderr
var stdout strings.Builder
Expand All @@ -127,8 +127,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

go 1.21.5

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/internal/execute"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/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/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 @@ -9,9 +9,9 @@ import (
"os"
"strings"

"asdf/internal/config"
"asdf/internal/plugins"
"asdf/internal/toolversions"
"github.com/asdf-vm/asdf/internal/config"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/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 @@ -7,10 +7,9 @@ import (
"strings"
"testing"

"asdf/internal/config"
"asdf/internal/plugins"
"asdf/repotest"

"github.com/asdf-vm/asdf/internal/config"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/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/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/internal/config"
"github.com/asdf-vm/asdf/internal/execute"
"github.com/asdf-vm/asdf/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/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/internal/config"
"github.com/asdf-vm/asdf/internal/data"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/internal/installtest"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/internal/toolversions"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/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 @@ -9,8 +9,7 @@ import (
"path/filepath"
"time"

"asdf/internal/git"

"github.com/asdf-vm/asdf/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/internal/git"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/internal/data"
"github.com/asdf-vm/asdf/internal/execute"
"github.com/asdf-vm/asdf/internal/git"
"github.com/asdf-vm/asdf/internal/hook"
"github.com/asdf-vm/asdf/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 @@ -7,10 +7,9 @@ import (
"strings"
"testing"

"asdf/internal/config"
"asdf/internal/data"
"asdf/repotest"

"github.com/asdf-vm/asdf/internal/config"
"github.com/asdf-vm/asdf/internal/data"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/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/internal/config"
"github.com/asdf-vm/asdf/internal/hook"
"github.com/asdf-vm/asdf/internal/installs"
"github.com/asdf-vm/asdf/internal/paths"
"github.com/asdf-vm/asdf/internal/plugins"
"github.com/asdf-vm/asdf/internal/resolve"
"github.com/asdf-vm/asdf/internal/toolversions"
"golang.org/x/sys/unix"
)

Expand Down
Loading

0 comments on commit f0d74ec

Please sign in to comment.