@@ -14,6 +14,21 @@ import { Command } from "commander"
1414import prompts from "prompts"
1515import { z } from "zod"
1616
17+ const DEPRECATED_COMPONENTS = [
18+ {
19+ name : "toast" ,
20+ deprecatedBy : "sonner" ,
21+ message :
22+ "The toast component is deprecated. Use the sonner component instead." ,
23+ } ,
24+ {
25+ name : "toaster" ,
26+ deprecatedBy : "sonner" ,
27+ message :
28+ "The toaster component is deprecated. Use the sonner component instead." ,
29+ } ,
30+ ]
31+
1732export const addOptionsSchema = z . object ( {
1833 components : z . array ( z . string ( ) ) . optional ( ) ,
1934 yes : z . boolean ( ) ,
@@ -81,6 +96,19 @@ export const add = new Command()
8196 options . components = await promptForRegistryComponents ( options )
8297 }
8398
99+ const deprecatedComponents = DEPRECATED_COMPONENTS . filter ( ( component ) =>
100+ options . components ?. includes ( component . name )
101+ )
102+
103+ if ( deprecatedComponents ?. length ) {
104+ logger . break ( )
105+ deprecatedComponents . forEach ( ( component ) => {
106+ logger . warn ( highlighter . warn ( component . message ) )
107+ } )
108+ logger . break ( )
109+ process . exit ( 1 )
110+ }
111+
84112 let { errors, config } = await preFlightAdd ( options )
85113
86114 // No components.json file. Prompt the user to run init.
@@ -190,7 +218,13 @@ async function promptForRegistryComponents(
190218 hint : "Space to select. A to toggle all. Enter to submit." ,
191219 instructions : false ,
192220 choices : registryIndex
193- . filter ( ( entry ) => entry . type === "registry:ui" )
221+ . filter (
222+ ( entry ) =>
223+ entry . type === "registry:ui" &&
224+ ! DEPRECATED_COMPONENTS . some (
225+ ( component ) => component . name === entry . name
226+ )
227+ )
194228 . map ( ( entry ) => ( {
195229 title : entry . name ,
196230 value : entry . name ,
0 commit comments