Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/core #5

Merged
merged 23 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "🟧 Backend"
on:
pull_request:
branches: [ dev ]
paths:
- 'src-tauri/**'
- 'crates/**'
- 'Cargo.*'

jobs:
check:
name: "⚙️ Check"
strategy:
fail-fast: false
matrix:
platform: [ ubuntu-20.04, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- if: matrix.platform == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- run: yarn --immutable
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "🟦 Frontend"
on:
pull_request:
branches: [ dev ]
paths:
- 'app/**'
- 'shared/**'
- '.yarn/**'
- '.pnp.*'
- '.yarnrc.yml'
- 'package.json'
- 'tsconfig.json'
- 'yarn.lock'

jobs:
lint:
name: "⚠️ Lint"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 19.x
- run: yarn --immutable
- run: yarn lint
typecheck:
name: "💯 Typecheck"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 19.x
- run: yarn --immutable
- run: yarn typecheck
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Minecraft
minecraft
19 changes: 19 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
imports_granularity = "One"
tab_spaces = 2
indent_style = "Block"
merge_derives = true
max_width = 100
newline_style = "Unix"
edition = "2021"
reorder_impl_items = true
reorder_modules = true
reorder_imports = true
trailing_comma = "Vertical"
trailing_semicolon = true
type_punctuation_density = "Wide"
use_field_init_shorthand = true
use_try_shorthand = true
wrap_comments = true
imports_layout = "Vertical"
skip_children = false
format_macro_matchers = true
1,288 changes: 666 additions & 622 deletions .yarn/releases/yarn-remote.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[workspace]
resolver = "2"
members = [
"src-tauri",
"crates/common",
"crates/launcher",
"crates/providers/mojang",
"crates/download",
]
3 changes: 3 additions & 0 deletions app/entrypoint/dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**
!.gitignore
!.gitkeep
Empty file added app/entrypoint/dist/.gitkeep
Empty file.
9 changes: 7 additions & 2 deletions app/entrypoint/main.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { createRoot } from 'react-dom/client'
import { createRoot } from 'react-dom/client'

createRoot(document.getElementById('root')!).render('Hello')
import { withProviders } from '@app/providers'
import { Root } from '@app/root'

const RootWithProviders = withProviders(Root)

createRoot(document.getElementById('root')!).render(<RootWithProviders />)
15 changes: 11 additions & 4 deletions app/entrypoint/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{
"name": "@app/entrypoint",
"type": "module",
"dependencies": {
"@app/providers": "workspace:",
"@app/root": "workspace:",
"@emotion/react": "11.11.1"
},
"devDependencies": {
"@tauri-apps/api": "1.5.1",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@vitejs/plugin-react": "4.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"vite": "4.5.0"
"@vitejs/plugin-react": "4.2.0",
"react": "canary",
"react-dom": "canary",
"vite": "5.0.0"
}
}
27 changes: 14 additions & 13 deletions app/entrypoint/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite"

import react from "@vitejs/plugin-react"

// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [react()],
plugins: [react()],

// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
}
}));
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
},
}))
14 changes: 14 additions & 0 deletions app/providers/mod.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { FC } from 'react'

import { withRouter } from './with-router.tsx'
import { withTheme } from './with-theme.tsx'

function apply<T, R>(target: T, fn: (t: T) => R) {
return fn(target)
}

const providers = [withRouter, withTheme]

export function withProviders(component: FC) {
return providers.reduce(apply, component)
}
16 changes: 16 additions & 0 deletions app/providers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@app/providers",
"type": "module",
"main": "mod.tsx",
"dependencies": {
"@theme/provider": "workspace:",
"react-router-dom": "6.19.0"
},
"devDependencies": {
"@types/react": "18.2.37"
},
"peerDependencies": {
"react": "*",
"react-dom": "*"
}
}
13 changes: 13 additions & 0 deletions app/providers/with-router.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FC } from 'react'

import { MemoryRouter } from 'react-router-dom'

export function withRouter(Component: FC) {
return function () {
return (
<MemoryRouter>
<Component />
</MemoryRouter>
)
}
}
13 changes: 13 additions & 0 deletions app/providers/with-theme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FC } from 'react'

