Merge remote-tracking branch 'origin/feat/channel-prototype' into refactor/claude-review

This commit is contained in:
AAA committed 2026-11-29 20:02:51 +08:00
commit bbfc116aaa
30 files changed
+382 -121

No files matched your search

+4
View File
@@ -91,6 +91,10 @@ export const APP_PACKAGE_TARGETS = [
},
];
export function appArtifactName(targetId) {
return targetId === ANDROID_APP_PACKAGE_TARGET.id ? ANDROID_APP_PACKAGE_TARGET.artifact : `piik-app-${targetId}.zip`;
}
export function appPackageTarget(id) {
return APP_PACKAGE_TARGETS.find((target) => target.id === id) ?? null;
}
+1 -1
View File
@@ -28,7 +28,7 @@ export function buildChannelWeb(root, { version, revision, cargoTarget }) {
writeChannelWebLicenseNotices(root, join(root, 'public', 'third-party-licenses.txt'));
for (const args of [
[join(root, 'prototype', 'channel-browser', 'build.mjs')],
[join(root, 'node_modules', 'vite', 'bin', 'vite.js'), 'build', '--config', 'prototype/channel-browser/web.vite.config.ts'],
[join(root, 'node_modules', 'vite', 'bin', 'vite.js'), 'build'],
]) {
const result = spawnSync(process.execPath, args, { cwd: root, env, stdio: 'inherit', windowsHide: true });
if (result.error) throw result.error;
+2 -2
View File
@@ -17,7 +17,7 @@ import { pipeline } from "node:stream/promises";
import { fileURLToPath } from "node:url";
import { parseArgs } from "node:util";
import { appPackageTarget, CLOUDFLARED_VERSION } from "./app-package-targets.mjs";
import { appArtifactName, appPackageTarget, CLOUDFLARED_VERSION } from "./app-package-targets.mjs";
import { createZip, extractZip, tarExecutable } from "./archive-tool.mjs";
import { assertBuildInputRetained, assertCleanRevision, resetBuildWorkspace } from "./build-workspace.mjs";
import { buildVersion } from "./release-version.mjs";
@@ -122,7 +122,7 @@ try {
mkdirSync(outputRoot, { recursive: false, mode: 0o700 });
outputOwned = true;
const archiveName = `piik-app-${target.id}.zip`;
const archiveName = appArtifactName(target.id);
const archive = join(outputRoot, archiveName);
createZip(packageRoot, archive);
const extractedRoot = join(temporaryRoot, "extracted");
+3 -7
View File
@@ -19,7 +19,7 @@ import { writeServerLicenseNotices } from "./package-licenses.mjs";
import { createZip, extractZip, tarExecutable } from "./archive-tool.mjs";
import { assertBuildInputRetained, assertCleanRevision, resetBuildWorkspace } from "./build-workspace.mjs";
import { buildVersion } from "./release-version.mjs";
import { SERVER_PACKAGE_TARGETS } from "./server-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS, serverReleaseNames } from "./server-package-targets.mjs";
import { sha256, fileRecords, compareFileRecords } from "./package-files.mjs";
import { copyChannelWeb } from "./channel-web-artifact.mjs";
import { buildChannelWeb } from "./build-channel-web.mjs";
@@ -180,11 +180,7 @@ try {
const paths = runtimePaths(target);
const records = recordsFor(runtimeRoot, paths);
const stem = `piik-${releaseId}${target.suffix}`;
const manifestName = `${stem}.manifest.tsv`;
const archiveKind = target.goos === "windows" ? "zip" : "tar.gz";
const artifactName = `${stem}-runtime.${archiveKind}`;
const descriptorName = `${stem}.release.json`;
const { manifest: manifestName, artifact: artifactName, descriptor: descriptorName } = serverReleaseNames(target, revision);
mkdirSync(outputRoot, { recursive: false, mode: 0o700 });
outputOwned = true;
const manifestPath = join(outputRoot, manifestName);
@@ -196,7 +192,7 @@ try {
"ascii",
);
if (archiveKind === "zip") {
if (target.goos === "windows") {
createZip(runtimeRoot, artifactPath);
mkdirSync(verifyRoot);
extractZip(artifactPath, verifyRoot);
+8 -4
View File
@@ -2,8 +2,8 @@ import { createHash, createPublicKey, verify } from "node:crypto";
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { basename, join, resolve } from "node:path";
import { isDeepStrictEqual } from "node:util";
import { APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET } from "./app-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS } from "./server-package-targets.mjs";
import { appArtifactName, APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET } from "./app-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS, serverReleaseNames } from "./server-package-targets.mjs";
export function updateIndex(release) {
return { schema: 1, version: release.version, revision: release.revision,
@@ -109,15 +109,19 @@ export function readReleaseArtifacts(directory, version, revision, { publicKey =
const target = descriptor.target ?? "server";
if (targets.has(target)) throw new Error(`Duplicate release target: ${target}`);
targets.add(target);
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target);
const serverNames = serverTarget && serverReleaseNames(serverTarget, revision);
if (descriptor.artifact !== (serverNames?.artifact ?? appArtifactName(target))) {
throw new Error(`Release artifact name mismatch: ${target}`);
}
const archive = asset(descriptor.artifact);
if (archive.sha256 !== descriptor.artifactSha256) {
throw new Error(`Release artifact checksum mismatch: ${name}`);
}
packages.push(archive);
packagesByTarget.set(target, archive);
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target);
if (serverTarget) {
if (asset(descriptor.manifest).sha256 !== descriptor.manifestSha256) {
if (descriptor.manifest !== serverNames.manifest || asset(descriptor.manifest).sha256 !== descriptor.manifestSha256) {
throw new Error("Server manifest checksum mismatch");
}
servers.push({ ...archive, arch: serverTarget.goarch, goos: serverTarget.goos });
+6
View File
@@ -6,3 +6,9 @@ export const SERVER_PACKAGE_TARGETS = [
{ id: "server-linux-arm64", goos: "linux", goarch: "arm64", rustTarget: "aarch64-unknown-linux-musl", suffix: "-linux-arm64" },
{ id: "server-windows-amd64", goos: "windows", goarch: "amd64", rustTarget: "x86_64-pc-windows-msvc", suffix: "-windows-amd64" },
];
export function serverReleaseNames(target, revision) {
const stem = `piik-${revision.slice(0, 7)}${target.suffix}`;
const extension = target.goos === "windows" ? "zip" : "tar.gz";
return { artifact: `${stem}-runtime.${extension}`, manifest: `${stem}.manifest.tsv`, descriptor: `${stem}.release.json` };
}