mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-31 14:51:02 +00:00
feat: adding api call for decky plugin
This commit is contained in:
@@ -1,17 +1,37 @@
|
||||
import { registerEvent } from "../register-event";
|
||||
import { logger } from "@main/services";
|
||||
import { logger, HydraApi } from "@main/services";
|
||||
import { HYDRA_DECKY_PLUGIN_LOCATION } from "@main/constants";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
interface DeckyReleaseInfo {
|
||||
version: string;
|
||||
downloadUrl: string;
|
||||
}
|
||||
|
||||
const getHydraDeckyPluginInfo = async (
|
||||
_event: Electron.IpcMainInvokeEvent
|
||||
): Promise<{
|
||||
installed: boolean;
|
||||
version: string | null;
|
||||
path: string;
|
||||
outdated: boolean;
|
||||
expectedVersion: string | null;
|
||||
}> => {
|
||||
try {
|
||||
// Fetch the expected version from API
|
||||
let expectedVersion: string | null = null;
|
||||
try {
|
||||
const releaseInfo = await HydraApi.get<DeckyReleaseInfo>(
|
||||
"/decky/release",
|
||||
{},
|
||||
{ needsAuth: false }
|
||||
);
|
||||
expectedVersion = releaseInfo.version;
|
||||
} catch (error) {
|
||||
logger.error("Failed to fetch Decky release info:", error);
|
||||
}
|
||||
|
||||
// Check if plugin folder exists
|
||||
if (!fs.existsSync(HYDRA_DECKY_PLUGIN_LOCATION)) {
|
||||
logger.log("Hydra Decky plugin not installed");
|
||||
@@ -19,6 +39,8 @@ const getHydraDeckyPluginInfo = async (
|
||||
installed: false,
|
||||
version: null,
|
||||
path: HYDRA_DECKY_PLUGIN_LOCATION,
|
||||
outdated: true,
|
||||
expectedVersion,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,6 +56,8 @@ const getHydraDeckyPluginInfo = async (
|
||||
installed: false,
|
||||
version: null,
|
||||
path: HYDRA_DECKY_PLUGIN_LOCATION,
|
||||
outdated: true,
|
||||
expectedVersion,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,12 +66,18 @@ const getHydraDeckyPluginInfo = async (
|
||||
const packageJson = JSON.parse(packageJsonContent);
|
||||
const version = packageJson.version;
|
||||
|
||||
logger.log(`Hydra Decky plugin installed, version: ${version}`);
|
||||
const outdated = expectedVersion ? version !== expectedVersion : false;
|
||||
|
||||
logger.log(
|
||||
`Hydra Decky plugin installed, version: ${version}, expected: ${expectedVersion}, outdated: ${outdated}`
|
||||
);
|
||||
|
||||
return {
|
||||
installed: true,
|
||||
version,
|
||||
path: HYDRA_DECKY_PLUGIN_LOCATION,
|
||||
outdated,
|
||||
expectedVersion,
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error("Failed to get plugin info:", error);
|
||||
@@ -55,6 +85,8 @@ const getHydraDeckyPluginInfo = async (
|
||||
installed: false,
|
||||
version: null,
|
||||
path: HYDRA_DECKY_PLUGIN_LOCATION,
|
||||
outdated: true,
|
||||
expectedVersion: null,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ const installHydraDeckyPlugin = async (
|
||||
success: false,
|
||||
path: HYDRA_DECKY_PLUGIN_LOCATION,
|
||||
currentVersion: null,
|
||||
expectedVersion: "0.0.3",
|
||||
expectedVersion: "unknown",
|
||||
error: errorMessage,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user