fix(update-center): handle missing apm and restore scrolling

This commit is contained in:
2026-04-16 11:11:06 +08:00
parent 120233cf56
commit e1ec526cb9
4 changed files with 41 additions and 35 deletions
+11 -33
View File
@@ -49,21 +49,6 @@ interface RemoteCategoryAppEntry {
const REMOTE_STORE_BASE_URL = "https://erotica.spark-app.store";
const categoryCache = new Map<string, Promise<StoreAppMetadataMap>>();
const isAptssAvailable = async (): Promise<boolean> => {
return await new Promise((resolve) => {
const child = spawn("command", ["-v", "aptss"], {
shell: false,
env: process.env,
});
child.on("close", (code) => {
resolve(code === 0);
});
child.on("error", () => {
resolve(false);
});
});
};
const APTSS_LIST_UPGRADABLE_COMMAND = {
command: "bash",
args: [
@@ -367,26 +352,23 @@ const enrichItemIcons = (items: UpdateCenterItem[]): UpdateCenterItem[] => {
export const loadUpdateCenterItems = async (
runCommand: UpdateCenterCommandRunner = runCommandCapture,
): Promise<UpdateCenterLoadItemsResult> => {
const aptssAvailable = await isAptssAvailable();
const [aptssResult, apmResult, aptssInstalledResult, apmInstalledResult] =
await Promise.all([
aptssAvailable
? runCommand(
APTSS_LIST_UPGRADABLE_COMMAND.command,
APTSS_LIST_UPGRADABLE_COMMAND.args,
)
: Promise.resolve({ code: 0, stdout: "", stderr: "" }),
runCommand(
APTSS_LIST_UPGRADABLE_COMMAND.command,
APTSS_LIST_UPGRADABLE_COMMAND.args,
),
runCommand("apm", ["list", "--upgradable"]),
aptssAvailable
? runCommand(
DPKG_QUERY_INSTALLED_COMMAND.command,
DPKG_QUERY_INSTALLED_COMMAND.args,
)
: Promise.resolve({ code: 0, stdout: "", stderr: "" }),
runCommand(
DPKG_QUERY_INSTALLED_COMMAND.command,
DPKG_QUERY_INSTALLED_COMMAND.args,
),
runCommand("apm", ["list", "--installed"]),
]);
const aptssAvailable =
aptssResult.code === 0 || aptssInstalledResult.code === 0;
const warnings = [
aptssAvailable
? getCommandError("aptss upgradable query", aptssResult)
@@ -405,10 +387,6 @@ export const loadUpdateCenterItems = async (
const apmItems =
apmResult.code === 0 ? parseApmUpgradableOutput(apmResult.stdout) : [];
if (apmResult.code !== 0) {
throw new Error(warnings.join("; "));
}
const installedSources = buildInstalledSourceMap(
aptssAvailable && aptssInstalledResult.code === 0
? aptssInstalledResult.stdout