File tree Expand file tree Collapse file tree 5 files changed +20
-12
lines changed
Expand file tree Collapse file tree 5 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 7777 'copy TypeScript theme files when possible (default: false)' ,
7878 )
7979 . option ( '--danger' , 'enable swizzle for unsafe component of themes' )
80+ . option (
81+ '--config <config>' ,
82+ 'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)' ,
83+ )
8084 . action ( swizzle ) ;
8185
8286cli
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export type SwizzleCLIOptions = {
6767 list : boolean ;
6868 wrap : boolean ;
6969 eject : boolean ;
70+ config ?: string ;
7071} ;
7172
7273export function normalizeOptions (
@@ -78,6 +79,7 @@ export function normalizeOptions(
7879 list : options . list ?? false ,
7980 wrap : options . wrap ?? false ,
8081 eject : options . eject ?? false ,
82+ config : options . config ?? undefined ,
8183 } ;
8284}
8385
Original file line number Diff line number Diff line change 88import { loadContext } from '../../server' ;
99import { initPlugins } from '../../server/plugins/init' ;
1010import { loadPluginConfigs } from '../../server/plugins/configs' ;
11- import type { SwizzleContext } from './common' ;
11+ import type { SwizzleCLIOptions , SwizzleContext } from './common' ;
1212
1313export async function initSwizzleContext (
1414 siteDir : string ,
15+ options : SwizzleCLIOptions ,
1516) : Promise < SwizzleContext > {
16- const context = await loadContext ( { siteDir} ) ;
17+ const context = await loadContext ( { siteDir, config : options . config } ) ;
1718 const plugins = await initPlugins ( context ) ;
1819 const pluginConfigs = await loadPluginConfigs ( context ) ;
1920
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ export async function swizzle(
9898 const options = normalizeOptions ( optionsParam ) ;
9999 const { list, danger, typescript} = options ;
100100
101- const { plugins} = await initSwizzleContext ( siteDir ) ;
101+ const { plugins} = await initSwizzleContext ( siteDir , options ) ;
102102 const themeNames = getThemeNames ( plugins ) ;
103103
104104 if ( list && ! themeNameParam ) {
Original file line number Diff line number Diff line change @@ -113,15 +113,16 @@ The swizzle CLI is interactive and will guide you through the whole [swizzle pro
113113
114114#### Options {#options-swizzle}
115115
116- | Name | Description |
117- | --------------- | ---------------------------------------------------- |
118- | ` themeName ` | The name of the theme to swizzle from. |
119- | ` componentName ` | The name of the theme component to swizzle. |
120- | ` --list ` | Display components available for swizzling |
121- | ` --eject ` | [ Eject] ( ./swizzling.md#ejecting ) the theme component |
122- | ` --wrap ` | [ Wrap] ( ./swizzling.md#wrapping ) the theme component |
123- | ` --danger ` | Allow immediate swizzling of unsafe components |
124- | ` --typescript ` | Swizzle the TypeScript variant component |
116+ | Name | Description |
117+ | --- | --- |
118+ | ` themeName ` | The name of the theme to swizzle from. |
119+ | ` componentName ` | The name of the theme component to swizzle. |
120+ | ` --list ` | Display components available for swizzling |
121+ | ` --eject ` | [ Eject] ( ./swizzling.md#ejecting ) the theme component |
122+ | ` --wrap ` | [ Wrap] ( ./swizzling.md#wrapping ) the theme component |
123+ | ` --danger ` | Allow immediate swizzling of unsafe components |
124+ | ` --typescript ` | Swizzle the TypeScript variant component |
125+ | ` --config ` | Path to docusaurus config file, default to ` [siteDir]/docusaurus.config.js ` |
125126
126127::: caution
127128
You can’t perform that action at this time.
0 commit comments