Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
784b443
chore: switch to tinyglobby
benmccann Mar 28, 2025
b1ddd48
fix tinyglobby integration
slorber Apr 8, 2025
bbce79b
Merge branch 'main' into tinyglobby
slorber Apr 8, 2025
51d9a1b
Merge branch 'main' into tinyglobby
slorber Apr 8, 2025
32c5be4
spelling
slorber Apr 8, 2025
3a7fc22
empty
slorber Apr 8, 2025
c32f548
merge main
benmccann Apr 9, 2025
e0d3696
upgrade tinyglobby
benmccann Apr 19, 2025
86303b3
Merge branch 'main' into tinyglobby
benmccann Apr 19, 2025
1207ebe
update lockfile
benmccann Apr 19, 2025
cac8d48
upgrade tinyglobby
benmccann May 25, 2025
175cfbf
Merge branch 'main' into tinyglobby
benmccann May 25, 2025
346a349
simplify
benmccann May 25, 2025
ca54f5d
Revert "simplify"
benmccann May 26, 2025
d98d5b9
Merge branch 'main' into tinyglobby
benmccann May 26, 2025
ac90682
try upgrade
slorber Dec 5, 2025
18b4031
Merge branch 'main' into tinyglobby
slorber Dec 5, 2025
dd0ee05
lockfile
slorber Dec 5, 2025
d168d18
log component names to swizzle
slorber Dec 5, 2025
e3e5fe6
try to ignore tests on windows?
slorber Dec 5, 2025
a61d775
try to ignore tests on windows?
slorber Dec 5, 2025
3b687a5
Merge branch 'main' into tinyglobby
slorber Dec 23, 2025
feebe31
try to fix tinyglobby swizzle CI bug?
slorber Dec 23, 2025
4593f3a
remove useless log
slorber Dec 23, 2025
267a800
test log
slorber Dec 23, 2025
1c13e46
try to fix tinyglobby error on windows
slorber Dec 23, 2025
f2edb91
try to fix tinyglobby
slorber Dec 23, 2025
fafe9f5
test windows
slorber Dec 23, 2025
787ed3c
remove logs
slorber Dec 31, 2025
7920f5b
Merge branch 'main' into tinyglobby
slorber Dec 31, 2025
c57db48
try to normalize windows paths
slorber Dec 31, 2025
8dcf233
remove log
slorber Jan 1, 2026
5389e3a
remove absolute glob translations
slorber Jan 1, 2026
736aaa5
remove absolute glob translations
slorber Jan 1, 2026
2b1dcce
improve eject glob workaround
slorber Jan 1, 2026
77da395
fix windows globbing issue again?
slorber Jan 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion jest/snapshotPathNormalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os from 'os';
import path from 'path';
import _ from 'lodash';
import {escapePath} from '@docusaurus/utils';
import {escapePath, posixPath} from '@docusaurus/utils';
import {version} from '@docusaurus/core/package.json';
import stripAnsi from 'strip-ansi';

