Skip to content

Commit

Permalink
chore: fix 2.3 backport tests due to failing test after backport, see…
Browse files Browse the repository at this point in the history
… also comment #7945 (comment)
  • Loading branch information
slorber committed Jan 26, 2023
1 parent 63ec772 commit 35a691b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus/src/commands/swizzle/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
48 changes: 31 additions & 17 deletions website/_dogfooding/testSwizzleThemeClassic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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),
Expand All @@ -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
*/
Expand Down

0 comments on commit 35a691b

Please sign in to comment.