11import { ofetch } from "ofetch" ;
22import { to } from "./index" ;
33import { detectPackageManager } from "./vscode" ;
4- import { getSvelteVersion } from "./getSvelteVersion" ;
54
65type OgComponent = {
7- type : "components :ui" ;
6+ type : "registry :ui" ;
87 name : string ;
98 files : string [ ] ;
109 dependencies ?: string [ ] ;
@@ -19,8 +18,7 @@ export type Component = {
1918export type Components = Component [ ] ;
2019
2120export const getRegistry = async ( ) : Promise < Components | null > => {
22- const svelteVersion = await getSvelteVersion ( ) ;
23- const reqUrl = svelteVersion >= 5 ? "https://next.shadcn-svelte.com/registry/index.json" : "https://shadcn-svelte.com/registry/index.json" ;
21+ const reqUrl = "https://shadcn-svelte.com/registry/index.json" ;
2422 const [ res , err ] = await to ( ofetch ( reqUrl ) ) ;
2523
2624 if ( err || ! res ) {
@@ -33,51 +31,47 @@ export const getRegistry = async (): Promise<Components | null> => {
3331 return null ;
3432 }
3533
36- const components : Components = ( data as OgComponent [ ] ) . map ( ( c ) => {
34+ const components : Components = ( data as OgComponent [ ] ) . filter ( ( c ) => c . type === 'registry:ui' ) . map ( ( c ) => {
3735 const component : Component = {
3836 label : c . name ,
39- detail : `dependencies: ${ c . dependencies && c . dependencies . length > 0 ? c . dependencies . join ( " " ) : "no dependency" } ` ,
37+ detail : `dependencies: ${ c . registryDependencies && c . registryDependencies . length > 0 ? c . registryDependencies . join ( ", " ) : "no dependency" } ` ,
4038 } ;
4139
4240 return component ;
4341 } ) ;
44-
4542 return components ;
4643} ;
4744
4845export const getInstallCmd = async ( components : string [ ] , cwd : string ) => {
4946 const packageManager = await detectPackageManager ( ) ;
5047 const componentStr = components . join ( " " ) ;
51- const svelteVersion = await getSvelteVersion ( ) ;
5248
5349 if ( packageManager === "bun" ) {
54- return svelteVersion >= 5 ? `bunx shadcn-svelte@next add ${ componentStr } -c ${ cwd } ` : `bunx shadcn-svelte add ${ componentStr } -c ${ cwd } `;
50+ return `bunx shadcn-svelte@latest add ${ componentStr } -c ${ cwd } ` ;
5551 }
5652
5753 if ( packageManager === "pnpm" ) {
58- return svelteVersion >= 5 ? `pnpm dlx shadcn-svelte@next add ${ componentStr } -c ${ cwd } ` : `pnpm dlx shadcn-svelte@latest add ${ componentStr } -c ${ cwd } ` ;
54+ return `pnpm dlx shadcn-svelte@latest add ${ componentStr } -c ${ cwd } ` ;
5955 }
6056
61- return svelteVersion >= 5 ? `npx shadcn-svelte@next add ${ componentStr } -c ${ cwd } ` : `npx shadcn-svelte@latest add ${ componentStr } -c ${ cwd } ` ;
57+ return `npx shadcn-svelte@latest add ${ componentStr } -c ${ cwd } ` ;
6258} ;
6359
6460export const getInitCmd = async ( cwd : string ) => {
6561 const packageManager = await detectPackageManager ( ) ;
66- const svelteVersion = await getSvelteVersion ( ) ;
6762
6863 if ( packageManager === "bun" ) {
69- return svelteVersion >= 5 ? `bunx shadcn-svelte@next init -c ${ cwd } ` : `bunx shadcn-svelte init -c ${ cwd } `;
64+ return `bunx shadcn-svelte@latest init -c ${ cwd } ` ;
7065 }
7166
7267 if ( packageManager === "pnpm" ) {
73- return svelteVersion >= 5 ? `pnpm dlx shadcn-svelte@next init -c ${ cwd } ` : `pnpm dlx shadcn-svelte@latest init -c ${ cwd } ` ;
68+ return `pnpm dlx shadcn-svelte@latest init -c ${ cwd } ` ;
7469 }
7570
76- return svelteVersion >= 5 ? `npx shadcn-svelte@next init -c ${ cwd } ` : `npx shadcn-svelte@latest init -c ${ cwd } ` ;
71+ return `npx shadcn-svelte@latest init -c ${ cwd } ` ;
7772} ;
7873
7974export const getComponentDocLink = async ( component : string ) => {
80- const svelteVersion = await getSvelteVersion ( ) ;
81- const shadCnDocUrl = svelteVersion >= 5 ? "https://next.shadcn-svelte.com/docs" : "https://shadcn-svelte.com/docs" ;
75+ const shadCnDocUrl = "https://shadcn-svelte.com/docs" ;
8276 return `${ shadCnDocUrl } /components/${ component } ` ;
8377} ;
0 commit comments