native-search-tools-config.mjs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /* eslint-disable max-lines -- release plan 同时持有内网下载地址与仓库归档路径两类来源及其固定摘要,集中在同一所有者,避免拆分后 plan 漂移。 */
  2. import { dirname, join, resolve } from "node:path";
  3. import process from "node:process";
  4. import { fileURLToPath } from "node:url";
  5. import { resolveIntranetDepsBaseUrl } from "./intranetDefaults.mjs";
  6. const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
  7. // 仓库内置的预编译归档与内网镜像同名、同 SHA-256;只在未配置内网依赖源时作为离线来源。
  8. export const NATIVE_SEARCH_DEPENDENCIES_DIR = join(
  9. repoRoot,
  10. "apps/zcode-cli/dependencies/native-search",
  11. );
  12. export const MACOS_NATIVE_SEARCH_DEPLOYMENT_TARGET = "12.0";
  13. export const LINUX_NATIVE_SEARCH_GLIBC_BASELINE = "2.28";
  14. export const LEGACY_REMOTE_RIPGREP_VERSION = "v13.0.0-10";
  15. export const NATIVE_SEARCH_RIPGREP_REVISION = "4649aa9700";
  16. // Darwin remote 仍使用 legacy ripgrep release;下载器与新的预编译工具链共用同一份
  17. // “下载前必须具备可信摘要”的合同,不能因为该 release 较旧就跳过归档验真。
  18. export const LEGACY_REMOTE_RIPGREP_ARCHIVE_SHA256_BY_TARGET = Object.freeze({
  19. "darwin-arm64": "de44338ca53677968bdd7403ddc1cf9c735e708f7b63e3b34367f9411010a7db",
  20. "darwin-x64": "3b501c05ff9b1d24ae8897dd1c6b5bf842fd12a6f7114264407ac42bc222b25b",
  21. "linux-arm64": "705fc9bcd14baa18bd4dda8fe0651bff440fc0fb934fcdb8e745a85efd7b2afa",
  22. "linux-x64": "ef820a62c1d6fdc396646762ff0f0e47e127947073ed8b5aa4ceea8b61cb1659",
  23. "win32-arm64": "6c12d2c95073a4b981e5706981f42327b6359fc4cd7449ebd11f6769768dea97",
  24. "win32-x64": "7b35b95cf3d7f92d8fe087006899617b1b5a6dac4bbed5d4f6ace6f0934799dc",
  25. });
  26. export const NATIVE_SEARCH_BFS_CONFIGURE_ARGS = Object.freeze([
  27. "--enable-release",
  28. "--with-oniguruma",
  29. "--without-libselinux",
  30. "--without-libacl",
  31. "--without-liburing",
  32. "--without-libcap",
  33. ]);
  34. export const NATIVE_SEARCH_TOOL_VERSIONS = Object.freeze({
  35. bfs: "4.1.1",
  36. ripgrep: "14.1.1",
  37. ugrep: "7.8.4",
  38. });
  39. export const NATIVE_SEARCH_PREBUILT_RELEASES = Object.freeze({
  40. bfs: `v${NATIVE_SEARCH_TOOL_VERSIONS.bfs}-1`,
  41. ripgrep: `v${NATIVE_SEARCH_TOOL_VERSIONS.ripgrep}-1`,
  42. ugrep: `v${NATIVE_SEARCH_TOOL_VERSIONS.ugrep}-1`,
  43. });
  44. const NATIVE_SEARCH_PREBUILT_RELEASE_OVERRIDES = Object.freeze({
  45. linux: Object.freeze({
  46. bfs: `v${NATIVE_SEARCH_TOOL_VERSIONS.bfs}-2`,
  47. }),
  48. });
  49. export const NATIVE_SEARCH_SOURCE_ARCHIVES = Object.freeze([
  50. {
  51. id: "bfs",
  52. version: NATIVE_SEARCH_TOOL_VERSIONS.bfs,
  53. url: "https://codeload.github.com/tavianator/bfs/tar.gz/f220fb5afd8dd7f46b1d1a2ae9c36261eaccf3cd",
  54. sha256: "26a122dbafc81f42a60f32d842ca5b4f30c943ba2efff1d61db827bda5efe742",
  55. },
  56. {
  57. id: "ugrep",
  58. version: NATIVE_SEARCH_TOOL_VERSIONS.ugrep,
  59. url: "https://codeload.github.com/Genivia/ugrep/tar.gz/550599a6434fc5315fb6ecd415a5d859e6d846a8",
  60. sha256: "0b3ed2dc7c3902d89f2ef8b66961db2e31a32f240fa2a2e0eb8d559827f36dab",
  61. },
  62. {
  63. id: "oniguruma",
  64. version: "6.9.10",
  65. url: "https://github.com/kkos/oniguruma/releases/download/v6.9.10/onig-6.9.10.tar.gz",
  66. sha256: "2a5cfc5ae259e4e97f86b68dfffc152cdaffe94e2060b770cb827238d769fc05",
  67. },
  68. {
  69. id: "pcre2",
  70. version: "10.43",
  71. url: "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.43/pcre2-10.43.tar.gz",
  72. sha256: "889d16be5abb8d05400b33c25e151638b8d4bac0e2d9c76e9d6923118ae8a34e",
  73. },
  74. {
  75. id: "zlib",
  76. version: "1.3.1",
  77. url: "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz",
  78. sha256: "9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23",
  79. },
  80. {
  81. id: "bzip2",
  82. version: "1.0.8",
  83. url: "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz",
  84. sha256: "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269",
  85. },
  86. {
  87. id: "zstd",
  88. version: "1.5.6",
  89. url: "https://codeload.github.com/facebook/zstd/tar.gz/794ea1b0afca0f020f4e57b6732332231fb23c70",
  90. sha256: "33eaa5611d330dbc037e32554521d4e4a8edf2358df7d9b74d586c510a4bcec6",
  91. },
  92. {
  93. id: "brotli",
  94. version: "1.1.0",
  95. url: "https://codeload.github.com/google/brotli/tar.gz/ed738e842d2fbdf2d6459e39267a633c4a9b2f5d",
  96. sha256: "aaa739962a45b508b2e783b915e6b2b57ed3b12bd4b0feac73acfb144dffa54f",
  97. },
  98. ]);
  99. const UGREP_ARCHIVE_FEATURES = "-z:zlib,bzip2,zstd,brotli,7z,tar/pax/cpio/zip";
  100. const NATIVE_SEARCH_RUNTIME_TOOL_IDS_BY_PLATFORM = Object.freeze({
  101. darwin: Object.freeze(["bfs", "ugrep", "ripgrep"]),
  102. linux: Object.freeze(["bfs", "ugrep", "ripgrep"]),
  103. win32: Object.freeze(["ugrep", "ripgrep"]),
  104. });
  105. const NATIVE_SEARCH_PRODUCER_OUTPUT_IDS_BY_TARGET = Object.freeze({
  106. "darwin-arm64": Object.freeze(["bfs", "ugrep"]),
  107. "darwin-x64": Object.freeze(["bfs", "ugrep"]),
  108. "linux-arm64": Object.freeze(["bfs", "ugrep"]),
  109. "linux-x64": Object.freeze(["bfs", "ugrep"]),
  110. "win32-arm64": Object.freeze(["ugrep"]),
  111. "win32-x64": Object.freeze(["ugrep"]),
  112. });
  113. export const NATIVE_SEARCH_OFFICIAL_RIPGREP_ASSETS = Object.freeze({
  114. "darwin-arm64": Object.freeze({
  115. archiveExt: "tar.gz",
  116. releaseFileName: "ripgrep-v14.1.1-1-aarch64-apple-darwin.tar.gz",
  117. revision: NATIVE_SEARCH_RIPGREP_REVISION,
  118. sha256: "84ff9b227b9aad651be0ac4cf7802a190015bfba3dfa6b015cc7aa89dd8c5c2b",
  119. }),
  120. "darwin-x64": Object.freeze({
  121. archiveExt: "tar.gz",
  122. releaseFileName: "ripgrep-v14.1.1-1-x86_64-apple-darwin.tar.gz",
  123. revision: NATIVE_SEARCH_RIPGREP_REVISION,
  124. sha256: "cfedd7993342bc5f90310ce73a00cbf5d3b5237654c9bfc18b383f0e829f3b11",
  125. }),
  126. "linux-arm64": Object.freeze({
  127. archiveExt: "tar.gz",
  128. releaseFileName: "ripgrep-v14.1.1-1-aarch64-unknown-linux-musl.tar.gz",
  129. revision: null,
  130. sha256: "98c0371366a9db920ed6c196083e8030511055e5f128b3bde2ca56bbddf85b9a",
  131. }),
  132. "linux-x64": Object.freeze({
  133. archiveExt: "tar.gz",
  134. releaseFileName: "ripgrep-v14.1.1-1-x86_64-unknown-linux-musl.tar.gz",
  135. revision: NATIVE_SEARCH_RIPGREP_REVISION,
  136. sha256: "1154dd91f7b144cee490b91f1ab27ce04f8f01d8876cde2d9c0eff845c8ab012",
  137. }),
  138. "win32-x64": Object.freeze({
  139. archiveExt: "zip",
  140. releaseFileName: "ripgrep-v14.1.1-1-x86_64-pc-windows-msvc.zip",
  141. revision: NATIVE_SEARCH_RIPGREP_REVISION,
  142. sha256: "ede1d7f533f30d7e2870f77139d0fb9d7591daad5260b80d6a525e0bb5bd440e",
  143. }),
  144. "win32-arm64": Object.freeze({
  145. archiveExt: "zip",
  146. releaseFileName: "ripgrep-v14.1.1-1-aarch64-pc-windows-msvc.zip",
  147. revision: NATIVE_SEARCH_RIPGREP_REVISION,
  148. sha256: "88660d96f822d2e0329e254031068e82028f9c13efcec9b2d78c5a19d3f9ac47",
  149. }),
  150. });
  151. export const NATIVE_SEARCH_PRODUCER_ARCHIVE_SHA256_BY_TARGET = Object.freeze({
  152. "darwin-arm64": Object.freeze({
  153. bfs: "696f73eaff50d3c3de8a8ee36746a89693dd6ff0d010b05cd3b4b3eb2a369781",
  154. ugrep: "01ea803e3fc3b94e796a9376e4d062a5490fe08e5760c6173e72b8f31546a4f3",
  155. }),
  156. "darwin-x64": Object.freeze({
  157. bfs: "d993d72530749fa777339a7546f03338499abf235e2147d4adcd086641c6376f",
  158. ugrep: "6a2bedd9ccf53a2ac574d2fa498a36dcbe21e957b40442f9493180c6dad4dea9",
  159. }),
  160. "linux-arm64": Object.freeze({
  161. bfs: "dabdde935a02f89dd0c48c5cd0ec756a87d300fd5ace85a78e6a9eb51d771118",
  162. ugrep: "bf3b99c0af41f50c0ec3031b32ab8f67fa95b5581add18fad5163ece978d31ba",
  163. }),
  164. "linux-x64": Object.freeze({
  165. bfs: "9adf5759000021dd8fcd99670461cc43863f9172fb16f2f9a3e49c700311e7a0",
  166. ugrep: "13732f50fe63da07f3472f627f611b75359153163d07a0eb01e7c54125ae930e",
  167. }),
  168. "win32-arm64": Object.freeze({
  169. ugrep: "e9de73f1b542105203d586b19b4d57b8ecf2bf780f23e86c66a0fb7f56d51024",
  170. }),
  171. "win32-x64": Object.freeze({
  172. ugrep: "7bbd8e56540d2019a343688f1fc0ddb2ff5f0988090c577d2b9d6f4a8a86be21",
  173. }),
  174. });
  175. const NATIVE_SEARCH_BINARY_NAMES = Object.freeze({
  176. bfs: "bfs",
  177. ripgrep: "rg",
  178. ugrep: "ugrep",
  179. });
  180. function resolveNativeSearchArchiveTarget(platform, arch) {
  181. switch (platform) {
  182. case "darwin":
  183. return `${arch === "arm64" ? "aarch64" : "x86_64"}-apple-darwin.tar.gz`;
  184. case "linux":
  185. return `${arch === "arm64" ? "aarch64" : "x86_64"}-unknown-linux-gnu.tar.gz`;
  186. case "win32":
  187. return `${arch === "arm64" ? "aarch64" : "x86_64"}-pc-windows-msvc.zip`;
  188. }
  189. }
  190. // 只有完成对应构建与发布校验的 platform key 才能进入 desktop 发行链路。
  191. const ENABLED_NATIVE_SEARCH_PLATFORM_KEYS = Object.freeze([
  192. "darwin-arm64",
  193. "darwin-x64",
  194. "linux-arm64",
  195. "linux-x64",
  196. "win32-arm64",
  197. "win32-x64",
  198. ]);
  199. const UGREP_SOURCE_IDS = Object.freeze(["ugrep", "pcre2", "zlib", "bzip2", "zstd", "brotli"]);
  200. export function normalizeNativeSearchPlatform(rawPlatform = process.platform) {
  201. switch (rawPlatform.toLowerCase()) {
  202. case "mac":
  203. case "macos":
  204. case "darwin":
  205. case "osx":
  206. return "darwin";
  207. case "win":
  208. case "windows":
  209. case "win32":
  210. return "win32";
  211. case "linux":
  212. return "linux";
  213. default:
  214. throw new Error(`unsupported native search platform ${rawPlatform}`);
  215. }
  216. }
  217. export function normalizeNativeSearchArch(rawArch = process.arch) {
  218. switch (rawArch.toLowerCase()) {
  219. case "x64":
  220. case "amd64":
  221. case "x86_64":
  222. return "x64";
  223. case "arm64":
  224. case "aarch64":
  225. return "arm64";
  226. default:
  227. throw new Error(`unsupported native search architecture ${rawArch}`);
  228. }
  229. }
  230. export function resolveNativeSearchPrebuiltRelease(toolId, rawPlatform = process.platform) {
  231. const platform = normalizeNativeSearchPlatform(rawPlatform);
  232. const release =
  233. NATIVE_SEARCH_PREBUILT_RELEASE_OVERRIDES[platform]?.[toolId] ??
  234. NATIVE_SEARCH_PREBUILT_RELEASES[toolId];
  235. if (!release) {
  236. throw new Error(`unsupported native search tool ${toolId}`);
  237. }
  238. return release;
  239. }
  240. export function isMacosRosettaTarget({
  241. platform,
  242. arch,
  243. hostPlatform = process.platform,
  244. hostArch = process.arch,
  245. }) {
  246. return (
  247. normalizeNativeSearchPlatform(platform) === "darwin" &&
  248. normalizeNativeSearchPlatform(hostPlatform) === "darwin" &&
  249. normalizeNativeSearchArch(hostArch) === "arm64" &&
  250. normalizeNativeSearchArch(arch) === "x64"
  251. );
  252. }
  253. export function getNativeSearchRuntimeToolIdsForPlatform(rawPlatform) {
  254. const platform = normalizeNativeSearchPlatform(rawPlatform);
  255. return NATIVE_SEARCH_RUNTIME_TOOL_IDS_BY_PLATFORM[platform];
  256. }
  257. export function getNativeSearchProducerOutputIds({ platform, arch }) {
  258. const normalizedPlatform = normalizeNativeSearchPlatform(platform);
  259. const normalizedArch = normalizeNativeSearchArch(arch);
  260. const platformKey = `${normalizedPlatform}-${normalizedArch}`;
  261. const outputIds = NATIVE_SEARCH_PRODUCER_OUTPUT_IDS_BY_TARGET[platformKey];
  262. if (!outputIds) {
  263. throw new Error(`unsupported native search producer target ${platformKey}`);
  264. }
  265. return outputIds;
  266. }
  267. export function getExpectedUgrepFeatureContract(rawPlatform) {
  268. const platform = normalizeNativeSearchPlatform(rawPlatform);
  269. const pcre2Feature = platform === "darwin" ? "-P:pcre2" : "-P:pcre2jit";
  270. return `; ${pcre2Feature}; ${UGREP_ARCHIVE_FEATURES}`;
  271. }
  272. export function resolveNativeSearchReleasePlan({
  273. platform = process.platform,
  274. arch = process.arch,
  275. } = {}) {
  276. const normalizedPlatform = normalizeNativeSearchPlatform(platform);
  277. const normalizedArch = normalizeNativeSearchArch(arch);
  278. const platformKey = `${normalizedPlatform}-${normalizedArch}`;
  279. const enabled = ENABLED_NATIVE_SEARCH_PLATFORM_KEYS.includes(platformKey);
  280. const runtimeToolIds = enabled
  281. ? [...getNativeSearchRuntimeToolIdsForPlatform(normalizedPlatform)]
  282. : [];
  283. return {
  284. platform: normalizedPlatform,
  285. arch: normalizedArch,
  286. platformKey,
  287. enabled,
  288. runtimeToolIds,
  289. extraResourceToolIds: runtimeToolIds.filter((toolId) => toolId !== "ripgrep"),
  290. };
  291. }
  292. export function getNativeSearchSourceArchivesForTarget({ platform, arch }) {
  293. const producerOutputIds = getNativeSearchProducerOutputIds({ platform, arch });
  294. const requiredSourceIds = new Set();
  295. if (producerOutputIds.includes("ugrep")) {
  296. for (const sourceId of UGREP_SOURCE_IDS) requiredSourceIds.add(sourceId);
  297. }
  298. if (producerOutputIds.includes("bfs")) {
  299. requiredSourceIds.add("bfs");
  300. requiredSourceIds.add("oniguruma");
  301. }
  302. return NATIVE_SEARCH_SOURCE_ARCHIVES.filter((source) => requiredSourceIds.has(source.id));
  303. }
  304. export function resolveNativeSearchBuildPlan({
  305. platform = process.platform,
  306. arch = process.arch,
  307. outputDir,
  308. } = {}) {
  309. const normalizedPlatform = normalizeNativeSearchPlatform(platform);
  310. const normalizedArch = normalizeNativeSearchArch(arch);
  311. const platformKey = `${normalizedPlatform}-${normalizedArch}`;
  312. const resolvedOutputDir = resolve(
  313. outputDir ?? join(repoRoot, "packages/desktop/bundled-tools", platformKey),
  314. );
  315. const runtimeToolIds = getNativeSearchRuntimeToolIdsForPlatform(normalizedPlatform);
  316. const producerOutputIds = getNativeSearchProducerOutputIds({
  317. platform: normalizedPlatform,
  318. arch: normalizedArch,
  319. });
  320. const executableSuffix = normalizedPlatform === "win32" ? ".exe" : "";
  321. const binaries = Object.fromEntries(
  322. runtimeToolIds.map((toolId) => [
  323. toolId,
  324. join(resolvedOutputDir, toolId, `${NATIVE_SEARCH_BINARY_NAMES[toolId]}${executableSuffix}`),
  325. ]),
  326. );
  327. return {
  328. platform: normalizedPlatform,
  329. arch: normalizedArch,
  330. platformKey,
  331. outputDir: resolvedOutputDir,
  332. runtimeToolIds,
  333. producerOutputIds: [...producerOutputIds],
  334. binaries,
  335. bfsPath: binaries.bfs,
  336. rgPath: binaries.ripgrep,
  337. ugrepPath: binaries.ugrep,
  338. };
  339. }
  340. export function resolveNativeSearchPrebuiltDownloadBaseUrl(env = process.env) {
  341. return (
  342. env.NATIVE_SEARCH_TOOLS_DOWNLOAD_BASE_URL?.trim().replace(/\/+$/, "") ||
  343. `${resolveIntranetDepsBaseUrl(env)}/native-search-tools`
  344. );
  345. }
  346. export function resolveNativeSearchRipgrepDownloadBaseUrl(env = process.env) {
  347. return (
  348. env.NATIVE_SEARCH_RIPGREP_DOWNLOAD_BASE_URL?.trim().replace(/\/+$/, "") ||
  349. `${resolveNativeSearchPrebuiltDownloadBaseUrl(env)}/ripgrep-${NATIVE_SEARCH_PREBUILT_RELEASES.ripgrep}`
  350. );
  351. }
  352. /**
  353. * native search 预编译归档来源的唯一判定,desktop / SEA / server-cli / remote 准备共用:
  354. * - 显式配置 NATIVE_SEARCH_TOOLS_DOWNLOAD_BASE_URL,或内网依赖源可解析:`intranet`,沿用原有下载链路;
  355. * - 内网依赖源未配置(resolveIntranetDepsBaseUrl 抛错或返回空):`repository`,解包仓库内置归档。
  356. * 两种来源使用同一份 release plan 与固定 SHA-256,只是字节来源不同。
  357. */
  358. export function resolveNativeSearchArtifactSource(env = process.env) {
  359. if (env.NATIVE_SEARCH_TOOLS_DOWNLOAD_BASE_URL?.trim()) return "intranet";
  360. try {
  361. return resolveIntranetDepsBaseUrl(env) ? "intranet" : "repository";
  362. } catch {
  363. return "repository";
  364. }
  365. }
  366. export function resolveNativeSearchPrebuiltPlan({
  367. platform = process.platform,
  368. arch = process.arch,
  369. outputDir,
  370. env = process.env,
  371. dependenciesDir = NATIVE_SEARCH_DEPENDENCIES_DIR,
  372. } = {}) {
  373. const buildPlan = resolveNativeSearchBuildPlan({ platform, arch, outputDir });
  374. const archiveTarget = resolveNativeSearchArchiveTarget(buildPlan.platform, buildPlan.arch);
  375. // 未配置内网依赖源时不能解析下载地址;此时计划只携带仓库归档路径,下载地址留空。
  376. const downloadBaseUrls =
  377. resolveNativeSearchArtifactSource(env) === "intranet"
  378. ? {
  379. producer: resolveNativeSearchPrebuiltDownloadBaseUrl(env),
  380. ripgrep: resolveNativeSearchRipgrepDownloadBaseUrl(env),
  381. }
  382. : null;
  383. const officialRipgrepAsset = NATIVE_SEARCH_OFFICIAL_RIPGREP_ASSETS[buildPlan.platformKey];
  384. return {
  385. ...buildPlan,
  386. artifacts: buildPlan.runtimeToolIds.map((toolId) => {
  387. if (toolId === "ripgrep") {
  388. if (!officialRipgrepAsset) {
  389. throw new Error(`missing Microsoft ripgrep asset for ${buildPlan.platformKey}`);
  390. }
  391. return {
  392. toolId,
  393. version: NATIVE_SEARCH_TOOL_VERSIONS[toolId],
  394. release: NATIVE_SEARCH_PREBUILT_RELEASES[toolId],
  395. releaseFileName: officialRipgrepAsset.releaseFileName,
  396. archiveExt: officialRipgrepAsset.archiveExt,
  397. archiveSha256: officialRipgrepAsset.sha256,
  398. binaryName: `${NATIVE_SEARCH_BINARY_NAMES[toolId]}${buildPlan.platform === "win32" ? ".exe" : ""}`,
  399. binaryPath: buildPlan.binaries[toolId],
  400. ...(downloadBaseUrls
  401. ? { downloadUrl: `${downloadBaseUrls.ripgrep}/${officialRipgrepAsset.releaseFileName}` }
  402. : {}),
  403. archivePath: resolve(
  404. dependenciesDir,
  405. `ripgrep-${NATIVE_SEARCH_PREBUILT_RELEASES.ripgrep}`,
  406. officialRipgrepAsset.releaseFileName,
  407. ),
  408. source: "official",
  409. };
  410. }
  411. const release = resolveNativeSearchPrebuiltRelease(toolId, buildPlan.platform);
  412. const releaseFileName = `${toolId}-${release}-${archiveTarget}`;
  413. const archiveSha256 =
  414. NATIVE_SEARCH_PRODUCER_ARCHIVE_SHA256_BY_TARGET[buildPlan.platformKey]?.[toolId];
  415. if (!archiveSha256) {
  416. throw new Error(
  417. `missing producer archive SHA-256 for ${buildPlan.platformKey}/${releaseFileName}`,
  418. );
  419. }
  420. return {
  421. toolId,
  422. version: NATIVE_SEARCH_TOOL_VERSIONS[toolId],
  423. release,
  424. releaseFileName,
  425. archiveExt: archiveTarget.endsWith(".zip") ? "zip" : "tar.gz",
  426. archiveSha256,
  427. binaryName: `${NATIVE_SEARCH_BINARY_NAMES[toolId]}${buildPlan.platform === "win32" ? ".exe" : ""}`,
  428. binaryPath: buildPlan.binaries[toolId],
  429. ...(downloadBaseUrls
  430. ? { downloadUrl: `${downloadBaseUrls.producer}/${toolId}-${release}/${releaseFileName}` }
  431. : {}),
  432. archivePath: resolve(dependenciesDir, `${toolId}-${release}`, releaseFileName),
  433. source: "producer",
  434. };
  435. }),
  436. };
  437. }