@@ -14,6 +14,21 @@ import { Command } from "commander"
14
14
import prompts from "prompts"
15
15
import { z } from "zod"
16
16
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
+
17
32
export const addOptionsSchema = z . object ( {
18
33
components : z . array ( z . string ( ) ) . optional ( ) ,
19
34
yes : z . boolean ( ) ,
@@ -81,6 +96,19 @@ export const add = new Command()
81
96
options . components = await promptForRegistryComponents ( options )
82
97
}
83
98
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
+
84
112
let { errors, config } = await preFlightAdd ( options )
85
113
86
114
// No components.json file. Prompt the user to run init.
@@ -190,7 +218,13 @@ async function promptForRegistryComponents(
190
218
hint : "Space to select. A to toggle all. Enter to submit." ,
191
219
instructions : false ,
192
220
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
+ )
194
228
. map ( ( entry ) => ( {
195
229
title : entry . name ,
196
230
value : entry . name ,
0 commit comments