Skip to content

Commit

Permalink
fix: upgrade vfox.rs with http module
Browse files Browse the repository at this point in the history
Fixes #2864
  • Loading branch information
jdx committed Nov 5, 2024
1 parent b6bef04 commit f177371
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 309 deletions.
325 changes: 30 additions & 295 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ url = "2"
# usage-lib = { path = "../usage/lib", features = ["clap", "docs"] }
usage-lib = { version = "1", features = ["clap", "docs"] }
versions = { version = "6", features = ["serde"] }
# vfox = { path="../vfox.rs" }
vfox = "0.2"
# vfox = { path = "../vfox.rs" }
vfox = "0.3"
walkdir = "2"
which = "6"
which = "7"
xx = { version = "1", features = ["glob"] }
zip = { version = "2", default-features = false, features = ["deflate"] }

Expand Down
4 changes: 4 additions & 0 deletions e2e/backend/test_vfox_kotlin_slow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mise use java
assert_contains "mise x vfox:version-fox/[email protected] -- kotlin" "Kotlin version 2.0.20"
4 changes: 4 additions & 0 deletions e2e/backend/test_vfox_maven_slow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mise use java
assert_contains "mise x vfox:version-fox/[email protected] -- mvn --version" "Apache Maven 3.9.8"
4 changes: 4 additions & 0 deletions e2e/backend/test_vfox_python_slow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

mise i vfox:version-fox/[email protected]
assert "mise x vfox:version-fox/[email protected] -- python3 -V" "Python 3.12.0"
12 changes: 4 additions & 8 deletions registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ cyclonedx = ["asdf:xeedio/asdf-cyclonedx"]
dagger = ["asdf:virtualstaticvoid/asdf-dagger"]
danger-js = ["asdf:MontakOleg/asdf-danger-js"]
dapr = ["asdf:asdf-community/asdf-dapr-cli"]
# dart = ["vfox:version-fox/vfox-dart", "asdf:PatOConnor43/asdf-dart"] # TODO: vfox has issues on arm64
dart = ["asdf:PatOConnor43/asdf-dart"]
dart = ["asdf:PatOConnor43/asdf-dart", "vfox:version-fox/vfox-dart"]
dasel = ["asdf:asdf-community/asdf-dasel"]
datree = ["asdf:lukeab/asdf-datree"]
daytona = ["asdf:CrouchingMuppet/asdf-daytona"]
Expand Down Expand Up @@ -212,8 +211,7 @@ editorconfig-checker = ["asdf:gabitchov/asdf-editorconfig-checker"]
ejson = ["asdf:cipherstash/asdf-ejson"]
eksctl = ["asdf:elementalvoid/asdf-eksctl"]
elasticsearch = ["asdf:asdf-community/asdf-elasticsearch"]
# elixir = ["vfox:version-fox/vfox-elixir", "asdf:mise-plugins/mise-elixir"] # TODO: not sure what is wrong with this one
elixir = ["asdf:mise-plugins/mise-elixir"]
elixir = ["asdf:mise-plugins/mise-elixir", "vfox:version-fox/vfox-elixir"]
elixir-ls = ["asdf:juantascon/asdf-elixir-ls"]
elm = ["asdf:asdf-community/asdf-elm"]
embulk = ["asdf:yuokada/asdf-embulk"]
Expand Down Expand Up @@ -396,8 +394,7 @@ ko = ["asdf:zasdaym/asdf-ko"]
koka = ["asdf:susurri/asdf-koka"]
kompose = ["ubi:kubernetes/kompose", "asdf:technikhil314/asdf-kompose"]
kops = ["asdf:Antiarchitect/asdf-kops"]
# kotlin = ["vfox:version-fox/vfox-kotlin", "asdf:asdf-community/asdf-kotlin"] # TODO: needs html extension for vfox.rs
kotlin = ["asdf:asdf-community/asdf-kotlin"]
kotlin = ["asdf:asdf-community/asdf-kotlin", "vfox:version-fox/vfox-kotlin"]
kp = ["asdf:vmware-tanzu/tanzu-plug-in-for-asdf"]
kpack = ["asdf:asdf-community/asdf-kpack-cli"]
kpt = ["asdf:nlamirault/asdf-kpt"]
Expand Down Expand Up @@ -473,8 +470,7 @@ mark = ["asdf:jfreeland/asdf-mark"]
markdownlint-cli2 = ["npm:markdownlint-cli2", "asdf:paulo-ferraz-oliveira/asdf-markdownlint-cli2"]
marp-cli = ["asdf:xataz/asdf-marp-cli"]
mask = ["asdf:aaaaninja/asdf-mask"]
# maven = ["vfox:version-fox/vfox-maven", "asdf:mise-plugins/asdf-maven"] # TODO: needs html extension for vfox.rs
maven = ["asdf:mise-plugins/asdf-maven"]
maven = ["asdf:mise-plugins/asdf-maven", "vfox:version-fox/vfox-maven"]
mc = ["asdf:penpyt/asdf-mc"]
mdbook = ["asdf:cipherstash/asdf-mdbook"]
mdbook-linkcheck = ["asdf:cipherstash/asdf-mdbook-linkcheck"]
Expand Down
15 changes: 13 additions & 2 deletions src/backend/vfox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::dirs;
use crate::install_context::InstallContext;
use crate::plugins::vfox_plugin::VfoxPlugin;
use crate::plugins::{Plugin, PluginType};
use crate::toolset::{ToolVersion, Toolset};
use crate::toolset::{ToolRequest, ToolVersion, Toolset};
use crate::ui::multi_progress_report::MultiProgressReport;

