| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #!/usr/bin/env node
- import process from "node:process";
- import { dirname, resolve } from "node:path";
- import { fileURLToPath } from "node:url";
- import { resolveNativeSearchReleasePlan } from "../../../scripts/native-search-tools-config.mjs";
- import { runCommand } from "../../../scripts/spawn-command.mjs";
- import { getTargetPlatform } from "./target-platform.mjs";
- import { isRealComputerUseProducerInstalled } from "./computer-use-producer.mjs";
- const scriptDir = dirname(fileURLToPath(import.meta.url));
- const desktopRoot = resolve(scriptDir, "..");
- const pnpmCommand = process.platform === "win32" ? "pnpm.cmd" : "pnpm";
- const target = getTargetPlatform();
- const nativeSearchReleasePlan = resolveNativeSearchReleasePlan({
- platform: target.os,
- arch: target.arch,
- });
- // Windows Chrome 导入入口未启用,默认构建继续编译 helper 会增加 CI 时间和发布签名面。
- // 保留显式开关,后续恢复入口时仍可复用既有原生实现和供应链校验。
- const shouldPrepareWindowsBrowserImportHelper =
- target.os === "win32" && process.env.ZCODE_ENABLE_WINDOWS_BROWSER_IMPORT === "1";
- // Windows Computer Use Helper 由真实 producer 提供;开源占位包没有 Helper runtime,跳过准备。
- const shouldPrepareWindowsCuaHelper =
- target.os === "win32" && isRealComputerUseProducerInstalled({ desktopPackageRoot: desktopRoot });
- // CUA 权限浮窗的吸附数据源。仅 macOS;缺 swiftc 时脚本内部自行降级为跳过(浮窗 fail-open
- // 到屏幕底部,仍可用),所以无条件挂在 darwin 上不会让构建变脆。
- const shouldPrepareMacosWindowBounds = target.os === "darwin";
- // 本机桌面包不再内置 glm 原生二进制(prepare:glm),改为内置 agent 的 JS bundle(prepare:agent-bundle),
- // 运行时由 app 的 Electron Node runtime 执行。Source Server 资源由独立 stage:remote-assets 入口负责。
- const localRuntimeScripts = [
- "prepare:agent-bundle",
- ...(target.os === "win32" ? ["prepare:windows-runtime-host"] : []),
- ...(shouldPrepareWindowsCuaHelper ? ["prepare:windows-cua-helper"] : []),
- ...(nativeSearchReleasePlan.enabled ? ["prepare:native-search"] : []),
- ...(shouldPrepareWindowsBrowserImportHelper ? ["prepare:browser-import-helper"] : []),
- // 预装工具的 Windows 入口都由这个 shim 提供;缺失时入口无法写入。
- ...(target.os === "win32" ? ["prepare:preinstalled-entry-shim"] : []),
- ...(shouldPrepareMacosWindowBounds ? ["prepare:macos-window-bounds"] : []),
- ];
- function runTimedPnpmScript(scriptName) {
- const startMs = Date.now();
- console.log(`[ci][timer] prepare-runtime-assets:${scriptName} start`);
- try {
- runCommand(pnpmCommand, [scriptName], {
- cwd: desktopRoot,
- env: process.env,
- });
- } finally {
- console.log(
- `[ci][timer] prepare-runtime-assets:${scriptName} end duration_ms=${Date.now() - startMs}`,
- );
- }
- }
- for (const scriptName of localRuntimeScripts) {
- runTimedPnpmScript(scriptName);
- }
|