Expand Down Expand Up @@ -71,8 +71,10 @@ function normalizePaths<T>(value: T): T {

const runner: ((val: string) => string)[] = [
(val) => (val.includes('keepAnsi') ? val : stripAnsi(val)),

// Replace process.cwd with <PROJECT_ROOT>
(val) => val.split(cwd).join('<PROJECT_ROOT>'),
(val) => val.split(posixPath(cwd)).join('<PROJECT_ROOT>'),

// Replace temp directory with <TEMP_DIR>
(val) => val.split(tempDir).join('<TEMP_DIR>'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import {jest} from '@jest/globals';
import fs from 'fs-extra';
import tmp from 'tmp-promise';
import {getBabelOptions} from '../utils';
Expand Down Expand Up @@ -45,16 +44,10 @@ const default => {
`,
});

const errorMock = jest.spyOn(console, 'error').mockImplementation(() => {});

await expect(
extractSourceCodeFileTranslations(sourceCodeFilePath, TestBabelOptions),
).rejects.toThrow();

expect(errorMock).toHaveBeenCalledWith(
expect.stringMatching(
/Error while attempting to extract Docusaurus translations from source code file at/,
),
).rejects.toThrow(
/Error while attempting to extract Docusaurus translations from source code file at/,
);
});

Expand Down
8 changes: 5 additions & 3 deletions packages/docusaurus-babel/src/babelTranslationsExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import fs from 'fs-extra';
import logger from '@docusaurus/logger';
import traverse, {type Node} from '@babel/traverse';
import generate from '@babel/generator';
import {
Expand All @@ -15,6 +14,7 @@ import {
type NodePath,
type TransformOptions,
} from '@babel/core';
import {logger} from '@docusaurus/logger';
import type {TranslationFileContent} from '@docusaurus/types';

export type SourceCodeFileTranslations = {
Expand Down Expand Up @@ -56,8 +56,10 @@ export async function extractSourceCodeFileTranslations(
);
return translations;
} catch (err) {
logger.error`Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`;
throw err;
throw new Error(
logger.interpolate`Error while attempting to extract Docusaurus translations from source code file at path=${sourceCodeFilePath}.`,
{cause: err as Error},
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ describe('extractThemeCodeMessages', () => {
await expect(() =>
extractThemeCodeMessages([path.join(__dirname, '__fixtures__/theme')]),
).rejects.toThrowErrorMatchingInlineSnapshot(`
"
Please make sure all theme translations are static!
Some warnings were found!
"
Please make sure all theme translations are static!
Some warnings were found!

Translate content could not be extracted. It has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.
File: packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 4
Full code: <Translate>{index}</Translate>
"
`);
Translate content could not be extracted. It has to be a static string and use optional but static props, like <Translate id="my-id" description="my-description">text</Translate>.
File: <PROJECT_ROOT>/packages/docusaurus-theme-translations/src/__tests__/__fixtures__/theme/index.js at line 4
Full code: <Translate>{index}</Translate>
"
`);
});
});
2 changes: 1 addition & 1 deletion packages/docusaurus-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"file-loader": "^6.2.0",
"fs-extra": "^11.1.1",
"github-slugger": "^1.5.0",
"globby": "^11.1.0",
"gray-matter": "^4.0.3",
"jiti": "^1.20.0",
"js-yaml": "^4.1.0",
Expand All @@ -35,6 +34,7 @@
"p-queue": "^6.6.2",
"prompts": "^2.4.2",
"resolve-pathname": "^3.0.0",
"tinyglobby": "^0.2.15",
"tslib": "^2.6.0",
"url-loader": "^4.1.1",
"utility-types": "^3.10.0",
Expand Down
14 changes: 10 additions & 4 deletions packages/docusaurus-utils/src/globUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
import path from 'path';
import Micromatch from 'micromatch'; // Note: Micromatch is used by Globby
import {addSuffix} from '@docusaurus/utils-common';
import Globby from 'globby';
import * as Tinyglobby from 'tinyglobby';
import {posixPath} from './pathUtils';

type GlobOptions = Tinyglobby.GlobOptions;

// TODO Docusaurus v4 refactor, hide lib behind home-made abstraction
// See https://github.com/facebook/docusaurus/pull/11042
/** A re-export of the globby instance. */
export {Globby};
export const Globby = Tinyglobby.glob;

