Skip to content

Commit 9d9c7d3

Browse files
Merge branch 'main' into nicholasyang/web-ui
2 parents f65af06 + bd2bffa commit 9d9c7d3

File tree

16 files changed

+75
-111
lines changed

16 files changed

+75
-111
lines changed

Cargo.lock

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ console = "0.15.5"
9898
console-subscriber = "0.1.8"
9999
crossbeam-channel = "0.5.8"
100100
dashmap = "5.4.0"
101+
derive_setters = "0.1.6"
101102
dialoguer = "0.10.3"
102103
dunce = "1.0.3"
103104
either = "1.9.0"
@@ -110,6 +111,7 @@ indicatif = "0.17.3"
110111
indoc = "2.0.0"
111112
itertools = "0.10.5"
112113
lazy_static = "1.4.0"
114+
merge = "0.1.0"
113115
mime = "0.3.16"
114116
notify = "6.1.1"
115117
once_cell = "1.17.1"

crates/turborepo-lib/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const_format = "0.2.30"
5252
convert_case = "0.6.0"
5353
crossterm = "0.26"
5454
ctrlc = { version = "3.4.0", features = ["termination"] }
55+
derive_setters = { workspace = true }
5556
dialoguer = { workspace = true, features = ["fuzzy-select"] }
5657
dirs-next = "2.0.0"
5758
dunce = { workspace = true }
@@ -70,6 +71,7 @@ itertools = { workspace = true }
7071
jsonc-parser = { version = "0.21.0" }
7172
lazy_static = { workspace = true }
7273
libc = "0.2.140"
74+
merge = { workspace = true }
7375
miette = { workspace = true, features = ["fancy"] }
7476
nix = "0.26.2"
7577
notify = { workspace = true }

crates/turborepo-lib/src/config/mod.rs

+10-93
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use std::{collections::HashMap, ffi::OsString, io};
66

77
use camino::{Utf8Path, Utf8PathBuf};
88
use convert_case::{Case, Casing};
9+
use derive_setters::Setters;
910
use env::{EnvVars, OverrideEnvVars};
1011
use file::{AuthFile, ConfigFile};
12+
use merge::Merge;
1113
use miette::{Diagnostic, NamedSource, SourceSpan};
1214
use serde::Deserialize;
1315
use struct_iterable::Iterable;
@@ -173,15 +175,6 @@ pub enum Error {
173175
},
174176
}
175177

176-
macro_rules! create_builder {
177-
($func_name:ident, $property_name:ident, $type:ty) => {
178-
pub fn $func_name(mut self, value: $type) -> Self {
179-
self.override_config.$property_name = value;
180-
self
181-
}
182-
};
183-
}
184-
185178
const DEFAULT_API_URL: &str = "https://vercel.com/api";
186179
const DEFAULT_LOGIN_URL: &str = "https://vercel.com";
187180
const DEFAULT_TIMEOUT: u64 = 30;
@@ -190,8 +183,13 @@ const DEFAULT_UPLOAD_TIMEOUT: u64 = 60;
190183
// We intentionally don't derive Serialize so that different parts
191184
// of the code that want to display the config can tune how they
192185
// want to display and what fields they want to include.
193-
#[derive(Deserialize, Default, Debug, PartialEq, Eq, Clone, Iterable)]
186+
#[derive(Deserialize, Default, Debug, PartialEq, Eq, Clone, Iterable, Merge, Setters)]
194187
#[serde(rename_all = "camelCase")]
188+
// Generate setters for the builder type that set these values on its override_config field
189+
#[setters(
190+
prefix = "with_",
191+
generate_delegates(ty = "TurborepoConfigBuilder", field = "override_config")
192+
)]
195193
pub struct ConfigurationOptions {
196194
#[serde(alias = "apiurl")]
197195
#[serde(alias = "ApiUrl")]
@@ -336,44 +334,6 @@ impl ConfigurationOptions {
336334
}
337335
}
338336

