From 47b92e4dfe5708cc242f9f15a12d9804e8f43052 Mon Sep 17 00:00:00 2001 From: kevin mudrick Date: Tue, 16 Apr 2024 11:45:56 -0700 Subject: [PATCH] Support http_proxy, https_proxy in gulp git tasks (#1158) Co-authored-by: Damian Reeves <957246+DamianReeves@users.noreply.github.com> --- gulpfile.js | 13 +++++- package-lock.json | 101 ++++++++++++++++++++++++++++++---------------- package.json | 3 +- 3 files changed, 81 insertions(+), 36 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 30a453506..c54e320ef 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,8 @@ const util = require('util') const fs = require('fs') const tmp = require('tmp') const git = require('isomorphic-git') -const http = require('isomorphic-git/http/node') +const { request: delegate } = require('isomorphic-git/http/node') +const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent') const del = require('del') const elmMake = require('node-elm-compiler').compile const execa = require('execa'); @@ -18,6 +19,16 @@ const mainTsProject = ts.createProject('./tsconfig.json') const cliTsProject = ts.createProject('./cli2/tsconfig.json') const readFile = util.promisify(fs.readFile) +async function request ({ url, method, headers, body }) { + const proxy = url.startsWith('https:') + ? { Agent: HttpsProxyAgent, url: process.env.https_proxy } + : { Agent: HttpProxyAgent, url: process.env.http_proxy } + const agent = proxy.url ? new proxy.Agent({ proxy: proxy.url }) : undefined + return delegate({ url, method, agent, headers, body }) + } + +const http = { request }; + const config = { morphirJvmVersion: '0.18.2', morphirJvmCloneDir: tmp.dirSync() diff --git a/package-lock.json b/package-lock.json index 5c714c02a..9083643b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,8 @@ "gulp-concat": "^2.6.1", "gulp-mocha": "^8.0.0", "gulp-typescript": "^6.0.0-alpha.1", - "isomorphic-git": "^1.8.1", + "hpagent": "^1.2.0", + "isomorphic-git": "^1.25.7", "jest": "^27.5.1", "json-schema": "^0.4.0", "mocha": "^9.1.3", @@ -6310,6 +6311,15 @@ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, + "node_modules/hpagent": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hpagent/-/hpagent-1.2.0.tgz", + "integrity": "sha512-A91dYTeIB6NoXG+PxTQpCCDDnfHsW9kc06Lvpu1TEe9gnd6ZFeiBoRO9JvzEv6xK7EX97/dUE8g/vBMTqTS3CA==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", @@ -6979,9 +6989,9 @@ } }, "node_modules/isomorphic-git": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.8.2.tgz", - "integrity": "sha512-wp3on2Kks1sE/tLUmGLPV7EEAj+JRK8WoL2ZSfJHVQfWzRqMRv96bqzDjyYpC6COGKlDQnhTNCucRf83S3cuMw==", + "version": "1.25.7", + "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.25.7.tgz", + "integrity": "sha512-KE10ejaIsEpQ+I/apS33qqTjyzCXgOniEaL32DwNbXtboKG8H3cu+RiBcdp3G9w4MpOOTQfGPsWp4i8UxRfDLg==", "dev": true, "dependencies": { "async-lock": "^1.1.0", @@ -6994,13 +7004,13 @@ "pify": "^4.0.1", "readable-stream": "^3.4.0", "sha.js": "^2.4.9", - "simple-get": "^3.0.2" + "simple-get": "^4.0.1" }, "bin": { "isogit": "cli.cjs" }, "engines": { - "node": ">=10" + "node": ">=12" } }, "node_modules/isomorphic-git/node_modules/pify": { @@ -10896,35 +10906,52 @@ ] }, "node_modules/simple-get": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz", - "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], "dependencies": { - "decompress-response": "^4.2.0", + "decompress-response": "^6.0.0", "once": "^1.3.1", "simple-concat": "^1.0.0" } }, "node_modules/simple-get/node_modules/decompress-response": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", - "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", "dev": true, "dependencies": { - "mimic-response": "^2.0.0" + "mimic-response": "^3.1.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/simple-get/node_modules/mimic-response": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", - "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", "dev": true, "engines": { - "node": ">=8" + "node": ">=10" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -17814,6 +17841,12 @@ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, + "hpagent": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/hpagent/-/hpagent-1.2.0.tgz", + "integrity": "sha512-A91dYTeIB6NoXG+PxTQpCCDDnfHsW9kc06Lvpu1TEe9gnd6ZFeiBoRO9JvzEv6xK7EX97/dUE8g/vBMTqTS3CA==", + "dev": true + }, "html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", @@ -18316,9 +18349,9 @@ "dev": true }, "isomorphic-git": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.8.2.tgz", - "integrity": "sha512-wp3on2Kks1sE/tLUmGLPV7EEAj+JRK8WoL2ZSfJHVQfWzRqMRv96bqzDjyYpC6COGKlDQnhTNCucRf83S3cuMw==", + "version": "1.25.7", + "resolved": "https://registry.npmjs.org/isomorphic-git/-/isomorphic-git-1.25.7.tgz", + "integrity": "sha512-KE10ejaIsEpQ+I/apS33qqTjyzCXgOniEaL32DwNbXtboKG8H3cu+RiBcdp3G9w4MpOOTQfGPsWp4i8UxRfDLg==", "dev": true, "requires": { "async-lock": "^1.1.0", @@ -18331,7 +18364,7 @@ "pify": "^4.0.1", "readable-stream": "^3.4.0", "sha.js": "^2.4.9", - "simple-get": "^3.0.2" + "simple-get": "^4.0.1" }, "dependencies": { "pify": { @@ -21356,29 +21389,29 @@ "dev": true }, "simple-get": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz", - "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", + "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", "dev": true, "requires": { - "decompress-response": "^4.2.0", + "decompress-response": "^6.0.0", "once": "^1.3.1", "simple-concat": "^1.0.0" }, "dependencies": { "decompress-response": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", - "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", + "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", "dev": true, "requires": { - "mimic-response": "^2.0.0" + "mimic-response": "^3.1.0" } }, "mimic-response": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", - "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", + "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", "dev": true } } diff --git a/package.json b/package.json index 4076a1bb8..ad7c37dac 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,8 @@ "gulp-concat": "^2.6.1", "gulp-mocha": "^8.0.0", "gulp-typescript": "^6.0.0-alpha.1", - "isomorphic-git": "^1.8.1", + "hpagent": "^1.2.0", + "isomorphic-git": "^1.25.7", "jest": "^27.5.1", "json-schema": "^0.4.0", "mocha": "^9.1.3",