Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow usage of turbo without turbo.json #9149

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
2 changes: 2 additions & 0 deletions crates/turborepo-lib/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ pub struct Args {
/// should be used.
#[clap(long, global = true)]
pub dangerously_disable_package_manager_check: bool,
#[clap(long = "experimental-allow-no-turbo-json", hide = true, global = true)]
pub allow_no_turbo_json: bool,
/// Use the `turbo.json` located at the provided path instead of one at the
/// root of the repository.
#[clap(long, global = true)]
Expand Down
1 change: 1 addition & 0 deletions crates/turborepo-lib/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl CommandBase {
.and_then(|args| args.remote_cache_read_only()),
)
.with_run_summary(self.args.run_args().and_then(|args| args.summarize()))
.with_allow_no_turbo_json(self.args.allow_no_turbo_json.then_some(true))
.build()
}

Expand Down
7 changes: 7 additions & 0 deletions crates/turborepo-lib/src/config/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const TURBO_MAPPING: &[(&str, &str)] = [
("turbo_remote_only", "remote_only"),
("turbo_remote_cache_read_only", "remote_cache_read_only"),
("turbo_run_summary", "run_summary"),
("turbo_allow_no_turbo_json", "allow_no_turbo_json"),
]
.as_slice();

Expand Down Expand Up @@ -86,6 +87,7 @@ impl ResolvedConfigurationOptions for EnvVars {
let remote_only = self.truthy_value("remote_only").flatten();
let remote_cache_read_only = self.truthy_value("remote_cache_read_only").flatten();
let run_summary = self.truthy_value("run_summary").flatten();
let allow_no_turbo_json = self.truthy_value("allow_no_turbo_json").flatten();

// Process timeout
let timeout = self
Expand Down Expand Up @@ -171,6 +173,7 @@ impl ResolvedConfigurationOptions for EnvVars {
remote_only,
remote_cache_read_only,
run_summary,
allow_no_turbo_json,

// Processed numbers
timeout,
Expand Down Expand Up @@ -317,6 +320,7 @@ mod test {
env.insert("turbo_remote_only".into(), "1".into());
env.insert("turbo_remote_cache_read_only".into(), "1".into());
env.insert("turbo_run_summary".into(), "true".into());
env.insert("turbo_allow_no_turbo_json".into(), "true".into());

let config = EnvVars::new(&env)
.unwrap()
Expand All @@ -328,6 +332,7 @@ mod test {
assert!(config.remote_only());
assert!(config.remote_cache_read_only());
assert!(config.run_summary());
assert!(config.allow_no_turbo_json());
assert_eq!(turbo_api, config.api_url.unwrap());
assert_eq!(turbo_login, config.login_url.unwrap());
assert_eq!(turbo_team, config.team_slug.unwrap());
Expand Down Expand Up @@ -365,6 +370,7 @@ mod test {
env.insert("turbo_remote_only".into(), "".into());
env.insert("turbo_remote_cache_read_only".into(), "".into());
env.insert("turbo_run_summary".into(), "".into());
env.insert("turbo_allow_no_turbo_json".into(), "".into());

let config = EnvVars::new(&env)
.unwrap()
Expand All @@ -387,6 +393,7 @@ mod test {
assert!(!config.remote_only());
assert!(!config.remote_cache_read_only());
assert!(!config.run_summary());
assert!(!config.allow_no_turbo_json());
}

#[test]
Expand Down
8 changes: 8 additions & 0 deletions crates/turborepo-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use thiserror::Error;
use turbo_json::TurboJsonReader;
use turbopath::{AbsoluteSystemPath, AbsoluteSystemPathBuf};
use turborepo_errors::TURBO_SITE;
use turborepo_repository::package_graph::PackageName;

pub use crate::turbo_json::{RawTurboJson, UIMode};
use crate::{
Expand Down Expand Up @@ -179,6 +180,8 @@ pub enum Error {
#[source_code]
text: NamedSource,
},
#[error("Cannot load turbo.json for in {0} single package mode")]
InvalidTurboJsonLoad(PackageName),
}

const DEFAULT_API_URL: &str = "https://vercel.com/api";
Expand Down Expand Up @@ -239,6 +242,7 @@ pub struct ConfigurationOptions {
pub(crate) remote_only: Option<bool>,
pub(crate) remote_cache_read_only: Option<bool>,
pub(crate) run_summary: Option<bool>,
pub(crate) allow_no_turbo_json: Option<bool>,
}

#[derive(Default)]
Expand Down Expand Up @@ -367,6 +371,10 @@ impl ConfigurationOptions {
.clone()
.unwrap_or_else(|| repo_root.join_component(CONFIG_FILE))
}

pub fn allow_no_turbo_json(&self) -> bool {
self.allow_no_turbo_json.unwrap_or_default()
}
}

// Maps Some("") to None to emulate how Go handles empty strings
Expand Down
Loading
Loading