From eeb895cbf5b211e620d6225be2326a99728096c5 Mon Sep 17 00:00:00 2001 From: Konstantin Burkalev Date: Thu, 26 Jun 2025 12:06:07 +0300 Subject: [PATCH] chore!(backend-shared): Remove deprecated npm proxy settings --- packages/cubejs-backend-shared/package.json | 1 - packages/cubejs-backend-shared/src/proxy.ts | 44 +-------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/packages/cubejs-backend-shared/package.json b/packages/cubejs-backend-shared/package.json index c88c50df890a7..4b9230075239d 100644 --- a/packages/cubejs-backend-shared/package.json +++ b/packages/cubejs-backend-shared/package.json @@ -42,7 +42,6 @@ "decompress": "^4.2.1", "env-var": "^6.3.0", "fs-extra": "^9.1.0", - "https-proxy-agent": "^7.0.6", "moment-range": "^4.0.2", "moment-timezone": "^0.5.47", "node-fetch": "^2.6.1", diff --git a/packages/cubejs-backend-shared/src/proxy.ts b/packages/cubejs-backend-shared/src/proxy.ts index 55ecf84e8cb3d..dfbf4a8b2f3e8 100644 --- a/packages/cubejs-backend-shared/src/proxy.ts +++ b/packages/cubejs-backend-shared/src/proxy.ts @@ -1,48 +1,8 @@ -import { exec } from 'child_process'; import { ProxyAgent } from 'proxy-agent'; -import { HttpsProxyAgent } from 'https-proxy-agent'; - -let npmProxy: string; -let npmProxyInitialized = false; - -function getCommandOutput(command: string) { - return new Promise((resolve, reject) => { - exec(command, (error, stdout) => { - if (error) { - reject(error.message); - return; - } - - resolve(stdout); - }); - }); -} - -/** - * @deprecated - * use ProxyAgent instead - */ -export async function getProxySettings(): Promise { - const [proxy] = ( - await Promise.all([getCommandOutput('npm config -g get https-proxy'), getCommandOutput('npm config -g get proxy')]) - ) - .map((s) => s.trim()) - .filter((s) => !['null', 'undefined', ''].includes(s)); - - npmProxyInitialized = true; - - return proxy; -} export async function getHttpAgentForProxySettings() { - if (!npmProxyInitialized) { - npmProxy = await getProxySettings(); + if (!process.env.HTTP_PROXY && !process.env.HTTPS_PROXY) { + return undefined; } - - if (npmProxy) { - console.warn('Npm proxy settings are deprecated. Please use HTTP_PROXY, HTTPS_PROXY environment variables instead.'); - return new HttpsProxyAgent(npmProxy); - } - return new ProxyAgent(); }