Skip to content
Merged
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
5 changes: 2 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@v7
# TODO For compiling moby only.
# Because https://github.com/actions/runner-images/blob/win11-arm64/20260920.174/images/windows/Windows11-Arm64-Readme.md is still using `Go 1.24.13`.
# TODO For compiling moby only. Because https://github.com/actions/runner-images/blob/win11-arm64/20260920.174/images/windows/Windows11-Arm64-Readme.md is still using `Go 1.24.13`.
- if: matrix.runs-on == 'windows-11-arm'
uses: actions/setup-go@v7
with:
Expand All @@ -51,7 +50,7 @@ jobs:
name: Install Compose CLI plugin
run: |
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.docker\cli-plugins" | Out-Null
curl.exe -fsSL --retry 3 --retry-delay 5 --retry-all-errors "https://github.com/docker/compose/releases/download/v5.5.1/docker-compose-windows-aarch64.exe" -o "$env:USERPROFILE\.docker\cli-plugins\docker-compose.exe"
curl.exe -fsSL "https://github.com/docker/compose/releases/download/v5.5.1/docker-compose-windows-aarch64.exe" -o "$env:USERPROFILE\.docker\cli-plugins\docker-compose.exe"
docker compose version
- run: docker compose -f tests/e2e/windows/compose.yaml run --rm --build e2e
env:
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ permissions:
contents: read

jobs:
lint:
lint-go:
if: github.repository == 'version-fox/vfox-flutter'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-go@v6
with:
go-version: '1.26.8'
Expand All @@ -26,3 +24,18 @@ jobs:
- name: Run go vet
run: go vet ./...
working-directory: tests/e2e

lint-lua:
if: github.repository == 'version-fox/vfox-flutter'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: jdx/mise-action@v5
- name: Check Lua formatting
uses: JohnnyMorganz/stylua-action@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v2.5.2
args: --check .
- name: Check Lua
run: mise x aqua:LuaLS/lua-language-server@3.19.1 -- lua-language-server --check . --checklevel=Warning
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version: '1.24.0'
Expand Down
6 changes: 6 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
"Lua.runtime.version": "Lua 5.1",
"Lua.diagnostics.globals": ["PLUGIN", "RUNTIME"],
"Lua.diagnostics.disable": ["duplicate-set-field"]
}
1 change: 0 additions & 1 deletion Injection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ RUNTIME = {
--- vfox runtime version
version = "",
}

6 changes: 3 additions & 3 deletions hooks/available.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function PLUGIN:Available(ctx)
addition = {
{
name = "dart",
version = info.dart_sdk_version
}
}
version = info.dart_sdk_version,
},
},
})
end
for _, info in ipairs(ohos.list()) do
Expand Down
6 changes: 3 additions & 3 deletions hooks/env_keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function PLUGIN:EnvKeys(ctx)
return {
{
key = "PATH",
value = mainPath .. "/bin"
}
value = mainPath .. "/bin",
},
}
end
end
8 changes: 4 additions & 4 deletions hooks/pre_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function PLUGIN:PreInstall(ctx)
local channelKey
if arg == "beta" or arg == "dev" or arg == "stable" then
local resp, err = http.get({
url = getReleasesUrl(platform.osType)
url = getReleasesUrl(platform.osType),
})
if err ~= nil or resp.status_code ~= 200 then
error("get version failed: " .. tostring(err) .. " (status " .. tostring(resp and resp.status_code) .. ")")
Expand All @@ -36,15 +36,14 @@ function PLUGIN:PreInstall(ctx)
return {
version = versionName,
url = info.url,
sha256 = info.sha256
sha256 = info.sha256,
}
end

local legacy
for _, info in ipairs(self:Available({})) do
local version, arch = splitVersionAndArch(info.version)
local matches = channelKey and info.key == channelKey or
(channelKey == nil and version == arg)
local matches = channelKey and info.key == channelKey or (channelKey == nil and version == arg)
if matches then
if arch == targetArch then
return package(info, version)
Expand All @@ -65,6 +64,7 @@ function PLUGIN:PostInstall(ctx)
end
if sdk.path ~= nil and sdk.path ~= "" then
pcall(manifest.write, sdk.path, sdk)
pcall(manifest.touchPubspecLock, sdk.path)
end
if ohos.isOhosVersion(sdk.version) then
ohos.clean(sdk.version)
Expand Down
28 changes: 15 additions & 13 deletions hooks/pre_use.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ local manifest = require("manifest")

local REASON = {
["head-drifted"] = "the SDK's git HEAD no longer matches the commit vfox installed",
["sdk-no-longer-git"] = "vfox can no longer read the SDK's git HEAD (its .git may be broken)"
["sdk-no-longer-git"] = "vfox can no longer read the SDK's git HEAD (its .git may be broken)",
}

