diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 2d965a7..87c12d7 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -45,7 +45,7 @@ pub enum PluginCommand { #[arg(short = 'd', long, default_value = "false")] build_with_dev: bool, - + #[arg(short = 'S', long, default_value = "true")] follow_symlinks: bool, @@ -71,7 +71,7 @@ pub enum PluginCommand { #[arg(short = 's', long, value_enum, default_value = "plugin-name")] output_filename_source: FilenameSource, - + #[arg(short = 'S', long, default_value = "true")] follow_symlinks: bool, diff --git a/src/cli/plugin/deploy.rs b/src/cli/plugin/deploy.rs index 36c05f2..7a7b30b 100644 --- a/src/cli/plugin/deploy.rs +++ b/src/cli/plugin/deploy.rs @@ -55,13 +55,25 @@ impl Deployer { format!("deck@{}", deck.deckip), "-p".to_string(), format!("{}", deck.deckport), - format!("{}", if deck.deckkey.contains("-i ") { "-i" } else { "" }), - format!("{}", if deck.deckkey.contains("-i ") { - deck.deckkey - .replace("-i ", "") - .replace("$HOME", &*home_dir().unwrap().to_string_lossy()) - .replace("${env:HOME}", &*home_dir().unwrap().to_string_lossy()) - } else {"".to_string()}), + format!( + "{}", + if deck.deckkey.contains("-i ") { + "-i" + } else { + "" + } + ), + format!( + "{}", + if deck.deckkey.contains("-i ") { + deck.deckkey + .replace("-i ", "") + .replace("$HOME", &*home_dir().unwrap().to_string_lossy()) + .replace("${env:HOME}", &*home_dir().unwrap().to_string_lossy()) + } else { + "".to_string() + } + ), format!( "echo '{}' | sudo -S chmod -R ug+rw {}/homebrew/", deck.deckpass, deck.deckdir @@ -104,13 +116,25 @@ impl Deployer { format!("deck@{}", deck.deckip), "-p".to_string(), format!("{}", deck.deckport), - format!("{}", if deck.deckkey.contains("-i ") { "-i" } else { "" }), - format!("{}", if deck.deckkey.contains("-i ") { - deck.deckkey - .replace("-i ", "") - .replace("$HOME", &*home_dir().unwrap().to_string_lossy()) - .replace("${env:HOME}", &*home_dir().unwrap().to_string_lossy()) - } else {"".to_string()}), + format!( + "{}", + if deck.deckkey.contains("-i ") { + "-i" + } else { + "" + } + ), + format!( + "{}", + if deck.deckkey.contains("-i ") { + deck.deckkey + .replace("-i ", "") + .replace("$HOME", &*home_dir().unwrap().to_string_lossy()) + .replace("${env:HOME}", &*home_dir().unwrap().to_string_lossy()) + } else { + "".to_string() + } + ), format!( "echo '{}' | sudo -S systemctl restart plugin_loader.service", deck.deckpass @@ -171,7 +195,15 @@ impl Deployer { .to_string_lossy() .to_string(), }; - let zip_filename = format!("{}{}.zip", &filename, if self.builder.build_with_dev { "-dev".to_string() } else { "".to_string() }); + let zip_filename = format!( + "{}{}.zip", + &filename, + if self.builder.build_with_dev { + "-dev".to_string() + } else { + "".to_string() + } + ); let file = std::fs::File::open(&self.builder.output_root.join(zip_filename)) .expect("Could not open zip file"); let mut zip = zip::ZipArchive::new(file).unwrap(); @@ -214,7 +246,8 @@ impl Deployer { build_with_dev, follow_symlinks, output_filename_source, - ).expect("Could not create builder"); + ) + .expect("Could not create builder"); Ok(Self { builder: builder.clone(), diff --git a/src/docker.rs b/src/docker.rs index c76cb3c..cf07484 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -70,7 +70,12 @@ pub async fn build_image(dockerfile: PathBuf, tag: String) -> Result { } // docker run --rm -i -v $PWD/backend:/backend -v /tmp/output/$plugin/backend/out:/backend/out --entrypoint /backend/entrypoint.sh "$docker_name" -pub async fn run_image(tag: String, binds: Vec<(String, String)>, run_as_root: bool, run_with_dev: bool) -> Result<()> { +pub async fn run_image( + tag: String, + binds: Vec<(String, String)>, + run_as_root: bool, + run_with_dev: bool, +) -> Result<()> { let mut cmd = Command::new("docker"); let mut command_with_default_args = cmd.arg("run").arg("--rm"); @@ -83,10 +88,13 @@ pub async fn run_image(tag: String, binds: Vec<(String, String)>, run_as_root: b } if run_with_dev { - command_with_default_args = command_with_default_args.arg("-e").arg("RELEASE_TYPE=development") - } - else { - command_with_default_args = command_with_default_args.arg("-e").arg("RELEASE_TYPE=production") + command_with_default_args = command_with_default_args + .arg("-e") + .arg("RELEASE_TYPE=development") + } else { + command_with_default_args = command_with_default_args + .arg("-e") + .arg("RELEASE_TYPE=production") } let mut dynamic_args: Vec = vec![]; diff --git a/src/plugin.rs b/src/plugin.rs index e7f01b3..12df194 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -67,9 +67,13 @@ impl Plugin { plugin_root .join("deck.json") .exists() - .as_result(deckfile_location.clone(), anyhow!("Could not find deck.json")) + .as_result( + deckfile_location.clone(), + anyhow!("Could not find deck.json"), + ) .and_then(|deckfile| std::fs::read_to_string(deckfile).map_err(Into::into)) - .and_then(|str| serde_json::from_str::(&str).map_err(Into::into)).or_else(|_| { + .and_then(|str| serde_json::from_str::(&str).map_err(Into::into)) + .or_else(|_| { let deck = DeckFile { deckip: "0.0.0.0".to_string(), deckport: "22".to_string(), @@ -77,9 +81,13 @@ impl Plugin { deckkey: "-i $HOME/.ssh/id_rsa".to_string(), deckdir: "/home/deck".to_string(), }; - std::fs::write(deckfile_location, serde_json::to_string_pretty(&deck).unwrap()).unwrap(); + std::fs::write( + deckfile_location, + serde_json::to_string_pretty(&deck).unwrap(), + ) + .unwrap(); Ok(deck) - }) + }) } fn find_pluginfile(plugin_root: &Path) -> Result {