feat: add proxy support for ripgrep download

This commit is contained in:
dipfocus 2025-06-13 09:23:54 +08:00
parent 895139443d
commit d42c050e36
3 changed files with 23 additions and 3 deletions

View File

@ -20,6 +20,7 @@
"posthog-node": "^3.6.3", "posthog-node": "^3.6.3",
"system-ca": "^1.0.2", "system-ca": "^1.0.2",
"tar": "^7.4.3", "tar": "^7.4.3",
"undici": "^7.10.0",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"vectordb": "^0.4.20", "vectordb": "^0.4.20",
"win-ca": "^3.5.1" "win-ca": "^3.5.1"
@ -52,9 +53,9 @@
"@aws-sdk/credential-providers": "^3.778.0", "@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13", "@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "file:../packages/config-yaml", "@continuedev/config-yaml": "file:../packages/config-yaml",
"@continuedev/fetch": "^1.0.10", "@continuedev/fetch": "^1.0.13",
"@continuedev/llm-info": "^1.0.8", "@continuedev/llm-info": "^1.0.8",
"@continuedev/openai-adapters": "^1.0.25", "@continuedev/openai-adapters": "^1.0.32",
"@modelcontextprotocol/sdk": "^1.12.0", "@modelcontextprotocol/sdk": "^1.12.0",
"@mozilla/readability": "^0.5.0", "@mozilla/readability": "^0.5.0",
"@octokit/rest": "^20.1.1", "@octokit/rest": "^20.1.1",
@ -105,6 +106,7 @@
"sqlite3": "^5.1.7", "sqlite3": "^5.1.7",
"system-ca": "^1.0.3", "system-ca": "^1.0.3",
"tar": "^7.4.3", "tar": "^7.4.3",
"tree-sitter-structured-text": "^0.0.1",
"tree-sitter-wasms": "^0.1.11", "tree-sitter-wasms": "^0.1.11",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"vectordb": "^0.4.20", "vectordb": "^0.4.20",
@ -143,8 +145,10 @@
"myers-diff": "^2.1.0", "myers-diff": "^2.1.0",
"onnxruntime-common": "1.14.0", "onnxruntime-common": "1.14.0",
"onnxruntime-web": "1.14.0", "onnxruntime-web": "1.14.0",
"tree-sitter-cli": "^0.22.5",
"ts-jest": "^29.1.1", "ts-jest": "^29.1.1",
"typescript": "^5.6.3" "typescript": "^5.6.3",
"vitest": "^3.1.4"
}, },
"engines": { "engines": {
"node": ">=20.19.0" "node": ">=20.19.0"
@ -6773,6 +6777,15 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/undici": {
"version": "7.10.0",
"resolved": "https://registry.npmmirror.com/undici/-/undici-7.10.0.tgz",
"integrity": "sha512-u5otvFBOBZvmdjWLVW+5DAc9Nkq8f24g0O9oY7qw2JVIF1VocIFoyz9JFkuVOS2j41AufeO0xnlweJ2RLT8nGw==",
"license": "MIT",
"engines": {
"node": ">=20.18.1"
}
},
"node_modules/universal-user-agent": { "node_modules/universal-user-agent": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz",

View File

@ -53,6 +53,7 @@
"posthog-node": "^3.6.3", "posthog-node": "^3.6.3",
"system-ca": "^1.0.2", "system-ca": "^1.0.2",
"tar": "^7.4.3", "tar": "^7.4.3",
"undici": "^7.10.0",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"vectordb": "^0.4.20", "vectordb": "^0.4.20",
"win-ca": "^3.5.1" "win-ca": "^3.5.1"

View File

@ -4,6 +4,7 @@ const { rimrafSync } = require("rimraf");
const tar = require("tar"); const tar = require("tar");
const { RIPGREP_VERSION, TARGET_TO_RIPGREP_RELEASE } = require("./targets"); const { RIPGREP_VERSION, TARGET_TO_RIPGREP_RELEASE } = require("./targets");
const AdmZip = require("adm-zip"); const AdmZip = require("adm-zip");
const { ProxyAgent } = require('undici');
const RIPGREP_BASE_URL = `https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}`; const RIPGREP_BASE_URL = `https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}`;
@ -16,8 +17,13 @@ const RIPGREP_BASE_URL = `https://github.com/BurntSushi/ripgrep/releases/downloa
*/ */
async function downloadFile(url, destPath) { async function downloadFile(url, destPath) {
// Use the built-in fetch API instead of node-fetch // Use the built-in fetch API instead of node-fetch
// Use proxy if set in environment variables
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY;
const agent = proxy ? new ProxyAgent(proxy) : undefined;
const response = await fetch(url, { const response = await fetch(url, {
redirect: "follow", // Automatically follow redirects redirect: "follow", // Automatically follow redirects
dispatcher: agent,
}); });
if (!response.ok) { if (!response.ok) {