@@ -16,43 +16,45 @@ type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
1616
1717const LOCAL_STORAGE_KEY = 'package-manager-copy-command'
1818
19- export function Command ( { name, highlight, framework = 'react' } : CommandCopyProps ) {
20- const [ value , setValue ] = useLocalStorage ( LOCAL_STORAGE_KEY , 'npm' )
19+ const getBaseUrl = ( ) => {
20+ if ( process . env . NEXT_PUBLIC_VERCEL_TARGET_ENV === 'production' ) {
21+ // we have a special alias for the production environment, added in https://github.com/shadcn-ui/ui/pull/8161
22+ return `@supabase`
23+ } else if ( process . env . NEXT_PUBLIC_VERCEL_TARGET_ENV === 'preview' ) {
24+ return `https://${ process . env . NEXT_PUBLIC_VERCEL_BRANCH_URL } `
25+ } else {
26+ return 'http://localhost:3004'
27+ }
28+ }
2129
22- const getBaseUrl = ( ) => {
23- if ( process . env . NEXT_PUBLIC_VERCEL_TARGET_ENV === 'production' ) {
24- return `https://supabase.com`
25- } else if ( process . env . NEXT_PUBLIC_VERCEL_TARGET_ENV === 'preview' ) {
26- return `https://${ process . env . NEXT_PUBLIC_VERCEL_BRANCH_URL } `
27- } else {
28- return 'http://localhost:3004'
29- }
30+ const getComponentPath = ( name : string ) => {
31+ if ( process . env . NEXT_PUBLIC_VERCEL_TARGET_ENV === 'production' ) {
32+ return `/${ name } `
33+ } else {
34+ return `${ process . env . NEXT_PUBLIC_BASE_PATH ?? '' } /r/${ name } .json`
3035 }
36+ }
37+
38+ export function Command ( { name, highlight, framework = 'react' } : CommandCopyProps ) {
39+ const [ value , setValue ] = useLocalStorage ( LOCAL_STORAGE_KEY , 'npm' )
3140
3241 const baseUrl = getBaseUrl ( )
33- const componentPath = ` ${ process . env . NEXT_PUBLIC_BASE_PATH ?? '' } /r/ ${ name } .json`
42+ const componentPath = getComponentPath ( name )
3443
3544 const commands : Record < PackageManager , string > =
36- framework === 'react '
45+ framework === 'vue '
3746 ? {
47+ npm : `npx shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
48+ pnpm : `pnpm dlx shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
49+ yarn : `yarn dlx shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
50+ bun : `bunx --bun shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
51+ }
52+ : {
3853 npm : `npx shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
3954 pnpm : `pnpm dlx shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
4055 yarn : `yarn dlx shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
4156 bun : `bunx --bun shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
4257 }
43- : framework === 'vue'
44- ? {
45- npm : `npx shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
46- pnpm : `pnpm dlx shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
47- yarn : `yarn dlx shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
48- bun : `bunx --bun shadcn-vue@latest add ${ baseUrl } ${ componentPath } ` ,
49- }
50- : {
51- npm : `npx shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
52- pnpm : `pnpm dlx shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
53- yarn : `yarn dlx shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
54- bun : `bunx --bun shadcn@latest add ${ baseUrl } ${ componentPath } ` ,
55- }
5658
5759 return (
5860 < Tabs_Shadcn_ value = { value } onValueChange = { setValue } className = "w-full" >
0 commit comments