Remove Homebrew integration and tap promotion

This commit is contained in:
gitea committed 2026-10-12 13:16:51 +08:00
1 parent fc9e148764
commit 4bee160086
15 files changed
+95 -424

No files matched your search

+53 -28
View File
@@ -1,8 +1,8 @@
import { describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { compareSemVer, getMirrorMode, isHomebrewInstall, isNewerVersion, matchAssetForPlatform, pruneUpdateLeftovers } from "./update.js";
import { compareSemVer, getMirrorMode, handleUpdateCommand, isNewerVersion, matchAssetForPlatform, pruneUpdateLeftovers } from "./update.js";
type Asset = { name: string; downloadUrl: string; size: number };
@@ -241,33 +241,58 @@ describe("update command bgSave and cache integration", () => {
rmSync(tempDir, { recursive: true, force: true });
}
});
});
describe("isHomebrewInstall", () => {
test("requires the executable to resolve inside Homebrew's registered formula prefix", () => {
const root = mkdtempSync(join(tmpdir(), "seal-use-homebrew-detect-"));
try {
const formulaPrefix = join(root, "opt", "seal-use");
const cellarBin = join(root, "Cellar", "seal-use", "0.10.33", "bin");
const nativeBin = join(root, "bin");
const formulaExecutable = join(cellarBin, "seal-use");
const nativeExecutable = join(nativeBin, "seal-use");
describe("update installation modes", () => {
test("a copied source package cannot update its parent application's Git repository", async () => {
const dir = mkdtempSync(join(tmpdir(), "seal-source-update-test-"));
try {
await expect(handleUpdateCommand({ appRoot: dir, entryFile: join(dir, "src", "cli.ts") }))
.rejects.toMatchObject({ exitCode: 13 });
expect(existsSync(join(dir, "bun.lock"))).toBe(false);
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
mkdirSync(cellarBin, { recursive: true });
mkdirSync(nativeBin, { recursive: true });
mkdirSync(join(root, "opt"), { recursive: true });
writeFileSync(formulaExecutable, "homebrew binary");
writeFileSync(nativeExecutable, "native binary");
symlinkSync(join(root, "Cellar", "seal-use", "0.10.33"), formulaPrefix);
expect(isHomebrewInstall(formulaExecutable, formulaPrefix)).toBe(true);
expect(isHomebrewInstall(nativeExecutable, formulaPrefix)).toBe(false);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("does not infer Homebrew from a matching directory name alone", () => {
expect(isHomebrewInstall("/opt/homebrew/bin/seal-use", "/tmp/not-installed-seal-use")).toBe(false);
});
test("native updates ignore package managers and allow selecting a release", async () => {
const dir = mkdtempSync(join(tmpdir(), "seal-native-update-test-"));
const originalExecPath = process.execPath;
const originalEnv = { ...process.env };
const originalFetch = globalThis.fetch;
const originalLog = console.log;
try {
// Every executable, cache and response is a temp fixture; never update the running test engine.
const binary = join(dir, "seal-use");
const invoked = join(dir, "package-manager-invoked");
writeFileSync(binary, "native fixture");
writeFileSync(join(dir, "brew"), `#!/bin/sh\ntouch '${invoked}'\nprintf '%s\\n' '${dir}'\n`, { mode: 0o755 });
process.execPath = binary;
process.env.PATH = `${dir}:${originalEnv.PATH ?? ""}`;
process.env.SEAL_USE_UPDATE_CACHE_FILE = join(dir, "update-cache.json");
process.env.SEAL_USE_MIRROR = "github";
globalThis.fetch = Object.assign(async () => new Response(JSON.stringify([
{ tag_name: "v100.0.0", assets: [] },
{ tag_name: "v99.0.0", assets: [] }
]), { headers: { "Content-Type": "application/json" } }), { preconnect: originalFetch.preconnect });
let stdout = "";
console.log = (message: string) => { stdout += message; };
const runtime = { appRoot: dir, entryFile: join(dir, "src", "cli.ts") };
await handleUpdateCommand(runtime, { checkOnly: true, targetVersion: "99.0.0" });
expect(JSON.parse(stdout)).toMatchObject({ mode: "binary", latestVersion: "99.0.0", updateAvailable: true });
stdout = "";
// Reaching asset selection proves explicit versions are not blocked by a removed installation mode.
await expect(handleUpdateCommand(runtime, { targetVersion: "v99.0.0" }))
.rejects.toThrow("in release v99.0.0");
expect(stdout).toBe("");
expect(existsSync(invoked)).toBe(false);
expect(readFileSync(binary, "utf8")).toBe("native fixture");
} finally {
process.execPath = originalExecPath;
process.env = originalEnv;
globalThis.fetch = originalFetch;
console.log = originalLog;
rmSync(dir, { recursive: true, force: true });
}
});
});