summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-27 15:30:14 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-27 15:30:14 +0530
commitcb3072066dc482cbadfbd77c64b7e61a1b24b9c6 (patch)
tree4d16baf85a519670ca8647b0b11abb1c54fc0bad
parent1e5c688ed99fe7f96e5e690fba70d80782a53d3d (diff)
hotfix(publish): Move install module and asset_map to main zellij package. publish should hopefully work now.
-rw-r--r--assets/plugins/status-bar.wasmbin462240 -> 424268 bytes
-rw-r--r--assets/plugins/strider.wasmbin564581 -> 522690 bytes
-rw-r--r--assets/plugins/tab-bar.wasmbin451906 -> 413551 bytes
-rw-r--r--src/install.rs42
-rw-r--r--src/main.rs10
-rw-r--r--zellij-server/src/lib.rs5
-rw-r--r--zellij-utils/src/setup.rs47
7 files changed, 53 insertions, 51 deletions
diff --git a/assets/plugins/status-bar.wasm b/assets/plugins/status-bar.wasm
index 8ca71ac64..fe58e8a5b 100644
--- a/assets/plugins/status-bar.wasm
+++ b/assets/plugins/status-bar.wasm
Binary files differ
diff --git a/assets/plugins/strider.wasm b/assets/plugins/strider.wasm
index f687db8da..4cf9eec6c 100644
--- a/assets/plugins/strider.wasm
+++ b/assets/plugins/strider.wasm
Binary files differ
diff --git a/assets/plugins/tab-bar.wasm b/assets/plugins/tab-bar.wasm
index bb981a5b9..2ec458e4d 100644
--- a/assets/plugins/tab-bar.wasm
+++ b/assets/plugins/tab-bar.wasm
Binary files differ
diff --git a/src/install.rs b/src/install.rs
new file mode 100644
index 000000000..e9f58a8b9
--- /dev/null
+++ b/src/install.rs
@@ -0,0 +1,42 @@
+use std::fs;
+use std::path::Path;
+use zellij_utils::{consts::VERSION, shared::set_permissions};
+
+macro_rules! asset_map {
+ ($($src:literal => $dst:literal),+ $(,)?) => {
+ {
+ let mut assets = std::collections::HashMap::new();
+ $(
+ assets.insert($dst, include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $src)).to_vec());
+ )+
+ assets
+ }
+ }
+}
+
+pub(crate) fn populate_data_dir(data_dir: &Path) {
+ // First run installation of default plugins & layouts
+ let mut assets = asset_map! {
+ "assets/layouts/default.yaml" => "layouts/default.yaml",
+ "assets/layouts/strider.yaml" => "layouts/strider.yaml",
+ };
+ assets.extend(asset_map! {
+ "assets/plugins/status-bar.wasm" => "plugins/status-bar.wasm",
+ "assets/plugins/tab-bar.wasm" => "plugins/tab-bar.wasm",
+ "assets/plugins/strider.wasm" => "plugins/strider.wasm",
+ });
+ assets.insert("VERSION", VERSION.as_bytes().to_vec());
+
+ let last_version = fs::read_to_string(data_dir.join("VERSION")).unwrap_or_default();
+ let out_of_date = VERSION != last_version;
+
+ for (path, bytes) in assets {
+ let path = data_dir.join(path);
+ let parent_path = path.parent().unwrap();
+ fs::create_dir_all(parent_path).unwrap();
+ set_permissions(parent_path).unwrap();
+ if out_of_date || !path.exists() {
+ fs::write(path, bytes).expect("Failed to install default assets!");
+ }
+ }
+}
diff --git a/src/main.rs b/src/main.rs
index 67b833988..efb991567 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,9 @@
+mod install;
mod sessions;
#[cfg(test)]
mod tests;
+use crate::install::populate_data_dir;
use sessions::{assert_session, assert_session_ne, list_sessions};
use std::convert::TryFrom;
use std::process;
@@ -12,7 +14,7 @@ use zellij_utils::{
consts::{ZELLIJ_TMP_DIR, ZELLIJ_TMP_LOG_DIR},
input::config::Config,
logging::*,
- setup::Setup,
+ setup::{get_default_data_dir, Setup},
structopt::StructOpt,
};
@@ -69,6 +71,12 @@ pub fn main() {
.clone()
.unwrap_or_else(|| names::Generator::default().next().unwrap());
assert_session_ne(&session_name);
+ // Determine and initialize the data directory
+ let data_dir = opts.data_dir.clone().unwrap_or_else(get_default_data_dir);
+
+ #[cfg(not(disable_automatic_asset_installation))]
+ populate_data_dir(&data_dir);
+
start_client(
Box::new(os_input),
opts,
diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs
index 40fb87f7d..348734957 100644
--- a/zellij-server/src/lib.rs
+++ b/zellij-server/src/lib.rs
@@ -32,7 +32,7 @@ use zellij_utils::{
errors::{ContextType, ErrorInstruction, ServerContext},
input::{get_mode_info, options::Options},
ipc::{ClientAttributes, ClientToServerMsg, ExitReason, ServerToClientMsg},
- setup::{get_default_data_dir, install::populate_data_dir},
+ setup::get_default_data_dir,
};
/// Instructions related to server-side application
@@ -312,9 +312,6 @@ fn init_session(
// Determine and initialize the data directory
let data_dir = opts.data_dir.unwrap_or_else(get_default_data_dir);
- #[cfg(not(disable_automatic_asset_installation))]
- populate_data_dir(&data_dir);
-
let capabilities = PluginCapabilities {
arrow_fonts: config_options.simplified_ui,
};
diff --git a/zellij-utils/src/setup.rs b/zellij-utils/src/setup.rs
index 0d442f0f7..d7ddefe4d 100644
--- a/zellij-utils/src/setup.rs
+++ b/zellij-utils/src/setup.rs
@@ -2,61 +2,16 @@ use crate::cli::CliArgs;
use crate::consts::{
FEATURES, SYSTEM_DEFAULT_CONFIG_DIR, SYSTEM_DEFAULT_DATA_DIR_PREFIX, VERSION, ZELLIJ_PROJ_DIR,
};
-use crate::shared::set_permissions;
use directories_next::BaseDirs;
use serde::{Deserialize, Serialize};
use std::io::Write;
-use std::{fs, path::Path, path::PathBuf};
+use std::{path::Path, path::PathBuf};
use structopt::StructOpt;
const CONFIG_LOCATION: &str = ".config/zellij";
const CONFIG_NAME: &str = "config.yaml";
static ARROW_SEPARATOR: &str = "";
-#[macro_export]
-macro_rules! asset_map {
- ($($src:literal => $dst:literal),+ $(,)?) => {
- {
- let mut assets = std::collections::HashMap::new();
- $(
- assets.insert($dst, include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/", $src)).to_vec());
- )+
- assets
- }
- }
-}
-
-pub mod install {
- use super::*;
-
- pub fn populate_data_dir(data_dir: &Path) {
- // First run installation of default plugins & layouts
- let mut assets = asset_map! {
- "../assets/layouts/default.yaml" => "layouts/default.yaml",
- "../assets/layouts/strider.yaml" => "layouts/strider.yaml",
- };
- assets.extend(asset_map! {
- "../assets/plugins/status-bar.wasm" => "plugins/status-bar.wasm",
- "../assets/plugins/tab-bar.wasm" => "plugins/tab-bar.wasm",
- "../assets/plugins/strider.wasm" => "plugins/strider.wasm",
- });
- assets.insert("VERSION", VERSION.as_bytes().to_vec());
-
- let last_version = fs::read_to_string(data_dir.join("VERSION")).unwrap_or_default();
- let out_of_date = VERSION != last_version;
-
- for (path, bytes) in assets {
- let path = data_dir.join(path);
- let parent_path = path.parent().unwrap();
- fs::create_dir_all(parent_path).unwrap();
- set_permissions(parent_path).unwrap();
- if out_of_date || !path.exists() {
- fs::write(path, bytes).expect("Failed to install default assets!");
- }
- }
- }
-}
-
#[cfg(not(any(feature = "test", test)))]
/// Goes through a predefined list and checks for an already
/// existing config directory, returns the first match