Skip to content

Commit

Permalink
fix: init should add only the required file according to the selection (
Browse files Browse the repository at this point in the history
#3041)

Co-authored-by: Tushar Mathur <[email protected]>
  • Loading branch information
Dhanus3133 and tusharmath authored Oct 20, 2024
1 parent d519a7a commit ae6285b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/cli/tc/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::core::http::API_URL_PREFIX;
use crate::core::print_schema;
use crate::core::rest::{EndpointSet, Unchecked};

pub const FILE_NAME: &str = ".tailcallrc.graphql";
pub const YML_FILE_NAME: &str = ".graphqlrc.yml";
pub const JSON_FILE_NAME: &str = ".tailcallrc.schema.json";
pub const TAILCALL_RC: &str = ".tailcallrc.graphql";
pub const GRAPHQL_RC: &str = ".graphqlrc.yml";
pub const TAILCALL_RC_SCHEMA: &str = ".tailcallrc.schema.json";

lazy_static! {
pub static ref TRACKER: tailcall_tracker::Tracker = tailcall_tracker::Tracker::default();
Expand Down
48 changes: 30 additions & 18 deletions src/cli/tc/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::Path;

use anyhow::Result;

use super::helpers::{FILE_NAME, JSON_FILE_NAME, YML_FILE_NAME};
use super::helpers::{GRAPHQL_RC, TAILCALL_RC, TAILCALL_RC_SCHEMA};
use crate::cli::runtime::{confirm_and_write, create_directory, select_prompt};
use crate::core::config::{Config, Expr, Field, Resolver, RootSchema, Source};
use crate::core::merge_right::MergeRight;
Expand All @@ -21,23 +21,35 @@ pub(super) async fn init_command(runtime: TargetRuntime, folder_path: &str) -> R
let tailcallrc = include_str!("../../../generated/.tailcallrc.graphql");
let tailcallrc_json: &str = include_str!("../../../generated/.tailcallrc.schema.json");

let file_path = Path::new(folder_path).join(FILE_NAME);
let json_file_path = Path::new(folder_path).join(JSON_FILE_NAME);
let yml_file_path = Path::new(folder_path).join(YML_FILE_NAME);

confirm_and_write(
runtime.clone(),
&file_path.display().to_string(),
tailcallrc.as_bytes(),
)
.await?;
confirm_and_write(
runtime.clone(),
&json_file_path.display().to_string(),
tailcallrc_json.as_bytes(),
)
.await?;
confirm_and_write_yml(runtime.clone(), &yml_file_path).await?;
let tailcall_rc = Path::new(folder_path).join(TAILCALL_RC);
let tailcall_rc_schema = Path::new(folder_path).join(TAILCALL_RC_SCHEMA);
let graphql_rc = Path::new(folder_path).join(GRAPHQL_RC);

match selection {
Source::GraphQL => {
// .tailcallrc.graphql
confirm_and_write(
runtime.clone(),
&tailcall_rc.display().to_string(),
tailcallrc.as_bytes(),
)
.await?;

// .graphqlrc.yml
confirm_and_write_yml(runtime.clone(), &graphql_rc).await?;
}

Source::Json | Source::Yml => {
// .tailcallrc.schema.json
confirm_and_write(
runtime.clone(),
&tailcall_rc_schema.display().to_string(),
tailcallrc_json.as_bytes(),
)
.await?;
}
}

create_main(runtime.clone(), folder_path, selection).await?;

Ok(())
Expand Down

1 comment on commit ae6285b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 10.61ms 4.42ms 161.42ms 91.86%
Req/Sec 2.40k 301.42 3.43k 86.92%

286722 requests in 30.01s, 1.44GB read

Requests/sec: 9553.06

Transfer/sec: 49.03MB

Please sign in to comment.