Skip to content

Commit

Permalink
build(cli): update proxy agent using undici agent to match ofetch req…
Browse files Browse the repository at this point in the history
…uirements (#934)
  • Loading branch information
ThomasLaSalmonie authored Dec 3, 2024
1 parent 6c0ab55 commit 5ada562
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 41 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"consola": "^3.2.3",
"diff": "^7.0.0",
"fs-extra": "^11.2.0",
"https-proxy-agent": "^7.0.5",
"lodash-es": "^4.17.21",
"magic-string": "^0.30.12",
"nypm": "^0.3.12",
Expand All @@ -69,6 +68,7 @@
"radix-vue": "catalog:",
"semver": "^7.6.3",
"tsconfig-paths": "^4.2.0",
"undici": "^7.0.0",
"vue-metamorph": "3.2.0",
"zod": "^3.23.8"
},
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/utils/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import {
stylesSchema,
} from '@/src/utils/registry/schema'
import consola from 'consola'
import { HttpsProxyAgent } from 'https-proxy-agent'
import { ofetch } from 'ofetch'
import path from 'pathe'
import { ProxyAgent } from 'undici'

const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? 'https://www.shadcn-vue.com'
const agent = process.env.https_proxy
? new HttpsProxyAgent(process.env.https_proxy)
? new ProxyAgent(process.env.https_proxy)
: undefined

export async function getRegistryIndex() {
Expand Down Expand Up @@ -144,8 +144,7 @@ async function fetchRegistry(paths: string[]) {
const results = await Promise.all(
paths.map(async (path) => {
const response = await ofetch(`${baseUrl}/registry/${path}`, {
// @ts-expect-error agent type
agent,
dispatcher: agent,
})

return response
Expand Down
57 changes: 21 additions & 36 deletions pnpm-lock.yaml

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

0 comments on commit 5ada562

Please sign in to comment.