@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.
Files changed (222) hide show
  1. package/README.md +1 -0
  2. package/bin/beforeCli.mjs +140 -0
  3. package/bin/docusaurus.mjs +223 -0
  4. package/lib/babel/preset.d.ts +8 -3
  5. package/lib/babel/preset.js +10 -8
  6. package/lib/client/App.d.ts +2 -3
  7. package/lib/client/App.js +31 -28
  8. package/lib/client/BaseUrlIssueBanner/index.d.ts +27 -0
  9. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.js → BaseUrlIssueBanner/index.js} +25 -14
  10. package/lib/client/{baseUrlIssueBanner → BaseUrlIssueBanner}/styles.module.css +0 -0
  11. package/lib/client/ClientLifecyclesDispatcher.d.ts +16 -0
  12. package/lib/client/ClientLifecyclesDispatcher.js +39 -0
  13. package/lib/client/LinksCollector.d.ts +3 -3
  14. package/lib/client/LinksCollector.js +8 -13
  15. package/lib/client/PendingNavigation.d.ts +17 -3
  16. package/lib/client/PendingNavigation.js +47 -72
  17. package/lib/client/{baseUrlIssueBanner/BaseUrlIssueBanner.d.ts → SiteMetadataDefaults.d.ts} +1 -2
  18. package/lib/client/SiteMetadataDefaults.js +21 -0
  19. package/lib/{choosePort.d.ts → client/browserContext.d.ts} +5 -5
  20. package/lib/client/browserContext.js +22 -0
  21. package/lib/client/clientEntry.js +14 -9
  22. package/lib/client/docusaurus.d.ts +12 -6
  23. package/lib/client/docusaurus.js +30 -43
  24. package/lib/client/docusaurusContext.d.ts +12 -0
  25. package/lib/client/docusaurusContext.js +25 -0
  26. package/lib/client/exports/BrowserOnly.d.ts +3 -5
  27. package/lib/client/exports/BrowserOnly.js +14 -7
  28. package/lib/client/exports/ComponentCreator.d.ts +6 -2
  29. package/lib/client/exports/ComponentCreator.js +75 -42
  30. package/lib/client/exports/ErrorBoundary.d.ts +18 -0
  31. package/lib/client/exports/ErrorBoundary.js +37 -0
  32. package/lib/client/exports/ExecutionEnvironment.js +7 -8
  33. package/lib/client/exports/Head.d.ts +2 -3
  34. package/lib/client/exports/Head.js +3 -4
  35. package/lib/client/exports/Interpolate.d.ts +2 -2
  36. package/lib/client/exports/Interpolate.js +20 -49
  37. package/lib/client/exports/Link.d.ts +4 -10
  38. package/lib/client/exports/Link.js +44 -38
  39. package/lib/client/exports/Translate.d.ts +1 -1
  40. package/lib/client/exports/Translate.js +14 -9
  41. package/lib/client/exports/constants.js +1 -11
  42. package/lib/client/exports/isInternalUrl.js +1 -1
  43. package/lib/client/exports/renderRoutes.d.ts +1 -2
  44. package/lib/client/exports/renderRoutes.js +1 -2
  45. package/lib/client/exports/router.d.ts +1 -1
  46. package/lib/client/exports/router.js +1 -1
  47. package/lib/client/exports/useBaseUrl.js +11 -14
  48. package/lib/client/exports/useDocusaurusContext.d.ts +2 -3
  49. package/lib/client/exports/useDocusaurusContext.js +3 -9
  50. package/lib/client/exports/useGlobalData.d.ts +4 -3
  51. package/lib/client/exports/useGlobalData.js +8 -15
  52. package/lib/{server/versions/__tests/index.test.d.ts → client/exports/useIsBrowser.d.ts} +1 -1
  53. package/lib/client/exports/useIsBrowser.js +11 -0
  54. package/lib/client/exports/useRouteContext.d.ts +8 -0
  55. package/lib/client/exports/useRouteContext.js +15 -0
  56. package/lib/client/flat.d.ts +12 -2
  57. package/lib/client/flat.js +19 -15
  58. package/lib/client/normalizeLocation.d.ts +2 -5
  59. package/lib/client/normalizeLocation.js +14 -10
  60. package/lib/client/prefetch.d.ts +1 -2
  61. package/lib/client/prefetch.js +12 -32
  62. package/lib/client/preload.d.ts +3 -4
  63. package/lib/client/preload.js +5 -12
  64. package/lib/client/routeContext.d.ts +13 -0
  65. package/lib/client/routeContext.js +31 -0
  66. package/lib/client/serverEntry.d.ts +10 -0
  67. package/lib/client/serverEntry.js +109 -136
  68. package/lib/client/theme-fallback/Error/index.d.ts +10 -0
  69. package/lib/client/theme-fallback/Error/index.js +45 -0
  70. package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
  71. package/lib/client/theme-fallback/Layout/index.js +2 -26
  72. package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
  73. package/lib/client/theme-fallback/Loading/index.js +50 -116
  74. package/lib/client/{exports/context.js → theme-fallback/NotFound/index.d.ts} +2 -2
  75. package/lib/client/theme-fallback/NotFound/index.js +19 -18
  76. package/lib/client/theme-fallback/Root/index.d.ts +10 -0
  77. package/lib/client/theme-fallback/Root/index.js +2 -6
  78. package/lib/{server/html-tags/htmlTags.d.ts → client/theme-fallback/SiteMetadata/index.d.ts} +2 -1
  79. package/lib/client/theme-fallback/SiteMetadata/index.js +10 -0
  80. package/lib/commands/build.d.ts +6 -2
  81. package/lib/commands/build.js +81 -64
  82. package/lib/commands/clear.d.ts +7 -1
  83. package/lib/commands/clear.js +34 -21
  84. package/lib/commands/deploy.d.ts +5 -2
  85. package/lib/commands/deploy.js +102 -81
  86. package/lib/commands/external.d.ts +2 -2
  87. package/lib/commands/external.js +9 -11
  88. package/lib/commands/serve.d.ts +8 -2
  89. package/lib/commands/serve.js +40 -20
  90. package/lib/commands/start.d.ts +9 -2
  91. package/lib/commands/start.js +111 -101
  92. package/lib/commands/swizzle/actions.d.ts +23 -0
  93. package/lib/commands/swizzle/actions.js +106 -0
  94. package/lib/commands/swizzle/common.d.ts +33 -0
  95. package/lib/commands/swizzle/common.js +56 -0
  96. package/lib/commands/swizzle/components.d.ts +29 -0
  97. package/lib/commands/swizzle/components.js +200 -0
  98. package/lib/commands/swizzle/config.d.ts +10 -0
  99. package/lib/commands/swizzle/config.js +84 -0
  100. package/lib/{server/client-modules/index.d.ts → commands/swizzle/context.d.ts} +2 -2
  101. package/lib/commands/swizzle/context.js +24 -0
  102. package/lib/commands/swizzle/index.d.ts +8 -0
  103. package/lib/commands/swizzle/index.js +119 -0
  104. package/lib/commands/swizzle/prompts.d.ts +12 -0
  105. package/lib/commands/swizzle/prompts.js +110 -0
  106. package/lib/{client/exports/context.d.ts → commands/swizzle/tables.d.ts} +3 -4
  107. package/lib/commands/swizzle/tables.js +113 -0
  108. package/lib/commands/swizzle/themes.d.ts +20 -0
  109. package/lib/commands/swizzle/themes.js +106 -0
  110. package/lib/commands/writeHeadingIds.d.ts +2 -6
  111. package/lib/commands/writeHeadingIds.js +22 -81
  112. package/lib/commands/writeTranslations.d.ts +4 -5
  113. package/lib/commands/writeTranslations.js +48 -28
  114. package/lib/index.d.ts +9 -9
  115. package/lib/index.js +14 -14
  116. package/lib/server/brokenLinks.d.ts +4 -17
  117. package/lib/server/brokenLinks.js +67 -56
  118. package/lib/server/clientModules.d.ts +12 -0
  119. package/lib/server/clientModules.js +20 -0
  120. package/lib/server/config.d.ts +5 -2
  121. package/lib/server/config.js +29 -6
  122. package/lib/server/configValidation.d.ts +5 -3
  123. package/lib/server/configValidation.js +105 -44
  124. package/lib/server/getHostPort.d.ts +14 -0
  125. package/lib/server/getHostPort.js +79 -0
  126. package/lib/server/htmlTags.d.ts +12 -0
  127. package/lib/server/htmlTags.js +62 -0
  128. package/lib/server/i18n.d.ts +3 -13
  129. package/lib/server/i18n.js +21 -55
  130. package/lib/server/index.d.ts +28 -6
  131. package/lib/server/index.js +86 -173
  132. package/lib/server/plugins/configs.d.ts +51 -0
  133. package/lib/server/plugins/configs.js +101 -0
  134. package/lib/server/plugins/index.d.ts +10 -10
  135. package/lib/server/plugins/index.js +76 -128
  136. package/lib/server/plugins/init.d.ts +6 -9
  137. package/lib/server/plugins/init.js +44 -109
  138. package/lib/server/plugins/moduleShorthand.d.ts +9 -0
  139. package/lib/server/plugins/moduleShorthand.js +46 -0
  140. package/lib/server/plugins/pluginIds.d.ts +6 -2
  141. package/lib/server/plugins/pluginIds.js +12 -7
  142. package/lib/server/plugins/presets.d.ts +12 -0
  143. package/lib/server/plugins/presets.js +49 -0
  144. package/lib/server/plugins/routeConfig.d.ts +11 -0
  145. package/lib/server/plugins/routeConfig.js +54 -0
  146. package/lib/server/plugins/synthetic.d.ts +20 -0
  147. package/lib/server/plugins/synthetic.js +111 -0
  148. package/lib/server/routes.d.ts +39 -7
  149. package/lib/server/routes.js +182 -95
  150. package/lib/server/siteMetadata.d.ts +12 -0
  151. package/lib/server/siteMetadata.js +81 -0
  152. package/lib/server/translations/translations.d.ts +16 -22
  153. package/lib/server/translations/translations.js +41 -73
  154. package/lib/server/translations/translationsExtractor.d.ts +10 -5
  155. package/lib/server/translations/translationsExtractor.js +158 -122
  156. package/lib/server/utils.d.ts +9 -3
  157. package/lib/server/utils.js +7 -9
  158. package/lib/webpack/aliases/index.d.ts +34 -0
  159. package/lib/webpack/aliases/index.js +106 -0
  160. package/lib/webpack/base.d.ts +3 -4
  161. package/lib/webpack/base.js +56 -58
  162. package/lib/webpack/client.d.ts +3 -3
  163. package/lib/webpack/client.js +12 -19
  164. package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +13 -3
  165. package/lib/webpack/plugins/ChunkAssetPlugin.js +24 -17
  166. package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +6 -25
  167. package/lib/webpack/plugins/CleanWebpackPlugin.js +34 -18
  168. package/lib/webpack/plugins/LogPlugin.d.ts +1 -1
  169. package/lib/webpack/plugins/LogPlugin.js +4 -5
  170. package/lib/webpack/plugins/WaitPlugin.d.ts +3 -3
  171. package/lib/webpack/plugins/WaitPlugin.js +1 -1
  172. package/lib/webpack/server.d.ts +5 -5
  173. package/lib/webpack/server.js +23 -8
  174. package/lib/{client → webpack}/templates/index.html.template.ejs +0 -0
  175. package/lib/webpack/templates/ssr.html.template.d.ts +8 -0
  176. package/lib/{client → webpack}/templates/ssr.html.template.js +5 -4
  177. package/lib/webpack/utils.d.ts +16 -31
  178. package/lib/webpack/utils.js +63 -183
  179. package/package.json +83 -77
  180. package/bin/docusaurus.js +0 -326
  181. package/lib/.tsbuildinfo +0 -5682
  182. package/lib/choosePort.js +0 -105
  183. package/lib/client/.eslintrc.js +0 -29
  184. package/lib/client/.tsbuildinfo +0 -4127
  185. package/lib/client/client-lifecycles-dispatcher.d.ts +0 -12
  186. package/lib/client/client-lifecycles-dispatcher.js +0 -27
  187. package/lib/client/nprogress.css +0 -36
  188. package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
  189. package/lib/commands/buildRemoteBranchUrl.js +0 -27
  190. package/lib/commands/commandUtils.d.ts +0 -3
  191. package/lib/commands/commandUtils.js +0 -21
  192. package/lib/commands/swizzle.d.ts +0 -9
  193. package/lib/commands/swizzle.js +0 -245
  194. package/lib/constants.d.ts +0 -18
  195. package/lib/constants.js +0 -23
  196. package/lib/server/client-modules/index.js +0 -14
  197. package/lib/server/duplicateRoutes.d.ts +0 -10
  198. package/lib/server/duplicateRoutes.js +0 -38
  199. package/lib/server/html-tags/htmlTags.js +0 -39
  200. package/lib/server/html-tags/index.d.ts +0 -9
  201. package/lib/server/html-tags/index.js +0 -43
  202. package/lib/server/loadSetup.d.ts +0 -9
  203. package/lib/server/loadSetup.js +0 -25
  204. package/lib/server/presets/index.d.ts +0 -11
  205. package/lib/server/presets/index.js +0 -48
  206. package/lib/server/themes/alias.d.ts +0 -8
  207. package/lib/server/themes/alias.js +0 -39
  208. package/lib/server/themes/index.d.ts +0 -8
  209. package/lib/server/themes/index.js +0 -35
  210. package/lib/server/versions/__fixtures__/dummy-plugin.js +0 -0
  211. package/lib/server/versions/__fixtures__/package.json +0 -3
  212. package/lib/server/versions/__tests/index.test.js +0 -25
  213. package/lib/server/versions/index.d.ts +0 -10
  214. package/lib/server/versions/index.js +0 -50
  215. package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
  216. package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
  217. package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
  218. package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
  219. package/lib/webpack/sharedModuleAliases.d.ts +0 -10
  220. package/lib/webpack/sharedModuleAliases.js +0 -18
  221. package/tsconfig.client.json +0 -13
  222. package/tsconfig.json +0 -13
