Skip to content

Commit

Permalink
Merge branch 'main' into nicholasyang/web-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang authored Sep 10, 2024
2 parents f65af06 + bd2bffa commit 9d9c7d3
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 111 deletions.
36 changes: 36 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ console = "0.15.5"
console-subscriber = "0.1.8"
crossbeam-channel = "0.5.8"
dashmap = "5.4.0"
derive_setters = "0.1.6"
dialoguer = "0.10.3"
dunce = "1.0.3"
either = "1.9.0"
Expand All @@ -110,6 +111,7 @@ indicatif = "0.17.3"
indoc = "2.0.0"
itertools = "0.10.5"
lazy_static = "1.4.0"
merge = "0.1.0"
mime = "0.3.16"
notify = "6.1.1"
once_cell = "1.17.1"
Expand Down
2 changes: 2 additions & 0 deletions crates/turborepo-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const_format = "0.2.30"
convert_case = "0.6.0"
crossterm = "0.26"
ctrlc = { version = "3.4.0", features = ["termination"] }
derive_setters = { workspace = true }
dialoguer = { workspace = true, features = ["fuzzy-select"] }
dirs-next = "2.0.0"
dunce = { workspace = true }
Expand All @@ -70,6 +71,7 @@ itertools = { workspace = true }
jsonc-parser = { version = "0.21.0" }
lazy_static = { workspace = true }
libc = "0.2.140"
merge = { workspace = true }
miette = { workspace = true, features = ["fancy"] }
nix = "0.26.2"
notify = { workspace = true }
Expand Down
103 changes: 10 additions & 93 deletions crates/turborepo-lib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ use std::{collections::HashMap, ffi::OsString, io};

use camino::{Utf8Path, Utf8PathBuf};
use convert_case::{Case, Casing};
use derive_setters::Setters;
use env::{EnvVars, OverrideEnvVars};
use file::{AuthFile, ConfigFile};
use merge::Merge;
use miette::{Diagnostic, NamedSource, SourceSpan};
use serde::Deserialize;
use struct_iterable::Iterable;
Expand Down Expand Up @@ -173,15 +175,6 @@ pub enum Error {
},
}

macro_rules! create_builder {
($func_name:ident, $property_name:ident, $type:ty) => {
pub fn $func_name(mut self, value: $type) -> Self {
self.override_config.$property_name = value;
self
}
};
}

const DEFAULT_API_URL: &str = "https://vercel.com/api";
const DEFAULT_LOGIN_URL: &str = "https://vercel.com";
const DEFAULT_TIMEOUT: u64 = 30;
Expand All @@ -190,8 +183,13 @@ const DEFAULT_UPLOAD_TIMEOUT: u64 = 60;
// We intentionally don't derive Serialize so that different parts
// of the code that want to display the config can tune how they
// want to display and what fields they want to include.
#[derive(Deserialize, Default, Debug, PartialEq, Eq, Clone, Iterable)]
#[derive(Deserialize, Default, Debug, PartialEq, Eq, Clone, Iterable, Merge, Setters)]
#[serde(rename_all = "camelCase")]
// Generate setters for the builder type that set these values on its override_config field
#[setters(
prefix = "with_",
generate_delegates(ty = "TurborepoConfigBuilder", field = "override_config")
)]
pub struct ConfigurationOptions {
#[serde(alias = "apiurl")]
#[serde(alias = "ApiUrl")]
Expand Down Expand Up @@ -336,44 +334,6 @@ impl ConfigurationOptions {
}
}

macro_rules! create_set_if_empty {
($func_name:ident, $property_name:ident, $type:ty) => {
fn $func_name(&mut self, value: &mut Option<$type>) {
if self.$property_name.is_none() {
if let Some(value) = value.take() {
self.$property_name = Some(value);
}
}
}
};
}

// Private setters used only for construction
impl ConfigurationOptions {
create_set_if_empty!(set_api_url, api_url, String);
create_set_if_empty!(set_login_url, login_url, String);
create_set_if_empty!(set_team_slug, team_slug, String);
create_set_if_empty!(set_team_id, team_id, String);
create_set_if_empty!(set_token, token, String);
create_set_if_empty!(set_signature, signature, bool);
create_set_if_empty!(set_enabled, enabled, bool);
create_set_if_empty!(set_preflight, preflight, bool);
create_set_if_empty!(set_timeout, timeout, u64);
create_set_if_empty!(set_ui, ui, UIMode);
create_set_if_empty!(set_allow_no_package_manager, allow_no_package_manager, bool);
create_set_if_empty!(set_daemon, daemon, bool);
create_set_if_empty!(set_env_mode, env_mode, EnvMode);
create_set_if_empty!(set_cache_dir, cache_dir, Utf8PathBuf);
create_set_if_empty!(set_scm_base, scm_base, String);
create_set_if_empty!(set_scm_head, scm_head, String);
create_set_if_empty!(set_spaces_id, spaces_id, String);
create_set_if_empty!(
set_root_turbo_json_path,
root_turbo_json_path,
AbsoluteSystemPathBuf
);
}

