@docusaurus/core 2.0.0-beta.12faed89d → 2.0.0-beta.14

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 (111) hide show
  1. package/bin/beforeCli.js +46 -22
  2. package/bin/docusaurus.js +42 -44
  3. package/lib/babel/preset.d.ts +6 -0
  4. package/lib/babel/preset.js +3 -3
  5. package/lib/choosePort.js +19 -20
  6. package/lib/client/.eslintrc.js +0 -1
  7. package/lib/client/App.js +12 -22
  8. package/lib/client/LinksCollector.d.ts +2 -2
  9. package/lib/client/LinksCollector.js +4 -8
  10. package/lib/client/PendingNavigation.d.ts +24 -1
  11. package/lib/client/PendingNavigation.js +1 -1
  12. package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +5 -0
  13. package/lib/client/client-lifecycles-dispatcher.d.ts +2 -2
  14. package/lib/client/client-lifecycles-dispatcher.js +0 -2
  15. package/lib/client/docusaurus.d.ts +6 -0
  16. package/lib/client/docusaurus.js +11 -19
  17. package/lib/client/exports/BrowserOnly.js +5 -3
  18. package/lib/client/exports/ErrorBoundary.d.ts +18 -0
  19. package/lib/client/exports/ErrorBoundary.js +35 -0
  20. package/lib/client/exports/Interpolate.js +12 -15
  21. package/lib/client/exports/Link.js +9 -9
  22. package/lib/client/exports/Translate.d.ts +2 -2
  23. package/lib/client/exports/Translate.js +13 -9
  24. package/lib/client/exports/browserContext.d.ts +11 -0
  25. package/lib/client/exports/browserContext.js +21 -0
  26. package/lib/client/exports/constants.js +1 -11
  27. package/lib/client/exports/{context.d.ts → docusaurusContext.d.ts} +5 -3
  28. package/lib/client/exports/docusaurusContext.js +25 -0
  29. package/lib/client/exports/useBaseUrl.js +2 -4
  30. package/lib/client/exports/useDocusaurusContext.js +2 -7
  31. package/lib/client/exports/useGlobalData.js +1 -5
  32. package/lib/client/exports/{context.js → useIsBrowser.d.ts} +1 -2
  33. package/lib/{webpack/sharedModuleAliases.d.ts → client/exports/useIsBrowser.js} +5 -4
  34. package/lib/client/flat.d.ts +2 -1
  35. package/lib/client/flat.js +7 -9
  36. package/lib/client/normalizeLocation.d.ts +1 -3
  37. package/lib/client/prefetch.js +0 -1
  38. package/lib/client/serverEntry.js +20 -42
  39. package/lib/client/theme-fallback/Error/index.js +47 -0
  40. package/lib/client/theme-fallback/Layout/index.js +1 -1
  41. package/lib/client/theme-fallback/Loading/index.js +2 -2
  42. package/lib/client/theme-fallback/Root/index.js +1 -3
  43. package/lib/commands/build.js +39 -44
  44. package/lib/commands/clear.d.ts +6 -0
  45. package/lib/commands/clear.js +17 -18
  46. package/lib/commands/commandUtils.d.ts +6 -0
  47. package/lib/commands/commandUtils.js +7 -7
  48. package/lib/commands/deploy.d.ts +3 -0
  49. package/lib/commands/deploy.js +99 -64
  50. package/lib/commands/external.js +4 -4
  51. package/lib/commands/serve.js +12 -18
  52. package/lib/commands/start.js +98 -86
  53. package/lib/commands/swizzle.js +42 -51
  54. package/lib/commands/writeHeadingIds.d.ts +9 -6
  55. package/lib/commands/writeHeadingIds.js +33 -34
  56. package/lib/commands/writeTranslations.js +31 -11
  57. package/lib/server/brokenLinks.js +13 -17
  58. package/lib/server/client-modules/index.js +1 -3
  59. package/lib/server/config.js +4 -4
  60. package/lib/server/configValidation.d.ts +1 -1
  61. package/lib/server/configValidation.js +14 -7
  62. package/lib/server/duplicateRoutes.js +8 -2
  63. package/lib/server/html-tags/htmlTags.js +5 -6
  64. package/lib/server/html-tags/index.js +2 -2
  65. package/lib/server/i18n.js +16 -16
  66. package/lib/server/index.js +132 -59
  67. package/lib/server/loadSetup.js +3 -3
  68. package/lib/server/moduleShorthand.d.ts +9 -0
  69. package/lib/server/moduleShorthand.js +42 -0
  70. package/lib/server/plugins/applyRouteTrailingSlash.js +1 -1
  71. package/lib/server/plugins/index.d.ts +1 -1
  72. package/lib/server/plugins/index.js +25 -21
  73. package/lib/server/plugins/init.js +9 -12
  74. package/lib/server/plugins/pluginIds.js +6 -4
  75. package/lib/server/presets/index.js +12 -12
  76. package/lib/server/routes.js +9 -11
  77. package/lib/server/themes/alias.d.ts +1 -0
  78. package/lib/server/themes/alias.js +21 -12
  79. package/lib/server/themes/index.d.ts +1 -1
  80. package/lib/server/themes/index.js +22 -23
  81. package/lib/server/translations/translations.d.ts +6 -0
  82. package/lib/server/translations/translations.js +19 -26
  83. package/lib/server/translations/translationsExtractor.d.ts +7 -1
  84. package/lib/server/translations/translationsExtractor.js +66 -59
  85. package/lib/server/utils.d.ts +8 -2
  86. package/lib/server/utils.js +8 -10
  87. package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
  88. package/lib/server/versions/__tests/index.test.js +5 -5
  89. package/lib/server/versions/index.js +6 -6
  90. package/lib/webpack/base.js +14 -16
  91. package/lib/webpack/client.js +9 -18
  92. package/lib/webpack/plugins/CleanWebpackPlugin.js +4 -11
  93. package/lib/webpack/plugins/LogPlugin.js +5 -6
  94. package/lib/webpack/plugins/WaitPlugin.js +4 -4
  95. package/lib/webpack/server.js +9 -9
  96. package/lib/webpack/utils.d.ts +0 -22
  97. package/lib/webpack/utils.js +37 -134
  98. package/package.json +55 -50
  99. package/lib/.tsbuildinfo +0 -1
  100. package/lib/client/.tsbuildinfo +0 -1
  101. package/lib/commands/buildRemoteBranchUrl.d.ts +0 -7
  102. package/lib/commands/buildRemoteBranchUrl.js +0 -27
  103. package/lib/constants.d.ts +0 -18
  104. package/lib/constants.js +0 -23
  105. package/lib/webpack/react-dev-utils-webpack5/README.md +0 -11
  106. package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.js +0 -57
  107. package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +0 -138
  108. package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.js +0 -285
  109. package/lib/webpack/sharedModuleAliases.js +0 -18
  110. package/tsconfig.client.json +0 -13
  111. package/tsconfig.json +0 -13
