cc-haha/desktop/scripts/build-preview-agent.ts
程序员阿江(Relakkes) 4d6b1855bf release: prepare v0.3.2
Prepare the desktop release metadata and concise release notes while keeping
tagging and release publishing for a later step. The staged local build-script
updates keep desktop commands on checked-in local toolchain paths and avoid
rewriting preview-agent output when the built content is unchanged.

The persistence-upgrade gate now runs the focused desktop Vitest migration
suite in non-watch mode, matching the broader desktop quality lane and avoiding
pre-push termination during release preparation.

Constraint: Release publishing is intentionally deferred per request
Constraint: Desktop release metadata must keep package, Tauri config, Cargo metadata, and Cargo.lock aligned
Confidence: medium
Scope-risk: moderate
Directive: Do not tag v0.3.2 until release dry-run and final release verification are rerun on the release candidate
Tested: bun run scripts/release.ts 0.3.2 --dry
Tested: cd desktop && bun run lint
Tested: bun run check:persistence-upgrade
Tested: git diff --check
Not-tested: Full bun run verify
2026-06-01 02:30:01 +08:00

28 lines
731 B
TypeScript

import { $ } from 'bun'
import { readFile, rename, rm } from 'node:fs/promises'
const outfile = './src-tauri/resources/preview-agent.js'
const tmpfile = `${outfile}.${process.pid}.tmp`
await $`bun build ./src/preview-agent/index.ts --outfile=${tmpfile} --format=iife --minify`
try {
const [current, next] = await Promise.all([
readFile(outfile),
readFile(tmpfile),
])
if (current.equals(next)) {
await rm(tmpfile, { force: true })
console.log('preview-agent.js unchanged')
process.exit(0)
}
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
await rm(tmpfile, { force: true })
throw error
}
}
await rename(tmpfile, outfile)
console.log('preview-agent.js built')