local function printDriftWarning(sdkPath, version, manifestInfo, currentHead, reason)
local installedVersion = (manifestInfo and manifestInfo.version) or version
local expectedHead = (manifestInfo and manifestInfo.expected_head) or "unknown"
io.write(string.format(
[[
io.write(
string.format(
[[
Warning: flutter SDK at %s has drifted from the version vfox installed.
vfox installed: flutter@%s (git HEAD %s)
current git HEAD: %s
Expand All @@ -29,16 +30,17 @@ To upgrade to a newer version, use vfox directly:
vfox install flutter@<new-version>
vfox use flutter@<new-version>
]],
sdkPath,
installedVersion,
expectedHead,
currentHead or "unknown",
REASON[reason] or reason,
version,
version,
version,
version
))
sdkPath,
installedVersion,
expectedHead,
currentHead or "unknown",
REASON[reason] or reason,
version,
version,
version,
version
)
)
end

function PLUGIN:PreUse(ctx)
Expand Down
45 changes: 41 additions & 4 deletions lib/manifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ local function hasGitDir(path)
end

local function isEmptyTable(table)
for _ in pairs(table) do
return false
end
return true
return next(table) == nil
end

local M = {}
Expand Down Expand Up @@ -179,4 +176,44 @@ function M.checkDrift(sdkRoot)
return false, "ok"
end

-- vfox extracts archives with Go's archive/tar (see
-- internal/shared/util/decompressor.go), which creates files with the
-- extraction time instead of the mtime stored in the archive. The official
-- `tar -xf` flow preserves mtimes, where
-- packages/flutter_tools/pubspec.lock is newer than pubspec.yaml. After a
-- vfox install the two files share the extraction time and whichever was
-- extracted last (currently pubspec.yaml) looks newer, so
-- bin/internal/shared.sh's `upgrade_flutter` sees
-- `pubspec.yaml -nt pubspec.lock` and rebuilds the Flutter tool on first
-- run (`Building flutter tool...`), deleting `version` and
-- `bin/cache/flutter.version.json` and forcing a `fetch --tags` version
-- lookup. Rewriting pubspec.lock bumps its mtime past pubspec.yaml and
-- restores the official first-run behavior (no rebuild).
function M.touchPubspecLock(sdkRoot)
local root = M.gitRoot(sdkRoot)
if root == nil then
if type(sdkRoot) ~= "string" or sdkRoot == "" then
return false
end
root = sdkRoot
end
local lockPath = joinPath(joinPath(joinPath(root, "packages"), "flutter_tools"), "pubspec.lock")
local f = io.open(lockPath, "rb")
if f == nil then
return false
end
local content = f:read("*a")
f:close()
if content == nil then
return false
end
local w = io.open(lockPath, "wb")
if w == nil then
return false
end
w:write(content)
w:close()
return true
end

return M
7 changes: 3 additions & 4 deletions lib/ohos.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function M.list()
version = version,
url = CLONE_URL:format(REPO),
key = version,
note = NOTE
note = NOTE,
})
end
end
Expand All @@ -73,8 +73,7 @@ function M.checkout(version, requestedArch)
local commit
local body, err = releases()
if body == nil then
error("OpenHarmony releases are unavailable from " .. RELEASES_URL:format(REPO)
.. ": " .. tostring(err))
error("OpenHarmony releases are unavailable from " .. RELEASES_URL:format(REPO) .. ": " .. tostring(err))
end
for _, info in ipairs(body) do
if info.tag_name == version then
Expand Down Expand Up @@ -106,7 +105,7 @@ function M.checkout(version, requestedArch)
return {
version = version,
url = dir,
note = NOTE
note = NOTE,
}
end

Expand Down
11 changes: 5 additions & 6 deletions lib/source.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ end
function M.list(releases)
local result = {}
for _, info in ipairs(releases or {}) do
if type(info.version) == "string" and string.sub(info.version, 1, 1) ~= "v"
and info.dart_sdk_arch == "x64" then
if type(info.version) == "string" and string.sub(info.version, 1, 1) ~= "v" and info.dart_sdk_arch == "x64" then
table.insert(result, {
version = info.version .. "-arm64",
url = M.repoUrl(),
Expand All @@ -32,9 +31,9 @@ function M.list(releases)
addition = {
{
name = "dart",
version = info.dart_sdk_version
}
}
version = info.dart_sdk_version,
},
},
})
end
end
Expand Down Expand Up @@ -73,7 +72,7 @@ function M.checkout(baseVersion, versionName)
end
return {
version = versionName,
url = dir
url = dir,
}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function getReleasesUrl(osType)
return getStorageBaseUrl() .. "/flutter_infra_release/releases/releases_" .. osType .. ".json"
end


function getOsTypeAndArch()
local osType = RUNTIME.osType
local archType = RUNTIME.archType
Expand All @@ -35,7 +34,8 @@ function getOsTypeAndArch()
error("flutter does not support" .. archType .. "architecture")
end
return {
osType = osType, archType = archType
osType = osType,
archType = archType,
}
end

Expand Down
1 change: 0 additions & 1 deletion metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ PLUGIN.license = "Apache 2.0"
--- Plugin description
PLUGIN.description = "Flutter plugin, https://flutter.dev"


--- !!! OPTIONAL !!!
--[[
NOTE:
Expand Down
5 changes: 5 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
Loading
Loading