File tree Expand file tree Collapse file tree 4 files changed +36
-70
lines changed
docusaurus/src/commands/swizzle Expand file tree Collapse file tree 4 files changed +36
-70
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -119,7 +119,6 @@ export {
119119} from './dataFileUtils' ;
120120export { isDraft , isUnlisted } from './contentVisibilityUtils' ;
121121export { escapeRegexp } from './regExpUtils' ;
122- export { askPreferredLanguage } from './cliUtils' ;
123122export { flattenRoutes } from './routeUtils' ;
124123
125124export {
Original file line number Diff line number Diff line change 77
88import fs from 'fs-extra' ;
99import logger from '@docusaurus/logger' ;
10- import { askPreferredLanguage } from '@docusaurus/utils' ;
1110import {
1211 getThemeName ,
1312 getThemePath ,
@@ -19,7 +18,10 @@ import {helpTables, themeComponentsTable} from './tables';
1918import { normalizeOptions } from './common' ;
2019import { eject , getAction , wrap } from './actions' ;
2120import { getThemeSwizzleConfig } from './config' ;
22- import { askSwizzleDangerousComponent } from './prompts' ;
21+ import {
22+ askSwizzleDangerousComponent ,
23+ askSwizzlePreferredLanguage ,
24+ } from './prompts' ;
2325import { initSwizzleContext } from './context' ;
2426import type { SwizzleAction , SwizzleComponentConfig } from '@docusaurus/types' ;
2527import type { SwizzleCLIOptions , SwizzlePlugin } from './common' ;
@@ -54,7 +56,7 @@ async function getLanguageForThemeName({
5456
5557 // It's only useful to prompt the user for themes that support both JS/TS
5658 if ( supportsTS ) {
57- return askPreferredLanguage ( { exit : true } ) ;
59+ return askSwizzlePreferredLanguage ( ) ;
5860 }
5961
6062 return 'javascript' ;
Original file line number Diff line number Diff line change 66 */
77
88import logger from '@docusaurus/logger' ;
9- import prompts from 'prompts' ;
9+ import prompts , { type Choice } from 'prompts' ;
1010import { actionStatusSuffix , PartiallySafeHint } from './common' ;
1111import type { ThemeComponents } from './components' ;
1212import type { SwizzleAction , SwizzleComponentConfig } from '@docusaurus/types' ;
@@ -125,3 +125,33 @@ export async function askSwizzleAction(
125125
126126 return action ;
127127}
128+
129+ export async function askSwizzlePreferredLanguage ( ) : Promise <
130+ 'javascript' | 'typescript'
131+ > {
132+ const choices : Choice [ ] = [
133+ { title : logger . bold ( 'JavaScript' ) , value : 'javascript' } ,
134+ { title : logger . bold ( 'TypeScript' ) , value : 'typescript' } ,
135+ { title : logger . yellow ( '[Exit]' ) , value : '[Exit]' } ,
136+ ] ;
137+
138+ const { language} = await prompts (
139+ {
140+ type : 'select' ,
141+ name : 'language' ,
142+ message : 'Which language do you want to use?' ,
143+ choices,
144+ } ,
145+ {
146+ onCancel ( ) {
147+ process . exit ( 0 ) ;
148+ } ,
149+ } ,
150+ ) ;
151+
152+ if ( typeof language === 'undefined' || language === '[Exit]' ) {
153+ process . exit ( 0 ) ;
154+ }
155+
156+ return language ;
157+ }
You can’t perform that action at this time.
0 commit comments