@docusaurus/core 2.0.0-beta.ff31de0ff → 2.0.1
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/README.md +1 -0
- package/bin/beforeCli.mjs +140 -0
- package/bin/docusaurus.mjs +223 -0
- package/lib/babel/preset.d.ts +8 -3
- package/lib/babel/preset.js +10 -8
- package/lib/client/App.d.ts +2 -3
- package/lib/client/App.js +31 -28
- package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
- package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
- package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
- package/lib/client/ClientLifecyclesDispatcher.js +39 -0
- package/lib/client/LinksCollector.d.ts +3 -3
- package/lib/client/LinksCollector.js +8 -13
- package/lib/client/PendingNavigation.d.ts +17 -3
- package/lib/client/PendingNavigation.js +47 -72
- package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
- package/lib/client/SiteMetadataDefaults.js +21 -0
- package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
- package/lib/client/browserContext.js +22 -0
- package/lib/client/clientEntry.js +14 -9
- package/lib/client/docusaurus.d.ts +12 -6
- package/lib/client/docusaurus.js +30 -43
- package/lib/client/docusaurusContext.d.ts +12 -0
- package/lib/client/docusaurusContext.js +25 -0
- package/lib/client/exports/BrowserOnly.d.ts +3 -5
- package/lib/client/exports/BrowserOnly.js +14 -7
- package/lib/client/exports/ComponentCreator.d.ts +6 -2
- package/lib/client/exports/ComponentCreator.js +75 -42
- package/lib/client/exports/ErrorBoundary.d.ts +18 -0
- package/lib/client/exports/ErrorBoundary.js +37 -0
- package/lib/client/exports/ExecutionEnvironment.js +7 -8
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.d.ts +2 -2
- package/lib/client/exports/Interpolate.js +20 -49
- package/lib/client/exports/Link.d.ts +4 -10
- package/lib/client/exports/Link.js +44 -38
- package/lib/client/exports/Translate.d.ts +1 -1
- package/lib/client/exports/Translate.js +14 -9
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useBaseUrl.js +11 -14
- package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
- package/lib/client/exports/useDocusaurusContext.js +3 -9
- package/lib/client/exports/useGlobalData.d.ts +4 -3
- package/lib/client/exports/useGlobalData.js +8 -15
- package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/exports/useRouteContext.d.ts +8 -0
- package/lib/client/exports/useRouteContext.js +15 -0
- package/lib/client/flat.d.ts +12 -2
- package/lib/client/flat.js +19 -15
- package/lib/client/normalizeLocation.d.ts +2 -5
- package/lib/client/normalizeLocation.js +14 -10
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +12 -32
- package/lib/client/preload.d.ts +3 -4
- package/lib/client/preload.js +5 -12
- package/lib/client/routeContext.d.ts +13 -0
- package/lib/client/routeContext.js +31 -0
- package/lib/client/serverEntry.d.ts +10 -0
- package/lib/client/serverEntry.js +109 -136
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +45 -0
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +2 -26
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +50 -116
- package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
- package/lib/client/theme-fallback/NotFound/index.js +19 -18
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -6
- package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
- package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
- package/lib/commands/build.d.ts +6 -2
- package/lib/commands/build.js +81 -64
- package/lib/commands/clear.d.ts +7 -1
- package/lib/commands/clear.js +34 -21
- package/lib/commands/deploy.d.ts +5 -2
- package/lib/commands/deploy.js +102 -81
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +9 -11
- package/lib/commands/serve.d.ts +8 -2
- package/lib/commands/serve.js +40 -20
- package/lib/commands/start.d.ts +9 -2
- package/lib/commands/start.js +111 -101
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +106 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +56 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +200 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +84 -0
- package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
- package/lib/commands/swizzle/context.js +24 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +119 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
- package/lib/commands/swizzle/tables.js +113 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +106 -0
- package/lib/commands/writeHeadingIds.d.ts +2 -6
- package/lib/commands/writeHeadingIds.js +22 -81
- package/lib/commands/writeTranslations.d.ts +4 -5
- package/lib/commands/writeTranslations.js +48 -28
- package/lib/index.d.ts +9 -9
- package/lib/index.js +14 -14
- package/lib/server/brokenLinks.d.ts +4 -17
- package/lib/server/brokenLinks.js +67 -56
- package/lib/server/clientModules.d.ts +12 -0
- package/lib/server/clientModules.js +20 -0
- package/lib/server/config.d.ts +5 -2
- package/lib/server/config.js +29 -6
- package/lib/server/configValidation.d.ts +5 -3
- package/lib/server/configValidation.js +105 -44
- package/lib/server/getHostPort.d.ts +14 -0
- package/lib/server/getHostPort.js +79 -0
- package/lib/server/htmlTags.d.ts +12 -0
- package/lib/server/htmlTags.js +62 -0
- package/lib/server/i18n.d.ts +3 -13
- package/lib/server/i18n.js +21 -55
- package/lib/server/index.d.ts +28 -6
- package/lib/server/index.js +86 -173
- package/lib/server/plugins/configs.d.ts +51 -0
- package/lib/server/plugins/configs.js +101 -0
- package/lib/server/plugins/index.d.ts +10 -10
- package/lib/server/plugins/index.js +76 -128
- package/lib/server/plugins/init.d.ts +6 -9
- package/lib/server/plugins/init.js +44 -109
- package/lib/server/plugins/moduleShorthand.d.ts +9 -0
- package/lib/server/plugins/moduleShorthand.js +46 -0
- package/lib/server/plugins/pluginIds.d.ts +6 -2
- package/lib/server/plugins/pluginIds.js +12 -7
- package/lib/server/plugins/presets.d.ts +12 -0
- package/lib/server/plugins/presets.js +49 -0
- package/lib/server/plugins/routeConfig.d.ts +11 -0
- package/lib/server/plugins/routeConfig.js +54 -0
- package/lib/server/plugins/synthetic.d.ts +20 -0
- package/lib/server/plugins/synthetic.js +111 -0
- package/lib/server/routes.d.ts +39 -7
- package/lib/server/routes.js +182 -95
- package/lib/server/siteMetadata.d.ts +12 -0
- package/lib/server/siteMetadata.js +81 -0
- package/lib/server/translations/translations.d.ts +16 -22
- package/lib/server/translations/translations.js +41 -73
- package/lib/server/translations/translationsExtractor.d.ts +10 -5
- package/lib/server/translations/translationsExtractor.js +158 -122
- package/lib/server/utils.d.ts +9 -3
- package/lib/server/utils.js +7 -9
- package/lib/webpack/aliases/index.d.ts +34 -0
- package/lib/webpack/aliases/index.js +106 -0
- package/lib/webpack/base.d.ts +3 -4
- package/lib/webpack/base.js +56 -58
- package/lib/webpack/client.d.ts +3 -3
- package/lib/webpack/client.js +12 -19
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
- package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
- package/lib/webpack/plugins/CleanWebpackPlugin.js +34 -18
- package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
- package/lib/webpack/plugins/LogPlugin.js +4 -5
- package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
- package/lib/webpack/plugins/WaitPlugin.js +1 -1
- package/lib/webpack/server.d.ts +5 -5
- package/lib/webpack/server.js +23 -8
- package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
- package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
- package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
- package/lib/webpack/utils.d.ts +16 -31
- package/lib/webpack/utils.js +63 -183
- package/package.json +83 -77
- package/bin/docusaurus.js +0 -326
- package/lib/.tsbuildinfo +0 -5682
- package/lib/choosePort.js +0 -105
- package/lib/client/.eslintrc.js +0 -29
- package/lib/client/.tsbuildinfo +0 -4127
- package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
- package/lib/client/client-lifecycles-dispatcher.js +0 -27
- package/lib/client/nprogress.css +0 -36
- package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
- package/lib/commands/buildRemoteBranchUrl.js +0 -27
- package/lib/commands/commandUtils.d.ts +0 -3
- package/lib/commands/commandUtils.js +0 -21
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -245
- package/lib/constants.d.ts +0 -18
- package/lib/constants.js +0 -23
- package/lib/server/client-modules/index.js +0 -14
- package/lib/server/duplicateRoutes.d.ts +0 -10
- package/lib/server/duplicateRoutes.js +0 -38
- package/lib/server/html-tags/htmlTags.js +0 -39
- package/lib/server/html-tags/index.d.ts +0 -9
- package/lib/server/html-tags/index.js +0 -43
- package/lib/server/loadSetup.d.ts +0 -9
- package/lib/server/loadSetup.js +0 -25
- package/lib/server/presets/index.d.ts +0 -11
- package/lib/server/presets/index.js +0 -48
- package/lib/server/themes/alias.d.ts +0 -8
- package/lib/server/themes/alias.js +0 -39
- package/lib/server/themes/index.d.ts +0 -8
- package/lib/server/themes/index.js +0 -35
- package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
- package/lib/server/versions/__fixtures__/package.json +0 -3
- package/lib/server/versions/__tests/index.test.js +0 -25
- package/lib/server/versions/index.d.ts +0 -10
- package/lib/server/versions/index.js +0 -50
- package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
- package/lib/webpack/sharedModuleAliases.d.ts +0 -10
- package/lib/webpack/sharedModuleAliases.js +0 -18
- package/tsconfig.client.json +0 -13
- package/tsconfig.json +0 -13
|
@@ -6,57 +6,54 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.handleBrokenLinks =
|
|
9
|
+
exports.handleBrokenLinks = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const react_router_config_1 = require("react-router-config");
|
|
12
|
-
const resolve_pathname_1 = tslib_1.__importDefault(require("resolve-pathname"));
|
|
13
11
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
14
|
-
const
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
14
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
|
+
const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
|
|
16
|
+
const react_router_config_1 = require("react-router-config");
|
|
15
17
|
const utils_1 = require("@docusaurus/utils");
|
|
16
18
|
const utils_2 = require("./utils");
|
|
17
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
18
|
-
function toReactRouterRoutes(routes) {
|
|
19
|
-
// @ts-expect-error: types incompatible???
|
|
20
|
-
return routes;
|
|
21
|
-
}
|
|
22
19
|
// matchRoutes does not support qs/anchors, so we remove it!
|
|
23
20
|
function onlyPathname(link) {
|
|
24
21
|
return link.split('#')[0].split('?')[0];
|
|
25
22
|
}
|
|
26
23
|
function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
|
|
27
|
-
// ReactRouter is able to support links like ./../somePath
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// resolvePathname is used internally by ReactRouter
|
|
24
|
+
// ReactRouter is able to support links like ./../somePath but `matchRoutes`
|
|
25
|
+
// does not do this resolution internally. We must resolve the links before
|
|
26
|
+
// using `matchRoutes`. `resolvePathname` is used internally by React Router
|
|
31
27
|
function resolveLink(link) {
|
|
32
|
-
const resolvedLink =
|
|
28
|
+
const resolvedLink = (0, utils_1.resolvePathname)(onlyPathname(link), pagePath);
|
|
33
29
|
return { link, resolvedLink };
|
|
34
30
|
}
|
|
35
31
|
function isBrokenLink(link) {
|
|
36
32
|
const matchedRoutes = [link, decodeURI(link)]
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
// @ts-expect-error: React router types RouteConfig with an actual React
|
|
34
|
+
// component, but we load route components with string paths.
|
|
35
|
+
// We don't actually access component here, so it's fine.
|
|
36
|
+
.map((l) => (0, react_router_config_1.matchRoutes)(routes, l))
|
|
37
|
+
.flat();
|
|
39
38
|
return matchedRoutes.length === 0;
|
|
40
39
|
}
|
|
41
40
|
return pageLinks.map(resolveLink).filter((l) => isBrokenLink(l.resolvedLink));
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
/**
|
|
43
|
+
* The route defs can be recursive, and have a parent match-all route. We don't
|
|
44
|
+
* want to match broken links like /docs/brokenLink against /docs/*. For this
|
|
45
|
+
* reason, we only consider the "final routes" that do not have subroutes.
|
|
46
|
+
* We also need to remove the match-all 404 route
|
|
47
|
+
*/
|
|
47
48
|
function filterIntermediateRoutes(routesInput) {
|
|
48
49
|
const routesWithout404 = routesInput.filter((route) => route.path !== '*');
|
|
49
|
-
return utils_2.getAllFinalRoutes(routesWithout404);
|
|
50
|
+
return (0, utils_2.getAllFinalRoutes)(routesWithout404);
|
|
50
51
|
}
|
|
51
52
|
function getAllBrokenLinks({ allCollectedLinks, routes, }) {
|
|
52
53
|
const filteredRoutes = filterIntermediateRoutes(routes);
|
|
53
|
-
const allBrokenLinks = lodash_1.mapValues(allCollectedLinks, (pageLinks, pagePath) => {
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
// remove pages without any broken link
|
|
57
|
-
return lodash_1.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
|
|
54
|
+
const allBrokenLinks = lodash_1.default.mapValues(allCollectedLinks, (pageLinks, pagePath) => getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes }));
|
|
55
|
+
return lodash_1.default.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
|
|
58
56
|
}
|
|
59
|
-
exports.getAllBrokenLinks = getAllBrokenLinks;
|
|
60
57
|
function getBrokenLinksErrorMessage(allBrokenLinks) {
|
|
61
58
|
if (Object.keys(allBrokenLinks).length === 0) {
|
|
62
59
|
return undefined;
|
|
@@ -66,16 +63,20 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
|
|
|
66
63
|
return `${brokenLink.link}${showResolvedLink ? ` (resolved as: ${brokenLink.resolvedLink})` : ''}`;
|
|
67
64
|
}
|
|
68
65
|
function pageBrokenLinksMessage(pagePath, brokenLinks) {
|
|
69
|
-
return
|
|
66
|
+
return `
|
|
67
|
+
- On source page path = ${pagePath}:
|
|
68
|
+
-> linking to ${brokenLinks
|
|
70
69
|
.map(brokenLinkMessage)
|
|
71
70
|
.join('\n -> linking to ')}`;
|
|
72
71
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
/**
|
|
73
|
+
* If there's a broken link appearing very often, it is probably a broken link
|
|
74
|
+
* on the layout. Add an additional message in such case to help user figure
|
|
75
|
+
* this out. See https://github.com/facebook/docusaurus/issues/3567#issuecomment-706973805
|
|
76
|
+
*/
|
|
76
77
|
function getLayoutBrokenLinksHelpMessage() {
|
|
77
|
-
const flatList =
|
|
78
|
-
const countedBrokenLinks = lodash_1.countBy(flatList, (item) => item.brokenLink.link);
|
|
78
|
+
const flatList = Object.entries(allBrokenLinks).flatMap(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink })));
|
|
79
|
+
const countedBrokenLinks = lodash_1.default.countBy(flatList, (item) => item.brokenLink.link);
|
|
79
80
|
const FrequencyThreshold = 5; // Is this a good value?
|
|
80
81
|
const frequentLinks = Object.entries(countedBrokenLinks)
|
|
81
82
|
.filter(([, count]) => count >= FrequencyThreshold)
|
|
@@ -83,51 +84,61 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
|
|
|
83
84
|
if (frequentLinks.length === 0) {
|
|
84
85
|
return '';
|
|
85
86
|
}
|
|
86
|
-
return
|
|
87
|
+
return logger_1.default.interpolate `
|
|
88
|
+
|
|
89
|
+
It looks like some of the broken links we found appear in many pages of your site.
|
|
90
|
+
Maybe those broken links appear on all pages through your site layout?
|
|
91
|
+
We recommend that you check your theme configuration for such links (particularly, theme navbar and footer).
|
|
92
|
+
Frequent broken links are linking to:${frequentLinks}`;
|
|
87
93
|
}
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
return `Docusaurus found broken links!
|
|
95
|
+
|
|
96
|
+
Please check the pages of your site in the list below, and make sure you don't reference any path that does not exist.
|
|
97
|
+
Note: it's possible to ignore broken links with the 'onBrokenLinks' Docusaurus configuration, and let the build pass.${getLayoutBrokenLinksHelpMessage()}
|
|
98
|
+
|
|
99
|
+
Exhaustive list of all broken links found:
|
|
100
|
+
${Object.entries(allBrokenLinks)
|
|
101
|
+
.map(([pagePath, brokenLinks]) => pageBrokenLinksMessage(pagePath, brokenLinks))
|
|
102
|
+
.join('\n')}
|
|
103
|
+
`;
|
|
93
104
|
}
|
|
94
|
-
|
|
95
|
-
function isExistingFile(filePath) {
|
|
105
|
+
async function isExistingFile(filePath) {
|
|
96
106
|
try {
|
|
97
|
-
return fs_extra_1.default.
|
|
107
|
+
return (await fs_extra_1.default.stat(filePath)).isFile();
|
|
98
108
|
}
|
|
99
|
-
catch
|
|
109
|
+
catch {
|
|
100
110
|
return false;
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
// If a file actually exist on the file system, we know the link is valid
|
|
104
114
|
// even if docusaurus does not know about this file, so we don't report it
|
|
105
115
|
async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, }) {
|
|
106
|
-
|
|
107
|
-
function linkFileExists(link) {
|
|
116
|
+
async function linkFileExists(link) {
|
|
108
117
|
// /baseUrl/javadoc/ -> /outDir/javadoc
|
|
109
|
-
const baseFilePath = utils_1.removeSuffix(`${outDir}/${utils_1.removePrefix(link, baseUrl)}`, '/');
|
|
118
|
+
const baseFilePath = onlyPathname((0, utils_1.removeSuffix)(`${outDir}/${(0, utils_1.removePrefix)(link, baseUrl)}`, '/'));
|
|
110
119
|
// -> /outDir/javadoc
|
|
111
120
|
// -> /outDir/javadoc.html
|
|
112
121
|
// -> /outDir/javadoc/index.html
|
|
113
122
|
const filePathsToTry = [baseFilePath];
|
|
114
123
|
if (!path_1.default.extname(baseFilePath)) {
|
|
115
|
-
filePathsToTry.push(`${baseFilePath}.html
|
|
116
|
-
|
|
124
|
+
filePathsToTry.push(`${baseFilePath}.html`, path_1.default.join(baseFilePath, 'index.html'));
|
|
125
|
+
}
|
|
126
|
+
for (const file of filePathsToTry) {
|
|
127
|
+
if (await isExistingFile(file)) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
117
130
|
}
|
|
118
|
-
return
|
|
131
|
+
return false;
|
|
119
132
|
}
|
|
120
|
-
return lodash_1.mapValues(allCollectedLinks, (links) =>
|
|
121
|
-
return links.filter((link) => !linkFileExists(link));
|
|
122
|
-
});
|
|
133
|
+
return (0, combine_promises_1.default)(lodash_1.default.mapValues(allCollectedLinks, async (links) => (await Promise.all(links.map(async (link) => ((await linkFileExists(link)) ? '' : link)))).filter(Boolean)));
|
|
123
134
|
}
|
|
124
|
-
exports.filterExistingFileLinks = filterExistingFileLinks;
|
|
125
135
|
async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }) {
|
|
126
136
|
if (onBrokenLinks === 'ignore') {
|
|
127
137
|
return;
|
|
128
138
|
}
|
|
129
|
-
// If we link to a file like /myFile.zip, and the file actually exist for the
|
|
130
|
-
//
|
|
139
|
+
// If we link to a file like /myFile.zip, and the file actually exist for the
|
|
140
|
+
// file system. It is not a broken link, it may simply be a link to an
|
|
141
|
+
// existing static file...
|
|
131
142
|
const allCollectedLinksFiltered = await filterExistingFileLinks({
|
|
132
143
|
allCollectedLinks,
|
|
133
144
|
baseUrl,
|
|
@@ -139,7 +150,7 @@ async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, bas
|
|
|
139
150
|
});
|
|
140
151
|
const errorMessage = getBrokenLinksErrorMessage(allBrokenLinks);
|
|
141
152
|
if (errorMessage) {
|
|
142
|
-
|
|
153
|
+
logger_1.default.report(onBrokenLinks)(errorMessage);
|
|
143
154
|
}
|
|
144
155
|
}
|
|
145
156
|
exports.handleBrokenLinks = handleBrokenLinks;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { LoadedPlugin } from '@docusaurus/types';
|
|
8
|
+
/**
|
|
9
|
+
* Runs the `getClientModules` lifecycle. The returned file paths are all
|
|
10
|
+
* absolute.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadClientModules(plugins: LoadedPlugin[]): string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadClientModules = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
/**
|
|
13
|
+
* Runs the `getClientModules` lifecycle. The returned file paths are all
|
|
14
|
+
* absolute.
|
|
15
|
+
*/
|
|
16
|
+
function loadClientModules(plugins) {
|
|
17
|
+
return plugins.flatMap((plugin) => plugin.getClientModules?.().map((p) => path_1.default.resolve(plugin.path, p)) ??
|
|
18
|
+
[]);
|
|
19
|
+
}
|
|
20
|
+
exports.loadClientModules = loadClientModules;
|
package/lib/server/config.d.ts
CHANGED
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
export
|
|
7
|
+
import type { LoadContext } from '@docusaurus/types';
|
|
8
|
+
export declare function loadSiteConfig({ siteDir, customConfigFilePath, }: {
|
|
9
|
+
siteDir: string;
|
|
10
|
+
customConfigFilePath?: string;
|
|
11
|
+
}): Promise<Pick<LoadContext, 'siteConfig' | 'siteConfigPath'>>;
|
package/lib/server/config.js
CHANGED
|
@@ -6,15 +6,38 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.loadSiteConfig = void 0;
|
|
9
10
|
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
12
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
11
13
|
const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
|
|
14
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
15
|
+
const utils_1 = require("@docusaurus/utils");
|
|
12
16
|
const configValidation_1 = require("./configValidation");
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
async function findConfig(siteDir) {
|
|
18
|
+
// We could support .mjs, .ts, etc. in the future
|
|
19
|
+
const candidates = ['.js', '.cjs'].map((ext) => utils_1.DEFAULT_CONFIG_FILE_NAME + ext);
|
|
20
|
+
const configPath = await (0, utils_1.findAsyncSequential)(candidates.map((file) => path_1.default.join(siteDir, file)), fs_extra_1.default.pathExists);
|
|
21
|
+
if (!configPath) {
|
|
22
|
+
logger_1.default.error('No config file found.');
|
|
23
|
+
logger_1.default.info `Expected one of:${candidates}
|
|
24
|
+
You can provide a custom config path with the code=${'--config'} option.`;
|
|
25
|
+
throw new Error();
|
|
16
26
|
}
|
|
17
|
-
|
|
18
|
-
return configValidation_1.validateConfig(loadedConfig);
|
|
27
|
+
return configPath;
|
|
19
28
|
}
|
|
20
|
-
|
|
29
|
+
async function loadSiteConfig({ siteDir, customConfigFilePath, }) {
|
|
30
|
+
const siteConfigPath = customConfigFilePath
|
|
31
|
+
? path_1.default.resolve(siteDir, customConfigFilePath)
|
|
32
|
+
: await findConfig(siteDir);
|
|
33
|
+
if (!(await fs_extra_1.default.pathExists(siteConfigPath))) {
|
|
34
|
+
throw new Error(`Config file at "${siteConfigPath}" not found.`);
|
|
35
|
+
}
|
|
36
|
+
const importedConfig = (0, import_fresh_1.default)(siteConfigPath);
|
|
37
|
+
const loadedConfig = typeof importedConfig === 'function'
|
|
38
|
+
? await importedConfig()
|
|
39
|
+
: await importedConfig;
|
|
40
|
+
const siteConfig = (0, configValidation_1.validateConfig)(loadedConfig, path_1.default.relative(siteDir, siteConfigPath));
|
|
41
|
+
return { siteConfig, siteConfigPath };
|
|
42
|
+
}
|
|
43
|
+
exports.loadSiteConfig = loadSiteConfig;
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Joi } from '@docusaurus/utils-validation';
|
|
8
|
+
import type { DocusaurusConfig, I18nConfig } from '@docusaurus/types';
|
|
8
9
|
export declare const DEFAULT_I18N_CONFIG: I18nConfig;
|
|
9
|
-
export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'baseUrlIssueBanner'>;
|
|
10
|
-
export declare
|
|
10
|
+
export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'stylesheets' | 'scripts' | 'clientModules' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'tagline' | 'baseUrlIssueBanner' | 'staticDirectories'>;
|
|
11
|
+
export declare const ConfigSchema: Joi.ObjectSchema<DocusaurusConfig>;
|
|
12
|
+
export declare function validateConfig(config: unknown, siteConfigPath: string): DocusaurusConfig;
|
|
@@ -6,12 +6,13 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.validateConfig = exports.DEFAULT_CONFIG = exports.DEFAULT_I18N_CONFIG = void 0;
|
|
10
|
-
const
|
|
9
|
+
exports.validateConfig = exports.ConfigSchema = exports.DEFAULT_CONFIG = exports.DEFAULT_I18N_CONFIG = void 0;
|
|
10
|
+
const utils_1 = require("@docusaurus/utils");
|
|
11
11
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
12
12
|
const DEFAULT_I18N_LOCALE = 'en';
|
|
13
13
|
exports.DEFAULT_I18N_CONFIG = {
|
|
14
14
|
defaultLocale: DEFAULT_I18N_LOCALE,
|
|
15
|
+
path: utils_1.DEFAULT_I18N_DIR_NAME,
|
|
15
16
|
locales: [DEFAULT_I18N_LOCALE],
|
|
16
17
|
localeConfigs: {},
|
|
17
18
|
};
|
|
@@ -23,23 +24,39 @@ exports.DEFAULT_CONFIG = {
|
|
|
23
24
|
plugins: [],
|
|
24
25
|
themes: [],
|
|
25
26
|
presets: [],
|
|
27
|
+
stylesheets: [],
|
|
28
|
+
scripts: [],
|
|
29
|
+
clientModules: [],
|
|
26
30
|
customFields: {},
|
|
27
31
|
themeConfig: {},
|
|
28
32
|
titleDelimiter: '|',
|
|
29
33
|
noIndex: false,
|
|
34
|
+
tagline: '',
|
|
30
35
|
baseUrlIssueBanner: true,
|
|
36
|
+
staticDirectories: [utils_1.DEFAULT_STATIC_DIR_NAME],
|
|
31
37
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
error
|
|
42
|
-
|
|
38
|
+
function createPluginSchema(theme) {
|
|
39
|
+
return (utils_validation_1.Joi.alternatives()
|
|
40
|
+
.try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array()
|
|
41
|
+
.ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required())
|
|
42
|
+
.length(2), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
|
|
43
|
+
.ordered(utils_validation_1.Joi.string().required(), utils_validation_1.Joi.object().required())
|
|
44
|
+
.length(2), utils_validation_1.Joi.any().valid(false, null))
|
|
45
|
+
// @ts-expect-error: bad lib def, doesn't recognize an array of reports
|
|
46
|
+
.error((errors) => {
|
|
47
|
+
errors.forEach((error) => {
|
|
48
|
+
const validConfigExample = theme
|
|
49
|
+
? `Example valid theme config:
|
|
50
|
+
{
|
|
51
|
+
themes: [
|
|
52
|
+
["@docusaurus/theme-classic",options],
|
|
53
|
+
"./myTheme",
|
|
54
|
+
["./myTheme",{someOption: 42}],
|
|
55
|
+
function myTheme() { },
|
|
56
|
+
[function myTheme() { },options]
|
|
57
|
+
],
|
|
58
|
+
};`
|
|
59
|
+
: `Example valid plugin config:
|
|
43
60
|
{
|
|
44
61
|
plugins: [
|
|
45
62
|
["@docusaurus/plugin-content-docs",options],
|
|
@@ -48,19 +65,35 @@ Example valid plugin config:
|
|
|
48
65
|
function myPlugin() { },
|
|
49
66
|
[function myPlugin() { },options]
|
|
50
67
|
],
|
|
51
|
-
}
|
|
68
|
+
};`;
|
|
69
|
+
error.message = ` => Bad Docusaurus ${theme ? 'theme' : 'plugin'} value ${error.path.reduce((acc, cur) => typeof cur === 'string' ? `${acc}.${cur}` : `${acc}[${cur}]`)}.
|
|
70
|
+
${validConfigExample}
|
|
52
71
|
`;
|
|
53
|
-
|
|
54
|
-
|
|
72
|
+
});
|
|
73
|
+
return errors;
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
const PluginSchema = createPluginSchema(false);
|
|
77
|
+
const ThemeSchema = createPluginSchema(true);
|
|
78
|
+
const PresetSchema = utils_validation_1.Joi.alternatives()
|
|
79
|
+
.try(utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
|
|
80
|
+
.items(utils_validation_1.Joi.string().required(), utils_validation_1.Joi.object().required())
|
|
81
|
+
.length(2), utils_validation_1.Joi.any().valid(false, null))
|
|
82
|
+
.messages({
|
|
83
|
+
'alternatives.types': `{#label} does not look like a valid preset config. A preset config entry should be one of:
|
|
84
|
+
- A tuple of [presetName, options], like \`["classic", \\{ blog: false \\}]\`, or
|
|
85
|
+
- A simple string, like \`"classic"\``,
|
|
55
86
|
});
|
|
56
|
-
const ThemeSchema = utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.array().items(utils_validation_1.Joi.string().required(), utils_validation_1.Joi.object().required()).length(2));
|
|
57
|
-
const PresetSchema = utils_validation_1.Joi.alternatives().try(utils_validation_1.Joi.string(), utils_validation_1.Joi.array().items(utils_validation_1.Joi.string().required(), utils_validation_1.Joi.object().required()).length(2));
|
|
58
87
|
const LocaleConfigSchema = utils_validation_1.Joi.object({
|
|
59
88
|
label: utils_validation_1.Joi.string(),
|
|
89
|
+
htmlLang: utils_validation_1.Joi.string(),
|
|
60
90
|
direction: utils_validation_1.Joi.string().equal('ltr', 'rtl').default('ltr'),
|
|
91
|
+
calendar: utils_validation_1.Joi.string(),
|
|
92
|
+
path: utils_validation_1.Joi.string(),
|
|
61
93
|
});
|
|
62
94
|
const I18N_CONFIG_SCHEMA = utils_validation_1.Joi.object({
|
|
63
95
|
defaultLocale: utils_validation_1.Joi.string().required(),
|
|
96
|
+
path: utils_validation_1.Joi.string().default(exports.DEFAULT_I18N_CONFIG.path),
|
|
64
97
|
locales: utils_validation_1.Joi.array().items().min(1).items(utils_validation_1.Joi.string().required()).required(),
|
|
65
98
|
localeConfigs: utils_validation_1.Joi.object()
|
|
66
99
|
.pattern(/.*/, LocaleConfigSchema)
|
|
@@ -68,70 +101,98 @@ const I18N_CONFIG_SCHEMA = utils_validation_1.Joi.object({
|
|
|
68
101
|
})
|
|
69
102
|
.optional()
|
|
70
103
|
.default(exports.DEFAULT_I18N_CONFIG);
|
|
104
|
+
const SiteUrlSchema = utils_validation_1.URISchema.required().custom((value, helpers) => {
|
|
105
|
+
try {
|
|
106
|
+
const { pathname } = new URL(String(value));
|
|
107
|
+
if (pathname !== '/') {
|
|
108
|
+
helpers.warn('docusaurus.configValidationWarning', {
|
|
109
|
+
warningMessage: `the url is not supposed to contain a sub-path like '${pathname}', please use the baseUrl field for sub-paths`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch { }
|
|
114
|
+
return value;
|
|
115
|
+
}, 'siteUrlCustomValidation');
|
|
71
116
|
// TODO move to @docusaurus/utils-validation
|
|
72
|
-
|
|
117
|
+
exports.ConfigSchema = utils_validation_1.Joi.object({
|
|
73
118
|
baseUrl: utils_validation_1.Joi.string()
|
|
74
119
|
.required()
|
|
75
|
-
.regex(
|
|
76
|
-
.message('{{#label}} must be a string with a trailing
|
|
120
|
+
.regex(/\/$/m)
|
|
121
|
+
.message('{{#label}} must be a string with a trailing slash.'),
|
|
77
122
|
baseUrlIssueBanner: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.baseUrlIssueBanner),
|
|
78
|
-
favicon: utils_validation_1.Joi.string().
|
|
123
|
+
favicon: utils_validation_1.Joi.string().optional(),
|
|
79
124
|
title: utils_validation_1.Joi.string().required(),
|
|
80
|
-
url:
|
|
125
|
+
url: SiteUrlSchema,
|
|
126
|
+
trailingSlash: utils_validation_1.Joi.boolean(),
|
|
81
127
|
i18n: I18N_CONFIG_SCHEMA,
|
|
82
128
|
onBrokenLinks: utils_validation_1.Joi.string()
|
|
83
|
-
.equal('ignore', 'log', 'warn', '
|
|
129
|
+
.equal('ignore', 'log', 'warn', 'throw')
|
|
84
130
|
.default(exports.DEFAULT_CONFIG.onBrokenLinks),
|
|
85
131
|
onBrokenMarkdownLinks: utils_validation_1.Joi.string()
|
|
86
|
-
.equal('ignore', 'log', 'warn', '
|
|
132
|
+
.equal('ignore', 'log', 'warn', 'throw')
|
|
87
133
|
.default(exports.DEFAULT_CONFIG.onBrokenMarkdownLinks),
|
|
88
134
|
onDuplicateRoutes: utils_validation_1.Joi.string()
|
|
89
|
-
.equal('ignore', 'log', 'warn', '
|
|
135
|
+
.equal('ignore', 'log', 'warn', 'throw')
|
|
90
136
|
.default(exports.DEFAULT_CONFIG.onDuplicateRoutes),
|
|
91
137
|
organizationName: utils_validation_1.Joi.string().allow(''),
|
|
138
|
+
staticDirectories: utils_validation_1.Joi.array()
|
|
139
|
+
.items(utils_validation_1.Joi.string())
|
|
140
|
+
.default(exports.DEFAULT_CONFIG.staticDirectories),
|
|
92
141
|
projectName: utils_validation_1.Joi.string().allow(''),
|
|
142
|
+
deploymentBranch: utils_validation_1.Joi.string().optional(),
|
|
93
143
|
customFields: utils_validation_1.Joi.object().unknown().default(exports.DEFAULT_CONFIG.customFields),
|
|
94
144
|
githubHost: utils_validation_1.Joi.string(),
|
|
145
|
+
githubPort: utils_validation_1.Joi.string(),
|
|
95
146
|
plugins: utils_validation_1.Joi.array().items(PluginSchema).default(exports.DEFAULT_CONFIG.plugins),
|
|
96
147
|
themes: utils_validation_1.Joi.array().items(ThemeSchema).default(exports.DEFAULT_CONFIG.themes),
|
|
97
148
|
presets: utils_validation_1.Joi.array().items(PresetSchema).default(exports.DEFAULT_CONFIG.presets),
|
|
98
149
|
themeConfig: utils_validation_1.Joi.object().unknown().default(exports.DEFAULT_CONFIG.themeConfig),
|
|
99
|
-
scripts: utils_validation_1.Joi.array()
|
|
150
|
+
scripts: utils_validation_1.Joi.array()
|
|
151
|
+
.items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
|
|
100
152
|
src: utils_validation_1.Joi.string().required(),
|
|
101
153
|
async: utils_validation_1.Joi.bool(),
|
|
102
154
|
defer: utils_validation_1.Joi.bool(),
|
|
103
155
|
})
|
|
104
156
|
// See https://github.com/facebook/docusaurus/issues/3378
|
|
105
|
-
.unknown())
|
|
157
|
+
.unknown())
|
|
158
|
+
.messages({
|
|
159
|
+
'array.includes': '{#label} is invalid. A script must be a plain string (the src), or an object with at least a "src" property.',
|
|
160
|
+
})
|
|
161
|
+
.default(exports.DEFAULT_CONFIG.scripts),
|
|
106
162
|
ssrTemplate: utils_validation_1.Joi.string(),
|
|
107
|
-
stylesheets: utils_validation_1.Joi.array()
|
|
163
|
+
stylesheets: utils_validation_1.Joi.array()
|
|
164
|
+
.items(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
|
|
108
165
|
href: utils_validation_1.Joi.string().required(),
|
|
109
|
-
type: utils_validation_1.Joi.string()
|
|
110
|
-
}).unknown())
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
166
|
+
type: utils_validation_1.Joi.string(),
|
|
167
|
+
}).unknown())
|
|
168
|
+
.messages({
|
|
169
|
+
'array.includes': '{#label} is invalid. A stylesheet must be a plain string (the href), or an object with at least a "href" property.',
|
|
170
|
+
})
|
|
171
|
+
.default(exports.DEFAULT_CONFIG.stylesheets),
|
|
172
|
+
clientModules: utils_validation_1.Joi.array()
|
|
173
|
+
.items(utils_validation_1.Joi.string())
|
|
174
|
+
.default(exports.DEFAULT_CONFIG.clientModules),
|
|
175
|
+
tagline: utils_validation_1.Joi.string().allow('').default(exports.DEFAULT_CONFIG.tagline),
|
|
176
|
+
titleDelimiter: utils_validation_1.Joi.string().default(exports.DEFAULT_CONFIG.titleDelimiter),
|
|
177
|
+
noIndex: utils_validation_1.Joi.bool().default(exports.DEFAULT_CONFIG.noIndex),
|
|
115
178
|
webpack: utils_validation_1.Joi.object({
|
|
116
179
|
jsLoader: utils_validation_1.Joi.alternatives()
|
|
117
180
|
.try(utils_validation_1.Joi.string().equal('babel'), utils_validation_1.Joi.function())
|
|
118
181
|
.optional(),
|
|
119
182
|
}).optional(),
|
|
183
|
+
}).messages({
|
|
184
|
+
'docusaurus.configValidationWarning': 'Docusaurus config validation warning. Field {#label}: {#warningMessage}',
|
|
120
185
|
});
|
|
121
186
|
// TODO move to @docusaurus/utils-validation
|
|
122
|
-
function validateConfig(config) {
|
|
123
|
-
const { error, value } = ConfigSchema.validate(config, {
|
|
187
|
+
function validateConfig(config, siteConfigPath) {
|
|
188
|
+
const { error, warning, value } = exports.ConfigSchema.validate(config, {
|
|
124
189
|
abortEarly: false,
|
|
125
190
|
});
|
|
191
|
+
(0, utils_validation_1.printWarning)(warning);
|
|
126
192
|
if (error) {
|
|
127
|
-
utils_validation_1.logValidationBugReportHint();
|
|
128
|
-
if (utils_validation_1.isValidationDisabledEscapeHatch) {
|
|
129
|
-
console.error(error);
|
|
130
|
-
return config;
|
|
131
|
-
}
|
|
132
193
|
const unknownFields = error.details.reduce((formattedError, err) => {
|
|
133
194
|
if (err.type === 'object.unknown') {
|
|
134
|
-
return `${formattedError}"${err.path}",`;
|
|
195
|
+
return `${formattedError}"${err.path.reduce((acc, cur) => typeof cur === 'string' ? `${acc}.${cur}` : `${acc}[${cur}]`)}",`;
|
|
135
196
|
}
|
|
136
197
|
return formattedError;
|
|
137
198
|
}, '');
|
|
@@ -139,7 +200,7 @@ function validateConfig(config) {
|
|
|
139
200
|
? `${accumulatedErr}${err.message}\n`
|
|
140
201
|
: accumulatedErr, '');
|
|
141
202
|
formattedError = unknownFields
|
|
142
|
-
? `${formattedError}These field(s)
|
|
203
|
+
? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${siteConfigPath}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/api/docusaurus-config/#customfields`
|
|
143
204
|
: formattedError;
|
|
144
205
|
throw new Error(formattedError);
|
|
145
206
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export declare type HostPortOptions = {
|
|
8
|
+
host?: string;
|
|
9
|
+
port?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function getHostPort(options: HostPortOptions): Promise<{
|
|
12
|
+
host: string;
|
|
13
|
+
port: number | null;
|
|
14
|
+
}>;
|