Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/encoding-int
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Mar 25, 2024
2 parents bfae6de + 02dec8e commit 87fa227
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 45 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
.idea
/docs/node_modules/
/docs/node_modules/


coverage.out
5 changes: 5 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
- [ ] 插件能力: 允许插件加载已安装的运行时, 并提供运行时的信息

## 贡献者

> 感谢以下贡献者对本项目的贡献。🎉🎉🙏🙏
Expand Down
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
32 changes: 2 additions & 30 deletions internal/module/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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("<html><body><div id='test'>123</div><div id='test'>456</div></body></html>")
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("<html><body><div id='test'>test</div><div id='t2'>456</div></body></html>")
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()
Expand Down
17 changes: 12 additions & 5 deletions internal/module/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,41 @@
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()
defer s.Close()

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")
Expand All @@ -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")
Expand Down
7 changes: 6 additions & 1 deletion internal/printer/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -46,7 +51,7 @@ func TestSelect_Show(t *testing.T) {
}
s := &PageKVSelect{
index: 0,
SourceFunc: func(page, size int) ([]*KV, error) {
SourceFunc: func(page, size int, options []*KV) ([]*KV, error) {
// 计算开始和结束索引
start := page * size
end := start + size
Expand Down

0 comments on commit 87fa227

Please sign in to comment.