Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Update nx.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Aug 30, 2024
1 parent 00d08d1 commit 48d2aa7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 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 crates/migrate-nx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#### 🚀 Updates

- Added support for `defaultBase` from `nx.json`.
- Added support for `metadata` from `project.json`.
- Updated dependencies.

## 0.0.5
Expand Down
1 change: 1 addition & 0 deletions crates/migrate-nx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ moon_pdk = { workspace = true }
moon_target = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
starbase_utils = { workspace = true, features = ["glob", "json", "yaml"] }

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions crates/migrate-nx/src/nx_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub struct NxWorkspaceLayout {
#[serde(rename_all = "camelCase")]
pub struct NxJson {
pub affected: Option<NxAffected>,
pub default_base: Option<String>,
pub named_inputs: Option<NxNamedInputs>,
pub target_defaults: Option<FxHashMap<String, NxTargetOptions>>,
pub workspace_layout: Option<NxWorkspaceLayout>,
Expand Down
27 changes: 19 additions & 8 deletions crates/migrate-nx/src/nx_migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::nx_json::*;
use crate::nx_project_json::*;
use moon_common::Id;
use moon_config::FilePath;
use moon_config::PartialProjectMetadataConfig;
use moon_config::PortablePath;
use moon_config::TaskOptionEnvFile;
use moon_config::{
Expand Down Expand Up @@ -71,14 +72,15 @@ impl NxMigrator {
}

pub fn migrate_root_config(&mut self, nx_json: NxJson) -> AnyResult<()> {
if let Some(affected) = nx_json.affected {
if let Some(default_branch) = affected.default_base {
self.inner
.load_workspace_config()?
.vcs
.get_or_insert(PartialVcsConfig::default())
.default_branch = Some(default_branch);
}
if let Some(default_branch) = nx_json
.default_base
.or_else(|| nx_json.affected.and_then(|aff| aff.default_base))
{
self.inner
.load_workspace_config()?
.vcs
.get_or_insert(PartialVcsConfig::default())
.default_branch = Some(default_branch);
}

if let Some(named_inputs) = nx_json.named_inputs {
Expand Down Expand Up @@ -223,6 +225,15 @@ impl NxMigrator {
}
}

if let Some(metadata) = project_json.metadata {
config
.project
.get_or_insert(PartialProjectMetadataConfig::default())
.metadata
.get_or_insert(Default::default())
.extend(metadata);
}

Ok(())
}

Expand Down
2 changes: 2 additions & 0 deletions crates/migrate-nx/src/nx_project_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
use crate::nx_json::{NxNamedInputs, NxTargetOptions};
use rustc_hash::FxHashMap;
use serde::Deserialize;
use std::collections::HashMap;

#[derive(Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct NxProjectJson {
pub implicit_dependencies: Option<Vec<String>>,
pub metadata: Option<HashMap<String, serde_json::Value>>,
pub name: Option<String>,
pub named_inputs: Option<NxNamedInputs>,
pub project_type: Option<String>,
Expand Down

0 comments on commit 48d2aa7

Please sign in to comment.