Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add proxy configuration #423

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Prev Previous commit
Next Next commit
πŸ”§ (.dockerignore): add node_modules to .dockerignore file to exclude …
…it from Docker build

⬆️ (package.json): upgrade version from 3.2.2 to 3.2.3 in package.json
♻️ (httpAgent.ts): refactor code in getHttpAgent function to improve readability and maintainability
  • Loading branch information
ByJacob committed Oct 17, 2024
commit 7aba1c22d421110199af1af7ff48b2b735843a6a
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
node_modules
3 changes: 0 additions & 3 deletions out/cli.cjs
Original file line number Diff line number Diff line change
@@ -39543,8 +39543,6 @@ function getHttpAgent(url_) {
}
const ca = Array.from(/* @__PURE__ */ new Set([...import_node_tls.default.rootCertificates, ...globalCerts]));
const customCerts = config7.OCO_HTTP_CA_BUNDLE;
console.error(customCerts);
console.error("AAAA");
if (isDefinedAndNotEmpty(customCerts)) {
ca.push(
...customCerts.split(",").map((customCert) => fs2.readFileSync(customCert, "utf8"))
@@ -39559,7 +39557,6 @@ function getHttpAgent(url_) {
keepAlive: true,
keepAliveMsecs: timeout
};
console.log(config7);
if (isDefinedAndNotEmpty(config7.OCO_HTTP_CLIENT_CERTIFICATE_CERT) && isDefinedAndNotEmpty(config7.OCO_HTTP_CLIENT_CERTIFICATE_KEY)) {
agentOptions.cert = fs2.readFileSync(
config7.OCO_HTTP_CLIENT_CERTIFICATE_CERT,
3 changes: 0 additions & 3 deletions out/github-action.cjs
Original file line number Diff line number Diff line change
@@ -58341,8 +58341,6 @@ function getHttpAgent(url_) {
}
const ca = Array.from(/* @__PURE__ */ new Set([...import_node_tls.default.rootCertificates, ...globalCerts]));
const customCerts = config6.OCO_HTTP_CA_BUNDLE;
console.error(customCerts);
console.error("AAAA");
if (isDefinedAndNotEmpty(customCerts)) {
ca.push(
...customCerts.split(",").map((customCert) => fs2.readFileSync(customCert, "utf8"))
@@ -58357,7 +58355,6 @@ function getHttpAgent(url_) {
keepAlive: true,
keepAliveMsecs: timeout
};
console.log(config6);
if (isDefinedAndNotEmpty(config6.OCO_HTTP_CLIENT_CERTIFICATE_CERT) && isDefinedAndNotEmpty(config6.OCO_HTTP_CLIENT_CERTIFICATE_KEY)) {
agentOptions.cert = fs2.readFileSync(
config6.OCO_HTTP_CLIENT_CERTIFICATE_CERT,
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opencommit",
"version": "3.2.2",
"version": "3.2.3",
"description": "Auto-generate impressive commits in 1 second. Killing lame commits with AI πŸ€―πŸ”«",
"keywords": [
"git",
15 changes: 8 additions & 7 deletions src/utils/httpAgent.ts
Original file line number Diff line number Diff line change
@@ -36,7 +36,9 @@ export function getHttpAgent(url_: URL | string): Agent {
const customCerts = config.OCO_HTTP_CA_BUNDLE;
if (isDefinedAndNotEmpty(customCerts)) {
ca.push(
...customCerts.split(",").map((customCert) => fs.readFileSync(customCert, 'utf8'))
...customCerts
.split(',')
.map((customCert) => fs.readFileSync(customCert, 'utf8'))
);
}

@@ -73,12 +75,11 @@ export function getHttpAgent(url_: URL | string): Agent {
const proxy = config.OCO_HTTP_PROXY;
// Create agent
const protocol = url.protocol === 'https:' ? https : http;
const agent =
isDefinedAndNotEmpty(proxy)
? protocol === https
? new HttpsProxyAgent(proxy, agentOptions)
: new HttpProxyAgent(proxy, agentOptions)
: new protocol.Agent(agentOptions);
const agent = isDefinedAndNotEmpty(proxy)
? protocol === https
? new HttpsProxyAgent(proxy, agentOptions)
: new HttpProxyAgent(proxy, agentOptions)
: new protocol.Agent(agentOptions);

return agent;
}
Loading
Oops, something went wrong.