import { ThemeProvider } from '@theme/provider'

export function withTheme(Component: FC) {
return function () {
return (
<ThemeProvider>
<Component />
</ThemeProvider>
)
}
}
3 changes: 3 additions & 0 deletions app/root/mod.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function Root() {
return 'Hello!'
}
13 changes: 13 additions & 0 deletions app/root/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "@app/root",
"type": "module",
"main": "mod.tsx",
"devDependencies": {
"@types/react": "18.2.37"
},
"peerDependencies": {
"@emotion/react": "*",
"react": "*",
"react-dom": "*"
}
}
11 changes: 11 additions & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "common"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde = { version = "1.0.192", features = ["derive"] }
url = { version = "2.4.1", features = ["serde"] }
regex = "1.10.2"
17 changes: 17 additions & 0 deletions crates/common/src/env/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use {
serde::{
Deserialize,
Serialize,
},
std::path::PathBuf,
};

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Env {
pub jre_bin: PathBuf,
pub versions_dir: PathBuf,
pub lib_dir: PathBuf,
pub natives_dir: PathBuf,
pub assets_dir: PathBuf,
}
78 changes: 78 additions & 0 deletions crates/common/src/jre/all.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
use {
serde::Deserialize,
std::collections::HashMap,
};

#[derive(Debug, Deserialize, PartialEq, Eq, Hash)]
pub enum Target {
#[serde(rename = "gamecore")]
GameCore,
#[serde(rename = "linux")]
Linux,
#[serde(rename = "linux-i386")]
LinuxI386,
#[serde(rename = "mac-os")]
Macos,
#[serde(rename = "mac-os-arm64")]
MacosArm64,
#[serde(rename = "windows-arm64")]
WindowsArm64,
#[serde(rename = "windows-x64")]
WindowsX64,
#[serde(rename = "windows-x86")]
WindowsX86,
}

#[derive(Debug, Deserialize, PartialEq, Eq, Hash)]
#[serde(rename_all = "kebab-case")]
pub enum ComponentType {
JavaRuntimeAlpha,
JavaRuntimeBeta,
JavaRuntimeGamma,
JavaRuntimeGammaSnapshot,
JreLegacy,
MinecraftJavaExe,
}

impl ComponentType {
#[allow(clippy::should_implement_trait)]
pub fn from_str(value: &str) -> Option<ComponentType> {
match value {
"java-runtime-alpha" => Some(Self::JavaRuntimeAlpha),
"java-runtime-beta" => Some(Self::JavaRuntimeBeta),
"java-runtime-gamma" => Some(Self::JavaRuntimeGamma),
"java-runtime-gamma-snapshot" => Some(Self::JavaRuntimeGammaSnapshot),
"jre-legacy" => Some(Self::JreLegacy),
"minecraft-java-exe" => Some(Self::MinecraftJavaExe),
_ => None,
}
}
}

#[derive(Debug, Deserialize)]
pub struct Manifest {
pub sha1: String,
pub size: u32,
pub url: String,
}

#[derive(Debug, Deserialize)]
pub struct Availability {
pub group: u32,
pub progress: u32,
}

#[derive(Debug, Deserialize)]
pub struct Version {
pub name: String,
pub released: String,
}

#[derive(Debug, Deserialize)]
pub struct Component {
pub availability: Availability,
pub manifest: Manifest,
pub version: Version,
}

pub type JavaRuntime = HashMap<Target, HashMap<ComponentType, Vec<Component>>>;
39 changes: 39 additions & 0 deletions crates/common/src/jre/manifest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use url::Url;
use {
serde::Deserialize,
std::{
collections::HashMap,
path::PathBuf,
},
};

#[derive(Debug, Deserialize)]
pub struct File {
pub sha1: String,
pub size: u64,
pub url: Url,
}

#[derive(Debug, Deserialize)]
pub struct Downloads {
pub lzma: Option<File>,
pub raw: File,
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "lowercase", tag = "type")]
pub enum Entry {
Link,
Directory,
File {
executable: bool,
downloads: Downloads,
},
}

pub type Files = HashMap<PathBuf, Entry>;

#[derive(Debug, Deserialize)]
pub struct Manifest {
pub files: Files,
}
Loading