remote-native-search-tools-config.mjs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { resolve } from "node:path";
  2. import process from "node:process";
  3. import {
  4. LEGACY_REMOTE_RIPGREP_ARCHIVE_SHA256_BY_TARGET,
  5. LEGACY_REMOTE_RIPGREP_VERSION,
  6. NATIVE_SEARCH_DEPENDENCIES_DIR,
  7. resolveNativeSearchBuildPlan,
  8. resolveNativeSearchPrebuiltPlan,
  9. } from "./native-search-tools-config.mjs";
  10. // legacy rg13 的版本与摘要仍由 native-search-tools-config.mjs 唯一持有(内网 download-ripgrep 链路同样读取),
  11. // 这里只转出,避免两份常量漂移。
  12. export { LEGACY_REMOTE_RIPGREP_ARCHIVE_SHA256_BY_TARGET, LEGACY_REMOTE_RIPGREP_VERSION };
  13. export function resolveRemoteNativeSearchPrebuiltPlan({
  14. platform = process.platform,
  15. arch = process.arch,
  16. outputDir,
  17. dependenciesDir = NATIVE_SEARCH_DEPENDENCIES_DIR,
  18. } = {}) {
  19. const buildPlan = resolveNativeSearchBuildPlan({ platform, arch, outputDir });
  20. if (buildPlan.platform === "linux") {
  21. return resolveNativeSearchPrebuiltPlan({ platform, arch, outputDir, dependenciesDir });
  22. }
  23. if (buildPlan.platform !== "darwin") {
  24. throw new Error(`unsupported remote native search target ${buildPlan.platformKey}`);
  25. }
  26. // macOS remote retains rg13; Desktop and SEA use the default rg14 plan.
  27. const release = LEGACY_REMOTE_RIPGREP_VERSION;
  28. const archiveTarget = `${buildPlan.arch === "arm64" ? "aarch64" : "x86_64"}-apple-darwin.tar.gz`;
  29. const releaseFileName = `ripgrep-${release}-${archiveTarget}`;
  30. return {
  31. platform: buildPlan.platform,
  32. arch: buildPlan.arch,
  33. platformKey: buildPlan.platformKey,
  34. outputDir: buildPlan.outputDir,
  35. runtimeToolIds: ["ripgrep"],
  36. producerOutputIds: [],
  37. binaries: { ripgrep: buildPlan.rgPath },
  38. rgPath: buildPlan.rgPath,
  39. artifacts: [
  40. {
  41. toolId: "ripgrep",
  42. version: "13.0.0",
  43. release,
  44. releaseFileName,
  45. archiveExt: "tar.gz",
  46. archiveSha256: LEGACY_REMOTE_RIPGREP_ARCHIVE_SHA256_BY_TARGET[buildPlan.platformKey],
  47. binaryName: "rg",
  48. binaryPath: buildPlan.rgPath,
  49. archivePath: resolve(dependenciesDir, `ripgrep-${release}`, releaseFileName),
  50. source: "official",
  51. },
  52. ],
  53. };
  54. }