diff --git a/Cargo.lock b/Cargo.lock index 8be189e3..5dd1133c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,9 +518,9 @@ dependencies = [ [[package]] name = "dtoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" [[package]] name = "either" @@ -818,9 +818,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.7.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b6cf41e31a7e7b78055b548826da45c7dc74e6a13a3fa6b897a17a01322f26" +checksum = "c4a1b21a2971cea49ca4613c0e9fe8225ecaf5de64090fddc6002284726e9244" dependencies = [ "console", "lazy_static", @@ -893,9 +893,9 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "js-sys" -version = "0.3.49" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" +checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" dependencies = [ "wasm-bindgen", ] @@ -936,9 +936,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.91" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" +checksum = "56d855069fafbb9b344c0f962150cd2c1187975cb1c22c1522c240d8c4986714" [[package]] name = "libloading" @@ -1001,9 +1001,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc14fc54a812b4472b4113facc3e44d099fbc0ea2ce0551fa5c703f8edfbfd38" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" dependencies = [ "autocfg", ] @@ -1182,9 +1182,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] @@ -1347,15 +1347,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -1575,9 +1566,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.64" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" dependencies = [ "proc-macro2", "quote", @@ -1689,15 +1680,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "toml" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" -dependencies = [ - "serde", -] - [[package]] name = "tracing" version = "0.1.25" @@ -1863,17 +1845,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" -[[package]] -name = "walkdir" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -1882,9 +1853,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.72" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" +checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -1892,9 +1863,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.72" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" +checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" dependencies = [ "bumpalo", "lazy_static", @@ -1907,9 +1878,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.22" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73157efb9af26fb564bb59a009afd1c7c334a44db171d280690d0c3faaec3468" +checksum = "81b8b767af23de6ac18bf2168b690bed2902743ddf0fb39252e36f9e2bfc63ea" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1919,9 +1890,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.72" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" +checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1929,9 +1900,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.72" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" +checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" dependencies = [ "proc-macro2", "quote", @@ -1942,9 +1913,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.72" +version = "0.2.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" +checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" [[package]] name = "wasmer" @@ -2157,18 +2128,18 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b0fa059022c5dabe129f02b429d67086400deb8277f89c975555dacc1dadbcc" +checksum = "8ec280a739b69173e0ffd12c1658507996836ba4e992ed9bc1e5385a0bd72a02" dependencies = [ "wast", ] [[package]] name = "web-sys" -version = "0.3.49" +version = "0.3.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59fe19d70f5dacc03f6e46777213facae5ac3801575d56ca6cbd4c93dcd12310" +checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" dependencies = [ "js-sys", "wasm-bindgen", @@ -2185,12 +2156,12 @@ dependencies = [ [[package]] name = "which" -version = "4.0.2" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe" dependencies = [ + "either", "libc", - "thiserror", ] [[package]] @@ -2209,15 +2180,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -2264,11 +2226,9 @@ dependencies = [ "strum", "termion", "termios", - "toml", "unicode-truncate", "unicode-width", "vte 0.8.0", - "walkdir", "wasmer", "wasmer-wasi", "zellij-tile", diff --git a/Cargo.toml b/Cargo.toml index b20ed6af..06fb0c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,10 +44,7 @@ features = ["unstable"] insta = "1.6.0" [build-dependencies] -directories-next = "2.0" structopt = "0.3" -walkdir = "2" -toml = "0.5.8" [workspace] members = [ diff --git a/Makefile.toml b/Makefile.toml index 03c1eef7..24d6445d 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -15,12 +15,15 @@ dependencies = ["pre-test"] [tasks.post-test] env = { "SKIP_TEST" = false } +# Running Zellij using patched layouts [tasks.run] workspace = false -dependencies = ["build"] -run_task = { name = ["patch-layouts", "run-zellij"] } +dependencies = ["build-workspace", "patch-layouts"] +run_task = "launch" + +[tasks.build-workspace] +run_task = { name = "build", fork = true } -## Need to walk the layout YAML and patch the plugin fields! [tasks.patch-layouts] script_runner = "@rust" script = ''' @@ -28,28 +31,54 @@ script = ''' //! [dependencies] //! yaml-rust = "0.4" //! ``` -use std::{fs, env, error::Error, path::Path}; -use yaml_rust::{YamlLoader, YamlEmitter}; +use std::{env, error::Error, fs, path::Path}; +use yaml_rust::{Yaml, YamlEmitter, YamlLoader}; fn main() -> Result<(), Box> { let root = env::var("CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY")?; let layout_path = Path::new(&root).join("assets/layouts"); for layout in fs::read_dir(layout_path)? { - let yaml = fs::read_to_string(layout?.path())?; - let yaml = YamlLoader::load_from_str(&yaml)?[0]; + let layout = layout?.path(); + let yaml = fs::read_to_string(&layout)?; + let yaml = YamlLoader::load_from_str(&yaml)?.remove(0); + let yaml = patch_plugins(&root, yaml); + let new_layout = Path::new(&root) + .join("target") + .join(layout.file_name().unwrap()); + let mut new_yaml = String::new(); + let mut emitter = YamlEmitter::new(&mut new_yaml); + emitter.dump(&yaml)?; + fs::write(new_layout, new_yaml)?; } Ok(()) } + +fn patch_plugins(root: &str, part: Yaml) -> Yaml { + let mut map = part.into_hash().unwrap(); + if let Some(plugin) = map.get_mut(&Yaml::from_str("plugin")) { + let new_plugin = Path::new(root) + .join("target/wasm32-wasi/debug") + .join(plugin.as_str().unwrap()); + *plugin = Yaml::String(new_plugin.to_string_lossy().into_owned()); + } + if let Some(parts) = map.get_mut(&Yaml::from_str("parts")) { + let new_parts = parts + .clone() + .into_iter() + .map(|p| patch_plugins(root, p)) + .collect(); + *parts = Yaml::Array(new_parts); + } + Yaml::Hash(map) +} ''' -[tasks.run-zellij] +[tasks.launch] +command = "cargo" +args = ["run", "--", "-l", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/default.yaml"] - -# Running Zellij - -# Change the build to always use the assets, but not delete them by default -# Instead, just run with a patched layout file that points to a local plugin copy +# Running Zellij (need to add a run-release option and multi-layout support!) # Have a publish flow that triggers wasm-opt and updates the assets diff --git a/build.rs b/build.rs index fdb7ab7a..3240db67 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,5 @@ -use directories_next::ProjectDirs; -use std::{ffi::OsStr, fs}; +use std::fs; use structopt::clap::Shell; -use walkdir::WalkDir; include!("src/cli.rs"); @@ -22,32 +20,4 @@ fn main() { clap_app.gen_completions(BIN_NAME, Shell::Bash, &out_dir); clap_app.gen_completions(BIN_NAME, Shell::Zsh, &out_dir); clap_app.gen_completions(BIN_NAME, Shell::Fish, &out_dir); - - // Clear Default Plugins and Layouts - - // Rerun on layout change - for entry in WalkDir::new("assets/layouts") { - let entry = entry.unwrap(); - println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy()); - } - - // Rerun on plugin change - #[cfg(not(feature = "publish"))] - let plugin_dir = "target"; - #[cfg(feature = "publish")] - let plugin_dir = "assets/plugins"; - for entry in WalkDir::new(plugin_dir) { - let entry = entry.unwrap(); - if entry.path().extension() == Some(OsStr::new("wasm")) { - println!("cargo:rerun-if-changed={}", entry.path().to_string_lossy()); - } - } - - let project_dirs = ProjectDirs::from("org", "Zellij Contributors", "Zellij").unwrap(); - let data_dir = project_dirs.data_dir(); - drop(fs::remove_file(data_dir.join("plugins/status-bar.wasm"))); - drop(fs::remove_file(data_dir.join("plugins/tab-bar.wasm"))); - drop(fs::remove_file(data_dir.join("plugins/strider.wasm"))); - drop(fs::remove_file(data_dir.join("layouts/default.yaml"))); - drop(fs::remove_file(data_dir.join("layouts/strider.yaml"))); }