@@ -9,13 +9,15 @@ const logger = consola.withTag('genapi:init')
99
1010const CONFIG = {
1111 presets : {
12- axios : { deps : [ 'axios' ] , schema : false } ,
13- fetch : { deps : [ ] , schema : true } ,
14- ky : { deps : [ 'ky' ] , schema : false } ,
15- got : { deps : [ 'got' ] , schema : false } ,
16- ofetch : { deps : [ 'ofetch' ] , schema : true } ,
17- uni : { deps : [ '@uni-helper/uni-network' ] , schema : false } ,
18- } as Record < string , { deps : string [ ] , schema : boolean } > ,
12+ axios : { deps : [ 'axios' ] , schema : false , supportsJs : true } ,
13+ fetch : { deps : [ ] , schema : true , supportsJs : true } ,
14+ ky : { deps : [ 'ky' ] , schema : false , supportsJs : true } ,
15+ got : { deps : [ 'got' ] , schema : false , supportsJs : true } ,
16+ ofetch : { deps : [ 'ofetch' ] , schema : true , supportsJs : true } ,
17+ reactQuery : { deps : [ '@tanstack/react-query' ] , schema : false , supportsJs : false } ,
18+ uni : { deps : [ '@uni-helper/uni-network' ] , schema : false , supportsJs : true } ,
19+ vueQuery : { deps : [ '@tanstack/vue-query' ] , schema : false , supportsJs : false } ,
20+ } as Record < string , { deps : string [ ] , schema : boolean , supportsJs ?: boolean } > ,
1921}
2022
2123async function mandate < T > ( promise : Promise < any > ) : Promise < T > {
@@ -35,18 +37,19 @@ export async function initCommand() {
3537 options : Object . keys ( CONFIG . presets ) . map ( v => ( { value : v , label : v } ) ) ,
3638 } ) )
3739
40+ const presetConfig = CONFIG . presets [ preset ]
3841 const mode = await mandate < ( 'ts' | 'js' | 'schema' ) > ( select ( {
3942 message : 'Select mode:' ,
4043 options : [
4144 { value : 'ts' , label : 'TS' } ,
42- { value : 'js' , label : 'JS' } ,
43- ...( CONFIG . presets [ preset ] . schema ? [ { value : 'schema' , label : 'Schema' } ] : [ ] ) ,
45+ ... ( presetConfig . supportsJs !== false ? [ { value : 'js' , label : 'JS' } ] : [ ] ) ,
46+ ...( presetConfig . schema ? [ { value : 'schema' , label : 'Schema' } ] : [ ] ) ,
4447 ] ,
4548 } ) )
4649
4750 const isTS = mode !== 'js'
4851 const fileName = `genapi.config.${ isTS ? 'ts' : 'js' } `
49- const presetValue = `${ preset } .${ mode } `
52+ const presetValue = presetConfig . supportsJs === false ? preset : `${ preset } .${ mode } `
5053 const content = isTS
5154 ? `import { defineConfig } from '@genapi/core'
5255import { ${ preset } } from '@genapi/presets'
0 commit comments