@@ -1,11 +1,31 @@
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
9
  const tslib_1 = require("tslib");
10
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
4
11
  const server_1 = require("../server");
5
- const init_1 = tslib_1.__importDefault(require("../server/plugins/init"));
12
+ const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
6
13
  const translations_1 = require("../server/translations/translations");
7
14
  const translationsExtractor_1 = require("../server/translations/translationsExtractor");
8
15
  const utils_1 = require("../webpack/utils");
16
+ // This is a hack, so that @docusaurus/theme-common translations are extracted!
17
+ // A theme doesn't have a way to express that one of its dependency (like @docusaurus/theme-common) also has translations to extract
18
+ // Instead of introducing a new lifecycle (like plugin.getThemeTranslationPaths() ?)
19
+ // We just make an exception and assume that Docusaurus user is using an official theme
20
+ async function getExtraSourceCodeFilePaths() {
21
+ try {
22
+ const themeCommonSourceDir = path_1.default.dirname(require.resolve('@docusaurus/theme-common/lib'));
23
+ return (0, translationsExtractor_1.globSourceCodeFilePaths)([themeCommonSourceDir]);
24
+ }
25
+ catch (e) {
26
+ return []; // User may not use a Docusaurus official theme? Quite unlikely...
27
+ }
28
+ }
9
29
  async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }) {
10
30
  var _a;
11
31
  if (plugin.getTranslationFiles) {
@@ -14,7 +34,7 @@ async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }
14
34
  content,
15
35
  });
