fix(update-center): load aptss updates reliably

This commit is contained in:
2026-04-16 13:32:23 +08:00
parent 0b784af3d7
commit 309b9bc003
8 changed files with 233 additions and 14 deletions
@@ -11,7 +11,7 @@ type RemoteStoreResponse =
| Array<Record<string, unknown>>;
const APTSS_LIST_UPGRADABLE_KEY =
"bash -lc env LANGUAGE=en_US /usr/bin/apt -c /opt/durapps/spark-store/bin/apt-fast-conf/aptss-apt.conf list --upgradable -o Dir::Etc::sourcelist=/opt/durapps/spark-store/bin/apt-fast-conf/sources.list.d/aptss.list -o Dir::Etc::sourceparts=/dev/null -o APT::Get::List-Cleanup=0";
"bash -lc env LANGUAGE=en_US aptss list --upgradable";
const DPKG_QUERY_INSTALLED_KEY =
"dpkg-query -W -f=${Package}\t${db:Status-Want} ${db:Status-Status} ${db:Status-Eflag}\n";
@@ -28,6 +28,25 @@ describe("update-center query", () => {
]);
});
it("parses aptss wrapper output with ansi noise before package lines", () => {
const output = [
"\u001b[1;32m信息:正在使用非 Root 权限模式启动!若出现问题,请尝试使用 Root 权限执行命令。\u001b[0m",
"正在列表...",
"spark-weather/stable 2.0.0 amd64 [upgradable from: 1.9.0]",
"",
].join("\n");
expect(parseAptssUpgradableOutput(output)).toEqual([
{
pkgname: "spark-weather",
source: "aptss",
currentVersion: "1.9.0",
nextVersion: "2.0.0",
arch: "amd64",
},
]);
});
it("parses the legacy from variant in upgradable output", () => {
const aptssOutput = "spark-clock/stable 1.2.0 amd64 [from: 1.1.0]";
const apmOutput = "spark-player/main 2.0.0 amd64 [from: 1.5.0]";
@@ -69,6 +69,18 @@ describe("updateCenter store", () => {
expect(store.filteredItems.value).toEqual(snapshot.items);
});
it("reuses the last store filter when refreshing without an explicit filter", async () => {
const snapshot = createSnapshot();
open.mockResolvedValue(snapshot);
refresh.mockResolvedValue(snapshot);
const store = createUpdateCenterStore();
await store.open("apm");
await store.refresh();
expect(refresh).toHaveBeenCalledWith("apm");
});
it("starts only the selected non-ignored items", async () => {
const snapshot = createSnapshot({
items: [