#[derive(Debug)]
Expand Down Expand Up @@ -92,6 +92,15 @@ impl Backend for VfoxBackend {
) -> eyre::Result<BTreeMap<String, String>> {
self._exec_env(tv).cloned()
}

fn get_dependencies(&self, tvr: &ToolRequest) -> eyre::Result<Vec<BackendArg>> {
let out = match tvr.backend().name.as_str() {
"poetry" | "pipenv" | "pipx" => vec!["python"],
"elixir" => vec!["erlang"],
_ => vec![],
};
Ok(out.into_iter().map(|s| s.into()).collect())
}
}

impl VfoxBackend {
Expand All @@ -110,6 +119,8 @@ impl VfoxBackend {
pub fn from_arg(ba: BackendArg) -> Self {
let pathname = ba.short.to_kebab_case();
let plugin_path = dirs::PLUGINS.join(&pathname);
let mut plugin = VfoxPlugin::new(pathname.clone());
plugin.full = Some(ba.full.clone());
Self {
remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"),
Expand All @@ -124,7 +135,7 @@ impl VfoxBackend {
.with_fresh_file(plugin_path.to_path_buf())
.with_fresh_file(ba.installs_path.to_path_buf())
.build(),
plugin: Box::new(VfoxPlugin::new(pathname.clone())),
plugin: Box::new(plugin),
ba,
pathname,
}
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/vfox_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use xx::regex;
#[derive(Debug)]
pub struct VfoxPlugin {
pub name: String,
pub full: Option<String>,
pub plugin_path: PathBuf,
pub repo: Mutex<Git>,
pub repo_url: Option<String>,
Expand All @@ -42,6 +43,7 @@ impl VfoxPlugin {
let repo = Git::new(&plugin_path);
Self {
name,
full: None,
repo_url: None,
repo: Mutex::new(repo),
plugin_path,
Expand Down Expand Up @@ -71,7 +73,7 @@ impl VfoxPlugin {
if let Some(url) = self.repo().get_remote_url() {
return Ok(Url::parse(&url)?);
}
vfox_to_url(&self.name)
vfox_to_url(self.full.as_ref().unwrap_or(&self.name))
}

pub fn mise_env(&self, opts: &toml::Value) -> Result<Option<IndexMap<String, String>>> {
Expand Down Expand Up @@ -253,6 +255,7 @@ Plugins could support local directories in the future but for now a symlink is r
}

fn vfox_to_url(name: &str) -> eyre::Result<Url> {
let name = name.strip_prefix("vfox:").unwrap_or(name);
if let Some(full) = registry::REGISTRY_VFOX.get(name.trim_start_matches("vfox-")) {
// bun -> version-fox/vfox-bun
return vfox_to_url(full.split_once(':').unwrap().1);
Expand Down

0 comments on commit f177371

Please sign in to comment.