Skip to content

Commit

Permalink
new: Allow no pipeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Feb 3, 2024
1 parent 6bff232 commit cc1c183
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 2 deletions.
6 changes: 6 additions & 0 deletions crates/migrate-turborepo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

#### 🚀 Updates

- Updated to allow a missing or empty `pipeline` in `turbo.json`.

## 0.0.1

#### 🚀 Updates
Expand Down
6 changes: 5 additions & 1 deletion crates/migrate-turborepo/src/migrate_turborepo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/migrate-turborepo/src/turbo_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ pub struct TurboJson {
pub global_dot_env: Option<Vec<String>>,
pub global_env: Option<Vec<String>>,
pub global_pass_through_env: Option<Vec<String>>,
pub pipeline: FxHashMap<String, TurboTask>,
pub pipeline: Option<FxHashMap<String, TurboTask>>,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
projects:
- "packages/*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://turbo.build/schema.json"
}
14 changes: 14 additions & 0 deletions crates/migrate-turborepo/tests/migrate_turborepo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit cc1c183

Please sign in to comment.