@docusaurus/core 4.0.0-canary-6885 → 4.0.0-canary-6891

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/beforeCli.mjs CHANGED
@@ -7,7 +7,6 @@
7
7
 
8
8
  // @ts-check
9
9
 
10
- import fs from 'fs-extra';
11
10
  import path from 'node:path';
12
11
  import {createRequire} from 'node:module';
13
12
  import {execa} from 'execa';
@@ -16,6 +15,7 @@ import semver from 'semver';
16
15
  import updateNotifier from 'update-notifier';
17
16
  import boxen from 'boxen';
18
17
  import {DOCUSAURUS_VERSION} from '@docusaurus/utils';
18
+ import {pathExists} from '@docusaurus/fs';
19
19
 
20
20
  const packageJson = /** @type {typeof import("../package.json")} */ (
21
21
  createRequire(import.meta.url)('../package.json')
@@ -108,7 +108,7 @@ export default async function beforeCli() {
108
108
  .join(' ');
109
109
 
110
110
  const getYarnVersion = async () => {
111
- if (!(await fs.pathExists(path.resolve('yarn.lock')))) {
111
+ if (!(await pathExists(path.resolve('yarn.lock')))) {
112
112
  return undefined;
113
113
  }
114
114
 
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.build = build;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
13
12
  const utils_1 = require("@docusaurus/utils");
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  const i18n_1 = require("../../server/i18n");
15
15
  const buildLocale_1 = require("./buildLocale");
16
16
  const config_1 = require("../../server/config");
@@ -22,7 +22,7 @@ async function build(siteDirParam = '.', cliOptions = {}) {
22
22
  process.env.BABEL_ENV = 'development';
23
23
  process.env.NODE_ENV = 'development';
24
24
  }
25
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
25
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
26
26
  ['SIGINT', 'SIGTERM'].forEach((sig) => {
27
27
  process.on(sig, () => process.exit());
28
28
  });
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.buildLocale = buildLocale;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
13
  const bundler_1 = require("@docusaurus/bundler");
15
14
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
15
+ const fs_1 = require("@docusaurus/fs");
16
16
  const site_1 = require("../../server/site");
17
17
  const brokenLinks_1 = require("../../server/brokenLinks");
18
18
  const client_1 = require("../../webpack/client");
@@ -164,7 +164,7 @@ async function cleanupServerBundle(serverBundlePath) {
164
164
  await logger_1.PerfLogger.async('Deleting server bundle', async () => {
165
165
  // For now we assume server entry is at the root of the server out dir
166
166
  const serverDir = node_path_1.default.dirname(serverBundlePath);
167
- await fs_extra_1.default.rm(serverDir, { recursive: true, force: true });
167
+ await fs_1.fs.rm(serverDir, { recursive: true, force: true });
168
168
  });
169
169
  }
170
170
  }
@@ -8,13 +8,13 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.clear = clear;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
13
  const utils_1 = require("@docusaurus/utils");
14
+ const fs_1 = require("@docusaurus/fs");
15
15
  const clearPath_1 = tslib_1.__importDefault(require("./utils/clearPath"));
16
16
  async function removePath(entry) {
17
- if (!(await fs_extra_1.default.pathExists(entry.path))) {
17
+ if (!(await (0, fs_1.pathExists)(entry.path))) {
18
18
  return;
19
19
  }
20
20
  try {
@@ -27,7 +27,7 @@ async function removePath(entry) {
27
27
  }
28
28
  }
29
29
  async function clear(siteDirParam = '.') {
30
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
30
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
31
31
  const generatedFolder = {
32
32
  path: node_path_1.default.join(siteDir, utils_1.GENERATED_FILES_DIR_NAME),
33
33
  description: 'generated folder',
@@ -8,12 +8,12 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.deploy = deploy;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
14
  const execa_1 = require("execa");
16
15
  const utils_1 = require("@docusaurus/utils");
16
+ const fs_1 = require("@docusaurus/fs");
17
17
  const site_1 = require("../server/site");
18
18
  const build_1 = require("./build/build");
19
19
  // GIT_PASS env variable should not appear in logs
@@ -51,7 +51,7 @@ async function hasGit() {
51
51
  return (await exec('git', ['--version'], { failfast: false })).exitCode === 0;
52
52
  }
53
53
  async function deploy(siteDirParam = '.', cliOptions = {}) {
54
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
54
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
55
55
  const { outDir, siteConfig, siteConfigPath } = await (0, site_1.loadContext)({
56
56
  siteDir,
57
57
  config: cliOptions.config,
@@ -146,7 +146,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
146
146
  const runDeploy = async (outputDirectory) => {
147
147
  const targetDirectory = cliOptions.targetDir ?? '.';
148
148
  const fromPath = outputDirectory;
149
- const toPath = await fs_extra_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
149
+ const toPath = await fs_1.fs.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
150
150
  process.chdir(toPath);
151
151
  // Clones the repo into the temp folder and checks out the target branch.
152
152
  // If the branch doesn't exist, it creates a new one based on the
@@ -168,7 +168,11 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
168
168
  await exec('git', ['rm', '-rf', targetDirectory], { log: false });
169
169
  const targetPath = node_path_1.default.join(toPath, targetDirectory);
170
170
  try {
171
- await fs_extra_1.default.copy(fromPath, targetPath);
171
+ // verbatimSymlinks: keep relative symlinks relative
172
+ await fs_1.fs.cp(fromPath, targetPath, {
173
+ recursive: true,
174
+ verbatimSymlinks: true,
175
+ });
172
176
  }
173
177
  catch (err) {
174
178
  throw new Error(`Failed to copy build assets from path=${fromPath} to path=${targetPath}.`, { cause: err });
@@ -7,12 +7,11 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.externalCommand = externalCommand;
10
- const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
10
+ const fs_1 = require("@docusaurus/fs");
12
11
  const site_1 = require("../server/site");
13
12
  const init_1 = require("../server/plugins/init");
14
13
  async function externalCommand({ cli, siteDir: siteDirInput, config, }) {
15
- const siteDir = await fs_extra_1.default.realpath(siteDirInput);
14
+ const siteDir = await (0, fs_1.realpath)(siteDirInput);
16
15
  const context = await (0, site_1.loadContext)({ siteDir, config });
17
16
  const plugins = await (0, init_1.initPlugins)(context);
18
17
  // Plugin Lifecycle - extendCli.
@@ -8,13 +8,13 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.serve = serve;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_http_1 = tslib_1.__importDefault(require("node:http"));
13
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
14
  const utils_1 = require("@docusaurus/utils");
16
15
  const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
17
16
  const utils_common_1 = require("@docusaurus/utils-common");
17
+ const fs_1 = require("@docusaurus/fs");
18
18
  const openBrowser_1 = tslib_1.__importDefault(require("./utils/openBrowser/openBrowser"));
19
19
  const config_1 = require("../server/config");
20
20
  const build_1 = require("./build/build");
@@ -27,7 +27,7 @@ function redirect(res, location) {
27
27
  res.end();
28
28
  }
29
29
  async function serve(siteDirParam = '.', cliOptions = {}) {
30
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
30
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
31
31
  const buildDir = cliOptions.dir ?? utils_1.DEFAULT_BUILD_DIR_NAME;
32
32
  const outDir = node_path_1.default.resolve(siteDir, buildDir);
33
33
  if (cliOptions.build) {
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createReloadableSite = createReloadableSite;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_url_1 = tslib_1.__importDefault(require("node:url"));
13
12
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
13
  const utils_1 = require("@docusaurus/utils");
15
14
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
15
+ const fs_1 = require("@docusaurus/fs");
16
16
  const getHostPort_1 = require("../../server/getHostPort");
17
17
  const site_1 = require("../../server/site");
18
18
  const pluginsUtils_1 = require("../../server/plugins/pluginsUtils");
@@ -47,7 +47,7 @@ async function createOpenUrlContext({ cliOptions, }) {
47
47
  return { host, port, getOpenUrl };
48
48
  }
49
49
  async function createLoadSiteParams({ siteDirParam, cliOptions, }) {
50
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
50
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
51
51
  return {
52
52
  siteDir,
53
53
  config: cliOptions.config,
@@ -11,11 +11,11 @@ exports.getAction = getAction;
11
11
  exports.eject = eject;
12
12
  exports.wrap = wrap;
13
13
  const tslib_1 = require("tslib");
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
15
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
16
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
17
  const utils_1 = require("@docusaurus/utils");
18
+ const fs_1 = require("@docusaurus/fs");
19
19
  const glob_1 = require("@docusaurus/glob");
20
20
  const prompts_1 = require("./prompts");
21
21
  exports.SwizzleActions = ['wrap', 'eject'];
@@ -29,7 +29,7 @@ async function getAction(componentConfig, options) {
29
29
  return (0, prompts_1.askSwizzleAction)(componentConfig);
30
30
  }
31
31
  async function isDir(dirPath) {
32
- return ((await fs_extra_1.default.pathExists(dirPath)) && (await fs_extra_1.default.stat(dirPath)).isDirectory());
32
+ return (await (0, fs_1.pathExists)(dirPath)) && (await fs_1.fs.stat(dirPath)).isDirectory();
33
33
  }
34
34
  async function eject({ siteDir, themePath, componentName, typescript, }) {
35
35
  const fromPath = node_path_1.default.join(themePath, componentName);
@@ -58,12 +58,12 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
58
58
  throw new Error(logger_1.default.interpolate `No files to copy from path=${fromPath} with glob code=${globPatternPosix}`);
59
59
  }
60
60
  const toPath = node_path_1.default.join(siteDir, utils_1.THEME_PATH);
61
- await fs_extra_1.default.ensureDir(toPath);
61
+ await fs_1.fs.mkdir(toPath, { recursive: true });
62
62
  const createdFiles = await Promise.all(filesToCopy.map(async (sourceFile) => {
63
63
  const targetFile = node_path_1.default.join(toPath, node_path_1.default.relative(themePath, sourceFile));
64
64
  try {
65
- const fileContents = await fs_extra_1.default.readFile(sourceFile, 'utf-8');
66
- await fs_extra_1.default.outputFile(targetFile, fileContents.trimStart().replace(/^\/\*.+?\*\/\s*/ms, ''));
65
+ const fileContents = await fs_1.fs.readFile(sourceFile, 'utf-8');
66
+ await (0, fs_1.outputFile)(targetFile, fileContents.trimStart().replace(/^\/\*.+?\*\/\s*/ms, ''));
67
67
  }
68
68
  catch (err) {
69
69
  logger_1.default.error `Could not copy file from path=${sourceFile} to path=${targetFile}`;
@@ -79,7 +79,7 @@ async function wrap({ siteDir, themePath, componentName: themeComponentName, typ
79
79
  const componentName = lodash_1.default.last(themeComponentName.split('/'));
80
80
  const wrapperComponentName = `${componentName}Wrapper`;
81
81
  const wrapperFileName = `${themeComponentName}${isDirectory ? '/index' : ''}${typescript ? '.tsx' : '.js'}`;
82
- await fs_extra_1.default.ensureDir(node_path_1.default.resolve(siteDir, utils_1.THEME_PATH));
82
+ await fs_1.fs.mkdir(node_path_1.default.resolve(siteDir, utils_1.THEME_PATH), { recursive: true });
83
83
  const toPath = node_path_1.default.resolve(siteDir, utils_1.THEME_PATH, wrapperFileName);
84
84
  const content = typescript
85
85
  ? `import type {ReactNode} from 'react';
@@ -107,6 +107,6 @@ export default function ${wrapperComponentName}(props) {
107
107
  );
108
108
  }
109
109
  `;
110
- await fs_extra_1.default.outputFile(toPath, content);
110
+ await (0, fs_1.outputFile)(toPath, content);
111
111
  return { createdFiles: [toPath] };
112
112
  }
@@ -11,11 +11,11 @@ exports.readComponentNames = readComponentNames;
11
11
  exports.getThemeComponents = getThemeComponents;
12
12
  exports.getComponentName = getComponentName;
13
13
  const tslib_1 = require("tslib");
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
15
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
16
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
17
  const utils_1 = require("@docusaurus/utils");
18
+ const fs_1 = require("@docusaurus/fs");
19
19
  const prompts_1 = require("./prompts");
20
20
  const common_1 = require("./common");
21
21
  const tables_1 = require("./tables");
@@ -42,13 +42,13 @@ function getMissingIntermediateComponentFolderNames(componentNames) {
42
42
  }
43
43
  const skipReadDirNames = ['__test__', '__tests__', '__mocks__', '__fixtures__'];
44
44
  async function readComponentNames(themePath) {
45
- if (!(await fs_extra_1.default.pathExists(themePath))) {
45
+ if (!(await (0, fs_1.pathExists)(themePath))) {
46
46
  return [];
47
47
  }
48
48
  async function walk(dir) {
49
- const files = await Promise.all((await fs_extra_1.default.readdir(dir)).flatMap(async (file) => {
49
+ const files = await Promise.all((await fs_1.fs.readdir(dir)).flatMap(async (file) => {
50
50
  const fullPath = node_path_1.default.join(dir, file);
51
- const stat = await fs_extra_1.default.stat(fullPath);
51
+ const stat = await fs_1.fs.stat(fullPath);
52
52
  const isDir = stat.isDirectory();
53
53
  return { file, fullPath, isDir };
54
54
  }));
@@ -8,8 +8,8 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.swizzle = swizzle;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ const fs_1 = require("@docusaurus/fs");
13
13
  const themes_1 = require("./themes");
14
14
  const components_1 = require("./components");
15
15
  const tables_1 = require("./tables");
@@ -77,7 +77,7 @@ If you want to swizzle it, use the code=${'--danger'} flag, or confirm that you
77
77
  return undefined;
78
78
  }
79
79
  async function swizzle(themeNameParam = undefined, componentNameParam = undefined, siteDirParam = '.', optionsParam = {}) {
80
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
80
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
81
81
  const options = (0, common_1.normalizeOptions)(optionsParam);
82
82
  const { list, danger } = options;
83
83
  const { plugins } = await (0, context_1.initSwizzleContext)(siteDir, options);
@@ -9,13 +9,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.default = clearPath;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
12
- const promises_1 = require("node:fs/promises");
13
12
  const logger_1 = require("@docusaurus/logger");
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  /**
15
15
  * @param pathToClear
16
16
  */
17
17
  async function clearPath(pathToClear) {
18
18
  return logger_1.PerfLogger.async(`clearPath ${node_path_1.default.relative(process.cwd(), pathToClear)}`, async () => {
19
- await (0, promises_1.rm)(pathToClear, { recursive: true, force: true });
19
+ await fs_1.fs.rm(pathToClear, { recursive: true, force: true });
20
20
  });
21
21
  }
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.writeHeadingIds = writeHeadingIds;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
12
  const utils_1 = require("@docusaurus/utils");
14
13
  const glob_1 = require("@docusaurus/glob");
14
+ const fs_1 = require("@docusaurus/fs");
15
15
  const site_1 = require("../server/site");
16
16
  const init_1 = require("../server/plugins/init");
17
17
  function inferFallbackSyntax(_filepath) {
@@ -27,14 +27,14 @@ function getHeadingIdSyntax(filepath, options) {
27
27
  return options?.syntax ?? inferFallbackSyntax(filepath);
28
28
  }
29
29
  async function transformMarkdownFile(filepath, options) {
30
- const content = await fs_extra_1.default.readFile(filepath, 'utf8');
30
+ const content = await fs_1.fs.readFile(filepath, 'utf8');
31
31
  const syntax = getHeadingIdSyntax(filepath, options);
32
32
  const updatedContent = (0, utils_1.writeMarkdownHeadingId)(content, {
33
33
  ...options,
34
34
  syntax,
35
35
  });
36
36
  if (content !== updatedContent) {
37
- await fs_extra_1.default.writeFile(filepath, updatedContent);
37
+ await fs_1.fs.writeFile(filepath, updatedContent);
38
38
  return filepath;
39
39
  }
40
40
  return undefined;
@@ -66,7 +66,7 @@ function validateOptions(options) {
66
66
  }
67
67
  async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
68
68
  validateOptions(options);
69
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
69
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
70
70
  const patterns = files.length ? files : await getPathsToWatch(siteDir);
71
71
  const markdownFiles = await globMarkdownFiles(patterns);
72
72
  if (markdownFiles.length === 0) {
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.writeTranslations = writeTranslations;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const glob_1 = require("@docusaurus/glob");
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  const site_1 = require("../server/site");
15
15
  const init_1 = require("../server/plugins/init");
16
16
  const translations_1 = require("../server/translations/translations");
@@ -54,7 +54,7 @@ async function writePluginTranslationFiles({ localizationDir, plugin, options, }
54
54
  }
55
55
  }
56
56
  async function writeTranslations(siteDirParam = '.', options = {}) {
57
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
57
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
58
58
  const context = await (0, site_1.loadContext)({
59
59
  siteDir,
60
60
  config: options.config,
@@ -9,14 +9,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadSiteConfig = loadSiteConfig;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
12
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
13
  const utils_1 = require("@docusaurus/utils");
14
+ const fs_1 = require("@docusaurus/fs");
15
15
  const configValidation_1 = require("./configValidation");
16
16
  async function findConfig(siteDir) {
17
17
  // We could support .mjs, .ts, etc. in the future
18
18
  const candidates = ['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs'].map((ext) => utils_1.DEFAULT_CONFIG_FILE_NAME + ext);
19
- const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => node_path_1.default.join(siteDir, file)), fs_extra_1.default.pathExists);
19
+ const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => node_path_1.default.join(siteDir, file)), fs_1.pathExists);
20
20
  if (!configPath) {
21
21
  const relativeSiteDir = node_path_1.default.relative(process.cwd(), siteDir);
22
22
  throw new Error(logger_1.default.interpolate `No config file found in site dir code=${relativeSiteDir}.
@@ -30,7 +30,7 @@ async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
30
30
  const siteConfigPath = customConfigFilePath
31
31
  ? node_path_1.default.resolve(siteDir, customConfigFilePath)
32
32
  : await findConfig(siteDir);
33
- if (!(await fs_extra_1.default.pathExists(siteConfigPath))) {
33
+ if (!(await (0, fs_1.pathExists)(siteConfigPath))) {
34
34
  throw new Error(`Config file at "${siteConfigPath}" not found.`);
35
35
  }
36
36
  const importedConfig = await (0, utils_1.loadFreshModule)(siteConfigPath, { default: true });
@@ -11,10 +11,10 @@ exports.getLocaleList = getLocaleList;
11
11
  exports.loadI18n = loadI18n;
12
12
  const tslib_1 = require("tslib");
13
13
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
16
15
  const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
17
16
  const utils_1 = require("@docusaurus/utils");
17
+ const fs_1 = require("@docusaurus/fs");
18
18
  function inferLanguageDisplayName(locale) {
19
19
  const tryLocale = (l) => {
20
20
  try {
@@ -112,7 +112,7 @@ async function loadI18n({ siteDir, config, currentLocale, automaticBaseUrlLocali
112
112
  // By default, translations will be enabled if i18n/<locale> dir exists
113
113
  async function inferTranslate() {
114
114
  const localizationDir = node_path_1.default.resolve(siteDir, i18nConfig.path, localeConfig.path);
115
- return fs_extra_1.default.pathExists(localizationDir);
115
+ return (0, fs_1.pathExists)(localizationDir);
116
116
  }
117
117
  function getInferredBaseUrl() {
118
118
  const addLocaleSegment = locale !== i18nConfig.defaultLocale &&
@@ -10,13 +10,13 @@ exports.tryLoadSitePackageJson = tryLoadSitePackageJson;
10
10
  exports.loadPluginVersion = loadPluginVersion;
11
11
  exports.createSiteMetadata = createSiteMetadata;
12
12
  const tslib_1 = require("tslib");
13
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
14
13
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
15
14
  const utils_1 = require("@docusaurus/utils");
15
+ const fs_1 = require("@docusaurus/fs");
16
16
  async function tryLoadPackageJson(packageJsonPath) {
17
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
17
+ if (await (0, fs_1.pathExists)(packageJsonPath)) {
18
18
  try {
19
- return (await fs_extra_1.default.readJSON(packageJsonPath));
19
+ return (await (0, fs_1.readJSON)(packageJsonPath));
20
20
  }
21
21
  catch (error) {
22
22
  throw new Error(`Couldn't load package.json file at ${packageJsonPath}`, {
@@ -33,8 +33,8 @@ async function loadPluginVersion(pluginPath, siteDir) {
33
33
  let potentialPluginPackageJsonDirectory = node_path_1.default.dirname(pluginPath);
34
34
  while (potentialPluginPackageJsonDirectory !== '/') {
35
35
  const packageJsonPath = node_path_1.default.join(potentialPluginPackageJsonDirectory, 'package.json');
36
- if ((await fs_extra_1.default.pathExists(packageJsonPath)) &&
37
- (await fs_extra_1.default.lstat(packageJsonPath)).isFile()) {
36
+ if ((await (0, fs_1.pathExists)(packageJsonPath)) &&
37
+ (await fs_1.fs.lstat(packageJsonPath)).isFile()) {
38
38
  if (potentialPluginPackageJsonDirectory === siteDir) {
39
39
  // If the plugin belongs to the same docusaurus project, we classify it
40
40
  // as local plugin.
@@ -16,11 +16,11 @@ exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
16
16
  exports.loadSiteCodeTranslations = loadSiteCodeTranslations;
17
17
  const tslib_1 = require("tslib");
18
18
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
19
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
20
19
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
21
20
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
22
21
  const utils_1 = require("@docusaurus/utils");
23
22
  const utils_validation_1 = require("@docusaurus/utils-validation");
23
+ const fs_1 = require("@docusaurus/fs");
24
24
  const TranslationFileContentSchema = utils_validation_1.Joi.object()
25
25
  .pattern(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
26
26
  message: utils_validation_1.Joi.string().allow('').required(),
@@ -35,9 +35,9 @@ function ensureTranslationFileContent(content) {
35
35
  });
36
36
  }
37
37
  async function readTranslationFileContent(filePath) {
38
- if (await fs_extra_1.default.pathExists(filePath)) {
38
+ if (await (0, fs_1.pathExists)(filePath)) {
39
39
  try {
40
- const content = await fs_extra_1.default.readJSON(filePath);
40
+ const content = await (0, fs_1.readJSON)(filePath);
41
41
  ensureTranslationFileContent(content);
42
42
  return content;
43
43
  }
@@ -83,7 +83,7 @@ Maybe you should remove them? ${unknownKeys}`;
83
83
  // Avoid creating empty translation files
84
84
  if (Object.keys(mergedContent).length > 0) {
85
85
  logger_1.default.info `number=${Object.keys(mergedContent).length} translations will be written at path=${(0, utils_1.toMessageRelativeFilePath)(filePath)}.`;
86
- await fs_extra_1.default.outputFile(filePath, `${JSON.stringify(mergedContent, null, 2)}\n`);
86
+ await (0, fs_1.outputFile)(filePath, `${JSON.stringify(mergedContent, null, 2)}\n`);
87
87
  }
88
88
  }
89
89
  function getCodeTranslationsFilePath(context) {
@@ -8,12 +8,12 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createSSGParams = createSSGParams;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const utils_1 = require("@docusaurus/utils");
13
12
  const logger_1 = require("@docusaurus/logger");
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  const ssgTemplate_html_1 = tslib_1.__importDefault(require("./ssgTemplate.html"));
15
15
  async function createSSGParams({ props, serverBundlePath, clientManifestPath, }) {
16
- const manifest = await logger_1.PerfLogger.async('Read client manifest', () => fs_extra_1.default.readJSON(clientManifestPath, 'utf-8'));
16
+ const manifest = await logger_1.PerfLogger.async('Read client manifest', () => (0, fs_1.readJSON)(clientManifestPath));
17
17
  const params = {
18
18
  trailingSlash: props.siteConfig.trailingSlash,
19
19
  outDir: props.outDir,
@@ -11,10 +11,10 @@ const tslib_1 = require("tslib");
11
11
  const node_module_1 = require("node:module");
12
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
13
  const node_vm_1 = require("node:vm");
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
14
  const p_map_1 = tslib_1.__importDefault(require("p-map"));
16
15
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
17
16
  const bundler_1 = require("@docusaurus/bundler");
17
+ const fs_1 = require("@docusaurus/fs");
18
18
  const ssgTemplate_1 = require("./ssgTemplate");
19
19
  const ssgEnv_1 = require("./ssgEnv");
20
20
  const ssgUtils_1 = require("./ssgUtils");
@@ -29,7 +29,7 @@ function evaluateServerBundle({ source, serverBundlePath, }) {
29
29
  return module.exports;
30
30
  }
31
31
  async function loadAppRenderer({ serverBundlePath, }) {
32
- const source = await logger_1.PerfLogger.async(`Load server bundle`, () => fs_extra_1.default.readFile(serverBundlePath, 'utf8'));
32
+ const source = await logger_1.PerfLogger.async(`Load server bundle`, () => fs_1.fs.readFile(serverBundlePath, 'utf8'));
33
33
  const serverEntry = await logger_1.PerfLogger.async(`Evaluate server bundle`, () => evaluateServerBundle({ source, serverBundlePath }));
34
34
  if (!serverEntry?.default || typeof serverEntry.default !== 'function') {
35
35
  throw new Error(`Docusaurus Bug: server bundle export from "${serverBundlePath}" must be a function that renders the Docusaurus React app, not ${typeof serverEntry?.default}`);
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.generateHashRouterEntrypoint = generateHashRouterEntrypoint;
10
10
  exports.writeStaticFile = writeStaticFile;
11
11
  const tslib_1 = require("tslib");
12
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  function pathnameToFilename({ pathname, trailingSlash, }) {
15
15
  const outputFileName = pathname.replace(/^[/\\]/, ''); // Remove leading slashes for webpack-dev-server
16
16
  // Paths ending with .html are left untouched
@@ -44,6 +44,6 @@ async function writeStaticFile({ content, pathname, params, }) {
44
44
  trailingSlash: params.trailingSlash,
45
45
  });
46
46
  const filePath = node_path_1.default.join(params.outDir, filename);
47
- await fs_extra_1.default.ensureDir(node_path_1.default.dirname(filePath));
48
- await fs_extra_1.default.writeFile(filePath, content);
47
+ await fs_1.fs.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
48
+ await fs_1.fs.writeFile(filePath, content);
49
49
  }
@@ -11,11 +11,11 @@ exports.createAliasesForTheme = createAliasesForTheme;
11
11
  exports.loadThemeAliases = loadThemeAliases;
12
12
  exports.loadDocusaurusAliases = loadDocusaurusAliases;
13
13
  const tslib_1 = require("tslib");
14
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
15
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
15
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
16
  const utils_1 = require("@docusaurus/utils");
18
17
  const glob_1 = require("@docusaurus/glob");
18
+ const fs_1 = require("@docusaurus/fs");
19
19
  const ThemeFallbackDir = node_path_1.default.join(__dirname, '../../client/theme-fallback');
20
20
  /**
21
21
  * Order of Webpack aliases is important because one alias can shadow another.
@@ -35,7 +35,7 @@ function sortAliases(aliases) {
35
35
  return Object.fromEntries(entries);
36
36
  }
37
37
  async function createAliasesForTheme(themePath, addOriginalAlias) {
38
- if (!(await fs_extra_1.default.pathExists(themePath))) {
38
+ if (!(await (0, fs_1.pathExists)(themePath))) {
39
39
  return {};
40
40
  }
41
41
  const themeComponentFiles = await (0, glob_1.glob)(['**/*.{js,jsx,ts,tsx}'], {
@@ -102,7 +102,7 @@ async function loadDocusaurusAliases() {
102
102
  const dirPath = node_path_1.default.resolve(__dirname, '../../client/exports');
103
103
  const extensions = ['.js', '.ts', '.tsx'];
104
104
  const aliases = {};
105
- (await fs_extra_1.default.readdir(dirPath))
105
+ (await fs_1.fs.readdir(dirPath))
106
106
  .filter((fileName) => extensions.includes(node_path_1.default.extname(fileName)))
107
107
  .forEach((fileName) => {
108
108
  const fileNameWithoutExtension = node_path_1.default.basename(fileName, node_path_1.default.extname(fileName));
@@ -10,11 +10,11 @@ exports.clientDir = void 0;
10
10
  exports.excludeJS = excludeJS;
11
11
  exports.createBaseConfig = createBaseConfig;
12
12
  const tslib_1 = require("tslib");
13
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
14
13
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
15
14
  const babel_1 = require("@docusaurus/babel");
16
15
  const bundler_1 = require("@docusaurus/bundler");
17
16
  const utils_1 = require("@docusaurus/utils");
17
+ const fs_1 = require("@docusaurus/fs");
18
18
  const aliases_1 = require("./aliases");
19
19
  const BundlerCPUProfilerPlugin_1 = require("./plugins/BundlerCPUProfilerPlugin");
20
20
  const CSS_REGEX = /\.css$/i;
@@ -155,7 +155,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
155
155
  modules: [
156
156
  node_path_1.default.resolve(__dirname, '..', '..', 'node_modules'),
157
157
  'node_modules',
158
- node_path_1.default.resolve(await fs_extra_1.default.realpath(process.cwd()), 'node_modules'),
158
+ node_path_1.default.resolve(await (0, fs_1.realpath)(process.cwd()), 'node_modules'),
159
159
  ],
160
160
  },
161
161
  resolveLoader: {
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.BundlerCPUProfilerPlugin = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_inspector_1 = tslib_1.__importDefault(require("node:inspector"));
12
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const fs_1 = require("@docusaurus/fs");
13
13
  // Bundle CPU profiling plugin, contributed by the Rspack team
14
14
  // Can be opened in https://www.speedscope.app/
15
15
  // See also https://github.com/jerrykingxyz/docusaurus/pull/1
@@ -33,7 +33,7 @@ class BundlerCPUProfilerPlugin {
33
33
  console.error('Failed to generate JS CPU profile:', error);
34
34
  return;
35
35
  }
36
- fs_extra_1.default.writeFile(this.output, JSON.stringify(param.profile)).catch(console.error);
36
+ fs_1.fs.writeFile(this.output, JSON.stringify(param.profile)).catch(console.error);
37
37
  });
38
38
  });
39
39
  }
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createStaticDirectoriesCopyPlugin = createStaticDirectoriesCopyPlugin;
10
10
  const tslib_1 = require("tslib");
11
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
12
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
12
  const bundler_1 = require("@docusaurus/bundler");
13
+ const fs_1 = require("@docusaurus/fs");
14
14
  async function createStaticDirectoriesCopyPlugin({ props, }) {
15
15
  const CopyPlugin = await (0, bundler_1.getCopyPlugin)({
16
16
  currentBundler: props.currentBundler,
@@ -22,8 +22,8 @@ async function createStaticDirectoriesCopyPlugin({ props, }) {
22
22
  // in the first place (the default option should always "work").
23
23
  const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
24
24
  const staticDir = node_path_1.default.resolve(siteDir, dir);
25
- if ((await fs_extra_1.default.pathExists(staticDir)) &&
26
- (await fs_extra_1.default.readdir(staticDir)).length > 0) {
25
+ if ((await (0, fs_1.pathExists)(staticDir)) &&
26
+ (await fs_1.fs.readdir(staticDir)).length > 0) {
27
27
  return staticDir;
28
28
  }
29
29
  return '';
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.default = getHttpsConfig;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
11
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
12
  const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
14
13
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const fs_1 = require("@docusaurus/fs");
15
15
  // Ensure the certificate and key provided are valid and if not
16
16
  // throw an easy to debug error.
17
17
  //
@@ -47,14 +47,14 @@ function getExplicitHttps(options) {
47
47
  : undefined));
48
48
  }
49
49
  async function readCryptoFile(filepath, source) {
50
- if (!(await fs_extra_1.default.pathExists(filepath))) {
50
+ if (!(await (0, fs_1.pathExists)(filepath))) {
51
51
  throw new Error(logger_1.default.interpolate `You specified ${source}, but file at path path=${filepath} can't be found.`);
52
52
  }
53
53
  try {
54
54
  return {
55
55
  path: filepath,
56
56
  source,
57
- content: await fs_extra_1.default.readFile(filepath),
57
+ content: await fs_1.fs.readFile(filepath),
58
58
  };
59
59
  }
60
60
  catch (error) {
@@ -96,7 +96,7 @@ You only provided a ${cert ? 'certificate' : 'key'} (with ${fileProvided.source}
96
96
  // Return cert files if provided via CLI or env, otherwise just true or false.
97
97
  // CLI options take precedence over env vars.
98
98
  async function getHttpsConfig(options = {}) {
99
- const cwd = await fs_extra_1.default.realpath(process.cwd());
99
+ const cwd = await (0, fs_1.realpath)(process.cwd());
100
100
  const [cert, key] = await Promise.all([
101
101
  getCert(options, cwd),
102
102
  getKeyFile(options, cwd),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "4.0.0-canary-6885",
4
+ "version": "4.0.0-canary-6891",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -33,14 +33,15 @@
33
33
  "url": "https://github.com/facebook/docusaurus/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@docusaurus/babel": "4.0.0-canary-6885",
37
- "@docusaurus/bundler": "4.0.0-canary-6885",
38
- "@docusaurus/glob": "4.0.0-canary-6885",
39
- "@docusaurus/logger": "4.0.0-canary-6885",
40
- "@docusaurus/mdx-loader": "4.0.0-canary-6885",
41
- "@docusaurus/utils": "4.0.0-canary-6885",
42
- "@docusaurus/utils-common": "4.0.0-canary-6885",
43
- "@docusaurus/utils-validation": "4.0.0-canary-6885",
36
+ "@docusaurus/babel": "4.0.0-canary-6891",
37
+ "@docusaurus/bundler": "4.0.0-canary-6891",
38
+ "@docusaurus/fs": "4.0.0-canary-6891",
39
+ "@docusaurus/glob": "4.0.0-canary-6891",
40
+ "@docusaurus/logger": "4.0.0-canary-6891",
41
+ "@docusaurus/mdx-loader": "4.0.0-canary-6891",
42
+ "@docusaurus/utils": "4.0.0-canary-6891",
43
+ "@docusaurus/utils-common": "4.0.0-canary-6891",
44
+ "@docusaurus/utils-validation": "4.0.0-canary-6891",
44
45
  "boxen": "^9.0.0",
45
46
  "cli-table3": "^0.6.5",
46
47
  "combine-promises": "^1.2.0",
@@ -49,7 +50,6 @@
49
50
  "escape-html": "^1.0.3",
50
51
  "eta": "^4.6.0",
51
52
  "execa": "^10.0.1",
52
- "fs-extra": "^11.4.0",
53
53
  "html-tags": "^5.1.0",
54
54
  "leven": "^4.1.0",
55
55
  "lodash": "^4.18.1",
@@ -72,8 +72,8 @@
72
72
  "webpack-merge": "^6.0.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@docusaurus/module-type-aliases": "4.0.0-canary-6885",
76
- "@docusaurus/types": "4.0.0-canary-6885",
75
+ "@docusaurus/module-type-aliases": "4.0.0-canary-6891",
76
+ "@docusaurus/types": "4.0.0-canary-6891",
77
77
  "@total-typescript/shoehorn": "^0.1.2",
78
78
  "@types/escape-html": "^1.0.4",
79
79
  "@types/history": "^4.7.11",
@@ -87,7 +87,7 @@
87
87
  "utility-types": "^3.11.0"
88
88
  },
89
89
  "peerDependencies": {
90
- "@docusaurus/faster": "4.0.0-canary-6885",
90
+ "@docusaurus/faster": "4.0.0-canary-6891",
91
91
  "@mdx-js/react": "^3.1.1",
92
92
  "react": "^19.3.0",
93
93
  "react-dom": "^19.3.0"
@@ -100,5 +100,5 @@
100
100
  "engines": {
101
101
  "node": ">=24.21"
102
102
  },
103
- "gitHead": "7d9062fc85a858f25784b589ba163999eb653232"
103
+ "gitHead": "f276aff972dcc432c037123c6d522e6c50881e79"
104
104
  }