From c0cd76d40e5ccd5104d30be7f310f0419d9180c1 Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Wed, 7 Aug 2024 11:46:05 +0200 Subject: [PATCH] Debug log for proxy config --- src/bin/shared/buildContext.ts | 4 ++++ src/bin/tools/fetchProxyOptions.ts | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/bin/shared/buildContext.ts b/src/bin/shared/buildContext.ts index d5811e75..88a2760f 100644 --- a/src/bin/shared/buildContext.ts +++ b/src/bin/shared/buildContext.ts @@ -670,6 +670,10 @@ export function getBuildContext(params: { throw error; } + console.log( + `The root of the NPM project should be "${pathRelative(process.cwd(), dirPath) || "."}"` + ); + return dirPath; })(0) }), diff --git a/src/bin/tools/fetchProxyOptions.ts b/src/bin/tools/fetchProxyOptions.ts index c4e0d90c..e9767f5c 100644 --- a/src/bin/tools/fetchProxyOptions.ts +++ b/src/bin/tools/fetchProxyOptions.ts @@ -19,6 +19,9 @@ export function getProxyFetchOptions(params: { }) .toString("utf8"); + console.log("Output of `npm config get`:"); + console.log(output); + return output .split("\n") .filter(line => !line.startsWith(";")) @@ -36,18 +39,35 @@ export function getProxyFetchOptions(params: { ); })(); + console.log("npm config get object"); + console.log(cfg); + const proxy = ensureSingleOrNone(cfg["https-proxy"] ?? cfg["proxy"]); + + console.log("proxy", proxy); + const noProxy = cfg["noproxy"] ?? cfg["no-proxy"]; + console.log("noProxy", noProxy); + function maybeBoolean(arg0: string | undefined) { return typeof arg0 === "undefined" ? undefined : Boolean(arg0); } const strictSSL = maybeBoolean(ensureSingleOrNone(cfg["strict-ssl"])); + + console.log("strictSSL", strictSSL); + const cert = cfg["cert"]; + + console.log("cert", cert); const ca = ensureArray(cfg["ca"] ?? cfg["ca[]"]); + + console.log("ca", ca); const cafile = ensureSingleOrNone(cfg["cafile"]); + console.log("cafile", cafile); + if (typeof cafile !== "undefined" && cafile !== "null") { ca.push( ...(() => { @@ -72,13 +92,17 @@ export function getProxyFetchOptions(params: { ); } - return { + const out = { proxy, noProxy, strictSSL, cert, ca: ca.length === 0 ? undefined : ca }; + + console.log("Final proxy options", out); + + return out; } function ensureArray(arg0: T | T[]) {