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
12 changes: 12 additions & 0 deletions .cursor/rules/development.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
alwaysApply: true
---

- `cargo build --all-features` - build the project
- `target/debug/mise` - run the built binary
- `mise run test:e2e -- [test_filename]...` - run e2e tests
- `mise run test:unit` - run unit tests
- `mise run lint` - run linting
- `mise run lint-fix` - run linting and fix issues

Don't run e2e tests by trying to execute them directly, always use `mise run test:e2e -- [test_filename]...`
4 changes: 2 additions & 2 deletions .cursor/rules/testing.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ alwaysApply: false

Testing and linting commands should be run via `mise run`.

- `mise run e2e [test_filename]` executes an e2e test
- `mise run test:e2e -- [test_filename]...` executes an e2e test
- `mise run test:unit` executes the unit tests
- `mise run lint` runs the linting commands
- `mise run lint-fix` runs the linting commands and fixes the issues
- `mise --cd crates/vfox run test` executes the tests for the vfox crate
- `mise --cd crates/vfox run lint` runs the linting commands for the vfox crate
- `mise --cd crates/vfox run lint-fix` runs the linting commands and fixes the issues for the vfox crate

other tasks can be found by running `mise task ls`
Other tasks can be found by running `mise task ls`
2 changes: 2 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- run: mise x -- bun i
- run: mise run render
- run: mise run lint-fix
- run: mise --cd crates/vfox run lint-fix
- uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2
# windows:
# runs-on: windows-latest
Expand All @@ -69,4 +70,5 @@ jobs:
# - run: mise x -- npm i
# #- run: mise run render
# - run: mise run lint-fix
# - run: mise --cd crates/vfox run lint-fix
# - uses: autofix-ci/action@2891949f3779a1cafafae1523058501de3d4e944 # v1.3.1
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ jobs:
tranche: [0, 1, 2, 3, 4, 5, 6, 7]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: true
- name: Install zsh/fish/direnv/fd
run: sudo apt-get update; sudo apt-get install zsh fish direnv fd-find
- name: Install fd-find
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: true
fetch-depth: 0
- name: Install build and test dependencies
run: |
Expand Down Expand Up @@ -257,6 +258,8 @@ jobs:
MISE_CACHE_DIR: ~/.cache/mise
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: true
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: mise-windows-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "aqua-registry"]
path = aqua-registry
url = https://github.com/aquaproj/aqua-registry
[submodule "test/plugins/vfox-npm"]
path = test/plugins/vfox-npm
url = https://github.com/jdx/vfox-npm.git
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/vfox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
license = "MIT"
description = "Interface to vfox plugins"
documentation = "https://docs.rs/vfox"
homepage = "https://github.com/jdx/vfox.rs"
repository = "https://github.com/jdx/vfox.rs"
homepage = "https://github.com/jdx/mise"
repository = "https://github.com/jdx/mise"
include = ["src", "lua", "Cargo.toml", "Cargo.lock", "README.md", "LICENSE"]

