Skip to content

Commit

Permalink
fix: Fix pnpm/yarn unexpected panics. (#1043)
Browse files Browse the repository at this point in the history
* Add fix.

* Bump version.
  • Loading branch information
milesj authored Sep 6, 2023
1 parent f4a9836 commit 2887395
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .yarn/versions/60f61bde.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
releases:
"@moonrepo/cli": patch
"@moonrepo/core-linux-arm64-gnu": patch
"@moonrepo/core-linux-arm64-musl": patch
"@moonrepo/core-linux-x64-gnu": patch
"@moonrepo/core-linux-x64-musl": patch
"@moonrepo/core-macos-arm64": patch
"@moonrepo/core-macos-x64": patch
"@moonrepo/core-windows-x64-msvc": patch
8 changes: 8 additions & 0 deletions nextgen/config/src/toolchain/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,17 @@ impl NodeConfig {
self.inherit_proto_npm(proto_tools)?;
}
NodePackageManager::Pnpm => {
if self.pnpm.is_none() {
self.pnpm = Some(PnpmConfig::default());
}

self.inherit_proto_pnpm(proto_tools)?;
}
NodePackageManager::Yarn => {
if self.yarn.is_none() {
self.yarn = Some(YarnConfig::default());
}

self.inherit_proto_yarn(proto_tools)?;
}
};
Expand Down
48 changes: 48 additions & 0 deletions nextgen/config/tests/toolchain_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,30 @@ node:
);
}

#[test]
fn inherits_plugin_locator_when_none() {
let config = test_load_config(
FILENAME,
r"
node:
packageManager: pnpm
",
|path| {
let mut tools = ToolsConfig::default();
tools.inherit_builtin_plugins();

ToolchainConfig::load_from(path, &tools)
},
);

assert_eq!(
config.node.unwrap().pnpm.unwrap().plugin.unwrap(),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/node-plugin/releases/latest/download/node_depman_plugin.wasm".into()
}
);
}

#[test]
fn proto_version_doesnt_override() {
let config = test_load_config(
Expand Down Expand Up @@ -499,6 +523,30 @@ node:
);
}

#[test]
fn inherits_plugin_locator_when_none() {
let config = test_load_config(
FILENAME,
r"
node:
packageManager: yarn
",
|path| {
let mut tools = ToolsConfig::default();
tools.inherit_builtin_plugins();

ToolchainConfig::load_from(path, &tools)
},
);

assert_eq!(
config.node.unwrap().yarn.unwrap().plugin.unwrap(),
PluginLocator::SourceUrl {
url: "https://github.com/moonrepo/node-plugin/releases/latest/download/node_depman_plugin.wasm".into()
}
);
}

#[test]
fn proto_version_doesnt_override() {
let config = test_load_config(
Expand Down
2 changes: 1 addition & 1 deletion nextgen/task-builder/src/tasks_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<'proj> TasksBuilder<'proj> {
let mut args_sets = vec![];

for link in &chain {
let (command, base_args) = self.get_command_and_args(&link.config)?;
let (command, base_args) = self.get_command_and_args(link.config)?;

if let Some(command) = command {
task.command = command;
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

#### 🐞 Fixes

- Fixed an issue where `pnpm` or `yarn` would panic based on configuration combination.

## 1.13.1

#### 🐞 Fixes
Expand Down

0 comments on commit 2887395

Please sign in to comment.