From 92c6ecc771b570f45920519fc3c966fc2256a5de Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Thu, 24 Sep 2026 18:08:44 -0400 Subject: [PATCH 1/5] refactor fn to mod --- src/cmd/dev.rs | 2 +- src/cmd/mod.rs | 10 ++++++++++ src/cmd/run.rs | 9 +-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cmd/dev.rs b/src/cmd/dev.rs index 5ef3390..0f7a318 100644 --- a/src/cmd/dev.rs +++ b/src/cmd/dev.rs @@ -9,7 +9,7 @@ use std::{ use clap::Args; -use crate::cmd::run::is_cwd_oseda_project; +use crate::cmd::is_cwd_oseda_project; /// Options for the `oseda dev` command #[derive(Args, Debug, Clone)] diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 6aab6b9..5b60a36 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -1,3 +1,7 @@ +use std::path::Path; + +use crate::config; + pub mod check; pub mod deploy; pub mod dev; @@ -6,3 +10,9 @@ pub mod fork; pub mod init; pub mod run; pub mod update; + +pub fn is_cwd_oseda_project() -> bool { + Path::new(config::CONFIG_FILE_NAME) + .try_exists() + .is_ok_and(|exists| exists) +} diff --git a/src/cmd/run.rs b/src/cmd/run.rs index 567004d..3140545 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -1,5 +1,4 @@ use std::{ - path::Path, process::Command, sync::{ atomic::{AtomicBool, Ordering}, @@ -8,7 +7,7 @@ use std::{ time::Duration, }; -use crate::config::{self}; +use crate::cmd::is_cwd_oseda_project; /// More in depth errors that could cause a project not to run #[derive(Debug)] @@ -47,12 +46,6 @@ pub fn run() -> Result<(), OsedaRunError> { run_with_shutdown(Arc::new(AtomicBool::new(false))) } -pub fn is_cwd_oseda_project() -> bool { - Path::new(config::CONFIG_FILE_NAME) - .try_exists() - .is_ok_and(|exists| exists) -} - pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunError> { // command run failure and command status are considered different, handled accordingly if !is_cwd_oseda_project() { From 89ccb3286c5f2755d97d9ff944d63399746eaff3 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Thu, 24 Sep 2026 18:11:52 -0400 Subject: [PATCH 2/5] check on check --- src/cmd/check.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmd/check.rs b/src/cmd/check.rs index d15677c..a93db94 100644 --- a/src/cmd/check.rs +++ b/src/cmd/check.rs @@ -9,7 +9,7 @@ use std::{ use clap::Args; use reqwest::StatusCode; -use crate::cmd::run; +use crate::cmd::{is_cwd_oseda_project, run}; use crate::config; use crate::net::{self, kill_port}; @@ -32,6 +32,7 @@ pub enum OsedaCheckError { CouldNotPingLocalPresentation(String), MissingDescription(String), MissingTags(String), + NotOsedaProject(String), } impl std::error::Error for OsedaCheckError {} @@ -55,6 +56,9 @@ impl std::fmt::Display for OsedaCheckError { Self::MissingTags(msg) => { write!(f, "No tags detected: {}", msg) } + Self::NotOsedaProject(msg) => { + write!(f, "Not an Oseda project: {}", msg) + } } } } @@ -68,6 +72,11 @@ impl std::fmt::Display for OsedaCheckError { /// * `Ok(())` if the project passes all checks and is considered as "deployabl"e /// * `Err(OsedaCheckError)` a problem was detected that prevents the user from doing a deployment pub fn check(opts: CheckOptions) -> Result<(), OsedaCheckError> { + + if !is_cwd_oseda_project(){ + return Err(OsedaCheckError::NotOsedaProject("Cannot check non-project".to_owned())); + } + // separate abstraction layer here, want the primary subcommand to call this // verify can also be called from deploy (in theory) match verify_project(opts.port) { From f7f19ca7ace6d578dc3e90236dbc58e936f5c704 Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Thu, 24 Sep 2026 18:15:00 -0400 Subject: [PATCH 3/5] check on dev --- src/cmd/deploy.rs | 8 ++++++-- src/cmd/dev.rs | 12 +++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cmd/deploy.rs b/src/cmd/deploy.rs index 5d5fb07..9772663 100644 --- a/src/cmd/deploy.rs +++ b/src/cmd/deploy.rs @@ -3,8 +3,7 @@ use std::{env, error::Error, fs, path::Path}; use clap::Args; use crate::{ - config, - github::{self, git}, + cmd::is_cwd_oseda_project, config, github::{self, git} }; /// Options for the `oseda deploy` command @@ -64,6 +63,11 @@ impl TryFrom for SshUrl { /// * `Ok(())` on success /// * `Err` if any git, file, or config step fails, including a check failure pub fn deploy(opts: DeployOptions) -> Result<(), Box> { + + if !is_cwd_oseda_project() { + return Err("Not an Oseda project".into()); + } + let tmp_dir = tempfile::tempdir()?; let repo_path = tmp_dir.path(); diff --git a/src/cmd/dev.rs b/src/cmd/dev.rs index 0f7a318..ab0bfd6 100644 --- a/src/cmd/dev.rs +++ b/src/cmd/dev.rs @@ -49,6 +49,12 @@ impl std::fmt::Display for OsedaDevError { /// * `Ok()` on success /// * `Err` on any issue related to running oseda in dev mode pub fn dev(opts: DevOptions) -> Result<(), OsedaDevError> { + if !is_cwd_oseda_project() { + return Err(OsedaDevError::NotOsedaProjectError( + "oseda-config.json not found".to_string(), + )); + } + dev_with_shutdown(opts, Arc::new(AtomicBool::new(false))) } @@ -65,11 +71,7 @@ pub fn dev_with_shutdown( opts: DevOptions, shutdown_flag: Arc, ) -> Result<(), OsedaDevError> { - if !is_cwd_oseda_project() { - return Err(OsedaDevError::NotOsedaProjectError( - "oseda-config.json not found".to_string(), - )); - } + let mut cmd = Command::new("npx"); cmd.arg("vite") From 47104f992c1577a16f682b05ee40790429ed547e Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Thu, 24 Sep 2026 18:19:01 -0400 Subject: [PATCH 4/5] more checks --- src/cmd/deploy.rs | 2 +- src/cmd/export.rs | 7 ++++++- src/cmd/run.rs | 12 +++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/cmd/deploy.rs b/src/cmd/deploy.rs index 9772663..fd34a31 100644 --- a/src/cmd/deploy.rs +++ b/src/cmd/deploy.rs @@ -65,7 +65,7 @@ impl TryFrom for SshUrl { pub fn deploy(opts: DeployOptions) -> Result<(), Box> { if !is_cwd_oseda_project() { - return Err("Not an Oseda project".into()); + return Err("Current working directory is not an Oseda project".into()); } let tmp_dir = tempfile::tempdir()?; diff --git a/src/cmd/export.rs b/src/cmd/export.rs index dd8938c..2850435 100644 --- a/src/cmd/export.rs +++ b/src/cmd/export.rs @@ -10,7 +10,7 @@ use std::{ use clap::Args; use crate::{ - cmd::run, + cmd::{is_cwd_oseda_project, run}, config::read_and_validate_config, net::kill_port, puppeteer::{is_puppeteer_chrome_installed, prompt_install_puppeteer_chrome}, @@ -46,6 +46,11 @@ fn get_default_output() -> String { /// Export the current Oseda project to a PDF file via `decktape` pub fn export(opts: ExportOptions) -> Result<(), Box> { + + if !is_cwd_oseda_project() { + return Err("Current working directory is not an Oseda project".into()) + } + println!("Cleaning any existing oseda processing..."); if kill_port(opts.port).is_err() { eprintln!("Warning, could not kill value on desired port") diff --git a/src/cmd/run.rs b/src/cmd/run.rs index 3140545..1e316d3 100644 --- a/src/cmd/run.rs +++ b/src/cmd/run.rs @@ -43,17 +43,19 @@ impl std::fmt::Display for OsedaRunError { /// * `Ok(())` if both the build and serve steps succeed /// * `Err(OsedaRunError)` if any step fails (missing vite isn't installed, or `serve` fails to start) pub fn run() -> Result<(), OsedaRunError> { - run_with_shutdown(Arc::new(AtomicBool::new(false))) -} - -pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunError> { - // command run failure and command status are considered different, handled accordingly if !is_cwd_oseda_project() { return Err(OsedaRunError::NotOsedaProjectError( "oseda-config.json not found".to_string(), )); } + run_with_shutdown(Arc::new(AtomicBool::new(false))) +} + +pub fn run_with_shutdown(shutdown_flag: Arc) -> Result<(), OsedaRunError> { + // command run failure and command status are considered different, handled accordingly + + match Command::new("npx").arg("vite").arg("build").status() { Ok(status) => { if !status.success() { From 9cb992aa6925b16cb4c5a687aec4a56e335d00bf Mon Sep 17 00:00:00 2001 From: ReeseHatfield Date: Thu, 24 Sep 2026 18:19:37 -0400 Subject: [PATCH 5/5] semver --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a45be08..353c198 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1109,7 +1109,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "oseda-cli" -version = "3.2.1" +version = "3.2.2" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index 7ca2ed3..94e2cf0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ homepage = "https://oseda.net" repository = "https://github.com/oseda-dev/oseda-cli" readme = "README.md" name = "oseda-cli" -version = "3.2.1" +version = "3.2.2" edition = "2021" [[bin]]