Skip to content
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
13 changes: 13 additions & 0 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
with:
command: check
Expand All @@ -41,6 +42,18 @@ jobs:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- run: |
sudo apt update
sudo apt install libwebkit2gtk-4.0-dev \
build-essential \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
with:
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ members = [
"libra",
"vault",
"neptune",
"lunar/src-tauri",
]
default-members = ["mega", "libra"]
exclude = ["craft"]
resolver = "1"

Expand All @@ -25,7 +27,7 @@ callisto = { path = "jupiter/callisto" }
gemini = { path = "gemini" }
vault = { path = "vault" }
neptune = { path = "neptune" }

mega = { path = "mega" }
anyhow = "1.0.86"
serde = "1.0.203"
serde_json = "1.0.117"
Expand Down
8 changes: 8 additions & 0 deletions lunar/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
// "trailingComma": "es5",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
// "useTabs": false
}
19 changes: 18 additions & 1 deletion lunar/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
## Lunar Module
## Lunar Module

## bundle

Because Lunar depends on Mega, which in turn relies on Neptune’s dynamic library pipy, it’s important to handle libpipy carefully during compilation.

### Linux

- deb

Currently, on Linux Debian, you can complete the compilation directly using cargo tauri build -b deb.

- AppImage

However, compilation for AppImage will fail. After encountering the error “libpipy.so Not found” when executing `cargo tauri build -b appimage,` you need to manually copy `target/release/libpipy.so` to the `target/release/bundle/appimage/lunar.AppDir/usr/bin` folder and then manually execute `target/release/bundle/appimage/build_appimage.sh`.

> [!NOTE]
> If you use archlinux to bundle, according to [\[bug\]\[linuxdeploy\] Linux AppImage script fails](https://github.com/tauri-apps/tauri/issues/8929), you may need to run build with `NO_STRIP=true cargo tauri **`.
1 change: 1 addition & 0 deletions lunar/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const nextConfig = {
reactStrictMode: true,
output: "export",
transpilePackages: [
// antd & deps
// https://github.com/vercel/next.js/issues/65707
Expand Down
1 change: 1 addition & 0 deletions lunar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@headlessui/tailwindcss": "^0.2.1",
"@heroicons/react": "^2.1.3",
"@tailwindcss/forms": "^0.5.7",
"@tauri-apps/api": "^1.6.0",
"clsx": "^2.1.1",
"framer-motion": "^11.3.2",
"next": "14.2.3",
Expand Down
3 changes: 3 additions & 0 deletions lunar/src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Generated by Cargo
# will have compiled files and executables
/target/
26 changes: 26 additions & 0 deletions lunar/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "lunar-tauri"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.60"

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

[build-dependencies]
tauri-build = { version = "1.5.3", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.7.0", features = [] }
mega = { workspace = true }

[features]
# this feature is used for production builds or when `devPath` points to the filesystem and the built-in dev server is disabled.
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
11 changes: 11 additions & 0 deletions lunar/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main() {
#[cfg(target_os = "linux")]
println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-arg=-Wl,-rpath,@executable_path");

// only for githut action check, according to [[feat] Prevent error when distDir doesn't exist](https://github.com/tauri-apps/tauri/issues/3142)
// ../out is the default distDir
std::fs::create_dir_all("../out").expect("failed to create out directory");
tauri_build::build()
}
90 changes: 90 additions & 0 deletions lunar/src-tauri/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Filling the following environment variables with values you set
## Logging Configuration
[log]
# The path which log file is saved
log_path = "/tmp/.mega/logs"

# log level
level = "debug"

# print std log in console, disable it on production for performance
print_std = true


[database]
# "sqlite" | "postgres"
# "sqlite" will use `db_path` and ignore `db_url`
db_type = "sqlite"

# used for sqlite
db_path = "./lunar-mega.db"

# database connection url
db_url = "postgres://mega:mega@localhost:5432/mega"

# db max connection, setting it to twice the number of CPU cores would be appropriate.
max_connection = 32

# db min connection, setting it to the number of CPU cores would be appropriate.
min_connection = 16

# Whether to disabling SQLx Log
sqlx_logging = false


[ssh]
ssh_key_path = "/tmp/.mega/ssh"

[storage]
# raw object stroage type, can be `local` or `remote`
raw_obj_storage_type = "LOCAL"

## If the object file size exceeds the threshold value, it will be handled by file storage instead of the database, Unit is KB
big_obj_threshold = 1024

# set the local path of the project storage
raw_obj_local_path = "/tmp/.mega/objects"

lfs_obj_local_path = "/tmp/.mega/lfs"

obs_access_key = ""
obs_secret_key = ""

# cloud storage region
obs_region = "cn-east-3"

# Override the endpoint URL used for remote storage services
obs_endpoint = "https://obs.cn-east-3.myhuaweicloud.com"


[monorepo]
## Only import directory support multi-branch commit and tag, monorepo only support main branch
## Mega treats files under this directory as import repo and other directories as monorepo
import_dir = "/third-part"


[pack]
# The maximum memory used by decode, Unit is GB
pack_decode_mem_size = 4

# The location where the object stored when the memory used by decode exceeds the limit
pack_decode_cache_path = "/tmp/.mega/cache"

clean_cache_after_decode = true

# The maximum meesage size in channel buffer while decode
channel_message_size = 1_000_000


[ztm]
ca = "http://127.0.0.1:9999"
hub = "http://127.0.0.1:8888"
agent = "http://127.0.0.1:7777"

[lfs]
## IMPORTANT: The 'enable_split' feature can only be enabled for new databases. Existing databases do not support this feature.
# Enable or disable splitting large files into smaller chunks
enable_split = true # Default is disabled. Set to true to enable file splitting.

# Size of each file chunk when splitting is enabled, in bytes. Ignored if splitting is disabled.
split_size = 20971520 # Default size is 20MB (20971520 bytes)
Binary file added lunar/src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/128x128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square107x107Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square142x142Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square284x284Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square310x310Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square71x71Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/Square89x89Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lunar/src-tauri/icons/icon.icns
Binary file not shown.
Binary file added lunar/src-tauri/icons/icon.ico
Binary file not shown.
Binary file added lunar/src-tauri/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions lunar/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

#[tauri::command]
fn hello_string(name: &str) -> String {
format!("Hello from Rust, {}!", name)
}

fn start_mega(config_path: &str) {
let args_str = format!("-c \"{}\" service http", config_path);
let args = args_str.split(' ').collect();
mega::cli::parse(Some(args)).expect("failed to start mega");
}

fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![hello_string])
.setup(|app| {
let resource_path = app
.path_resolver()
.resolve_resource("config.toml")
.expect("failed to resolve config.toml resource");
std::thread::spawn(move || {
start_mega(resource_path.to_str().unwrap());
});
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
74 changes: 74 additions & 0 deletions lunar/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"build": {
"beforeBuildCommand": "npm run build",
"beforeDevCommand": "npm run dev",
"devPath": "http://localhost:3000",
"distDir": "../out"
},
"package": {
"productName": "lunar",
"version": "0.1.0"
},
"tauri": {
"allowlist": {
"fs": {
"scope": [
"$RESOURCE/*"
]
}
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"appimage": {},
"deb": {
"files": {
"/usr/bin/libpipy.so": "../../target/release/libpipy.so"
}
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "org.mega.dev",
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": [
"config.toml"
],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "lunar-app",
"width": 800
}
]
}
}
Loading