From 614e41574a8af93e0cddcb51e3ac7ef81fbece26 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 5 Jun 2024 16:51:45 -0700 Subject: [PATCH] Add v2 support. --- crates/migrate-turborepo/CHANGELOG.md | 1 + crates/migrate-turborepo/src/turbo_json.rs | 12 +++++++++--- crates/migrate-turborepo/src/turbo_migrator.rs | 4 ++-- .../__fixtures__/error-missing-project/turbo.json | 2 +- .../__fixtures__/root-merge-existing/turbo.json | 2 +- .../tests/__fixtures__/root-only/turbo.json | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/crates/migrate-turborepo/CHANGELOG.md b/crates/migrate-turborepo/CHANGELOG.md index 23d9515..ca8fd13 100644 --- a/crates/migrate-turborepo/CHANGELOG.md +++ b/crates/migrate-turborepo/CHANGELOG.md @@ -2,6 +2,7 @@ #### 🚀 Updates +- Added support for Turborepo v2. - Updated dependencies. ## 0.1.0 diff --git a/crates/migrate-turborepo/src/turbo_json.rs b/crates/migrate-turborepo/src/turbo_json.rs index c089b75..65b8896 100644 --- a/crates/migrate-turborepo/src/turbo_json.rs +++ b/crates/migrate-turborepo/src/turbo_json.rs @@ -17,13 +17,16 @@ pub enum TurboOutputMode { pub struct TurboTask { pub cache: Option, pub depends_on: Option>, - pub dot_env: Option>, pub env: Option>, pub inputs: Option>, - pub output_mode: Option, pub outputs: Option>, pub pass_through_env: Option>, pub persistent: Option, + // v2 + pub output_logs: Option, + // v1 (removed) + pub dot_env: Option>, + pub output_mode: Option, } #[derive(Default, Deserialize)] @@ -31,9 +34,12 @@ pub struct TurboTask { pub struct TurboJson { pub extends: Option>, pub global_dependencies: Option>, - pub global_dot_env: Option>, pub global_env: Option>, pub global_pass_through_env: Option>, + // v2 + pub tasks: Option>, + // v1 (removed) + pub global_dot_env: Option>, pub pipeline: Option>, } diff --git a/crates/migrate-turborepo/src/turbo_migrator.rs b/crates/migrate-turborepo/src/turbo_migrator.rs index 1171eed..258ddf8 100644 --- a/crates/migrate-turborepo/src/turbo_migrator.rs +++ b/crates/migrate-turborepo/src/turbo_migrator.rs @@ -146,7 +146,7 @@ impl TurboMigrator { turbo_json: TurboJson, from_source: Option<&str>, ) -> AnyResult<()> { - let Some(pipeline) = turbo_json.pipeline else { + let Some(pipeline) = turbo_json.tasks.or_else(|| turbo_json.pipeline) else { return Ok(()); }; @@ -312,7 +312,7 @@ impl TurboMigrator { }); } - if let Some(output_mode) = &turbo_task.output_mode { + if let Some(output_mode) = &turbo_task.output_logs.or_else(|| turbo_task.output_mode) { let output_style = match output_mode { TurboOutputMode::HashOnly => Some(TaskOutputStyle::Hash), TurboOutputMode::NewOnly => Some(TaskOutputStyle::Buffer), diff --git a/crates/migrate-turborepo/tests/__fixtures__/error-missing-project/turbo.json b/crates/migrate-turborepo/tests/__fixtures__/error-missing-project/turbo.json index df9f625..108a98b 100644 --- a/crates/migrate-turborepo/tests/__fixtures__/error-missing-project/turbo.json +++ b/crates/migrate-turborepo/tests/__fixtures__/error-missing-project/turbo.json @@ -1,6 +1,6 @@ { "$schema": "https://turbo.build/schema.json", - "pipeline": { + "tasks": { "client#build": { "dependsOn": ["^build"] } diff --git a/crates/migrate-turborepo/tests/__fixtures__/root-merge-existing/turbo.json b/crates/migrate-turborepo/tests/__fixtures__/root-merge-existing/turbo.json index 1201f08..2438117 100644 --- a/crates/migrate-turborepo/tests/__fixtures__/root-merge-existing/turbo.json +++ b/crates/migrate-turborepo/tests/__fixtures__/root-merge-existing/turbo.json @@ -1,6 +1,6 @@ { "$schema": "https://turbo.build/schema.json", - "pipeline": { + "tasks": { "build": { "dependsOn": ["^build"], "outputs": ["dist/**"] diff --git a/crates/migrate-turborepo/tests/__fixtures__/root-only/turbo.json b/crates/migrate-turborepo/tests/__fixtures__/root-only/turbo.json index 8398c9e..d196f45 100644 --- a/crates/migrate-turborepo/tests/__fixtures__/root-only/turbo.json +++ b/crates/migrate-turborepo/tests/__fixtures__/root-only/turbo.json @@ -9,7 +9,7 @@ "test": { "dependsOn": ["build"], "inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts"], - "outputMode": "full" + "outputLogs": "full" }, "dev": { "cache": false,