@smbcloud / cli / commits / ed7c246

wip

Seto committed Oct 10, 2025 at 23:00 UTC ed7c2465f70fe6e2891b66a1ad9a02d033bb0465
7 files changed +38 -5
Cargo.lock
+1
@@ -2122,6 +2122,7 @@ dependencies = [
2122 "serde",
2123 "serde_json",
2124 "smbcloud-model",
2125 + "toml",
2126 ]
2127
2128 [[package]]
crates/smbcloud-model/src/project.rs
+4 -2
@@ -1,5 +1,5 @@
1 use {
2 - crate::{app_auth::AuthApp, ar_date_format},
2 + crate::{app_auth::AuthApp, ar_date_format, runner::Runner},
3 chrono::{DateTime, Utc},
4 serde::{Deserialize, Serialize},
5 serde_repr::{Deserialize_repr, Serialize_repr},
@@ -18,6 +18,7 @@ pub struct Config {
18 pub struct Project {
19 pub id: i32,
20 pub name: String,
21 + pub runner: Runner,
22 pub repository: Option<String>,
23 pub description: Option<String>,
24 pub created_at: DateTime<Utc>,
@@ -29,7 +30,8 @@ impl Display for Project {
30 write!(f, "ID: {}, Name: {}", self.id, self.name,)
31 }
32 }
32 -#[derive(Serialize, Debug)]
33 +#[derive(Serialize, Debug, Deserialize, Clone)]
34 +#[tsync]
35 pub struct ProjectCreate {
36 pub name: String,
37 pub repository: String,
crates/smbcloud-model/src/runner.rs
+1 -1
@@ -8,7 +8,7 @@ use {
8 },
9 };
10
11 -#[derive(Debug, Serialize, Deserialize)]
11 +#[derive(Debug, Serialize, Deserialize, Clone)]
12 #[tsync::tsync]
13 pub enum Runner {
14 NodeJs,
crates/smbcloud-networking-project/src/crud_project_create.rs
+1 -2
@@ -1,3 +1,4 @@
1 +use crate::url_builder::build_project_url;
2 use anyhow::Result;
3 use reqwest::Client;
4 use smbcloud_model::{
@@ -7,8 +8,6 @@ use smbcloud_model::{
8 use smbcloud_network::{environment::Environment, network::request};
9 use smbcloud_networking::constants::SMB_USER_AGENT;
10
10 -use crate::url_builder::build_project_url;
11 -
11 pub async fn create_project(
12 env: Environment,
13 access_token: String,
crates/smbcloud-utils/Cargo.toml
+1
@@ -26,3 +26,4 @@ regex = { workspace = true }
26 serde = { workspace = true, features = ["derive"] }
27 serde_json = { workspace = true }
28 smbcloud-model = { workspace = true }
29 +toml = { workspace = true }
crates/smbcloud-utils/src/lib.rs
+1
@@ -7,6 +7,7 @@ use {
7 };
8
9 pub mod config;
10 +pub mod write_config;
11
12 pub fn email_validation(input: &str) -> Result<(), &'static str> {
13 let email_regex = Regex::new(
crates/smbcloud-utils/src/write_config.rs new
+29
@@ -0,0 +1,29 @@
1 +use {
2 + crate::config::Config,
3 + smbcloud_model::error_codes::{ErrorCode, ErrorResponse},
4 + std::{fs, path::Path},
5 +};
6 +
7 +pub fn write_config(repo_path: &str, config: Config) -> Result<(), ErrorResponse> {
8 + // Ensure .smb directory exists
9 + let smb_dir = Path::new(&repo_path).join(".smb");
10 + if !smb_dir.exists() {
11 + fs::create_dir(smb_dir).map_err(|_| ErrorResponse::Error {
12 + error_code: ErrorCode::MissingConfig,
13 + message: ErrorCode::MissingConfig.message(None).to_string(),
14 + })?;
15 + }
16 +
17 + // Write config to .smb/config.toml
18 + let config_toml = toml::to_string(&config).map_err(|_| ErrorResponse::Error {
19 + error_code: ErrorCode::MissingConfig,
20 + message: ErrorCode::MissingConfig.message(None).to_string(),
21 + })?;
22 +
23 + fs::write(".smb/config.toml", config_toml).map_err(|_| ErrorResponse::Error {
24 + error_code: ErrorCode::MissingConfig,
25 + message: ErrorCode::MissingConfig.message(None).to_string(),
26 + })?;
27 +
28 + Ok(())
29 +}