[lib]
Expand All @@ -22,7 +22,7 @@ homedir = "0.3"
indexmap = "2"
itertools = "0.14"
log = "0.4"
mlua = { version = "0.10", features = [
mlua = { version = "0.11.0-beta.3", features = [
"async",
"lua51",
"macros",
Expand Down
58 changes: 58 additions & 0 deletions crates/vfox/src/hooks/backend_exec_env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use mlua::{prelude::LuaError, FromLua, IntoLua, Lua, Value};
use std::path::PathBuf;

use crate::{error::Result, hooks::env_keys::EnvKey, Plugin};

#[derive(Debug, Clone)]
pub struct BackendExecEnvContext {
pub tool: String,
pub version: String,
pub install_path: PathBuf,
}

#[derive(Debug)]
pub struct BackendExecEnvResponse {
pub env_vars: Vec<EnvKey>,
}

impl Plugin {
pub async fn backend_exec_env(
&self,
ctx: BackendExecEnvContext,
) -> Result<BackendExecEnvResponse> {
debug!("[vfox:{}] backend_exec_env", &self.name);
self.eval_async(chunk! {
require "hooks/backend_exec_env"
return PLUGIN:BackendExecEnv($ctx)
})
.await
}
}

impl IntoLua for BackendExecEnvContext {
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<Value> {
let table = lua.create_table()?;
table.set("tool", self.tool)?;
table.set("version", self.version)?;
table.set(
"install_path",
self.install_path.to_string_lossy().to_string(),
)?;
Ok(Value::Table(table))
}
}

impl FromLua for BackendExecEnvResponse {
fn from_lua(value: Value, _: &Lua) -> std::result::Result<Self, LuaError> {
match value {
Value::Table(table) => Ok(BackendExecEnvResponse {
env_vars: table.get::<Vec<crate::hooks::env_keys::EnvKey>>("env_vars")?,
}),
_ => Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "BackendExecEnvResponse".to_string(),
message: Some("Expected table".to_string()),
}),
}
}
}
54 changes: 54 additions & 0 deletions crates/vfox/src/hooks/backend_install.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use mlua::{prelude::LuaError, FromLua, IntoLua, Lua, Value};
use std::path::PathBuf;

use crate::{error::Result, Plugin};

#[derive(Debug)]
pub struct BackendInstallContext {
pub tool: String,
pub version: String,
pub install_path: PathBuf,
}

#[derive(Debug)]
pub struct BackendInstallResponse {}

impl Plugin {
pub async fn backend_install(
&self,
ctx: BackendInstallContext,
) -> Result<BackendInstallResponse> {
debug!("[vfox:{}] backend_install", &self.name);
self.eval_async(chunk! {
require "hooks/backend_install"
return PLUGIN:BackendInstall($ctx)
})
.await
}
}

impl IntoLua for BackendInstallContext {
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<Value> {
let table = lua.create_table()?;
table.set("tool", self.tool)?;
table.set("version", self.version)?;
table.set(
"install_path",
self.install_path.to_string_lossy().to_string(),
)?;
Ok(Value::Table(table))
}
}

impl FromLua for BackendInstallResponse {
fn from_lua(value: Value, _: &Lua) -> std::result::Result<Self, LuaError> {
match value {
Value::Table(_) => Ok(BackendInstallResponse {}),
_ => Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "BackendInstallResponse".to_string(),
message: Some("Expected table".to_string()),
}),
}
}
}
49 changes: 49 additions & 0 deletions crates/vfox/src/hooks/backend_list_versions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use crate::{error::Result, Plugin};
use mlua::{prelude::LuaError, FromLua, IntoLua, Lua, Value};

#[derive(Debug, Clone)]
pub struct BackendListVersionsContext {
pub tool: String,
}

#[derive(Debug, Clone)]
pub struct BackendListVersionsResponse {
pub versions: Vec<String>,
}

impl Plugin {
pub async fn backend_list_versions(
&self,
ctx: BackendListVersionsContext,
) -> Result<BackendListVersionsResponse> {
debug!("[vfox:{}] backend_list_versions", &self.name);
self.eval_async(chunk! {
require "hooks/backend_list_versions"
return PLUGIN:BackendListVersions($ctx)
})
.await
}
}

impl IntoLua for BackendListVersionsContext {
fn into_lua(self, lua: &mlua::Lua) -> mlua::Result<Value> {
let table = lua.create_table()?;
table.set("tool", self.tool)?;
Ok(Value::Table(table))
}
}

impl FromLua for BackendListVersionsResponse {
fn from_lua(value: Value, _: &Lua) -> std::result::Result<Self, LuaError> {
match value {
Value::Table(table) => Ok(BackendListVersionsResponse {
versions: table.get::<Vec<String>>("versions")?,
}),
_ => Err(LuaError::FromLuaConversionError {
from: value.type_name(),
to: "BackendListVersionsResponse".to_string(),
message: Some("Expected table".to_string()),
}),
}
}
}
3 changes: 3 additions & 0 deletions crates/vfox/src/hooks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pub mod available;
pub mod backend_exec_env;
pub mod backend_install;
pub mod backend_list_versions;
pub mod env_keys;
pub mod mise_env;
pub mod mise_path;
Expand Down
Loading
Loading