chore(release): bump version to v0.8.9 and prioritize archive updates

This commit is contained in:
gitea committed 2026-09-18 11:43:55 +08:00
1 parent db2b256fcd
commit 64c0fafcf6
10 files changed
+153 -136

No files matched your search

+4 -3
View File
@@ -53,18 +53,19 @@ describe("normalizeRepo and isValidRepo", () => {
describe("matchAssetForPlatform", () => {
const assets: GitHubAsset[] = [
{ name: "hose-use-darwin-arm64", downloadUrl: "https://example.com/darwin-arm64", size: 100 },
{ name: "hose-use-darwin-arm64.tar.gz", downloadUrl: "https://example.com/darwin-arm64.tar.gz", size: 40 },
{ name: "hose-use-darwin-x64", downloadUrl: "https://example.com/darwin-x64", size: 100 },
{ name: "hose-use-linux-x64.tar.gz", downloadUrl: "https://example.com/linux-x64.tar.gz", size: 100 },
{ name: "hose-use-linux-arm64", downloadUrl: "https://example.com/linux-arm64", size: 100 },
{ name: "hose-use-windows-x64.zip", downloadUrl: "https://example.com/win-x64.zip", size: 100 },
];
test("matches darwin arm64", () => {
test("matches darwin arm64 with archive priority", () => {
const matched = matchAssetForPlatform(assets, "darwin", "arm64");
expect(matched?.name).toBe("hose-use-darwin-arm64");
expect(matched?.name).toBe("hose-use-darwin-arm64.tar.gz");
});
test("matches darwin x64", () => {
test("matches darwin x64 fallback to raw binary when no archive present", () => {
const matched = matchAssetForPlatform(assets, "darwin", "x64");
expect(matched?.name).toBe("hose-use-darwin-x64");
});
+31 -15
View File
@@ -715,7 +715,16 @@ export function matchAssetForPlatform(
return matchesP && matchesA;
});
// Prefer direct raw executable over tar.gz / zip if both exist
// Prefer compressed archives (.tar.gz / .zip) over raw binary for faster downloads (25MB vs 65MB+)
const archive = matched.find(
(asset) =>
asset.name.endsWith(".tar.gz") ||
asset.name.endsWith(".tgz") ||
asset.name.endsWith(".zip")
);
if (archive) return archive;
// Fallback to direct raw binary if available
const directBinary = matched.find(
(asset) =>
!asset.name.endsWith(".tar.gz") &&
@@ -723,16 +732,7 @@ export function matchAssetForPlatform(
!asset.name.endsWith(".zip") &&
!asset.name.endsWith(".sha256")
);
if (directBinary) return directBinary;
// Fallback to archive
const archive = matched.find(
(asset) =>
asset.name.endsWith(".tar.gz") ||
asset.name.endsWith(".tgz") ||
asset.name.endsWith(".zip")
);
return archive || matched[0];
return directBinary || matched[0];
}
function logProgress(msg: string) {
@@ -877,15 +877,24 @@ function extractTarGz(archivePath: string, targetDir: string, platform: string):
}
unlinkSync(archivePath);
const expectedName = platform === "windows" ? "hose-use.exe" : "hose-use";
const files = spawnSync("find", [targetDir, "-type", "f"], { encoding: "utf8" })
.stdout.trim()
.split("\n")
.filter(Boolean);
// Exact match for hose-use or hose-use.exe
const expectedName = platform === "windows" ? "hose-use.exe" : "hose-use";
const exact = files.find((f) => f.endsWith(`/${expectedName}`) || f.endsWith(expectedName));
if (exact) return exact;
return files[0] || archivePath;
// Next match for hose-use-darwin-arm64 etc., excluding hose-aipro
const platformBinary = files.find((f) => {
const base = f.split("/").pop() || "";
return base.startsWith("hose-use-") && !base.endsWith(".cmd") && !base.endsWith(".json");
});
if (platformBinary) return platformBinary;
return files.find((f) => !f.endsWith("hose-aipro")) || files[0] || archivePath;
}
function extractZip(archivePath: string, targetDir: string, platform: string): string {
@@ -895,15 +904,22 @@ function extractZip(archivePath: string, targetDir: string, platform: string): s
}
unlinkSync(archivePath);
const expectedName = platform === "windows" ? "hose-use.exe" : "hose-use";
const files = spawnSync("find", [targetDir, "-type", "f"], { encoding: "utf8" })
.stdout.trim()
.split("\n")
.filter(Boolean);
const expectedName = platform === "windows" ? "hose-use.exe" : "hose-use";
const exact = files.find((f) => f.endsWith(`/${expectedName}`) || f.endsWith(expectedName));
if (exact) return exact;
return files[0] || archivePath;
const platformBinary = files.find((f) => {
const base = f.split("/").pop() || "";
return base.startsWith("hose-use-") && !base.endsWith(".cmd") && !base.endsWith(".json");
});
if (platformBinary) return platformBinary;
return files.find((f) => !f.endsWith("hose-aipro")) || files[0] || archivePath;
}
export function compareSemVer(v1: string, v2: string): number {