mirror of
https://github.com/ivabus/gui
synced 2025-04-23 14:07:14 +03:00
* #246 #247 include all installed versions of package in GuiPackage.installed_versions --------- Co-authored-by: neil <neil@neils-MacBook-Pro.local>
This commit is contained in:
parent
beb882eef5
commit
076dd1d4eb
3 changed files with 10 additions and 5 deletions
|
@ -31,7 +31,6 @@ export async function getInstalledPackages() {
|
|||
|
||||
const pkgs = folders
|
||||
.map((p: string) => p.split(".tea/")[1])
|
||||
.filter((p: string) => !p.includes("tea.xyz"))
|
||||
.map((p: string) => {
|
||||
const path = p.trim().split("/");
|
||||
const version = path.pop();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
* - connect to a local platform api and returns a data
|
||||
*/
|
||||
|
||||
import semverCompare from "semver/functions/compare";
|
||||
import type { Package, Review, AirtablePost, Bottle } from "@tea/ui/types";
|
||||
import type { GUIPackage, Course, Category, DeviceAuth, Session } from "./types";
|
||||
|
||||
|
@ -28,12 +29,17 @@ export async function getPackages(): Promise<GUIPackage[]> {
|
|||
ipcRenderer.invoke("get-installed-packages") as { version: string; full_name: string }[]
|
||||
]);
|
||||
|
||||
// sorts all packages from highest -> lowest
|
||||
installedPackages.sort((a, b) => semverCompare(b.version, a.version));
|
||||
|
||||
return (packages || []).map((pkg) => {
|
||||
const found = installedPackages.find((p) => p.full_name === pkg.full_name);
|
||||
const installedVersions = installedPackages
|
||||
.filter((p) => p.full_name === pkg.full_name)
|
||||
.map((p) => p.version);
|
||||
return {
|
||||
...pkg,
|
||||
state: found ? PackageStates.INSTALLED : PackageStates.AVAILABLE,
|
||||
installed_version: found ? found.version : ""
|
||||
state: installedVersions.length ? PackageStates.INSTALLED : PackageStates.AVAILABLE,
|
||||
installed_versions: installedVersions
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ export enum PackageStates {
|
|||
|
||||
export type GUIPackage = Package & {
|
||||
state: PackageStates;
|
||||
installed_version?: string;
|
||||
installed_versions?: string[];
|
||||
synced?: boolean;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue