@@ -10,24 +10,23 @@ import type {
1010 * Resolves which plugins to include in the generated config.
1111 *
1212 * Resolution order (first match wins):
13- * 1. `--plugins`: comma-separated slugs, validated against available bindings
13+ * 1. `--plugins`: user-provided slugs
1414 * 2. `--yes`: recommended plugins
1515 * 3. Interactive: checkbox prompt with recommended plugins pre-checked
1616 */
1717export async function promptPluginSelection (
1818 bindings : PluginSetupBinding [ ] ,
1919 targetDir : string ,
20- cliArgs : CliArgs ,
20+ { plugins , yes } : CliArgs ,
2121) : Promise < PluginSetupBinding [ ] > {
2222 if ( bindings . length === 0 ) {
2323 return [ ] ;
2424 }
25- const slugs = parsePluginSlugs ( cliArgs . plugins ) ;
26- if ( slugs != null ) {
27- return filterBindingsBySlugs ( bindings , slugs ) ;
25+ if ( plugins != null && plugins . length > 0 ) {
26+ return bindings . filter ( b => plugins . includes ( b . slug ) ) ;
2827 }
2928 const recommended = await detectRecommended ( bindings , targetDir ) ;
30- if ( cliArgs . yes ) {
29+ if ( yes ) {
3130 return bindings . filter ( ( { slug } ) => recommended . has ( slug ) ) ;
3231 }
3332 const selected = await checkbox ( {
@@ -43,33 +42,6 @@ export async function promptPluginSelection(
4342 return bindings . filter ( ( { slug } ) => selectedSet . has ( slug ) ) ;
4443}
4544
46- function parsePluginSlugs ( value : string | undefined ) : string [ ] | null {
47- if ( value == null || value . trim ( ) === '' ) {
48- return null ;
49- }
50- return [
51- ...new Set (
52- value
53- . split ( ',' )
54- . map ( s => s . trim ( ) )
55- . filter ( Boolean ) ,
56- ) ,
57- ] ;
58- }
59-
60- function filterBindingsBySlugs (
61- bindings : PluginSetupBinding [ ] ,
62- slugs : string [ ] ,
63- ) : PluginSetupBinding [ ] {
64- const unknown = slugs . filter ( slug => ! bindings . some ( b => b . slug === slug ) ) ;
65- if ( unknown . length > 0 ) {
66- throw new Error (
67- `Unknown plugin slugs: ${ unknown . join ( ', ' ) } . Available: ${ bindings . map ( b => b . slug ) . join ( ', ' ) } ` ,
68- ) ;
69- }
70- return bindings . filter ( b => slugs . includes ( b . slug ) ) ;
71- }
72-
7345/**
7446 * Calls each binding's `isRecommended` callback (if provided)
7547 * and collects the slugs of bindings that returned `true`.
0 commit comments