Skip to content

Commit bb53425

Browse files
authored
Proxy support added via global agent (#76)
1 parent bbd5b8d commit bb53425

File tree

7 files changed

+301
-146
lines changed

7 files changed

+301
-146
lines changed

.changeset/tame-crews-trade.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-llama": patch
3+
---
4+
5+
Support HTTP proxies by setting the GLOBAL_AGENT_HTTP_PROXY env variable

helpers/proxy.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* Function to conditionally load the global-agent/bootstrap module */
2+
export async function initializeGlobalAgent() {
3+
if (process.env.GLOBAL_AGENT_HTTP_PROXY) {
4+
/* Dynamically import global-agent/bootstrap */
5+
await import("global-agent/bootstrap");
6+
console.log("Proxy enabled via global-agent.");
7+
} else {
8+
console.log("No proxy configuration found. Continuing without proxy.");
9+
}
10+
}

index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ import { createApp } from "./create-app";
1212
import { getDataSources } from "./helpers/datasources";
1313
import { getPkgManager } from "./helpers/get-pkg-manager";
1414
import { isFolderEmpty } from "./helpers/is-folder-empty";
15+
import { initializeGlobalAgent } from "./helpers/proxy";
1516
import { runApp } from "./helpers/run-app";
1617
import { getTools } from "./helpers/tools";
1718
import { validateNpmName } from "./helpers/validate-pkg";
1819
import packageJson from "./package.json";
1920
import { QuestionArgs, askQuestions, onPromptState } from "./questions";
2021

22+
// Run the initialization function
23+
initializeGlobalAgent();
24+
2125
let projectPath: string = "";
2226

2327
const handleSigTerm = () => process.exit(0);

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"cross-spawn": "7.0.3",
5353
"fast-glob": "3.3.1",
5454
"fs-extra": "11.2.0",
55+
"global-agent": "^3.0.0",
5556
"got": "10.7.0",
5657
"ollama": "^0.5.0",
5758
"ora": "^8.0.1",
@@ -67,6 +68,7 @@
6768
"devDependencies": {
6869
"@changesets/cli": "^2.27.1",
6970
"@playwright/test": "^1.41.1",
71+
"@types/global-agent": "^2.1.3",
7072
"@vercel/ncc": "0.38.1",
7173
"eslint": "^8.56.0",
7274
"eslint-config-prettier": "^8.10.0",

0 commit comments

Comments
 (0)