Skip to content
Draft
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
694 changes: 392 additions & 302 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ indoc = "2.0.3"
is-terminal = "0.4"
path-absolutize = "3.1.0"
human-sort = "0.2.2"
regex = "1.10"
toml_edit = "0.22"
regex = "1.10.5"

[target.'cfg(windows)'.dependencies]
windows = { version = "0.61.1", features = ["Win32_Foundation", "Win32_UI_Shell", "Win32_Security", "Win32_System_JobObjects", "Win32_System_Console", "Win32_System_Threading", "Services_Store", "Foundation", "Foundation_Collections", "Web_Http", "Web_Http_Headers", "Storage_Streams", "Management_Deployment"] }
Expand Down
9 changes: 0 additions & 9 deletions deploy/winpkgidentityext/appmanifest/app.manifest

This file was deleted.

24 changes: 0 additions & 24 deletions deploy/winpkgidentityext/create-msix.ps1

This file was deleted.

Binary file removed deploy/winpkgidentityext/juliaup.msix
Binary file not shown.
90 changes: 0 additions & 90 deletions deploy/winpkgidentityext/msix/appxmanifest.xml

This file was deleted.

14 changes: 13 additions & 1 deletion src/bin/juliaup.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use anyhow::{Context, Result};
use clap::Parser;
use juliaup::cli::{ConfigSubCmd, Juliaup, OverrideSubCmd, SelfSubCmd};
use juliaup::cli::{ApplicationSubCmd, ConfigSubCmd, Juliaup, OverrideSubCmd, SelfSubCmd};
use juliaup::command_api::run_command_api;
use juliaup::command_app_register::run_command_app_register;
use juliaup::command_app_run::run_command_app_run;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
use juliaup::command_app_run::run_command_app_run;

use juliaup::command_app_remove::run_command_app_remove;
use juliaup::command_completions::run_command_completions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
use juliaup::command_completions::run_command_completions;
use juliaup::command_app_run::run_command_app_run;
use juliaup::command_completions::run_command_completions;

#[cfg(not(windows))]
use juliaup::command_config_symlinks::run_command_config_symlinks;
Expand Down Expand Up @@ -149,5 +152,14 @@ fn main() -> Result<()> {
SelfSubCmd::Uninstall {} => run_command_selfuninstall_unavailable(),
},
Juliaup::Completions { shell } => run_command_completions(shell),
Juliaup::Application(subcmd) => match subcmd {
ApplicationSubCmd::Register { value } => {
run_command_app_register(&value, &paths)
},
ApplicationSubCmd::Run { name, args } => {
run_command_app_run(&name, &args, &paths)
},
ApplicationSubCmd::Remove { name } => run_command_app_remove(&name, &paths)
Comment on lines +156 to +162
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
ApplicationSubCmd::Register { value } => {
run_command_app_register(&value, &paths)
},
ApplicationSubCmd::Run { name, args } => {
run_command_app_run(&name, &args, &paths)
},
ApplicationSubCmd::Remove { name } => run_command_app_remove(&name, &paths)
ApplicationSubCmd::Register { value } => run_command_app_register(&value, &paths),
ApplicationSubCmd::Run { name, args } => run_command_app_run(&name, &args, &paths),
ApplicationSubCmd::Remove { name } => run_command_app_remove(&name, &paths),

},
}
}
23 changes: 23 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub enum Juliaup {
#[cfg(feature = "selfupdate")]
#[clap(name = "4c79c12db1d34bbbab1f6c6f838f423f", hide = true)]
SecretSelfUpdate {},
#[clap(subcommand, name = "app")]
/// Juliaup applications
Application(ApplicationSubCmd),
}

#[derive(Parser)]
Expand Down Expand Up @@ -158,3 +161,23 @@ pub enum ConfigSubCmd {
value: Option<i64>,
},
}

#[derive(Parser)]
pub enum ApplicationSubCmd {
#[clap(name = "register")]
/// Register a Julia application
Register {
value: String
},
Comment on lines +169 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
Register {
value: String
},
Register { value: String },

#[clap(name = "run")]
/// Run a Julia application
Run {
name: String,
args: Vec<String>
},
Comment on lines +174 to +177
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
Run {
name: String,
args: Vec<String>
},
Run { name: String, args: Vec<String> },

#[clap(name = "remove", alias = "rm")]
/// Remove a Julia application
Remove {
name: String
}
Comment on lines +180 to +182
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
Remove {
name: String
}
Remove { name: String },

}
86 changes: 86 additions & 0 deletions src/command_app_register.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
use std::fs;
use std::path::PathBuf;
use std::str::FromStr;

use crate::config_file::{load_mut_config_db, save_config_db, JuliaupConfigApplication, JuliaupConfigExcutionAlias};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
use crate::config_file::{load_mut_config_db, save_config_db, JuliaupConfigApplication, JuliaupConfigExcutionAlias};
use crate::config_file::{
load_mut_config_db, save_config_db, JuliaupConfigApplication, JuliaupConfigExcutionAlias,
};