16
36
  await Promise.all(translationFiles.map(async (translationFile) => {
17
- await translations_1.writePluginTranslations({
37
+ await (0, translations_1.writePluginTranslations)({
18
38
  siteDir,
19
39
  plugin,
20
40
  translationFile,
@@ -26,12 +46,12 @@ async function writePluginTranslationFiles({ siteDir, plugin, locale, options, }
26
46
  }
27
47
  async function writeTranslations(siteDir, options) {
28
48
  var _a;
29
- const context = await server_1.loadContext(siteDir, {
49
+ const context = await (0, server_1.loadContext)(siteDir, {
30
50
  customConfigFilePath: options.config,
31
51
  locale: options.locale,
32
52
  });
33
- const pluginConfigs = server_1.loadPluginConfigs(context);
34
- const plugins = init_1.default({
53
+ const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
54
+ const plugins = (0, init_1.default)({
35
55
  pluginConfigs,
36
56
  context,
37
57
  });
@@ -40,17 +60,17 @@ async function writeTranslations(siteDir, options) {
40
60
  throw new Error(`Can't write-translation for locale "${locale}" that is not in the locale configuration file.
41
61
  Available locales are: ${context.i18n.locales.join(',')}.`);
42
62
  }
43
- const babelOptions = utils_1.getBabelOptions({
63
+ const babelOptions = (0, utils_1.getBabelOptions)({
44
64
  isServer: true,
45
- babelOptions: utils_1.getCustomBabelConfigFilePath(siteDir),
65
+ babelOptions: (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
46
66
  });
47
- const extractedCodeTranslations = await translationsExtractor_1.extractSiteSourceCodeTranslations(siteDir, plugins, babelOptions);
48
- const defaultCodeMessages = await translations_1.getPluginsDefaultCodeTranslationMessages(plugins);
49
- const codeTranslations = translations_1.applyDefaultCodeTranslations({
67
+ const extractedCodeTranslations = await (0, translationsExtractor_1.extractSiteSourceCodeTranslations)(siteDir, plugins, babelOptions, await getExtraSourceCodeFilePaths());
68
+ const defaultCodeMessages = await (0, translations_1.getPluginsDefaultCodeTranslationMessages)(plugins);
69
+ const codeTranslations = (0, translations_1.applyDefaultCodeTranslations)({
50
70
  extractedCodeTranslations,
51
71
  defaultCodeMessages,
52
72
  });
53
- await translations_1.writeCodeTranslations({ siteDir, locale }, codeTranslations, options);
73
+ await (0, translations_1.writeCodeTranslations)({ siteDir, locale }, codeTranslations, options);
54
74
  await Promise.all(plugins.map(async (plugin) => {
55
75
  await writePluginTranslationFiles({ siteDir, plugin, locale, options });
56
76
  }));
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.handleBrokenLinks = exports.filterExistingFileLinks = exports.getBrokenLinksErrorMessage = exports.getAllBrokenLinks = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const react_router_config_1 = require("react-router-config");
12
- const resolve_pathname_1 = tslib_1.__importDefault(require("resolve-pathname"));
13
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const resolve_pathname_1 = (0, tslib_1.__importDefault)(require("resolve-pathname"));
13
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
14
14
  const lodash_1 = require("lodash");
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const utils_2 = require("./utils");
17
- const path_1 = tslib_1.__importDefault(require("path"));
17
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
18
18
  function toReactRouterRoutes(routes) {
19
19
  // @ts-expect-error: types incompatible???
20
20
  return routes;
@@ -29,12 +29,12 @@ function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
29
29
  // we must resolve the links before using matchRoutes
30
30
  // resolvePathname is used internally by ReactRouter
31
31
  function resolveLink(link) {
32
- const resolvedLink = resolve_pathname_1.default(onlyPathname(link), pagePath);
32
+ const resolvedLink = (0, resolve_pathname_1.default)(onlyPathname(link), pagePath);
33
33
  return { link, resolvedLink };
34
34
  }
35
35
  function isBrokenLink(link) {
36
36
  const matchedRoutes = [link, decodeURI(link)]
37
- .map((l) => react_router_config_1.matchRoutes(toReactRouterRoutes(routes), l))
37
+ .map((l) => (0, react_router_config_1.matchRoutes)(toReactRouterRoutes(routes), l))
38
38
  .reduce((prev, cur) => prev.concat(cur));
39
39
  return matchedRoutes.length === 0;
40
40
  }
@@ -46,15 +46,13 @@ function getPageBrokenLinks({ pagePath, pageLinks, routes, }) {
46
46
  // We also need to remove the match all 404 route
47
47
  function filterIntermediateRoutes(routesInput) {
48
48
  const routesWithout404 = routesInput.filter((route) => route.path !== '*');
49
- return utils_2.getAllFinalRoutes(routesWithout404);
49
+ return (0, utils_2.getAllFinalRoutes)(routesWithout404);
50
50
  }
51
51
  function getAllBrokenLinks({ allCollectedLinks, routes, }) {
52
52
  const filteredRoutes = filterIntermediateRoutes(routes);
53
- const allBrokenLinks = lodash_1.mapValues(allCollectedLinks, (pageLinks, pagePath) => {
54
- return getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes });
55
- });
53
+ const allBrokenLinks = (0, lodash_1.mapValues)(allCollectedLinks, (pageLinks, pagePath) => getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes }));
56
54
  // remove pages without any broken link
57
- return lodash_1.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
55
+ return (0, lodash_1.pickBy)(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
58
56
  }
59
57
  exports.getAllBrokenLinks = getAllBrokenLinks;
60
58
  function getBrokenLinksErrorMessage(allBrokenLinks) {
@@ -74,8 +72,8 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
74
72
  // Add an additional message in such case to help user figure this out.
75
73
  // see https://github.com/facebook/docusaurus/issues/3567#issuecomment-706973805
76
74
  function getLayoutBrokenLinksHelpMessage() {
77
- const flatList = lodash_1.flatten(Object.entries(allBrokenLinks).map(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink }))));
78
- const countedBrokenLinks = lodash_1.countBy(flatList, (item) => item.brokenLink.link);
75
+ const flatList = Object.entries(allBrokenLinks).flatMap(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink })));
76
+ const countedBrokenLinks = (0, lodash_1.countBy)(flatList, (item) => item.brokenLink.link);
79
77
  const FrequencyThreshold = 5; // Is this a good value?
80
78
  const frequentLinks = Object.entries(countedBrokenLinks)
81
79
  .filter(([, count]) => count >= FrequencyThreshold)
@@ -106,7 +104,7 @@ async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, })
106
104
  // not easy to make this async :'(
107
105
  function linkFileExists(link) {
108
106
  // /baseUrl/javadoc/ -> /outDir/javadoc
109
- const baseFilePath = utils_1.removeSuffix(`${outDir}/${utils_1.removePrefix(link, baseUrl)}`, '/');
107
+ const baseFilePath = (0, utils_1.removeSuffix)(`${outDir}/${(0, utils_1.removePrefix)(link, baseUrl)}`, '/');
110
108
  // -> /outDir/javadoc
111
109
  // -> /outDir/javadoc.html
112
110
  // -> /outDir/javadoc/index.html
@@ -117,9 +115,7 @@ async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, })
117
115
  }
118
116
  return filePathsToTry.some(isExistingFile);
119
117
  }
120
- return lodash_1.mapValues(allCollectedLinks, (links) => {
121
- return links.filter((link) => !linkFileExists(link));
122
- });
118
+ return (0, lodash_1.mapValues)(allCollectedLinks, (links) => links.filter((link) => !linkFileExists(link)));
123
119
  }
124
120
  exports.filterExistingFileLinks = filterExistingFileLinks;
125
121
  async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }) {
@@ -139,7 +135,7 @@ async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, bas
139
135
  });
140
136
  const errorMessage = getBrokenLinksErrorMessage(allBrokenLinks);
141
137
  if (errorMessage) {
142
- utils_1.reportMessage(errorMessage, onBrokenLinks);
138
+ (0, utils_1.reportMessage)(errorMessage, onBrokenLinks);
143
139
  }
144
140
  }
145
141
  exports.handleBrokenLinks = handleBrokenLinks;
@@ -7,8 +7,6 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  function loadClientModules(plugins) {
10
- return [].concat(...plugins
11
- .map((plugin) => { var _a, _b; return (_b = (_a = plugin.getClientModules) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; })
12
- .filter(Boolean));
10
+ return plugins.flatMap((plugin) => { var _a, _b; return (_b = (_a = plugin.getClientModules) === null || _a === void 0 ? void 0 : _a.call(plugin)) !== null && _b !== void 0 ? _b : []; });
13
11
  }
14
12
  exports.default = loadClientModules;
@@ -7,14 +7,14 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
- const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
10
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
11
+ const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
12
12
  const configValidation_1 = require("./configValidation");
13
13
  function loadConfig(configPath) {
14
14
  if (!fs_extra_1.default.existsSync(configPath)) {
15
15
  throw new Error(`Config file at "${configPath}" not found.`);
16
16
  }
17
- const loadedConfig = import_fresh_1.default(configPath);
18
- return configValidation_1.validateConfig(loadedConfig);
17
+ const loadedConfig = (0, import_fresh_1.default)(configPath);
18
+ return (0, configValidation_1.validateConfig)(loadedConfig);
19
19
  }
20
20
  exports.default = loadConfig;
@@ -7,6 +7,6 @@
7
7
  import { DocusaurusConfig, I18nConfig } from '@docusaurus/types';
8
8
  import { Joi } from '@docusaurus/utils-validation';
9
9
  export declare const DEFAULT_I18N_CONFIG: I18nConfig;
10
- export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'baseUrlIssueBanner'>;
10
+ export declare const DEFAULT_CONFIG: Pick<DocusaurusConfig, 'i18n' | 'onBrokenLinks' | 'onBrokenMarkdownLinks' | 'onDuplicateRoutes' | 'plugins' | 'themes' | 'presets' | 'customFields' | 'themeConfig' | 'titleDelimiter' | 'noIndex' | 'baseUrlIssueBanner' | 'staticDirectories'>;
11
11
  export declare const ConfigSchema: Joi.ObjectSchema<any>;
12
12
  export declare function validateConfig(config: Partial<DocusaurusConfig>): DocusaurusConfig;
@@ -7,7 +7,9 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.validateConfig = exports.ConfigSchema = exports.DEFAULT_CONFIG = exports.DEFAULT_I18N_CONFIG = void 0;
10
- const constants_1 = require("../constants");
10
+ const tslib_1 = require("tslib");
11
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
+ const utils_1 = require("@docusaurus/utils");
11
13
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
14
  const DEFAULT_I18N_LOCALE = 'en';
13
15
  exports.DEFAULT_I18N_CONFIG = {
@@ -28,6 +30,7 @@ exports.DEFAULT_CONFIG = {
28
30
  titleDelimiter: '|',
29
31
  noIndex: false,
30
32
  baseUrlIssueBanner: true,
33
+ staticDirectories: [utils_1.STATIC_DIR_NAME],
31
34
  };
32
35
  const PluginSchema = utils_validation_1.Joi.alternatives()
33
36
  .try(utils_validation_1.Joi.function(), utils_validation_1.Joi.array().ordered(utils_validation_1.Joi.function().required(), utils_validation_1.Joi.object().required()), utils_validation_1.Joi.string(), utils_validation_1.Joi.array()
@@ -68,7 +71,7 @@ const I18N_CONFIG_SCHEMA = utils_validation_1.Joi.object({
68
71
  })
69
72
  .optional()
70
73
  .default(exports.DEFAULT_I18N_CONFIG);
71
- const SiteUrlSchema = utils_validation_1.URISchema.required().custom(function (value, helpers) {
74
+ const SiteUrlSchema = utils_validation_1.URISchema.required().custom((value, helpers) => {
72
75
  try {
73
76
  const { pathname } = new URL(value);
74
77
  if (pathname !== '/') {
@@ -84,7 +87,7 @@ const SiteUrlSchema = utils_validation_1.URISchema.required().custom(function (v
84
87
  exports.ConfigSchema = utils_validation_1.Joi.object({
85
88
  baseUrl: utils_validation_1.Joi.string()
86
89
  .required()
87
- .regex(new RegExp('/$', 'm'))
90
+ .regex(/\/$/m)
88
91
  .message('{{#label}} must be a string with a trailing slash.'),
89
92
  baseUrlIssueBanner: utils_validation_1.Joi.boolean().default(exports.DEFAULT_CONFIG.baseUrlIssueBanner),
90
93
  favicon: utils_validation_1.Joi.string().optional(),
@@ -102,7 +105,11 @@ exports.ConfigSchema = utils_validation_1.Joi.object({
102
105
  .equal('ignore', 'log', 'warn', 'error', 'throw')
103
106
  .default(exports.DEFAULT_CONFIG.onDuplicateRoutes),
104
107
  organizationName: utils_validation_1.Joi.string().allow(''),
108
+ staticDirectories: utils_validation_1.Joi.array()
109
+ .items(utils_validation_1.Joi.string())
110
+ .default(exports.DEFAULT_CONFIG.staticDirectories),
105
111
  projectName: utils_validation_1.Joi.string().allow(''),
112
+ deploymentBranch: utils_validation_1.Joi.string().optional(),
106
113
  customFields: utils_validation_1.Joi.object().unknown().default(exports.DEFAULT_CONFIG.customFields),
107
114
  githubHost: utils_validation_1.Joi.string(),
108
115
  plugins: utils_validation_1.Joi.array().items(PluginSchema).default(exports.DEFAULT_CONFIG.plugins),
@@ -138,11 +145,11 @@ function validateConfig(config) {
138
145
  const { error, warning, value } = exports.ConfigSchema.validate(config, {
139
146
  abortEarly: false,
140
147
  });
141
- utils_validation_1.printWarning(warning);
148
+ (0, utils_validation_1.printWarning)(warning);
142
149
  if (error) {
143
- utils_validation_1.logValidationBugReportHint();
150
+ (0, utils_validation_1.logValidationBugReportHint)();
144
151
  if (utils_validation_1.isValidationDisabledEscapeHatch) {
145
- console.error(error);
152
+ logger_1.default.error(error.message);
146
153
  return config;
147
154
  }
148
155
  const unknownFields = error.details.reduce((formattedError, err) => {
@@ -155,7 +162,7 @@ function validateConfig(config) {
155
162
  ? `${accumulatedErr}${err.message}\n`
156
163
  : accumulatedErr, '');
157
164
  formattedError = unknownFields
158
- ? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${constants_1.DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/docusaurus.config.js/#customfields`
165
+ ? `${formattedError}These field(s) (${unknownFields}) are not recognized in ${utils_1.DEFAULT_CONFIG_FILE_NAME}.\nIf you still want these fields to be in your configuration, put them in the "customFields" field.\nSee https://docusaurus.io/docs/docusaurus.config.js/#customfields`
159
166
  : formattedError;
160
167
  throw new Error(formattedError);
161
168
  }
@@ -1,10 +1,16 @@
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
9
  exports.handleDuplicateRoutes = exports.getDuplicateRoutesMessage = exports.getAllDuplicateRoutes = void 0;
4
10
  const utils_1 = require("@docusaurus/utils");
5
11
  const utils_2 = require("./utils");
6
12
  function getAllDuplicateRoutes(pluginsRouteConfigs) {
7
- const allRoutes = utils_2.getAllFinalRoutes(pluginsRouteConfigs).map((routeConfig) => routeConfig.path);
13
+ const allRoutes = (0, utils_2.getAllFinalRoutes)(pluginsRouteConfigs).map((routeConfig) => routeConfig.path);
8
14
  const seenRoutes = {};
9
15
  return allRoutes.filter((route) => {
10
16
  if (Object.prototype.hasOwnProperty.call(seenRoutes, route)) {
@@ -32,7 +38,7 @@ function handleDuplicateRoutes(pluginsRouteConfigs, onDuplicateRoutes) {
32
38
  const message = getDuplicateRoutesMessage(duplicatePaths);
33
39
  if (message) {
34
40
  const finalMessage = `Duplicate routes found!\n${message}\nThis could lead to non-deterministic routing behavior`;
35
- utils_1.reportMessage(finalMessage, onDuplicateRoutes);
41
+ (0, utils_1.reportMessage)(finalMessage, onDuplicateRoutes);
36
42
  }
37
43
  }
38
44
  exports.handleDuplicateRoutes = handleDuplicateRoutes;
@@ -8,14 +8,13 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const lodash_1 = require("lodash");
11
- const html_tags_1 = tslib_1.__importDefault(require("html-tags"));
12
- const void_1 = tslib_1.__importDefault(require("html-tags/void"));
13
- const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
11
+ const html_tags_1 = (0, tslib_1.__importDefault)(require("html-tags"));
12
+ const void_1 = (0, tslib_1.__importDefault)(require("html-tags/void"));
13
+ const escape_html_1 = (0, tslib_1.__importDefault)(require("escape-html"));
14
14
  function assertIsHtmlTagObject(val) {
15
- if (!lodash_1.isPlainObject(val)) {
15
+ if (!(0, lodash_1.isPlainObject)(val)) {
16
16
  throw new Error(`"${val}" is not a valid HTML tag object.`);
17
17
  }
18
- // @ts-expect-error: If tagName doesn't exist, it will throw.
19
18
  if (typeof val.tagName !== 'string') {
20
19
  throw new Error(`${JSON.stringify(val)} is not a valid HTML tag object. "tagName" must be defined as a string.`);
21
20
  }
@@ -33,7 +32,7 @@ function htmlTagObjectToString(tagDefinition) {
33
32
  if (tagAttributes[attributeName] === true) {
34
33
  return attributeName;
35
34
  }
36
- return `${attributeName}="${escape_html_1.default(tagAttributes[attributeName])}"`;
35
+ return `${attributeName}="${(0, escape_html_1.default)(tagAttributes[attributeName])}"`;
37
36
  });
38
37
  return `<${[tagDefinition.tagName].concat(attributes).join(' ')}>${(!isVoidTag && tagDefinition.innerHTML) || ''}${isVoidTag ? '' : `</${tagDefinition.tagName}>`}`;
39
38
  }
@@ -8,9 +8,9 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadHtmlTags = exports.createHtmlTagsString = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const htmlTags_1 = tslib_1.__importDefault(require("./htmlTags"));
11
+ const htmlTags_1 = (0, tslib_1.__importDefault)(require("./htmlTags"));
12
12
  function toString(val) {
13
- return typeof val === 'string' ? val : htmlTags_1.default(val);
13
+ return typeof val === 'string' ? val : (0, htmlTags_1.default)(val);
14
14
  }
15
15
  function createHtmlTagsString(tags) {
16
16
  return Array.isArray(tags) ? tags.map(toString).join('\n') : toString(tags);
@@ -1,26 +1,31 @@
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
9
  exports.localizePath = exports.loadI18n = exports.shouldWarnAboutNodeVersion = exports.getDefaultLocaleConfig = void 0;
4
10
  const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
11
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
6
12
  const utils_1 = require("@docusaurus/utils");
7
13
  const rtl_detect_1 = require("rtl-detect");
8
- const constants_1 = require("../constants");
9
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
14
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
10
15
  function getDefaultLocaleLabel(locale) {
11
16
  // Intl.DisplayNames is ES2021 - Node14+
12
17
  // https://v8.dev/features/intl-displaynames
13
- // @ts-expect-error: wait for TS support of ES2021 feature
14
18
  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);
19
+ const languageName = new Intl.DisplayNames(locale, { type: 'language' }).of(locale);
20
+ return (languageName.charAt(0).toLocaleUpperCase(locale) +
21
+ languageName.substring(1));
17
22
  }
18
23
  return locale;
19
24
  }
20
25
  function getDefaultLocaleConfig(locale) {
21
26
  return {
22
27
  label: getDefaultLocaleLabel(locale),
23
- direction: rtl_detect_1.getLangDir(locale),
28
+ direction: (0, rtl_detect_1.getLangDir)(locale),
24
29
  };
25
30
  }
26
31
  exports.getDefaultLocaleConfig = getDefaultLocaleConfig;
@@ -35,24 +40,19 @@ async function loadI18n(config, options = {}) {
35
40
  const { i18n: i18nConfig } = config;
36
41
  const currentLocale = (_a = options.locale) !== null && _a !== void 0 ? _a : i18nConfig.defaultLocale;
37
42
  if (!i18nConfig.locales.includes(currentLocale)) {
38
- console.warn(chalk_1.default.yellow(`The locale "${currentLocale}" was not found in your site configuration: Available locales are: ${i18nConfig.locales.join(',')}.
39
- Note: Docusaurus only support running one locale at a time.`));
43
+ logger_1.default.warn `The locale name=${currentLocale} was not found in your site configuration: Available locales are: ${i18nConfig.locales}
44
+ Note: Docusaurus only support running one locale at a time.`;
40
45
  }
41
46
  const locales = i18nConfig.locales.includes(currentLocale)
42
47
  ? i18nConfig.locales
43
48
  : 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 Node.js 14 or later (instead of ${constants_1.NODE_MAJOR_VERSION}).`));
46
- }
47
49
  function getLocaleConfig(locale) {
48
50
  return {
49
51
  ...getDefaultLocaleConfig(locale),
50
52
  ...i18nConfig.localeConfigs[locale],
51
53
  };
52
54
  }
53
- const localeConfigs = locales.reduce((acc, locale) => {
54
- return { ...acc, [locale]: getLocaleConfig(locale) };
55
- }, {});
55
+ const localeConfigs = locales.reduce((acc, locale) => ({ ...acc, [locale]: getLocaleConfig(locale) }), {});
56
56
  return {
57
57
  defaultLocale: i18nConfig.defaultLocale,
58
58
  locales,
@@ -73,7 +73,7 @@ function localizePath({ pathType, path: originalPath, i18n, options = {}, }) {
73
73
  }
74
74
  // Url paths
75
75
  else if (pathType === 'url') {
76
- return utils_1.normalizeUrl([originalPath, '/', i18n.currentLocale, '/']);
76
+ return (0, utils_1.normalizeUrl)([originalPath, '/', i18n.currentLocale, '/']);
77
77
  }
78
78
  // should never happen
79
79
  else {