Skip to content

Commit

Permalink
initial rt_path and platforms crates split
Browse files Browse the repository at this point in the history
  • Loading branch information
blarfoon committed Dec 14, 2024
1 parent 80d5aa7 commit 977e5c5
Show file tree
Hide file tree
Showing 53 changed files with 612 additions and 553 deletions.
86 changes: 86 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions apps/desktop/__tests__/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,26 @@ test.describe("Init Tests", () => {
// set the CI environment variable to true
process.env.CI = "e2e"

// log process stdout and stderr
electronApp.process().stdout?.on("data", (data) => {
console.log(data.toString())
})
electronApp.process().stderr?.on("data", (data) => {
console.error(data.toString())
})

electronApp = await electron.launch({
args: [],
executablePath: await getBinaryPath(),
env: { ...process.env } as any
})

page = await electronApp.firstWindow()

electronApp.on("console", (msg) => {
console.log(msg.text())
electronApp.process().on("message", (message) => {
console.log(message)
})

page = await electronApp.firstWindow()

// capture errors
page.on("pageerror", (error) => {
console.error(JSON.stringify(error, null, 2))
Expand Down
2 changes: 2 additions & 0 deletions crates/carbon_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ display-info = "0.5.1"
# libc = { workspace = true }
nom = { workspace = true }
carbon_parsing = { path = "../carbon_parsing" }
carbon_rt_path = { path = "../carbon_rt_path" }
carbon_platforms = { path = "../carbon_platforms" }

[target.'cfg(windows)'.dependencies]
winreg = { workspace = true }
Expand Down
23 changes: 10 additions & 13 deletions crates/carbon_app/src/api/settings.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::str::FromStr;

use rspc::RouterBuilder;
use serde::{Deserialize, Serialize};
use specta::Type;

use super::{
modplatforms::{ModChannelWithUsage, ModPlatform, ModSources},
Set,
};
use crate::{
api::{
keys::settings::{
Expand All @@ -13,11 +11,10 @@ use crate::{
},
managers::App,
};

use super::{
modplatforms::{ModChannelWithUsage, ModPlatform, ModSources},
Set,
};
use rspc::RouterBuilder;
use serde::{Deserialize, Serialize};
use specta::Type;
use std::str::FromStr;

pub(super) fn mount() -> RouterBuilder<App> {
router! {
Expand Down Expand Up @@ -276,7 +273,7 @@ impl TryFrom<crate::db::app_configuration::Data> for FESettings {
auto_manage_java_system_profiles: data.auto_manage_java_system_profiles,
mod_sources: ModSources {
channels: {
use crate::domain::modplatforms::ModChannelWithUsage as DModChannelWithUsage;
use carbon_platforms::ModChannelWithUsage as DModChannelWithUsage;

let mut channels = DModChannelWithUsage::str_to_vec(&data.mod_channels)?;
DModChannelWithUsage::fixup_list(&mut channels);
Expand All @@ -290,7 +287,7 @@ impl TryFrom<crate::db::app_configuration::Data> for FESettings {
.mod_platform_blacklist
.split(",")
.filter(|p| !p.is_empty())
.map(crate::domain::modplatforms::ModPlatform::from_str)
.map(carbon_platforms::ModPlatform::from_str)
.map(|r| r.map(ModPlatform::from))
.collect::<Result<_, _>>()?,
},
Expand Down
17 changes: 13 additions & 4 deletions crates/carbon_app/src/domain/instance/info.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! Schema for instance jsons
use std::collections::HashSet;

use anyhow::bail;
use carbon_platforms::{ModPlatform, ModSources};
use chrono::{DateTime, Utc};

use crate::domain::modplatforms::{ModPlatform, ModSources};
use std::collections::HashSet;

#[derive(Debug, Clone)]
pub struct Instance {
Expand Down Expand Up @@ -145,3 +143,14 @@ impl Modpack {
}
}
}

impl From<ModLoaderType> for carbon_platforms::curseforge::ModLoaderType {
fn from(value: ModLoaderType) -> Self {
match value {
ModLoaderType::Neoforge => Self::NeoForge,
ModLoaderType::Forge => Self::Forge,
ModLoaderType::Fabric => Self::Fabric,
ModLoaderType::Quilt => Self::Quilt,
}
}
}
9 changes: 3 additions & 6 deletions crates/carbon_app/src/domain/instance/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use std::collections::HashMap;

use crate::domain::vtask::VisualTaskId;
use carbon_platforms::ModSources;
use chrono::{DateTime, Local, Utc};
use std::collections::HashMap;
use uuid::Uuid;

use crate::domain::vtask::VisualTaskId;

use super::modplatforms::ModSources;

pub mod info;

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
Expand Down
6 changes: 2 additions & 4 deletions crates/carbon_app/src/domain/minecraft/minecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use daedalus::minecraft::{
};
use std::{cmp::Ordering, collections::HashMap, path::PathBuf};

use crate::domain::{
java::JavaArch,
runtime_path::{AssetsPath, LibrariesPath, RuntimePath},
};
use crate::domain::java::JavaArch;
use carbon_rt_path::{AssetsPath, LibrariesPath, RuntimePath};

pub fn libraries_into_vec_downloadable(
libraries: &[Library],
Expand Down
3 changes: 0 additions & 3 deletions crates/carbon_app/src/domain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ pub mod instance;
pub mod java;
pub mod metrics;
pub mod minecraft;
pub mod modplatforms;
pub mod runtime_path;
pub mod url;
pub mod vtask;
19 changes: 0 additions & 19 deletions crates/carbon_app/src/domain/url.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
use std::{collections::HashMap, fs::File, io::Write, path::PathBuf, sync::Arc};

use anyhow::anyhow;
use tokio::sync::mpsc;
use tracing::trace;

use crate::{
api::translation::Translation,
domain::{
instance::{info::GameVersion, ExportEntry, InstanceId},
modplatforms::curseforge::manifest::{
Manifest, ManifestFileReference, Minecraft, ModLoaders,
},
vtask::VisualTaskId,
},
managers::{
Expand All @@ -20,6 +11,13 @@ use crate::{
AppInner,
},
};
use anyhow::anyhow;
use carbon_platforms::curseforge::manifest::{
Manifest, ManifestFileReference, Minecraft, ModLoaders,
};
use std::{collections::HashMap, fs::File, io::Write, path::PathBuf, sync::Arc};
use tokio::sync::mpsc;
use tracing::trace;

use crate::db::{mod_file_cache as fcdb, mod_metadata as metadb};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
use std::{collections::HashMap, fs::File, io::Write, path::PathBuf, sync::Arc};

use anyhow::anyhow;
use tokio::sync::mpsc;

use crate::{
api::translation::Translation,
domain::{
instance::{
info::{GameVersion, ModLoaderType},
ExportEntry, InstanceId,
},
modplatforms::modrinth::version::{
Hashes, ModpackIndex, ModrinthFile, ModrinthGame, ModrinthPackDependencies,
},
vtask::VisualTaskId,
},
managers::{
Expand All @@ -22,6 +14,12 @@ use crate::{
AppInner,
},
};
use anyhow::anyhow;
use carbon_platforms::modrinth::version::{
Hashes, ModpackIndex, ModrinthFile, ModrinthGame, ModrinthPackDependencies,
};
use std::{collections::HashMap, fs::File, io::Write, path::PathBuf, sync::Arc};
use tokio::sync::mpsc;

use crate::db::{mod_file_cache as fcdb, mod_metadata as metadb};

Expand Down
19 changes: 8 additions & 11 deletions crates/carbon_app/src/managers/instance/importer/curseforge.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
use std::path::PathBuf;
use std::sync::Arc;

use super::{
ImportScanStatus, ImportableInstance, ImporterState, InstanceImporter, InternalImportEntry,
InvalidImportEntry, GET_IMPORT_SCAN_STATUS,
};
use crate::api::translation::Translation;
use crate::domain::instance::info::{CurseforgeModpack, GameVersion, Modpack};
use crate::managers::instance::InstanceVersionSource;
use crate::managers::modplatforms::curseforge::convert_cf_version_to_standard_version;
use crate::managers::AppInner;
use crate::{domain::vtask::VisualTaskId, managers::instance::anyhow};
use carbon_platforms::curseforge::manifest::{Manifest, Minecraft, ModLoaders};
use serde::Deserialize;
use std::path::PathBuf;
use std::sync::Arc;
use tokio::sync::RwLock;
use tracing::{info, trace};

use crate::domain::modplatforms::curseforge::manifest::{Manifest, Minecraft, ModLoaders};

use super::{
ImportScanStatus, ImportableInstance, ImporterState, InstanceImporter, InternalImportEntry,
InvalidImportEntry, GET_IMPORT_SCAN_STATUS,
};

#[derive(Debug, Clone)]
struct Importable {
filename: String,
Expand Down Expand Up @@ -210,7 +207,7 @@ impl InstanceImporter for CurseforgeImporter {

trace!("Copying files from legacy instance");
// create copy-filter function in file utils for all importers
crate::domain::runtime_path::copy_dir_filter(&instance.path, &path, |path| {
carbon_rt_path::copy_dir_filter(&instance.path, &path, |path| {
match path.to_str() {
Some("minecraftinstance.json" | "manifest.json" | "modelist.html") => false,
Some(p) if p.starts_with("profileImage") => false,
Expand Down
Loading

0 comments on commit 977e5c5

Please sign in to comment.