Skip to content

Commit aa508df

Browse files
Fix issues in UI and compilation!
1 parent 8f89c58 commit aa508df

File tree

14 files changed

+87
-34
lines changed

14 files changed

+87
-34
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ModHost
22

33
![Contributions](./assets/contributions.svg)
4-
![Crates.io Version](https://img.shields.io/crates/v/modhost-api?style=for-the-badge)
5-
![Deployment Status](https://img.shields.io/github/actions/workflow/status/RedstoneWizard08/ModHost/deploy.yml?branch=main&style=for-the-badge&label=Deployment)
6-
![CLI Build Status](https://img.shields.io/github/actions/workflow/status/RedstoneWizard08/ModHost/cli-build.yml?branch=main&style=for-the-badge&label=CLI%20Build)
4+
![Crates.io Version](https://img.shields.io/crates/v/modhost-api?style=for-the-badge&labelColor=191d28)
5+
![Deployment Status](https://img.shields.io/github/actions/workflow/status/RedstoneWizard08/ModHost/deploy.yml?branch=main&style=for-the-badge&label=Deployment&labelColor=191d28)
6+
![CLI Build Status](https://img.shields.io/github/actions/workflow/status/RedstoneWizard08/ModHost/cli-build.yml?branch=main&style=for-the-badge&label=CLI%20Build&labelColor=191d28)
77
![Lines of Code](https://tokei.rs/b1/github/RedstoneWizard08/ModHost?style=for-the-badge&label=Lines+Of+Code)
88

99
A simple, open-source, and self-hostable place to host mods for any game!

apps/kjspkg-migrator/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# KJSPKG Migrator
2+
3+
A tool for migrating packages from the old [KJSPKG](https://github.com/Modern-Modpacks/kjspkg) to a new ModHost-based instance.
4+
5+
## Usage
6+
7+
1. Make sure to set `MIGRATOR_TOKEN` in `.env`. It's just a GitHub personal access token - it doesn't actually need permissions. It's only used for ratelimit purposes.
8+
2. Clear the database: `diesel migration redo -a`
9+
3. Run it: `cargo run --bin kjspkg-migrator`
10+
11+
Unfortunately, due to the nature of how old KJSPKG was set up, a couple of packages that no longer exist on GitHub yet still exist in the manifest won't be migrated. You'll see their error messages in the tool's output.

apps/kjspkg-migrator/src/migrator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ pub async fn run() -> Result<()> {
105105
slug: id.clone(),
106106
name: id.clone(),
107107
description: manifest.description,
108-
issues: Some(format!("https://github.com/{}/issues", repo)),
109-
source: Some(format!("https://github.com/{}", repo)),
110-
wiki: Some(format!("https://github.com/{}/wiki", repo)),
108+
issues: Some(format!("https://github.com/{}/{}/issues", owner, repo)),
109+
source: Some(format!("https://github.com/{}/{}", owner, repo)),
110+
wiki: Some(format!("https://github.com/{}/{}/wiki", owner, repo)),
111111
license: None,
112112
readme,
113113
tags: Vec::new(),

bun.lockb

768 Bytes
Binary file not shown.

crates/modhost-ui/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ readme.workspace = true
1111
[dependencies]
1212
ctrlc.workspace = true
1313
include_dir.workspace = true
14-
modhost-core.workspace = true
14+
jsglue.workspace = true
15+
modhost-core = { workspace = true, features = ["tempfile", "zip"] }
1516
modhost-config.workspace = true
1617
reqwest.workspace = true
18+
serde_json.workspace = true
1719
tempfile.workspace = true
1820
tokio.workspace = true
1921
tracing.workspace = true

crates/modhost-ui/src/bun.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use zip::ZipArchive;
1414
pub const BUN_REPO: &str = "https://github.com/oven-sh/bun";
1515

1616
/// The Bun version to download.
17-
pub const BUN_VERSION: &str = "bun-v1.1.36";
17+
pub const BUN_VERSION: &str = "bun-v1.1.43";
1818

1919
/// Get the base release URL for the download.
2020
pub fn get_base_url() -> String {

crates/modhost-ui/src/lib.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ pub const DEFAULT_FAVICON_PNG: &[u8] = include_bytes!("./assets/modhost.png");
2626
pub const UI_SOURCE: include_dir::Dir<'static> =
2727
include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../ui");
2828

29+
/// The embedded source for the API client.
30+
/// Yes, the entire source code is embedded in the binary.
31+
#[cfg(not(debug_assertions))]
32+
pub const API_SOURCE: include_dir::Dir<'static> =
33+
include_dir::include_dir!("$CARGO_MANIFEST_DIR/../../packages/modhost-api");
34+
2935
/// Build the frontend.
3036
/// In debug builds, this uses the config and a root path to the source
3137
/// to write the favicon files.
@@ -87,6 +93,7 @@ pub async fn build_ui(config: &AppConfig, dir: &PathBuf) -> Result<()> {
8793
/// path to the built UI. In debug builds this will return `()`.
8894
#[cfg(not(debug_assertions))]
8995
pub async fn build_ui(config: &AppConfig) -> Result<PathBuf> {
96+
use serde_json::Value;
9097
use tempfile::TempDir;
9198
use tokio::process::Command;
9299

@@ -100,9 +107,32 @@ pub async fn build_ui(config: &AppConfig) -> Result<PathBuf> {
100107
fs::create_dir_all(&dir)?;
101108
}
102109

103-
info!("Extracting to: {:?}", dir);
110+
let api_dir = dir.join("api");
111+
112+
if !api_dir.exists() {
113+
fs::create_dir_all(&api_dir)?;
114+
}
115+
116+
info!("Extracting to: {:?}...", dir);
104117

105118
UI_SOURCE.extract(&dir)?;
119+
API_SOURCE.extract(&api_dir)?;
120+
121+
info!("Fixing package.json...");
122+
123+
let pkg_json_path = dir.join("package.json");
124+
let mut pkg_json = serde_json::from_str::<Value>(&fs::read_to_string(&pkg_json_path)?)?;
125+
let pkg_json_obj = pkg_json.as_object_mut().unwrap();
126+
127+
// We need to add the workspaces key to fix dependency resolution issues
128+
pkg_json_obj.insert(
129+
"workspaces".into(),
130+
Value::Array(vec![Value::String("./api".into())]),
131+
);
132+
133+
fs::write(pkg_json_path, serde_json::to_string_pretty(&pkg_json)?)?;
134+
135+
info!("Checking icons...");
106136

107137
if config.ui.favicon_ico == "default" {
108138
info!("Downloading favicon.ico...");
@@ -159,7 +189,7 @@ pub async fn build_ui(config: &AppConfig) -> Result<PathBuf> {
159189
.wait()
160190
.await?;
161191

162-
info!("Running `bun run build`...");
192+
info!("Running `bun run dist`...");
163193

164194
Command::new(&bun_exe)
165195
.arg("--bun")

ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@skeletonlabs/skeleton": "^2.10.3",
2121
"@skeletonlabs/tw-plugin": "^0.4.0",
2222
"@sveltejs/adapter-static": "^3.0.6",
23-
"@sveltejs/kit": "^2.8.5",
23+
"@sveltejs/kit": "^2.15.3",
2424
"@sveltejs/vite-plugin-svelte": "^5.0.1",
2525
"@tailwindcss/forms": "^0.5.9",
2626
"@tailwindcss/typography": "^0.5.15",
@@ -37,7 +37,7 @@
3737
"tailwindcss": "^3.4.15",
3838
"tslib": "^2.8.1",
3939
"typescript": "^5.7.2",
40-
"vite": "^6.0.1"
40+
"vite": "^6.0.7"
4141
},
4242
"type": "module",
4343
"dependencies": {

ui/src/routes/new/+page.svelte

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
<p class="text-primary-500 mb-2 flex flex-row items-center justify-start">
8383
<Icon icon="tabler:plus" height="24" class="mr-2" />
84-
Create Package
84+
Package Creation
8585
</p>
8686

8787
{#snippet buttonComplete(locked: boolean, clickHandler: () => void)}
@@ -127,40 +127,48 @@
127127

128128
<div class="flex h-full w-full flex-row items-start justify-start">
129129
<div
130-
class="bg-surface-600 mr-4 flex h-full w-[40%] max-w-[40%] flex-col items-start justify-start overflow-scroll rounded-xl p-2 px-3"
130+
class="bg-primary-500 bg-opacity-20 mr-4 flex h-full w-[40%] max-w-[40%] flex-col items-start justify-start overflow-scroll rounded-xl p-2 px-3 space-y-1"
131131
>
132132
<p class="border-b-primary-700 mb-1 w-full border-b py-1 text-lg font-bold">
133133
Package Overview
134134
</p>
135-
<p>
135+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
136+
<Icon icon="tabler:tag" height="24" />
136137
<span class="font-bold">Display Name:</span>
137138
<span>{name == "" ? "Unset" : name}</span>
138139
</p>
139-
<p>
140+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
141+
<Icon icon="tabler:link" height="24" />
140142
<span class="font-bold">Slug:</span>
141143
<span>{slug == "" ? "Unset" : slug}</span>
142144
</p>
143-
<p>
145+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
146+
<Icon icon="tabler:info-circle" height="24" />
144147
<span class="font-bold">Description:</span>
145148
<span>{description == "" ? "Unset" : description}</span>
146149
</p>
147-
<p>
150+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
151+
<Icon icon="tabler:code" height="24" />
148152
<span class="font-bold">Repository:</span>
149153
<span>{repo == "" ? "Unset" : repo}</span>
150154
</p>
151-
<p>
155+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
156+
<Icon icon="tabler:exclamation-circle" height="24" />
152157
<span class="font-bold">Issues:</span>
153158
<span>{issues == "" ? "Unset" : issues}</span>
154159
</p>
155-
<p>
160+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
161+
<Icon icon="tabler:world" height="24" />
156162
<span class="font-bold">Wiki:</span>
157163
<span>{wiki == "" ? "Unset" : wiki}</span>
158164
</p>
159-
<p>
165+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
166+
<Icon icon="tabler:license" height="24" />
160167
<span class="font-bold">License:</span>
161168
<span>{license == "" ? "Unset" : license}</span>
162169
</p>
163-
<p>
170+
<p class="flex flex-row items-center justify-start flex-wrap space-x-1">
171+
<Icon icon="tabler:eye" height="24" />
164172
<span class="font-bold">Visibility:</span>
165173
<span>{visibility}</span>
166174
</p>

0 commit comments

Comments
 (0)