Skip to content

Commit

Permalink
Merge pull request #347 from chromaui/proxy-support
Browse files Browse the repository at this point in the history
Add support for proxy server
  • Loading branch information
ghengeveld committed May 21, 2021
2 parents ab2303a + 05b7120 commit 701f7c8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
15 changes: 15 additions & 0 deletions bin/io/setGlobalProxyAgent.js
@@ -0,0 +1,15 @@
import https from 'https';
import HttpsProxyAgent from 'https-proxy-agent';

const setGlobalProxyAgent = ({ log }) => {
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
const noProxy = process.env.NO_PROXY || process.env.no_proxy;

if ((httpsProxy || httpProxy) && !noProxy) {
https.globalAgent = new HttpsProxyAgent(httpsProxy || httpProxy);
log.info(`Using proxy server: ${httpsProxy || httpProxy}`);
}
};

export default setGlobalProxyAgent;
4 changes: 4 additions & 0 deletions bin/main.js
Expand Up @@ -4,6 +4,7 @@ import pkgUp from 'pkg-up';
import { v4 as uuid } from 'uuid';

import GraphQLClient from './io/GraphQLClient';
import setGlobalProxyAgent from './io/setGlobalProxyAgent';
import checkForUpdates from './lib/checkForUpdates';
import checkPackageJson from './lib/checkPackageJson';
import getEnv from './lib/getEnv';
Expand Down Expand Up @@ -37,6 +38,9 @@ export async function main(argv) {
}

export async function runAll(ctx) {
// Configure the proxy (if available) before we make any requests.
setGlobalProxyAgent(ctx);

// Run these in parallel; neither should ever reject
await Promise.all([runBuild(ctx), checkForUpdates(ctx)]);

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -80,6 +80,7 @@
"execa": "^5.0.0",
"fake-tag": "^2.0.0",
"fs-extra": "^9.1.0",
"https-proxy-agent": "^5.0.0",
"jsonfile": "^6.0.1",
"junit-report-builder": "2.1.0",
"listr": "0.14.3",
Expand Down
29 changes: 22 additions & 7 deletions yarn.lock
Expand Up @@ -3308,6 +3308,13 @@ address@1.1.2, address@^1.0.1:
resolved "https://registry.yarnpkg.com/address/-/address-1.1.2.tgz#bf1116c9c758c51b7a933d296b72c221ed9428b6"
integrity sha512-aT6camzM4xEA54YVJYSqxz1kv4IHnQZRtThJJHhUMRExaU5spC7jX5ugSwTaTgJliIgs4VhZOk7htClvQ/LmRA==

agent-base@6:
version "6.0.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==
dependencies:
debug "4"

aggregate-error@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a"
Expand Down Expand Up @@ -5222,20 +5229,20 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
dependencies:
ms "2.0.0"

debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee"
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==
dependencies:
ms "2.1.2"

debug@^3.0.0, debug@^3.0.1:
version "3.2.7"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a"
integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==
dependencies:
ms "^2.1.1"

debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0, debug@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee"
integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==
dependencies:
ms "2.1.2"

decamelize-keys@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9"
Expand Down Expand Up @@ -7255,6 +7262,14 @@ https-browserify@^1.0.0:
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=

https-proxy-agent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2"
integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==
dependencies:
agent-base "6"
debug "4"

human-signals@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3"
Expand Down

0 comments on commit 701f7c8

Please sign in to comment.