export function getReleaseVersion(packageJson) {
  return packageJson.version;
}

export function getReleaseArch(platformArch = process.arch) {
  if (platformArch === "arm64" || platformArch === "aarch64") {
    return "arm64";
  }
  if (platformArch === "x64" || platformArch === "amd64") {
    return "x64";
  }
  return platformArch;
}

export function isBundleCefEnabled(
  value = process.env.ELECTROBUN_BUNDLE_CEF,
) {
  return ["1", "true", "yes"].includes(String(value || "").toLowerCase());
}

export function getReleaseArtifactName(version, arch, ext, options = {}) {
  const cef =
    typeof options === "boolean"
      ? options
      : Boolean(options.cef ?? isBundleCefEnabled());
  const cefSuffix = cef ? "-cef" : "";
  return `farmcontrol-${version}-${arch}${cefSuffix}.${ext}`;
}