339-
macro_rules! create_set_if_empty {
340-
($func_name:ident, $property_name:ident, $type:ty) => {
341-
fn $func_name(&mut self, value: &mut Option<$type>) {
342-
if self.$property_name.is_none() {
343-
if let Some(value) = value.take() {
344-
self.$property_name = Some(value);
345-
}
346-
}
347-
}
348-
};
349-
}
350-
351-
// Private setters used only for construction
352-
impl ConfigurationOptions {
353-
create_set_if_empty!(set_api_url, api_url, String);
354-
create_set_if_empty!(set_login_url, login_url, String);
355-
create_set_if_empty!(set_team_slug, team_slug, String);
356-
create_set_if_empty!(set_team_id, team_id, String);
357-
create_set_if_empty!(set_token, token, String);
358-
create_set_if_empty!(set_signature, signature, bool);
359-
create_set_if_empty!(set_enabled, enabled, bool);
360-
create_set_if_empty!(set_preflight, preflight, bool);
361-
create_set_if_empty!(set_timeout, timeout, u64);
362-
create_set_if_empty!(set_ui, ui, UIMode);
363-
create_set_if_empty!(set_allow_no_package_manager, allow_no_package_manager, bool);
364-
create_set_if_empty!(set_daemon, daemon, bool);
365-
create_set_if_empty!(set_env_mode, env_mode, EnvMode);
366-
create_set_if_empty!(set_cache_dir, cache_dir, Utf8PathBuf);
367-
create_set_if_empty!(set_scm_base, scm_base, String);
368-
create_set_if_empty!(set_scm_head, scm_head, String);
369-
create_set_if_empty!(set_spaces_id, spaces_id, String);
370-
create_set_if_empty!(
371-
set_root_turbo_json_path,
372-
root_turbo_json_path,
373-
AbsoluteSystemPathBuf
374-
);
375-
}
376-
377337
// Maps Some("") to None to emulate how Go handles empty strings
378338
fn non_empty_str(s: Option<&str>) -> Option<&str> {
379339
s.filter(|s| !s.is_empty())
@@ -428,30 +388,6 @@ impl TurborepoConfigBuilder {
428388
.unwrap_or_else(get_lowercased_env_vars)
429389
}
430390

431-
create_builder!(with_api_url, api_url, Option<String>);
432-
create_builder!(with_login_url, login_url, Option<String>);
433-
create_builder!(with_team_slug, team_slug, Option<String>);
434-
create_builder!(with_team_id, team_id, Option<String>);
435-
create_builder!(with_token, token, Option<String>);
436-
create_builder!(with_signature, signature, Option<bool>);
437-
create_builder!(with_enabled, enabled, Option<bool>);
438-
create_builder!(with_preflight, preflight, Option<bool>);
439-
create_builder!(with_timeout, timeout, Option<u64>);
440-
create_builder!(with_ui, ui, Option<UIMode>);
441-
create_builder!(
442-
with_allow_no_package_manager,
443-
allow_no_package_manager,
444-
Option<bool>
445-
);
446-
create_builder!(with_daemon, daemon, Option<bool>);
447-
create_builder!(with_env_mode, env_mode, Option<EnvMode>);
448-
create_builder!(with_cache_dir, cache_dir, Option<Utf8PathBuf>);
449-
create_builder!(
450-
with_root_turbo_json_path,
451-
root_turbo_json_path,
452-
Option<AbsoluteSystemPathBuf>
453-
);
454-
455391
pub fn build(&self) -> Result<ConfigurationOptions, Error> {
456392
// Priority, from least significant to most significant:
457393
// - shared configuration (turbo.json)
@@ -483,27 +419,8 @@ impl TurborepoConfigBuilder {
483419
let config = sources.into_iter().try_fold(
484420
ConfigurationOptions::default(),
485421
|mut acc, current_source| {
486-
let mut current_source_config = current_source.get_configuration_options(&acc)?;
487-
acc.set_api_url(&mut current_source_config.api_url);
488-
acc.set_login_url(&mut current_source_config.login_url);
489-
acc.set_team_slug(&mut current_source_config.team_slug);
490-
acc.set_team_id(&mut current_source_config.team_id);
491-
acc.set_token(&mut current_source_config.token);
492-
acc.set_signature(&mut current_source_config.signature);
493-
acc.set_enabled(&mut current_source_config.enabled);
494-
acc.set_preflight(&mut current_source_config.preflight);
495-
acc.set_timeout(&mut current_source_config.timeout);
496-
acc.set_spaces_id(&mut current_source_config.spaces_id);
497-
acc.set_ui(&mut current_source_config.ui);
498-
acc.set_allow_no_package_manager(
499-
&mut current_source_config.allow_no_package_manager,
500-
);
501-
acc.set_daemon(&mut current_source_config.daemon);
502-
acc.set_env_mode(&mut current_source_config.env_mode);
503-
acc.set_scm_base(&mut current_source_config.scm_base);
504-
acc.set_scm_head(&mut current_source_config.scm_head);
505-
acc.set_cache_dir(&mut current_source_config.cache_dir);
506-
acc.set_root_turbo_json_path(&mut current_source_config.root_turbo_json_path);
422+
let current_source_config = current_source.get_configuration_options(&acc)?;
423+
acc.merge(current_source_config);
507424
Ok(acc)
508425
},
509426
);

crates/turborepo-ui/src/tui/app.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,13 @@ fn run_app_inner<B: Backend + std::io::Write>(
586586
let mut last_render = Instant::now();
587587
let mut resize_debouncer = Debouncer::new(RESIZE_DEBOUNCE_DELAY);
588588
let mut callback = None;
589+
let mut needs_rerender = true;
589590
while let Some(event) = poll(app.input_options()?, &receiver, last_render + FRAMERATE) {
591+
// If we only receive ticks, then there's been no state change so no update
592+
// needed
593+
if !matches!(event, Event::Tick) {
594+
needs_rerender = true;
595+
}
590596
let mut event = Some(event);
591597
let mut resize_event = None;
592598
if matches!(event, Some(Event::Resize { .. })) {
@@ -606,9 +612,10 @@ fn run_app_inner<B: Backend + std::io::Write>(
606612
if app.done {
607613
break;
608614
}
609-
if FRAMERATE <= last_render.elapsed() {
615+
if FRAMERATE <= last_render.elapsed() && needs_rerender {
610616
terminal.draw(|f| view(app, f))?;
611617
last_render = Instant::now();
618+
needs_rerender = false;
612619
}
613620
}
614621
}

crates/turborepo/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
1. Install `protobuf` and `golang` (note: Go must be pinned to v1.20.x, see https://github.com/vercel/turborepo/issues/5918 for details)
66

7-
- On macOS: `brew install protobuf protoc-gen-go protoc-gen-go-grpc [email protected]`
7+
- On macOS: `brew install protobuf protoc-gen-go protoc-gen-go-grpc [email protected] capnp`
88
- On Windows: `choco install golang --version=1.20.7` and `choco install protoc make python3 mingw`
99
- On Ubuntu: `apt-get install golang golang-goprotobuf-dev`
1010

packages/create-turbo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-turbo",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "Create a new Turborepo",
55
"homepage": "https://turbo.build/repo",
66
"license": "MIT",

packages/eslint-config-turbo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-turbo",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "ESLint config for Turborepo",
55
"repository": {
66
"type": "git",

packages/eslint-plugin-turbo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-turbo",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "ESLint plugin for Turborepo",
55
"keywords": [
66
"turbo",

packages/turbo-codemod/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@turbo/codemod",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",
55
"homepage": "https://turbo.build/repo",
66
"license": "MIT",

packages/turbo-gen/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@turbo/gen",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "Extend a Turborepo",
55
"homepage": "https://turbo.build/repo",
66
"license": "MIT",

packages/turbo-ignore/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "turbo-ignore",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "",
55
"homepage": "https://turbo.build/repo",
66
"keywords": [],

packages/turbo-types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@turbo/types",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "Turborepo types",
55
"homepage": "https://turbo.build/repo",
66
"license": "MIT",

packages/turbo-workspaces/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@turbo/workspaces",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "Tools for working with package managers",
55
"homepage": "https://turbo.build/repo",
66
"license": "MIT",

packages/turbo/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "turbo",
3-
"version": "2.1.2-canary.0",
3+
"version": "2.1.2-canary.1",
44
"description": "Turborepo is a high-performance build system for JavaScript and TypeScript codebases.",
55
"repository": "https://github.com/vercel/turborepo",
66
"bugs": "https://github.com/vercel/turborepo/issues",
@@ -17,11 +17,11 @@
1717
"bin"
1818
],
1919
"optionalDependencies": {
20-
"turbo-darwin-64": "2.1.2-canary.0",
21-
"turbo-darwin-arm64": "2.1.2-canary.0",
22-
"turbo-linux-64": "2.1.2-canary.0",
23-
"turbo-linux-arm64": "2.1.2-canary.0",
24-
"turbo-windows-64": "2.1.2-canary.0",
25-
"turbo-windows-arm64": "2.1.2-canary.0"
20+
"turbo-darwin-64": "2.1.2-canary.1",
21+
"turbo-darwin-arm64": "2.1.2-canary.1",
22+
"turbo-linux-64": "2.1.2-canary.1",
23+
"turbo-linux-arm64": "2.1.2-canary.1",
24+
"turbo-windows-64": "2.1.2-canary.1",
25+
"turbo-windows-arm64": "2.1.2-canary.1"
2626
}
2727
}

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
2.1.2-canary.0
1+
2.1.2-canary.1
22
canary

0 commit comments

Comments
 (0)