use crate::global_paths::GlobalPaths;
use crate::operations::install_version;
use crate::versions_file::load_versions_db;
use anyhow::{Context, Result};
use bstr::ByteVec;
use normpath::PathExt;

pub fn run_command_app_register(path: &str, paths: &GlobalPaths) -> Result<()> {
let app_folder_path = PathBuf::from(path);

let project_path = app_folder_path.join("Project.toml");
let manifest_path = app_folder_path.join("Manifest.toml");

let project_content = fs::read_to_string(project_path).unwrap();
let project_parsed = toml_edit::DocumentMut::from_str(&project_content).unwrap();

let manifest_content = fs::read_to_string(&manifest_path).unwrap();
let manifest_parsed = toml_edit::DocumentMut::from_str(&manifest_content).unwrap();

let app_name = project_parsed.as_table().get_key_value("name").unwrap().1.as_str().unwrap();
let julia_version = manifest_parsed.as_table().get_key_value("julia_version").unwrap().1.as_str().unwrap();
Comment on lines +25 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
let app_name = project_parsed.as_table().get_key_value("name").unwrap().1.as_str().unwrap();
let julia_version = manifest_parsed.as_table().get_key_value("julia_version").unwrap().1.as_str().unwrap();
let app_name = project_parsed
.as_table()
.get_key_value("name")
.unwrap()
.1
.as_str()
.unwrap();
let julia_version = manifest_parsed
.as_table()
.get_key_value("julia_version")
.unwrap()
.1
.as_str()
.unwrap();


let exec_aliases: Vec<(String, String)> = project_parsed
.as_table()
.get_key_value("executionaliases")
.unwrap()
.1
.clone()
.into_table()
.unwrap()
.iter()
.map(|i| (i.0.to_string(), i.1.clone().into_value().unwrap().as_str().unwrap().to_string()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.map(|i| (i.0.to_string(), i.1.clone().into_value().unwrap().as_str().unwrap().to_string()))
.map(|i| {
(
i.0.to_string(),
i.1.clone()
.into_value()
.unwrap()
.as_str()
.unwrap()
.to_string(),
)
})

.collect();

let version_db =
load_versions_db(paths).with_context(|| "`add app` command failed to load versions db.")?;

let asdf = version_db.available_channels.get(julia_version).unwrap();

let mut config_file = load_mut_config_db(paths)
.with_context(|| "`app add` command failed to load configuration data.")?;

install_version(&asdf.version, &mut config_file.data, &version_db, paths).unwrap();

let julia_binary_path = &paths.juliaupconfig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
let julia_binary_path = &paths.juliaupconfig
let julia_binary_path = &paths
.juliaupconfig

.parent()
.unwrap() // unwrap OK because there should always be a parent
.join(config_file.data.installed_versions.get(&asdf.version).unwrap().path.clone())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.join(config_file.data.installed_versions.get(&asdf.version).unwrap().path.clone())
.join(
config_file
.data
.installed_versions
.get(&asdf.version)
.unwrap()
.path
.clone(),
)

.join("bin")
.join(format!("julia{}", std::env::consts::EXE_SUFFIX))
.normalize().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.normalize().unwrap();
.normalize()
.unwrap();


let depot_detection_output = std::process::Command::new(julia_binary_path)
.arg("-e")
.arg("println(Base.DEPOT_PATH[1])")
.output()
.unwrap();

let depot_detection_output = depot_detection_output.stdout.into_string().unwrap().trim().to_string();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
let depot_detection_output = depot_detection_output.stdout.into_string().unwrap().trim().to_string();
let depot_detection_output = depot_detection_output
.stdout
.into_string()
.unwrap()
.trim()
.to_string();


config_file.data.installed_apps.insert(
app_name.to_string(),
JuliaupConfigApplication::DevedApplication {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
JuliaupConfigApplication::DevedApplication {
JuliaupConfigApplication::DevedApplication {

path: app_folder_path.to_str().unwrap().to_string(),
julia_version: asdf.version.to_string(),
julia_depot: depot_detection_output,
execution_aliases: exec_aliases.iter().map(|i| (i.0.clone(), JuliaupConfigExcutionAlias { target: i.1.to_string() })).collect()
}
Comment on lines +72 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
execution_aliases: exec_aliases.iter().map(|i| (i.0.clone(), JuliaupConfigExcutionAlias { target: i.1.to_string() })).collect()
}
execution_aliases: exec_aliases
.iter()
.map(|i| {
(
i.0.clone(),
JuliaupConfigExcutionAlias {
target: i.1.to_string(),
},
)
})
.collect(),
},

);

save_config_db(&mut config_file).unwrap();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change

std::process::Command::new(julia_binary_path)
.env("JULIA_PROJECT", &app_folder_path)
.arg("-e")
.arg("using Pkg; Pkg.instantiate()")
.status()
.unwrap();

return Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
return Ok(())
return Ok(());

}
21 changes: 21 additions & 0 deletions src/command_app_remove.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use anyhow::{Context,Result};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
use anyhow::{Context,Result};
use anyhow::{Context, Result};


use crate::{config_file::{load_mut_config_db, save_config_db}, global_paths::GlobalPaths, operations::garbage_collect_versions};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
use crate::{config_file::{load_mut_config_db, save_config_db}, global_paths::GlobalPaths, operations::garbage_collect_versions};
use crate::{
config_file::{load_mut_config_db, save_config_db},
global_paths::GlobalPaths,
operations::garbage_collect_versions,
};


pub fn run_command_app_remove(name: &str, paths: &GlobalPaths) -> Result<()> {
let mut config_file = load_mut_config_db(paths)
.with_context(|| "`app remove` command failed to load configuration data.")?;

if !config_file.data.installed_apps.contains_key(name) {
println!("Unknown app {}.", name);
}
else {
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
}
else {
} else {

config_file.data.installed_apps.remove(name).unwrap();

garbage_collect_versions(false, &mut config_file.data, paths).unwrap();

save_config_db(&mut config_file).unwrap();
}

return Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
return Ok(())
return Ok(());

}
54 changes: 54 additions & 0 deletions src/command_app_run.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::collections::HashMap;

use crate::{config_file::{load_config_db, JuliaupConfigApplication}, global_paths::GlobalPaths};
use anyhow::{Context,Result};
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
use crate::{config_file::{load_config_db, JuliaupConfigApplication}, global_paths::GlobalPaths};
use anyhow::{Context,Result};
use crate::{
config_file::{load_config_db, JuliaupConfigApplication},
global_paths::GlobalPaths,
};
use anyhow::{Context, Result};

use normpath::PathExt;

pub fn run_command_app_run(name: &str, args: &Vec<String>, paths: &GlobalPaths) -> Result<()> {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change

let config_file = load_config_db(paths, None)
.with_context(|| "`app run` command failed to load configuration data.")?;

let target: HashMap<String,(String,String,String,String)> = config_file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
let target: HashMap<String,(String,String,String,String)> = config_file
let target: HashMap<String, (String, String, String, String)> = config_file

.data
.installed_apps
.iter()
.flat_map(|i| match&i.1 {
JuliaupConfigApplication::DevedApplication { path, julia_version, julia_depot, execution_aliases } => execution_aliases.iter().map(|j| (j.0.clone(), (j.1.target.clone(), path.clone(), julia_version.clone(), julia_depot.clone())))
Comment on lines +16 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.flat_map(|i| match&i.1 {
JuliaupConfigApplication::DevedApplication { path, julia_version, julia_depot, execution_aliases } => execution_aliases.iter().map(|j| (j.0.clone(), (j.1.target.clone(), path.clone(), julia_version.clone(), julia_depot.clone())))
.flat_map(|i| match &i.1 {
JuliaupConfigApplication::DevedApplication {
path,
julia_version,
julia_depot,
execution_aliases,
} => execution_aliases.iter().map(|j| {
(
j.0.clone(),
(
j.1.target.clone(),
path.clone(),
julia_version.clone(),
julia_depot.clone(),
),
)
}),
})
.map(|i| {
(
i.0.clone(),
(
i.1 .0.clone(),
i.1 .1.clone(),
i.1 .2.clone(),
i.1 .3.clone(),
),
)

})
.map(|i| (i.0.clone(), (i.1.0.clone(), i.1.1.clone(), i.1.2.clone(), i.1.3.clone())))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.map(|i| (i.0.clone(), (i.1.0.clone(), i.1.1.clone(), i.1.2.clone(), i.1.3.clone())))

.collect();

if target.contains_key(name) {
let foo = target.get(name).unwrap();

let parts: Vec<&str> = foo.0.split(".").collect();

// println!("First arg {}, second arg {}", foo.0, foo.1)

let target_path = foo.1.clone();

let julia_binary_path = &paths.juliaupconfig
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
let julia_binary_path = &paths.juliaupconfig
let julia_binary_path = &paths
.juliaupconfig

.parent()
.unwrap() // unwrap OK because there should always be a parent
.join(config_file.data.installed_versions.get(&foo.2).unwrap().path.clone())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.join(config_file.data.installed_versions.get(&foo.2).unwrap().path.clone())
.join(
config_file
.data
.installed_versions
.get(&foo.2)
.unwrap()
.path
.clone(),
)

.join("bin")
.join(format!("julia{}", std::env::consts::EXE_SUFFIX))
.normalize().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
.normalize().unwrap();
.normalize()
.unwrap();


std::process::Command::new(julia_binary_path)
.arg(format!("--project={}", target_path))
// .env("JULIA_PROJECT", target_path)
.env("JULIA_DEPOT_PATH", foo.3.clone())
.arg("-e")
.arg(format!("import {}; {}(ARGS)", parts[0], foo.0))
.args(args)
.status()
.unwrap();

}
else {
Comment on lines +48 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
}
else {
} else {

println!("Could not find app.");
}
return Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[rustfmt] reported by reviewdog 🐶

Suggested change
return Ok(())
return Ok(());

}
Loading
Loading