mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 03:34:58 +02:00
Overhaul the plugin cache file with a new msgpack+brotli format (#12579)
# Description - Plugin signatures are now saved to `plugin.msgpackz`, which is brotli-compressed MessagePack. - The file is updated incrementally, rather than writing all plugin commands in the engine every time. - The file always contains the result of the `Signature` call to the plugin, even if commands were removed. - Invalid data for a particular plugin just causes an error to be reported, but the rest of the plugins can still be parsed # User-Facing Changes - The plugin file has a different filename, and it's not a nushell script. - The default `plugin.nu` file will be automatically migrated the first time, but not other plugin config files. - We don't currently provide any utilities that could help edit this file, beyond `plugin add` and `plugin rm` - `from msgpackz`, `to msgpackz` could also help - New commands: `plugin add`, `plugin rm` # Tests + Formatting Tests added for the format and for the invalid handling. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting - [ ] Check for documentation changes - [ ] Definitely needs release notes
This commit is contained in:
@ -202,11 +202,11 @@ macro_rules! nu_with_std {
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! nu_with_plugins {
|
||||
(cwd: $cwd:expr, plugins: [$(($plugin_name:expr)),+$(,)?], $command:expr) => {{
|
||||
(cwd: $cwd:expr, plugins: [$(($plugin_name:expr)),*$(,)?], $command:expr) => {{
|
||||
nu_with_plugins!(
|
||||
cwd: $cwd,
|
||||
envs: Vec::<(&str, &str)>::new(),
|
||||
plugins: [$(($plugin_name)),+],
|
||||
plugins: [$(($plugin_name)),*],
|
||||
$command
|
||||
)
|
||||
}};
|
||||
@ -222,10 +222,10 @@ macro_rules! nu_with_plugins {
|
||||
(
|
||||
cwd: $cwd:expr,
|
||||
envs: $envs:expr,
|
||||
plugins: [$(($plugin_name:expr)),+$(,)?],
|
||||
plugins: [$(($plugin_name:expr)),*$(,)?],
|
||||
$command:expr
|
||||
) => {{
|
||||
$crate::macros::nu_with_plugin_run_test($cwd, $envs, &[$($plugin_name),+], $command)
|
||||
$crate::macros::nu_with_plugin_run_test($cwd, $envs, &[$($plugin_name),*], $command)
|
||||
}};
|
||||
(cwd: $cwd:expr, envs: $envs:expr, plugin: ($plugin_name:expr), $command:expr) => {{
|
||||
$crate::macros::nu_with_plugin_run_test($cwd, $envs, &[$plugin_name], $command)
|
||||
@ -329,12 +329,14 @@ where
|
||||
});
|
||||
|
||||
let temp = tempdir().expect("couldn't create a temporary directory");
|
||||
let [temp_config_file, temp_env_config_file, temp_plugin_file] =
|
||||
["config.nu", "env.nu", "plugin.nu"].map(|name| {
|
||||
let temp_file = temp.path().join(name);
|
||||
std::fs::File::create(&temp_file).expect("couldn't create temporary config file");
|
||||
temp_file
|
||||
});
|
||||
let [temp_config_file, temp_env_config_file] = ["config.nu", "env.nu"].map(|name| {
|
||||
let temp_file = temp.path().join(name);
|
||||
std::fs::File::create(&temp_file).expect("couldn't create temporary config file");
|
||||
temp_file
|
||||
});
|
||||
|
||||
// We don't have to write the plugin cache file, it's ok for it to not exist
|
||||
let temp_plugin_file = temp.path().join("plugin.msgpackz");
|
||||
|
||||
crate::commands::ensure_plugins_built();
|
||||
|
||||
|
Reference in New Issue
Block a user