mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-07 11:26:41 +00:00
Use types for global-agent and global-tunnel-ng
Change-type: patch
This commit is contained in:
parent
3f6d770233
commit
00943463a4
@ -78,14 +78,7 @@ function checkNodeVersion() {
|
||||
}
|
||||
}
|
||||
|
||||
export interface GlobalTunnelNgConfig {
|
||||
host: string;
|
||||
port: number;
|
||||
protocol: string;
|
||||
proxyAuth?: string;
|
||||
connect?: string;
|
||||
sockets?: number;
|
||||
}
|
||||
export type GlobalTunnelNgConfig = import('global-tunnel-ng').Options;
|
||||
|
||||
type ProxyConfig = string | GlobalTunnelNgConfig;
|
||||
|
||||
@ -129,7 +122,7 @@ async function setupGlobalHttpProxy(settings: CliSettings) {
|
||||
if (proxy || env.HTTPS_PROXY || env.HTTP_PROXY) {
|
||||
const semver = await import('semver');
|
||||
if (semver.lt(process.version, '10.16.0')) {
|
||||
setupGlobalTunnelNgProxy(proxy);
|
||||
await setupGlobalTunnelNgProxy(proxy);
|
||||
} else {
|
||||
// use global-agent instead of global-tunnel-ng
|
||||
await setupGlobalAgentProxy(settings, proxy);
|
||||
@ -141,8 +134,8 @@ async function setupGlobalHttpProxy(settings: CliSettings) {
|
||||
* `global-tunnel-ng` proxy setup.
|
||||
* See docs for setupGlobalHttpProxy() above.
|
||||
*/
|
||||
function setupGlobalTunnelNgProxy(proxy?: ProxyConfig) {
|
||||
const globalTunnel = require('global-tunnel-ng');
|
||||
async function setupGlobalTunnelNgProxy(proxy?: ProxyConfig) {
|
||||
const globalTunnel = await import('global-tunnel-ng');
|
||||
// Init the tunnel even if BALENARC_PROXY is not defined, because
|
||||
// other env vars may be defined. If no proxy configuration exists,
|
||||
// initialize() does nothing.
|
||||
@ -183,7 +176,7 @@ async function setupGlobalAgentProxy(
|
||||
].join(',');
|
||||
}
|
||||
|
||||
const { bootstrap } = require('global-agent');
|
||||
const { bootstrap } = await import('global-agent');
|
||||
bootstrap();
|
||||
}
|
||||
|
||||
|
12
npm-shrinkwrap.json
generated
12
npm-shrinkwrap.json
generated
@ -745,6 +745,18 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/global-agent": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/global-agent/-/global-agent-2.1.0.tgz",
|
||||
"integrity": "sha512-xBOerse4Agekl7VZJclA9bfuA9aa3u9T24TDkBiMQrZgu4qe5HMBPzVGzAt2k4dx/v3uIFI6CzG0Z9X894LHrg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/global-tunnel-ng": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/global-tunnel-ng/-/global-tunnel-ng-2.1.0.tgz",
|
||||
"integrity": "sha512-JPhCJHHu5/5HuQ78rmbrnCk+XlyxKuAopk+/8rP5MfAeL7KwiCH/gFFNtAqIr0/JFqWFk+jXWZjEWSP8dzGpMg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/intercept-stdout": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/intercept-stdout/-/intercept-stdout-0.1.0.tgz",
|
||||
|
@ -108,6 +108,8 @@
|
||||
"@types/ejs": "^3.0.1",
|
||||
"@types/express": "^4.17.2",
|
||||
"@types/fs-extra": "^8.1.0",
|
||||
"@types/global-agent": "^2.1.0",
|
||||
"@types/global-tunnel-ng": "^2.1.0",
|
||||
"@types/intercept-stdout": "^0.1.0",
|
||||
"@types/is-root": "^2.1.2",
|
||||
"@types/lodash": "^4.14.149",
|
||||
|
Loading…
x
Reference in New Issue
Block a user