feat(dist,deploy,website): 交付产物统一归集到 releases/<组件>/<版本>,补齐官网与 Linux 验收
三个打包脚本原先各写各的输出目录,现在一律直接落在仓库根 releases/<组件>/<版本>/,分层固定为安装包/免安装/构建中间;dist-win 用 --config.directories.output 覆盖 electron-builder 的目录后再整理,显式传入时不覆盖。插件侧顺手修掉一个既有 bug:原先 rmSync 整个组件目录,重打一次就把上一版的留档抹掉,现在只清当前版本目录。verify-packaged 的 --exe 默认值跟着改到新落点。 deploy/verify-linux.sh 修掉管道在 pipefail 下的 SIGPIPE 误判(命中被算成失败);CI workflow 的出包与上传路径同步;electron-builder.yml 显式指定安装包图标。 website/ 是产品官网(纯静态、无构建步骤,不进 pnpm workspace),含 beUI 动效 token 与实机留档图;客户端冒烟相应加了采集留档图用的外观开关。
This commit is contained in:
1 parent
7b1ae29774
commit
82c85b59c1
40 files changed
+4976
-76
No files matched your search
@@ -15,6 +15,8 @@ electronLanguages:
|
||||
- zh-CN
|
||||
|
||||
directories:
|
||||
# 这里的 output 只是 electron-builder 的兜底值:scripts/dist-win.mjs 会把它覆盖成
|
||||
# releases/client/<版本>/(与服务端、插件同一约定)。直接手敲 electron-builder 才会落到这里。
|
||||
output: release
|
||||
buildResources: build
|
||||
|
||||
@@ -43,7 +45,10 @@ win:
|
||||
arch: [x64]
|
||||
- target: portable
|
||||
arch: [x64]
|
||||
# 未提供 build/icon.ico 时使用 Electron 默认图标
|
||||
# 应用/安装包图标。**显式指定**而不是靠 electron-builder 的默认约定(默认找 build/icon.ico):
|
||||
# 现在生效的是仓库根 build/classhelper.{ico,png}(设计导出、手工放入),
|
||||
# 而 `pnpm icons` 那条 SVG 流水线只会重写 icon.*,两者不打架。
|
||||
icon: build/classhelper.ico
|
||||
artifactName: ${productName}-${version}-${arch}.${ext}
|
||||
|
||||
nsis:
|
||||
|
||||
@@ -10,7 +10,14 @@
|
||||
*
|
||||
* 用法:
|
||||
* node scripts/dist-win.mjs # nsis 安装包 + portable 单文件
|
||||
* node scripts/dist-win.mjs --dir # 仅生成免安装目录 release/win-unpacked
|
||||
* node scripts/dist-win.mjs --dir # 仅生成免安装目录
|
||||
*
|
||||
* 产物统一落到 releases/client/<版本>/(releases/ 不入库,与服务端、插件同级):
|
||||
* 安装包/ 班级小助手-<版本>-x64-setup.exe / -portable.exe(+ .blockmap)
|
||||
* 免安装/ electron-builder 的 win-unpacked 内容
|
||||
* 构建中间/ builder-*.yml、*.nsis.7z
|
||||
* electron-builder 自身的 `directories.output` 由本脚本用 --config 覆盖成上面的版本目录;
|
||||
* 显式传入 `-c.directories.output=...` 时不覆盖,整理(tidyArtifacts)以传入的目录为准。
|
||||
*/
|
||||
import { execFileSync, spawn } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
@@ -59,6 +66,14 @@ if (!fs.existsSync(cli)) {
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
// 交付产物落到 releases/client/<版本>/(与服务端、插件同一约定;releases/ 不入库)
|
||||
const clientVersion = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')).version;
|
||||
const explicitOutput = passthrough.find((item) => item.includes('directories.output'));
|
||||
const destDir = explicitOutput
|
||||
? path.resolve(root, explicitOutput.slice(explicitOutput.indexOf('=') + 1))
|
||||
: path.join(repoRoot, 'releases', 'client', clientVersion);
|
||||
if (!explicitOutput) overrides.push(`--config.directories.output=${destDir}`);
|
||||
|
||||
const cliArgs = [cli, '--win', ...(dirOnly ? ['--dir'] : []), ...overrides, ...passthrough];
|
||||
console.log('[dist] electron-builder', cliArgs.slice(1).join(' '));
|
||||
|
||||
@@ -72,18 +87,18 @@ console.log(`[dist] Node 运行时:${runtime.path}(${runtime.version})`);
|
||||
// 清理上一轮产物:本仓库目录树带沙箱 ACL(含 Everyone 的 DENY(delete child)),
|
||||
// 已存在的产物会被工具(makensis / 7za)判为"Can't open output file / 拒绝访问"而失败,
|
||||
// 手动删掉再打包即可 —— 顺手也保证产物集合确定,不会残留上一轮的旧安装包。
|
||||
const outputDir = path.join(root, 'release');
|
||||
if (fs.existsSync(outputDir)) {
|
||||
for (const name of fs.readdirSync(outputDir)) {
|
||||
if (!/\.(exe|7z|blockmap|yml)$/i.test(name)) continue;
|
||||
try {
|
||||
fs.rmSync(path.join(outputDir, name), { force: true });
|
||||
} catch (error) {
|
||||
console.warn(`[dist] 无法清理旧产物 ${name}:${error.message}`);
|
||||
}
|
||||
let cleaned = false;
|
||||
for (const name of ['win-unpacked', '免安装', '安装包', '构建中间']) {
|
||||
const target = path.join(destDir, name);
|
||||
if (!fs.existsSync(target)) continue;
|
||||
try {
|
||||
fs.rmSync(target, { recursive: true, force: true });
|
||||
cleaned = true;
|
||||
} catch (error) {
|
||||
console.warn(`[dist] 无法清理旧产物 ${name}:${error.message}`);
|
||||
}
|
||||
console.log('[dist] 已清理上一轮的安装包 / 归档');
|
||||
}
|
||||
if (cleaned) console.log('[dist] 已清理上一轮的免安装目录 / 安装包 / 构建中间');
|
||||
|
||||
const child = spawn(runtime.path, cliArgs, { cwd: root, stdio: 'inherit', env });
|
||||
|
||||
@@ -105,21 +120,58 @@ const child = spawn(runtime.path, cliArgs, { cwd: root, stdio: 'inherit', env })
|
||||
function normalizeIntegrityLabel(dir) {
|
||||
if (process.platform !== 'win32') return;
|
||||
const run = (args) => execFileSync('icacls', args, { stdio: 'pipe', windowsHide: true });
|
||||
// 这一行才是"交付物能不能用"的关键,失败必须喊出来
|
||||
try {
|
||||
run([dir, '/setintegritylevel', 'Medium', '/T', '/C']);
|
||||
// 目录自身恢复为"继承父目录的 Low",保证下次构建时 Low 的 7za 仍能写入归档
|
||||
run([dir, '/setintegritylevel', '(OI)(CI)Low']);
|
||||
console.log('[dist] 已修正交付物完整性标签为 Medium,目录恢复继承:', dir);
|
||||
console.log('[dist] 已把交付物完整性标签修正为 Medium:', dir);
|
||||
} catch (error) {
|
||||
console.warn('[dist] 完整性标签修正跳过:', error.message);
|
||||
console.warn('[dist] 完整性标签修正失败(交付物可能装不上,见 AGENTS.md §7 第 7 条):', error.message);
|
||||
}
|
||||
// 目录自身恢复为"继承父目录的 Low",保证下次构建时带 Low 标签的 7za 仍能写进这个目录。
|
||||
// 宿主目录树本来就没有 Low 标签体系时,这一步会被系统拒绝(保持继承即可),属正常,不提示。
|
||||
try {
|
||||
run([dir, '/setintegritylevel', '(OI)(CI)Low']);
|
||||
} catch {
|
||||
/* 忽略 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把 electron-builder 的原始输出整理成 releases 的固定分层:
|
||||
* win-unpacked/ → 免安装/
|
||||
* *.exe / *.blockmap → 安装包/
|
||||
* *.yml / *.nsis.7z → 构建中间/
|
||||
* electron-builder 每次都会按自己的布局重写这些路径,因此整理只放在打包成功之后做;
|
||||
* 同名文件用 renameSync 同盘移动,不会产生大文件的额外拷贝。
|
||||
*/
|
||||
function tidyArtifacts(dir) {
|
||||
if (!fs.existsSync(dir)) return;
|
||||
const moveInto = (from, sub) => {
|
||||
const to = path.join(dir, sub);
|
||||
fs.mkdirSync(to, { recursive: true });
|
||||
fs.renameSync(from, path.join(to, path.basename(from)));
|
||||
};
|
||||
|
||||
const unpacked = path.join(dir, 'win-unpacked');
|
||||
const portableDir = path.join(dir, '免安装');
|
||||
if (fs.existsSync(unpacked)) {
|
||||
fs.rmSync(portableDir, { recursive: true, force: true });
|
||||
fs.renameSync(unpacked, portableDir);
|
||||
}
|
||||
|
||||
for (const name of fs.readdirSync(dir)) {
|
||||
const from = path.join(dir, name);
|
||||
if (!fs.statSync(from).isFile()) continue;
|
||||
if (/\.(exe|blockmap)$/i.test(name)) moveInto(from, '安装包');
|
||||
else if (/\.(yml|7z)$/i.test(name)) moveInto(from, '构建中间');
|
||||
}
|
||||
}
|
||||
|
||||
child.on('exit', (code) => {
|
||||
if (code === 0) {
|
||||
const output = path.join(root, 'release');
|
||||
normalizeIntegrityLabel(output);
|
||||
console.log('\n[dist] 打包完成,产物目录:', output);
|
||||
tidyArtifacts(destDir);
|
||||
normalizeIntegrityLabel(destDir);
|
||||
console.log('\n[dist] 打包完成,产物目录:', destDir);
|
||||
}
|
||||
process.exit(code ?? 1);
|
||||
});
|
||||
@@ -1142,8 +1142,20 @@ async function runIslandChecks(
|
||||
* (他常是 top-center + 较大 marginY,验证实例是 top-center + marginY=8)—— 两个岛一高一低叠在一起,
|
||||
* 用户会以为"屏幕上出现了第二个灵动岛",点它又"反应不对"(它归验证脚本控制,会自己展开/收起)。
|
||||
* 只改**颜色**(不动停靠位置):命中/几何断言全部按默认位置写过,挪位置会把它们弄红(实测踩过)。
|
||||
*
|
||||
* 例外:采集产品留档图时这两个值可以临时换成产品默认外观 ——
|
||||
* `ELECTRON_SMOKE_ISLAND_ACCENT` / `ELECTRON_SMOKE_ISLAND_STYLE`(见 website/tools/capture-shots.mjs)。
|
||||
* 留档图要的是"产品长什么样",不是"验证实例长什么样"。**日常跑验证不要设它们。**
|
||||
*/
|
||||
island.setAppearance({ accent: '#e91e8c', style: 'tinted' });
|
||||
const shotAppearance: Parameters<typeof island.setAppearance>[0] = {
|
||||
accent: process.env.ELECTRON_SMOKE_ISLAND_ACCENT ?? '#e91e8c',
|
||||
};
|
||||
if (process.env.ELECTRON_SMOKE_ISLAND_STYLE === 'black' || process.env.ELECTRON_SMOKE_ISLAND_STYLE === 'glass') {
|
||||
shotAppearance.style = process.env.ELECTRON_SMOKE_ISLAND_STYLE;
|
||||
} else if (!process.env.ELECTRON_SMOKE_ISLAND_STYLE) {
|
||||
shotAppearance.style = 'tinted';
|
||||
}
|
||||
island.setAppearance(shotAppearance);
|
||||
/**
|
||||
* 强制关掉触摸模式:本节的命中/穿透/窗口几何断言全部是按"鼠标模式"写的(用
|
||||
* `setHitTestCursor` 注入光标位置代替挪动真实鼠标)。若跑在带触摸屏的机器上,
|
||||
@@ -3526,6 +3538,94 @@ async function runIslandChecks(
|
||||
* "HTTP 发布 → Socket.IO 广播 → 渲染进程 realtime store → bridge → IPC → 灵动岛"全链路,
|
||||
* 并在灵动岛里真实点击"标为已读",确认通知中心的未读状态同步更新。
|
||||
*/
|
||||
/**
|
||||
* 客户端逐页留档(官网素材用)。只有设了 `ELECTRON_CLIENT_SHOTS_DIR` 才会调用。
|
||||
*
|
||||
* 页面顺序就是侧边栏的顺序,方便照着做图注;走的是 hash 路由,与真实点击菜单等价。
|
||||
* 作业页带 `?date=` 深链 —— 当天通常没有作业,空看板当素材没意义(日期取自
|
||||
* `GET /homeworks/days`,种子数据里只有 2026-09-27 有作业)。
|
||||
*/
|
||||
const CLIENT_PAGE_SHOTS: Array<{ name: string; hash: string }> = [
|
||||
{ name: 'client-schedule', hash: '#/schedule' },
|
||||
{ name: 'client-homeworks', hash: '#/homeworks?date=2026-09-27' },
|
||||
{ name: 'client-notifications', hash: '#/notifications' },
|
||||
{ name: 'client-grades', hash: '#/grades' },
|
||||
{ name: 'client-settings-island', hash: '#/settings/island' },
|
||||
{ name: 'client-settings-appearance', hash: '#/settings/appearance' },
|
||||
];
|
||||
|
||||
/** 页面里飘着的 ElMessage 提示会挡内容,截之前先收掉 */
|
||||
const STRIP_TOASTS = `document.querySelectorAll('.el-message, .el-notification').forEach((node) => node.remove()); true;`;
|
||||
|
||||
/** 主内容区的纯文本长度(侧栏不算):用来判断页面到底渲染出来没有 */
|
||||
const MAIN_TEXT_LENGTH = `((document.querySelector('.el-main.main') ?? document.body).innerText ?? '').trim().length`;
|
||||
|
||||
/**
|
||||
* 截图前把 CSS 动画与过渡停掉。
|
||||
*
|
||||
* 为什么必须:客户端每个页面有「错峰入场」动画(styles/index.css 的 `.page > *`),
|
||||
* 起始帧是 `opacity: 0`。窗口被别的窗口盖住时 Chromium 会冻结 CSS 动画,
|
||||
* 于是 DOM 里文本齐全(实测 3000 多字)、截出来却是**整片空白** —— 排查了半天。
|
||||
* `animation: none` 之后元素回落到自己的基础样式(可见),截图也顺带变成确定性的一帧。
|
||||
*/
|
||||
const FREEZE_ANIMATIONS = `(() => {
|
||||
const id = 'smoke-shot-freeze';
|
||||
if (!document.getElementById(id)) {
|
||||
const style = document.createElement('style');
|
||||
style.id = id;
|
||||
style.textContent = '*, *::before, *::after { animation: none !important; transition: none !important; }';
|
||||
document.head.append(style);
|
||||
}
|
||||
return true;
|
||||
})()`;
|
||||
|
||||
const UNFREEZE_ANIMATIONS = `(() => {
|
||||
document.getElementById('smoke-shot-freeze')?.remove();
|
||||
return true;
|
||||
})()`;
|
||||
|
||||
async function captureClientPages(win: BrowserWindow, dir: string): Promise<void> {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
await win.webContents.executeJavaScript(FREEZE_ANIMATIONS);
|
||||
for (const page of CLIENT_PAGE_SHOTS) {
|
||||
try {
|
||||
for (let attempt = 1; attempt <= 3; attempt += 1) {
|
||||
// 连点两次同样的 hash 不会触发路由,先回课表再过去,保证每次都真的重新渲染
|
||||
await win.webContents.executeJavaScript(`location.hash = '#/schedule'; true;`);
|
||||
await sleep(350);
|
||||
await win.webContents.executeJavaScript(`location.hash = ${JSON.stringify(page.hash)}; true;`);
|
||||
await sleep(1200);
|
||||
await win.webContents.executeJavaScript(STRIP_TOASTS);
|
||||
await sleep(200);
|
||||
|
||||
// 懒加载的视图偶尔会来不及挂上,量到空内容就重来一次
|
||||
const length = await win.webContents.executeJavaScript(MAIN_TEXT_LENGTH);
|
||||
if (typeof length === 'number' && length >= 60) break;
|
||||
if (attempt === 3) {
|
||||
console.warn(`[SHOTS] ${page.name} 内容区一直是空的(最后一次 ${length} 字),跳过`);
|
||||
break;
|
||||
}
|
||||
await sleep(900);
|
||||
}
|
||||
|
||||
const length = await win.webContents.executeJavaScript(MAIN_TEXT_LENGTH);
|
||||
if (typeof length !== 'number' || length < 60) continue;
|
||||
|
||||
const image = await win.webContents.capturePage();
|
||||
if (image.isEmpty()) {
|
||||
console.warn(`[SHOTS] ${page.name} 截到空图,跳过`);
|
||||
continue;
|
||||
}
|
||||
const file = path.join(dir, `${page.name}.png`);
|
||||
fs.writeFileSync(file, image.toPNG());
|
||||
console.log(`[SHOTS] ${page.name} → ${file}(内容 ${length} 字)`);
|
||||
} catch (error) {
|
||||
console.warn(`[SHOTS] ${page.name} 截图失败`, error);
|
||||
}
|
||||
}
|
||||
await win.webContents.executeJavaScript(UNFREEZE_ANIMATIONS);
|
||||
}
|
||||
|
||||
async function runIslandRealtimeCheck(
|
||||
win: BrowserWindow,
|
||||
): Promise<{ delivered: boolean; deliveryDetail: string; markRead: boolean; markReadDetail: string }> {
|
||||
@@ -4454,6 +4554,17 @@ export async function runSmokeTest(win: BrowserWindow): Promise<void> {
|
||||
);
|
||||
if (injectedId) await deleteSmokeNotification(injectedId);
|
||||
|
||||
/**
|
||||
* 官网素材:逐页留档。只有设了 ELECTRON_CLIENT_SHOTS_DIR 才跑 —— 日常验证不受影响。
|
||||
*
|
||||
* 位置两头的约束把这里夹死了:
|
||||
* - 必须在**收尾清理登录态之前**,否则截出来的是登录页 + 缓存数据;
|
||||
* - 必须在**所有 UI 断言之后**:翻页会改变侧栏分组展开态,紧接着测「折叠后图标与汉堡同列」
|
||||
* 就会量到过渡中间值(实测:宽度 200→77、中心差 3.2px,把那条用例弄红了)。
|
||||
*/
|
||||
const clientShotsDir = process.env.ELECTRON_CLIENT_SHOTS_DIR ?? '';
|
||||
if (clientShotsDir) await captureClientPages(win, clientShotsDir);
|
||||
|
||||
const cleanup = await win.webContents.executeJavaScript(
|
||||
`(async () => {
|
||||
if (!window.__classhelperSmoke__) return { ok: false, detail: '渲染进程未注册冒烟钩子' };
|
||||
|
||||
Reference in new issue
Block a user