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:
sebastienlorber 2023-01-26 17:42:33 +01:00
parent 63ec772b83
commit 35a691bb73
2 changed files with 32 additions and 18 deletions

View file

@ -50,7 +50,7 @@ function sortComponentNames(componentNames: string[]): string[] {
*
* @param componentNames the original list of component names
*/
function getMissingIntermediateComponentFolderNames(
export function getMissingIntermediateComponentFolderNames(
componentNames: string[],
): string[] {
function getAllIntermediatePaths(componentName: string): string[] {

View file

@ -13,7 +13,10 @@ import logger from '@docusaurus/logger';
import classicTheme from '@docusaurus/theme-classic';
// 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 {wrap, eject} from '@docusaurus/core/lib/commands/swizzle/actions.js';
@ -50,7 +53,33 @@ console.log('\n');
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(
(componentName) => !componentNames.includes(componentName),
@ -67,21 +96,6 @@ Please double-check or clean up these components from the config:
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
*/