diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/dvm.iml b/.idea/dvm.iml
new file mode 100644
index 0000000..c254557
--- /dev/null
+++ b/.idea/dvm.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..610d591
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Cargo.lock b/Cargo.lock
index 4083bd7..83e0b37 100755
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -125,7 +125,7 @@ checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b"
[[package]]
name = "dvm"
-version = "1.1.8"
+version = "1.1.9"
dependencies = [
"clap",
"clap_generate",
diff --git a/Cargo.toml b/Cargo.toml
index f8d3880..7aae5a1 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ description = "discord version manager for linux"
homepage = "https://github.com/diced/dvm"
repository = "https://github.com/diced/dvm.git"
license = "MIT"
-version = "1.1.8"
+version = "1.1.9"
authors = ["diced "]
edition = "2021"
diff --git a/README.md b/README.md
index 9e458ed..2a451dc 100755
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ chmod +x dvm
```
# Usage
```
-dvm 1.1.8
+dvm 1.1.9
USAGE:
dvm
@@ -42,13 +42,14 @@ FLAGS:
-V, --version Prints version information
SUBCOMMANDS:
- completions get shell completions
- help Prints this message or the help of the given subcommand(s)
- install install the latest of discord
- remove remove the installed of discord
- run run discord with specific options
- show show all installed versions
- update update to the latest of discord
+ completions get shell completions
+ help Prints this message or the help of the given subcommand(s)
+ install install the latest of discord
+ install-open-asar install openasar for of discord
+ remove remove the installed of discord
+ run run discord with specific options
+ show show all installed versions
+ update update to the latest of discord
```
# Installing Discord
@@ -60,7 +61,19 @@ This will do the following:
1. Download the latest stable tarball from discord
2. Extract it into $HOME/.dvm
3. Create a bin file that executes the executable
-4. Copy desktop and icons to respectful folders
+4. Copy desktop and icons to their folders
+
+## Install Open Asar
+If you forget to add the flag `-o` when installing discord, you can install open asar by doing
+```sh
+dvm install-open-asar stable
+```
+...or do it when installing discord
+```sh
+dvm install stable -o
+```
+
+
## Installing multiple versions at once
You can install multiple versions at once, they will be executed one after the other.
diff --git a/src/cli/install.rs b/src/cli/install.rs
index 2feecec..189675b 100755
--- a/src/cli/install.rs
+++ b/src/cli/install.rs
@@ -2,7 +2,7 @@ use std::{ env, fs, path::Path};
use crate::{error, info, r#type::Type, success, Res, util::install_version};
-pub async fn install(release_type: Type, verbose: bool) -> Res<()> {
+pub async fn install(release_type: Type, verbose: bool, open_asar: bool) -> Res<()> {
// create user var & create .dvm dirs
let user = env::var("USER")?;
fs::create_dir_all(format!("/home/{}/.dvm/bin", user))?;
@@ -17,13 +17,29 @@ pub async fn install(release_type: Type, verbose: bool) -> Res<()> {
Type::DEVELOPMENT => "DiscordDevelopment",
};
- let exists = Path::new(&format!("/home/{}/.dvm/{}", user, pascal_pkg)).exists();
+ let exists = Path::new(&format!("/home/{}/.dvm/{}", &user, &pascal_pkg)).exists();
if exists {
error!("{} is already installed", release_type);
}
- let (latest, _) = install_version(false, release_type.clone(), verbose, user).await?;
+ let (latest, _) = install_version(false, release_type.clone(), verbose, user.clone()).await?;
+
+ if open_asar {
+ let asar_file = format!("/home/{}/.dvm/{}/resources/app.asar", user, pascal_pkg);
+
+ fs::rename(&asar_file, format!("{}.bak", &asar_file))?;
+ info!("renamed app.asar to app.asar.bak (if discord doesn't work after this, rename it back)");
+
+ let res = reqwest::get("https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar")
+ .await?
+ .bytes()
+ .await?;
+
+ fs::write(&asar_file, res)?;
+
+ info!("downloaded openasar, if discord is open, restart it");
+ }
success!("installed {}:{}", release_type, latest);
Ok(())
diff --git a/src/cli/install_openasar.rs b/src/cli/install_openasar.rs
new file mode 100755
index 0000000..6986371
--- /dev/null
+++ b/src/cli/install_openasar.rs
@@ -0,0 +1,41 @@
+use std::{env, fs, path::Path};
+
+use crate::{error, info, r#type::Type, success, Res};
+
+pub async fn install_openasar(release_type: Type, verbose: bool) -> Res<()> {
+ // create user var & create .dvm dirs
+ let user = env::var("USER")?;
+ fs::create_dir_all(format!("/home/{}/.dvm/bin", user))?;
+ if verbose {
+ info!("created .dvm dir")
+ }
+
+ let pascal_pkg = match release_type {
+ Type::STABLE => "Discord",
+ Type::PTB => "DiscordPTB",
+ Type::CANARY => "DiscordCanary",
+ Type::DEVELOPMENT => "DiscordDevelopment",
+ };
+
+ let exists = Path::new(&format!("/home/{}/.dvm/{}", &user, &pascal_pkg)).exists();
+
+ if !exists {
+ error!("{} is not installed", release_type);
+ }
+
+ let asar_file = format!("/home/{}/.dvm/{}/resources/app.asar", user, pascal_pkg);
+
+ fs::rename(&asar_file, format!("{}.bak", &asar_file))?;
+ info!("renamed app.asar to app.asar.bak (if discord doesn't work after this, rename it back)");
+
+ let res = reqwest::get("https://github.com/GooseMod/OpenAsar/releases/download/nightly/app.asar")
+ .await?
+ .bytes()
+ .await?;
+
+ fs::write(&asar_file, res)?;
+
+ success!("installed openasar, if discord is open, restart it");
+
+ Ok(())
+}
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 07daec2..7b0765f 100755
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1,7 +1,8 @@
mod install;
+mod install_openasar;
mod remove;
mod show;
mod update;
mod run;
-pub use {install::install, remove::remove, show::show, update::update, run::run};
\ No newline at end of file
+pub use {install::install, install_openasar::install_openasar, remove::remove, show::show, update::update, run::run};
\ No newline at end of file
diff --git a/src/common.rs b/src/common.rs
index c740c7e..d349c77 100755
--- a/src/common.rs
+++ b/src/common.rs
@@ -1,6 +1,8 @@
-pub const VERSION: &str = "1.1.8";
+pub const VERSION: &str = "1.1.9";
pub const INSTALL_DESC: &str = "install the latest of discord";
pub const INSTALL_ALIASES: &[&str] = &["i", "in", "get"];
+pub const INSTALL_OPENASAR_DESC: &str = "install openasar for of discord";
+pub const INSTALL_OPENASAR_ALIASES: &[&str] = &["asar", "oa"];
pub const UPDATE_DESC: &str = "update to the latest of discord";
pub const UPDATE_ALIASES: &[&str] = &["u", "up", "upgrade"];
pub const REMOVE_DESC: &str = "remove the installed of discord";
diff --git a/src/main.rs b/src/main.rs
index 7cc4733..da02103 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,7 +2,7 @@
compile_error!("can only be compiled on linux ;)");
use clap::{AppSettings, Clap};
-use dvm::{Res, cli::{install, remove, show, update, run}, common::*, common::VERSION, completions, error, r#type::Type};
+use dvm::{Res, cli::{install, install_openasar, remove, show, update, run}, common::*, common::VERSION, completions, error, r#type::Type};
#[derive(Clap, Debug)]
#[clap(version = VERSION, setting = AppSettings::ColoredHelp)]
@@ -16,6 +16,9 @@ enum Command {
#[clap(about = INSTALL_DESC, aliases = INSTALL_ALIASES)]
Install(InstallOption),
+ #[clap(about = INSTALL_OPENASAR_DESC, aliases = INSTALL_OPENASAR_ALIASES)]
+ InstallOpenAsar(InstallOpenAsarOption),
+
#[clap(about = UPDATE_DESC, aliases = UPDATE_ALIASES)]
Update(UpdateOption),
@@ -39,6 +42,18 @@ struct InstallOption {
#[clap(short, long)]
verbose: bool,
+
+ #[clap(short, long)]
+ open_asar: bool
+}
+
+#[derive(Clap, Debug)]
+struct InstallOpenAsarOption {
+ #[clap(possible_values = POSSIBLE_VALUES)]
+ r#type: Vec,
+
+ #[clap(short, long)]
+ verbose: bool
}
#[derive(Clap, Debug)]
@@ -98,22 +113,44 @@ fn str_to_type(s: String) -> Type {
}
}
+fn check_type_len(types: &Vec) -> Res<()> {
+ if types.len() == 0 {
+ error!("no types provided");
+ }
+
+ Ok(())
+}
+
#[tokio::main]
async fn main() -> Res<()> {
let opts = Opts::parse();
Ok(match opts.command {
Command::Install(opt) => {
+ check_type_len(&opt.r#type)?;
+
for r#type in opt.r#type {
- install(str_to_type(r#type), opt.verbose).await?
+ install(str_to_type(r#type), opt.verbose, opt.open_asar).await?
}
}
+ Command::InstallOpenAsar(opt) => {
+ check_type_len(&opt.r#type)?;
+
+ for r#type in opt.r#type {
+ install_openasar(str_to_type(r#type), opt.verbose).await?
+ }
+ }
+
Command::Update(opt) => {
+ check_type_len(&opt.r#type)?;
+
for r#type in opt.r#type {
update(str_to_type(r#type), opt.verbose).await?
}
}
Command::Remove(opt) => {
+ check_type_len(&opt.r#type)?;
+
for r#type in opt.r#type {
remove(str_to_type(r#type), opt.verbose).await?
}
diff --git a/src/util.rs b/src/util.rs
index 90e9465..30f0873 100755
--- a/src/util.rs
+++ b/src/util.rs
@@ -131,10 +131,19 @@ pub async fn install_version(update: bool, release_type: Type, verbose: bool, us
fs::write(
&bin_path,
format!(
- "#!/bin/sh\n/home/{}/.dvm/{}/{} \"$@\"\n",
- user, pascal_pkg, pascal_pkg
+ r#"#!/usr/bin/env bash
+
+USER_FLAGS_FILE="$HOME/.dvm/{}-flags.conf"
+if [[ -f $USER_FLAGS_FILE ]]; then
+ USER_FLAGS="$(cat $USER_FLAGS_FILE | sed 's/#.*//')"
+fi
+
+exec /home/{}/.dvm/{}/{} "$@" $USER_FLAGS
+"#,
+ pkg_name, user, pascal_pkg, pascal_pkg
),
)?;
+
if verbose {
info!("created executable bin")
}