@docusaurus/core 0.0.0-4608 → 0.0.0-4614

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/beforeCli.mjs CHANGED
@@ -36,7 +36,7 @@ const {
36
36
  *
37
37
  * cache data is stored in `~/.config/configstore/update-notifier-@docusaurus`
38
38
  */
39
- function beforeCli() {
39
+ async function beforeCli() {
40
40
  const notifier = updateNotifier({
41
41
  pkg: {
42
42
  name,
@@ -98,7 +98,9 @@ function beforeCli() {
98
98
  .filter((p) => p.startsWith('@docusaurus'))
99
99
  .map((p) => p.concat('@latest'))
100
100
  .join(' ');
101
- const isYarnUsed = fs.existsSync(path.resolve(process.cwd(), 'yarn.lock'));
101
+ const isYarnUsed = await fs.pathExists(
102
+ path.resolve(process.cwd(), 'yarn.lock'),
103
+ );
102
104
  const upgradeCommand = isYarnUsed
103
105
  ? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
104
106
  : `npm i ${siteDocusaurusPackagesForUpdate}`;
@@ -9,7 +9,7 @@
9
9
  // @ts-check
10
10
 
11
11
  import logger from '@docusaurus/logger';
12
- import fs from 'fs';
12
+ import fs from 'fs-extra';
13
13
  import cli from 'commander';
14
14
  import {createRequire} from 'module';
15
15
  import {
@@ -25,9 +25,9 @@ import {
25
25
  } from '../lib/index.js';
26
26
  import beforeCli from './beforeCli.mjs';
27
27
 
28
- beforeCli();
28
+ await beforeCli();
29
29
 
30
- const resolveDir = (dir = '.') => fs.realpathSync(dir);
30
+ const resolveDir = (dir = '.') => fs.realpath(dir);
31
31
 
32
32
  cli
33
33
  .version(createRequire(import.meta.url)('../package.json').version)
@@ -56,8 +56,8 @@ cli
56
56
  '--no-minify',
57
57
  'build website without minimizing JS bundles (default: false)',
58
58
  )
59
- .action((siteDir, {bundleAnalyzer, config, outDir, locale, minify}) => {
60
- build(resolveDir(siteDir), {
59
+ .action(async (siteDir, {bundleAnalyzer, config, outDir, locale, minify}) => {
60
+ build(await resolveDir(siteDir), {
61
61
  bundleAnalyzer,
62
62
  outDir,
63
63
  config,
@@ -74,8 +74,14 @@ cli
74
74
  'copy TypeScript theme files when possible (default: false)',
75
75
  )
76
76
  .option('--danger', 'enable swizzle for internal component of themes')
77
- .action((themeName, componentName, siteDir, {typescript, danger}) => {
78
- swizzle(resolveDir(siteDir), themeName, componentName, typescript, danger);
77
+ .action(async (themeName, componentName, siteDir, {typescript, danger}) => {
78
+ swizzle(
79
+ await resolveDir(siteDir),
80
+ themeName,
81
+ componentName,
82
+ typescript,
83
+ danger,
84
+ );
79
85
  });
80
86
 
81
87
  cli
@@ -97,8 +103,8 @@ cli
97
103
  '--skip-build',
98
104
  'skip building website before deploy it (default: false)',
99
105
  )
100
- .action((siteDir, {outDir, skipBuild, config}) => {
101
- deploy(resolveDir(siteDir), {
106
+ .action(async (siteDir, {outDir, skipBuild, config}) => {
107
+ deploy(await resolveDir(siteDir), {
102
108
  outDir,
103
109
  config,
104
110
  skipBuild,
@@ -124,17 +130,19 @@ cli
124
130
  '--poll [interval]',
125
131
  'use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds',
126
132
  )
127
- .action((siteDir, {port, host, locale, config, hotOnly, open, poll}) => {
128
- start(resolveDir(siteDir), {
129
- port,
130
- host,
131
- locale,
132
- config,
133
- hotOnly,
134
- open,
135
- poll,
136
- });
137
- });
133
+ .action(
134
+ async (siteDir, {port, host, locale, config, hotOnly, open, poll}) => {
135
+ start(await resolveDir(siteDir), {
136
+ port,
137
+ host,
138
+ locale,
139
+ config,
140
+ hotOnly,
141
+ open,
142
+ poll,
143
+ });
144
+ },
145
+ );
138
146
 
139
147
  cli
140
148
  .command('serve [siteDir]')
@@ -151,7 +159,7 @@ cli
151
159
  .option('--build', 'build website before serving (default: false)')
152
160
  .option('-h, --host <host>', 'use specified host (default: localhost)')
153
161
  .action(
154
- (
162
+ async (
155
163
  siteDir,
156
164
  {
157
165
  dir = 'build',
@@ -161,7 +169,7 @@ cli
161
169
  config,
162
170
  },
163
171
  ) => {
164
- serve(resolveDir(siteDir), {
172
+ serve(await resolveDir(siteDir), {
165
173
  dir,
166
174
  port,
167
175
  build: buildSite,
@@ -174,8 +182,8 @@ cli
174
182
  cli
175
183
  .command('clear [siteDir]')
176
184
  .description('Remove build artifacts.')
177
- .action((siteDir) => {
178
- clear(resolveDir(siteDir));
185
+ .action(async (siteDir) => {
186
+ clear(await resolveDir(siteDir));
179
187
  });
180
188
 
181
189
  cli
@@ -198,11 +206,11 @@ cli
198
206
  'allows to init new written messages with a given prefix. This might help you to highlight untranslated message to make them stand out in the UI',
199
207
  )
200
208
  .action(
201
- (
209
+ async (
202
210
  siteDir,
203
211
  {locale = undefined, override = false, messagePrefix = '', config},
204
212
  ) => {
205
- writeTranslations(resolveDir(siteDir), {
213
+ writeTranslations(await resolveDir(siteDir), {
206
214
  locale,
207
215
  override,
208
216
  config,
@@ -219,8 +227,8 @@ cli
219
227
  "keep the headings' casing, otherwise make all lowercase (default: false)",
220
228
  )
221
229
  .option('--overwrite', 'overwrite existing heading IDs (default: false)')
222
- .action((siteDir, files, options) =>
223
- writeHeadingIds(resolveDir(siteDir), files, options),
230
+ .action(async (siteDir, files, options) =>
231
+ writeHeadingIds(await resolveDir(siteDir), files, options),
224
232
  );
225
233
 
226
234
  cli.arguments('<command>').action((cmd) => {
@@ -246,7 +254,7 @@ function isInternalCommand(command) {
246
254
 
247
255
  async function run() {
248
256
  if (!isInternalCommand(process.argv.slice(2)[0])) {
249
- await externalCommand(cli, resolveDir('.'));
257
+ await externalCommand(cli, await resolveDir('.'));
250
258
  }
251
259
 
252
260
  cli.parse(process.argv);
@@ -6,6 +6,6 @@
6
6
  */
7
7
  /// <reference types="@docusaurus/module-type-aliases" />
8
8
  /// <reference types="react" />
9
- import type { HeadProps } from '@docusaurus/Head';
10
- declare function Head(props: HeadProps): JSX.Element;
9
+ import type { Props } from '@docusaurus/Head';
10
+ declare function Head(props: Props): JSX.Element;
11
11
  export default Head;
@@ -20,10 +20,10 @@ import App from './App';
20
20
  import { createStatefulLinksCollector, ProvideLinksCollector, } from './LinksCollector';
21
21
  import logger from '@docusaurus/logger';
22
22
  // eslint-disable-next-line no-restricted-imports
23
- import { memoize } from 'lodash';
23
+ import _ from 'lodash';
24
24
  // eslint-disable-next-line @typescript-eslint/no-var-requires
25
25
  const packageJson = require('../../package.json');
26
- const getCompiledSSRTemplate = memoize((template) => eta.compile(template.trim(), {
26
+ const getCompiledSSRTemplate = _.memoize((template) => eta.compile(template.trim(), {
27
27
  rmWhitespace: true,
28
28
  }));
29
29
  function renderSSRTemplate(ssrTemplate, data) {
@@ -87,7 +87,7 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
87
87
  // Apply user webpack config.
88
88
  const { outDir, generatedFilesDir, plugins, siteConfig: { baseUrl, onBrokenLinks, staticDirectories }, routes, } = props;
89
89
  const clientManifestPath = path_1.default.join(generatedFilesDir, 'client-manifest.json');
90
- let clientConfig = (0, webpack_merge_1.default)((0, client_1.default)(props, cliOptions.minify), {
90
+ let clientConfig = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify), {
91
91
  plugins: [
92
92
  // Remove/clean build folders before building bundles.
93
93
  new CleanWebpackPlugin_1.default({ verbose: false }),
@@ -101,22 +101,24 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
101
101
  ].filter(Boolean),
102
102
  });
103
103
  const allCollectedLinks = {};
104
- let serverConfig = (0, server_2.default)({
104
+ let serverConfig = await (0, server_2.default)({
105
105
  props,
106
106
  onLinksCollected: (staticPagePath, links) => {
107
107
  allCollectedLinks[staticPagePath] = links;
108
108
  },
109
109
  });
110
- serverConfig = (0, webpack_merge_1.default)(serverConfig, {
111
- plugins: [
112
- new copy_webpack_plugin_1.default({
113
- patterns: staticDirectories
114
- .map((dir) => path_1.default.resolve(siteDir, dir))
115
- .filter(fs_extra_1.default.existsSync)
116
- .map((dir) => ({ from: dir, to: outDir })),
117
- }),
118
- ],
119
- });
110
+ if (staticDirectories.length > 0) {
111
+ await Promise.all(staticDirectories.map((dir) => fs_extra_1.default.ensureDir(dir)));
112
+ serverConfig = (0, webpack_merge_1.default)(serverConfig, {
113
+ plugins: [
114
+ new copy_webpack_plugin_1.default({
115
+ patterns: staticDirectories
116
+ .map((dir) => path_1.default.resolve(siteDir, dir))
117
+ .map((dir) => ({ from: dir, to: outDir })),
118
+ }),
119
+ ],
120
+ });
121
+ }
120
122
  // Plugin Lifecycle - configureWebpack and configurePostCss.
121
123
  plugins.forEach((plugin) => {
122
124
  var _a, _b;
@@ -12,7 +12,7 @@ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
12
  const chokidar_1 = (0, tslib_1.__importDefault)(require("chokidar"));
13
13
  const html_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("html-webpack-plugin"));
14
14
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
15
- const lodash_1 = require("lodash");
15
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
16
16
  const openBrowser_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/openBrowser"));
17
17
  const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
18
18
  const evalSourceMapMiddleware_1 = (0, tslib_1.__importDefault)(require("react-dev-utils/evalSourceMapMiddleware"));
@@ -48,7 +48,7 @@ async function start(siteDir, cliOptions) {
48
48
  const openUrl = (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, baseUrl]);
49
49
  logger_1.default.success `Docusaurus website is running at path=${openUrl}.`;
50
50
  // Reload files processing.
51
- const reload = (0, lodash_1.debounce)(() => {
51
+ const reload = lodash_1.default.debounce(() => {
52
52
  loadSite()
53
53
  .then(({ baseUrl: newBaseUrl }) => {
54
54
  const newOpenUrl = (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, newBaseUrl]);
@@ -86,14 +86,14 @@ async function start(siteDir, cliOptions) {
86
86
  ? cliOptions.poll
87
87
  : undefined,
88
88
  };
89
- const httpsConfig = (0, utils_2.getHttpsConfig)();
89
+ const httpsConfig = await (0, utils_2.getHttpsConfig)();
90
90
  const fsWatcher = chokidar_1.default.watch(pathsToWatch, {
91
91
  cwd: siteDir,
92
92
  ignoreInitial: true,
93
93
  ...{ pollingOptions },
94
94
  });
95
95
  ['add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach((event) => fsWatcher.on(event, reload));
96
- let config = (0, webpack_merge_1.default)((0, client_1.default)(props), {
96
+ let config = (0, webpack_merge_1.default)(await (0, client_1.default)(props), {
97
97
  infrastructureLogging: {
98
98
  // Reduce log verbosity, see https://github.com/facebook/docusaurus/pull/5420#issuecomment-906613105
99
99
  level: 'warn',
@@ -8,6 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getPluginNames = void 0;
10
10
  const tslib_1 = require("tslib");
11
+ /* eslint-disable no-restricted-properties */
11
12
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
13
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
14
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
@@ -65,7 +65,7 @@ Available locales are: ${context.i18n.locales.join(',')}.`);
65
65
  }
66
66
  const babelOptions = (0, utils_1.getBabelOptions)({
67
67
  isServer: true,
68
- babelOptions: (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
68
+ babelOptions: await (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
69
69
  });
70
70
  const extractedCodeTranslations = await (0, translationsExtractor_1.extractSiteSourceCodeTranslations)(siteDir, plugins, babelOptions, await getExtraSourceCodeFilePaths());
71
71
  const defaultCodeMessages = await (0, translations_1.getPluginsDefaultCodeTranslationMessages)(plugins);
@@ -10,10 +10,11 @@ exports.handleBrokenLinks = exports.filterExistingFileLinks = exports.getBrokenL
10
10
  const tslib_1 = require("tslib");
11
11
  const react_router_config_1 = require("react-router-config");
12
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const lodash_1 = require("lodash");
13
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
14
14
  const utils_1 = require("@docusaurus/utils");
15
15
  const utils_2 = require("./utils");
16
16
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
17
+ const combine_promises_1 = (0, tslib_1.__importDefault)(require("combine-promises"));
17
18
  function toReactRouterRoutes(routes) {
18
19
  // @ts-expect-error: types incompatible???
19
20
  return routes;
@@ -51,9 +52,9 @@ function filterIntermediateRoutes(routesInput) {
51
52
  }
52
53
  function getAllBrokenLinks({ allCollectedLinks, routes, }) {
53
54
  const filteredRoutes = filterIntermediateRoutes(routes);
54
- const allBrokenLinks = (0, lodash_1.mapValues)(allCollectedLinks, (pageLinks, pagePath) => getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes }));
55
+ const allBrokenLinks = lodash_1.default.mapValues(allCollectedLinks, (pageLinks, pagePath) => getPageBrokenLinks({ pageLinks, pagePath, routes: filteredRoutes }));
55
56
  // remove pages without any broken link
56
- return (0, lodash_1.pickBy)(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
57
+ return lodash_1.default.pickBy(allBrokenLinks, (brokenLinks) => brokenLinks.length > 0);
57
58
  }
58
59
  exports.getAllBrokenLinks = getAllBrokenLinks;
59
60
  function getBrokenLinksErrorMessage(allBrokenLinks) {
@@ -76,7 +77,7 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
76
77
  */
77
78
  function getLayoutBrokenLinksHelpMessage() {
78
79
  const flatList = Object.entries(allBrokenLinks).flatMap(([pagePage, brokenLinks]) => brokenLinks.map((brokenLink) => ({ pagePage, brokenLink })));
79
- const countedBrokenLinks = (0, lodash_1.countBy)(flatList, (item) => item.brokenLink.link);
80
+ const countedBrokenLinks = lodash_1.default.countBy(flatList, (item) => item.brokenLink.link);
80
81
  const FrequencyThreshold = 5; // Is this a good value?
81
82
  const frequentLinks = Object.entries(countedBrokenLinks)
82
83
  .filter(([, count]) => count >= FrequencyThreshold)
@@ -93,9 +94,9 @@ function getBrokenLinksErrorMessage(allBrokenLinks) {
93
94
  `);
94
95
  }
95
96
  exports.getBrokenLinksErrorMessage = getBrokenLinksErrorMessage;
96
- function isExistingFile(filePath) {
97
+ async function isExistingFile(filePath) {
97
98
  try {
98
- return fs_extra_1.default.statSync(filePath).isFile();
99
+ return (await fs_extra_1.default.stat(filePath)).isFile();
99
100
  }
100
101
  catch (e) {
101
102
  return false;
@@ -104,8 +105,7 @@ function isExistingFile(filePath) {
104
105
  // If a file actually exist on the file system, we know the link is valid
105
106
  // even if docusaurus does not know about this file, so we don't report it
106
107
  async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, }) {
107
- // not easy to make this async :'(
108
- function linkFileExists(link) {
108
+ async function linkFileExists(link) {
109
109
  // /baseUrl/javadoc/ -> /outDir/javadoc
110
110
  const baseFilePath = (0, utils_1.removeSuffix)(`${outDir}/${(0, utils_1.removePrefix)(link, baseUrl)}`, '/');
111
111
  // -> /outDir/javadoc
@@ -116,9 +116,14 @@ async function filterExistingFileLinks({ baseUrl, outDir, allCollectedLinks, })
116
116
  filePathsToTry.push(`${baseFilePath}.html`);
117
117
  filePathsToTry.push(path_1.default.join(baseFilePath, 'index.html'));
118
118
  }
119
- return filePathsToTry.some(isExistingFile);
119
+ for (const file of filePathsToTry) {
120
+ if (await isExistingFile(file)) {
121
+ return true;
122
+ }
123
+ }
124
+ return false;
120
125
  }
121
- return (0, lodash_1.mapValues)(allCollectedLinks, (links) => links.filter((link) => !linkFileExists(link)));
126
+ 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)));
122
127
  }
123
128
  exports.filterExistingFileLinks = filterExistingFileLinks;
124
129
  async function handleBrokenLinks({ allCollectedLinks, onBrokenLinks, routes, baseUrl, outDir, }) {
@@ -11,7 +11,7 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
11
11
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
12
12
  const configValidation_1 = require("./configValidation");
13
13
  async function loadConfig(configPath) {
14
- if (!fs_extra_1.default.existsSync(configPath)) {
14
+ if (!(await fs_extra_1.default.pathExists(configPath))) {
15
15
  throw new Error(`Config file at "${configPath}" not found.`);
16
16
  }
17
17
  const importedConfig = (0, import_fresh_1.default)(configPath);
@@ -7,12 +7,11 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const lodash_1 = require("lodash");
11
10
  const html_tags_1 = (0, tslib_1.__importDefault)(require("html-tags"));
12
11
  const void_1 = (0, tslib_1.__importDefault)(require("html-tags/void"));
13
12
  const escape_html_1 = (0, tslib_1.__importDefault)(require("escape-html"));
14
13
  function assertIsHtmlTagObject(val) {
15
- if (!(0, lodash_1.isPlainObject)(val)) {
14
+ if (typeof val !== 'object' || !val) {
16
15
  throw new Error(`"${val}" is not a valid HTML tag object.`);
17
16
  }
18
17
  if (typeof val.tagName !== 'string') {
@@ -22,7 +22,7 @@ const versions_1 = require("./versions");
22
22
  const duplicateRoutes_1 = require("./duplicateRoutes");
23
23
  const i18n_1 = require("./i18n");
24
24
  const translations_1 = require("./translations/translations");
25
- const lodash_1 = require("lodash");
25
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
26
26
  const remark_admonitions_1 = (0, tslib_1.__importDefault)(require("remark-admonitions"));
27
27
  const module_1 = require("module");
28
28
  const moduleShorthand_1 = require("./moduleShorthand");
@@ -68,7 +68,7 @@ async function loadContext(siteDir, options = {}) {
68
68
  locale: i18n.currentLocale,
69
69
  }))) !== null && _a !== void 0 ? _a : {};
70
70
  // We only need key->message for code translations
71
- const codeTranslations = (0, lodash_1.mapValues)(codeTranslationFileContent, (value) => value.message);
71
+ const codeTranslations = lodash_1.default.mapValues(codeTranslationFileContent, (value) => value.message);
72
72
  return {
73
73
  siteDir,
74
74
  generatedFilesDir,
@@ -252,8 +252,8 @@ ${Object.keys(registry)
252
252
  const genCodeTranslations = (0, utils_1.generate)(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslationsWithFallbacks, null, 2));
253
253
  // Version metadata.
254
254
  const siteMetadata = {
255
- docusaurusVersion: (0, versions_1.getPackageJsonVersion)(path_1.default.join(__dirname, '../../package.json')),
256
- siteVersion: (0, versions_1.getPackageJsonVersion)(path_1.default.join(siteDir, 'package.json')),
255
+ docusaurusVersion: (await (0, versions_1.getPackageJsonVersion)(path_1.default.join(__dirname, '../../package.json'))),
256
+ siteVersion: await (0, versions_1.getPackageJsonVersion)(path_1.default.join(siteDir, 'package.json')),
257
257
  pluginVersions: {},
258
258
  };
259
259
  plugins
@@ -13,7 +13,7 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
14
  const init_1 = (0, tslib_1.__importDefault)(require("./init"));
15
15
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
16
- const lodash_1 = require("lodash");
16
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
17
17
  const translations_1 = require("../translations/translations");
18
18
  const applyRouteTrailingSlash_1 = (0, tslib_1.__importDefault)(require("./applyRouteTrailingSlash"));
19
19
  function sortConfig(routeConfigs, baseUrl = '/') {
@@ -80,9 +80,9 @@ async function loadPlugins({ pluginConfigs, context, }) {
80
80
  translationFiles: localizedTranslationFiles,
81
81
  };
82
82
  }));
83
- const allContent = (0, lodash_1.chain)(loadedPlugins)
83
+ const allContent = lodash_1.default.chain(loadedPlugins)
84
84
  .groupBy((item) => item.name)
85
- .mapValues((nameItems) => (0, lodash_1.chain)(nameItems)
85
+ .mapValues((nameItems) => lodash_1.default.chain(nameItems)
86
86
  .groupBy((item) => { var _a; return (_a = item.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; })
87
87
  .mapValues((idItems) => idItems[0].content)
88
88
  .value())
@@ -85,7 +85,7 @@ async function initPlugins({ pluginConfigs, context, }) {
85
85
  // We need to resolve plugins from the perspective of the siteDir, since the
86
86
  // siteDir's package.json declares the dependency on these plugins.
87
87
  const pluginRequire = (0, module_1.createRequire)(context.siteConfigPath);
88
- function doGetPluginVersion(normalizedPluginConfig) {
88
+ async function doGetPluginVersion(normalizedPluginConfig) {
89
89
  var _a, _b;
90
90
  // get plugin version
91
91
  if ((_a = normalizedPluginConfig.pluginModule) === null || _a === void 0 ? void 0 : _a.path) {
@@ -122,7 +122,7 @@ async function initPlugins({ pluginConfigs, context, }) {
122
122
  }
123
123
  async function initializePlugin(pluginConfig) {
124
124
  const normalizedPluginConfig = await normalizePluginConfig(pluginConfig, pluginRequire);
125
- const pluginVersion = doGetPluginVersion(normalizedPluginConfig);
125
+ const pluginVersion = await doGetPluginVersion(normalizedPluginConfig);
126
126
  const pluginOptions = doValidatePluginOptions(normalizedPluginConfig);
127
127
  // Side-effect: merge the normalized theme config in the original one
128
128
  context.siteConfig.themeConfig = {
@@ -7,14 +7,15 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.ensureUniquePluginInstanceIds = void 0;
10
- const lodash_1 = require("lodash");
10
+ const tslib_1 = require("tslib");
11
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
12
  const utils_1 = require("@docusaurus/utils");
12
13
  // It is forbidden to have 2 plugins of the same name sharing the same id
13
14
  // this is required to support multi-instance plugins without conflict
14
15
  function ensureUniquePluginInstanceIds(plugins) {
15
- const pluginsByName = (0, lodash_1.groupBy)(plugins, (p) => p.name);
16
+ const pluginsByName = lodash_1.default.groupBy(plugins, (p) => p.name);
16
17
  Object.entries(pluginsByName).forEach(([pluginName, pluginInstances]) => {
17
- const pluginInstancesById = (0, lodash_1.groupBy)(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; });
18
+ const pluginInstancesById = lodash_1.default.groupBy(pluginInstances, (p) => { var _a; return (_a = p.options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID; });
18
19
  Object.entries(pluginInstancesById).forEach(([pluginId, pluginInstancesWithId]) => {
19
20
  if (pluginInstancesWithId.length !== 1) {
20
21
  throw new Error(`Plugin "${pluginName}" is used ${pluginInstancesWithId.length} times with ID "${pluginId}".\nTo use the same plugin multiple times on a Docusaurus site, you need to assign a unique ID to each plugin instance.${pluginId === utils_1.DEFAULT_PLUGIN_ID
@@ -7,7 +7,6 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const utils_1 = require("@docusaurus/utils");
10
- const lodash_1 = require("lodash");
11
10
  const querystring_1 = require("querystring");
12
11
  function indent(str) {
13
12
  const spaces = ' ';
@@ -46,10 +45,15 @@ const RoutesImportsCode = [
46
45
  `import ComponentCreator from '@docusaurus/ComponentCreator';`,
47
46
  ].join('\n');
48
47
  function isModule(value) {
49
- if ((0, lodash_1.isString)(value)) {
48
+ var _a, _b;
49
+ if (typeof value === 'string') {
50
50
  return true;
51
51
  }
52
- if ((0, lodash_1.isPlainObject)(value) && (0, lodash_1.has)(value, '__import') && (0, lodash_1.has)(value, 'path')) {
52
+ if (typeof value === 'object' &&
53
+ (
54
+ // eslint-disable-next-line no-underscore-dangle
55
+ (_a = value) === null || _a === void 0 ? void 0 : _a.__import) &&
56
+ ((_b = value) === null || _b === void 0 ? void 0 : _b.path)) {
53
57
  return true;
54
58
  }
55
59
  return false;
@@ -68,8 +72,9 @@ async function loadRoutes(pluginsRouteConfigs, baseUrl) {
68
72
  // This is the higher level overview of route code generation.
69
73
  function generateRouteCode(routeConfig) {
70
74
  const { path: routePath, component, modules = {}, routes: subroutes, exact, priority, ...props } = routeConfig;
71
- if (!(0, lodash_1.isString)(routePath) || !component) {
72
- throw new Error(`Invalid route config: path must be a string and component is required.\n${JSON.stringify(routeConfig)}`);
75
+ if (typeof routePath !== 'string' || !component) {
76
+ throw new Error(`Invalid route config: path must be a string and component is required.
77
+ ${JSON.stringify(routeConfig)}`);
73
78
  }
74
79
  // Collect all page paths for injecting it later in the plugin lifecycle
75
80
  // This is useful for plugins like sitemaps, redirects etc...
@@ -6,4 +6,4 @@
6
6
  */
7
7
  import type { ThemeAliases } from '@docusaurus/types';
8
8
  export declare function sortAliases(aliases: ThemeAliases): ThemeAliases;
9
- export default function themeAlias(themePath: string, addOriginalAlias: boolean): ThemeAliases;
9
+ export default function themeAlias(themePath: string, addOriginalAlias: boolean): Promise<ThemeAliases>;
@@ -11,25 +11,24 @@ const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
12
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
- const lodash_1 = require("lodash");
14
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
15
15
  // Order of Webpack aliases is important because one alias can shadow another
16
16
  // This ensure @theme/NavbarItem alias is after @theme/NavbarItem/LocaleDropdown
17
17
  // See https://github.com/facebook/docusaurus/pull/3922
18
18
  // See https://github.com/facebook/docusaurus/issues/5382
19
19
  function sortAliases(aliases) {
20
20
  // Alphabetical order by default
21
- const entries = (0, lodash_1.sortBy)(Object.entries(aliases), ([alias]) => alias);
21
+ const entries = lodash_1.default.sortBy(Object.entries(aliases), ([alias]) => alias);
22
22
  // @theme/NavbarItem should be after @theme/NavbarItem/LocaleDropdown
23
23
  entries.sort(([alias1], [alias2]) => alias1.includes(`${alias2}/`) ? -1 : 0);
24
24
  return Object.fromEntries(entries);
25
25
  }
26
26
  exports.sortAliases = sortAliases;
27
- // TODO make async
28
- function themeAlias(themePath, addOriginalAlias) {
29
- if (!fs_extra_1.default.pathExistsSync(themePath)) {
27
+ async function themeAlias(themePath, addOriginalAlias) {
28
+ if (!(await fs_extra_1.default.pathExists(themePath))) {
30
29
  return {};
31
30
  }
32
- const themeComponentFiles = utils_1.Globby.sync(['**/*.{js,jsx,ts,tsx}'], {
31
+ const themeComponentFiles = await (0, utils_1.Globby)(['**/*.{js,jsx,ts,tsx}'], {
33
32
  cwd: themePath,
34
33
  });
35
34
  const aliases = {};
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { ThemeAliases, LoadedPlugin } from '@docusaurus/types';
8
- export declare function loadThemeAliases(themePaths: string[], userThemePaths: string[]): ThemeAliases;
8
+ export declare function loadThemeAliases(themePaths: string[], userThemePaths: string[]): Promise<ThemeAliases>;
9
9
  export declare function loadPluginsThemeAliases({ siteDir, plugins, }: {
10
10
  siteDir: string;
11
11
  plugins: LoadedPlugin[];
12
- }): ThemeAliases;
12
+ }): Promise<ThemeAliases>;
@@ -12,10 +12,10 @@ const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  const alias_1 = (0, tslib_1.__importStar)(require("./alias"));
14
14
  const ThemeFallbackDir = path_1.default.resolve(__dirname, '../../client/theme-fallback');
15
- function loadThemeAliases(themePaths, userThemePaths) {
15
+ async function loadThemeAliases(themePaths, userThemePaths) {
16
16
  const aliases = {};
17
- themePaths.forEach((themePath) => {
18
- const themeAliases = (0, alias_1.default)(themePath, true);
17
+ for (const themePath of themePaths) {
18
+ const themeAliases = await (0, alias_1.default)(themePath, true);
19
19
  Object.keys(themeAliases).forEach((aliasKey) => {
20
20
  // If this alias shadows a previous one, use @theme-init to preserve the
21
21
  // initial one. @theme-init is only applied once: to the initial theme
@@ -29,11 +29,11 @@ function loadThemeAliases(themePaths, userThemePaths) {
29
29
  }
30
30
  aliases[aliasKey] = themeAliases[aliasKey];
31
31
  });
32
- });
33
- userThemePaths.forEach((themePath) => {
34
- const userThemeAliases = (0, alias_1.default)(themePath, false);
32
+ }
33
+ for (const themePath of userThemePaths) {
34
+ const userThemeAliases = await (0, alias_1.default)(themePath, false);
35
35
  Object.assign(aliases, userThemeAliases);
36
- });
36
+ }
37
37
  return (0, alias_1.sortAliases)(aliases);
38
38
  }
39
39
  exports.loadThemeAliases = loadThemeAliases;
@@ -10,7 +10,7 @@ exports.applyDefaultCodeTranslations = exports.getPluginsDefaultCodeTranslationM
10
10
  const tslib_1 = require("tslib");
11
11
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const lodash_1 = require("lodash");
13
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
14
14
  const utils_1 = require("@docusaurus/utils");
15
15
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
16
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
@@ -44,7 +44,7 @@ async function readTranslationFileContent(filePath) {
44
44
  exports.readTranslationFileContent = readTranslationFileContent;
45
45
  function mergeTranslationFileContent({ existingContent = {}, newContent, options, }) {
46
46
  // Apply messagePrefix to all messages
47
- const newContentTransformed = (0, lodash_1.mapValues)(newContent, (value) => {
47
+ const newContentTransformed = lodash_1.default.mapValues(newContent, (value) => {
48
48
  var _a;
49
49
  return ({
50
50
  ...value,
@@ -68,7 +68,7 @@ function mergeTranslationFileContent({ existingContent = {}, newContent, options
68
68
  async function writeTranslationFileContent({ filePath, content: newContent, options = {}, }) {
69
69
  const existingContent = await readTranslationFileContent(filePath);
70
70
  // Warn about potential legacy keys
71
- const unknownKeys = (0, lodash_1.difference)(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
71
+ const unknownKeys = lodash_1.default.difference(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
72
72
  if (unknownKeys.length > 0) {
73
73
  logger_1.default.warn `Some translation keys looks unknown to us in file path=${filePath}.
74
74
  Maybe you should remove them? ${unknownKeys}`;
@@ -171,12 +171,12 @@ async function getPluginsDefaultCodeTranslationMessages(plugins) {
171
171
  }
172
172
  exports.getPluginsDefaultCodeTranslationMessages = getPluginsDefaultCodeTranslationMessages;
173
173
  function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }) {
174
- const unusedDefaultCodeMessages = (0, lodash_1.difference)(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
174
+ const unusedDefaultCodeMessages = lodash_1.default.difference(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
175
175
  if (unusedDefaultCodeMessages.length > 0) {
176
176
  logger_1.default.warn `Unused default message codes found.
177
177
  Please report this Docusaurus issue. name=${unusedDefaultCodeMessages}`;
178
178
  }
179
- return (0, lodash_1.mapValues)(extractedCodeTranslations, (messageTranslation, messageId) => {
179
+ return lodash_1.default.mapValues(extractedCodeTranslations, (messageTranslation, messageId) => {
180
180
  var _a;
181
181
  return ({
182
182
  ...messageTranslation,
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { DocusaurusPluginVersionInformation } from '@docusaurus/types';
8
- export declare function getPackageJsonVersion(packageJsonPath: string): string | undefined;
9
- export declare function getPackageJsonName(packageJsonPath: string): string | undefined;
10
- export declare function getPluginVersion(pluginPath: string, siteDir: string): DocusaurusPluginVersionInformation;
8
+ export declare function getPackageJsonVersion(packageJsonPath: string): Promise<string | undefined>;
9
+ export declare function getPackageJsonName(packageJsonPath: string): Promise<string | undefined>;
10
+ export declare function getPluginVersion(pluginPath: string, siteDir: string): Promise<DocusaurusPluginVersionInformation>;
@@ -7,10 +7,11 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getPluginVersion = exports.getPackageJsonName = exports.getPackageJsonVersion = void 0;
10
- const fs_extra_1 = require("fs-extra");
11
- const path_1 = require("path");
12
- function getPackageJsonVersion(packageJsonPath) {
13
- if ((0, fs_extra_1.existsSync)(packageJsonPath)) {
10
+ const tslib_1 = require("tslib");
11
+ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
+ async function getPackageJsonVersion(packageJsonPath) {
14
+ if (await fs_extra_1.default.pathExists(packageJsonPath)) {
14
15
  // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
15
16
  const { version } = require(packageJsonPath);
16
17
  return typeof version === 'string' ? version : undefined;
@@ -18,8 +19,8 @@ function getPackageJsonVersion(packageJsonPath) {
18
19
  return undefined;
19
20
  }
20
21
  exports.getPackageJsonVersion = getPackageJsonVersion;
21
- function getPackageJsonName(packageJsonPath) {
22
- if ((0, fs_extra_1.existsSync)(packageJsonPath)) {
22
+ async function getPackageJsonName(packageJsonPath) {
23
+ if (await fs_extra_1.default.pathExists(packageJsonPath)) {
23
24
  // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-dynamic-require, global-require
24
25
  const { name } = require(packageJsonPath);
25
26
  return typeof name === 'string' ? name : undefined;
@@ -27,11 +28,12 @@ function getPackageJsonName(packageJsonPath) {
27
28
  return undefined;
28
29
  }
29
30
  exports.getPackageJsonName = getPackageJsonName;
30
- function getPluginVersion(pluginPath, siteDir) {
31
- let potentialPluginPackageJsonDirectory = (0, path_1.dirname)(pluginPath);
31
+ async function getPluginVersion(pluginPath, siteDir) {
32
+ let potentialPluginPackageJsonDirectory = path_1.default.dirname(pluginPath);
32
33
  while (potentialPluginPackageJsonDirectory !== '/') {
33
- const packageJsonPath = (0, path_1.join)(potentialPluginPackageJsonDirectory, 'package.json');
34
- if ((0, fs_extra_1.existsSync)(packageJsonPath) && (0, fs_extra_1.lstatSync)(packageJsonPath).isFile()) {
34
+ const packageJsonPath = path_1.default.join(potentialPluginPackageJsonDirectory, 'package.json');
35
+ if ((await fs_extra_1.default.pathExists(packageJsonPath)) &&
36
+ (await fs_extra_1.default.lstat(packageJsonPath)).isFile()) {
35
37
  if (potentialPluginPackageJsonDirectory === siteDir) {
36
38
  // If the plugin belongs to the same docusaurus project, we classify it
37
39
  // as local plugin.
@@ -39,11 +41,11 @@ function getPluginVersion(pluginPath, siteDir) {
39
41
  }
40
42
  return {
41
43
  type: 'package',
42
- name: getPackageJsonName(packageJsonPath),
43
- version: getPackageJsonVersion(packageJsonPath),
44
+ name: await getPackageJsonName(packageJsonPath),
45
+ version: await getPackageJsonVersion(packageJsonPath),
44
46
  };
45
47
  }
46
- potentialPluginPackageJsonDirectory = (0, path_1.dirname)(potentialPluginPackageJsonDirectory);
48
+ potentialPluginPackageJsonDirectory = path_1.default.dirname(potentialPluginPackageJsonDirectory);
47
49
  }
48
50
  // In the case where a plugin is a path where no parent directory contains
49
51
  // package.json (e.g. inline plugin), we can only classify it as local.
@@ -8,5 +8,5 @@ import type { Configuration } from 'webpack';
8
8
  import type { Props } from '@docusaurus/types';
9
9
  export declare const clientDir: string;
10
10
  export declare function excludeJS(modulePath: string): boolean;
11
- export declare function getDocusaurusAliases(): Record<string, string>;
12
- export declare function createBaseConfig(props: Props, isServer: boolean, minify?: boolean): Configuration;
11
+ export declare function getDocusaurusAliases(): Promise<Record<string, string>>;
12
+ export declare function createBaseConfig(props: Props, isServer: boolean, minify?: boolean): Promise<Configuration>;
@@ -32,11 +32,11 @@ function excludeJS(modulePath) {
32
32
  !LibrariesToTranspileRegex.test(modulePath));
33
33
  }
34
34
  exports.excludeJS = excludeJS;
35
- function getDocusaurusAliases() {
35
+ async function getDocusaurusAliases() {
36
36
  const dirPath = path_1.default.resolve(__dirname, '../client/exports');
37
37
  const extensions = ['.js', '.ts', '.tsx'];
38
38
  const aliases = {};
39
- fs_extra_1.default.readdirSync(dirPath)
39
+ (await fs_extra_1.default.readdir(dirPath))
40
40
  .filter((fileName) => extensions.includes(path_1.default.extname(fileName)))
41
41
  .forEach((fileName) => {
42
42
  const fileNameWithoutExtension = path_1.default.basename(fileName, path_1.default.extname(fileName));
@@ -46,7 +46,7 @@ function getDocusaurusAliases() {
46
46
  return aliases;
47
47
  }
48
48
  exports.getDocusaurusAliases = getDocusaurusAliases;
49
- function createBaseConfig(props, isServer, minify = true) {
49
+ async function createBaseConfig(props, isServer, minify = true) {
50
50
  var _a;
51
51
  const { outDir, siteDir, siteConfig, siteConfigPath, baseUrl, generatedFilesDir, routesPaths, siteMetadata, plugins, } = props;
52
52
  const totalPages = routesPaths.length;
@@ -56,7 +56,7 @@ function createBaseConfig(props, isServer, minify = true) {
56
56
  const fileLoaderUtils = (0, utils_2.getFileLoaderUtils)();
57
57
  const name = isServer ? 'server' : 'client';
58
58
  const mode = isProd ? 'production' : 'development';
59
- const themeAliases = (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
59
+ const themeAliases = await (0, themes_1.loadPluginsThemeAliases)({ siteDir, plugins });
60
60
  return {
61
61
  mode,
62
62
  name,
@@ -120,7 +120,7 @@ function createBaseConfig(props, isServer, minify = true) {
120
120
  // Note: a @docusaurus alias would also catch @docusaurus/theme-common,
121
121
  // so we use fine-grained aliases instead
122
122
  // '@docusaurus': path.resolve(__dirname, '../client/exports'),
123
- ...getDocusaurusAliases(),
123
+ ...(await getDocusaurusAliases()),
124
124
  ...themeAliases,
125
125
  },
126
126
  // This allows you to set a fallback for where Webpack should look for
@@ -131,7 +131,7 @@ function createBaseConfig(props, isServer, minify = true) {
131
131
  modules: [
132
132
  path_1.default.resolve(__dirname, '..', '..', 'node_modules'),
133
133
  'node_modules',
134
- path_1.default.resolve(fs_extra_1.default.realpathSync(process.cwd()), 'node_modules'),
134
+ path_1.default.resolve(await fs_extra_1.default.realpath(process.cwd()), 'node_modules'),
135
135
  ],
136
136
  },
137
137
  resolveLoader: {
@@ -187,7 +187,7 @@ function createBaseConfig(props, isServer, minify = true) {
187
187
  use: [
188
188
  (0, utils_1.getCustomizableJSLoader)((_a = siteConfig.webpack) === null || _a === void 0 ? void 0 : _a.jsLoader)({
189
189
  isServer,
190
- babelOptions: (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
190
+ babelOptions: await (0, utils_1.getCustomBabelConfigFilePath)(siteDir),
191
191
  }),
192
192
  ],
193
193
  },
@@ -6,4 +6,4 @@
6
6
  */
7
7
  import type { Configuration } from 'webpack';
8
8
  import type { Props } from '@docusaurus/types';
9
- export default function createClientConfig(props: Props, minify?: boolean): Configuration;
9
+ export default function createClientConfig(props: Props, minify?: boolean): Promise<Configuration>;
@@ -13,10 +13,10 @@ const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
13
13
  const base_1 = require("./base");
14
14
  const ChunkAssetPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/ChunkAssetPlugin"));
15
15
  const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"));
16
- function createClientConfig(props, minify = true) {
16
+ async function createClientConfig(props, minify = true) {
17
17
  var _a;
18
18
  const isBuilding = process.argv[2] === 'build';
19
- const config = (0, base_1.createBaseConfig)(props, false, minify);
19
+ const config = await (0, base_1.createBaseConfig)(props, false, minify);
20
20
  const clientConfig = (0, webpack_merge_1.default)(config, {
21
21
  // useless, disabled on purpose (errors on existing sites with no
22
22
  // browserslist config)
@@ -9,4 +9,4 @@ import type { Props } from '@docusaurus/types';
9
9
  export default function createServerConfig({ props, onLinksCollected, }: {
10
10
  props: Props;
11
11
  onLinksCollected?: (staticPagePath: string, links: string[]) => void;
12
- }): Configuration;
12
+ }): Promise<Configuration>;
@@ -15,9 +15,9 @@ const LogPlugin_1 = (0, tslib_1.__importDefault)(require("./plugins/LogPlugin"))
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  // Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
17
17
  const static_site_generator_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("@slorber/static-site-generator-webpack-plugin"));
18
- function createServerConfig({ props, onLinksCollected = () => { }, }) {
18
+ async function createServerConfig({ props, onLinksCollected = () => { }, }) {
19
19
  const { baseUrl, routesPaths, generatedFilesDir, headTags, preBodyTags, postBodyTags, ssrTemplate, siteConfig: { noIndex, trailingSlash }, } = props;
20
- const config = (0, base_1.createBaseConfig)(props, true);
20
+ const config = await (0, base_1.createBaseConfig)(props, true);
21
21
  const routesLocation = {};
22
22
  // Array of paths to be rendered. Relative to output directory
23
23
  const ssgPaths = routesPaths.map((str) => {
@@ -11,7 +11,7 @@ import type { ConfigureWebpackFn, ConfigurePostCssFn } from '@docusaurus/types';
11
11
  export declare function getStyleLoaders(isServer: boolean, cssOptionsArg?: {
12
12
  [key: string]: unknown;
13
13
  }): RuleSetRule[];
14
- export declare function getCustomBabelConfigFilePath(siteDir: string): string | undefined;
14
+ export declare function getCustomBabelConfigFilePath(siteDir: string): Promise<string | undefined>;
15
15
  export declare function getBabelOptions({ isServer, babelOptions, }?: {
16
16
  isServer?: boolean;
17
17
  babelOptions?: TransformOptions | string;
@@ -32,8 +32,8 @@ export declare const getCustomizableJSLoader: (jsLoader?: "babel" | ((isServer:
32
32
  export declare function applyConfigureWebpack(configureWebpack: ConfigureWebpackFn, config: Configuration, isServer: boolean, jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule) | undefined, content: unknown): Configuration;
33
33
  export declare function applyConfigurePostCss(configurePostCss: NonNullable<ConfigurePostCssFn>, config: Configuration): Configuration;
34
34
  export declare function compile(config: Configuration[]): Promise<void>;
35
- export declare function getHttpsConfig(): boolean | {
35
+ export declare function getHttpsConfig(): Promise<boolean | {
36
36
  cert: Buffer;
37
37
  key: Buffer;
38
- };
38
+ }>;
39
39
  export declare function getMinimizer(useSimpleCssMinifier?: boolean): WebpackPluginInstance[];
@@ -18,7 +18,7 @@ const path_1 = (0, tslib_1.__importDefault)(require("path"));
18
18
  const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
19
19
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
20
20
  const utils_1 = require("@docusaurus/utils");
21
- const lodash_1 = require("lodash");
21
+ const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
22
22
  // Utility method to get style loaders
23
23
  function getStyleLoaders(isServer, cssOptionsArg = {}) {
24
24
  const cssOptions = {
@@ -80,9 +80,9 @@ function getStyleLoaders(isServer, cssOptionsArg = {}) {
80
80
  ];
81
81
  }
82
82
  exports.getStyleLoaders = getStyleLoaders;
83
- function getCustomBabelConfigFilePath(siteDir) {
83
+ async function getCustomBabelConfigFilePath(siteDir) {
84
84
  const customBabelConfigurationPath = path_1.default.join(siteDir, utils_1.BABEL_CONFIG_FILE_NAME);
85
- return fs_extra_1.default.existsSync(customBabelConfigurationPath)
85
+ return (await fs_extra_1.default.pathExists(customBabelConfigurationPath))
86
86
  ? customBabelConfigurationPath
87
87
  : undefined;
88
88
  }
@@ -116,7 +116,7 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
116
116
  : jsLoader(isServer);
117
117
  exports.getCustomizableJSLoader = getCustomizableJSLoader;
118
118
  // TODO remove this before end of 2021?
119
- const warnBabelLoaderOnce = (0, lodash_1.memoize)(() => {
119
+ const warnBabelLoaderOnce = lodash_1.default.memoize(() => {
120
120
  logger_1.default.warn `Docusaurus plans to support multiple JS loader strategies (Babel, esbuild...): code=${'getBabelLoader(isServer)'} is now deprecated in favor of code=${'getJSLoader(isServer)'}.`;
121
121
  });
122
122
  const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, babelOptions) {
@@ -124,7 +124,7 @@ const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, bab
124
124
  return getDefaultBabelLoader({ isServer, babelOptions });
125
125
  };
126
126
  // TODO remove this before end of 2021 ?
127
- const warnCacheLoaderOnce = (0, lodash_1.memoize)(() => {
127
+ const warnCacheLoaderOnce = lodash_1.default.memoize(() => {
128
128
  logger_1.default.warn `Docusaurus uses Webpack 5 and code=${'getCacheLoader()'} usage is now deprecated.`;
129
129
  });
130
130
  function getCacheLoaderDeprecated() {
@@ -247,24 +247,24 @@ ${err}`);
247
247
  }
248
248
  }
249
249
  // Read file and throw an error if it doesn't exist
250
- function readEnvFile(file, type) {
251
- if (!fs_extra_1.default.existsSync(file)) {
250
+ async function readEnvFile(file, type) {
251
+ if (!(await fs_extra_1.default.pathExists(file))) {
252
252
  throw new Error(`You specified ${type} in your env, but the file "${file}" can't be found.`);
253
253
  }
254
- return fs_extra_1.default.readFileSync(file);
254
+ return fs_extra_1.default.readFile(file);
255
255
  }
256
- const appDirectory = fs_extra_1.default.realpathSync(process.cwd());
257
256
  // Get the https config
258
257
  // Return cert files if provided in env, otherwise just true or false
259
- function getHttpsConfig() {
258
+ async function getHttpsConfig() {
259
+ const appDirectory = await fs_extra_1.default.realpath(process.cwd());
260
260
  const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
261
261
  const isHttps = HTTPS === 'true';
262
262
  if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
263
263
  const crtFile = path_1.default.resolve(appDirectory, SSL_CRT_FILE);
264
264
  const keyFile = path_1.default.resolve(appDirectory, SSL_KEY_FILE);
265
265
  const config = {
266
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
267
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
266
+ cert: await readEnvFile(crtFile, 'SSL_CRT_FILE'),
267
+ key: await readEnvFile(keyFile, 'SSL_KEY_FILE'),
268
268
  };
269
269
  validateKeyAndCerts({ ...config, keyFile, crtFile });
270
270
  return config;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@docusaurus/core",
3
3
  "description": "Easy to Maintain Open Source Documentation Websites",
4
- "version": "0.0.0-4608",
4
+ "version": "0.0.0-4614",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,13 +41,13 @@
41
41
  "@babel/runtime": "^7.17.2",
42
42
  "@babel/runtime-corejs3": "^7.17.2",
43
43
  "@babel/traverse": "^7.17.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4608",
45
- "@docusaurus/logger": "0.0.0-4608",
46
- "@docusaurus/mdx-loader": "0.0.0-4608",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4614",
45
+ "@docusaurus/logger": "0.0.0-4614",
46
+ "@docusaurus/mdx-loader": "0.0.0-4614",
47
47
  "@docusaurus/react-loadable": "5.5.2",
48
- "@docusaurus/utils": "0.0.0-4608",
49
- "@docusaurus/utils-common": "0.0.0-4608",
50
- "@docusaurus/utils-validation": "0.0.0-4608",
48
+ "@docusaurus/utils": "0.0.0-4614",
49
+ "@docusaurus/utils-common": "0.0.0-4614",
50
+ "@docusaurus/utils-validation": "0.0.0-4614",
51
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.1",
52
52
  "@svgr/webpack": "^6.2.1",
53
53
  "autoprefixer": "^10.4.2",
@@ -56,6 +56,7 @@
56
56
  "boxen": "^5.1.2",
57
57
  "chokidar": "^3.5.3",
58
58
  "clean-css": "^5.2.4",
59
+ "combine-promises": "^1.1.0",
59
60
  "commander": "^5.1.0",
60
61
  "copy-webpack-plugin": "^10.2.4",
61
62
  "core-js": "^3.21.1",
@@ -104,8 +105,8 @@
104
105
  "webpackbar": "^5.0.2"
105
106
  },
106
107
  "devDependencies": {
107
- "@docusaurus/module-type-aliases": "0.0.0-4608",
108
- "@docusaurus/types": "0.0.0-4608",
108
+ "@docusaurus/module-type-aliases": "0.0.0-4614",
109
+ "@docusaurus/types": "0.0.0-4614",
109
110
  "@types/detect-port": "^1.3.2",
110
111
  "@types/nprogress": "^0.2.0",
111
112
  "@types/react-dom": "^17.0.11",
@@ -125,5 +126,5 @@
125
126
  "engines": {
126
127
  "node": ">=14"
127
128
  },
128
- "gitHead": "b22e657f0f14ffe2bbf983b110c58b7ce7e59f39"
129
+ "gitHead": "0fa2e52fbc24ea9aa80a5da40149036009bcf21c"
129
130
  }