// Maps Some("") to None to emulate how Go handles empty strings
fn non_empty_str(s: Option<&str>) -> Option<&str> {
s.filter(|s| !s.is_empty())
Expand Down Expand Up @@ -428,30 +388,6 @@ impl TurborepoConfigBuilder {
.unwrap_or_else(get_lowercased_env_vars)
}

create_builder!(with_api_url, api_url, Option<String>);
create_builder!(with_login_url, login_url, Option<String>);
create_builder!(with_team_slug, team_slug, Option<String>);
create_builder!(with_team_id, team_id, Option<String>);
create_builder!(with_token, token, Option<String>);
create_builder!(with_signature, signature, Option<bool>);
create_builder!(with_enabled, enabled, Option<bool>);
create_builder!(with_preflight, preflight, Option<bool>);
create_builder!(with_timeout, timeout, Option<u64>);
create_builder!(with_ui, ui, Option<UIMode>);
create_builder!(
with_allow_no_package_manager,
allow_no_package_manager,
Option<bool>
);
create_builder!(with_daemon, daemon, Option<bool>);
create_builder!(with_env_mode, env_mode, Option<EnvMode>);
create_builder!(with_cache_dir, cache_dir, Option<Utf8PathBuf>);
create_builder!(
with_root_turbo_json_path,
root_turbo_json_path,
Option<AbsoluteSystemPathBuf>
);

pub fn build(&self) -> Result<ConfigurationOptions, Error> {
// Priority, from least significant to most significant:
// - shared configuration (turbo.json)
Expand Down Expand Up @@ -483,27 +419,8 @@ impl TurborepoConfigBuilder {
let config = sources.into_iter().try_fold(
ConfigurationOptions::default(),
|mut acc, current_source| {
let mut current_source_config = current_source.get_configuration_options(&acc)?;
acc.set_api_url(&mut current_source_config.api_url);
acc.set_login_url(&mut current_source_config.login_url);
acc.set_team_slug(&mut current_source_config.team_slug);
acc.set_team_id(&mut current_source_config.team_id);
acc.set_token(&mut current_source_config.token);
acc.set_signature(&mut current_source_config.signature);
acc.set_enabled(&mut current_source_config.enabled);
acc.set_preflight(&mut current_source_config.preflight);
acc.set_timeout(&mut current_source_config.timeout);
acc.set_spaces_id(&mut current_source_config.spaces_id);
acc.set_ui(&mut current_source_config.ui);
acc.set_allow_no_package_manager(
&mut current_source_config.allow_no_package_manager,
);
acc.set_daemon(&mut current_source_config.daemon);
acc.set_env_mode(&mut current_source_config.env_mode);
acc.set_scm_base(&mut current_source_config.scm_base);
acc.set_scm_head(&mut current_source_config.scm_head);
acc.set_cache_dir(&mut current_source_config.cache_dir);
acc.set_root_turbo_json_path(&mut current_source_config.root_turbo_json_path);
let current_source_config = current_source.get_configuration_options(&acc)?;
acc.merge(current_source_config);
Ok(acc)
},
);
Expand Down
9 changes: 8 additions & 1 deletion crates/turborepo-ui/src/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,13 @@ fn run_app_inner<B: Backend + std::io::Write>(
let mut last_render = Instant::now();
let mut resize_debouncer = Debouncer::new(RESIZE_DEBOUNCE_DELAY);
let mut callback = None;
let mut needs_rerender = true;
while let Some(event) = poll(app.input_options()?, &receiver, last_render + FRAMERATE) {
// If we only receive ticks, then there's been no state change so no update
// needed
if !matches!(event, Event::Tick) {
needs_rerender = true;
}
let mut event = Some(event);
let mut resize_event = None;
if matches!(event, Some(Event::Resize { .. })) {
Expand All @@ -606,9 +612,10 @@ fn run_app_inner<B: Backend + std::io::Write>(
if app.done {
break;
}
if FRAMERATE <= last_render.elapsed() {
if FRAMERATE <= last_render.elapsed() && needs_rerender {
terminal.draw(|f| view(app, f))?;
last_render = Instant::now();
needs_rerender = false;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

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

Expand Down
2 changes: 1 addition & 1 deletion packages/create-turbo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-turbo",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "Create a new Turborepo",
"homepage": "https://turbo.build/repo",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-turbo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-turbo",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "ESLint config for Turborepo",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-turbo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-turbo",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "ESLint plugin for Turborepo",
"keywords": [
"turbo",
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@turbo/codemod",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "Provides Codemod transformations to help upgrade your Turborepo codebase when a feature is deprecated.",
"homepage": "https://turbo.build/repo",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-gen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@turbo/gen",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "Extend a Turborepo",
"homepage": "https://turbo.build/repo",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-ignore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turbo-ignore",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "",
"homepage": "https://turbo.build/repo",
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@turbo/types",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "Turborepo types",
"homepage": "https://turbo.build/repo",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-workspaces/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@turbo/workspaces",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "Tools for working with package managers",
"homepage": "https://turbo.build/repo",
"license": "MIT",
Expand Down
14 changes: 7 additions & 7 deletions packages/turbo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "turbo",
"version": "2.1.2-canary.0",
"version": "2.1.2-canary.1",
"description": "Turborepo is a high-performance build system for JavaScript and TypeScript codebases.",
"repository": "https://github.com/vercel/turborepo",
"bugs": "https://github.com/vercel/turborepo/issues",
Expand All @@ -17,11 +17,11 @@
"bin"
],
"optionalDependencies": {
"turbo-darwin-64": "2.1.2-canary.0",
"turbo-darwin-arm64": "2.1.2-canary.0",
"turbo-linux-64": "2.1.2-canary.0",
"turbo-linux-arm64": "2.1.2-canary.0",
"turbo-windows-64": "2.1.2-canary.0",
"turbo-windows-arm64": "2.1.2-canary.0"
"turbo-darwin-64": "2.1.2-canary.1",
"turbo-darwin-arm64": "2.1.2-canary.1",
"turbo-linux-64": "2.1.2-canary.1",
"turbo-linux-arm64": "2.1.2-canary.1",
"turbo-windows-64": "2.1.2-canary.1",
"turbo-windows-arm64": "2.1.2-canary.1"
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
2.1.2-canary.0
2.1.2-canary.1
canary

0 comments on commit 9d9c7d3

Please sign in to comment.