Skip to content

Commit

Permalink
Add v2 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jun 5, 2024
1 parent 2e9dfde commit 614e415
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions crates/migrate-turborepo/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### 🚀 Updates

- Added support for Turborepo v2.
- Updated dependencies.

## 0.1.0
Expand Down
12 changes: 9 additions & 3 deletions crates/migrate-turborepo/src/turbo_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,29 @@ pub enum TurboOutputMode {
pub struct TurboTask {
pub cache: Option<bool>,
pub depends_on: Option<Vec<String>>,
pub dot_env: Option<Vec<String>>,
pub env: Option<Vec<String>>,
pub inputs: Option<Vec<String>>,
pub output_mode: Option<TurboOutputMode>,
pub outputs: Option<Vec<String>>,
pub pass_through_env: Option<Vec<String>>,
pub persistent: Option<bool>,
// v2
pub output_logs: Option<TurboOutputMode>,
// v1 (removed)
pub dot_env: Option<Vec<String>>,
pub output_mode: Option<TurboOutputMode>,
}

#[derive(Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TurboJson {
pub extends: Option<Vec<String>>,
pub global_dependencies: Option<Vec<String>>,
pub global_dot_env: Option<Vec<String>>,
pub global_env: Option<Vec<String>>,
pub global_pass_through_env: Option<Vec<String>>,
// v2
pub tasks: Option<FxHashMap<String, TurboTask>>,
// v1 (removed)
pub global_dot_env: Option<Vec<String>>,
pub pipeline: Option<FxHashMap<String, TurboTask>>,
}

Expand Down
4 changes: 2 additions & 2 deletions crates/migrate-turborepo/src/turbo_migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
};

Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"tasks": {
"client#build": {
"dependsOn": ["^build"]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"test": {
"dependsOn": ["build"],
"inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts"],
"outputMode": "full"
"outputLogs": "full"
},
"dev": {
"cache": false,
Expand Down

0 comments on commit 614e415

Please sign in to comment.