@@ -0,0 +1,79 @@
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.getHostPort = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const child_process_1 = require("child_process");
12
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
+ const detect_port_1 = tslib_1.__importDefault(require("detect-port"));
14
+ const utils_1 = require("@docusaurus/utils");
15
+ const prompts_1 = tslib_1.__importDefault(require("prompts"));
16
+ const execOptions = {
17
+ encoding: 'utf8',
18
+ stdio: [/* stdin */ 'pipe', /* stdout */ 'pipe', /* stderr */ 'ignore'],
19
+ };
20
+ function clearConsole() {
21
+ process.stdout.write(process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H');
22
+ }
23
+ function getProcessForPort(port) {
24
+ try {
25
+ const processId = (0, child_process_1.execSync)(`lsof -i:${port} -P -t -sTCP:LISTEN`, execOptions)
26
+ .split('\n')[0]
27
+ .trim();
28
+ const directory = (0, 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, child_process_1.execSync)(`ps -o command -p ${processId} | sed -n 2p`, execOptions).replace(/\n$/, '');
30
+ return logger_1.default.interpolate `code=${command} subdue=${`(pid ${processId})`} in path=${directory}`;
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
36
+ /**
37
+ * Detects if program is running on port, and prompts user to choose another if
38
+ * port is already being used. This feature was heavily inspired by
39
+ * create-react-app and uses many of the same utility functions to implement it.
40
+ */
41
+ async function choosePort(host, defaultPort) {
42
+ try {
43
+ const port = await (0, detect_port_1.default)({ port: defaultPort, hostname: host });
44
+ if (port === defaultPort) {
45
+ return port;
46
+ }
47
+ const isRoot = process.getuid?.() === 0;
48
+ const isInteractive = process.stdout.isTTY;
49
+ const message = process.platform !== 'win32' && defaultPort < 1024 && !isRoot
50
+ ? `Admin permissions are required to run a server on a port below 1024.`
51
+ : `Something is already running on port ${defaultPort}.`;
52
+ if (!isInteractive) {
53
+ logger_1.default.error(message);
54
+ return null;
55
+ }
56
+ clearConsole();
57
+ const existingProcess = getProcessForPort(defaultPort);
58
+ const { shouldChangePort } = (await (0, prompts_1.default)({
59
+ type: 'confirm',
60
+ name: 'shouldChangePort',
61
+ message: logger_1.default.yellow(`${logger_1.default.bold('[WARNING]')} ${message}${existingProcess ? ` Probably:\n ${existingProcess}` : ''}
62
+
63
+ Would you like to run the app on another port instead?`),
64
+ initial: true,
65
+ }));
66
+ return shouldChangePort ? port : null;
67
+ }
68
+ catch (err) {
69
+ logger_1.default.error `Could not find an open port at ${host}.`;
70
+ throw err;
71
+ }
72
+ }
73
+ async function getHostPort(options) {
74
+ const host = options.host ?? 'localhost';
75
+ const basePort = options.port ? parseInt(options.port, 10) : utils_1.DEFAULT_PORT;
76
+ const port = await choosePort(host, basePort);
77
+ return { host, port };
78
+ }
79
+ exports.getHostPort = getHostPort;
@@ -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 { Props, LoadedPlugin } from '@docusaurus/types';
8
+ /**
9
+ * Runs the `injectHtmlTags` lifecycle, and aggregates all plugins' tags into
10
+ * directly render-able HTML markup.
11
+ */
12
+ export declare function loadHtmlTags(plugins: LoadedPlugin[]): Pick<Props, 'headTags' | 'preBodyTags' | 'postBodyTags'>;
@@ -0,0 +1,62 @@
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.loadHtmlTags = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
+ const html_tags_1 = tslib_1.__importDefault(require("html-tags"));
13
+ const void_1 = tslib_1.__importDefault(require("html-tags/void"));
14
+ const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
15
+ function assertIsHtmlTagObject(val) {
16
+ if (typeof val !== 'object' || !val) {
17
+ throw new Error(`"${val}" is not a valid HTML tag object.`);
18
+ }
19
+ if (typeof val.tagName !== 'string') {
20
+ throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
21
+ }
22
+ if (!html_tags_1.default.includes(val.tagName)) {
23
+ throw new Error(`Error loading ${JSON.stringify(val)}, "${val.tagName}" is not a valid HTML tag.`);
24
+ }
25
+ }
26
+ function htmlTagObjectToString(tag) {
27
+ assertIsHtmlTagObject(tag);
28
+ const isVoidTag = void_1.default.includes(tag.tagName);
29
+ const tagAttributes = tag.attributes ?? {};
30
+ const attributes = Object.keys(tagAttributes)
31
+ .map((attr) => {
32
+ const value = tagAttributes[attr];
33
+ if (typeof value === 'boolean') {
34
+ return value ? attr : undefined;
35
+ }
36
+ return `${attr}="${(0, escape_html_1.default)(value)}"`;
37
+ })
38
+ .filter((str) => Boolean(str));
39
+ const openingTag = `<${[tag.tagName].concat(attributes).join(' ')}>`;
40
+ const innerHTML = (!isVoidTag && tag.innerHTML) || '';
41
+ const closingTag = isVoidTag ? '' : `</${tag.tagName}>`;
42
+ return openingTag + innerHTML + closingTag;
43
+ }
44
+ function createHtmlTagsString(tags) {
45
+ return (Array.isArray(tags) ? tags : [tags])
46
+ .filter(Boolean)
47
+ .map((val) => (typeof val === 'string' ? val : htmlTagObjectToString(val)))
48
+ .join('\n');
49
+ }
50
+ /**
51
+ * Runs the `injectHtmlTags` lifecycle, and aggregates all plugins' tags into
52
+ * directly render-able HTML markup.
53
+ */
54
+ function loadHtmlTags(plugins) {
55
+ const pluginHtmlTags = plugins.map((plugin) => plugin.injectHtmlTags?.({ content: plugin.content }) ?? {});
56
+ const tagTypes = ['headTags', 'preBodyTags', 'postBodyTags'];
57
+ return Object.fromEntries(lodash_1.default.zip(tagTypes, tagTypes.map((type) => pluginHtmlTags
58
+ .map((tags) => createHtmlTagsString(tags[type]))
59
+ .join('\n')
60
+ .trim())));
61
+ }
62
+ exports.loadHtmlTags = loadHtmlTags;
@@ -4,17 +4,7 @@
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 { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
7
+ import type { I18n, DocusaurusConfig, I18nLocaleConfig } from '@docusaurus/types';
8
+ import type { LoadContextOptions } from './index';
8
9
  export declare function getDefaultLocaleConfig(locale: string): I18nLocaleConfig;
9
- export declare function shouldWarnAboutNodeVersion(version: number, locales: string[]): boolean;
10
- export declare function loadI18n(config: DocusaurusConfig, options?: {
11
- locale?: string;
12
- }): Promise<I18n>;
13
- export declare function localizePath({ pathType, path: originalPath, i18n, options, }: {
14
- pathType: 'fs' | 'url';
15
- path: string;
16
- i18n: I18n;
17
- options?: {
18
- localizePath?: boolean;
19
- };
20
- }): string;
10
+ export declare function loadI18n(config: DocusaurusConfig, options: Pick<LoadContextOptions, 'locale'>): Promise<I18n>;
@@ -1,87 +1,53 @@
1
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
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.localizePath = exports.loadI18n = exports.shouldWarnAboutNodeVersion = exports.getDefaultLocaleConfig = void 0;
9
+ exports.loadI18n = exports.getDefaultLocaleConfig = void 0;
4
10
  const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const utils_1 = require("@docusaurus/utils");
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
7
12
  const rtl_detect_1 = require("rtl-detect");
8
- const constants_1 = require("../constants");
9
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
10
13
  function getDefaultLocaleLabel(locale) {
11
- // Intl.DisplayNames is ES2021 - Node14+
12
- // https://v8.dev/features/intl-displaynames
13
- // @ts-expect-error: wait for TS support of ES2021 feature
14
- if (typeof Intl.DisplayNames !== 'undefined') {
15
- // @ts-expect-error: wait for TS support of ES2021 feature
16
- return new Intl.DisplayNames([locale], { type: 'language' }).of(locale);
17
- }
18
- return locale;
14
+ const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
15
+ return (languageName.charAt(0).toLocaleUpperCase(locale) + languageName.substring(1));
19
16
  }
20
17
  function getDefaultLocaleConfig(locale) {
21
18
  return {
22
19
  label: getDefaultLocaleLabel(locale),
23
- direction: rtl_detect_1.getLangDir(locale),
20
+ direction: (0, rtl_detect_1.getLangDir)(locale),
21
+ htmlLang: locale,
22
+ // If the locale name includes -u-ca-xxx the calendar will be defined
23
+ calendar: new Intl.Locale(locale).calendar ?? 'gregory',
24
+ path: locale,
24
25
  };
25
26
  }
26
27
  exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
27
- function shouldWarnAboutNodeVersion(version, locales) {
28
- const isOnlyEnglish = locales.length === 1 && locales.includes('en');
29
- const isOlderNodeVersion = version < 14;
30
- return isOlderNodeVersion && !isOnlyEnglish;
31
- }
32
- exports.shouldWarnAboutNodeVersion = shouldWarnAboutNodeVersion;
33
- async function loadI18n(config, options = {}) {
34
- var _a;
28
+ async function loadI18n(config, options) {
35
29
  const { i18n: i18nConfig } = config;
36
- const currentLocale = (_a = options.locale) !== null && _a !== void 0 ? _a : i18nConfig.defaultLocale;
30
+ const currentLocale = options.locale ?? i18nConfig.defaultLocale;
37
31
  if (!i18nConfig.locales.includes(currentLocale)) {
38
- console.warn(chalk_1.default.yellow(`The locale=${currentLocale} was not found in your site configuration: config.i18n.locales=[${i18nConfig.locales.join(',')}]
39
- Note: Docusaurus only support running one locale at a time.`));
32
+ logger_1.default.warn `The locale name=${currentLocale} was not found in your site configuration: Available locales are: ${i18nConfig.locales}
33
+ Note: Docusaurus only support running one locale at a time.`;
40
34
  }
41
35
  const locales = i18nConfig.locales.includes(currentLocale)
42
36
  ? i18nConfig.locales
43
37
  : i18nConfig.locales.concat(currentLocale);
44
- if (shouldWarnAboutNodeVersion(constants_1.NODE_MAJOR_VERSION, locales)) {
45
- console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use NodeJS >= 14 (instead of ${constants_1.NODE_MAJOR_VERSION})`));
46
- }
47
38
  function getLocaleConfig(locale) {
48
39
  return {
49
40
  ...getDefaultLocaleConfig(locale),
50
41
  ...i18nConfig.localeConfigs[locale],
51
42
  };
52
43
  }
53
- const localeConfigs = locales.reduce((acc, locale) => {
54
- return { ...acc, [locale]: getLocaleConfig(locale) };
55
- }, {});
44
+ const localeConfigs = Object.fromEntries(locales.map((locale) => [locale, getLocaleConfig(locale)]));
56
45
  return {
57
46
  defaultLocale: i18nConfig.defaultLocale,
58
47
  locales,
48
+ path: i18nConfig.path,
59
49
  currentLocale,
60
50
  localeConfigs,
61
51
  };
62
52
  }
63
53
  exports.loadI18n = loadI18n;
64
- function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
65
- const shouldLocalizePath = typeof options.localizePath === 'undefined'
66
- ? // By default, we don't localize the path of defaultLocale
67
- i18n.currentLocale !== i18n.defaultLocale
68
- : options.localizePath;
69
- if (shouldLocalizePath) {
70
- // FS paths need special care, for Windows support
71
- if (pathType === 'fs') {
72
- return path_1.default.join(originalPath, path_1.default.sep, i18n.currentLocale, path_1.default.sep);
73
- }
74
- // Url paths
75
- else if (pathType === 'url') {
76
- return utils_1.normalizeUrl([originalPath, '/', i18n.currentLocale, '/']);
77
- }
78
- // should never happen
79
- else {
80
- throw new Error(`unhandled pathType=${pathType}`);
81
- }
82
- }
83
- else {
84
- return originalPath;
85
- }
86
- }
87
- exports.localizePath = localizePath;
@@ -4,13 +4,35 @@
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 { LoadContext, PluginConfig, Props } from '@docusaurus/types';
7
+ import type { LoadContext, Props } from '@docusaurus/types';
8
8
  export declare type LoadContextOptions = {
9
- customOutDir?: string;
10
- customConfigFilePath?: string;
9
+ /** Usually the CWD; can be overridden with command argument. */
10
+ siteDir: string;
11
+ /** Custom output directory. Can be customized with `--out-dir` option */
12
+ outDir?: string;
13
+ /** Custom config path. Can be customized with `--config` option */
14
+ config?: string;
15
+ /** Default is `i18n.defaultLocale` */
11
16
  locale?: string;
17
+ /**
18
+ * `true` means the paths will have the locale prepended; `false` means they
19
+ * won't (useful for `yarn build -l zh-Hans` where the output should be
20
+ * emitted into `build/` instead of `build/zh-Hans/`); `undefined` is like the
21
+ * "smart" option where only non-default locale paths are localized
22
+ */
12
23
  localizePath?: boolean;
13
24
  };
14
- export declare function loadContext(siteDir: string, options?: LoadContextOptions): Promise<LoadContext>;
15
- export declare function loadPluginConfigs(context: LoadContext): PluginConfig[];
16
- export declare function load(siteDir: string, options?: LoadContextOptions): Promise<Props>;
25
+ /**
26
+ * Loading context is the very first step in site building. Its options are
27
+ * directly acquired from CLI options. It mainly loads `siteConfig` and the i18n
28
+ * context (which includes code translations). The `LoadContext` will be passed
29
+ * to plugin constructors.
30
+ */
31
+ export declare function loadContext(options: LoadContextOptions): Promise<LoadContext>;
32
+ /**
33
+ * This is the crux of the Docusaurus server-side. It reads everything it needs—
34
+ * code translations, config file, plugin modules... Plugins then use their
35
+ * lifecycles to generate content and other data. It is side-effect-ful because
36
+ * it generates temp files in the `.docusaurus` folder for the bundler.
37
+ */
38
+ export declare function load(options: LoadContextOptions): Promise<Props>;
@@ -6,190 +6,120 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.load = exports.loadPluginConfigs = exports.loadContext = void 0;
9
+ exports.load = exports.loadContext = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
11
13
  const utils_1 = require("@docusaurus/utils");
12
- const path_1 = tslib_1.__importStar(require("path"));
13
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
14
- const ssr_html_template_1 = tslib_1.__importDefault(require("../client/templates/ssr.html.template"));
15
- const constants_1 = require("../constants");
16
- const client_modules_1 = tslib_1.__importDefault(require("./client-modules"));
17
- const config_1 = tslib_1.__importDefault(require("./config"));
14
+ const config_1 = require("./config");
15
+ const clientModules_1 = require("./clientModules");
18
16
  const plugins_1 = require("./plugins");
19
- const presets_1 = tslib_1.__importDefault(require("./presets"));
20
- const routes_1 = tslib_1.__importDefault(require("./routes"));
21
- const themes_1 = tslib_1.__importDefault(require("./themes"));
22
- const html_tags_1 = require("./html-tags");
23
- const versions_1 = require("./versions");
24
- const duplicateRoutes_1 = require("./duplicateRoutes");
17
+ const routes_1 = require("./routes");
18
+ const htmlTags_1 = require("./htmlTags");
19
+ const siteMetadata_1 = require("./siteMetadata");
25
20
  const i18n_1 = require("./i18n");
26
21
  const translations_1 = require("./translations/translations");
27
- const lodash_1 = require("lodash");
28
- async function loadContext(siteDir, options = {}) {
29
- var _a;
30
- const { customOutDir, locale, customConfigFilePath } = options;
31
- const generatedFilesDir = path_1.default.isAbsolute(constants_1.GENERATED_FILES_DIR_NAME)
32
- ? constants_1.GENERATED_FILES_DIR_NAME
33
- : path_1.default.resolve(siteDir, constants_1.GENERATED_FILES_DIR_NAME);
34
- const siteConfigPathUnresolved = customConfigFilePath !== null && customConfigFilePath !== void 0 ? customConfigFilePath : constants_1.DEFAULT_CONFIG_FILE_NAME;
35
- const siteConfigPath = path_1.default.isAbsolute(siteConfigPathUnresolved)
36
- ? siteConfigPathUnresolved
37
- : path_1.default.resolve(siteDir, siteConfigPathUnresolved);
38
- const initialSiteConfig = config_1.default(siteConfigPath);
39
- const { ssrTemplate } = initialSiteConfig;
40
- const baseOutDir = customOutDir
41
- ? path_1.default.resolve(customOutDir)
42
- : path_1.default.resolve(siteDir, constants_1.DEFAULT_BUILD_DIR_NAME);
43
- const i18n = await i18n_1.loadI18n(initialSiteConfig, { locale });
44
- const baseUrl = i18n_1.localizePath({
22
+ /**
23
+ * Loading context is the very first step in site building. Its options are
24
+ * directly acquired from CLI options. It mainly loads `siteConfig` and the i18n
25
+ * context (which includes code translations). The `LoadContext` will be passed
26
+ * to plugin constructors.
27
+ */
28
+ async function loadContext(options) {
29
+ const { siteDir, outDir: baseOutDir = utils_1.DEFAULT_BUILD_DIR_NAME, locale, config: customConfigFilePath, } = options;
30
+ const generatedFilesDir = path_1.default.resolve(siteDir, utils_1.GENERATED_FILES_DIR_NAME);
31
+ const { siteConfig: initialSiteConfig, siteConfigPath } = await (0, config_1.loadSiteConfig)({
32
+ siteDir,
33
+ customConfigFilePath,
34
+ });
35
+ const i18n = await (0, i18n_1.loadI18n)(initialSiteConfig, { locale });
36
+ const baseUrl = (0, utils_1.localizePath)({
45
37
  path: initialSiteConfig.baseUrl,
46
38
  i18n,
47
39
  options,
48
40
  pathType: 'url',
49
41
  });
50
- const outDir = i18n_1.localizePath({
51
- path: baseOutDir,
42
+ const outDir = (0, utils_1.localizePath)({
43
+ path: path_1.default.resolve(siteDir, baseOutDir),
52
44
  i18n,
53
45
  options,
54
46
  pathType: 'fs',
55
47
  });
56
48
  const siteConfig = { ...initialSiteConfig, baseUrl };
57
- const codeTranslationFileContent = (_a = (await translations_1.readCodeTranslationFileContent({
58
- siteDir,
59
- locale: i18n.currentLocale,
60
- }))) !== null && _a !== void 0 ? _a : {};
49
+ const localizationDir = path_1.default.resolve(siteDir, i18n.path, i18n.localeConfigs[i18n.currentLocale].path);
50
+ const codeTranslationFileContent = (await (0, translations_1.readCodeTranslationFileContent)({ localizationDir })) ?? {};
61
51
  // We only need key->message for code translations
62
- const codeTranslations = lodash_1.mapValues(codeTranslationFileContent, (value) => value.message);
52
+ const codeTranslations = lodash_1.default.mapValues(codeTranslationFileContent, (value) => value.message);
63
53
  return {
64
54
  siteDir,
65
55
  generatedFilesDir,
56
+ localizationDir,
66
57
  siteConfig,
67
58
  siteConfigPath,
68
59
  outDir,
69
60
  baseUrl,
70
61
  i18n,
71
- ssrTemplate,
72
62
  codeTranslations,
73
63
  };
74
64
  }
75
65
  exports.loadContext = loadContext;
76
- function loadPluginConfigs(context) {
77
- const { plugins: presetPlugins, themes: presetThemes } = presets_1.default(context);
78
- const { siteConfig } = context;
79
- return [
80
- ...presetPlugins,
81
- ...presetThemes,
82
- // Site config should be the highest priority.
83
- ...(siteConfig.plugins || []),
84
- ...(siteConfig.themes || []),
85
- ];
86
- }
87
- exports.loadPluginConfigs = loadPluginConfigs;
88
- async function load(siteDir, options = {}) {
89
- // Context.
90
- const context = await loadContext(siteDir, options);
91
- const { generatedFilesDir, siteConfig, siteConfigPath, outDir, baseUrl, i18n, ssrTemplate, codeTranslations, } = context;
92
- // Plugins.
93
- const pluginConfigs = loadPluginConfigs(context);
94
- const { plugins, pluginsRouteConfigs, globalData, themeConfigTranslated, } = await plugins_1.loadPlugins({
95
- pluginConfigs,
96
- context,
97
- });
98
- // Side-effect to replace the untranslated themeConfig by the translated one
99
- context.siteConfig.themeConfig = themeConfigTranslated;
100
- duplicateRoutes_1.handleDuplicateRoutes(pluginsRouteConfigs, siteConfig.onDuplicateRoutes);
101
- // Site config must be generated after plugins
102
- // We want the generated config to have been normalized by the plugins!
103
- const genSiteConfig = utils_1.generate(generatedFilesDir, constants_1.DEFAULT_CONFIG_FILE_NAME, `export default ${JSON.stringify(siteConfig, null, 2)};`);
104
- // Themes.
105
- const fallbackTheme = path_1.default.resolve(__dirname, '../client/theme-fallback');
106
- const pluginThemes = plugins
107
- .map((plugin) => plugin.getThemePath && plugin.getThemePath())
108
- .filter((x) => Boolean(x));
109
- const userTheme = path_1.default.resolve(siteDir, constants_1.THEME_PATH);
110
- const alias = themes_1.default([fallbackTheme, ...pluginThemes], [userTheme]);
111
- // Make a fake plugin to:
112
- // - Resolve aliased theme components
113
- // - Inject scripts/stylesheets
114
- const { stylesheets = [], scripts = [], clientModules: siteConfigClientModules = [], } = siteConfig;
115
- plugins.push({
116
- name: 'docusaurus-bootstrap-plugin',
117
- options: {},
118
- version: { type: 'synthetic' },
119
- getClientModules() {
120
- return siteConfigClientModules;
121
- },
122
- configureWebpack: () => ({
123
- resolve: {
124
- alias,
125
- },
126
- }),
127
- injectHtmlTags: () => {
128
- const stylesheetsTags = stylesheets.map((source) => typeof source === 'string'
129
- ? `<link rel="stylesheet" href="${source}">`
130
- : {
131
- tagName: 'link',
132
- attributes: {
133
- rel: 'stylesheet',
134
- ...source,
135
- },
136
- });
137
- const scriptsTags = scripts.map((source) => typeof source === 'string'
138
- ? `<script type="text/javascript" src="${source}"></script>`
139
- : {
140
- tagName: 'script',
141
- attributes: {
142
- type: 'text/javascript',
143
- ...source,
144
- },
145
- });
146
- return {
147
- headTags: [...stylesheetsTags, ...scriptsTags],
148
- };
149
- },
150
- });
151
- // Load client modules.
152
- const clientModules = client_modules_1.default(plugins);
153
- const genClientModules = utils_1.generate(generatedFilesDir, 'client-modules.js', `export default [\n${clientModules
154
- // import() is async so we use require() because client modules can have
155
- // CSS and the order matters for loading CSS.
156
- // We need to JSON.stringify so that if its on windows, backslash are escaped.
157
- .map((module) => ` require(${JSON.stringify(module)}),`)
158
- .join('\n')}\n];\n`);
159
- // Load extra head & body html tags.
160
- const { headTags, preBodyTags, postBodyTags } = html_tags_1.loadHtmlTags(plugins);
161
- // Routing.
162
- const { registry, routesChunkNames, routesConfig, routesPaths, } = await routes_1.default(pluginsRouteConfigs, baseUrl);
163
- const genRegistry = utils_1.generate(generatedFilesDir, 'registry.js', `export default {
164
- ${Object.keys(registry)
165
- .sort()
166
- .map((key) =>
167
- // We need to JSON.stringify so that if its on windows, backslash are escaped.
168
- ` '${key}': [${registry[key].loader}, ${JSON.stringify(registry[key].modulePath)}, require.resolveWeak(${JSON.stringify(registry[key].modulePath)})],`)
169
- .join('\n')}};\n`);
170
- const genRoutesChunkNames = utils_1.generate(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
171
- const genRoutes = utils_1.generate(generatedFilesDir, 'routes.js', routesConfig);
172
- const genGlobalData = utils_1.generate(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
173
- const genI18n = utils_1.generate(generatedFilesDir, 'i18n.json', JSON.stringify(i18n, null, 2));
174
- const codeTranslationsWithFallbacks = {
175
- ...(await translations_1.getPluginsDefaultCodeTranslationMessages(plugins)),
176
- ...codeTranslations,
177
- };
178
- const genCodeTranslations = utils_1.generate(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslationsWithFallbacks, null, 2));
179
- // Version metadata.
180
- const siteMetadata = {
181
- docusaurusVersion: versions_1.getPackageJsonVersion(path_1.join(__dirname, '../../package.json')),
182
- siteVersion: versions_1.getPackageJsonVersion(path_1.join(siteDir, 'package.json')),
183
- pluginVersions: {},
66
+ /**
67
+ * This is the crux of the Docusaurus server-side. It reads everything it needs—
68
+ * code translations, config file, plugin modules... Plugins then use their
69
+ * lifecycles to generate content and other data. It is side-effect-ful because
70
+ * it generates temp files in the `.docusaurus` folder for the bundler.
71
+ */
72
+ async function load(options) {
73
+ const { siteDir } = options;
74
+ const context = await loadContext(options);
75
+ const { generatedFilesDir, siteConfig, siteConfigPath, outDir, baseUrl, i18n, localizationDir, codeTranslations: siteCodeTranslations, } = context;
76
+ const { plugins, pluginsRouteConfigs, globalData } = await (0, plugins_1.loadPlugins)(context);
77
+ const clientModules = (0, clientModules_1.loadClientModules)(plugins);
78
+ const { headTags, preBodyTags, postBodyTags } = (0, htmlTags_1.loadHtmlTags)(plugins);
79
+ const { registry, routesChunkNames, routesConfig, routesPaths } = (0, routes_1.loadRoutes)(pluginsRouteConfigs, baseUrl, siteConfig.onDuplicateRoutes);
80
+ const codeTranslations = {
81
+ ...(await (0, translations_1.getPluginsDefaultCodeTranslationMessages)(plugins)),
82
+ ...siteCodeTranslations,
184
83
  };
185
- plugins
186
- .filter(({ version: { type } }) => type !== 'synthetic')
187
- .forEach(({ name, version }) => {
188
- siteMetadata.pluginVersions[name] = version;
189
- });
190
- checkDocusaurusPackagesVersion(siteMetadata);
191
- const genSiteMetadata = utils_1.generate(generatedFilesDir, 'site-metadata.json', JSON.stringify(siteMetadata, null, 2));
84
+ const siteMetadata = await (0, siteMetadata_1.loadSiteMetadata)({ plugins, siteDir });
85
+ // === Side-effects part ===
86
+ const genWarning = (0, utils_1.generate)(generatedFilesDir,
87
+ // cSpell:ignore DONT
88
+ 'DONT-EDIT-THIS-FOLDER', `This folder stores temp files that Docusaurus' client bundler accesses.
89
+
90
+ DO NOT hand-modify files in this folder because they will be overwritten in the
91
+ next build. You can clear all build artifacts (including this folder) with the
92
+ \`docusaurus clear\` command.
93
+ `);
94
+ const genSiteConfig = (0, utils_1.generate)(generatedFilesDir, `${utils_1.DEFAULT_CONFIG_FILE_NAME}.mjs`, `/*
95
+ * AUTOGENERATED - DON'T EDIT
96
+ * Your edits in this file will be overwritten in the next build!
97
+ * Modify the docusaurus.config.js file at your site's root instead.
98
+ */
99
+ export default ${JSON.stringify(siteConfig, null, 2)};
100
+ `);
101
+ const genClientModules = (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
102
+ ${clientModules
103
+ // Use `require()` because `import()` is async but client modules can have CSS
104
+ // and the order matters for loading CSS.
105
+ .map((clientModule) => ` require('${(0, utils_1.escapePath)(clientModule)}'),`)
106
+ .join('\n')}
107
+ ];
108
+ `);
109
+ const genRegistry = (0, utils_1.generate)(generatedFilesDir, 'registry.js', `export default {
110
+ ${Object.entries(registry)
111
+ .sort((a, b) => a[0].localeCompare(b[0]))
112
+ .map(([chunkName, modulePath]) => ` '${chunkName}': [() => import(/* webpackChunkName: '${chunkName}' */ '${modulePath}'), '${modulePath}', require.resolveWeak('${modulePath}')],`)
113
+ .join('\n')}};
114
+ `);
115
+ const genRoutesChunkNames = (0, utils_1.generate)(generatedFilesDir, 'routesChunkNames.json', JSON.stringify(routesChunkNames, null, 2));
116
+ const genRoutes = (0, utils_1.generate)(generatedFilesDir, 'routes.js', routesConfig);
117
+ const genGlobalData = (0, utils_1.generate)(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
118
+ const genI18n = (0, utils_1.generate)(generatedFilesDir, 'i18n.json', JSON.stringify(i18n, null, 2));
119
+ const genCodeTranslations = (0, utils_1.generate)(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslations, null, 2));
120
+ const genSiteMetadata = (0, utils_1.generate)(generatedFilesDir, 'site-metadata.json', JSON.stringify(siteMetadata, null, 2));
192
121
  await Promise.all([
122
+ genWarning,
193
123
  genClientModules,
194
124
  genSiteConfig,
195
125
  genRegistry,
@@ -200,7 +130,7 @@ ${Object.keys(registry)
200
130
  genI18n,
201
131
  genCodeTranslations,
202
132
  ]);
203
- const props = {
133
+ return {
204
134
  siteConfig,
205
135
  siteConfigPath,
206
136
  siteMetadata,
@@ -208,6 +138,7 @@ ${Object.keys(registry)
208
138
  outDir,
209
139
  baseUrl,
210
140
  i18n,
141
+ localizationDir,
211
142
  generatedFilesDir,
212
143
  routes: pluginsRouteConfigs,
213
144
  routesPaths,
@@ -215,25 +146,7 @@ ${Object.keys(registry)
215
146
  headTags,
216
147
  preBodyTags,
217
148
  postBodyTags,
218
- ssrTemplate: ssrTemplate || ssr_html_template_1.default,
219
149
  codeTranslations,
220
150
  };
221
- return props;
222
151
  }
223
152
  exports.load = load;
224
- // We want all @docusaurus/* packages to have the exact same version!
225
- // See https://github.com/facebook/docusaurus/issues/3371
226
- // See https://github.com/facebook/docusaurus/pull/3386
227
- function checkDocusaurusPackagesVersion(siteMetadata) {
228
- const { docusaurusVersion } = siteMetadata;
229
- Object.entries(siteMetadata.pluginVersions).forEach(([plugin, versionInfo]) => {
230
- var _a;
231
- if (versionInfo.type === 'package' &&
232
- ((_a = versionInfo.name) === null || _a === void 0 ? void 0 : _a.startsWith('@docusaurus/')) &&
233
- versionInfo.version !== docusaurusVersion) {
234
- // should we throw instead?
235
- // It still could work with different versions
236
- console.warn(chalk_1.default.red(`Bad ${plugin} version ${versionInfo.version}.\nAll official @docusaurus/* packages should have the exact same version as @docusaurus/core (${docusaurusVersion}).\nMaybe you want to check, or regenerate your yarn.lock or package-lock.json file?`));
237
- }
238
- });
239
- }