Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 67 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ open = "5.3.3"
reqwest = { version = "0.12.20", features = ["blocking"] }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
spinners = "4.2.0"
strum = "0.27.1"
strum_macros = "0.27.1"
tempfile = "3.20.0"
5 changes: 2 additions & 3 deletions src/cmd/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::config;

use crate::net::{self, kill_port};


/// Options for the `oseda check` command
#[derive(Args, Debug)]
pub struct CheckOptions {
Expand Down Expand Up @@ -127,7 +126,7 @@ fn verify_project(port_num: u16) -> OsedaProjectStatus {
let status = match status {
Some(status) => status,
None => {
// if could not get status, ensure process dies
// if could not get status, ensure process dies
shutdown_flag.store(true, Ordering::SeqCst);
let _ = run_handle.join();
return OsedaProjectStatus::NotDeploymentReady(
Expand Down Expand Up @@ -169,4 +168,4 @@ fn verify_project(port_num: u16) -> OsedaProjectStatus {
}

OsedaProjectStatus::DeployReady
}
}
10 changes: 10 additions & 0 deletions src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ use std::{
fs::{self},
process::Command,
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
time::Duration,
};

use clap::Args;
use spinners::{Spinner, Spinners};
use strum::IntoEnumIterator;

use crate::{config, template::Template};
Expand Down Expand Up @@ -105,6 +111,8 @@ pub fn init(opts: InitOptions) -> Result<(), Box<dyn Error>> {
];

for c in npm_commands {
let mut spinner = Spinner::new(Spinners::Dots9, "Initializing...".into());

let args: Vec<&str> = c.split(' ').collect();
let output = Command::new("npm")
.args(&args)
Expand All @@ -119,6 +127,8 @@ pub fn init(opts: InitOptions) -> Result<(), Box<dyn Error>> {
);
return Err(format!("npm {} failed", c).into());
}
spinner.stop();

println!("Bootstrapped npm {}", c);
}

Expand Down
28 changes: 20 additions & 8 deletions src/cmd/run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use std::{
path::Path, process::Command, sync::{
Arc, atomic::{AtomicBool, Ordering}
}, time::Duration
path::Path,
process::Command,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
time::Duration,
};

use crate::config::{self};
Expand All @@ -20,7 +24,11 @@ impl std::fmt::Display for OsedaRunError {
match self {
Self::BuildError(msg) => write!(f, "Oseda Build Error: {}", msg),
Self::ServeError(msg) => write!(f, "Oseda Serve Error: {}", msg),
Self::NotOsedaProjectError(msg) => write!(f, "Current working directory is not an Oseda project: {}", msg)
Self::NotOsedaProjectError(msg) => write!(
f,
"Current working directory is not an Oseda project: {}",
msg
),
}
}
}
Expand All @@ -41,15 +49,19 @@ pub fn run() -> Result<(), OsedaRunError> {
}

pub fn is_cwd_oseda_project() -> bool {
Path::new(config::CONFIG_FILE_NAME).try_exists().is_ok_and(|exists| exists)
Path::new(config::CONFIG_FILE_NAME)
.try_exists()
.is_ok_and(|exists| exists)
}

pub fn run_with_shutdown(shutdown_flag: Arc<AtomicBool>) -> 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()));
if !is_cwd_oseda_project() {
return Err(OsedaRunError::NotOsedaProjectError(
"oseda-config.json not found".to_string(),
));
}

match Command::new("npx").arg("vite").arg("build").status() {
Ok(status) => {
if !status.success() {
Expand Down
Loading