Skip to content

Commit 98547f3

Browse files
committed
Revert "fix: correct ruby/setup-ruby version comment to match SHA"
This reverts commit 92a77d7.
1 parent 92a77d7 commit 98547f3

File tree

2 files changed

+36
-12
lines changed
  • .github/workflows
  • crates/socket-patch-core/src/package_json

2 files changed

+36
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151

152152
- name: Setup Ruby
153153
if: matrix.suite == 'e2e_gem'
154-
uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1.295.0
154+
uses: ruby/setup-ruby@319994f95fa847cf3fb3cd3dbe89f6dcde9f178f # v1
155155
with:
156156
ruby-version: '3.2'
157157
bundler-cache: false

crates/socket-patch-core/src/package_json/find.rs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,19 @@ pub async fn detect_workspaces(package_json_path: &Path) -> WorkspaceConfig {
9393
Err(_) => return default,
9494
};
9595

96+
// Check for pnpm workspaces first — pnpm projects may also have
97+
// "workspaces" in package.json for compatibility, but
98+
// pnpm-workspace.yaml is the definitive signal.
99+
let dir = package_json_path.parent().unwrap_or(Path::new("."));
100+
let pnpm_workspace = dir.join("pnpm-workspace.yaml");
101+
if let Ok(yaml_content) = fs::read_to_string(&pnpm_workspace).await {
102+
let patterns = parse_pnpm_workspace_patterns(&yaml_content);
103+
return WorkspaceConfig {
104+
ws_type: WorkspaceType::Pnpm,
105+
patterns,
106+
};
107+
}
108+
96109
// Check for npm/yarn workspaces
97110
if let Some(workspaces) = pkg.get("workspaces") {
98111
let patterns = if let Some(arr) = workspaces.as_array() {
@@ -118,17 +131,6 @@ pub async fn detect_workspaces(package_json_path: &Path) -> WorkspaceConfig {
118131
};
119132
}
120133

121-
// Check for pnpm workspaces
122-
let dir = package_json_path.parent().unwrap_or(Path::new("."));
123-
let pnpm_workspace = dir.join("pnpm-workspace.yaml");
124-
if let Ok(yaml_content) = fs::read_to_string(&pnpm_workspace).await {
125-
let patterns = parse_pnpm_workspace_patterns(&yaml_content);
126-
return WorkspaceConfig {
127-
ws_type: WorkspaceType::Pnpm,
128-
patterns,
129-
};
130-
}
131-
132134
default
133135
}
134136

@@ -450,6 +452,28 @@ mod tests {
450452
assert_eq!(config.patterns, vec!["packages/*"]);
451453
}
452454

455+
#[tokio::test]
456+
async fn test_detect_workspaces_pnpm_with_workspaces_field() {
457+
// When both pnpm-workspace.yaml AND "workspaces" in package.json
458+
// exist, pnpm should take priority (e.g. depscan repo)
459+
let dir = tempfile::tempdir().unwrap();
460+
let pkg = dir.path().join("package.json");
461+
fs::write(
462+
&pkg,
463+
r#"{"name": "root", "workspaces": ["packages/*"]}"#,
464+
)
465+
.await
466+
.unwrap();
467+
let pnpm = dir.path().join("pnpm-workspace.yaml");
468+
fs::write(&pnpm, "packages:\n - workspaces/*")
469+
.await
470+
.unwrap();
471+
let config = detect_workspaces(&pkg).await;
472+
assert!(matches!(config.ws_type, WorkspaceType::Pnpm));
473+
// Should use pnpm-workspace.yaml patterns, not package.json workspaces
474+
assert_eq!(config.patterns, vec!["workspaces/*"]);
475+
}
476+
453477
#[tokio::test]
454478
async fn test_detect_workspaces_none() {
455479
let dir = tempfile::tempdir().unwrap();

0 commit comments

Comments
 (0)