54 lines
2.3 KiB
JavaScript
54 lines
2.3 KiB
JavaScript
/* 一次性校验脚本(默认头像轮 2026-09-30):parse + compileScript + compileTemplate + compileStyle(preprocessLang) */
|
|
const { parse, compileScript, compileTemplate, compileStyle } = require("@vue/compiler-sfc");
|
|
const fs = require("fs");
|
|
|
|
const files = [
|
|
"D:/SoftProject/yunhai/YschTheme/assets-src/pc/UserAvatar.vue",
|
|
"D:/SoftProject/yunhai/UserHome/front/src/components/UserAvatar.vue",
|
|
"D:/SoftProject/yunhai/UserHome/front/src/views/Settings.vue",
|
|
"D:/SoftProject/yunhai/UserHome/front/src/views/ThemePreview.vue",
|
|
"D:/SoftProject/yunhai/UserHome/front/src/components/AppHeader.vue",
|
|
"D:/SoftProject/yunhai/UserHome/front/src/components/UserInfoModal.vue",
|
|
"D:/SoftProject/yunhai/UserHome/front/src/App.vue",
|
|
"D:/SoftProject/yunhai/UserBase/front/src/components/UserAvatar.vue",
|
|
"D:/SoftProject/yunhai/UserBase/front/src/components/layout.vue",
|
|
"D:/SoftProject/yunhai/Notice/front/src/components/UserAvatar.vue",
|
|
"D:/SoftProject/yunhai/Notice/front/src/components/layout.vue",
|
|
];
|
|
|
|
let bad = 0;
|
|
for (const f of files) {
|
|
const src = fs.readFileSync(f, "utf8");
|
|
const { descriptor, errors } = parse(src, { filename: f });
|
|
const fail = msg => {
|
|
bad++;
|
|
console.log("FAIL", f, "::", msg);
|
|
};
|
|
if (errors && errors.length) {
|
|
fail("parse: " + errors.map(e => e.message || String(e)).join(" | "));
|
|
continue;
|
|
}
|
|
try {
|
|
compileScript(descriptor, { id: "check" });
|
|
} catch (e) {
|
|
fail("script: " + e.message);
|
|
continue;
|
|
}
|
|
if (descriptor.template) {
|
|
const t = compileTemplate({ source: descriptor.template.content, filename: f, id: "check" });
|
|
if (t.errors && t.errors.length) {
|
|
fail("template: " + t.errors.map(e => e.message || String(e)).join(" | "));
|
|
continue;
|
|
}
|
|
}
|
|
for (const s of descriptor.styles) {
|
|
const r = compileStyle({ source: s.content, filename: f, id: "check", scoped: !!s.scoped, preprocessLang: s.lang });
|
|
if (r.errors && r.errors.length) {
|
|
fail(`style(lang=${s.lang}): ` + r.errors.map(e => e.message || String(e)).join(" | "));
|
|
}
|
|
}
|
|
if (!bad) console.log("OK ", f);
|
|
}
|
|
console.log(bad ? `\n${bad} 处失败` : "\n全部通过");
|
|
process.exit(bad ? 1 : 0);
|