aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/Cargo.lock15
-rw-r--r--src-tauri/Cargo.toml1
-rw-r--r--src-tauri/bindings/NorthstarThunderstoreRelease.ts3
-rw-r--r--src-tauri/bindings/NorthstarThunderstoreReleaseWrapper.ts4
-rw-r--r--src-tauri/src/main.rs58
5 files changed, 74 insertions, 7 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 6e02854f..aec72631 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -101,6 +101,7 @@ dependencies = [
"pretty_env_logger",
"regex",
"reqwest",
+ "semver 1.0.17",
"sentry",
"sentry-log",
"serde",
@@ -3395,7 +3396,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
- "semver 1.0.16",
+ "semver 1.0.17",
]
[[package]]
@@ -3556,9 +3557,9 @@ dependencies = [
[[package]]
name = "semver"
-version = "1.0.16"
+version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a"
+checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed"
dependencies = [
"serde",
]
@@ -4209,7 +4210,7 @@ dependencies = [
"raw-window-handle",
"regex",
"rfd",
- "semver 1.0.16",
+ "semver 1.0.17",
"serde",
"serde_json",
"serde_repr",
@@ -4243,7 +4244,7 @@ dependencies = [
"cargo_toml",
"heck 0.4.1",
"json-patch",
- "semver 1.0.16",
+ "semver 1.0.17",
"serde",
"serde_json",
"tauri-utils",
@@ -4266,7 +4267,7 @@ dependencies = [
"proc-macro2",
"quote",
"regex",
- "semver 1.0.16",
+ "semver 1.0.17",
"serde",
"serde_json",
"sha2",
@@ -4362,7 +4363,7 @@ dependencies = [
"phf 0.10.1",
"proc-macro2",
"quote",
- "semver 1.0.16",
+ "semver 1.0.17",
"serde",
"serde_json",
"serde_with",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 95df7208..df583658 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -66,6 +66,7 @@ zip-extract = "0.1.2"
open = "3.2.0"
# Windows API stuff
winapi = "0.3.9"
+semver = "1.0"
[features]
# by default Tauri runs in production mode
diff --git a/src-tauri/bindings/NorthstarThunderstoreRelease.ts b/src-tauri/bindings/NorthstarThunderstoreRelease.ts
new file mode 100644
index 00000000..4e9d5235
--- /dev/null
+++ b/src-tauri/bindings/NorthstarThunderstoreRelease.ts
@@ -0,0 +1,3 @@
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+
+export interface NorthstarThunderstoreRelease { package: string, version: string, } \ No newline at end of file
diff --git a/src-tauri/bindings/NorthstarThunderstoreReleaseWrapper.ts b/src-tauri/bindings/NorthstarThunderstoreReleaseWrapper.ts
new file mode 100644
index 00000000..77593816
--- /dev/null
+++ b/src-tauri/bindings/NorthstarThunderstoreReleaseWrapper.ts
@@ -0,0 +1,4 @@
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+import type { NorthstarThunderstoreRelease } from "./NorthstarThunderstoreRelease";
+
+export interface NorthstarThunderstoreReleaseWrapper { label: string, value: NorthstarThunderstoreRelease, } \ No newline at end of file
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index df13cfb9..b6c923e3 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -33,8 +33,25 @@ use northstar::get_northstar_version_number;
mod thunderstore;
use thunderstore::query_thunderstore_packages_api;
+use semver::Version;
+use serde::{Deserialize, Serialize};
use tauri::{Manager, Runtime};
use tokio::time::sleep;
+use ts_rs::TS;
+
+#[derive(Serialize, Deserialize, Debug, Clone, TS)]
+#[ts(export)]
+struct NorthstarThunderstoreRelease {
+ package: String,
+ version: String,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone, TS)]
+#[ts(export)]
+struct NorthstarThunderstoreReleaseWrapper {
+ label: String,
+ value: NorthstarThunderstoreRelease,
+}
#[derive(Default)]
struct Counter(Arc<Mutex<i32>>);
@@ -139,6 +156,7 @@ fn main() {
github::pull_requests::apply_mods_pr,
github::pull_requests::get_launcher_download_link,
close_application,
+ get_available_northstar_versions,
])
.run(tauri::generate_context!())
{
@@ -469,6 +487,46 @@ async fn close_application<R: Runtime>(app: tauri::AppHandle<R>) -> Result<(), S
Ok(())
}
+/// Gets list of available Northstar versions from Thunderstore
+#[tauri::command]
+async fn get_available_northstar_versions() -> Result<Vec<NorthstarThunderstoreReleaseWrapper>, ()>
+{
+ let northstar_package_name = "Northstar";
+ let index = thermite::api::get_package_index().unwrap().to_vec();
+ let nsmod = index
+ .iter()
+ .find(|f| f.name.to_lowercase() == northstar_package_name.to_lowercase())
+ .ok_or_else(|| panic!("Couldn't find Northstar on thunderstore???"))
+ .unwrap();
+
+ let mut releases: Vec<NorthstarThunderstoreReleaseWrapper> = vec![];
+ for (_version_string, nsmod_version_obj) in nsmod.versions.iter() {
+ let current_elem = NorthstarThunderstoreRelease {
+ package: nsmod_version_obj.name.clone(),
+ version: nsmod_version_obj.version.clone(),
+ };
+ let current_elem_wrapped = NorthstarThunderstoreReleaseWrapper {
+ label: format!(
+ "{} v{}",
+ nsmod_version_obj.name.clone(),
+ nsmod_version_obj.version.clone()
+ ),
+ value: current_elem,
+ };
+
+ releases.push(current_elem_wrapped);
+ }
+
+ releases.sort_by(|a, b| {
+ // Parse version number
+ let a_ver = Version::parse(&a.value.version).unwrap();
+ let b_ver = Version::parse(&b.value.version).unwrap();
+ b_ver.partial_cmp(&a_ver).unwrap() // Sort newest first
+ });
+
+ Ok(releases)
+}
+
/// Returns a serde json object of the parsed `enabledmods.json` file
pub fn get_enabled_mods(game_install: &GameInstall) -> Result<serde_json::value::Value, String> {
let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path);