GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix yarn berry project gates drifting between modes (#628, #629) (#657) · SocketDev/socket-patch@2519aa7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • crates
    • socket-patch-cli
      • CLI_CONTRACT.md
      • src/commands/scan
        • hosted.rs
      • tests
        • in_process_redirect.rs
        • in_process_vendor.rs
    • socket-patch-core/src
      • formats/yarn
        • berry_gates.rs
        • mod.rs
      • patch
        • redirect
          • mod.rs
          • upstream
            • npm.rs
        • shared_store.rs
      • vendor
        • lock_inventory
          • yarn.rs
        • yarn_berry_lock.rs
  • docs
    • ecosystems.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎crates/socket-patch-cli/CLI_CONTRACT.md‎

Copy file name to clipboardExpand all lines: crates/socket-patch-cli/CLI_CONTRACT.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎crates/socket-patch-cli/src/commands/scan/hosted.rs‎

Copy file name to clipboardExpand all lines: crates/socket-patch-cli/src/commands/scan/hosted.rs
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,8 +1745,8 @@ async fn vendored_takeover(
17451745
None
17461746
};
17471747
// Yarn berry twin of the bun gate: the berry rewriter's project-level
1748-
// refusals (mixed line endings, cacheKey, `.yarnrc.yml`
1749-
// compressionLevel) must be known before the takeover reverts a
1748+
// refusals (mixed yarn.lock / package.json line endings, cacheKey,
1749+
// `.yarnrc.yml` compressionLevel) must be known before the takeover reverts a
17501750
// vendored berry purl, or the revert strips the live vendored patch
17511751
// and the rewriter then refuses the lock. Only entries the
17521752
// vendor ledger wired through the yarn-berry backend are gated (the
@@ -1768,8 +1768,14 @@ async fn vendored_takeover(
17681768
)
17691769
.await
17701770
.ok();
1771+
let manifest = socket_patch_core::utils::fs::read_regular_to_string(
1772+
&common.cwd.join("package.json"),
1773+
)
1774+
.await
1775+
.ok();
17711776
socket_patch_core::patch::redirect::preflight_yarn_berry_hosted(
17721777
&lock,
1778+
manifest.as_deref(),
17731779
yarnrc.as_deref(),
17741780
)
17751781
.err()
Collapse file

‎crates/socket-patch-cli/tests/in_process_redirect.rs‎

Copy file name to clipboardExpand all lines: crates/socket-patch-cli/tests/in_process_redirect.rs
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,52 @@ async fn scan_redirect_refuses_a_mixed_line_ending_yarn_berry_lock() {
10601060
);
10611061
}
10621062

1063+
/// #628: the root `package.json` of a berry project is a file the hosted
1064+
/// rewrite edits (its `resolutions`), so a manifest mixing CRLF and LF is
1065+
/// refused like a mixed lock — the same decision vendored mode takes with
1066+
/// `vendor_yarn_berry_mixed_line_endings` — instead of being re-rendered in
1067+
/// its majority ending, which rewrote lines the user never touched and
1068+
/// left rollback no original bytes to restore. Nothing is written.
1069+
#[tokio::test]
1070+
#[serial]
1071+
async fn scan_redirect_refuses_a_mixed_line_ending_yarn_berry_manifest() {
1072+
let server = MockServer::start().await;
1073+
mock_discovery(&server).await;
1074+
mock_reference_with_berry(&server).await;
1075+
mock_view(&server).await;
1076+
1077+
let tmp = tempfile::tempdir().unwrap();
1078+
write_berry_project_spelled(tmp.path(), |t| t.to_string());
1079+
let pkg_path = tmp.path().join("package.json");
1080+
std::fs::write(
1081+
&pkg_path,
1082+
format!(
1083+
"{{\r\n \"name\": \"consumer\",\n \"version\": \"0.0.0\",\r\n \
1084+
\"dependencies\": {{ \"{NAME}\": \"^{VERSION}\" }}\r\n}}\r\n"
1085+
),
1086+
)
1087+
.unwrap();
1088+
let lock_path = tmp.path().join("yarn.lock");
1089+
let (pkg_before, lock_before) = (
1090+
std::fs::read(&pkg_path).unwrap(),
1091+
std::fs::read(&lock_path).unwrap(),
1092+
);
1093+
1094+
let env = run_redirect_subprocess(tmp.path(), &server.uri());
1095+
assert_eq!(env["redirect"]["redirected"], 0, "{env:#}");
1096+
let detail = redirect_warning_detail(&env, "redirect_yarn_berry_mixed_line_endings");
1097+
assert!(detail.contains("package.json"), "names the file: {detail}");
1098+
assert!(detail.contains("yarn install"), "remedy named: {detail}");
1099+
assert_eq!(std::fs::read(&pkg_path).unwrap(), pkg_before, "untouched");
1100+
assert_eq!(std::fs::read(&lock_path).unwrap(), lock_before, "untouched");
1101+
assert!(
1102+
!tmp.path()
1103+
.join(".socket/vendor/redirect-state.json")
1104+
.exists(),
1105+
"no ledger for a refused rewrite"
1106+
);
1107+
}
1108+
10631109
/// Classic (v1) yarn.lock with CRLF line endings (Windows `core.autocrlf`
10641110
/// checkout): the full hosted chain must repoint the TARGET entry — not
10651111
/// whichever entry sorts first — and keep every untouched line CRLF
Collapse file

‎crates/socket-patch-cli/tests/in_process_vendor.rs‎

Copy file name to clipboardExpand all lines: crates/socket-patch-cli/tests/in_process_vendor.rs
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,15 @@ async fn berry_takeovers_refuse_before_reverting_the_old_mode() {
15541554
"yarn.lock",
15551555
"redirect_yarn_berry_mixed_line_endings",
15561556
),
1557+
// #628: hosted mode re-renders the root manifest (its
1558+
// `resolutions`), so a mixed one is refused before the revert, the
1559+
// same decision the hosted→vendored leg below takes.
1560+
(
1561+
"mixed package.json",
1562+
mix,
1563+
"package.json",
1564+
"redirect_yarn_berry_mixed_line_endings",
1565+
),
15571566
(
15581567
"compressionLevel",
15591568
compression,

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.