mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-31 07:18:59 +02:00
feat(core): add --config param to swizzle command (#8210)
This commit is contained in:
parent
308b5390b5
commit
7b3ebb7729
5 changed files with 20 additions and 12 deletions
|
@ -77,6 +77,10 @@ cli
|
||||||
'copy TypeScript theme files when possible (default: false)',
|
'copy TypeScript theme files when possible (default: false)',
|
||||||
)
|
)
|
||||||
.option('--danger', 'enable swizzle for unsafe component of themes')
|
.option('--danger', 'enable swizzle for unsafe component of themes')
|
||||||
|
.option(
|
||||||
|
'--config <config>',
|
||||||
|
'path to Docusaurus config file (default: `[siteDir]/docusaurus.config.js`)',
|
||||||
|
)
|
||||||
.action(swizzle);
|
.action(swizzle);
|
||||||
|
|
||||||
cli
|
cli
|
||||||
|
|
|
@ -67,6 +67,7 @@ export type SwizzleCLIOptions = {
|
||||||
list: boolean;
|
list: boolean;
|
||||||
wrap: boolean;
|
wrap: boolean;
|
||||||
eject: boolean;
|
eject: boolean;
|
||||||
|
config?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function normalizeOptions(
|
export function normalizeOptions(
|
||||||
|
@ -78,6 +79,7 @@ export function normalizeOptions(
|
||||||
list: options.list ?? false,
|
list: options.list ?? false,
|
||||||
wrap: options.wrap ?? false,
|
wrap: options.wrap ?? false,
|
||||||
eject: options.eject ?? false,
|
eject: options.eject ?? false,
|
||||||
|
config: options.config ?? undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
import {loadContext} from '../../server';
|
import {loadContext} from '../../server';
|
||||||
import {initPlugins} from '../../server/plugins/init';
|
import {initPlugins} from '../../server/plugins/init';
|
||||||
import {loadPluginConfigs} from '../../server/plugins/configs';
|
import {loadPluginConfigs} from '../../server/plugins/configs';
|
||||||
import type {SwizzleContext} from './common';
|
import type {SwizzleCLIOptions, SwizzleContext} from './common';
|
||||||
|
|
||||||
export async function initSwizzleContext(
|
export async function initSwizzleContext(
|
||||||
siteDir: string,
|
siteDir: string,
|
||||||
|
options: SwizzleCLIOptions,
|
||||||
): Promise<SwizzleContext> {
|
): Promise<SwizzleContext> {
|
||||||
const context = await loadContext({siteDir});
|
const context = await loadContext({siteDir, config: options.config});
|
||||||
const plugins = await initPlugins(context);
|
const plugins = await initPlugins(context);
|
||||||
const pluginConfigs = await loadPluginConfigs(context);
|
const pluginConfigs = await loadPluginConfigs(context);
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ export async function swizzle(
|
||||||
const options = normalizeOptions(optionsParam);
|
const options = normalizeOptions(optionsParam);
|
||||||
const {list, danger, typescript} = options;
|
const {list, danger, typescript} = options;
|
||||||
|
|
||||||
const {plugins} = await initSwizzleContext(siteDir);
|
const {plugins} = await initSwizzleContext(siteDir, options);
|
||||||
const themeNames = getThemeNames(plugins);
|
const themeNames = getThemeNames(plugins);
|
||||||
|
|
||||||
if (list && !themeNameParam) {
|
if (list && !themeNameParam) {
|
||||||
|
|
|
@ -113,15 +113,16 @@ The swizzle CLI is interactive and will guide you through the whole [swizzle pro
|
||||||
|
|
||||||
#### Options {#options-swizzle}
|
#### Options {#options-swizzle}
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| --------------- | ---------------------------------------------------- |
|
| --- | --- |
|
||||||
| `themeName` | The name of the theme to swizzle from. |
|
| `themeName` | The name of the theme to swizzle from. |
|
||||||
| `componentName` | The name of the theme component to swizzle. |
|
| `componentName` | The name of the theme component to swizzle. |
|
||||||
| `--list` | Display components available for swizzling |
|
| `--list` | Display components available for swizzling |
|
||||||
| `--eject` | [Eject](./swizzling.md#ejecting) the theme component |
|
| `--eject` | [Eject](./swizzling.md#ejecting) the theme component |
|
||||||
| `--wrap` | [Wrap](./swizzling.md#wrapping) the theme component |
|
| `--wrap` | [Wrap](./swizzling.md#wrapping) the theme component |
|
||||||
| `--danger` | Allow immediate swizzling of unsafe components |
|
| `--danger` | Allow immediate swizzling of unsafe components |
|
||||||
| `--typescript` | Swizzle the TypeScript variant component |
|
| `--typescript` | Swizzle the TypeScript variant component |
|
||||||
|
| `--config` | Path to docusaurus config file, default to `[siteDir]/docusaurus.config.js` |
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue