Skip to content

Commit ae4e43b

Browse files
ci: suppress attw node10 text fallback PIE-605
Mirror the JSON ATTW suppression policy when CI falls back to text output for node10-only resolution diagnostics. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c4fed82 commit ae4e43b

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

scripts/check-attw.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,37 @@ const runAttw = (dir) =>
6464
const runAttwText = (dir) =>
6565
runCommand("bunx attw --pack --ignore-rules cjs-resolves-to-esm -- .", dir);
6666

67+
const isSuppressedTextReport = (stdout) => {
68+
const resolutionFailureLines = stdout
69+
.split(/\r?\n/)
70+
.filter((line) => line.includes("Resolution failed"));
71+
72+
if (resolutionFailureLines.length === 0) {
73+
return false;
74+
}
75+
76+
return resolutionFailureLines.every((line) => {
77+
const rest = line.slice(
78+
line.indexOf("Resolution failed") + "Resolution failed".length,
79+
);
80+
const successfulModernResolutions =
81+
(rest.match(/\((?:ESM|CJS|JSON|types)\)/g) ?? []).length >= 2;
82+
return !rest.includes("Resolution failed") && successfulModernResolutions;
83+
});
84+
};
85+
6786
const parseAttwReport = ({ stdout, failed }, packageName, dir) => {
6887
try {
6988
return JSON.parse(stdout);
7089
} catch (error) {
7190
const textReport = runAttwText(dir);
7291
if (textReport.failed) {
92+
if (isSuppressedTextReport(textReport.stdout)) {
93+
console.warn(
94+
`[check-attw] ${packageName}: ATTW JSON report was malformed; text-mode ATTW reported only suppressed node10 resolution failures.`,
95+
);
96+
return { problems: {} };
97+
}
7398
throw new Error(textReport.stdout || error.message);
7499
}
75100

0 commit comments

Comments
 (0)