Skip to content

Commit

Permalink
fix: Fix Bun + Node warnings. (#1215)
Browse files Browse the repository at this point in the history
* Wrap warns.

* Update changelog.
  • Loading branch information
milesj authored Dec 4, 2023
1 parent 78c7668 commit fd05a18
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 74 deletions.
80 changes: 35 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pathdiff = "0.2.1"
petgraph = { version = "0.6.4", default-features = false, features = [
"serde-1",
] }
proto_core = "0.23.5"
proto_core = "0.23.7"
relative-path = { version = "1.9.0", features = ["serde"] }
regex = "1.10.2"
reqwest = { version = "0.11.22", default-features = false, features = [
Expand All @@ -48,7 +48,7 @@ reqwest = { version = "0.11.22", default-features = false, features = [
"native-tls-vendored",
] }
rustc-hash = "1.1.0"
schematic = { version = "0.12.8", default-features = false, features = [
schematic = { version = "0.12.10", default-features = false, features = [
"config",
"schema",
"url",
Expand All @@ -75,7 +75,7 @@ starbase_utils = { version = "0.3.11", default-features = false, features = [
"toml",
"yaml",
] }
system_env = "0.1.4"
system_env = "0.1.6"
tera = { version = "1.19.1", features = ["preserve_order"] }
thiserror = "1.0.50"
tokio = { version = "1.34.0", default-features = false, features = [
Expand Down
32 changes: 23 additions & 9 deletions crates/bun/platform/src/bun_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const LOG_TARGET: &str = "moon:bun-platform";
pub struct BunPlatform {
pub config: BunConfig,

node_also_enabled: bool,

package_names: FxHashMap<String, Id>,

packages_root: PathBuf,
Expand All @@ -52,10 +54,12 @@ impl BunPlatform {
typescript_config: &Option<TypeScriptConfig>,
workspace_root: &Path,
proto_env: Arc<ProtoEnvironment>,
node_also_enabled: bool,
) -> Self {
BunPlatform {
packages_root: path::normalize(workspace_root.join(&config.packages_root)),
config: config.to_owned(),
node_also_enabled,
package_names: FxHashMap::default(),
proto_env,
toolchain: ToolManager::new(Runtime::new(PlatformType::Bun, RuntimeReq::Global)),
Expand Down Expand Up @@ -149,21 +153,31 @@ impl Platform for BunPlatform {

if let Some(existing_source) = projects_map.get(&alias) {
if existing_source != project_source {
if !self.node_also_enabled {
warn!(
target: LOG_TARGET,
"A project already exists with the ID {} ({}), skipping alias of the same name ({})",
color::id(&alias),
color::file(existing_source),
color::file(project_source)
);
}

continue;
}
}

if let Some(existing_id) = aliases_map.get(&alias) {
if !self.node_also_enabled {
warn!(
target: LOG_TARGET,
"A project already exists with the ID {} ({}), skipping alias of the same name ({})",
color::id(&alias),
color::file(existing_source),
"A project already exists with the alias {} (for ID {}), skipping conflicting alias (from {})",
color::id(alias),
color::id(existing_id),
color::file(project_source)
);

continue;
}
}

if aliases_map.contains_key(&alias) {
// Ignore warning here since the duplicate may have come
// from the Node.js platform!
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions crates/core/moon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub async fn load_workspace_from(path: &Path) -> miette::Result<Workspace> {
&workspace.toolchain_config.typescript,
&workspace.root,
Arc::clone(&workspace.proto_env),
workspace.toolchain_config.node.is_some(),
)),
);
}
Expand All @@ -107,6 +108,7 @@ pub async fn load_workspace_from(path: &Path) -> miette::Result<Workspace> {
&workspace.toolchain_config.typescript,
&workspace.root,
Arc::clone(&workspace.proto_env),
workspace.toolchain_config.bun.is_some(),
)),
);
}
Expand Down
Loading

0 comments on commit fd05a18

Please sign in to comment.