mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 19:03:38 +02:00
chore: fix 2.3 backport tests due to failing test after backport, see also comment https://github.com/facebook/docusaurus/pull/7945#issuecomment-1405287563
This commit is contained in:
parent
63ec772b83
commit
35a691bb73
2 changed files with 32 additions and 18 deletions
|
@ -50,7 +50,7 @@ function sortComponentNames(componentNames: string[]): string[] {
|
||||||
*
|
*
|
||||||
* @param componentNames the original list of component names
|
* @param componentNames the original list of component names
|
||||||
*/
|
*/
|
||||||
function getMissingIntermediateComponentFolderNames(
|
export function getMissingIntermediateComponentFolderNames(
|
||||||
componentNames: string[],
|
componentNames: string[],
|
||||||
): string[] {
|
): string[] {
|
||||||
function getAllIntermediatePaths(componentName: string): string[] {
|
function getAllIntermediatePaths(componentName: string): string[] {
|
||||||
|
|
|
@ -13,7 +13,10 @@ import logger from '@docusaurus/logger';
|
||||||
import classicTheme from '@docusaurus/theme-classic';
|
import classicTheme from '@docusaurus/theme-classic';
|
||||||
|
|
||||||
// Unsafe imports
|
// Unsafe imports
|
||||||
import {readComponentNames} from '@docusaurus/core/lib/commands/swizzle/components.js';
|
import {
|
||||||
|
readComponentNames,
|
||||||
|
getMissingIntermediateComponentFolderNames,
|
||||||
|
} from '@docusaurus/core/lib/commands/swizzle/components.js';
|
||||||
import {normalizeSwizzleConfig} from '@docusaurus/core/lib/commands/swizzle/config.js';
|
import {normalizeSwizzleConfig} from '@docusaurus/core/lib/commands/swizzle/config.js';
|
||||||
import {wrap, eject} from '@docusaurus/core/lib/commands/swizzle/actions.js';
|
import {wrap, eject} from '@docusaurus/core/lib/commands/swizzle/actions.js';
|
||||||
|
|
||||||
|
@ -50,7 +53,33 @@ console.log('\n');
|
||||||
|
|
||||||
await fs.remove(toPath);
|
await fs.remove(toPath);
|
||||||
|
|
||||||
let componentNames = await readComponentNames(themePath);
|
function filterComponentNames(componentNames) {
|
||||||
|
// TODO temp workaround: non-comps should be forbidden to wrap
|
||||||
|
if (action === 'wrap') {
|
||||||
|
const WrapBlocklist = [
|
||||||
|
'Layout', // Due to theme-fallback?
|
||||||
|
];
|
||||||
|
|
||||||
|
return componentNames.filter((componentName) => {
|
||||||
|
const blocked = WrapBlocklist.includes(componentName);
|
||||||
|
if (blocked) {
|
||||||
|
logger.warn(`${componentName} is blocked and will not be wrapped`);
|
||||||
|
}
|
||||||
|
return !blocked;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return componentNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getAllComponentNames() {
|
||||||
|
const names = await readComponentNames(themePath);
|
||||||
|
const allNames = names.concat(
|
||||||
|
await getMissingIntermediateComponentFolderNames(names),
|
||||||
|
);
|
||||||
|
return filterComponentNames(allNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
const componentNames = await getAllComponentNames();
|
||||||
|
|
||||||
const componentsNotFound = Object.keys(swizzleConfig.components).filter(
|
const componentsNotFound = Object.keys(swizzleConfig.components).filter(
|
||||||
(componentName) => !componentNames.includes(componentName),
|
(componentName) => !componentNames.includes(componentName),
|
||||||
|
@ -67,21 +96,6 @@ Please double-check or clean up these components from the config:
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO temp workaround: non-comps should be forbidden to wrap
|
|
||||||
if (action === 'wrap') {
|
|
||||||
const WrapBlocklist = [
|
|
||||||
'Layout', // Due to theme-fallback?
|
|
||||||
];
|
|
||||||
|
|
||||||
componentNames = componentNames.filter((componentName) => {
|
|
||||||
const blocked = WrapBlocklist.includes(componentName);
|
|
||||||
if (blocked) {
|
|
||||||
logger.warn(`${componentName} is blocked and will not be wrapped`);
|
|
||||||
}
|
|
||||||
return !blocked;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} componentName
|
* @param {string} componentName
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue