From 37ea0df67787aa57bfff293549ff9b3d0cda4944 Mon Sep 17 00:00:00 2001 From: WuYongJie <549727955@qq.com> Date: Mon, 30 Nov 2026 15:48:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E5=8F=91=E5=B8=83=E5=8C=85?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=9C=89=E6=95=88=E7=9A=84=E6=9C=80=E4=BD=8E?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E7=89=88=E6=9C=AC=EF=BC=8C=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=20--minimum=20=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/detail-agent-pi/scripts/package-client.mjs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/detail-agent-pi/scripts/package-client.mjs b/apps/detail-agent-pi/scripts/package-client.mjs index 1fd47724..4b8f000d 100644 --- a/apps/detail-agent-pi/scripts/package-client.mjs +++ b/apps/detail-agent-pi/scripts/package-client.mjs @@ -82,7 +82,7 @@ export async function packageClient({ return { destination, ...await checkClientPackage({ destination }), node: version, pi: piVersion }; } -export async function packageRelease({ binary, destination, node, nodeLicense, version, notes }) { +export async function packageRelease({ binary, destination, node, nodeLicense, version, notes, minimum = '0.0.0' }) { const official = (await fs.readFile(path.join(root, '../detail-photocraft/client-version.txt'), 'utf8')).trim(); if (version !== official && version !== official + '-test') throw Error('发布版本与源码版本不一致'); const executable = await fs.readFile(binary); @@ -127,7 +127,7 @@ export async function packageRelease({ binary, destination, node, nodeLicense, v const hash = createHash('sha256'); for await (const chunk of createReadStream(archive)) hash.update(chunk); const metadata = { - ...release, notes: releaseNotes, minimumVersion: null, + ...release, notes: releaseNotes, minimumVersion: minimum, file: { name, size: (await fs.stat(archive)).size, sha256: hash.digest('hex') }, }; await fs.writeFile(path.join(destination, 'release.json'), JSON.stringify(metadata, null, 2)); @@ -139,9 +139,11 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me const flag = args.indexOf('--release'); if (flag !== -1) { const [binary, destination, node, nodeLicense] = args.slice(0, flag); - const [version, notesFlag, notes] = args.slice(flag + 1); - if (notesFlag !== '--notes' || !notes) throw Error('发布模式需要 --release <版本> --notes <说明文件>'); - console.log(JSON.stringify(await packageRelease({ binary, destination, node, nodeLicense, version, notes }))); + const [version, notesFlag, notes, minimumFlag, minimum] = args.slice(flag + 1); + if (notesFlag !== '--notes' || !notes || minimumFlag !== undefined && (minimumFlag !== '--minimum' || !minimum)) { + throw Error('发布模式需要 --release <版本> --notes <说明文件> [--minimum <最低可用版本>]'); + } + console.log(JSON.stringify(await packageRelease({ binary, destination, node, nodeLicense, version, notes, minimum }))); } else { const [binary, destination, node, nodeLicense] = args; const result = await packageClient({ binary, destination, node, nodeLicense });