@@ -3,7 +3,7 @@ import process from 'node:process'
33import { styleText } from 'node:util'
44import { box } from '@clack/prompts'
55import { defineCommand } from 'citty'
6- import { byLengthAsc , Fzf } from 'fzf '
6+ import fuzzysort from 'fuzzysort '
77import { kebabCase , upperFirst } from 'scule'
88
99import { formatInfoBox } from '../../utils/formatting'
@@ -64,21 +64,20 @@ async function findModuleByKeywords(query: string, nuxtVersion: string) {
6464 const compatibleModules = allModules . filter ( m =>
6565 checkNuxtCompatibility ( m , nuxtVersion ) ,
6666 )
67- const fzf = new Fzf ( compatibleModules , {
68- selector : m => [
69- m . name ,
70- m . npm ,
71- m . repo ,
72- m . tags ?. join ( ' ' ) ,
73- m . category ,
74- m . description ,
75- m . maintainers . map ( maintainer => `${ maintainer . name } ${ maintainer . github } ` ) . join ( ' ' ) ,
76- ] . filter ( Boolean ) . join ( ' ' ) ,
77- casing : 'case-insensitive' ,
78- tiebreakers : [ byLengthAsc ] ,
79- } )
67+ const targets = compatibleModules . map ( item => ( {
68+ item,
69+ name : fuzzysort . prepare ( item . name ) ,
70+ npm : fuzzysort . prepare ( item . npm ) ,
71+ rest : fuzzysort . prepare ( [
72+ item . repo ,
73+ item . tags ?. join ( ' ' ) ,
74+ item . category ,
75+ item . description ,
76+ item . maintainers . map ( maintainer => `${ maintainer . name } ${ maintainer . github } ` ) . join ( ' ' ) ,
77+ ] . filter ( Boolean ) . join ( ' ' ) ) ,
78+ } ) )
8079
81- const results = fzf . find ( query ) . map ( ( { item } ) => {
80+ const results = fuzzysort . go ( query , targets , { keys : [ 'name' , 'npm' , 'rest' ] , all : ! query } ) . map ( ( { obj : { item } } ) => {
8281 const res : Record < string , string > = {
8382 name : item . name ,
8483 package : item . npm ,
0 commit comments