Skip to content

Commit 975414e

Browse files
authored
Merge pull request #25 from smbcloudXYZ/feature/swift-runner
feat: add `Swift` runner
2 parents f81c16f + 8d7a2a3 commit 975414e

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

Cargo.lock

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

crates/cli/src/deploy/git.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use crate::project::runner::Runner;
12
use crate::ui::{fail_message, fail_symbol, succeed_message, succeed_symbol};
23
use anyhow::{anyhow, Result};
34
use console::style;
45
use git2::{Remote, Repository};
56
use spinners::Spinner;
67

78
pub async fn remote_deployment_setup<'a>(
9+
runner: &Runner,
810
repo: &'a Repository,
911
repo_name: &'a str,
1012
) -> Result<Remote<'a>> {
@@ -36,11 +38,11 @@ pub async fn remote_deployment_setup<'a>(
3638
.bold()
3739
.to_string(),
3840
);
39-
let remote_format = format!("{}.git", repo_name);
41+
let repo_name_format = format!("{}.git", repo_name);
4042
let remote = repo
4143
.remote(
4244
"smbcloud",
43-
&format!("[email protected]:{}", remote_format),
45+
&format!("{}:{}", runner.git_host(), repo_name_format),
4446
)
4547
.map_err(|e: git2::Error| {
4648
spinner.stop_and_persist(&fail_symbol(), e.to_string());

crates/cli/src/deploy/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
3838
let config = check_config(env).await?;
3939

4040
// Check runner.
41-
detect_runner().await?;
41+
let runner = detect_runner().await?;
4242

4343
// Validate config with project.
4444
check_project(env, &access_token, config.project.id).await?;
@@ -62,7 +62,7 @@ pub async fn process_deploy(env: Environment) -> Result<CommandResult> {
6262
}
6363
};
6464

65-
let mut origin = remote_deployment_setup(&repo, &config.project.repository).await?;
65+
let mut origin = remote_deployment_setup(&runner, &repo, &config.project.repository).await?;
6666

6767
let commit_hash = match main_branch.resolve() {
6868
Ok(result) => match result.target() {

crates/cli/src/project/runner.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ pub(crate) enum Runner {
99
Swift,
1010
}
1111

12+
impl Runner {
13+
pub fn git_host(&self) -> String {
14+
format!("git@{}.smbcloud.xyz", self.api())
15+
}
16+
17+
fn api(&self) -> &str {
18+
match self {
19+
Runner::NodeJs => "api",
20+
Runner::Ruby | Runner::Swift => "api-1",
21+
}
22+
}
23+
}
24+
1225
pub(crate) async fn detect_runner() -> Result<Runner> {
1326
let mut spinner: Spinner = Spinner::new(
1427
spinners::Spinners::SimpleDotsScrolling,

0 commit comments

Comments
 (0)