feat: improve dynamic settings (#2731)

Main functionality this provides is making `mise settings set` dynamic so we no longer need to manually specify each setting for that command.
This commit is contained in:
jdx 2024-10-12 12:41:30 -05:00 committed by GitHub
parent 0844a73141
commit be715e9535
28 changed files with 408 additions and 290 deletions

View File

@ -3,7 +3,7 @@
min_version = "2024.1.1" min_version = "2024.1.1"
[env] [env]
_.file = [".env"] _.file = [".env"]
_.path = ["./target/debug"] _.path = ["./target/debug", "./node_modules/.bin"]
FOO = "bar" FOO = "bar"
FOO_NUM = 1 FOO_NUM = 1
THIS_PROJECT = "{{config_root}}-{{cwd}}" THIS_PROJECT = "{{config_root}}-{{cwd}}"
@ -75,6 +75,9 @@ mise completion fish > completions/mise.fish
depends = ["build"] depends = ["build"]
run = "./scripts/render-registry.js" run = "./scripts/render-registry.js"
[tasks."render:settings"]
run = "tsx tasks/render/settings.ts"
[tasks."render:mangen"] [tasks."render:mangen"]
depends = ["build"] depends = ["build"]
env = { NO_COLOR = "1" } env = { NO_COLOR = "1" }

View File

@ -33,14 +33,33 @@ pub struct Settings {"#
if let Some(description) = props.get("description") { if let Some(description) = props.get("description") {
lines.push(format!(" /// {}", description.as_str().unwrap())); lines.push(format!(" /// {}", description.as_str().unwrap()));
} }
if let Some(type_) = props.get("type") { let type_ = props
.get("rust_type")
.map(|rt| rt.as_str().unwrap())
.or(props.get("type").map(|t| match t.as_str().unwrap() {
"Bool" => "bool",
"String" => "String",
"Integer" => "i64",
"Url" => "String",
"Path" => "PathBuf",
"Duration" => "String",
"ListString" => "Vec<String>",
"ListPath" => "Vec<PathBuf>",
t => panic!("Unknown type: {}", t),
}));
if let Some(type_) = type_ {
let type_ = if props.get("optional").is_some_and(|v| v.as_bool().unwrap()) {
format!("Option<{}>", type_)
} else {
type_.to_string()
};
let mut opts = IndexMap::new(); let mut opts = IndexMap::new();
if let Some(env) = props.get("env") { if let Some(env) = props.get("env") {
opts.insert("env".to_string(), env.to_string()); opts.insert("env".to_string(), env.to_string());
} }
if let Some(default) = props.get("default") { if let Some(default) = props.get("default") {
opts.insert("default".to_string(), default.to_string()); opts.insert("default".to_string(), default.to_string());
} else if type_.as_str().unwrap() == "bool" { } else if type_ == "bool" {
opts.insert("default".to_string(), "false".to_string()); opts.insert("default".to_string(), "false".to_string());
} }
if let Some(parse_env) = props.get("parse_env") { if let Some(parse_env) = props.get("parse_env") {
@ -56,7 +75,7 @@ pub struct Settings {"#
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", ") .join(", ")
)); ));
lines.push(format!(" pub {}: {},", key, type_.as_str().unwrap())); lines.push(format!(" pub {}: {},", key, type_));
} else { } else {
lines.push(" #[config(nested)]".to_string()); lines.push(" #[config(nested)]".to_string());
lines.push(format!( lines.push(format!(
@ -76,7 +95,7 @@ pub struct Settings {"#
.iter() .iter()
.filter(|(_, v)| !v.as_table().unwrap().contains_key("type")) .filter(|(_, v)| !v.as_table().unwrap().contains_key("type"))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for (child, props) in nested_settings { for (child, props) in &nested_settings {
lines.push(format!( lines.push(format!(
r#"#[derive(Config, Default, Debug, Clone, Serialize)] r#"#[derive(Config, Default, Debug, Clone, Serialize)]
#[config(partial_attr(derive(Clone, Serialize, Default)))] #[config(partial_attr(derive(Clone, Serialize, Default)))]
@ -92,5 +111,41 @@ pub struct Settings{name} {{
lines.push("}".to_string()); lines.push("}".to_string());
} }
lines.push(
r#"
pub static SETTINGS_META: Lazy<IndexMap<String, SettingsMeta>> = Lazy::new(|| {
indexmap!{
"#
.to_string(),
);
for (name, props) in &settings {
let props = props.as_table().unwrap();
if let Some(type_) = props.get("type").map(|v| v.as_str().unwrap()) {
lines.push(format!(
r#" "{name}".to_string() => SettingsMeta {{
type_: SettingsType::{type_},
}},"#,
));
}
}
for (name, props) in &nested_settings {
for (key, props) in props.as_table().unwrap() {
let props = props.as_table().unwrap();
if let Some(type_) = props.get("type").map(|v| v.as_str().unwrap()) {
lines.push(format!(
r#" "{name}.{key}".to_string() => SettingsMeta {{
type_: SettingsType::{type_},
}},"#,
));
}
}
}
lines.push(
r#" }
});
"#
.to_string(),
);
fs::write(&dest_path, lines.join("\n")).unwrap(); fs::write(&dest_path, lines.join("\n")).unwrap();
} }

View File

@ -15,47 +15,50 @@ export default defineConfig({
// https://vitepress.dev/reference/default-theme-config // https://vitepress.dev/reference/default-theme-config
outline: "deep", outline: "deep",
nav: [ nav: [
{text: "Dev Tools", link: "/dev-tools/"}, { text: "Dev Tools", link: "/dev-tools/" },
{text: "Environments", link: "/environments"}, { text: "Environments", link: "/environments" },
{text: "Tasks", link: "/tasks/"}, { text: "Tasks", link: "/tasks/" },
], ],
sidebar: [ sidebar: [
{text: "Getting Started", link: "/getting-started"}, { text: "Getting Started", link: "/getting-started" },
{text: "About", link: "/about"}, { text: "About", link: "/about" },
{text: "Configuration", link: "/configuration"}, { text: "Continuous Integration", link: "/continuous-integration" },
{text: "Continuous Integration", link: "/continuous-integration"}, { text: "Demo", link: "/demo" },
{text: "Demo", link: "/demo"}, { text: "FAQs", link: "/faq" },
{text: "FAQs", link: "/faq"}, { text: "Troubleshooting", link: "/troubleshooting" },
{text: "Troubleshooting", link: "/troubleshooting"}, { text: "How I Use mise", link: "/how-i-use-mise" },
{text: "How I Use mise", link: "/how-i-use-mise"}, { text: "IDE Integration", link: "/ide-integration" },
{text: "IDE Integration", link: "/ide-integration"}, { text: "Paranoid", link: "/paranoid" },
{text: "Paranoid", link: "/paranoid"}, { text: "Registry", link: "/registry" },
{text: "Registry", link: "/registry"}, { text: "Plugins", link: "/plugins" },
{text: "Settings", link: "/settings"}, { text: "Coming from rtx", link: "/rtx" },
{text: "Plugins", link: "/plugins"}, { text: "Team", link: "/team" },
{text: "Coming from rtx", link: "/rtx"}, { text: "Contributing", link: "/contributing" },
{text: "Team", link: "/team"}, { text: "Tips & Tricks", link: "/tips-and-tricks" },
{text: "Contributing", link: "/contributing"}, {
{text: "Tips & Tricks", link: "/tips-and-tricks"}, text: "Configuration",
link: "/configuration",
items: [{ text: "Settings", link: "/configuration/settings" }],
},
{ {
text: "Dev Tools", text: "Dev Tools",
link: "/dev-tools/", link: "/dev-tools/",
items: [ items: [
{text: "Aliases", link: "/dev-tools/aliases"}, { text: "Aliases", link: "/dev-tools/aliases" },
{text: "Comparison to asdf", link: "/dev-tools/comparison-to-asdf"}, { text: "Comparison to asdf", link: "/dev-tools/comparison-to-asdf" },
{text: "Shims", link: "/dev-tools/shims"}, { text: "Shims", link: "/dev-tools/shims" },
{ {
text: "Backends", text: "Backends",
link: "/dev-tools/backends/", link: "/dev-tools/backends/",
items: [ items: [
{text: "asdf", link: "/dev-tools/backends/asdf"}, { text: "asdf", link: "/dev-tools/backends/asdf" },
{text: "cargo", link: "/dev-tools/backends/cargo"}, { text: "cargo", link: "/dev-tools/backends/cargo" },
{text: "go", link: "/dev-tools/backends/go"}, { text: "go", link: "/dev-tools/backends/go" },
{text: "npm", link: "/dev-tools/backends/npm"}, { text: "npm", link: "/dev-tools/backends/npm" },
{text: "pipx", link: "/dev-tools/backends/pipx"}, { text: "pipx", link: "/dev-tools/backends/pipx" },
{text: "spm", link: "/dev-tools/backends/spm"}, { text: "spm", link: "/dev-tools/backends/spm" },
{text: "ubi", link: "/dev-tools/backends/ubi"}, { text: "ubi", link: "/dev-tools/backends/ubi" },
{text: "vfox", link: "/dev-tools/backends/vfox"}, { text: "vfox", link: "/dev-tools/backends/vfox" },
], ],
}, },
], ],
@ -64,40 +67,40 @@ export default defineConfig({
text: "Environments", text: "Environments",
link: "/environments", link: "/environments",
items: [ items: [
{text: "direnv", link: "/direnv"}, { text: "direnv", link: "/direnv" },
{text: "Profiles", link: "/profiles"}, { text: "Profiles", link: "/profiles" },
{text: "Templates", link: "/templates"}, { text: "Templates", link: "/templates" },
], ],
}, },
{ {
text: "Tasks", text: "Tasks",
link: "/tasks/", link: "/tasks/",
items: [ items: [
{text: "Running Tasks", link: "/tasks/running-tasks"}, { text: "Running Tasks", link: "/tasks/running-tasks" },
{text: "File Tasks", link: "/tasks/file-tasks"}, { text: "File Tasks", link: "/tasks/file-tasks" },
{text: "TOML Tasks", link: "/tasks/toml-tasks"}, { text: "TOML Tasks", link: "/tasks/toml-tasks" },
], ],
}, },
{ {
text: "Languages", text: "Languages",
items: [ items: [
{text: "Bun", link: "/lang/bun"}, { text: "Bun", link: "/lang/bun" },
{text: "Deno", link: "/lang/deno"}, { text: "Deno", link: "/lang/deno" },
{text: "Erlang", link: "/lang/erlang"}, { text: "Erlang", link: "/lang/erlang" },
{text: "Go", link: "/lang/go"}, { text: "Go", link: "/lang/go" },
{text: "Java", link: "/lang/java"}, { text: "Java", link: "/lang/java" },
{text: "Node.js", link: "/lang/node"}, { text: "Node.js", link: "/lang/node" },
{text: "Python", link: "/lang/python"}, { text: "Python", link: "/lang/python" },
{text: "Ruby", link: "/lang/ruby"}, { text: "Ruby", link: "/lang/ruby" },
{text: "Rust", link: "/lang/rust"}, { text: "Rust", link: "/lang/rust" },
], ],
}, },
{ {
text: "Internals", text: "Internals",
items: [ items: [
{text: "Cache Behavior", link: "/cache-behavior"}, { text: "Cache Behavior", link: "/cache-behavior" },
{text: "Directory Structure", link: "/directories"}, { text: "Directory Structure", link: "/directories" },
{text: "Project Roadmap", link: "/project-roadmap"}, { text: "Project Roadmap", link: "/project-roadmap" },
], ],
}, },
{ {
@ -107,7 +110,7 @@ export default defineConfig({
}, },
], ],
socialLinks: [{icon: "github", link: "https://github.com/jdx/mise"}], socialLinks: [{ icon: "github", link: "https://github.com/jdx/mise" }],
editLink: { editLink: {
pattern: "https://github.com/jdx/mise/edit/main/docs/:path", pattern: "https://github.com/jdx/mise/edit/main/docs/:path",

View File

@ -245,7 +245,7 @@ version files since they're version files not specific to asdf/mise and can be u
## Settings ## Settings
See [Settings](/settings) for the full list of settings. See [Settings](/configuration/settings) for the full list of settings.
## Tasks ## Tasks

View File

@ -13,28 +13,19 @@ export default {
function buildElement(key, props) { function buildElement(key, props) {
let type = props.type; let type = props.type;
let optional = false;
if (type.startsWith("Option<")) {
type = type.slice(7, -1);
optional = true;
}
type = type.replaceAll("PathBuf", "String"); type = type.replaceAll("PathBuf", "String");
let default_ = props.default; let default_ = props.default;
if (default_ === undefined && type === "bool" && !optional) { if (default_ === undefined && type === "Bool" && !props.optional) {
default_ = false; default_ = false;
} }
if (default_ === undefined && optional) { if (default_ === undefined && props.optional) {
default_ = "None"; default_ = "None";
} }
if (type === "u64" || type === "usize") { if (type === "Integer") {
type = "integer"; type = "integer";
} else if (type === "String") { } else if (type === "String") {
type = "string"; type = "string";
} else if ( } else if (type === "ListString" || type === "ListPath") {
type === "BTreeSet<String>" ||
type === "HashSet<String>" ||
type === "Vec<String>"
) {
type = "string[]"; type = "string[]";
} }
// } else if (type === "String" || type === "PathBuf") { // } else if (type === "String" || type === "PathBuf") {
@ -51,7 +42,7 @@ export default {
deprecated: props.deprecated, deprecated: props.deprecated,
enum: props.enum, enum: props.enum,
env: props.env, env: props.env,
optional, optional: props.optional,
type, type,
}; };
return ele; return ele;

View File

@ -13,8 +13,14 @@
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "devDependencies": {
"handlebars": "^4.7.8", "handlebars": "^4.7.8",
"toml": "^3.0.0" "toml": "^3.0.0",
"ts-pattern": "^5.4.0",
"tsx": "^4.19.1",
"typescript": "^5.6.3"
},
"dependencies": {
"@types/node": "^22.7.5"
} }
} }

View File

@ -190,6 +190,16 @@
"description": "Enable experimental mise features which are incomplete or unstable—breakings changes may occur", "description": "Enable experimental mise features which are incomplete or unstable—breakings changes may occur",
"type": "boolean" "type": "boolean"
}, },
"fetch_remote_versions_cache": {
"default": "1h",
"description": "How long to cache remote versions for tools.",
"type": "string"
},
"fetch_remote_versions_timeout": {
"default": "10s",
"description": "Timeout in seconds for HTTP requests to fetch new tool versions in mise.",
"type": "string"
},
"go_default_packages_file": { "go_default_packages_file": {
"default": "~/.default-go-packages", "default": "~/.default-go-packages",
"description": "Path to a file containing default go packages to install when installing go", "description": "Path to a file containing default go packages to install when installing go",
@ -224,9 +234,9 @@
"type": "boolean" "type": "boolean"
}, },
"http_timeout": { "http_timeout": {
"default": 30, "default": "30s",
"description": "Timeout in seconds for all HTTP requests in mise.", "description": "Timeout in seconds for all HTTP requests in mise.",
"type": "number" "type": "string"
}, },
"jobs": { "jobs": {
"default": 4, "default": 4,

View File

@ -3,7 +3,7 @@
[activate_aggressive] [activate_aggressive]
env = "MISE_ACTIVATE_AGGRESSIVE" env = "MISE_ACTIVATE_AGGRESSIVE"
type = "bool" type = "Bool"
description = "Pushes tools' bin-paths to the front of PATH instead of allowing modifications of PATH after activation to take precedence." description = "Pushes tools' bin-paths to the front of PATH instead of allowing modifications of PATH after activation to take precedence."
docs = """ docs = """
Pushes tools' bin-paths to the front of PATH instead of allowing modifications of PATH after activation to take precedence. For example, if you have the following in your `mise.toml`: Pushes tools' bin-paths to the front of PATH instead of allowing modifications of PATH after activation to take precedence. For example, if you have the following in your `mise.toml`:
@ -32,7 +32,7 @@ In that case, using this example again, `/some/other/python` will be after mise'
[all_compile] [all_compile]
env = "MISE_ALL_COMPILE" env = "MISE_ALL_COMPILE"
type = "bool" type = "Bool"
description = "do not use precompiled binaries for any tool" description = "do not use precompiled binaries for any tool"
docs = """ docs = """
Default: false unless running NixOS or Alpine (let me know if others should be added) Default: false unless running NixOS or Alpine (let me know if others should be added)
@ -47,17 +47,17 @@ working with this config.
[always_keep_download] [always_keep_download]
env = "MISE_ALWAYS_KEEP_DOWNLOAD" env = "MISE_ALWAYS_KEEP_DOWNLOAD"
type = "bool" type = "Bool"
description = "should mise keep downloaded files after installation" description = "should mise keep downloaded files after installation"
[always_keep_install] [always_keep_install]
env = "MISE_ALWAYS_KEEP_INSTALL" env = "MISE_ALWAYS_KEEP_INSTALL"
type = "bool" type = "Bool"
description = "should mise keep install files after installation even if the installation fails" description = "should mise keep install files after installation even if the installation fails"
[asdf] [asdf]
env = "MISE_ASDF" env = "MISE_ASDF"
type = "bool" type = "Bool"
default = true default = true
description = "use asdf as a default plugin backend" description = "use asdf as a default plugin backend"
docs = """ docs = """
@ -67,7 +67,7 @@ default to using an asdf plugin for cmake.
[asdf_compat] [asdf_compat]
env = "MISE_ASDF_COMPAT" env = "MISE_ASDF_COMPAT"
type = "bool" type = "Bool"
description = "set to true to ensure .tool-versions will be compatible with asdf" description = "set to true to ensure .tool-versions will be compatible with asdf"
docs = """ docs = """
Only output `.tool-versions` files in `mise local|global` which will be usable by asdf. Only output `.tool-versions` files in `mise local|global` which will be usable by asdf.
@ -80,7 +80,7 @@ of `~/.config/mise/config.toml`.
[cache_prune_age] [cache_prune_age]
env = "MISE_CACHE_PRUNE_AGE" env = "MISE_CACHE_PRUNE_AGE"
type = "String" type = "Duration"
default = "30d" default = "30d"
description = "Delete files in cache that have not been accessed in this duration" description = "Delete files in cache that have not been accessed in this duration"
docs = """ docs = """
@ -92,37 +92,38 @@ Set to `0` to keep cache files indefinitely.
[cargo_binstall] [cargo_binstall]
env = "MISE_CARGO_BINSTALL" env = "MISE_CARGO_BINSTALL"
type = "bool" type = "Bool"
default = true default = true
description = "Use cargo-binstall instead of cargo install if available" description = "Use cargo-binstall instead of cargo install if available"
[cd] [cd]
env = "MISE_CD" env = "MISE_CD"
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Path to change to after launching mise" description = "Path to change to after launching mise"
hide = true hide = true
[ci] [ci]
env = "CI" env = "CI"
type = "bool" type = "Bool"
description = "Set to true if running in a CI environment" description = "Set to true if running in a CI environment"
hide = true hide = true
[color] [color]
env = "MISE_COLOR" env = "MISE_COLOR"
type = "bool" type = "Bool"
default = true default = true
description = "Use color in mise terminal output" description = "Use color in mise terminal output"
[debug] [debug]
env = "MISE_DEBUG" env = "MISE_DEBUG"
type = "bool" type = "Bool"
hide = true hide = true
description = "Sets log level to debug" description = "Sets log level to debug"
[disable_default_shorthands] [disable_default_shorthands]
env = "MISE_DISABLE_DEFAULT_SHORTHANDS" env = "MISE_DISABLE_DEFAULT_SHORTHANDS"
type = "bool" type = "Bool"
description = "Disables built-in shorthands to asdf/vfox plugins" description = "Disables built-in shorthands to asdf/vfox plugins"
docs = """ docs = """
Disables the shorthand aliases for installing plugins. You will have to specify full URLs when Disables the shorthand aliases for installing plugins. You will have to specify full URLs when
@ -131,27 +132,30 @@ installing plugins, e.g.: `mise plugin install node https://github.com/asdf-vm/a
[disable_hints] [disable_hints]
env = "MISE_DISABLE_HINTS" env = "MISE_DISABLE_HINTS"
type = "BTreeSet<String>" type = "ListString"
rust_type = "BTreeSet<String>"
default = [] default = []
parse_env = "list_by_comma" parse_env = "list_by_comma"
description = "Turns off helpful hints when using different mise features" description = "Turns off helpful hints when using different mise features"
[disable_tools] [disable_tools]
env = "MISE_DISABLE_TOOLS" env = "MISE_DISABLE_TOOLS"
type = "BTreeSet<String>" type = "ListString"
rust_type = "BTreeSet<String>"
default = [] default = []
parse_env = "list_by_comma" parse_env = "list_by_comma"
description = "Tools defined in mise.toml that should be ignored" description = "Tools defined in mise.toml that should be ignored"
[env_file] [env_file]
env = "MISE_ENV_FILE" env = "MISE_ENV_FILE"
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Path to a file containing environment variables." description = "Path to a file containing environment variables."
hide = true hide = true
[experimental] [experimental]
env = "MISE_EXPERIMENTAL" env = "MISE_EXPERIMENTAL"
type = "bool" type = "Bool"
description = "Enable experimental mise features which are incomplete or unstable—breakings changes may occur" description = "Enable experimental mise features which are incomplete or unstable—breakings changes may occur"
docs = """ docs = """
Enables experimental features. I generally will publish new features under Enables experimental features. I generally will publish new features under
@ -172,9 +176,29 @@ a particular feature you'd like to try. Also, if something isn't working
right, try disabling it if you can. right, try disabling it if you can.
""" """
[fetch_remote_versions_cache]
env = "MISE_FETCH_REMOTE_VERSIONS_CACHE"
type = "Duration"
default = "1h"
description = "How long to cache remote versions for tools."
docs = """
duration that remote version cache is kept for
for "fast" commands (represented by PREFER_STALE), these are always
cached. For "slow" commands like `mise ls-remote` or `mise install`:
- if MISE_FETCH_REMOTE_VERSIONS_CACHE is set, use that
- if MISE_FETCH_REMOTE_VERSIONS_CACHE is not set, use HOURLY
"""
[fetch_remote_versions_timeout]
env = "MISE_FETCH_REMOTE_VERSIONS_TIMEOUT"
type = "Duration"
default = "10s"
description = "Timeout in seconds for HTTP requests to fetch new tool versions in mise."
aliases = ["fetch_remote_version_timeout"]
[go_default_packages_file] [go_default_packages_file]
env = "MISE_GO_DEFAULT_PACKAGES_FILE" env = "MISE_GO_DEFAULT_PACKAGES_FILE"
type = "PathBuf" type = "Path"
default = "~/.default-go-packages" default = "~/.default-go-packages"
description = "Path to a file containing default go packages to install when installing go" description = "Path to a file containing default go packages to install when installing go"
@ -186,13 +210,14 @@ description = "Mirror to download go sdk tarballs from."
[go_repo] [go_repo]
env = "MISE_GO_REPO" env = "MISE_GO_REPO"
type = "String" type = "Url"
default = "https://github.com/golang/go" default = "https://github.com/golang/go"
description = "URL to fetch go from." description = "URL to fetch go from."
[go_set_gobin] [go_set_gobin]
env = "MISE_GO_SET_GOBIN" env = "MISE_GO_SET_GOBIN"
type = "Option<bool>" type = "Bool"
optional = true
description = "Changes where `go install` installs binaries to." description = "Changes where `go install` installs binaries to."
docs = """ docs = """
Defaults to `~/.local/share/mise/installs/go/.../bin`. Defaults to `~/.local/share/mise/installs/go/.../bin`.
@ -202,37 +227,38 @@ Set to `false` to not set GOBIN (default is `${GOPATH:-$HOME/go}/bin`).
[go_set_gopath] [go_set_gopath]
env = "MISE_GO_SET_GOPATH" env = "MISE_GO_SET_GOPATH"
type = "bool" type = "Bool"
description = "[deprecated] Set to true to set GOPATH=~/.local/share/mise/installs/go/.../packages." description = "[deprecated] Set to true to set GOPATH=~/.local/share/mise/installs/go/.../packages."
deprecated = "Use env._go.set_goroot instead." deprecated = "Use env._go.set_goroot instead."
[go_set_goroot] [go_set_goroot]
env = "MISE_GO_SET_GOROOT" env = "MISE_GO_SET_GOROOT"
type = "bool" type = "Bool"
default = true default = true
description = "Sets GOROOT=~/.local/share/mise/installs/go/.../." description = "Sets GOROOT=~/.local/share/mise/installs/go/.../."
[go_skip_checksum] [go_skip_checksum]
env = "MISE_GO_SKIP_CHECKSUM" env = "MISE_GO_SKIP_CHECKSUM"
type = "bool" type = "Bool"
description = "Set to true to skip checksum verification when downloading go sdk tarballs." description = "Set to true to skip checksum verification when downloading go sdk tarballs."
[http_timeout] [http_timeout]
env = "MISE_HTTP_TIMEOUT" env = "MISE_HTTP_TIMEOUT"
type = "u64" type = "Duration"
default = 30 default = "30s"
description = "Timeout in seconds for all HTTP requests in mise." description = "Timeout in seconds for all HTTP requests in mise."
[jobs] [jobs]
env = "MISE_JOBS" env = "MISE_JOBS"
type = "usize" type = "Integer"
rust_type = "usize"
default = 4 default = 4
description = "How many jobs to run concurrently such as tool installs." description = "How many jobs to run concurrently such as tool installs."
# TODO: rename to "idiomatic_version_file" # TODO: rename to "idiomatic_version_file"
[legacy_version_file] [legacy_version_file]
env = "MISE_LEGACY_VERSION_FILE" env = "MISE_LEGACY_VERSION_FILE"
type = "bool" type = "Bool"
default = true default = true
description = "Set to false to disable the idiomatic version files such as .node-version, .ruby-version, etc." description = "Set to false to disable the idiomatic version files such as .node-version, .ruby-version, etc."
docs = """ docs = """
@ -246,14 +272,15 @@ Set to "0" to disable legacy version file parsing.
[legacy_version_file_disable_tools] [legacy_version_file_disable_tools]
env = "MISE_LEGACY_VERSION_FILE_DISABLE_TOOLS" env = "MISE_LEGACY_VERSION_FILE_DISABLE_TOOLS"
type = "BTreeSet<String>" type = "ListString"
rust_type = "BTreeSet<String>"
default = [] default = []
parse_env = "list_by_comma" parse_env = "list_by_comma"
description = "Specific tools to disable idiomatic version files for." description = "Specific tools to disable idiomatic version files for."
[libgit2] [libgit2]
env = "MISE_LIBGIT2" env = "MISE_LIBGIT2"
type = "bool" type = "Bool"
default = true default = true
description = "Use libgit2 for git operations, set to false to shell out to git." description = "Use libgit2 for git operations, set to false to shell out to git."
docs = """ docs = """
@ -277,22 +304,25 @@ enum = [
[node.compile] [node.compile]
env = "MISE_NODE_COMPILE" env = "MISE_NODE_COMPILE"
type = "Option<bool>" type = "Bool"
optional = true
description = "Compile node from source." description = "Compile node from source."
[node.flavor] [node.flavor]
env = "MISE_NODE_FLAVOR" env = "MISE_NODE_FLAVOR"
type = "Option<String>" type = "String"
optional = true
description = "Install a specific node flavor like glibc-217 or musl. Use with unofficial node build repo." description = "Install a specific node flavor like glibc-217 or musl. Use with unofficial node build repo."
[node.mirror_url] [node.mirror_url]
env = "MISE_NODE_MIRROR_URL" env = "MISE_NODE_MIRROR_URL"
type = "Option<String>" type = "Url"
optional = true
description = "Mirror to download node tarballs from." description = "Mirror to download node tarballs from."
[not_found_auto_install] [not_found_auto_install]
env = "MISE_NOT_FOUND_AUTO_INSTALL" env = "MISE_NOT_FOUND_AUTO_INSTALL"
type = "bool" type = "Bool"
default = true default = true
description = "Set to false to disable the \"command not found\" handler to autoinstall missing tool versions." description = "Set to false to disable the \"command not found\" handler to autoinstall missing tool versions."
docs = """ docs = """
@ -303,7 +333,7 @@ ticket to help diagnose problems.
[paranoid] [paranoid]
env = "MISE_PARANOID" env = "MISE_PARANOID"
type = "bool" type = "Bool"
description = "Enables extra-secure behavior." description = "Enables extra-secure behavior."
docs = """ docs = """
Enables extra-secure behavior. See [Paranoid](/paranoid). Enables extra-secure behavior. See [Paranoid](/paranoid).
@ -311,7 +341,7 @@ Enables extra-secure behavior. See [Paranoid](/paranoid).
[pin] [pin]
env = "MISE_PIN" env = "MISE_PIN"
type = "bool" type = "Bool"
description = "Default to pinning versions when running `mise use` in mise.toml files." description = "Default to pinning versions when running `mise use` in mise.toml files."
docs = """ docs = """
This sets `--pin` by default when running `mise use` in mise.toml files. This can be overridden by This sets `--pin` by default when running `mise use` in mise.toml files. This can be overridden by
@ -320,7 +350,7 @@ passing `--fuzzy` on the command line.
[pipx_uvx] [pipx_uvx]
env = "MISE_PIPX_UVX" env = "MISE_PIPX_UVX"
type = "bool" type = "Bool"
description = "Use uvx instead of pipx if uv is installed and on PATH." description = "Use uvx instead of pipx if uv is installed and on PATH."
[plugin_autoupdate_last_check_duration] [plugin_autoupdate_last_check_duration]
@ -331,7 +361,8 @@ description = "How long to wait before updating plugins automatically (note this
[python.compile] [python.compile]
env = "MISE_PYTHON_COMPILE" env = "MISE_PYTHON_COMPILE"
type = "Option<bool>" type = "Bool"
optional = true
description = "If true, compile python from source. If false, use precompiled binaries. If not set, use precompiled binaries if available." description = "If true, compile python from source. If false, use precompiled binaries. If not set, use precompiled binaries if available."
docs = """ docs = """
* Values: * Values:
@ -342,28 +373,33 @@ docs = """
[python.default_packages_file] [python.default_packages_file]
env = "MISE_PYTHON_DEFAULT_PACKAGES_FILE" env = "MISE_PYTHON_DEFAULT_PACKAGES_FILE"
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Path to a file containing default python packages to install when installing a python version." description = "Path to a file containing default python packages to install when installing a python version."
[python.patch_url] [python.patch_url]
env = "MISE_PYTHON_PATCH_URL" env = "MISE_PYTHON_PATCH_URL"
type = "Option<String>" type = "Url"
optional = true
description = "URL to fetch python patches from to pass to python-build." description = "URL to fetch python patches from to pass to python-build."
[python.patches_directory] [python.patches_directory]
env = "MISE_PYTHON_PATCHES_DIRECTORY" env = "MISE_PYTHON_PATCHES_DIRECTORY"
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Directory to fetch python patches from." description = "Directory to fetch python patches from."
[python.precompiled_arch] [python.precompiled_arch]
env = "MISE_PYTHON_PRECOMPILED_ARCH" env = "MISE_PYTHON_PRECOMPILED_ARCH"
type = "Option<String>" type = "String"
optional = true
description = "Specify the architecture to use for precompiled binaries." description = "Specify the architecture to use for precompiled binaries."
default_docs = '"apple-darwin" | "unknown-linux-gnu" | "unknown-linux-musl"' default_docs = '"apple-darwin" | "unknown-linux-gnu" | "unknown-linux-musl"'
[python.precompiled_os] [python.precompiled_os]
env = "MISE_PYTHON_PRECOMPILED_OS" env = "MISE_PYTHON_PRECOMPILED_OS"
type = "Option<String>" type = "String"
optional = true
default_docs = '"x86_64_v3" | "aarch64"' default_docs = '"x86_64_v3" | "aarch64"'
description = "Specify the OS to use for precompiled binaries." description = "Specify the OS to use for precompiled binaries."
docs = """ docs = """
@ -378,82 +414,92 @@ description = "URL to fetch pyenv from for compiling python with python-build."
[python.venv_auto_create] [python.venv_auto_create]
env = "MISE_PYTHON_VENV_AUTO_CREATE" env = "MISE_PYTHON_VENV_AUTO_CREATE"
type = "bool" type = "Bool"
hide = true hide = true
deprecated = "Use env._python.venv instead." deprecated = "Use env._python.venv instead."
description = "Automatically create virtualenvs for python tools." description = "Automatically create virtualenvs for python tools."
[python.venv_stdlib] [python.venv_stdlib]
env = "MISE_VENV_STDLIB" env = "MISE_VENV_STDLIB"
type = "bool" type = "Bool"
description = "Prefer to use venv from Python's standard library." description = "Prefer to use venv from Python's standard library."
[python_compile] [python_compile]
type = "Option<bool>" type = "Bool"
optional = true
description = "If true, compile python from source. If false, use precompiled binaries. If not set, use precompiled binaries if available." description = "If true, compile python from source. If false, use precompiled binaries. If not set, use precompiled binaries if available."
deprecated = "Use python.compile instead." deprecated = "Use python.compile instead."
hide = true hide = true
[python_default_packages_file] [python_default_packages_file]
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Path to a file containing default python packages to install when installing python." description = "Path to a file containing default python packages to install when installing python."
deprecated = "Use python.default_packages_file instead." deprecated = "Use python.default_packages_file instead."
hide = true hide = true
[python_patch_url] [python_patch_url]
type = "Option<String>" type = "String"
optional = true
description = "URL to fetch python patches from." description = "URL to fetch python patches from."
deprecated = "Use python.patch_url instead." deprecated = "Use python.patch_url instead."
hide = true hide = true
[python_patches_directory] [python_patches_directory]
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Directory to fetch python patches from." description = "Directory to fetch python patches from."
deprecated = "Use python.patch_url instead." deprecated = "Use python.patch_url instead."
hide = true hide = true
[python_precompiled_arch] [python_precompiled_arch]
type = "Option<String>" type = "String"
optional = true
description = "Specify the architecture to use for precompiled binaries." description = "Specify the architecture to use for precompiled binaries."
deprecated = "Use python.precompiled_arch instead." deprecated = "Use python.precompiled_arch instead."
hide = true hide = true
[python_precompiled_os] [python_precompiled_os]
type = "Option<String>" type = "String"
optional = true
description = "Specify the OS to use for precompiled binaries." description = "Specify the OS to use for precompiled binaries."
deprecated = "Use python.precompiled_os instead." deprecated = "Use python.precompiled_os instead."
hide = true hide = true
[python_pyenv_repo] [python_pyenv_repo]
type = "Option<String>" type = "String"
optional = true
description = "URL to fetch pyenv from for compiling python." description = "URL to fetch pyenv from for compiling python."
deprecated = "Use python.pyenv_repo instead." deprecated = "Use python.pyenv_repo instead."
hide = true hide = true
[python_venv_auto_create] [python_venv_auto_create]
type = "Option<bool>" type = "Bool"
optional = true
hide = true hide = true
deprecated = "Use env._python.venv instead." deprecated = "Use env._python.venv instead."
description = "Automatically create virtualenvs for python tools." description = "Automatically create virtualenvs for python tools."
[python_venv_stdlib] [python_venv_stdlib]
type = "Option<bool>" type = "Bool"
optional = true
description = "Prefer to use venv from Python's standard library." description = "Prefer to use venv from Python's standard library."
hide = true hide = true
[quiet] [quiet]
env = "MISE_QUIET" env = "MISE_QUIET"
type = "bool" type = "Bool"
description = "Suppress all output except errors." description = "Suppress all output except errors."
[raw] [raw]
env = "MISE_RAW" env = "MISE_RAW"
type = "bool" type = "Bool"
description = "Connect stdin/stdout/stderr to child processes." description = "Connect stdin/stdout/stderr to child processes."
[ruby.apply_patches] [ruby.apply_patches]
env = "MISE_RUBY_APPLY_PATCHES" env = "MISE_RUBY_APPLY_PATCHES"
type = "Option<String>" type = "String"
optional = true
description = "A list of patch files or URLs to apply to ruby source." description = "A list of patch files or URLs to apply to ruby source."
[ruby.default_packages_file] [ruby.default_packages_file]
@ -464,7 +510,8 @@ description = "Path to a file containing default ruby gems to install when insta
[ruby.ruby_build_opts] [ruby.ruby_build_opts]
env = "MISE_RUBY_BUILD_OPTS" env = "MISE_RUBY_BUILD_OPTS"
type = "Option<String>" type = "String"
optional = true
description = "Options to pass to ruby-build." description = "Options to pass to ruby-build."
[ruby.ruby_build_repo] [ruby.ruby_build_repo]
@ -475,12 +522,13 @@ description = "URL to fetch ruby-build from."
[ruby.ruby_install] [ruby.ruby_install]
env = "MISE_RUBY_INSTALL" env = "MISE_RUBY_INSTALL"
type = "bool" type = "Bool"
description = "Use ruby-install instead of ruby-build." description = "Use ruby-install instead of ruby-build."
[ruby.ruby_install_opts] [ruby.ruby_install_opts]
env = "MISE_RUBY_INSTALL_OPTS" env = "MISE_RUBY_INSTALL_OPTS"
type = "Option<String>" type = "String"
optional = true
description = "Options to pass to ruby-install." description = "Options to pass to ruby-install."
[ruby.ruby_install_repo] [ruby.ruby_install_repo]
@ -491,12 +539,14 @@ description = "URL to fetch ruby-install from."
[ruby.verbose_install] [ruby.verbose_install]
env = "MISE_RUBY_VERBOSE_INSTALL" env = "MISE_RUBY_VERBOSE_INSTALL"
type = "Option<bool>" type = "Bool"
optional = true
description = "Set to true to enable verbose output during ruby installation." description = "Set to true to enable verbose output during ruby installation."
[shorthands_file] [shorthands_file]
env = "MISE_SHORTHANDS_FILE" env = "MISE_SHORTHANDS_FILE"
type = "Option<PathBuf>" type = "Path"
optional = true
description = "Path to a file containing custom tool shorthands." description = "Path to a file containing custom tool shorthands."
docs = """ docs = """
Use a custom file for the shorthand aliases. This is useful if you want to share plugins within Use a custom file for the shorthand aliases. This is useful if you want to share plugins within
@ -537,17 +587,18 @@ Disable tools with [`disable_tools`](#disable_tools).
[status.show_env] [status.show_env]
env = "MISE_STATUS_MESSAGE_SHOW_ENV" env = "MISE_STATUS_MESSAGE_SHOW_ENV"
type = "bool" type = "Bool"
description = "Show configured env vars when entering a directory with a mise.toml file." description = "Show configured env vars when entering a directory with a mise.toml file."
[status.show_tools] [status.show_tools]
env = "MISE_STATUS_MESSAGE_SHOW_TOOLS" env = "MISE_STATUS_MESSAGE_SHOW_TOOLS"
type = "bool" type = "Bool"
description = "Show configured env vars when entering a directory with a mise.toml file." description = "Show configured env vars when entering a directory with a mise.toml file."
[task_output] [task_output]
env = "MISE_TASK_OUTPUT" env = "MISE_TASK_OUTPUT"
type = "Option<String>" type = "String"
optional = true
description = "Change output style when executing tasks." description = "Change output style when executing tasks."
enum = [ enum = [
["prefix", "(default if jobs > 1) print by line with the prefix of the task name"], ["prefix", "(default if jobs > 1) print by line with the prefix of the task name"],
@ -559,20 +610,21 @@ Change output style when executing tasks. This controls the output of `mise run`
[trace] [trace]
env = "MISE_TRACE" env = "MISE_TRACE"
type = "bool" type = "Bool"
hide = true hide = true
description = "Sets log level to trace" description = "Sets log level to trace"
[trusted_config_paths] [trusted_config_paths]
env = "MISE_TRUSTED_CONFIG_PATHS" env = "MISE_TRUSTED_CONFIG_PATHS"
type = "BTreeSet<PathBuf>" type = "ListPath"
rust_type = "BTreeSet<PathBuf>"
default = [] default = []
parse_env = "list_by_colon" parse_env = "list_by_colon"
description = "This is a list of config paths that mise will automatically mark as trusted." description = "This is a list of config paths that mise will automatically mark as trusted."
[use_versions_host] [use_versions_host]
env = "MISE_USE_VERSIONS_HOST" env = "MISE_USE_VERSIONS_HOST"
type = "bool" type = "Bool"
default = true default = true
description = "Set to false to disable using the mise-versions API as a quick way for mise to query for new versions." description = "Set to false to disable using the mise-versions API as a quick way for mise to query for new versions."
docs = """ docs = """
@ -586,12 +638,12 @@ See [FAQ](/faq#new-version-of-a-tool-is-not-available) for more information.
[verbose] [verbose]
env = "MISE_VERBOSE" env = "MISE_VERBOSE"
type = "bool" type = "Bool"
description = "Shows more verbose output such as installation logs when installing tools." description = "Shows more verbose output such as installation logs when installing tools."
[vfox] [vfox]
env = "MISE_VFOX" env = "MISE_VFOX"
type = "bool" type = "Bool"
description = "Use vfox as a default plugin backend instead of asdf." description = "Use vfox as a default plugin backend instead of asdf."
docs = """ docs = """
Use vfox as a default plugin backend. This means running something like `mise use cmake` will Use vfox as a default plugin backend. This means running something like `mise use cmake` will
@ -600,5 +652,5 @@ default to using an vfox plugin for cmake.
[yes] [yes]
env = "MISE_YES" env = "MISE_YES"
type = "bool" type = "Bool"
description = "This will automatically answer yes or no to prompts. This is useful for scripting." description = "This will automatically answer yes or no to prompts. This is useful for scripting."

View File

@ -15,6 +15,7 @@ use crate::backend::external_plugin_cache::ExternalPluginCache;
use crate::backend::{ABackend, Backend, BackendList}; use crate::backend::{ABackend, Backend, BackendList};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::config::settings::SETTINGS;
use crate::config::{Config, Settings}; use crate::config::{Config, Settings};
use crate::default_shorthands::DEFAULT_SHORTHANDS; use crate::default_shorthands::DEFAULT_SHORTHANDS;
use crate::env_diff::{EnvDiff, EnvDiffOperation}; use crate::env_diff::{EnvDiff, EnvDiffOperation};
@ -59,14 +60,14 @@ impl AsdfBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.with_fresh_file(plugin_path.clone()) .with_fresh_file(plugin_path.clone())
.with_fresh_file(plugin_path.join("bin/list-all")) .with_fresh_file(plugin_path.join("bin/list-all"))
.build(), .build(),
latest_stable_cache: CacheManagerBuilder::new( latest_stable_cache: CacheManagerBuilder::new(
ba.cache_path.join("latest_stable.msgpack.z"), ba.cache_path.join("latest_stable.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.with_fresh_file(plugin_path.clone()) .with_fresh_file(plugin_path.clone())
.with_fresh_file(plugin_path.join("bin/latest-stable")) .with_fresh_file(plugin_path.join("bin/latest-stable"))
.build(), .build(),

View File

@ -9,8 +9,9 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::{Config, Settings}; use crate::config::{Config, Settings};
use crate::env::{self, GITHUB_TOKEN}; use crate::env::GITHUB_TOKEN;
use crate::file; use crate::file;
use crate::http::HTTP_FETCH; use crate::http::HTTP_FETCH;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
@ -116,7 +117,7 @@ impl CargoBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
ba, ba,
} }

View File

@ -4,8 +4,8 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::Settings; use crate::config::Settings;
use crate::env;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
use crate::toolset::ToolRequest; use crate::toolset::ToolRequest;
@ -95,7 +95,7 @@ impl GoBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
ba, ba,
} }

View File

@ -5,8 +5,8 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::Config; use crate::config::Config;
use crate::env;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
use crate::toolset::ToolRequest; use crate::toolset::ToolRequest;
@ -91,12 +91,12 @@ impl NPMBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
latest_version_cache: CacheManagerBuilder::new( latest_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("latest_version.msgpack.z"), ba.cache_path.join("latest_version.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
ba, ba,
} }

View File

@ -8,11 +8,12 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::{Config, Settings}; use crate::config::{Config, Settings};
use crate::github;
use crate::http::HTTP_FETCH; use crate::http::HTTP_FETCH;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
use crate::toolset::{ToolRequest, ToolVersionOptions}; use crate::toolset::{ToolRequest, ToolVersionOptions};
use crate::{env, github};
#[derive(Debug)] #[derive(Debug)]
pub struct PIPXBackend { pub struct PIPXBackend {
@ -122,12 +123,12 @@ impl PIPXBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
latest_version_cache: CacheManagerBuilder::new( latest_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("latest_version.msgpack.z"), ba.cache_path.join("latest_version.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
ba, ba,
} }

View File

@ -13,9 +13,10 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::Settings; use crate::config::Settings;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
use crate::{env, file, github}; use crate::{file, github};
#[derive(Debug)] #[derive(Debug)]
pub struct SPMBackend { pub struct SPMBackend {
@ -90,7 +91,7 @@ impl SPMBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
ba, ba,
} }

View File

@ -4,8 +4,9 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::{Config, Settings}; use crate::config::{Config, Settings};
use crate::env::{self, GITHUB_TOKEN}; use crate::env::GITHUB_TOKEN;
use crate::github; use crate::github;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
use crate::toolset::ToolRequest; use crate::toolset::ToolRequest;
@ -84,7 +85,7 @@ impl UbiBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
ba, ba,
} }

View File

@ -12,6 +12,7 @@ use url::Url;
use crate::backend::{ABackend, Backend, BackendList, BackendType}; use crate::backend::{ABackend, Backend, BackendList, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::config::settings::SETTINGS;
use crate::config::{Config, Settings}; use crate::config::{Config, Settings};
use crate::git::Git; use crate::git::Git;
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
@ -124,7 +125,7 @@ impl VfoxBackend {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
ba.cache_path.join("remote_versions.msgpack.z"), ba.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.with_fresh_file(dirs::DATA.to_path_buf()) .with_fresh_file(dirs::DATA.to_path_buf())
.with_fresh_file(plugin_path.to_path_buf()) .with_fresh_file(plugin_path.to_path_buf())
.with_fresh_file(ba.installs_path.to_path_buf()) .with_fresh_file(ba.installs_path.to_path_buf())

View File

@ -72,13 +72,15 @@ mod tests {
disable_hints = [] disable_hints = []
disable_tools = [] disable_tools = []
experimental = true experimental = true
fetch_remote_versions_cache = "1h"
fetch_remote_versions_timeout = "10s"
go_default_packages_file = "~/.default-go-packages" go_default_packages_file = "~/.default-go-packages"
go_download_mirror = "https://dl.google.com/go" go_download_mirror = "https://dl.google.com/go"
go_repo = "https://github.com/golang/go" go_repo = "https://github.com/golang/go"
go_set_gopath = false go_set_gopath = false
go_set_goroot = true go_set_goroot = true
go_skip_checksum = false go_skip_checksum = false
http_timeout = 30 http_timeout = "30s"
jobs = 2 jobs = 2
legacy_version_file = true legacy_version_file = true
legacy_version_file_disable_tools = [] legacy_version_file_disable_tools = []
@ -135,6 +137,8 @@ mod tests {
disable_hints disable_hints
disable_tools disable_tools
experimental experimental
fetch_remote_versions_cache
fetch_remote_versions_timeout
go_default_packages_file go_default_packages_file
go_download_mirror go_download_mirror
go_repo go_repo

View File

@ -1,7 +1,7 @@
use eyre::{eyre, Result}; use eyre::{bail, eyre, Result};
use toml_edit::DocumentMut; use toml_edit::DocumentMut;
use crate::config::settings::SettingsFile; use crate::config::settings::{SettingsFile, SettingsType, SETTINGS_META};
use crate::{env, file}; use crate::{env, file};
/// Add/update a setting /// Add/update a setting
@ -19,69 +19,17 @@ pub struct SettingsSet {
impl SettingsSet { impl SettingsSet {
pub fn run(self) -> Result<()> { pub fn run(self) -> Result<()> {
let value: toml_edit::Value = match self.setting.as_str() { let value = if let Some(meta) = SETTINGS_META.get(&self.setting) {
"activate_aggressive" => parse_bool(&self.value)?, match meta.type_ {
"all_compile" => parse_bool(&self.value)?, SettingsType::Bool => parse_bool(&self.value)?,
"always_keep_download" => parse_bool(&self.value)?, SettingsType::Integer => parse_i64(&self.value)?,
"always_keep_install" => parse_bool(&self.value)?, SettingsType::Duration => parse_duration(&self.value)?,
"asdf" => parse_bool(&self.value)?, SettingsType::Url | SettingsType::Path | SettingsType::String => self.value.into(),
"asdf_compat" => parse_bool(&self.value)?, SettingsType::ListString => parse_list_by_comma(&self.value)?,
"cargo_binstall" => parse_bool(&self.value)?, SettingsType::ListPath => parse_list_by_colon(&self.value)?,
"color" => parse_bool(&self.value)?,
"disable_default_shorthands" => parse_bool(&self.value)?,
"disable_hints" => self.value.split(',').map(|s| s.to_string()).collect(),
"disable_tools" => self.value.split(',').map(|s| s.to_string()).collect(),
"experimental" => parse_bool(&self.value)?,
"go_default_packages_file" => self.value.into(),
"go_download_mirror" => self.value.into(),
"go_repo" => self.value.into(),
"go_set_gobin" => parse_bool(&self.value)?,
"go_set_gopath" => parse_bool(&self.value)?,
"go_set_goroot" => parse_bool(&self.value)?,
"go_skip_checksum" => parse_bool(&self.value)?,
"http_timeout" => parse_i64(&self.value)?,
"jobs" => parse_i64(&self.value)?,
"legacy_version_file" => parse_bool(&self.value)?,
"legacy_version_file_disable_tools" => {
self.value.split(',').map(|s| s.to_string()).collect()
} }
"libgit2" => parse_bool(&self.value)?, } else {
"node.compile" => parse_bool(&self.value)?, bail!("Unknown setting: {}", self.setting);
"node.flavor" => self.value.into(),
"node.mirror_url" => self.value.into(),
"not_found_auto_install" => parse_bool(&self.value)?,
"paranoid" => parse_bool(&self.value)?,
"pin" => parse_bool(&self.value)?,
"pipx_uvx" => parse_bool(&self.value)?,
"plugin_autoupdate_last_check_duration" => self.value.into(),
"python.compile" => parse_bool(&self.value)?,
"python.default_packages_file" => self.value.into(),
"python.pyenv_repo" => self.value.into(),
"python.venv_auto_create" => parse_bool(&self.value)?,
"python_compile" => parse_bool(&self.value)?,
"python_default_packages_file" => self.value.into(),
"python_pyenv_repo" => self.value.into(),
"python_venv_auto_create" => parse_bool(&self.value)?,
"quiet" => parse_bool(&self.value)?,
"raw" => parse_bool(&self.value)?,
"ruby.apply_patches" => self.value.into(),
"ruby.default_packages_file" => self.value.into(),
"ruby.ruby_build_repo" => self.value.into(),
"ruby.ruby_build_opts" => self.value.into(),
"ruby.ruby_install" => parse_bool(&self.value)?,
"ruby.ruby_install_repo" => self.value.into(),
"ruby.ruby_install_opts" => self.value.into(),
"ruby.verbose_install" => parse_bool(&self.value)?,
"shorthands_file" => self.value.into(),
"status.missing_tools" => self.value.into(),
"status.show_env" => parse_bool(&self.value)?,
"status.show_tools" => parse_bool(&self.value)?,
"task_output" => self.value.into(),
"trusted_config_paths" => self.value.split(':').map(|s| s.to_string()).collect(),
"verbose" => parse_bool(&self.value)?,
"vfox" => parse_bool(&self.value)?,
"yes" => parse_bool(&self.value)?,
_ => return Err(eyre!("Unknown setting: {}", self.setting)),
}; };
let path = &*env::MISE_GLOBAL_CONFIG_FILE; let path = &*env::MISE_GLOBAL_CONFIG_FILE;
@ -111,6 +59,14 @@ impl SettingsSet {
} }
} }
fn parse_list_by_comma(value: &str) -> Result<toml_edit::Value> {
Ok(value.split(',').map(|s| s.to_string()).collect())
}
fn parse_list_by_colon(value: &str) -> Result<toml_edit::Value> {
Ok(value.split(':').map(|s| s.to_string()).collect())
}
fn parse_bool(value: &str) -> Result<toml_edit::Value> { fn parse_bool(value: &str) -> Result<toml_edit::Value> {
match value.to_lowercase().as_str() { match value.to_lowercase().as_str() {
"1" | "true" | "yes" | "y" => Ok(true.into()), "1" | "true" | "yes" | "y" => Ok(true.into()),
@ -126,6 +82,11 @@ fn parse_i64(value: &str) -> Result<toml_edit::Value> {
} }
} }
fn parse_duration(value: &str) -> Result<toml_edit::Value> {
humantime::parse_duration(value)?;
Ok(value.into())
}
static AFTER_LONG_HELP: &str = color_print::cstr!( static AFTER_LONG_HELP: &str = color_print::cstr!(
r#"<bold><underline>Examples:</underline></bold> r#"<bold><underline>Examples:</underline></bold>
@ -164,13 +125,15 @@ pub mod tests {
disable_hints = [] disable_hints = []
disable_tools = [] disable_tools = []
experimental = true experimental = true
fetch_remote_versions_cache = "1h"
fetch_remote_versions_timeout = "10s"
go_default_packages_file = "~/.default-go-packages" go_default_packages_file = "~/.default-go-packages"
go_download_mirror = "https://dl.google.com/go" go_download_mirror = "https://dl.google.com/go"
go_repo = "https://github.com/golang/go" go_repo = "https://github.com/golang/go"
go_set_gopath = false go_set_gopath = false
go_set_goroot = true go_set_goroot = true
go_skip_checksum = false go_skip_checksum = false
http_timeout = 30 http_timeout = "30s"
jobs = 2 jobs = 2
legacy_version_file = false legacy_version_file = false
legacy_version_file_disable_tools = [] legacy_version_file_disable_tools = []

View File

@ -63,13 +63,15 @@ mod tests {
disable_hints = [] disable_hints = []
disable_tools = [] disable_tools = []
experimental = true experimental = true
fetch_remote_versions_cache = "1h"
fetch_remote_versions_timeout = "10s"
go_default_packages_file = "~/.default-go-packages" go_default_packages_file = "~/.default-go-packages"
go_download_mirror = "https://dl.google.com/go" go_download_mirror = "https://dl.google.com/go"
go_repo = "https://github.com/golang/go" go_repo = "https://github.com/golang/go"
go_set_gopath = false go_set_gopath = false
go_set_goroot = true go_set_goroot = true
go_skip_checksum = false go_skip_checksum = false
http_timeout = 30 http_timeout = "30s"
jobs = 4 jobs = 4
legacy_version_file = true legacy_version_file = true
legacy_version_file_disable_tools = [] legacy_version_file_disable_tools = []

View File

@ -5,6 +5,7 @@ use crate::{config, dirs, env, file};
use confique::env::parse::{list_by_colon, list_by_comma}; use confique::env::parse::{list_by_colon, list_by_comma};
use confique::{Config, Partial}; use confique::{Config, Partial};
use eyre::{bail, Result}; use eyre::{bail, Result};
use indexmap::{indexmap, IndexMap};
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use serde::ser::Error; use serde::ser::Error;
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
@ -23,6 +24,23 @@ pub static SETTINGS: Lazy<Arc<Settings>> = Lazy::new(Settings::get);
// make sure you run `mise run render` after updating settings.toml // make sure you run `mise run render` after updating settings.toml
include!(concat!(env!("OUT_DIR"), "/settings.rs")); include!(concat!(env!("OUT_DIR"), "/settings.rs"));
pub enum SettingsType {
Bool,
String,
Integer,
Duration,
Path,
Url,
ListString,
ListPath,
}
pub struct SettingsMeta {
// pub key: String,
pub type_: SettingsType,
// pub description: String,
}
#[derive( #[derive(
Debug, Clone, Copy, Serialize, Deserialize, Default, strum::EnumString, strum::Display, Debug, Clone, Copy, Serialize, Deserialize, Default, strum::EnumString, strum::Display,
)] )]
@ -329,6 +347,23 @@ impl Settings {
} }
Some(humantime::parse_duration(&self.cache_prune_age).unwrap()) Some(humantime::parse_duration(&self.cache_prune_age).unwrap())
} }
pub fn fetch_remote_versions_timeout(&self) -> Duration {
humantime::parse_duration(&self.fetch_remote_versions_timeout).unwrap()
}
/// duration that remote version cache is kept for
/// for "fast" commands (represented by PREFER_STALE), these are always
/// cached. For "slow" commands like `mise ls-remote` or `mise install`:
/// - if MISE_FETCH_REMOTE_VERSIONS_CACHE is set, use that
/// - if MISE_FETCH_REMOTE_VERSIONS_CACHE is not set, use HOURLY
pub fn fetch_remote_versions_cache(&self) -> Option<Duration> {
if *env::PREFER_STALE {
None
} else {
Some(humantime::parse_duration(&self.fetch_remote_versions_cache).unwrap())
}
}
} }
impl Display for Settings { impl Display for Settings {

View File

@ -3,7 +3,6 @@ pub use std::env::*;
use std::path::PathBuf; use std::path::PathBuf;
use std::string::ToString; use std::string::ToString;
use std::sync::RwLock; use std::sync::RwLock;
use std::time::Duration;
use std::{path, process}; use std::{path, process};
use itertools::Itertools; use itertools::Itertools;
@ -11,7 +10,6 @@ use log::LevelFilter;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use crate::cli::args::ProfileArg; use crate::cli::args::ProfileArg;
use crate::duration::HOURLY;
use crate::env_diff::{EnvDiff, EnvDiffOperation, EnvDiffPatches}; use crate::env_diff::{EnvDiff, EnvDiffOperation, EnvDiffPatches};
use crate::file::replace_path; use crate::file::replace_path;
use crate::hook_env::{deserialize_watches, HookEnvWatches}; use crate::hook_env::{deserialize_watches, HookEnvWatches};
@ -101,9 +99,6 @@ pub static ARGV0: Lazy<String> = Lazy::new(|| ARGS.read().unwrap()[0].to_string(
pub static MISE_BIN_NAME: Lazy<&str> = Lazy::new(|| filename(&ARGV0)); pub static MISE_BIN_NAME: Lazy<&str> = Lazy::new(|| filename(&ARGV0));
pub static MISE_LOG_FILE: Lazy<Option<PathBuf>> = Lazy::new(|| var_path("MISE_LOG_FILE")); pub static MISE_LOG_FILE: Lazy<Option<PathBuf>> = Lazy::new(|| var_path("MISE_LOG_FILE"));
pub static MISE_LOG_FILE_LEVEL: Lazy<Option<LevelFilter>> = Lazy::new(log_file_level); pub static MISE_LOG_FILE_LEVEL: Lazy<Option<LevelFilter>> = Lazy::new(log_file_level);
pub static MISE_FETCH_REMOTE_VERSIONS_TIMEOUT: Lazy<Duration> = Lazy::new(|| {
var_duration("MISE_FETCH_REMOTE_VERSIONS_TIMEOUT").unwrap_or(Duration::from_secs(10))
});
pub static __USAGE: Lazy<Option<String>> = Lazy::new(|| var("__USAGE").ok()); pub static __USAGE: Lazy<Option<String>> = Lazy::new(|| var("__USAGE").ok());
@ -121,19 +116,6 @@ pub static TERM_WIDTH: Lazy<usize> = Lazy::new(|| {
.max(80) .max(80)
}); });
/// duration that remote version cache is kept for
/// for "fast" commands (represented by PREFER_STALE), these are always
/// cached. For "slow" commands like `mise ls-remote` or `mise install`:
/// - if MISE_FETCH_REMOTE_VERSIONS_CACHE is set, use that
/// - if MISE_FETCH_REMOTE_VERSIONS_CACHE is not set, use HOURLY
pub static MISE_FETCH_REMOTE_VERSIONS_CACHE: Lazy<Option<Duration>> = Lazy::new(|| {
if *PREFER_STALE {
None
} else {
Some(var_duration("MISE_FETCH_REMOTE_VERSIONS_CACHE").unwrap_or(HOURLY))
}
});
/// true if inside a script like bin/exec-env or bin/install /// true if inside a script like bin/exec-env or bin/install
/// used to prevent infinite loops /// used to prevent infinite loops
pub static MISE_BIN: Lazy<PathBuf> = Lazy::new(|| { pub static MISE_BIN: Lazy<PathBuf> = Lazy::new(|| {
@ -286,12 +268,6 @@ pub fn var_path(key: &str) -> Option<PathBuf> {
var_os(key).map(PathBuf::from).map(replace_path) var_os(key).map(PathBuf::from).map(replace_path)
} }
fn var_duration(key: &str) -> Option<Duration> {
var(key)
.ok()
.map(|v| v.parse::<humantime::Duration>().unwrap().into())
}
/// this returns the environment as if __MISE_DIFF was reversed. /// this returns the environment as if __MISE_DIFF was reversed.
/// putting the shell back into a state before hook-env was run /// putting the shell back into a state before hook-env was run
fn get_pristine_env( fn get_pristine_env(

View File

@ -10,8 +10,7 @@ use tokio::runtime::Runtime;
use url::Url; use url::Url;
use crate::cli::version; use crate::cli::version;
use crate::config::Settings; use crate::config::settings::SETTINGS;
use crate::env::MISE_FETCH_REMOTE_VERSIONS_TIMEOUT;
use crate::file::display_path; use crate::file::display_path;
use crate::ui::progress_report::SingleReport; use crate::ui::progress_report::SingleReport;
use crate::{env, file}; use crate::{env, file};
@ -20,11 +19,16 @@ use crate::{env, file};
pub static HTTP_VERSION_CHECK: Lazy<Client> = pub static HTTP_VERSION_CHECK: Lazy<Client> =
Lazy::new(|| Client::new(Duration::from_secs(3)).unwrap()); Lazy::new(|| Client::new(Duration::from_secs(3)).unwrap());
pub static HTTP: Lazy<Client> = pub static HTTP: Lazy<Client> = Lazy::new(|| {
Lazy::new(|| Client::new(Duration::from_secs(Settings::get().http_timeout)).unwrap()); let duration = humantime::parse_duration(&SETTINGS.http_timeout)
.unwrap_or_else(|_| Duration::from_secs(SETTINGS.http_timeout.parse().unwrap()));
Client::new(duration).unwrap()
});
pub static HTTP_FETCH: Lazy<Client> = pub static HTTP_FETCH: Lazy<Client> = Lazy::new(|| {
Lazy::new(|| Client::new(*MISE_FETCH_REMOTE_VERSIONS_TIMEOUT).unwrap()); Client::new(humantime::parse_duration(&SETTINGS.fetch_remote_versions_timeout).unwrap())
.unwrap()
});
#[derive(Debug)] #[derive(Debug)]
pub struct Client { pub struct Client {

View File

@ -1,6 +1,6 @@
use crate::config::settings::SETTINGS;
use crate::config::{Config, Settings}; use crate::config::{Config, Settings};
use crate::default_shorthands::{DEFAULT_SHORTHANDS, TRUSTED_SHORTHANDS}; use crate::default_shorthands::{DEFAULT_SHORTHANDS, TRUSTED_SHORTHANDS};
use crate::env::MISE_FETCH_REMOTE_VERSIONS_TIMEOUT;
use crate::errors::Error::PluginNotInstalled; use crate::errors::Error::PluginNotInstalled;
use crate::file::{display_path, remove_all}; use crate::file::{display_path, remove_all};
use crate::git::Git; use crate::git::Git;
@ -125,7 +125,7 @@ impl AsdfPlugin {
let result = cmd.stdout_capture().stderr_capture().unchecked().run()?; let result = cmd.stdout_capture().stderr_capture().unchecked().run()?;
Ok(result) Ok(result)
}, },
*MISE_FETCH_REMOTE_VERSIONS_TIMEOUT, SETTINGS.fetch_remote_versions_timeout(),
) )
.wrap_err_with(|| { .wrap_err_with(|| {
let script = self.script_man.get_script_path(&Script::ListAll); let script = self.script_man.get_script_path(&Script::ListAll);

View File

@ -17,6 +17,7 @@ use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg; use crate::cli::args::BackendArg;
use crate::cli::version::{ARCH, OS}; use crate::cli::version::{ARCH, OS};
use crate::cmd::CmdLineRunner; use crate::cmd::CmdLineRunner;
use crate::config::settings::SETTINGS;
use crate::config::Config; use crate::config::Config;
use crate::http::{HTTP, HTTP_FETCH}; use crate::http::{HTTP, HTTP_FETCH};
use crate::install_context::InstallContext; use crate::install_context::InstallContext;
@ -24,7 +25,7 @@ use crate::plugins::core::CorePlugin;
use crate::plugins::VERSION_REGEX; use crate::plugins::VERSION_REGEX;
use crate::toolset::{ToolRequest, ToolVersion, Toolset}; use crate::toolset::{ToolRequest, ToolVersion, Toolset};
use crate::ui::progress_report::SingleReport; use crate::ui::progress_report::SingleReport;
use crate::{env, file, hash}; use crate::{file, hash};
#[derive(Debug)] #[derive(Debug)]
pub struct JavaPlugin { pub struct JavaPlugin {
@ -44,12 +45,12 @@ impl JavaPlugin {
java_metadata_ea_cache: CacheManagerBuilder::new( java_metadata_ea_cache: CacheManagerBuilder::new(
core.fa.cache_path.join(java_metadata_ea_cache_filename), core.fa.cache_path.join(java_metadata_ea_cache_filename),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
java_metadata_ga_cache: CacheManagerBuilder::new( java_metadata_ga_cache: CacheManagerBuilder::new(
core.fa.cache_path.join(java_metadata_ga_cache_filename), core.fa.cache_path.join(java_metadata_ga_cache_filename),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
core, core,
} }

View File

@ -107,7 +107,7 @@ impl CorePlugin {
remote_version_cache: CacheManagerBuilder::new( remote_version_cache: CacheManagerBuilder::new(
fa.cache_path.join("remote_versions.msgpack.z"), fa.cache_path.join("remote_versions.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.with_cache_key(SETTINGS.node.mirror_url.clone().unwrap_or_default()) .with_cache_key(SETTINGS.node.mirror_url.clone().unwrap_or_default())
.with_cache_key(SETTINGS.node.flavor.clone().unwrap_or_default()) .with_cache_key(SETTINGS.node.flavor.clone().unwrap_or_default())
.build(), .build(),
@ -126,7 +126,7 @@ impl CorePlugin {
F: FnOnce() -> Result<T> + Send, F: FnOnce() -> Result<T> + Send,
T: Send, T: Send,
{ {
run_with_timeout(f, *env::MISE_FETCH_REMOTE_VERSIONS_TIMEOUT) run_with_timeout(f, SETTINGS.fetch_remote_versions_timeout())
} }
pub fn fetch_remote_versions_from_mise(&self) -> Result<Option<Vec<String>>> { pub fn fetch_remote_versions_from_mise(&self) -> Result<Option<Vec<String>>> {

View File

@ -12,7 +12,7 @@ use crate::install_context::InstallContext;
use crate::plugins::core::CorePlugin; use crate::plugins::core::CorePlugin;
use crate::toolset::{ToolRequest, ToolVersion, Toolset}; use crate::toolset::{ToolRequest, ToolVersion, Toolset};
use crate::ui::progress_report::SingleReport; use crate::ui::progress_report::SingleReport;
use crate::{cmd, env, file}; use crate::{cmd, file};
use eyre::{bail, eyre}; use eyre::{bail, eyre};
use itertools::Itertools; use itertools::Itertools;
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -32,7 +32,7 @@ impl PythonPlugin {
precompiled_cache: CacheManagerBuilder::new( precompiled_cache: CacheManagerBuilder::new(
core.fa.cache_path.join("precompiled.msgpack.z"), core.fa.cache_path.join("precompiled.msgpack.z"),
) )
.with_fresh_duration(*env::MISE_FETCH_REMOTE_VERSIONS_CACHE) .with_fresh_duration(SETTINGS.fetch_remote_versions_cache())
.build(), .build(),
core, core,
} }

53
tasks/render/settings → tasks/render/settings.ts Executable file → Normal file
View File

@ -1,39 +1,46 @@
#!/usr/bin/env node import * as fs from "node:fs";
import * as child_process from "node:child_process";
const fs = require("fs"); import * as toml from "toml";
const toml = require("toml"); import * as Handlebars from "handlebars";
const child_process = require("child_process"); import { match, P } from "ts-pattern";
const Handlebars = require("handlebars");
const doc = toml.parse(fs.readFileSync("settings.toml", "utf-8")); const doc = toml.parse(fs.readFileSync("settings.toml", "utf-8"));
const settings = {}; const settings = {};
function buildElement(key, props) { type Element = {
default: string;
description: string;
deprecated: boolean;
type: string;
enum?: string[];
items?: {
type: string;
};
};
function buildElement(key, props): Element {
let type = props.type; let type = props.type;
if (type.startsWith("Option<")) { if (type.startsWith("Option<")) {
type = type.slice(7, -1); type = type.slice(7, -1);
} }
type = type.replaceAll("PathBuf", "String"); type = type.replaceAll("PathBuf", "String");
if (type === "bool") { type = match(type)
type = "boolean"; .with("String", () => "string")
} else if (type === "String" || type === "PathBuf") { .with("Path", () => "string")
type = "string"; .with("Url", () => "string")
} else if (type === "usize" || type === "u64") { .with("Duration", () => "string")
type = "number"; .with("Bool", () => "boolean")
} else if ( .with("Integer", () => "number")
type === "BTreeSet<String>" || .with("ListString", () => "string[]")
type === "HashSet<String>" || .with("ListPath", () => "string[]")
type === "Vec<String>" .otherwise(() => {
) { throw new Error(`Unknown type: ${type}`);
type = "string[]"; });
} else {
throw new Error(`Unknown type: ${type}`);
}
if (!props.description) { if (!props.description) {
console.error(`Missing description for ${key}`); console.error(`Missing description for ${key}`);
process.exit(1); process.exit(1);
} }
const ele = { const ele: Element = {
default: props.default, default: props.default,
description: props.description, description: props.description,
deprecated: props.deprecated, deprecated: props.deprecated,