build: add precompiled CLI distribution
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import path from 'node:path';
|
||||
const overflowTolerance = 2;
|
||||
export function formatOverflowAuditResult(result, cwd = process.cwd()) {
|
||||
const lines = [];
|
||||
for (const issue of result.issues) {
|
||||
const dimensions = [
|
||||
issue.vertical > overflowTolerance ? `纵向 ${issue.vertical}px` : '',
|
||||
issue.horizontal > overflowTolerance ? `横向 ${issue.horizontal}px` : '',
|
||||
].filter(Boolean).join('、');
|
||||
const heading = issue.heading ? `(${issue.heading})` : '';
|
||||
lines.push(`WARN ${path.relative(cwd, issue.deck.entry)}: 第 ${issue.slide} 页${heading}内容溢出:${dimensions};放映时可上下滚动,请优先拆页或精简内容`);
|
||||
}
|
||||
for (const error of result.errors)
|
||||
lines.push(`WARN ${path.relative(cwd, error.deck.entry)}: 无法完成内容溢出检查:${error.message}`);
|
||||
if (!lines.length)
|
||||
lines.push('内容边界检查通过:未发现溢出');
|
||||
return lines;
|
||||
}
|
||||
export function overflowAuditFingerprint(result) {
|
||||
return JSON.stringify({
|
||||
errors: result.errors.map(error => [error.deck.entry, error.message]),
|
||||
issues: result.issues.map(issue => [
|
||||
issue.deck.entry,
|
||||
issue.slide,
|
||||
issue.heading,
|
||||
issue.horizontal,
|
||||
issue.vertical,
|
||||
]),
|
||||
});
|
||||
}
|
||||
export function formatStaticOverflowResult(result, cwd = process.cwd()) {
|
||||
const lines = [];
|
||||
for (const issue of result.issues) {
|
||||
const directions = issue.directions
|
||||
.map(direction => direction === 'vertical' ? '纵向' : '横向')
|
||||
.join('、');
|
||||
const heading = issue.heading ? `(${issue.heading})` : '';
|
||||
lines.push(`WARN ${path.relative(cwd, issue.deck.entry)}: 第 ${issue.slide} 页${heading}存在静态${directions}溢出风险:${issue.reason};请优先拆页或精简内容(最终以 build 渲染检查为准)`);
|
||||
}
|
||||
for (const error of result.errors)
|
||||
lines.push(`WARN ${path.relative(cwd, error.deck.entry)}: 无法完成静态内容检查:${error.message}`);
|
||||
if (!lines.length)
|
||||
lines.push('静态内容检查通过:未发现明显溢出风险(最终以 build 渲染检查为准)');
|
||||
return lines;
|
||||
}
|
||||
export function staticOverflowFingerprint(result) {
|
||||
return JSON.stringify({
|
||||
errors: result.errors.map(error => [error.deck.entry, error.message]),
|
||||
issues: result.issues.map(issue => [
|
||||
issue.deck.entry,
|
||||
issue.slide,
|
||||
issue.heading,
|
||||
issue.directions,
|
||||
issue.reason,
|
||||
]),
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=overflow-report.js.map
|
||||
Reference in New Issue
Block a user