@docusaurus/core 4.0.0-canary-6870 → 4.0.0-canary-6872
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 +2 -2
- package/lib/commands/build/buildLocale.js +3 -3
- package/lib/commands/clear.js +5 -5
- package/lib/commands/deploy.js +4 -4
- package/lib/commands/serve.js +4 -4
- package/lib/commands/start/utils.js +2 -2
- package/lib/commands/start/watcher.js +3 -3
- package/lib/commands/start/webpack.js +2 -2
- package/lib/commands/swizzle/actions.js +8 -8
- package/lib/commands/swizzle/components.js +3 -3
- package/lib/commands/swizzle/themes.js +3 -3
- package/lib/commands/utils/clearPath.js +3 -3
- package/lib/commands/utils/openBrowser/openBrowser.js +3 -3
- package/lib/commands/writeTranslations.js +2 -2
- package/lib/server/clientModules.js +2 -2
- package/lib/server/codegen/codegenRoutes.js +6 -6
- package/lib/server/config.js +5 -5
- package/lib/server/getHostPort.js +4 -4
- package/lib/server/i18n.js +2 -2
- package/lib/server/plugins/actions.js +5 -5
- package/lib/server/plugins/configs.js +2 -2
- package/lib/server/plugins/init.js +4 -4
- package/lib/server/plugins/presets.js +2 -2
- package/lib/server/plugins/synthetic.js +2 -2
- package/lib/server/site.js +4 -4
- package/lib/server/siteMessages.js +2 -2
- package/lib/server/siteMetadata.js +5 -5
- package/lib/server/translations/translations.js +3 -3
- package/lib/server/translations/translationsExtractor.js +3 -3
- package/lib/ssg/ssgExecutor.js +3 -3
- package/lib/ssg/ssgRenderer.js +5 -5
- package/lib/ssg/ssgUtils.js +5 -5
- package/lib/webpack/aliases/index.js +9 -9
- package/lib/webpack/base.js +10 -10
- package/lib/webpack/client.js +3 -3
- package/lib/webpack/plugins/StaticDirectoriesCopyPlugin.js +2 -2
- package/lib/webpack/server.js +4 -4
- package/lib/webpack/utils/getHttpsConfig.js +10 -10
- package/package.json +13 -13
package/bin/beforeCli.mjs
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
// @ts-check
|
|
9
9
|
|
|
10
10
|
import fs from 'fs-extra';
|
|
11
|
-
import path from 'path';
|
|
12
|
-
import {createRequire} from 'module';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import {createRequire} from 'node:module';
|
|
13
13
|
import {execa} from 'execa';
|
|
14
14
|
import {logger} from '@docusaurus/logger';
|
|
15
15
|
import semver from 'semver';
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.buildLocale = buildLocale;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
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");
|
|
15
15
|
const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
|
|
@@ -96,7 +96,7 @@ async function buildLocale({ siteDir, locale, cliOptions, }) {
|
|
|
96
96
|
await logger_1.PerfLogger.async('postBuild()', () => executePluginsPostBuild({ plugins, props, collectedData }));
|
|
97
97
|
// TODO execute this in parallel to postBuild?
|
|
98
98
|
await logger_1.PerfLogger.async('Broken links checker', () => executeBrokenLinksCheck({ props, collectedData }));
|
|
99
|
-
logger_1.default.success `Generated static files in path=${
|
|
99
|
+
logger_1.default.success `Generated static files in path=${node_path_1.default.relative(process.cwd(), outDir)}.`;
|
|
100
100
|
}
|
|
101
101
|
async function executePluginsPostBuild({ plugins, props, collectedData, }) {
|
|
102
102
|
const routesBuildMetadata = lodash_1.default.mapValues(collectedData, (d) => d.metadata.public);
|
|
@@ -163,7 +163,7 @@ async function cleanupServerBundle(serverBundlePath) {
|
|
|
163
163
|
else {
|
|
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
|
-
const serverDir =
|
|
166
|
+
const serverDir = node_path_1.default.dirname(serverBundlePath);
|
|
167
167
|
await fs_extra_1.default.rm(serverDir, { recursive: true, force: true });
|
|
168
168
|
});
|
|
169
169
|
}
|
package/lib/commands/clear.js
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.clear = clear;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
15
15
|
const clearPath_1 = tslib_1.__importDefault(require("./utils/clearPath"));
|
|
@@ -19,7 +19,7 @@ async function removePath(entry) {
|
|
|
19
19
|
}
|
|
20
20
|
try {
|
|
21
21
|
await (0, clearPath_1.default)(entry.path);
|
|
22
|
-
logger_1.default.success `Removed the ${entry.description} at path=${
|
|
22
|
+
logger_1.default.success `Removed the ${entry.description} at path=${node_path_1.default.relative(process.cwd(), entry.path)}.`;
|
|
23
23
|
}
|
|
24
24
|
catch (err) {
|
|
25
25
|
logger_1.default.error `Could not remove the ${entry.description} at path=${entry.path}.`;
|
|
@@ -29,16 +29,16 @@ async function removePath(entry) {
|
|
|
29
29
|
async function clear(siteDirParam = '.') {
|
|
30
30
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
31
31
|
const generatedFolder = {
|
|
32
|
-
path:
|
|
32
|
+
path: node_path_1.default.join(siteDir, utils_1.GENERATED_FILES_DIR_NAME),
|
|
33
33
|
description: 'generated folder',
|
|
34
34
|
};
|
|
35
35
|
const buildFolder = {
|
|
36
|
-
path:
|
|
36
|
+
path: node_path_1.default.join(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME),
|
|
37
37
|
description: 'build output folder',
|
|
38
38
|
};
|
|
39
39
|
// In Yarn PnP, cache is stored in `.yarn/.cache` because n_m doesn't exist
|
|
40
40
|
const cacheFolders = ['node_modules', '.yarn'].map((p) => ({
|
|
41
|
-
path:
|
|
41
|
+
path: node_path_1.default.join(siteDir, p, '.cache'),
|
|
42
42
|
description: 'bundler persistent cache folder',
|
|
43
43
|
}));
|
|
44
44
|
await Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
|
package/lib/commands/deploy.js
CHANGED
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.deploy = deploy;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
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");
|
|
@@ -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(
|
|
149
|
+
const toPath = await fs_extra_1.default.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
|
|
@@ -166,7 +166,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
166
166
|
}
|
|
167
167
|
// Clear out any existing contents in the target directory
|
|
168
168
|
await exec('git', ['rm', '-rf', targetDirectory], { log: false });
|
|
169
|
-
const targetPath =
|
|
169
|
+
const targetPath = node_path_1.default.join(toPath, targetDirectory);
|
|
170
170
|
try {
|
|
171
171
|
await fs_extra_1.default.copy(fromPath, targetPath);
|
|
172
172
|
}
|
package/lib/commands/serve.js
CHANGED
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.serve = serve;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const node_http_1 = tslib_1.__importDefault(require("node:http"));
|
|
13
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
14
14
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
const serve_handler_1 = tslib_1.__importDefault(require("serve-handler"));
|
|
@@ -29,7 +29,7 @@ function redirect(res, location) {
|
|
|
29
29
|
async function serve(siteDirParam = '.', cliOptions = {}) {
|
|
30
30
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
31
31
|
const buildDir = cliOptions.dir ?? utils_1.DEFAULT_BUILD_DIR_NAME;
|
|
32
|
-
const outDir =
|
|
32
|
+
const outDir = node_path_1.default.resolve(siteDir, buildDir);
|
|
33
33
|
if (cliOptions.build) {
|
|
34
34
|
await (0, build_1.build)(siteDir, {
|
|
35
35
|
config: cliOptions.config,
|
|
@@ -45,7 +45,7 @@ async function serve(siteDirParam = '.', cliOptions = {}) {
|
|
|
45
45
|
customConfigFilePath: cliOptions.config,
|
|
46
46
|
});
|
|
47
47
|
const servingUrl = `http://${host}:${port}`;
|
|
48
|
-
const server =
|
|
48
|
+
const server = node_http_1.default.createServer((req, res) => {
|
|
49
49
|
// Automatically redirect requests to /baseUrl/
|
|
50
50
|
if (!req.url?.startsWith(baseUrl)) {
|
|
51
51
|
redirect(res, baseUrl);
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.createReloadableSite = createReloadableSite;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
12
|
+
const node_url_1 = tslib_1.__importDefault(require("node:url"));
|
|
13
13
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
15
15
|
const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
|
|
@@ -23,7 +23,7 @@ const pluginsUtils_1 = require("../../server/plugins/pluginsUtils");
|
|
|
23
23
|
function getOpenUrlOrigin(protocol, host, port) {
|
|
24
24
|
const isUnspecifiedHost = host === '0.0.0.0' || host === '::';
|
|
25
25
|
const prettyHost = isUnspecifiedHost ? 'localhost' : host;
|
|
26
|
-
const localUrlForBrowser =
|
|
26
|
+
const localUrlForBrowser = node_url_1.default.format({
|
|
27
27
|
protocol,
|
|
28
28
|
hostname: prettyHost,
|
|
29
29
|
port,
|
|
@@ -10,7 +10,7 @@ exports.createPollingOptions = createPollingOptions;
|
|
|
10
10
|
exports.getPluginPathsToWatch = getPluginPathsToWatch;
|
|
11
11
|
exports.setupSiteFileWatchers = setupSiteFileWatchers;
|
|
12
12
|
const tslib_1 = require("tslib");
|
|
13
|
-
const
|
|
13
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
14
14
|
const glob_1 = require("@docusaurus/glob");
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
function createPollingOptions(cliOptions) {
|
|
@@ -44,8 +44,8 @@ function getSitePathsToWatch({ props }) {
|
|
|
44
44
|
}
|
|
45
45
|
function getPluginPathsToWatch({ siteDir, plugin, }) {
|
|
46
46
|
const normalizeToSiteDir = (filepath) => {
|
|
47
|
-
if (filepath &&
|
|
48
|
-
return (0, utils_1.posixPath)(
|
|
47
|
+
if (filepath && node_path_1.default.isAbsolute(filepath)) {
|
|
48
|
+
return (0, utils_1.posixPath)(node_path_1.default.relative(siteDir, filepath));
|
|
49
49
|
}
|
|
50
50
|
return (0, utils_1.posixPath)(filepath);
|
|
51
51
|
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createWebpackDevServer = createWebpackDevServer;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
13
13
|
const bundler_1 = require("@docusaurus/bundler");
|
|
14
14
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -71,7 +71,7 @@ async function createDevServerConfig({ cliOptions, props, host, port, }) {
|
|
|
71
71
|
},
|
|
72
72
|
static: siteConfig.staticDirectories.map((dir) => ({
|
|
73
73
|
publicPath: baseUrl,
|
|
74
|
-
directory:
|
|
74
|
+
directory: node_path_1.default.resolve(siteDir, dir),
|
|
75
75
|
watch: {
|
|
76
76
|
// Useful options for our own monorepo using symlinks!
|
|
77
77
|
// See https://github.com/webpack/webpack/issues/11612#issuecomment-879259806
|
|
@@ -12,7 +12,7 @@ exports.eject = eject;
|
|
|
12
12
|
exports.wrap = wrap;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
|
-
const
|
|
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");
|
|
@@ -32,11 +32,11 @@ async function isDir(dirPath) {
|
|
|
32
32
|
return ((await fs_extra_1.default.pathExists(dirPath)) && (await fs_extra_1.default.stat(dirPath)).isDirectory());
|
|
33
33
|
}
|
|
34
34
|
async function eject({ siteDir, themePath, componentName, typescript, }) {
|
|
35
|
-
const fromPath =
|
|
35
|
+
const fromPath = node_path_1.default.join(themePath, componentName);
|
|
36
36
|
const isDirectory = await isDir(fromPath);
|
|
37
37
|
const globPattern = isDirectory
|
|
38
38
|
? // Do we really want to copy all components?
|
|
39
|
-
|
|
39
|
+
node_path_1.default.join(fromPath, '**/*')
|
|
40
40
|
: `${fromPath}.*`;
|
|
41
41
|
const globPatternPosix = (0, utils_1.posixPath)(globPattern);
|
|
42
42
|
const filesToCopy = await (0, glob_1.glob)(globPatternPosix, {
|
|
@@ -57,10 +57,10 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
|
|
|
57
57
|
// This should never happen
|
|
58
58
|
throw new Error(logger_1.default.interpolate `No files to copy from path=${fromPath} with glob code=${globPatternPosix}`);
|
|
59
59
|
}
|
|
60
|
-
const toPath =
|
|
60
|
+
const toPath = node_path_1.default.join(siteDir, utils_1.THEME_PATH);
|
|
61
61
|
await fs_extra_1.default.ensureDir(toPath);
|
|
62
62
|
const createdFiles = await Promise.all(filesToCopy.map(async (sourceFile) => {
|
|
63
|
-
const targetFile =
|
|
63
|
+
const targetFile = node_path_1.default.join(toPath, node_path_1.default.relative(themePath, sourceFile));
|
|
64
64
|
try {
|
|
65
65
|
const fileContents = await fs_extra_1.default.readFile(sourceFile, 'utf-8');
|
|
66
66
|
await fs_extra_1.default.outputFile(targetFile, fileContents.trimStart().replace(/^\/\*.+?\*\/\s*/ms, ''));
|
|
@@ -74,13 +74,13 @@ async function eject({ siteDir, themePath, componentName, typescript, }) {
|
|
|
74
74
|
return { createdFiles };
|
|
75
75
|
}
|
|
76
76
|
async function wrap({ siteDir, themePath, componentName: themeComponentName, typescript, importType = 'original', }) {
|
|
77
|
-
const isDirectory = await isDir(
|
|
77
|
+
const isDirectory = await isDir(node_path_1.default.join(themePath, themeComponentName));
|
|
78
78
|
// Top/Parent/ComponentName => ComponentName
|
|
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(
|
|
83
|
-
const toPath =
|
|
82
|
+
await fs_extra_1.default.ensureDir(node_path_1.default.resolve(siteDir, utils_1.THEME_PATH));
|
|
83
|
+
const toPath = node_path_1.default.resolve(siteDir, utils_1.THEME_PATH, wrapperFileName);
|
|
84
84
|
const content = typescript
|
|
85
85
|
? `import React, {type ReactNode} from 'react';
|
|
86
86
|
import ${componentName} from '@theme-${importType}/${themeComponentName}';
|
|
@@ -12,7 +12,7 @@ exports.getThemeComponents = getThemeComponents;
|
|
|
12
12
|
exports.getComponentName = getComponentName;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
|
-
const
|
|
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");
|
|
@@ -47,7 +47,7 @@ async function readComponentNames(themePath) {
|
|
|
47
47
|
}
|
|
48
48
|
async function walk(dir) {
|
|
49
49
|
const files = await Promise.all((await fs_extra_1.default.readdir(dir)).flatMap(async (file) => {
|
|
50
|
-
const fullPath =
|
|
50
|
+
const fullPath = node_path_1.default.join(dir, file);
|
|
51
51
|
const stat = await fs_extra_1.default.stat(fullPath);
|
|
52
52
|
const isDir = stat.isDirectory();
|
|
53
53
|
return { file, fullPath, isDir };
|
|
@@ -63,7 +63,7 @@ async function readComponentNames(themePath) {
|
|
|
63
63
|
// TODO can probably be refactored
|
|
64
64
|
/(?<!\.d)\.[jt]sx?$/.test(file.fullPath) &&
|
|
65
65
|
!/(?<!\.d)\.(?:test|tests|story|stories)\.[jt]sx?$/.test(file.fullPath)) {
|
|
66
|
-
const componentName = formatComponentName((0, utils_1.posixPath)(
|
|
66
|
+
const componentName = formatComponentName((0, utils_1.posixPath)(node_path_1.default.relative(themePath, file.fullPath)));
|
|
67
67
|
return [{ ...file, componentName }];
|
|
68
68
|
}
|
|
69
69
|
return [];
|
|
@@ -11,7 +11,7 @@ exports.getThemeNames = getThemeNames;
|
|
|
11
11
|
exports.getThemeName = getThemeName;
|
|
12
12
|
exports.getThemePath = getThemePath;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
|
-
const
|
|
14
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
15
15
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
16
16
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
17
17
|
const leven_1 = tslib_1.__importDefault(require("leven"));
|
|
@@ -88,9 +88,9 @@ function getThemePath({ plugins, themeName, typescript, }) {
|
|
|
88
88
|
const pluginInstance = getPluginByThemeName(plugins, themeName);
|
|
89
89
|
const themePath = typescript
|
|
90
90
|
? pluginInstance.instance.getTypeScriptThemePath &&
|
|
91
|
-
|
|
91
|
+
node_path_1.default.resolve(pluginInstance.instance.path, pluginInstance.instance.getTypeScriptThemePath())
|
|
92
92
|
: pluginInstance.instance.getThemePath &&
|
|
93
|
-
|
|
93
|
+
node_path_1.default.resolve(pluginInstance.instance.path, pluginInstance.instance.getThemePath());
|
|
94
94
|
if (!themePath) {
|
|
95
95
|
logger_1.default.warn(typescript
|
|
96
96
|
? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.default = clearPath;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
12
|
-
const promises_1 = require("fs/promises");
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
|
+
const promises_1 = require("node:fs/promises");
|
|
13
13
|
const logger_1 = require("@docusaurus/logger");
|
|
14
14
|
/**
|
|
15
15
|
* @param pathToClear
|
|
16
16
|
*/
|
|
17
17
|
async function clearPath(pathToClear) {
|
|
18
|
-
return logger_1.PerfLogger.async(`clearPath ${
|
|
18
|
+
return logger_1.PerfLogger.async(`clearPath ${node_path_1.default.relative(process.cwd(), pathToClear)}`, async () => {
|
|
19
19
|
await (0, promises_1.rm)(pathToClear, { recursive: true, force: true });
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -13,11 +13,11 @@ const tslib_1 = require("tslib");
|
|
|
13
13
|
// See https://github.com/facebook/docusaurus/pull/10956
|
|
14
14
|
// See https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/openBrowser.js
|
|
15
15
|
/* eslint-disable */
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const node_child_process_1 = require("node:child_process");
|
|
17
|
+
const node_util_1 = require("node:util");
|
|
18
18
|
const open_1 = tslib_1.__importStar(require("open"));
|
|
19
19
|
const logger_1 = require("@docusaurus/logger");
|
|
20
|
-
const execPromise = (0,
|
|
20
|
+
const execPromise = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
21
21
|
// Not sure if we need this, but let's keep a secret escape hatch
|
|
22
22
|
// CRA/react-dev-utils supported BROWSER/BROWSER_ARGS
|
|
23
23
|
const BrowserEnv = process.env.DOCUSAURUS_BROWSER;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.writeTranslations = writeTranslations;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
13
|
const glob_1 = require("@docusaurus/glob");
|
|
14
14
|
const site_1 = require("../server/site");
|
|
15
15
|
const init_1 = require("../server/plugins/init");
|
|
@@ -17,7 +17,7 @@ const translations_1 = require("../server/translations/translations");
|
|
|
17
17
|
const translationsExtractor_1 = require("../server/translations/translationsExtractor");
|
|
18
18
|
function resolveThemeCommonLibDir() {
|
|
19
19
|
try {
|
|
20
|
-
return
|
|
20
|
+
return node_path_1.default.dirname(require.resolve('@docusaurus/theme-common'));
|
|
21
21
|
}
|
|
22
22
|
catch {
|
|
23
23
|
return undefined;
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getAllClientModules = getAllClientModules;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
/**
|
|
13
13
|
* Runs the `getClientModules` lifecycle. The returned file paths are all
|
|
14
14
|
* absolute.
|
|
15
15
|
*/
|
|
16
16
|
function getAllClientModules(plugins) {
|
|
17
|
-
return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) =>
|
|
17
|
+
return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) => node_path_1.default.resolve(plugin.path, p)) ??
|
|
18
18
|
[]);
|
|
19
19
|
}
|
|
@@ -11,8 +11,8 @@ exports.generateRoutesCode = generateRoutesCode;
|
|
|
11
11
|
exports.generateRoutePropFilename = generateRoutePropFilename;
|
|
12
12
|
exports.generateRouteFiles = generateRouteFiles;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const node_querystring_1 = tslib_1.__importDefault(require("node:querystring"));
|
|
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
|
/** Indents every line of `str` by one level. */
|
|
@@ -94,7 +94,7 @@ function getModulePath(target) {
|
|
|
94
94
|
if (typeof target === 'string') {
|
|
95
95
|
return target;
|
|
96
96
|
}
|
|
97
|
-
const queryStr = target.query ? `?${
|
|
97
|
+
const queryStr = target.query ? `?${node_querystring_1.default.stringify(target.query)}` : '';
|
|
98
98
|
return `${target.path}${queryStr}`;
|
|
99
99
|
}
|
|
100
100
|
function genChunkNames(routeModule, prefix, name, res) {
|
|
@@ -221,9 +221,9 @@ async function generateRoutePropModule({ generatedFilesDir, route, plugin, }) {
|
|
|
221
221
|
const moduleContent = JSON.stringify(route.props);
|
|
222
222
|
// TODO we should aim to reduce this path length
|
|
223
223
|
// This adds bytes to the global module registry
|
|
224
|
-
const relativePath =
|
|
225
|
-
const modulePath =
|
|
226
|
-
const aliasedPath =
|
|
224
|
+
const relativePath = node_path_1.default.posix.join(plugin.name, plugin.id, 'p', generateRoutePropFilename(route));
|
|
225
|
+
const modulePath = node_path_1.default.posix.join(generatedFilesDir, relativePath);
|
|
226
|
+
const aliasedPath = node_path_1.default.posix.join('@generated', relativePath);
|
|
227
227
|
await (0, utils_1.generate)(generatedFilesDir, modulePath, moduleContent);
|
|
228
228
|
return aliasedPath;
|
|
229
229
|
}
|
package/lib/server/config.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.loadSiteConfig = loadSiteConfig;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
13
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -16,9 +16,9 @@ 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) =>
|
|
19
|
+
const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => node_path_1.default.join(siteDir, file)), fs_extra_1.default.pathExists);
|
|
20
20
|
if (!configPath) {
|
|
21
|
-
const relativeSiteDir =
|
|
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}.
|
|
23
23
|
Expected one of:${candidates.map(logger_1.default.code)}
|
|
24
24
|
You can provide a custom config path with the code=${'--config'} option.
|
|
@@ -28,7 +28,7 @@ You can provide a custom config path with the code=${'--config'} option.
|
|
|
28
28
|
}
|
|
29
29
|
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
33
|
if (!(await fs_extra_1.default.pathExists(siteConfigPath))) {
|
|
34
34
|
throw new Error(`Config file at "${siteConfigPath}" not found.`);
|
|
@@ -37,6 +37,6 @@ async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
|
37
37
|
const loadedConfig = typeof importedConfig === 'function'
|
|
38
38
|
? await importedConfig()
|
|
39
39
|
: await importedConfig;
|
|
40
|
-
const siteConfig = (0, configValidation_1.validateConfig)(loadedConfig,
|
|
40
|
+
const siteConfig = (0, configValidation_1.validateConfig)(loadedConfig, node_path_1.default.relative(siteDir, siteConfigPath));
|
|
41
41
|
return { siteConfig, siteConfigPath };
|
|
42
42
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.getHostPort = getHostPort;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_child_process_1 = require("node:child_process");
|
|
12
12
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
13
13
|
const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -22,11 +22,11 @@ function clearConsole() {
|
|
|
22
22
|
}
|
|
23
23
|
function getProcessForPort(port) {
|
|
24
24
|
try {
|
|
25
|
-
const processId = (0,
|
|
25
|
+
const processId = (0, node_child_process_1.execSync)(`lsof -i:${port} -P -t -sTCP:LISTEN`, execOptions)
|
|
26
26
|
.split('\n')[0]
|
|
27
27
|
.trim();
|
|
28
|
-
const directory = (0,
|
|
29
|
-
const command = (0,
|
|
28
|
+
const directory = (0, node_child_process_1.execSync)(`lsof -p ${processId} | awk '$4=="cwd" {for (i=9; i<=NF; i++) printf "%s ", $i}'`, execOptions).trim();
|
|
29
|
+
const command = (0, node_child_process_1.execSync)(`ps -o command -p ${processId} | sed -n 2p`, execOptions).replace(/\n$/, '');
|
|
30
30
|
return logger_1.default.interpolate `code=${command} subdue=${`(pid ${processId})`} in path=${directory}`;
|
|
31
31
|
}
|
|
32
32
|
catch {
|
package/lib/server/i18n.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
|
|
|
10
10
|
exports.getLocaleList = getLocaleList;
|
|
11
11
|
exports.loadI18n = loadI18n;
|
|
12
12
|
const tslib_1 = require("tslib");
|
|
13
|
-
const
|
|
13
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
14
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
15
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
16
16
|
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
@@ -111,7 +111,7 @@ async function loadI18n({ siteDir, config, currentLocale, automaticBaseUrlLocali
|
|
|
111
111
|
};
|
|
112
112
|
// By default, translations will be enabled if i18n/<locale> dir exists
|
|
113
113
|
async function inferTranslate() {
|
|
114
|
-
const localizationDir =
|
|
114
|
+
const localizationDir = node_path_1.default.resolve(siteDir, i18nConfig.path, localeConfig.path);
|
|
115
115
|
return fs_extra_1.default.pathExists(localizationDir);
|
|
116
116
|
}
|
|
117
117
|
function getInferredBaseUrl() {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createPluginActionsUtils = createPluginActionsUtils;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
13
13
|
const routeConfig_1 = require("./routeConfig");
|
|
14
14
|
// TODO refactor historical action system and make this side-effect-free
|
|
@@ -21,15 +21,15 @@ async function createPluginActionsUtils({ plugin, generatedFilesDir, baseUrl, tr
|
|
|
21
21
|
// TODO Docusaurus v4 breaking change
|
|
22
22
|
// module aliasing should be automatic
|
|
23
23
|
// we should never find local absolute FS paths in the codegen registry
|
|
24
|
-
const aliasedSource = (source) => `@generated/${(0, utils_1.posixPath)(
|
|
24
|
+
const aliasedSource = (source) => `@generated/${(0, utils_1.posixPath)(node_path_1.default.relative(generatedFilesDir, source))}`;
|
|
25
25
|
// TODO use @generated data dir here!
|
|
26
26
|
// The module registry should not contain absolute paths
|
|
27
|
-
const dataDir =
|
|
27
|
+
const dataDir = node_path_1.default.join(generatedFilesDir, plugin.name, pluginId);
|
|
28
28
|
const pluginRouteContext = {
|
|
29
29
|
name: plugin.name,
|
|
30
30
|
id: pluginId,
|
|
31
31
|
};
|
|
32
|
-
const pluginRouteContextModulePath =
|
|
32
|
+
const pluginRouteContextModulePath = node_path_1.default.join(dataDir, `__plugin.json`);
|
|
33
33
|
// TODO not ideal place to generate that file
|
|
34
34
|
// move to codegen step instead!
|
|
35
35
|
await (0, utils_1.generate)('/', pluginRouteContextModulePath, JSON.stringify(pluginRouteContext, null, 2));
|
|
@@ -51,7 +51,7 @@ async function createPluginActionsUtils({ plugin, generatedFilesDir, baseUrl, tr
|
|
|
51
51
|
});
|
|
52
52
|
},
|
|
53
53
|
async createData(name, data) {
|
|
54
|
-
const modulePath =
|
|
54
|
+
const modulePath = node_path_1.default.join(dataDir, name);
|
|
55
55
|
const dataString = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
56
56
|
await (0, utils_1.generate)(dataDir, name, dataString);
|
|
57
57
|
return modulePath;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.loadPluginConfigs = loadPluginConfigs;
|
|
10
|
-
const
|
|
10
|
+
const node_module_1 = require("node:module");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const presets_1 = require("./presets");
|
|
13
13
|
const moduleShorthand_1 = require("./moduleShorthand");
|
|
@@ -70,7 +70,7 @@ async function normalizePluginConfig(pluginConfig, configPath, pluginRequire) {
|
|
|
70
70
|
async function loadPluginConfigs(context) {
|
|
71
71
|
const preset = await (0, presets_1.loadPresets)(context);
|
|
72
72
|
const { siteConfig, siteConfigPath } = context;
|
|
73
|
-
const pluginRequire = (0,
|
|
73
|
+
const pluginRequire = (0, node_module_1.createRequire)(siteConfigPath);
|
|
74
74
|
function normalizeShorthand(pluginConfig, pluginType) {
|
|
75
75
|
if (typeof pluginConfig === 'string') {
|
|
76
76
|
return (0, moduleShorthand_1.resolveModuleName)(pluginConfig, pluginRequire, pluginType);
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.initPluginsConfigs = initPluginsConfigs;
|
|
10
10
|
exports.initPlugins = initPlugins;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const node_module_1 = require("node:module");
|
|
13
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
14
14
|
const utils_1 = require("@docusaurus/utils");
|
|
15
15
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
16
16
|
const siteMetadata_1 = require("../siteMetadata");
|
|
@@ -45,7 +45,7 @@ function onlyInitializedPlugins(initPluginsConfigsResults) {
|
|
|
45
45
|
async function initPluginsConfigs(context, pluginConfigs) {
|
|
46
46
|
// We need to resolve plugins from the perspective of the site config, as if
|
|
47
47
|
// we are using `require.resolve` on those module names.
|
|
48
|
-
const pluginRequire = (0,
|
|
48
|
+
const pluginRequire = (0, node_module_1.createRequire)(context.siteConfigPath);
|
|
49
49
|
async function doLoadPluginVersion(normalizedPluginConfig) {
|
|
50
50
|
if (normalizedPluginConfig.pluginModule?.path) {
|
|
51
51
|
const pluginPath = pluginRequire.resolve(normalizedPluginConfig.pluginModule.path);
|
|
@@ -108,7 +108,7 @@ Note that even inline/anonymous plugin functions require a 'name' property.`);
|
|
|
108
108
|
...pluginInstance,
|
|
109
109
|
options: pluginOptions,
|
|
110
110
|
version: pluginVersion,
|
|
111
|
-
path:
|
|
111
|
+
path: node_path_1.default.dirname(normalizedPluginConfig.entryPath),
|
|
112
112
|
};
|
|
113
113
|
return {
|
|
114
114
|
config: normalizedPluginConfig,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.loadPresets = loadPresets;
|
|
10
|
-
const
|
|
10
|
+
const node_module_1 = require("node:module");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
const moduleShorthand_1 = require("./moduleShorthand");
|
|
13
13
|
/**
|
|
@@ -17,7 +17,7 @@ const moduleShorthand_1 = require("./moduleShorthand");
|
|
|
17
17
|
async function loadPresets(context) {
|
|
18
18
|
// We need to resolve plugins from the perspective of the site config, as if
|
|
19
19
|
// we are using `require.resolve` on those module names.
|
|
20
|
-
const presetRequire = (0,
|
|
20
|
+
const presetRequire = (0, node_module_1.createRequire)(context.siteConfigPath);
|
|
21
21
|
const presets = context.siteConfig.presets.filter((p) => !!p);
|
|
22
22
|
async function loadPreset(presetItem) {
|
|
23
23
|
let presetModuleImport;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.createBootstrapPlugin = createBootstrapPlugin;
|
|
10
10
|
exports.createMDXFallbackPlugin = createMDXFallbackPlugin;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
13
|
const mdx_loader_1 = require("@docusaurus/mdx-loader");
|
|
14
14
|
/**
|
|
15
15
|
* Make a synthetic plugin to:
|
|
@@ -62,7 +62,7 @@ async function createMDXFallbackPlugin({ siteDir, siteConfig, }) {
|
|
|
62
62
|
const mdxLoaderItem = await (0, mdx_loader_1.createMDXLoaderItem)({
|
|
63
63
|
useCrossCompilerCache: siteConfig.future.faster.mdxCrossCompilerCache,
|
|
64
64
|
admonitions: true,
|
|
65
|
-
staticDirs: siteConfig.staticDirectories.map((dir) =>
|
|
65
|
+
staticDirs: siteConfig.staticDirectories.map((dir) => node_path_1.default.resolve(siteDir, dir)),
|
|
66
66
|
siteDir,
|
|
67
67
|
// External MDX files are always meant to be imported as partials
|
|
68
68
|
isMDXPartial: () => true,
|
package/lib/server/site.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.loadSite = loadSite;
|
|
|
11
11
|
exports.reloadSite = reloadSite;
|
|
12
12
|
exports.reloadSitePlugin = reloadSitePlugin;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
|
-
const
|
|
14
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
const logger_1 = require("@docusaurus/logger");
|
|
17
17
|
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
@@ -35,7 +35,7 @@ const siteMessages_1 = require("./siteMessages");
|
|
|
35
35
|
*/
|
|
36
36
|
async function loadContext(params) {
|
|
37
37
|
const { siteDir, outDir: baseOutDir = utils_1.DEFAULT_BUILD_DIR_NAME, locale, config: customConfigFilePath, automaticBaseUrlLocalizationDisabled, } = params;
|
|
38
|
-
const generatedFilesDir =
|
|
38
|
+
const generatedFilesDir = node_path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
|
|
39
39
|
const { siteVersion, loadSiteConfig: { siteConfig: initialSiteConfig, siteConfigPath }, } = await (0, combine_promises_1.default)({
|
|
40
40
|
siteVersion: (0, siteMetadata_1.tryLoadSitePackageJson)(siteDir).then((pkg) => pkg?.version),
|
|
41
41
|
loadSiteConfig: (0, config_1.loadSiteConfig)({
|
|
@@ -74,8 +74,8 @@ async function loadContext(params) {
|
|
|
74
74
|
// which is the case if an explicit locale baseUrl is not provided
|
|
75
75
|
// but in practice a custom locale baseUrl could be anything now
|
|
76
76
|
const outDirBaseUrl = baseUrl.replace(initialSiteConfig.baseUrl, '/');
|
|
77
|
-
const outDir =
|
|
78
|
-
const localizationDir =
|
|
77
|
+
const outDir = node_path_1.default.join(node_path_1.default.resolve(siteDir, baseOutDir), outDirBaseUrl);
|
|
78
|
+
const localizationDir = node_path_1.default.resolve(siteDir, i18n.path, (0, utils_1.getLocaleConfig)(i18n).path);
|
|
79
79
|
const siteConfig = {
|
|
80
80
|
...initialSiteConfig,
|
|
81
81
|
url: localeConfig.url,
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.collectAllSiteMessages = collectAllSiteMessages;
|
|
10
10
|
exports.emitSiteMessages = emitSiteMessages;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
13
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
14
|
const babel_1 = require("@docusaurus/babel");
|
|
15
15
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -21,7 +21,7 @@ const uselessBabelConfigMessages = async ({ site }) => {
|
|
|
21
21
|
return [
|
|
22
22
|
{
|
|
23
23
|
type: 'warning',
|
|
24
|
-
message: `Your site is using the SWC js loader. You can safely remove the Babel config file at ${logger_1.default.code(
|
|
24
|
+
message: `Your site is using the SWC js loader. You can safely remove the Babel config file at ${logger_1.default.code(node_path_1.default.relative(process.cwd(), babelConfigFilePath))}.`,
|
|
25
25
|
},
|
|
26
26
|
];
|
|
27
27
|
}
|
|
@@ -11,7 +11,7 @@ exports.loadPluginVersion = loadPluginVersion;
|
|
|
11
11
|
exports.createSiteMetadata = createSiteMetadata;
|
|
12
12
|
const tslib_1 = require("tslib");
|
|
13
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
14
|
-
const
|
|
14
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
async function tryLoadPackageJson(packageJsonPath) {
|
|
17
17
|
if (await fs_extra_1.default.pathExists(packageJsonPath)) {
|
|
@@ -27,12 +27,12 @@ async function tryLoadPackageJson(packageJsonPath) {
|
|
|
27
27
|
return undefined;
|
|
28
28
|
}
|
|
29
29
|
async function tryLoadSitePackageJson(siteDir) {
|
|
30
|
-
return tryLoadPackageJson(
|
|
30
|
+
return tryLoadPackageJson(node_path_1.default.join(siteDir, 'package.json'));
|
|
31
31
|
}
|
|
32
32
|
async function loadPluginVersion(pluginPath, siteDir) {
|
|
33
|
-
let potentialPluginPackageJsonDirectory =
|
|
33
|
+
let potentialPluginPackageJsonDirectory = node_path_1.default.dirname(pluginPath);
|
|
34
34
|
while (potentialPluginPackageJsonDirectory !== '/') {
|
|
35
|
-
const packageJsonPath =
|
|
35
|
+
const packageJsonPath = node_path_1.default.join(potentialPluginPackageJsonDirectory, 'package.json');
|
|
36
36
|
if ((await fs_extra_1.default.pathExists(packageJsonPath)) &&
|
|
37
37
|
(await fs_extra_1.default.lstat(packageJsonPath)).isFile()) {
|
|
38
38
|
if (potentialPluginPackageJsonDirectory === siteDir) {
|
|
@@ -47,7 +47,7 @@ async function loadPluginVersion(pluginPath, siteDir) {
|
|
|
47
47
|
version: packageJson?.version,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
potentialPluginPackageJsonDirectory =
|
|
50
|
+
potentialPluginPackageJsonDirectory = node_path_1.default.dirname(potentialPluginPackageJsonDirectory);
|
|
51
51
|
}
|
|
52
52
|
// In the case where a plugin is a path where no parent directory contains
|
|
53
53
|
// package.json, we can only classify it as local. Could happen if one puts a
|
|
@@ -15,7 +15,7 @@ exports.getPluginsDefaultCodeTranslations = getPluginsDefaultCodeTranslations;
|
|
|
15
15
|
exports.applyDefaultCodeTranslations = applyDefaultCodeTranslations;
|
|
16
16
|
exports.loadSiteCodeTranslations = loadSiteCodeTranslations;
|
|
17
17
|
const tslib_1 = require("tslib");
|
|
18
|
-
const
|
|
18
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
19
19
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
20
20
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
21
21
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
@@ -87,7 +87,7 @@ Maybe you should remove them? ${unknownKeys}`;
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
function getCodeTranslationsFilePath(context) {
|
|
90
|
-
return
|
|
90
|
+
return node_path_1.default.join(context.localizationDir, utils_1.CODE_TRANSLATIONS_FILE_NAME);
|
|
91
91
|
}
|
|
92
92
|
async function readCodeTranslationFileContent(context) {
|
|
93
93
|
return readTranslationFileContent(getCodeTranslationsFilePath(context));
|
|
@@ -115,7 +115,7 @@ function getPluginTranslationFilePath({ localizationDir, plugin, translationFile
|
|
|
115
115
|
pluginId: plugin.options.id,
|
|
116
116
|
});
|
|
117
117
|
const filePath = addTranslationFileExtension(translationFilePath);
|
|
118
|
-
return
|
|
118
|
+
return node_path_1.default.join(dirPath, filePath);
|
|
119
119
|
}
|
|
120
120
|
async function writePluginTranslations({ localizationDir, plugin, translationFile, options, }) {
|
|
121
121
|
const filePath = getPluginTranslationFilePath({
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.extractSiteSourceCodeTranslations = extractSiteSourceCodeTranslations;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
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
15
|
const babel_1 = require("@docusaurus/babel");
|
|
16
16
|
function getSiteSourceCodeFilePaths(siteDir) {
|
|
17
|
-
return [
|
|
17
|
+
return [node_path_1.default.join(siteDir, utils_1.SRC_DIR_NAME)];
|
|
18
18
|
}
|
|
19
19
|
function getPluginSourceCodeFilePaths(plugin) {
|
|
20
20
|
// The getPathsToWatch() generally returns the js/jsx/ts/tsx/md/mdx file paths
|
|
@@ -27,7 +27,7 @@ function getPluginSourceCodeFilePaths(plugin) {
|
|
|
27
27
|
if (themePath) {
|
|
28
28
|
codePaths.push(themePath);
|
|
29
29
|
}
|
|
30
|
-
return codePaths.map((p) =>
|
|
30
|
+
return codePaths.map((p) => node_path_1.default.resolve(plugin.path, p));
|
|
31
31
|
}
|
|
32
32
|
async function getSourceCodeFilePaths(siteDir, plugins) {
|
|
33
33
|
const sitePaths = getSiteSourceCodeFilePaths(siteDir);
|
package/lib/ssg/ssgExecutor.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.executeSSG = executeSSG;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const path = tslib_1.__importStar(require("path"));
|
|
11
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
12
12
|
const node_url_1 = require("node:url");
|
|
13
|
-
const
|
|
13
|
+
const node_os_1 = tslib_1.__importDefault(require("node:os"));
|
|
14
14
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
15
15
|
const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
|
|
16
16
|
const ssgParams_1 = require("./ssgParams");
|
|
@@ -34,7 +34,7 @@ function getNumberOfThreads(pathnames) {
|
|
|
34
34
|
return ssgEnv_1.SSGWorkerThreadCount;
|
|
35
35
|
}
|
|
36
36
|
// See also https://github.com/tinylibs/tinypool/pull/108
|
|
37
|
-
const cpuCount =
|
|
37
|
+
const cpuCount = node_os_1.default.availableParallelism();
|
|
38
38
|
return inferNumberOfThreads({
|
|
39
39
|
pageCount: pathnames.length,
|
|
40
40
|
cpuCount,
|
package/lib/ssg/ssgRenderer.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.loadSSGRenderer = loadSSGRenderer;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
11
|
+
const node_module_1 = require("node:module");
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
|
+
const node_vm_1 = require("node:vm");
|
|
14
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
15
|
const p_map_1 = tslib_1.__importDefault(require("p-map"));
|
|
16
16
|
const logger_1 = tslib_1.__importStar(require("@docusaurus/logger"));
|
|
@@ -23,9 +23,9 @@ const ssgUtils_1 = require("./ssgUtils");
|
|
|
23
23
|
// that already isolate it from the main Docusaurus process
|
|
24
24
|
// Running in the current context is faster and avoids reading all the globals
|
|
25
25
|
function evaluateServerBundle({ source, serverBundlePath, }) {
|
|
26
|
-
const moduleFunction = (0,
|
|
26
|
+
const moduleFunction = (0, node_vm_1.compileFunction)(source, ['exports', 'require', 'module', '__filename', '__dirname'], { filename: serverBundlePath });
|
|
27
27
|
const module = { exports: {} };
|
|
28
|
-
moduleFunction.call(module.exports, module.exports, (0,
|
|
28
|
+
moduleFunction.call(module.exports, module.exports, (0, node_module_1.createRequire)(serverBundlePath), module, serverBundlePath, node_path_1.default.dirname(serverBundlePath));
|
|
29
29
|
return module.exports;
|
|
30
30
|
}
|
|
31
31
|
async function loadAppRenderer({ serverBundlePath, }) {
|
package/lib/ssg/ssgUtils.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.generateHashRouterEntrypoint = generateHashRouterEntrypoint;
|
|
|
10
10
|
exports.writeStaticFile = writeStaticFile;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
|
-
const
|
|
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
|
|
16
16
|
// Paths ending with .html are left untouched
|
|
@@ -19,12 +19,12 @@ function pathnameToFilename({ pathname, trailingSlash, }) {
|
|
|
19
19
|
}
|
|
20
20
|
// Legacy retro-compatible behavior
|
|
21
21
|
if (typeof trailingSlash === 'undefined') {
|
|
22
|
-
return
|
|
22
|
+
return node_path_1.default.join(outputFileName, 'index.html');
|
|
23
23
|
}
|
|
24
24
|
// New behavior: we can say if we prefer file/folder output
|
|
25
25
|
// Useful resource: https://github.com/slorber/trailing-slash-guide
|
|
26
26
|
if (pathname === '' || pathname.endsWith('/') || trailingSlash) {
|
|
27
|
-
return
|
|
27
|
+
return node_path_1.default.join(outputFileName, 'index.html');
|
|
28
28
|
}
|
|
29
29
|
return `${outputFileName}.html`;
|
|
30
30
|
}
|
|
@@ -43,7 +43,7 @@ async function writeStaticFile({ content, pathname, params, }) {
|
|
|
43
43
|
pathname: removeBaseUrl(pathname, params.baseUrl),
|
|
44
44
|
trailingSlash: params.trailingSlash,
|
|
45
45
|
});
|
|
46
|
-
const filePath =
|
|
47
|
-
await fs_extra_1.default.ensureDir(
|
|
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
48
|
await fs_extra_1.default.writeFile(filePath, content);
|
|
49
49
|
}
|
|
@@ -12,11 +12,11 @@ exports.loadThemeAliases = loadThemeAliases;
|
|
|
12
12
|
exports.loadDocusaurusAliases = loadDocusaurusAliases;
|
|
13
13
|
const tslib_1 = require("tslib");
|
|
14
14
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
15
|
-
const
|
|
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 ThemeFallbackDir =
|
|
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.
|
|
22
22
|
* This ensures `@theme/NavbarItem` alias is after
|
|
@@ -50,7 +50,7 @@ async function createAliasesForTheme(themePath, addOriginalAlias) {
|
|
|
50
50
|
});
|
|
51
51
|
const aliases = {};
|
|
52
52
|
themeComponentFiles.forEach((relativeSource) => {
|
|
53
|
-
const filePath =
|
|
53
|
+
const filePath = node_path_1.default.join(themePath, relativeSource);
|
|
54
54
|
const fileName = (0, utils_1.fileToPath)(relativeSource);
|
|
55
55
|
const aliasName = (0, utils_1.posixPath)((0, utils_1.normalizeUrl)(['@theme', fileName]).replace(/\/$/, ''));
|
|
56
56
|
aliases[aliasName] = filePath;
|
|
@@ -88,9 +88,9 @@ async function createThemeAliases(themePaths, userThemePaths) {
|
|
|
88
88
|
}
|
|
89
89
|
function loadThemeAliases({ siteDir, plugins, }) {
|
|
90
90
|
const pluginThemes = plugins
|
|
91
|
-
.map((plugin) => plugin.getThemePath &&
|
|
91
|
+
.map((plugin) => plugin.getThemePath && node_path_1.default.resolve(plugin.path, plugin.getThemePath()))
|
|
92
92
|
.filter((x) => Boolean(x));
|
|
93
|
-
const userTheme =
|
|
93
|
+
const userTheme = node_path_1.default.resolve(siteDir, utils_1.THEME_PATH);
|
|
94
94
|
return createThemeAliases([ThemeFallbackDir, ...pluginThemes], [userTheme]);
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
@@ -99,15 +99,15 @@ function loadThemeAliases({ siteDir, plugins, }) {
|
|
|
99
99
|
* aliases instead.
|
|
100
100
|
*/
|
|
101
101
|
async function loadDocusaurusAliases() {
|
|
102
|
-
const dirPath =
|
|
102
|
+
const dirPath = node_path_1.default.resolve(__dirname, '../../client/exports');
|
|
103
103
|
const extensions = ['.js', '.ts', '.tsx'];
|
|
104
104
|
const aliases = {};
|
|
105
105
|
(await fs_extra_1.default.readdir(dirPath))
|
|
106
|
-
.filter((fileName) => extensions.includes(
|
|
106
|
+
.filter((fileName) => extensions.includes(node_path_1.default.extname(fileName)))
|
|
107
107
|
.forEach((fileName) => {
|
|
108
|
-
const fileNameWithoutExtension =
|
|
108
|
+
const fileNameWithoutExtension = node_path_1.default.basename(fileName, node_path_1.default.extname(fileName));
|
|
109
109
|
const aliasName = `@docusaurus/${fileNameWithoutExtension}`;
|
|
110
|
-
aliases[aliasName] =
|
|
110
|
+
aliases[aliasName] = node_path_1.default.resolve(dirPath, fileName);
|
|
111
111
|
});
|
|
112
112
|
return aliases;
|
|
113
113
|
}
|
package/lib/webpack/base.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.excludeJS = excludeJS;
|
|
|
11
11
|
exports.createBaseConfig = createBaseConfig;
|
|
12
12
|
const tslib_1 = require("tslib");
|
|
13
13
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
14
|
-
const
|
|
14
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
15
15
|
const babel_1 = require("@docusaurus/babel");
|
|
16
16
|
const bundler_1 = require("@docusaurus/bundler");
|
|
17
17
|
const utils_1 = require("@docusaurus/utils");
|
|
@@ -19,7 +19,7 @@ const aliases_1 = require("./aliases");
|
|
|
19
19
|
const BundlerCPUProfilerPlugin_1 = require("./plugins/BundlerCPUProfilerPlugin");
|
|
20
20
|
const CSS_REGEX = /\.css$/i;
|
|
21
21
|
const CSS_MODULE_REGEX = /\.module\.css$/i;
|
|
22
|
-
exports.clientDir =
|
|
22
|
+
exports.clientDir = node_path_1.default.join(__dirname, '..', 'client');
|
|
23
23
|
function getReactAliases(siteDir) {
|
|
24
24
|
// Escape hatch
|
|
25
25
|
if (process.env.DOCUSAURUS_NO_REACT_ALIASES) {
|
|
@@ -27,9 +27,9 @@ function getReactAliases(siteDir) {
|
|
|
27
27
|
}
|
|
28
28
|
const resolveSitePkg = (id) => require.resolve(id, { paths: [siteDir] });
|
|
29
29
|
return {
|
|
30
|
-
react:
|
|
31
|
-
'react-dom':
|
|
32
|
-
'@mdx-js/react':
|
|
30
|
+
react: node_path_1.default.dirname(resolveSitePkg('react/package.json')),
|
|
31
|
+
'react-dom': node_path_1.default.dirname(resolveSitePkg('react-dom/package.json')),
|
|
32
|
+
'@mdx-js/react': node_path_1.default.dirname(resolveSitePkg('@mdx-js/react')),
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function excludeJS(modulePath) {
|
|
@@ -71,7 +71,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
|
|
|
71
71
|
function getCacheBuildDependencies() {
|
|
72
72
|
return [
|
|
73
73
|
__filename,
|
|
74
|
-
|
|
74
|
+
node_path_1.default.join(__dirname, isServer ? 'server.js' : 'client.js'),
|
|
75
75
|
// Docusaurus config changes can affect MDX/JSX compilation, so we'd
|
|
76
76
|
// rather evict the cache.
|
|
77
77
|
// See https://github.com/questdb/questdb.io/issues/493
|
|
@@ -136,7 +136,7 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
|
|
|
136
136
|
// Allow resolution of url("/fonts/xyz.ttf") by webpack
|
|
137
137
|
// See https://webpack.js.org/configuration/resolve/#resolveroots
|
|
138
138
|
// See https://github.com/webpack-contrib/css-loader/issues/1256
|
|
139
|
-
...siteConfig.staticDirectories.map((dir) =>
|
|
139
|
+
...siteConfig.staticDirectories.map((dir) => node_path_1.default.resolve(siteDir, dir)),
|
|
140
140
|
siteDir,
|
|
141
141
|
process.cwd(),
|
|
142
142
|
],
|
|
@@ -153,13 +153,13 @@ async function createBaseConfig({ props, isServer, minify, faster, configureWebp
|
|
|
153
153
|
// own node_modules, but core depends on core-js@2, we should use
|
|
154
154
|
// core-js@2.
|
|
155
155
|
modules: [
|
|
156
|
-
|
|
156
|
+
node_path_1.default.resolve(__dirname, '..', '..', 'node_modules'),
|
|
157
157
|
'node_modules',
|
|
158
|
-
|
|
158
|
+
node_path_1.default.resolve(await fs_extra_1.default.realpath(process.cwd()), 'node_modules'),
|
|
159
159
|
],
|
|
160
160
|
},
|
|
161
161
|
resolveLoader: {
|
|
162
|
-
modules: ['node_modules',
|
|
162
|
+
modules: ['node_modules', node_path_1.default.join(siteDir, 'node_modules')],
|
|
163
163
|
},
|
|
164
164
|
optimization: {
|
|
165
165
|
// The optimization.mergeDuplicateChunks is expensive
|
package/lib/webpack/client.js
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.createStartClientConfig = createStartClientConfig;
|
|
10
10
|
exports.createBuildClientConfig = createBuildClientConfig;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
13
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
14
14
|
const react_loadable_ssr_addon_v5_slorber_1 = tslib_1.__importDefault(require("react-loadable-ssr-addon-v5-slorber"));
|
|
15
15
|
const bundler_1 = require("@docusaurus/bundler");
|
|
@@ -35,7 +35,7 @@ async function createBaseClientConfig({ props, hydrate, minify, faster, configur
|
|
|
35
35
|
// Useless, disabled on purpose (errors on existing sites with no
|
|
36
36
|
// browserslist config)
|
|
37
37
|
// target: 'browserslist',
|
|
38
|
-
entry:
|
|
38
|
+
entry: node_path_1.default.resolve(__dirname, '../client/clientEntry.js'),
|
|
39
39
|
optimization: {
|
|
40
40
|
// Keep the runtime chunk separated to enable long term caching
|
|
41
41
|
// https://x.com/wSokra/status/969679223278505985
|
|
@@ -99,7 +99,7 @@ async function createBuildClientConfig({ props, minify, faster, configureWebpack
|
|
|
99
99
|
// With the hash router, we don't hydrate the React app, even in build mode!
|
|
100
100
|
// This is because it will always be a client-rendered React app
|
|
101
101
|
const hydrate = router !== 'hash';
|
|
102
|
-
const clientManifestPath =
|
|
102
|
+
const clientManifestPath = node_path_1.default.join(generatedFilesDir, 'client-manifest.json');
|
|
103
103
|
const config = (0, webpack_merge_1.default)(await createBaseClientConfig({
|
|
104
104
|
props,
|
|
105
105
|
minify,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createStaticDirectoriesCopyPlugin = createStaticDirectoriesCopyPlugin;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
13
|
const bundler_1 = require("@docusaurus/bundler");
|
|
14
14
|
async function createStaticDirectoriesCopyPlugin({ props, }) {
|
|
@@ -21,7 +21,7 @@ async function createStaticDirectoriesCopyPlugin({ props, }) {
|
|
|
21
21
|
// just silently filter them out, because user could have never configured it
|
|
22
22
|
// in the first place (the default option should always "work").
|
|
23
23
|
const staticDirectories = (await Promise.all(staticDirectoriesOption.map(async (dir) => {
|
|
24
|
-
const staticDir =
|
|
24
|
+
const staticDir = node_path_1.default.resolve(siteDir, dir);
|
|
25
25
|
if ((await fs_extra_1.default.pathExists(staticDir)) &&
|
|
26
26
|
(await fs_extra_1.default.readdir(staticDir)).length > 0) {
|
|
27
27
|
return staticDir;
|
package/lib/webpack/server.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.default = createServerConfig;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
11
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
12
12
|
const webpack_merge_1 = tslib_1.__importDefault(require("webpack-merge"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
14
|
const bundler_1 = require("@docusaurus/bundler");
|
|
@@ -25,12 +25,12 @@ async function createServerConfig({ props, configureWebpackUtils, }) {
|
|
|
25
25
|
currentBundler: props.currentBundler,
|
|
26
26
|
});
|
|
27
27
|
const outputFilename = 'server.bundle.js';
|
|
28
|
-
const outputDir =
|
|
29
|
-
const serverBundlePath =
|
|
28
|
+
const outputDir = node_path_1.default.join(props.outDir, '__server');
|
|
29
|
+
const serverBundlePath = node_path_1.default.join(outputDir, outputFilename);
|
|
30
30
|
const config = (0, webpack_merge_1.default)(baseConfig, {
|
|
31
31
|
target: `node${utils_1.NODE_MAJOR_VERSION}.${utils_1.NODE_MINOR_VERSION}`,
|
|
32
32
|
entry: {
|
|
33
|
-
main:
|
|
33
|
+
main: node_path_1.default.resolve(__dirname, '../client/serverEntry.js'),
|
|
34
34
|
},
|
|
35
35
|
output: {
|
|
36
36
|
path: outputDir,
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.default = getHttpsConfig;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
13
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
14
14
|
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
15
|
// Ensure the certificate and key provided are valid and if not
|
|
16
16
|
// throw an easy to debug error.
|
|
@@ -21,14 +21,14 @@ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
|
21
21
|
function validateKeyAndCerts({ cert, key }) {
|
|
22
22
|
let certPublicKey;
|
|
23
23
|
try {
|
|
24
|
-
certPublicKey = new
|
|
24
|
+
certPublicKey = new node_crypto_1.default.X509Certificate(cert.content).publicKey;
|
|
25
25
|
}
|
|
26
26
|
catch (error) {
|
|
27
27
|
throw new Error(logger_1.default.interpolate `The certificate path=${cert.path} is invalid.`, { cause: error });
|
|
28
28
|
}
|
|
29
29
|
let keyPublicKey;
|
|
30
30
|
try {
|
|
31
|
-
keyPublicKey =
|
|
31
|
+
keyPublicKey = node_crypto_1.default.createPublicKey(node_crypto_1.default.createPrivateKey(key.content));
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
34
|
throw new Error(logger_1.default.interpolate `The certificate key path=${key.path} is invalid.`, { cause: error });
|
|
@@ -63,25 +63,25 @@ async function readCryptoFile(filepath, source) {
|
|
|
63
63
|
}
|
|
64
64
|
function getCert(options, cwd) {
|
|
65
65
|
if (options.sslCert) {
|
|
66
|
-
return readCryptoFile(
|
|
66
|
+
return readCryptoFile(node_path_1.default.resolve(cwd, options.sslCert), 'CLI arg --ssl-cert');
|
|
67
67
|
}
|
|
68
68
|
if (process.env.DOCUSAURUS_SSL_CRT_FILE) {
|
|
69
|
-
return readCryptoFile(
|
|
69
|
+
return readCryptoFile(node_path_1.default.resolve(cwd, process.env.DOCUSAURUS_SSL_CRT_FILE), 'env DOCUSAURUS_SSL_CRT_FILE');
|
|
70
70
|
}
|
|
71
71
|
if (process.env.SSL_CRT_FILE) {
|
|
72
|
-
return readCryptoFile(
|
|
72
|
+
return readCryptoFile(node_path_1.default.resolve(cwd, process.env.SSL_CRT_FILE), 'env SSL_CRT_FILE');
|
|
73
73
|
}
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
function getKeyFile(options, cwd) {
|
|
77
77
|
if (options.sslKey) {
|
|
78
|
-
return readCryptoFile(
|
|
78
|
+
return readCryptoFile(node_path_1.default.resolve(cwd, options.sslKey), 'CLI arg --ssl-key');
|
|
79
79
|
}
|
|
80
80
|
if (process.env.DOCUSAURUS_SSL_KEY_FILE) {
|
|
81
|
-
return readCryptoFile(
|
|
81
|
+
return readCryptoFile(node_path_1.default.resolve(cwd, process.env.DOCUSAURUS_SSL_KEY_FILE), 'env DOCUSAURUS_SSL_KEY_FILE');
|
|
82
82
|
}
|
|
83
83
|
if (process.env.SSL_KEY_FILE) {
|
|
84
|
-
return readCryptoFile(
|
|
84
|
+
return readCryptoFile(node_path_1.default.resolve(cwd, process.env.SSL_KEY_FILE), 'env SSL_KEY_FILE');
|
|
85
85
|
}
|
|
86
86
|
return null;
|
|
87
87
|
}
|
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-
|
|
4
|
+
"version": "4.0.0-canary-6872",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"url": "https://github.com/facebook/docusaurus/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@docusaurus/babel": "4.0.0-canary-
|
|
37
|
-
"@docusaurus/bundler": "4.0.0-canary-
|
|
38
|
-
"@docusaurus/glob": "4.0.0-canary-
|
|
39
|
-
"@docusaurus/logger": "4.0.0-canary-
|
|
40
|
-
"@docusaurus/mdx-loader": "4.0.0-canary-
|
|
41
|
-
"@docusaurus/utils": "4.0.0-canary-
|
|
42
|
-
"@docusaurus/utils-common": "4.0.0-canary-
|
|
43
|
-
"@docusaurus/utils-validation": "4.0.0-canary-
|
|
36
|
+
"@docusaurus/babel": "4.0.0-canary-6872",
|
|
37
|
+
"@docusaurus/bundler": "4.0.0-canary-6872",
|
|
38
|
+
"@docusaurus/glob": "4.0.0-canary-6872",
|
|
39
|
+
"@docusaurus/logger": "4.0.0-canary-6872",
|
|
40
|
+
"@docusaurus/mdx-loader": "4.0.0-canary-6872",
|
|
41
|
+
"@docusaurus/utils": "4.0.0-canary-6872",
|
|
42
|
+
"@docusaurus/utils-common": "4.0.0-canary-6872",
|
|
43
|
+
"@docusaurus/utils-validation": "4.0.0-canary-6872",
|
|
44
44
|
"boxen": "^9.0.0",
|
|
45
45
|
"cli-table3": "^0.6.5",
|
|
46
46
|
"combine-promises": "^1.2.0",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"webpack-merge": "^6.0.1"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@docusaurus/module-type-aliases": "4.0.0-canary-
|
|
77
|
-
"@docusaurus/types": "4.0.0-canary-
|
|
76
|
+
"@docusaurus/module-type-aliases": "4.0.0-canary-6872",
|
|
77
|
+
"@docusaurus/types": "4.0.0-canary-6872",
|
|
78
78
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
79
79
|
"@types/escape-html": "^1.0.4",
|
|
80
80
|
"@types/history": "^4.7.11",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"utility-types": "^3.11.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
|
-
"@docusaurus/faster": "4.0.0-canary-
|
|
91
|
+
"@docusaurus/faster": "4.0.0-canary-6872",
|
|
92
92
|
"@mdx-js/react": "^3.1.1",
|
|
93
93
|
"react": "^19.3.0",
|
|
94
94
|
"react-dom": "^19.3.0"
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"engines": {
|
|
102
102
|
"node": ">=24.21"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "97ddb0451f086d8a1c20967f0d324d667dc58ebf"
|
|
105
105
|
}
|