Skip to content

Commit

Permalink
chore: Remove packageManager requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
LynithDev committed Dec 1, 2024
1 parent bda3b8b commit 471f5e8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
12 changes: 9 additions & 3 deletions apps/frontend/src/ui/pages/browser/BrowserMain.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ManagedPackage, Providers } from '@onelauncher/client/bindings';
import type { Providers } from '@onelauncher/client/bindings';
import { ChevronRightIcon } from '@untitled-theme/icons-solid';
import OneConfigLogo from '~assets/logos/oneconfig.svg?component-solid';
import Button from '~ui/components/base/Button';
Expand All @@ -21,7 +21,7 @@ function BrowserMain() {
<BrowserContent>
<div class="flex flex-col gap-8">
<Show when={browser.popularPackages() !== undefined && browser.featuredPackage() !== undefined}>
<Featured package={browser.featuredPackage()!} />
<Featured package={browser.featuredPackage()! as unknown as FeaturedProps['package']} />

<For each={Object.entries(browser.popularPackages()!)}>
{([provider, results]) => (
Expand All @@ -40,7 +40,13 @@ function BrowserMain() {
}

interface FeaturedProps {
package: ManagedPackage;
package: {
title: string;
description: string;
id: string;
provider: Providers;
oneconfig: boolean;
};
}

function Featured(props: FeaturedProps) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"version": "1.0.0-alpha.1",
"private": true,
"engineStrict": true,
"packageManager": "[email protected]",
"description": "Next-generation open source Minecraft launcher and tools for interacting with Polyfrost",
"license": "GPL-3.0-only",
"homepage": "https://polyfrost.org",
Expand Down
22 changes: 20 additions & 2 deletions packages/core/src/api/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,27 @@ pub async fn filter_java_version(java_version: Option<u32>) -> crate::Result<Vec
}

#[derive(Deserialize)]
struct JavaPackage {
pub struct JavaZuluPackage {
pub download_url: String,
pub name: PathBuf,
pub java_version: Vec<u32>,
}

pub async fn fetch_zulu() -> crate::Result<Vec<JavaZuluPackage>> {
let state = State::get().await?;

fetch_json::<Vec<JavaZuluPackage>>(
Method::GET,
&format!(
"https://api.azul.com/metadata/v1/zulu/packages/?os={}&arch={}&archive_type=zip&java_package_type=jre&javafx_bundled=false&latest=true&release_status=ga&availability_types=CA&certifications=tck&page=1&page_size=100",
std::env::consts::OS,
std::env::consts::ARCH,
),
None,
None,
&state.fetch_semaphore,
)
.await
}

// TODO: support more than just zulu ?
Expand All @@ -44,7 +62,7 @@ pub async fn install_java(java_version: u32) -> crate::Result<PathBuf> {
.await?;

send_ingress(&ingress, 0.0, Some("fetching java api")).await?;
let packages = fetch_json::<Vec<JavaPackage>>(Method::GET, &format!(
let packages = fetch_json::<Vec<JavaZuluPackage>>(Method::GET, &format!(
"https://api.azul.com/metadata/v1/zulu/packages?arch={}&java_version={}&os={}&archive_type=zip&javafx_bundled=false&java_package_type=jre&page_size=1",
std::env::consts::ARCH, java_version, std::env::consts::OS,
), None, None, &state.fetch_semaphore).await?;
Expand Down

0 comments on commit 471f5e8

Please sign in to comment.