Skip to content

Commit b3d646a

Browse files
committed
Updated deps and introduced a proxy
1 parent f956e1b commit b3d646a

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

.goreleaser.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ builds:
1313
goarch:
1414
- amd64
1515
- arm64
16-
ignore:
17-
- goos: windows
18-
goarch: arm64
16+
- "386"
1917
archives:
2018
- name_template: >-
2119
{{ .ProjectName }}_

npm-install/postinstall.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
import { createWriteStream } from "fs";
22
import * as fs from "fs/promises";
33
import fetch from "node-fetch";
4+
import { HttpsProxyAgent } from "https-proxy-agent";
45
import { pipeline } from "stream/promises";
5-
import tar from "tar";
6+
import * as tar from "tar";
67
import { execSync } from "child_process";
78

89
import { ARCH_MAPPING, CONFIG, PLATFORM_MAPPING } from "./config.js";
910

11+
// Get proxy URL from environment variables (standard convention)
12+
function getProxyUrl() {
13+
return process.env.HTTPS_PROXY ||
14+
process.env.https_proxy ||
15+
process.env.HTTP_PROXY ||
16+
process.env.http_proxy ||
17+
null;
18+
}
19+
1020
async function install() {
1121
if (process.platform === "android") {
1222
console.log("Installing, may take a moment...");
@@ -32,9 +42,16 @@ async function install() {
3242
url = url.replace(/{{version}}/g, version);
3343
url = url.replace(/{{bin_name}}/g, binName);
3444

45+
// Configure fetch options with proxy support
46+
const fetchOptions = {};
47+
const proxyUrl = getProxyUrl();
48+
if (proxyUrl) {
49+
console.log('Using proxy:', proxyUrl);
50+
fetchOptions.agent = new HttpsProxyAgent(proxyUrl);
51+
}
3552

3653
console.log('fetching from URL', url)
37-
const response = await fetch(url);
54+
const response = await fetch(url, fetchOptions);
3855
if (!response.ok) {
3956
throw new Error("Failed fetching the binary: " + response.statusText);
4057
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
"npm-install"
2424
],
2525
"dependencies": {
26-
"adm-zip": "^0.5.10",
27-
"node-fetch": "^3.2.10",
28-
"tar": "^6.1.11"
26+
"https-proxy-agent": "^7.0.6",
27+
"node-fetch": "^3.3.2",
28+
"tar": "^7.5.11"
2929
},
3030
"bugs": {
3131
"url": "https://github.com/pb33f/openapi-changes/issues"

0 commit comments

Comments
 (0)