diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 980ac1f8..4d9d9b5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,11 +2,16 @@ name: VersionFox CI on: [push] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [macos-latest, ubuntu-latest, windows-latest] go-version: [ '1.21.x' ] steps: @@ -15,16 +20,14 @@ jobs: uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - - name: Display Go version - run: go version - name: Install dependencies run: | go get . - - name: Build with the Go CLI + - name: Build run: | go build . - - name: Test with the Go CLI - # we cannot use `go test ./...` currently, because many test cases are failed + - name: Test and coverage run: | - go test ./internal - go test ./internal/luai + go test ./... -coverprofile=coverage.out -covermode=atomic + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index 3ba7f0ab..c9e8a97c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .DS_Store .idea -/docs/node_modules/ \ No newline at end of file +/docs/node_modules/ + + +coverage.out diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 3fff1b2c..b61babd7 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -17,11 +17,16 @@ builds: - amd64 - arm - arm64 + - loong64 goarm: - "7" ignore: - goos: windows goarch: arm + - goos: windows + goarch: loong64 + - goos: darwin + goarch: loong64 mod_timestamp: "{{ .CommitTimestamp }}" flags: - -trimpath diff --git a/README.md b/README.md index 4d959d77..cbe13b80 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,18 @@ $ node -v See [vfox.lhan.me](https://vfox.lhan.me) for full documentation. +## Roadmap + +Our future plans and high priority features and enhancements are: + +- [ ] Refactoring the plugin mechanism: + - Introducing plugin templates to facilitate multi-file plugin development. + - Establishing a global registry (similar to `NPM Registry` or `Scoop Main Bucket`) to provide a unified entry point for plugin distribution. + - Decomposing the existing plugin repository into individual repositories, one for each plugin. +- [ ] Allowing the switching of registry addresses. +- [ ] Plugin capabilities: Parsing legacy configuration files, such as `.nvmrc`, `.node-version`, `.sdkmanrc`, etc. +- [ ] Plugin capabilities: Allowing plugins to load installed runtimes and provide information about the runtime. + ## Supported Plugins > If you have installed `vfox`, you can view all available plugins with the `vfox available` command. diff --git a/README_CN.md b/README_CN.md index 8192b18f..603a5d5f 100644 --- a/README_CN.md +++ b/README_CN.md @@ -84,6 +84,17 @@ $ node -v 详细内容,请看 [version-fox-plugins](https://github.com/version-fox/version-fox-plugins) +## 路线图 + +我们未来的计划以及高度优先的功能和增强功能是: +- [ ] 重构插件机制: + - 增加插件模板, 允许多文件开发插件 + - 增加全局注册表(类似于:`NPM Registry`、`Scoop Main Bucket`), 为插件分发提供统一入口 + - 拆分现有的插件仓库, 一个插件一个仓库 +- [ ] 允许切换注册表地址 +- [ ] 插件能力: 允许插件解析旧版本的配置文件. 例如: `.nvmrc`, `.node-version`, `.sdkmanrc`等 +- [ ] 插件能力: 允许插件加载已安装的运行时, 并提供运行时的信息 + ## 贡献者 > 感谢以下贡献者对本项目的贡献。🎉🎉🙏🙏 diff --git a/install.sh b/install.sh index da0cde59..e4a7b040 100755 --- a/install.sh +++ b/install.sh @@ -31,6 +31,8 @@ ARCH_TYPE=$(uname -m) if [ "$ARCH_TYPE" = "arm64" ]; then ARCH_TYPE="aarch64" +elif [ "$ARCH_TYPE" = "loongarch64" ]; then + ARCH_TYPE="loong64" fi FILENAME="vfox_${VERSION}_${OS_TYPE}_${ARCH_TYPE}" diff --git a/internal/module/file/file_test.go b/internal/module/file/file_test.go index 30b401c5..c514b997 100644 --- a/internal/module/file/file_test.go +++ b/internal/module/file/file_test.go @@ -17,8 +17,9 @@ package html import ( - lua "github.com/yuin/gopher-lua" "testing" + + lua "github.com/yuin/gopher-lua" ) func TestRequire(t *testing.T) { @@ -30,35 +31,6 @@ func TestRequire(t *testing.T) { evalLua(str, t) } -func TestFind(t *testing.T) { - const str = ` - local file = require("file") - file.symlink(src, dest) - assert(div:text() == "hello world") - ` - evalLua(str, t) -} - -func TestFirst(t *testing.T) { - const str = ` - local html = require("html") - local doc = html.parse("
123
456
") - local div = doc:find("div") - assert(div:first():text() == "123") - ` - evalLua(str, t) -} - -func TestContinuousFind(t *testing.T) { - const str = ` - local html = require("html") - local doc = html.parse("
test
456
") - local div = doc:find("body"):find("#t2") - print(div:text() == "456") - ` - evalLua(str, t) -} - func evalLua(str string, t *testing.T) { s := lua.NewState() defer s.Close() diff --git a/internal/module/http/http_test.go b/internal/module/http/http_test.go index e781ce28..5b1e3383 100644 --- a/internal/module/http/http_test.go +++ b/internal/module/http/http_test.go @@ -17,19 +17,26 @@ package http import ( + "runtime" + "testing" + "github.com/version-fox/vfox/internal/config" lua "github.com/yuin/gopher-lua" - "testing" ) func TestWithConfig(t *testing.T) { - const str = ` + if runtime.GOOS == "windows" { + t.Skip("Skip on windows, the proxy won't error on windows.") + } + + const str = ` local http = require("http") assert(type(http) == "table") assert(type(http.get) == "function") local resp, err = http.get({ url = "http://ip.jsontest.com/" }) + print(err) assert(err == 'Get "http://ip.jsontest.com/": proxyconnect tcp: dial tcp 127.0.0.1:80: connect: connection refused') ` s := lua.NewState() @@ -37,14 +44,14 @@ func TestWithConfig(t *testing.T) { s.PreloadModule("http", NewModule(&config.Proxy{ Enable: true, - Url: "http://localhost", + Url: "http://127.0.0.1", })) if err := s.DoString(str); err != nil { t.Error(err) } } func TestGetRequest(t *testing.T) { - const str = ` + const str = ` local http = require("http") assert(type(http) == "table") assert(type(http.get) == "function") @@ -59,7 +66,7 @@ func TestGetRequest(t *testing.T) { } func TestHeadRequest(t *testing.T) { - const str = ` + const str = ` local http = require("http") assert(type(http) == "table") assert(type(http.get) == "function") diff --git a/internal/printer/select_test.go b/internal/printer/select_test.go index 9aff2725..a3cc8788 100644 --- a/internal/printer/select_test.go +++ b/internal/printer/select_test.go @@ -18,10 +18,15 @@ package printer import ( "fmt" + "os" "testing" ) func TestSelect_Show(t *testing.T) { + if os.Getenv("CI") != "" { + t.Skip("Skipping TestSelect_Show in CI environment because it requires user input") + } + source := []*KV{ { Key: "1",