Skip to content

Commit ed7c246

Browse files
committed
wip
1 parent d776058 commit ed7c246

File tree

7 files changed

+38
-5
lines changed

7 files changed

+38
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/smbcloud-model/src/project.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use {
2-
crate::{app_auth::AuthApp, ar_date_format},
2+
crate::{app_auth::AuthApp, ar_date_format, runner::Runner},
33
chrono::{DateTime, Utc},
44
serde::{Deserialize, Serialize},
55
serde_repr::{Deserialize_repr, Serialize_repr},
@@ -18,6 +18,7 @@ pub struct Config {
1818
pub struct Project {
1919
pub id: i32,
2020
pub name: String,
21+
pub runner: Runner,
2122
pub repository: Option<String>,
2223
pub description: Option<String>,
2324
pub created_at: DateTime<Utc>,
@@ -29,7 +30,8 @@ impl Display for Project {
2930
write!(f, "ID: {}, Name: {}", self.id, self.name,)
3031
}
3132
}
32-
#[derive(Serialize, Debug)]
33+
#[derive(Serialize, Debug, Deserialize, Clone)]
34+
#[tsync]
3335
pub struct ProjectCreate {
3436
pub name: String,
3537
pub repository: String,

crates/smbcloud-model/src/runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use {
88
},
99
};
1010

11-
#[derive(Debug, Serialize, Deserialize)]
11+
#[derive(Debug, Serialize, Deserialize, Clone)]
1212
#[tsync::tsync]
1313
pub enum Runner {
1414
NodeJs,

crates/smbcloud-networking-project/src/crud_project_create.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::url_builder::build_project_url;
12
use anyhow::Result;
23
use reqwest::Client;
34
use smbcloud_model::{
@@ -7,8 +8,6 @@ use smbcloud_model::{
78
use smbcloud_network::{environment::Environment, network::request};
89
use smbcloud_networking::constants::SMB_USER_AGENT;
910

10-
use crate::url_builder::build_project_url;
11-
1211
pub async fn create_project(
1312
env: Environment,
1413
access_token: String,

crates/smbcloud-utils/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ regex = { workspace = true }
2626
serde = { workspace = true, features = ["derive"] }
2727
serde_json = { workspace = true }
2828
smbcloud-model = { workspace = true }
29+
toml = { workspace = true }

crates/smbcloud-utils/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use {
77
};
88

99
pub mod config;
10+
pub mod write_config;
1011

1112
pub fn email_validation(input: &str) -> Result<(), &'static str> {
1213
let email_regex = Regex::new(
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)