diff --git a/crates/migrate-turborepo/CHANGELOG.md b/crates/migrate-turborepo/CHANGELOG.md index 7b0f5ee..75120f5 100644 --- a/crates/migrate-turborepo/CHANGELOG.md +++ b/crates/migrate-turborepo/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +#### 🚀 Updates + +- Updated to allow a missing or empty `pipeline` in `turbo.json`. + ## 0.0.1 #### 🚀 Updates diff --git a/crates/migrate-turborepo/src/migrate_turborepo.rs b/crates/migrate-turborepo/src/migrate_turborepo.rs index d198f67..e50cca6 100644 --- a/crates/migrate-turborepo/src/migrate_turborepo.rs +++ b/crates/migrate-turborepo/src/migrate_turborepo.rs @@ -156,8 +156,12 @@ impl TurboMigrator { turbo_json: TurboJson, from_source: Option<&str>, ) -> AnyResult<()> { + let Some(pipeline) = turbo_json.pipeline else { + return Ok(()); + }; + // package.json script names to turbo tasks - for (script, task) in turbo_json.pipeline { + for (script, task) in pipeline { let project_source; let script_name; diff --git a/crates/migrate-turborepo/src/turbo_json.rs b/crates/migrate-turborepo/src/turbo_json.rs index 36dc03f..3b29abe 100644 --- a/crates/migrate-turborepo/src/turbo_json.rs +++ b/crates/migrate-turborepo/src/turbo_json.rs @@ -34,5 +34,5 @@ pub struct TurboJson { pub global_dot_env: Option>, pub global_env: Option>, pub global_pass_through_env: Option>, - pub pipeline: FxHashMap, + pub pipeline: Option>, } diff --git a/crates/migrate-turborepo/tests/__fixtures__/missing-pipeline/.moon/workspace.yml b/crates/migrate-turborepo/tests/__fixtures__/missing-pipeline/.moon/workspace.yml new file mode 100644 index 0000000..bc09737 --- /dev/null +++ b/crates/migrate-turborepo/tests/__fixtures__/missing-pipeline/.moon/workspace.yml @@ -0,0 +1,2 @@ +projects: + - "packages/*" diff --git a/crates/migrate-turborepo/tests/__fixtures__/missing-pipeline/turbo.json b/crates/migrate-turborepo/tests/__fixtures__/missing-pipeline/turbo.json new file mode 100644 index 0000000..17e6cb8 --- /dev/null +++ b/crates/migrate-turborepo/tests/__fixtures__/missing-pipeline/turbo.json @@ -0,0 +1,3 @@ +{ + "$schema": "https://turbo.build/schema.json" +} diff --git a/crates/migrate-turborepo/tests/migrate_turborepo_test.rs b/crates/migrate-turborepo/tests/migrate_turborepo_test.rs index ed49ce6..02d236c 100644 --- a/crates/migrate-turborepo/tests/migrate_turborepo_test.rs +++ b/crates/migrate-turborepo/tests/migrate_turborepo_test.rs @@ -96,6 +96,20 @@ mod migrate_turborepo { assert_snapshot!(fs::read_to_string(sandbox.path().join(".moon/tasks/node.yml")).unwrap()); } + #[test] + fn supports_no_pipeline() { + let sandbox = create_sandbox("missing-pipeline"); + let plugin = create_extension("test", sandbox.path()); + + plugin.execute_extension(ExecuteExtensionInput { + args: vec![], + context: plugin.create_context(sandbox.path()), + }); + + assert!(!sandbox.path().join("turbo.json").exists()); + assert!(!sandbox.path().join(".moon/tasks/node.yml").exists()); + } + #[test] #[should_panic(expected = "Unable to migrate task for package client.")] fn errors_if_a_task_points_to_an_unknown_project() {