Skip to content

fix: update component URL fetching logic #18

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

Merged
merged 1 commit into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
possibilityUtilsPath,
} from "@/utils/helpers"
import { error, grayText, highlight, info } from "@/utils/logging"
import { getRepoUrlForComponent } from "@/utils/repo"
import { getPrimitiveComponentUrl } from "@/utils/repo"
import ora from "ora"
import stripJsonComments from "strip-json-comments"

Expand Down Expand Up @@ -302,7 +302,7 @@ export async function init(flags: {
})
})

const fileUrl = getRepoUrlForComponent("primitive", "intentui")
const fileUrl = getPrimitiveComponentUrl()
const response = await fetch(fileUrl)

if (!response.ok) throw new Error(`Failed to fetch component: ${response.statusText}`)
Expand Down
9 changes: 9 additions & 0 deletions src/utils/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ export const getThemesRepoUrl = (gray: string): string => {
return selectedGray
}

/**
* This function is used to get the URL for the primitive.tsx component
* @returns string
*/
export const getPrimitiveComponentUrl = () => {
if(branchWorkingOn === "1.x") return getRepoUrlForComponent("primitive", "intentui")
return `${REPO}/${BRANCH}/lib/primitive.tsx`
}

/**
* This function is used to get the URL for a component
* @param componentName string
Expand Down