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

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,7 +8,7 @@
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"));
11
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
13
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
14
  const bundler_1 = require("@docusaurus/bundler");
@@ -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 promises_1.default.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,13 @@
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"));
11
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
13
  const node_os_1 = tslib_1.__importDefault(require("node:os"));
14
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
15
  const execa_1 = require("execa");
16
16
  const utils_1 = require("@docusaurus/utils");
17
+ const fs_1 = require("@docusaurus/fs");
17
18
  const site_1 = require("../server/site");
18
19
  const build_1 = require("./build/build");
19
20
  // GIT_PASS env variable should not appear in logs
@@ -51,7 +52,7 @@ async function hasGit() {
51
52
  return (await exec('git', ['--version'], { failfast: false })).exitCode === 0;
52
53
  }
53
54
  async function deploy(siteDirParam = '.', cliOptions = {}) {
54
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
55
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
55
56
  const { outDir, siteConfig, siteConfigPath } = await (0, site_1.loadContext)({
56
57
  siteDir,
57
58
  config: cliOptions.config,
@@ -146,7 +147,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
146
147
  const runDeploy = async (outputDirectory) => {
147
148
  const targetDirectory = cliOptions.targetDir ?? '.';
148
149
  const fromPath = outputDirectory;
149
- const toPath = await fs_extra_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
150
+ const toPath = await promises_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), `${projectName}-${deploymentBranch}`));
150
151
  process.chdir(toPath);
151
152
  // Clones the repo into the temp folder and checks out the target branch.
152
153
  // If the branch doesn't exist, it creates a new one based on the
@@ -168,7 +169,11 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
168
169
  await exec('git', ['rm', '-rf', targetDirectory], { log: false });
169
170
  const targetPath = node_path_1.default.join(toPath, targetDirectory);
170
171
  try {
171
- await fs_extra_1.default.copy(fromPath, targetPath);
172
+ // verbatimSymlinks: keep relative symlinks relative
173
+ await promises_1.default.cp(fromPath, targetPath, {
174
+ recursive: true,
175
+ verbatimSymlinks: true,
176
+ });
172
177
  }
173
178
  catch (err) {
174
179
  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,12 @@ 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"));
14
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
15
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
16
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
17
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
18
  const utils_1 = require("@docusaurus/utils");
19
+ const fs_1 = require("@docusaurus/fs");
19
20
  const glob_1 = require("@docusaurus/glob");
20
21
  const prompts_1 = require("./prompts");
21
22
  exports.SwizzleActions = ['wrap', 'eject'];
@@ -29,7 +30,7 @@ async function getAction(componentConfig, options) {
29
30
  return (0, prompts_1.askSwizzleAction)(componentConfig);
30
31
  }
31
32
  async function isDir(dirPath) {
32
- return ((await fs_extra_1.default.pathExists(dirPath)) && (await fs_extra_1.default.stat(dirPath)).isDirectory());
33
+ return (await (0, fs_1.pathExists)(dirPath)) && (await promises_1.default.stat(dirPath)).isDirectory();
33
34
  }
34
35
  async function eject({ siteDir, themePath, componentName, typescript, }) {
35
36
  const fromPath = node_path_1.default.join(themePath, componentName);
@@ -58,12 +59,12 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
58
59
  throw new Error(logger_1.default.interpolate `No files to copy from path=${fromPath} with glob code=${globPatternPosix}`);
59
60
  }
60
61
  const toPath = node_path_1.default.join(siteDir, utils_1.THEME_PATH);
61
- await fs_extra_1.default.ensureDir(toPath);
62
+ await promises_1.default.mkdir(toPath, { recursive: true });
62
63
  const createdFiles = await Promise.all(filesToCopy.map(async (sourceFile) => {
63
64
  const targetFile = node_path_1.default.join(toPath, node_path_1.default.relative(themePath, sourceFile));
64
65
  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, ''));
66
+ const fileContents = await promises_1.default.readFile(sourceFile, 'utf-8');
67
+ await (0, fs_1.outputFile)(targetFile, fileContents.trimStart().replace(/^\/\*.+?\*\/\s*/ms, ''));
67
68
  }
68
69
  catch (err) {
69
70
  logger_1.default.error `Could not copy file from path=${sourceFile} to path=${targetFile}`;
@@ -79,7 +80,7 @@ async function wrap({ siteDir, themePath, componentName: themeComponentName, typ
79
80
  const componentName = lodash_1.default.last(themeComponentName.split('/'));
80
81
  const wrapperComponentName = `${componentName}Wrapper`;
81
82
  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));
83
+ await promises_1.default.mkdir(node_path_1.default.resolve(siteDir, utils_1.THEME_PATH), { recursive: true });
83
84
  const toPath = node_path_1.default.resolve(siteDir, utils_1.THEME_PATH, wrapperFileName);
84
85
  const content = typescript
85
86
  ? `import type {ReactNode} from 'react';
@@ -107,6 +108,6 @@ export default function ${wrapperComponentName}(props) {
107
108
  );
108
109
  }
109
110
  `;
110
- await fs_extra_1.default.outputFile(toPath, content);
111
+ await (0, fs_1.outputFile)(toPath, content);
111
112
  return { createdFiles: [toPath] };
112
113
  }
@@ -11,11 +11,12 @@ 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"));
14
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
15
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
16
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
17
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
18
18
  const utils_1 = require("@docusaurus/utils");
19
+ const fs_1 = require("@docusaurus/fs");
19
20
  const prompts_1 = require("./prompts");
20
21
  const common_1 = require("./common");
21
22
  const tables_1 = require("./tables");
@@ -42,13 +43,13 @@ function getMissingIntermediateComponentFolderNames(componentNames) {
42
43
  }
43
44
  const skipReadDirNames = ['__test__', '__tests__', '__mocks__', '__fixtures__'];
44
45
  async function readComponentNames(themePath) {
45
- if (!(await fs_extra_1.default.pathExists(themePath))) {
46
+ if (!(await (0, fs_1.pathExists)(themePath))) {
46
47
  return [];
47
48
  }
48
49
  async function walk(dir) {
49
- const files = await Promise.all((await fs_extra_1.default.readdir(dir)).flatMap(async (file) => {
50
+ const files = await Promise.all((await promises_1.default.readdir(dir)).flatMap(async (file) => {
50
51
  const fullPath = node_path_1.default.join(dir, file);
51
- const stat = await fs_extra_1.default.stat(fullPath);
52
+ const stat = await promises_1.default.stat(fullPath);
52
53
  const isDir = stat.isDirectory();
53
54
  return { file, fullPath, isDir };
54
55
  }));
@@ -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);
@@ -8,10 +8,11 @@
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"));
11
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
12
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
14
  const glob_1 = require("@docusaurus/glob");
15
+ const fs_1 = require("@docusaurus/fs");
15
16
  const site_1 = require("../server/site");
16
17
  const init_1 = require("../server/plugins/init");
17
18
  function inferFallbackSyntax(_filepath) {
@@ -27,14 +28,14 @@ function getHeadingIdSyntax(filepath, options) {
27
28
  return options?.syntax ?? inferFallbackSyntax(filepath);
28
29
  }
29
30
  async function transformMarkdownFile(filepath, options) {
30
- const content = await fs_extra_1.default.readFile(filepath, 'utf8');
31
+ const content = await promises_1.default.readFile(filepath, 'utf8');
31
32
  const syntax = getHeadingIdSyntax(filepath, options);
32
33
  const updatedContent = (0, utils_1.writeMarkdownHeadingId)(content, {
33
34
  ...options,
34
35
  syntax,
35
36
  });
36
37
  if (content !== updatedContent) {
37
- await fs_extra_1.default.writeFile(filepath, updatedContent);
38
+ await promises_1.default.writeFile(filepath, updatedContent);
38
39
  return filepath;
39
40
  }
40
41
  return undefined;
@@ -66,14 +67,14 @@ function validateOptions(options) {
66
67
  }
67
68
  async function writeHeadingIds(siteDirParam = '.', files = [], options = {}) {
68
69
  validateOptions(options);
69
- const siteDir = await fs_extra_1.default.realpath(siteDirParam);
70
+ const siteDir = await (0, fs_1.realpath)(siteDirParam);
70
71
  const patterns = files.length ? files : await getPathsToWatch(siteDir);
71
72
  const markdownFiles = await globMarkdownFiles(patterns);
72
73
  if (markdownFiles.length === 0) {
73
74
  logger_1.default.warn `No markdown files found in siteDir path=${siteDir} for patterns: ${patterns}`;
74
75
  return;
75
76
  }
76
- const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));
77
+ const result = await Promise.all(markdownFiles.map((p) => (0, fs_1.queueFileOperation)(() => transformMarkdownFile(p, options))));
77
78
  const pathsModified = result.filter(Boolean);
78
79
  if (pathsModified.length) {
79
80
  logger_1.default.success `Heading ids added to Markdown files (number=${`${pathsModified.length}/${markdownFiles.length}`} files): ${pathsModified}`;
@@ -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,14 @@ 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"));
13
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
14
14
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
15
15
  const utils_1 = require("@docusaurus/utils");
16
+ const fs_1 = require("@docusaurus/fs");
16
17
  async function tryLoadPackageJson(packageJsonPath) {
17
- if (await fs_extra_1.default.pathExists(packageJsonPath)) {
18
+ if (await (0, fs_1.pathExists)(packageJsonPath)) {
18
19
  try {
19
- return (await fs_extra_1.default.readJSON(packageJsonPath));
20
+ return (await (0, fs_1.readJSON)(packageJsonPath));
20
21
  }
21
22
  catch (error) {
22
23
  throw new Error(`Couldn't load package.json file at ${packageJsonPath}`, {
@@ -33,8 +34,8 @@ async function loadPluginVersion(pluginPath, siteDir) {
33
34
  let potentialPluginPackageJsonDirectory = node_path_1.default.dirname(pluginPath);
34
35
  while (potentialPluginPackageJsonDirectory !== '/') {
35
36
  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()) {
37
+ if ((await (0, fs_1.pathExists)(packageJsonPath)) &&
38
+ (await promises_1.default.lstat(packageJsonPath)).isFile()) {
38
39
  if (potentialPluginPackageJsonDirectory === siteDir) {
39
40
  // If the plugin belongs to the same docusaurus project, we classify it
40
41
  // 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,7 +11,7 @@ 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"));
14
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
15
  const p_map_1 = tslib_1.__importDefault(require("p-map"));
16
16
  const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
17
17
  const bundler_1 = require("@docusaurus/bundler");
@@ -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`, () => promises_1.default.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,7 +9,7 @@ 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"));
12
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
13
13
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
14
14
  function pathnameToFilename({ pathname, trailingSlash, }) {
15
15
  const outputFileName = pathname.replace(/^[/\\]/, ''); // Remove leading slashes for webpack-dev-server
@@ -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 promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true });
48
+ await promises_1.default.writeFile(filePath, content);
49
49
  }
@@ -11,11 +11,12 @@ 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"));
14
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
15
15
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
16
16
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
17
17
  const utils_1 = require("@docusaurus/utils");
18
18
  const glob_1 = require("@docusaurus/glob");
19
+ const fs_1 = require("@docusaurus/fs");
19
20
  const ThemeFallbackDir = node_path_1.default.join(__dirname, '../../client/theme-fallback');
20
21
  /**
21
22
  * Order of Webpack aliases is important because one alias can shadow another.
@@ -35,7 +36,7 @@ function sortAliases(aliases) {
35
36
  return Object.fromEntries(entries);
36
37
  }
37
38
  async function createAliasesForTheme(themePath, addOriginalAlias) {
38
- if (!(await fs_extra_1.default.pathExists(themePath))) {
39
+ if (!(await (0, fs_1.pathExists)(themePath))) {
39
40
  return {};
40
41
  }
41
42
  const themeComponentFiles = await (0, glob_1.glob)(['**/*.{js,jsx,ts,tsx}'], {
@@ -102,7 +103,7 @@ async function loadDocusaurusAliases() {
102
103
  const dirPath = node_path_1.default.resolve(__dirname, '../../client/exports');
103
104
  const extensions = ['.js', '.ts', '.tsx'];
104
105
  const aliases = {};
105
- (await fs_extra_1.default.readdir(dirPath))
106
+ (await promises_1.default.readdir(dirPath))
106
107
  .filter((fileName) => extensions.includes(node_path_1.default.extname(fileName)))
107
108
  .forEach((fileName) => {
108
109
  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 promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
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
+ promises_1.default.writeFile(this.output, JSON.stringify(param.profile)).catch(console.error);
37
37
  });
38
38
  });
39
39
  }
@@ -9,8 +9,9 @@ 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"));
12
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
13
13
  const bundler_1 = require("@docusaurus/bundler");
14
+ const fs_1 = require("@docusaurus/fs");
14
15
  async function createStaticDirectoriesCopyPlugin({ props, }) {
15
16
  const CopyPlugin = await (0, bundler_1.getCopyPlugin)({
16
17
  currentBundler: props.currentBundler,
@@ -22,8 +23,8 @@ async function createStaticDirectoriesCopyPlugin({ props, }) {
22
23
  // in the first place (the default option should always "work").
23
24
  const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
24
25
  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) {
26
+ if ((await (0, fs_1.pathExists)(staticDir)) &&
27
+ (await promises_1.default.readdir(staticDir)).length > 0) {
27
28
  return staticDir;
28
29
  }
29
30
  return '';
@@ -8,10 +8,11 @@
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"));
11
+ const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
12
12
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
13
13
  const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
14
14
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
15
+ const fs_1 = require("@docusaurus/fs");
15
16
  // Ensure the certificate and key provided are valid and if not
16
17
  // throw an easy to debug error.
17
18
  //
@@ -47,14 +48,14 @@ function getExplicitHttps(options) {
47
48
  : undefined));
48
49
  }
49
50
  async function readCryptoFile(filepath, source) {
50
- if (!(await fs_extra_1.default.pathExists(filepath))) {
51
+ if (!(await (0, fs_1.pathExists)(filepath))) {
51
52
  throw new Error(logger_1.default.interpolate `You specified ${source}, but file at path path=${filepath} can't be found.`);
52
53
  }
53
54
  try {
54
55
  return {
55
56
  path: filepath,
56
57
  source,
57
- content: await fs_extra_1.default.readFile(filepath),
58
+ content: await promises_1.default.readFile(filepath),
58
59
  };
59
60
  }
60
61
  catch (error) {
@@ -96,7 +97,7 @@ You only provided a ${cert ? 'certificate' : 'key'} (with ${fileProvided.source}
96
97
  // Return cert files if provided via CLI or env, otherwise just true or false.
97
98
  // CLI options take precedence over env vars.
98
99
  async function getHttpsConfig(options = {}) {
99
- const cwd = await fs_extra_1.default.realpath(process.cwd());
100
+ const cwd = await (0, fs_1.realpath)(process.cwd());
100
101
  const [cert, key] = await Promise.all([
101
102
  getCert(options, cwd),
102
103
  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-6888",
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-6888",
37
+ "@docusaurus/bundler": "4.0.0-canary-6888",
38
+ "@docusaurus/fs": "4.0.0-canary-6888",
39
+ "@docusaurus/glob": "4.0.0-canary-6888",
40
+ "@docusaurus/logger": "4.0.0-canary-6888",
41
+ "@docusaurus/mdx-loader": "4.0.0-canary-6888",
42
+ "@docusaurus/utils": "4.0.0-canary-6888",
43
+ "@docusaurus/utils-common": "4.0.0-canary-6888",
44
+ "@docusaurus/utils-validation": "4.0.0-canary-6888",
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-6888",
76
+ "@docusaurus/types": "4.0.0-canary-6888",
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-6888",
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": "5019a662590dcb2722926890c1ade27194bc3b70"
104
104
  }