/**
* The default glob patterns we ignore when sourcing content.
Expand Down Expand Up @@ -93,7 +97,7 @@ export function createAbsoluteFilePathMatcher(
// See https://github.com/facebook/docusaurus/pull/4222#issuecomment-795517329
export async function safeGlobby(
patterns: string[],
options?: Globby.GlobbyOptions,
options?: GlobOptions,
): Promise<string[]> {
// Required for Windows support, as paths using \ should not be used by globby
// (also using the windows hard drive prefix like c: is not a good idea)
Expand Down Expand Up @@ -132,6 +136,8 @@ export const isTranslatableSourceFile: (filePath: string) => boolean = (() => {
export async function globTranslatableSourceFiles(
patterns: string[],
): Promise<string[]> {
const filePaths = await safeGlobby(patterns);
const filePaths = await safeGlobby(patterns, {
absolute: true,
});
return filePaths.filter(isTranslatableSourceFile);
}
6 changes: 6 additions & 0 deletions packages/docusaurus/src/commands/swizzle/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ export async function eject({
const globPatternPosix = posixPath(globPattern);

const filesToCopy = await Globby(globPatternPosix, {
// Workaround for Tinyglobby bug?
// We glob absolute from the theme root path, not from cwd
// See https://github.com/SuperchupuDev/tinyglobby/issues/186
cwd: themePath,
absolute: true,

ignore: _.compact([
'**/*.{story,stories,test,tests}.{js,jsx,ts,tsx}',
// When ejecting JS components, we want to avoid emitting TS files
Expand Down
11 changes: 5 additions & 6 deletions packages/docusaurus/src/commands/writeHeadingIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ export async function writeHeadingIds(
): Promise<void> {
const siteDir = await fs.realpath(siteDirParam);

const markdownFiles = await safeGlobby(
files ?? (await getPathsToWatch(siteDir)),
{
expandDirectories: ['**/*.{md,mdx}'],
},
);
const markdownFiles = (
await safeGlobby(files ?? (await getPathsToWatch(siteDir)), {
expandDirectories: true,
})
).filter((file) => file.endsWith('.md') || file.endsWith('.mdx'));

const result = await Promise.all(
markdownFiles.map((p) => transformMarkdownFile(p, options)),
Expand Down
1 change: 1 addition & 0 deletions website/_dogfooding/testSwizzleThemeClassic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ async function getAllComponentNames() {
}

const componentNames = await getAllComponentNames();
console.log('componentNames', componentNames);

const componentsNotFound = Object.keys(swizzleConfig.components).filter(
(componentName) => !componentNames.includes(componentName),
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8994,10 +8994,10 @@ fb-watchman@^2.0.0:
dependencies:
bser "2.1.1"

fdir@^6.4.3:
version "6.4.3"
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.3.tgz#011cdacf837eca9b811c89dbb902df714273db72"
integrity sha512-PMXmW2y1hDDfTSRc9gaXIuCCRpuoz3Kaz8cUelp3smouvfT632ozg2vrT6lJsHKKOF59YLbOGfAWGUcKEfRMQw==
fdir@^6.5.0:
version "6.5.0"
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.5.0.tgz#ed2ab967a331ade62f18d077dae192684d50d350"
integrity sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==

feed@^4.2.2:
version "4.2.2"
Expand Down Expand Up @@ -14531,10 +14531,10 @@ picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.2.3, picomatc
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

picomatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab"
integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==
picomatch@^4.0.2, picomatch@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.3.tgz#796c76136d1eead715db1e7bad785dedd695a042"
integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==

pidtree@^0.3.0:
version "0.3.1"
Expand Down Expand Up @@ -17713,13 +17713,13 @@ tinyexec@^0.3.2:
resolved "https://registry.yarnpkg.com/tinyexec/-/tinyexec-0.3.2.tgz#941794e657a85e496577995c6eef66f53f42b3d2"
integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==

tinyglobby@^0.2.12:
version "0.2.12"
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.12.tgz#ac941a42e0c5773bd0b5d08f32de82e74a1a61b5"
integrity sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==
tinyglobby@^0.2.12, tinyglobby@^0.2.15:
version "0.2.15"
resolved "https://registry.yarnpkg.com/tinyglobby/-/tinyglobby-0.2.15.tgz#e228dd1e638cea993d2fdb4fcd2d4602a79951c2"
integrity sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==
dependencies:
fdir "^6.4.3"
picomatch "^4.0.2"
fdir "^6.5.0"
picomatch "^4.0.3"

tinypool@^1.0.2:
version "1.0.2"
Expand Down
Loading