build: electron-builder 打包配置 + 首次构建(win-unpacked 可运行 168MB,cross-env 注入 npmmirror 镜像;打包产物冒烟测试启动 .exe)

This commit is contained in:
hunter-dev
2026-08-24 23:18:39 +08:00
parent 403a28cb2f
commit b9aefa3c17
6 changed files with 1793 additions and 96 deletions
+22
View File
@@ -0,0 +1,22 @@
import { test, expect } from '@playwright/test';
import { _electron as electron } from 'playwright';
import { promises as fs } from 'node:fs';
import nodePath from 'node:path';
import os from 'node:os';
// 打包产物冒烟:启动 electron-builder 产出的 win-unpacked 可执行文件(FR-A0 可安装/可运行基线)
const EXE = nodePath.join(process.cwd(), 'release/win-unpacked/HunterNotes.exe');
test('packaged app launches and renders title bar', async () => {
const exists = await fs.stat(EXE).then(() => true).catch(() => false);
if (!exists) test.skip(true, 'HunterNotes.exe 未构建:先跑 pnpm --filter @hunter/desktop dist');
const tmp = await fs.mkdtemp(nodePath.join(os.tmpdir(), 'hn-pkg-'));
const app = await electron.launch({ executablePath: EXE, args: ['--user-data-dir=' + nodePath.join(tmp, 'userdata')] });
try {
const page = await app.firstWindow();
await page.waitForLoadState('domcontentloaded');
await expect(page.getByText('狩夜人笔记').first()).toBeVisible({ timeout: 15000 });
} finally {
await app.close();
}
});