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AAQ,mBAAoB,IAC5E,OAAO,GAAG,EAAyB,EACvC","file":"/npm/gh-release-fetch@4.0.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/gh-release-fetch@4.0.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { promises as fs } from 'fs';\n// @ts-expect-error this module does not have types itself, we need to use `download` types\nimport download from '@xhmikosr/downloader';\nimport fetch from 'node-fetch';\nimport { gt } from 'semver';\nconst versionPrefixRegex = /^v/;\nexport async function fetchLatest(release, fetchOptions) {\n    // eslint-disable-next-line no-param-reassign\n    release.version = await resolveRelease(release.repository, fetchOptions);\n    const agent = fetchOptions && fetchOptions.agent;\n    return fetchVersion(release, { agent });\n}\nexport async function fetchVersion(release, { agent } = {}) {\n    validateRelease(release);\n    await downloadFile(release, { agent });\n}\nexport async function updateAvailable(repository, currentVersion, fetchOptions) {\n    const latestVersion = await resolveRelease(repository, fetchOptions);\n    return newerVersion(latestVersion, currentVersion);\n}\nasync function resolveRelease(repository, fetchOptions) {\n    const res = await fetch(`https://api.github.com/repos/${repository}/releases/latest`, fetchOptions);\n    const json = (await res.json());\n    if (res.status === 403 && typeof json.message === 'string' && json.message.includes('API rate limit exceeded')) {\n        throw new Error('API rate limit exceeded, please try again later');\n    }\n    return json.tag_name;\n}\nasync function downloadFile(release, { agent }) {\n    const url = `https://github.com/${release.repository}/releases/download/${release.version}/${release.package}`;\n    await fs.mkdir(release.destination, { recursive: true });\n    await download(url, release.destination, {\n        extract: release.extract,\n        got: {\n            agent: { https: agent },\n        },\n    });\n}\nfunction validateRelease(release) {\n    if (!release.repository) {\n        throw new Error('Missing release repository');\n    }\n    if (!release.package) {\n        throw new Error('Missing release package name');\n    }\n    if (!release.destination) {\n        throw new Error('Missing release destination');\n    }\n    if (!release.version) {\n        throw new Error('Missing release version');\n    }\n}\nexport function newerVersion(latestVersion, currentVersion) {\n    if (!latestVersion) {\n        return false;\n    }\n    if (!currentVersion) {\n        return true;\n    }\n    const normalizedLatestVersion = latestVersion.replace(versionPrefixRegex, '');\n    const normalizedCurrentVersion = currentVersion.replace(versionPrefixRegex, '');\n    return gt(normalizedLatestVersion, normalizedCurrentVersion);\n}\n"]}