@docusaurus/core 0.0.0-4291 → 0.0.0-4297

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.js CHANGED
@@ -5,7 +5,9 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- const chalk = require('chalk');
8
+ // @ts-check
9
+
10
+ const logger = require('@docusaurus/logger').default;
9
11
  const fs = require('fs-extra');
10
12
  const semver = require('semver');
11
13
  const path = require('path');
@@ -53,7 +55,7 @@ try {
53
55
  }
54
56
  } catch (e) {
55
57
  // Do not stop cli if this fails, see https://github.com/facebook/docusaurus/issues/5400
56
- console.error(e);
58
+ logger.error(e);
57
59
  }
58
60
 
59
61
  // We don't want to display update message for canary releases
@@ -74,6 +76,7 @@ if (
74
76
  notifier.config.set('update', notifier.update);
75
77
 
76
78
  if (ignoreUpdate(notifier.update)) {
79
+ // @ts-expect-error: it works
77
80
  return;
78
81
  }
79
82
 
@@ -91,6 +94,7 @@ if (
91
94
  ? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
92
95
  : `npm i ${siteDocusaurusPackagesForUpdate}`;
93
96
 
97
+ /** @type {import('boxen').Options} */
94
98
  const boxenOptions = {
95
99
  padding: 1,
96
100
  margin: 1,
@@ -100,13 +104,12 @@ if (
100
104
  };
101
105
 
102
106
  const docusaurusUpdateMessage = boxen(
103
- `Update available ${chalk.dim(`${notifier.update.current}`)}${chalk.reset(
104
- ' → ',
105
- )}${chalk.green(
106
- `${notifier.update.latest}`,
107
- )}\n\nTo upgrade Docusaurus packages with the latest version, run the following command:\n${chalk.cyan(
108
- `${upgradeCommand}`,
109
- )}`,
107
+ `Update available ${logger.dim(
108
+ `${notifier.update.current}`,
109
+ )}${logger.green(`${notifier.update.latest}`)}
110
+
111
+ To upgrade Docusaurus packages with the latest version, run the following command:
112
+ ${logger.code(upgradeCommand)}`,
110
113
  boxenOptions,
111
114
  );
112
115
 
@@ -115,11 +118,7 @@ if (
115
118
 
116
119
  // notify user if node version needs to be updated
117
120
  if (!semver.satisfies(process.version, requiredVersion)) {
118
- console.log(
119
- chalk.red(`\nMinimum Node version not met :(`) +
120
- chalk.yellow(
121
- `\n\nYou are using Node ${process.version}. We require Node ${requiredVersion} or up!\n`,
122
- ),
123
- );
121
+ logger.error('Minimum Node.js version not met :(');
122
+ logger.info`You are using Node.js number=${process.version}, Requirement: Node.js number=${requiredVersion}.`;
124
123
  process.exit(1);
125
124
  }
package/bin/docusaurus.js CHANGED
@@ -6,7 +6,9 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
- const chalk = require('chalk');
9
+ // @ts-check
10
+
11
+ const logger = require('@docusaurus/logger').default;
10
12
  const fs = require('fs');
11
13
  const cli = require('commander');
12
14
  const {
@@ -219,8 +221,7 @@ cli
219
221
 
220
222
  cli.arguments('<command>').action((cmd) => {
221
223
  cli.outputHelp();
222
- console.log(` ${chalk.red(`\n Unknown command ${chalk.yellow(cmd)}.`)}.`);
223
- console.log();
224
+ logger.error` Unknown command name=${cmd}.`;
224
225
  });
225
226
 
226
227
  function isInternalCommand(command) {
@@ -238,6 +239,7 @@ function isInternalCommand(command) {
238
239
 
239
240
  async function run() {
240
241
  if (!isInternalCommand(process.argv.slice(2)[0])) {
242
+ // @ts-expect-error: Hmmm
241
243
  await externalCommand(cli, resolveDir('.'));
242
244
  }
243
245
 
@@ -251,6 +253,6 @@ async function run() {
251
253
  run();
252
254
 
253
255
  process.on('unhandledRejection', (err) => {
254
- console.error(chalk.red(err.stack));
256
+ logger.error(err.stack);
255
257
  process.exit(1);
256
258
  });
package/lib/choosePort.js CHANGED
@@ -14,7 +14,7 @@ const tslib_1 = require("tslib");
14
14
  const child_process_1 = require("child_process");
15
15
  const detect_port_1 = (0, tslib_1.__importDefault)(require("detect-port"));
16
16
  const is_root_1 = (0, tslib_1.__importDefault)(require("is-root"));
17
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
17
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
18
18
  const prompts_1 = (0, tslib_1.__importDefault)(require("prompts"));
19
19
  const isInteractive = process.stdout.isTTY;
20
20
  const execOptions = {
@@ -53,10 +53,7 @@ function getProcessForPort(port) {
53
53
  const processId = getProcessIdOnPort(port);
54
54
  const directory = getDirectoryOfProcessById(processId);
55
55
  const command = getProcessCommand(processId);
56
- return (chalk_1.default.cyan(command) +
57
- chalk_1.default.grey(` (pid ${processId})\n`) +
58
- chalk_1.default.blue(' in ') +
59
- chalk_1.default.cyan(directory));
56
+ return logger_1.default.interpolate `code=${command} subdue=${`(pid ${processId})`} in path=${directory}`;
60
57
  }
61
58
  catch (e) {
62
59
  return null;
@@ -81,7 +78,9 @@ async function choosePort(host, defaultPort) {
81
78
  const question = {
82
79
  type: 'confirm',
83
80
  name: 'shouldChangePort',
84
- message: `${chalk_1.default.yellow(`${message}${existingProcess ? ` Probably:\n ${existingProcess}` : ''}`)}\n\nWould you like to run the app on another port instead?`,
81
+ message: logger_1.default.yellow(`${logger_1.default.bold('[WARNING]')} ${message}${existingProcess ? ` Probably:\n ${existingProcess}` : ''}
82
+
83
+ Would you like to run the app on another port instead?`),
85
84
  initial: true,
86
85
  };
87
86
  (0, prompts_1.default)(question).then((answer) => {
@@ -94,11 +93,12 @@ async function choosePort(host, defaultPort) {
94
93
  });
95
94
  }
96
95
  else {
97
- console.log(chalk_1.default.red(message));
96
+ logger_1.default.error(message);
98
97
  resolve(null);
99
98
  }
100
99
  }), (err) => {
101
- throw new Error(`${chalk_1.default.red(`Could not find an open port at ${chalk_1.default.bold(host)}.`)}\n${`Network error message: "${err.message}".` || err}\n`);
100
+ throw new Error(`Could not find an open port at ${host}.
101
+ ${`Network error message: "${err.message || err}".`}`);
102
102
  });
103
103
  }
104
104
  exports.default = choosePort;
@@ -5,6 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ // @ts-check
9
+
8
10
  import * as eta from 'eta';
9
11
  import React from 'react';
10
12
  import {StaticRouter} from 'react-router-dom';
@@ -24,7 +26,7 @@ import {
24
26
  createStatefulLinksCollector,
25
27
  ProvideLinksCollector,
26
28
  } from './LinksCollector';
27
- import chalk from 'chalk';
29
+ import logger from '@docusaurus/logger';
28
30
  // eslint-disable-next-line no-restricted-imports
29
31
  import {memoize} from 'lodash';
30
32
 
@@ -43,21 +45,16 @@ export default async function render(locals) {
43
45
  try {
44
46
  return await doRender(locals);
45
47
  } catch (e) {
46
- console.error(
47
- chalk.red(
48
- `Docusaurus Node/SSR could not render static page with path "${locals.path}" because of following error:\n\n${e.stack}\n`,
49
- ),
50
- );
48
+ logger.error`Docusaurus Node/SSR could not render static page with path path=${locals.path} because of following error:
49
+ ${e.stack}`;
51
50
 
52
51
  const isNotDefinedErrorRegex =
53
52
  /(window|document|localStorage|navigator|alert|location|buffer|self) is not defined/i;
54
53
 
55
54
  if (isNotDefinedErrorRegex.test(e.message)) {
56
- console.error(
57
- chalk.green(
58
- 'Pro tip: It looks like you are using code that should run on the client-side only.\nTo get around it, try using <BrowserOnly> (https://docusaurus.io/docs/docusaurus-core/#browseronly) or ExecutionEnvironment (https://docusaurus.io/docs/docusaurus-core/#executionenvironment).\nIt might also require to wrap your client code in useEffect hook and/or import a third-party library dynamically (if any).',
59
- ),
60
- );
55
+ logger.info`It looks like you are using code that should run on the client-side only.
56
+ To get around it, try using code=${'<BrowserOnly>'} (path=${'https://docusaurus.io/docs/docusaurus-core/#browseronly'}) or code=${'ExecutionEnvironment'} (path=${'https://docusaurus.io/docs/docusaurus-core/#executionenvironment'}).
57
+ It might also require to wrap your client code in code=${'useEffect'} hook and/or import a third-party library dynamically (if any).`;
61
58
  }
62
59
 
63
60
  throw new Error('Server-side rendering fails due to the error above.');
@@ -142,11 +139,8 @@ async function doRender(locals) {
142
139
  minifyJS: true,
143
140
  });
144
141
  } catch (e) {
145
- console.error(
146
- chalk.red(
147
- `Minification page with path "${locals.path}" failed because of following error:\n\n${e.stack}\n`,
148
- ),
149
- );
142
+ logger.error`Minification of page path=${locals.path} failed because of following error:
143
+ ${e.stack}`;
150
144
  throw e;
151
145
  }
152
146
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
10
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
11
  const copy_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("copy-webpack-plugin"));
12
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
@@ -30,7 +30,6 @@ forceTerminate = true) {
30
30
  });
31
31
  async function tryToBuildLocale({ locale, isLastLocale, }) {
32
32
  try {
33
- // console.log(chalk.green(`Site successfully built in locale=${locale}`));
34
33
  return await buildLocale({
35
34
  siteDir,
36
35
  locale,
@@ -40,7 +39,7 @@ forceTerminate = true) {
40
39
  });
41
40
  }
42
41
  catch (e) {
43
- console.error(`Unable to build website for locale "${locale}".`);
42
+ logger_1.default.error `Unable to build website for locale name=${locale}.`;
44
43
  throw e;
45
44
  }
46
45
  }
@@ -58,8 +57,7 @@ forceTerminate = true) {
58
57
  }
59
58
  else {
60
59
  if (i18n.locales.length > 1) {
61
- console.log(chalk_1.default.yellow(`\nWebsite will be built for all these locales:
62
- - ${i18n.locales.join('\n- ')}`));
60
+ logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
63
61
  }
64
62
  // We need the default locale to always be the 1st in the list
65
63
  // If we build it last, it would "erase" the localized sites built in subfolders
@@ -78,7 +76,7 @@ exports.default = build;
78
76
  async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
79
77
  process.env.BABEL_ENV = 'production';
80
78
  process.env.NODE_ENV = 'production';
81
- console.log(chalk_1.default.blue(`\n[${locale}] Creating an optimized production build...`));
79
+ logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
82
80
  const props = await (0, server_1.load)(siteDir, {
83
81
  customOutDir: cliOptions.outDir,
84
82
  customConfigFilePath: cliOptions.config,
@@ -161,9 +159,9 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
161
159
  outDir,
162
160
  baseUrl,
163
161
  });
164
- console.log(`${chalk_1.default.green(`Success!`)} Generated static files in "${chalk_1.default.cyan(path_1.default.relative(process.cwd(), outDir))}".`);
162
+ logger_1.default.success `Generated static files in path=${path_1.default.relative(process.cwd(), outDir)}.`;
165
163
  if (isLastLocale) {
166
- console.log(`\nUse ${chalk_1.default.greenBright('`npm run serve`')} command to test your build locally.\n`);
164
+ logger_1.default.info `Use code=${'npm run serve'} command to test your build locally.`;
167
165
  }
168
166
  if (forceTerminate && isLastLocale && !cliOptions.bundleAnalyzer) {
169
167
  process.exit(0);
@@ -9,18 +9,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
11
11
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
12
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
- function removePath(fsPath) {
15
- return fs_extra_1.default
16
- .remove(path_1.default.join(fsPath))
17
- .then(() => {
18
- console.log(chalk_1.default.green(`Successfully removed "${fsPath}" directory.`));
19
- })
20
- .catch((err) => {
21
- console.error(`Could not remove ${fsPath} directory.`);
22
- console.error(err);
23
- });
14
+ async function removePath(fsPath) {
15
+ try {
16
+ fs_extra_1.default.remove(path_1.default.join(fsPath));
17
+ logger_1.default.success `Removed the path=${fsPath} directory.`;
18
+ }
19
+ catch (e) {
20
+ logger_1.default.error `Could not remove path=${fsPath} directory.
21
+ ${e}`;
22
+ }
24
23
  }
25
24
  async function clear(siteDir) {
26
25
  return Promise.all([
@@ -10,7 +10,7 @@ exports.hasSSHProtocol = exports.buildHttpsUrl = exports.buildSshUrl = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
12
  const shelljs_1 = (0, tslib_1.__importDefault)(require("shelljs"));
13
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
13
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
14
  const server_1 = require("../server");
15
15
  const build_1 = (0, tslib_1.__importDefault)(require("./build"));
16
16
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
@@ -25,11 +25,11 @@ function obfuscateGitPass(str) {
25
25
  function shellExecLog(cmd) {
26
26
  try {
27
27
  const result = shelljs_1.default.exec(cmd);
28
- console.log(`${chalk_1.default.cyan('CMD:')} ${obfuscateGitPass(cmd)} ${chalk_1.default.cyan(`(code: ${result.code})`)}`);
28
+ logger_1.default.info `code=${obfuscateGitPass(cmd)} subdue=${`code: ${result.code}`}`;
29
29
  return result;
30
30
  }
31
31
  catch (e) {
32
- console.log(`${chalk_1.default.red('CMD:')} ${obfuscateGitPass(cmd)}`);
32
+ logger_1.default.error `code=${obfuscateGitPass(cmd)}`;
33
33
  throw e;
34
34
  }
35
35
  }
@@ -66,14 +66,12 @@ async function deploy(siteDir, cliOptions = {}) {
66
66
  customOutDir: cliOptions.outDir,
67
67
  });
68
68
  if (typeof siteConfig.trailingSlash === 'undefined') {
69
- console.warn(chalk_1.default.yellow(`
70
- Docusaurus recommendation:
71
- When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
69
+ logger_1.default.warn(`When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
72
70
  Otherwise, GitHub Pages will add an extra trailing slash to your site urls only on direct-access (not when navigation) with a server redirect.
73
71
  This behavior can have SEO impacts and create relative link issues.
74
- `));
72
+ `);
75
73
  }
76
- console.log('Deploy command invoked...');
74
+ logger_1.default.info('Deploy command invoked...');
77
75
  if (!shelljs_1.default.which('git')) {
78
76
  throw new Error('Git not installed or on the PATH!');
79
77
  }
@@ -102,14 +100,14 @@ This behavior can have SEO impacts and create relative link issues.
102
100
  if (!organizationName) {
103
101
  throw new Error(`Missing project organization name. Did you forget to define "organizationName" in ${siteConfigPath}? You may also export it via the ORGANIZATION_NAME environment variable.`);
104
102
  }
105
- console.log(`${chalk_1.default.cyan('organizationName:')} ${organizationName}`);
103
+ logger_1.default.info `organizationName: name=${organizationName}`;
106
104
  const projectName = process.env.PROJECT_NAME ||
107
105
  process.env.CIRCLE_PROJECT_REPONAME ||
108
106
  siteConfig.projectName;
109
107
  if (!projectName) {
110
108
  throw new Error(`Missing project name. Did you forget to define "projectName" in ${siteConfigPath}? You may also export it via the PROJECT_NAME environment variable.`);
111
109
  }
112
- console.log(`${chalk_1.default.cyan('projectName:')} ${projectName}`);
110
+ logger_1.default.info `projectName: name=${projectName}`;
113
111
  // We never deploy on pull request.
114
112
  const isPullRequest = process.env.CI_PULL_REQUEST || process.env.CIRCLE_PULL_REQUEST;
115
113
  if (isPullRequest) {
@@ -129,7 +127,7 @@ Please provide the branch name to deploy to as an environment variable, for exam
129
127
  You can also set the deploymentBranch property in docusaurus.config.js .`);
130
128
  }
131
129
  const deploymentBranch = process.env.DEPLOYMENT_BRANCH || siteConfig.deploymentBranch || 'gh-pages';
132
- console.log(`${chalk_1.default.cyan('deploymentBranch:')} ${deploymentBranch}`);
130
+ logger_1.default.info `deploymentBranch: name=${deploymentBranch}`;
133
131
  const githubHost = process.env.GITHUB_HOST || siteConfig.githubHost || 'github.com';
134
132
  const githubPort = process.env.GITHUB_PORT || siteConfig.githubPort;
135
133
  let deploymentRepoURL;
@@ -141,7 +139,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
141
139
  const gitCredentials = gitPass ? `${gitUser}:${gitPass}` : gitUser;
142
140
  deploymentRepoURL = buildHttpsUrl(gitCredentials, githubHost, organizationName, projectName, githubPort);
143
141
  }
144
- console.log(`${chalk_1.default.cyan('Remote repo URL:')} ${obfuscateGitPass(deploymentRepoURL)}`);
142
+ logger_1.default.info `Remote repo URL: name=${obfuscateGitPass(deploymentRepoURL)}`;
145
143
  // Check if this is a cross-repo publish.
146
144
  const crossRepoPublish = !sourceRepoUrl.endsWith(`${organizationName}/${projectName}.git`);
147
145
  // We don't allow deploying to the same branch unless it's a cross publish.
@@ -203,7 +201,7 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
203
201
  await runDeploy(await (0, build_1.default)(siteDir, cliOptions, false));
204
202
  }
205
203
  catch (buildError) {
206
- console.error(buildError);
204
+ logger_1.default.error(buildError.message);
207
205
  process.exit(1);
208
206
  }
209
207
  }
@@ -9,8 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const http_1 = (0, tslib_1.__importDefault)(require("http"));
11
11
  const serve_handler_1 = (0, tslib_1.__importDefault)(require("serve-handler"));
12
- const boxen_1 = (0, tslib_1.__importDefault)(require("boxen"));
13
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
12
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
13
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
15
14
  const server_1 = require("../server");
16
15
  const build_1 = (0, tslib_1.__importDefault)(require("./build"));
@@ -54,12 +53,7 @@ async function serve(siteDir, cliOptions) {
54
53
  trailingSlash,
55
54
  });
56
55
  });
57
- console.log((0, boxen_1.default)(chalk_1.default.green(`Serving "${cliOptions.dir}" directory at "${servingUrl + baseUrl}".`), {
58
- borderColor: 'green',
59
- padding: 1,
60
- margin: 1,
61
- align: 'center',
62
- }));
56
+ logger_1.default.success `Serving path=${cliOptions.dir} directory at path=${servingUrl + baseUrl}.`;
63
57
  server.listen(port);
64
58
  }
65
59
  exports.default = serve;
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
10
  const utils_1 = require("@docusaurus/utils");
11
- const chalk = require("chalk");
11
+ 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"));
@@ -27,7 +27,7 @@ const translations_1 = require("../server/translations/translations");
27
27
  async function start(siteDir, cliOptions) {
28
28
  process.env.NODE_ENV = 'development';
29
29
  process.env.BABEL_ENV = 'development';
30
- console.log(chalk.blue('Starting the development server...'));
30
+ logger_1.default.info('Starting the development server...');
31
31
  function loadSite() {
32
32
  return (0, server_1.load)(siteDir, {
33
33
  customConfigFilePath: cliOptions.config,
@@ -46,18 +46,18 @@ async function start(siteDir, cliOptions) {
46
46
  const { baseUrl, headTags, preBodyTags, postBodyTags } = props;
47
47
  const urls = (0, WebpackDevServerUtils_1.prepareUrls)(protocol, host, port);
48
48
  const openUrl = (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, baseUrl]);
49
- console.log(chalk.cyanBright(`Docusaurus website is running at "${openUrl}".`));
49
+ logger_1.default.success `Docusaurus website is running at path=${openUrl}.`;
50
50
  // Reload files processing.
51
51
  const reload = (0, lodash_1.debounce)(() => {
52
52
  loadSite()
53
53
  .then(({ baseUrl: newBaseUrl }) => {
54
54
  const newOpenUrl = (0, utils_1.normalizeUrl)([urls.localUrlForBrowser, newBaseUrl]);
55
55
  if (newOpenUrl !== openUrl) {
56
- console.log(chalk.cyanBright(`Docusaurus website is running at "${newOpenUrl}".`));
56
+ logger_1.default.success `Docusaurus website is running at path=${newOpenUrl}.`;
57
57
  }
58
58
  })
59
59
  .catch((err) => {
60
- console.error(chalk.red(err.stack));
60
+ logger_1.default.error(err.stack);
61
61
  });
62
62
  }, 500);
63
63
  const { siteConfig, plugins = [] } = props;
@@ -128,10 +128,10 @@ async function start(siteDir, cliOptions) {
128
128
  if (process.env.E2E_TEST) {
129
129
  compiler.hooks.done.tap('done', (stats) => {
130
130
  if (stats.hasErrors()) {
131
- console.log('E2E_TEST: Project has compiler errors.');
131
+ logger_1.default.error('E2E_TEST: Project has compiler errors.');
132
132
  process.exit(1);
133
133
  }
134
- console.log('E2E_TEST: Project can compile.');
134
+ logger_1.default.success('E2E_TEST: Project can compile.');
135
135
  process.exit(0);
136
136
  });
137
137
  }
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getPluginNames = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
11
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
12
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
14
14
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
@@ -82,20 +82,16 @@ function getComponentName(themePath, plugin, danger) {
82
82
  function themeComponents(themePath, plugin) {
83
83
  const components = colorCode(themePath, plugin);
84
84
  if (components.length === 0) {
85
- return `${chalk_1.default.red('No component to swizzle.')}`;
85
+ return 'No component to swizzle.';
86
86
  }
87
- return `
88
- ${chalk_1.default.cyan('Theme components available for swizzle.')}
87
+ return `Theme components available for swizzle.
89
88
 
90
- ${chalk_1.default.green('green =>')} safe: lower breaking change risk
91
- ${chalk_1.default.red('red =>')} unsafe: higher breaking change risk
89
+ ${logger_1.default.green(logger_1.default.bold('green =>'))} safe: lower breaking change risk
90
+ ${logger_1.default.red(logger_1.default.bold('red =>'))} unsafe: higher breaking change risk
92
91
 
93
92
  ${components.join('\n')}
94
93
  `;
95
94
  }
96
- function formattedThemeNames(themeNames) {
97
- return `Themes available for swizzle:\n- ${themeNames.join('\n- ')}`;
98
- }
99
95
  function colorCode(themePath, plugin) {
100
96
  var _a, _b;
101
97
  // support both commonjs and ES style exports
@@ -106,8 +102,8 @@ function colorCode(themePath, plugin) {
106
102
  : [];
107
103
  const [greenComponents, redComponents] = (0, lodash_1.partition)(components, (comp) => allowedComponent.includes(comp));
108
104
  return [
109
- ...greenComponents.map((component) => chalk_1.default.green(`safe: ${component}`)),
110
- ...redComponents.map((component) => chalk_1.default.red(`unsafe: ${component}`)),
105
+ ...greenComponents.map((component) => `${logger_1.default.green(logger_1.default.bold('safe:'))} ${component}`),
106
+ ...redComponents.map((component) => `${logger_1.default.red(logger_1.default.bold('unsafe:'))} ${component}`),
111
107
  ];
112
108
  }
113
109
  async function swizzle(siteDir, themeName, componentName, typescript, danger) {
@@ -123,8 +119,8 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
123
119
  ? plugins[index].getTypeScriptThemePath
124
120
  : plugins[index].getThemePath);
125
121
  if (!themeName) {
126
- console.log(formattedThemeNames(themeNames));
127
- process.exit(1);
122
+ logger_1.default.info `Themes available for swizzle: name=${themeNames}`;
123
+ return;
128
124
  }
129
125
  let pluginModule;
130
126
  try {
@@ -137,9 +133,9 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
137
133
  suggestion = name;
138
134
  }
139
135
  });
140
- chalk_1.default.red(`Theme ${themeName} not found. ${suggestion
141
- ? `Did you mean "${suggestion}" ?`
142
- : formattedThemeNames(themeNames)}`);
136
+ logger_1.default.error `Theme name=${themeName} not found. ${suggestion
137
+ ? logger_1.default.interpolate `Did you mean name=${suggestion}?`
138
+ : logger_1.default.interpolate `Themes available for swizzle: ${themeNames}`}`;
143
139
  process.exit(1);
144
140
  }
145
141
  let pluginOptions = {};
@@ -171,14 +167,14 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
171
167
  ? (_d = pluginInstance.getTypeScriptThemePath) === null || _d === void 0 ? void 0 : _d.call(pluginInstance)
172
168
  : (_e = pluginInstance.getThemePath) === null || _e === void 0 ? void 0 : _e.call(pluginInstance);
173
169
  if (!themePath) {
174
- console.warn(chalk_1.default.yellow(typescript
175
- ? `${themeName} does not provide TypeScript theme code via "getTypeScriptThemePath()".`
176
- : `${themeName} does not provide any theme code.`));
170
+ logger_1.default.warn(typescript
171
+ ? logger_1.default.interpolate `name=${themeName} does not provide TypeScript theme code via ${'getTypeScriptThemePath()'}.`
172
+ : logger_1.default.interpolate `name=${themeName} does not provide any theme code.`);
177
173
  process.exit(1);
178
174
  }
179
175
  if (!componentName) {
180
- console.warn(themeComponents(themePath, pluginModule));
181
- process.exit(1);
176
+ logger_1.default.info(themeComponents(themePath, pluginModule));
177
+ return;
182
178
  }
183
179
  const components = getComponentName(themePath, pluginModule, Boolean(danger));
184
180
  const formattedComponentName = formatComponentName(componentName);
@@ -199,7 +195,8 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
199
195
  });
200
196
  if (mostSuitableMatch !== componentName) {
201
197
  mostSuitableComponent = mostSuitableMatch;
202
- console.log(chalk_1.default.red(`Component "${componentName}" doesn't exist.`), chalk_1.default.yellow(`"${mostSuitableComponent}" is swizzled instead of "${componentName}".`));
198
+ logger_1.default.error `Component name=${componentName} doesn't exist.`;
199
+ logger_1.default.info `name=${mostSuitableComponent} is swizzled instead of name=${componentName}.`;
203
200
  }
204
201
  }
205
202
  let fromPath = path_1.default.join(themePath, mostSuitableComponent);
@@ -223,23 +220,17 @@ async function swizzle(siteDir, themeName, componentName, typescript, danger) {
223
220
  suggestion = name;
224
221
  }
225
222
  });
226
- console.warn(chalk_1.default.red(`Component ${mostSuitableComponent} not found.`));
227
- console.warn(suggestion
228
- ? `Did you mean "${suggestion}"?`
229
- : `${themeComponents(themePath, pluginModule)}`);
223
+ logger_1.default.error `Component name=${mostSuitableComponent} not found. ${suggestion
224
+ ? logger_1.default.interpolate `Did you mean name=${suggestion} ?`
225
+ : themeComponents(themePath, pluginModule)}`;
230
226
  process.exit(1);
231
227
  }
232
228
  }
233
229
  if (!components.includes(mostSuitableComponent) && !danger) {
234
- console.warn(chalk_1.default.red(`${mostSuitableComponent} is an internal component and has a higher breaking change probability. If you want to swizzle it, use the "--danger" flag.`));
230
+ logger_1.default.error `name=${mostSuitableComponent} is an internal component and has a higher breaking change probability. If you want to swizzle it, use the code=${'--danger'} flag.`;
235
231
  process.exit(1);
236
232
  }
237
233
  await fs_extra_1.default.copy(fromPath, toPath);
238
- const relativeDir = path_1.default.relative(process.cwd(), toPath);
239
- const fromMsg = chalk_1.default.blue(mostSuitableComponent
240
- ? `${themeName} ${chalk_1.default.yellow(mostSuitableComponent)}`
241
- : themeName);
242
- const toMsg = chalk_1.default.cyan(relativeDir);
243
- console.log(`\n${chalk_1.default.green('Success!')} Copied ${fromMsg} to ${toMsg}.\n`);
234
+ logger_1.default.success `Copied code=${mostSuitableComponent ? `${themeName} ${mostSuitableComponent}` : themeName} to path=${path_1.default.relative(process.cwd(), toPath)}.`;
244
235
  }
245
236
  exports.default = swizzle;
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.transformMarkdownContent = exports.transformMarkdownHeadingLine = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
12
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
13
  const server_1 = require("../server");
14
14
  const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
15
15
  const utils_1 = require("@docusaurus/utils");
@@ -100,11 +100,10 @@ async function writeHeadingIds(siteDir, files, options) {
100
100
  const result = await Promise.all(markdownFiles.map((p) => transformMarkdownFile(p, options)));
101
101
  const pathsModified = result.filter(Boolean);
102
102
  if (pathsModified.length) {
103
- console.log(chalk_1.default.green(`Heading ids added to Markdown files (${pathsModified.length}/${markdownFiles.length} files):
104
- - ${pathsModified.join('\n- ')}`));
103
+ logger_1.default.success `Heading ids added to Markdown files (number=${`${pathsModified.length}/${markdownFiles.length}`} files): ${pathsModified}`;
105
104
  }
106
105
  else {
107
- console.log(chalk_1.default.yellow(`${markdownFiles.length} Markdown files already have explicit heading IDs. If you intend to overwrite the existing heading IDs, use the ${chalk_1.default.cyan('--overwrite')} option.`));
106
+ logger_1.default.warn `number=${markdownFiles.length} Markdown files already have explicit heading IDs. If you intend to overwrite the existing heading IDs, use the code=${'--overwrite'} option.`;
108
107
  }
109
108
  }
110
109
  exports.default = writeHeadingIds;
@@ -7,6 +7,8 @@
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 tslib_1 = require("tslib");
11
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
10
12
  const utils_1 = require("@docusaurus/utils");
11
13
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
14
  const DEFAULT_I18N_LOCALE = 'en';
@@ -147,7 +149,7 @@ function validateConfig(config) {
147
149
  if (error) {
148
150
  (0, utils_validation_1.logValidationBugReportHint)();
149
151
  if (utils_validation_1.isValidationDisabledEscapeHatch) {
150
- console.error(error);
152
+ logger_1.default.error(error.message);
151
153
  return config;
152
154
  }
153
155
  const unknownFields = error.details.reduce((formattedError, err) => {
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
11
11
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  const rtl_detect_1 = require("rtl-detect");
14
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
14
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
15
15
  function getDefaultLocaleLabel(locale) {
16
16
  // Intl.DisplayNames is ES2021 - Node14+
17
17
  // https://v8.dev/features/intl-displaynames
@@ -40,15 +40,12 @@ async function loadI18n(config, options = {}) {
40
40
  const { i18n: i18nConfig } = config;
41
41
  const currentLocale = (_a = options.locale) !== null && _a !== void 0 ? _a : i18nConfig.defaultLocale;
42
42
  if (!i18nConfig.locales.includes(currentLocale)) {
43
- console.warn(chalk_1.default.yellow(`The locale "${currentLocale}" was not found in your site configuration: Available locales are: ${i18nConfig.locales.join(',')}.
44
- 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.`;
45
45
  }
46
46
  const locales = i18nConfig.locales.includes(currentLocale)
47
47
  ? i18nConfig.locales
48
48
  : i18nConfig.locales.concat(currentLocale);
49
- if (shouldWarnAboutNodeVersion(utils_1.NODE_MAJOR_VERSION, locales)) {
50
- console.warn(chalk_1.default.yellow(`To use Docusaurus i18n, it is strongly advised to use Node.js 14 or later (instead of ${utils_1.NODE_MAJOR_VERSION}).`));
51
- }
52
49
  function getLocaleConfig(locale) {
53
50
  return {
54
51
  ...getDefaultLocaleConfig(locale),
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.load = exports.loadPluginConfigs = exports.loadContext = exports.loadSiteConfig = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("@docusaurus/utils");
12
- const path_1 = (0, tslib_1.__importStar)(require("path"));
13
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
12
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
14
  const ssr_html_template_1 = (0, tslib_1.__importDefault)(require("../client/templates/ssr.html.template"));
15
15
  const client_modules_1 = (0, tslib_1.__importDefault)(require("./client-modules"));
16
16
  const config_1 = (0, tslib_1.__importDefault)(require("./config"));
@@ -243,8 +243,8 @@ ${Object.keys(registry)
243
243
  const genCodeTranslations = (0, utils_1.generate)(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslationsWithFallbacks, null, 2));
244
244
  // Version metadata.
245
245
  const siteMetadata = {
246
- docusaurusVersion: (0, versions_1.getPackageJsonVersion)((0, path_1.join)(__dirname, '../../package.json')),
247
- siteVersion: (0, versions_1.getPackageJsonVersion)((0, path_1.join)(siteDir, 'package.json')),
246
+ docusaurusVersion: (0, versions_1.getPackageJsonVersion)(path_1.default.join(__dirname, '../../package.json')),
247
+ siteVersion: (0, versions_1.getPackageJsonVersion)(path_1.default.join(siteDir, 'package.json')),
248
248
  pluginVersions: {},
249
249
  };
250
250
  plugins
@@ -295,10 +295,13 @@ function checkDocusaurusPackagesVersion(siteMetadata) {
295
295
  var _a;
296
296
  if (versionInfo.type === 'package' &&
297
297
  ((_a = versionInfo.name) === null || _a === void 0 ? void 0 : _a.startsWith('@docusaurus/')) &&
298
+ versionInfo.version &&
298
299
  versionInfo.version !== docusaurusVersion) {
299
300
  // should we throw instead?
300
301
  // It still could work with different versions
301
- console.warn(chalk_1.default.red(`Invalid ${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?`));
302
+ logger_1.default.error `Invalid name=${plugin} version number=${versionInfo.version}.
303
+ All official @docusaurus/* packages should have the exact same version as @docusaurus/core (number=${docusaurusVersion}).
304
+ Maybe you want to check, or regenerate your yarn.lock or package-lock.json file?`;
302
305
  }
303
306
  });
304
307
  }
@@ -12,7 +12,7 @@ const utils_1 = require("@docusaurus/utils");
12
12
  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
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
15
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
16
16
  const lodash_1 = require("lodash");
17
17
  const translations_1 = require("../translations/translations");
18
18
  const applyRouteTrailingSlash_1 = (0, tslib_1.__importDefault)(require("./applyRouteTrailingSlash"));
@@ -144,7 +144,7 @@ async function loadPlugins({ pluginConfigs, context, }) {
144
144
  // TODO remove this deprecated lifecycle soon
145
145
  // deprecated since alpha-60
146
146
  // TODO, 1 user reported usage of this lifecycle! https://github.com/facebook/docusaurus/issues/3918
147
- console.error(chalk_1.default.red('Plugin routesLoaded lifecycle is deprecated. If you think we should keep this lifecycle, please report here: https://github.com/facebook/docusaurus/issues/3918'));
147
+ logger_1.default.error `Plugin code=${'routesLoaded'} lifecycle is deprecated. If you think we should keep this lifecycle, please report here: path=${'https://github.com/facebook/docusaurus/issues/3918'}`;
148
148
  return plugin.routesLoaded(pluginsRouteConfigs);
149
149
  }));
150
150
  // Sort the route config. This ensures that route with nested
@@ -13,7 +13,7 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
13
  const lodash_1 = require("lodash");
14
14
  const utils_1 = require("@docusaurus/utils");
15
15
  const utils_validation_1 = require("@docusaurus/utils-validation");
16
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
16
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
17
17
  const TranslationFileContentSchema = utils_validation_1.Joi.object()
18
18
  .pattern(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
19
19
  message: utils_validation_1.Joi.string().allow('').required(),
@@ -70,9 +70,8 @@ async function writeTranslationFileContent({ filePath, content: newContent, opti
70
70
  // Warn about potential legacy keys
71
71
  const unknownKeys = (0, lodash_1.difference)(Object.keys(existingContent !== null && existingContent !== void 0 ? existingContent : {}), Object.keys(newContent));
72
72
  if (unknownKeys.length > 0) {
73
- console.warn(chalk_1.default.yellow(`Some translation keys looks unknown to us in file ${filePath}
74
- Maybe you should remove them?
75
- - ${unknownKeys.join('\n- ')}`));
73
+ logger_1.default.warn `Some translation keys looks unknown to us in file path=${filePath}.
74
+ Maybe you should remove them? ${unknownKeys}`;
76
75
  }
77
76
  const mergedContent = mergeTranslationFileContent({
78
77
  existingContent,
@@ -81,9 +80,7 @@ Maybe you should remove them?
81
80
  });
82
81
  // Avoid creating empty translation files
83
82
  if (Object.keys(mergedContent).length > 0) {
84
- console.log(`${Object.keys(mergedContent)
85
- .length.toString()
86
- .padStart(3, ' ')} translations will be written at "${(0, utils_1.toMessageRelativeFilePath)(filePath)}".`);
83
+ logger_1.default.info `number=${Object.keys(mergedContent).length} translations will be written at path=${(0, utils_1.toMessageRelativeFilePath)(filePath)}.`;
87
84
  await fs_extra_1.default.ensureDir(path_1.default.dirname(filePath));
88
85
  await fs_extra_1.default.writeFile(filePath, JSON.stringify(mergedContent, null, 2));
89
86
  }
@@ -178,10 +175,8 @@ exports.getPluginsDefaultCodeTranslationMessages = getPluginsDefaultCodeTranslat
178
175
  function applyDefaultCodeTranslations({ extractedCodeTranslations, defaultCodeMessages, }) {
179
176
  const unusedDefaultCodeMessages = (0, lodash_1.difference)(Object.keys(defaultCodeMessages), Object.keys(extractedCodeTranslations));
180
177
  if (unusedDefaultCodeMessages.length > 0) {
181
- console.warn(chalk_1.default.yellow(`Unused default message codes found.
182
- Please report this Docusaurus issue.
183
- - ${unusedDefaultCodeMessages.join('\n- ')}
184
- `));
178
+ logger_1.default.warn `Unused default message codes found.
179
+ Please report this Docusaurus issue. name=${unusedDefaultCodeMessages}`;
185
180
  }
186
181
  return (0, lodash_1.mapValues)(extractedCodeTranslations, (messageTranslation, messageId) => {
187
182
  var _a;
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
11
11
  const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
12
  const traverse_1 = (0, tslib_1.__importDefault)(require("@babel/traverse"));
13
13
  const generator_1 = (0, tslib_1.__importDefault)(require("@babel/generator"));
14
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
14
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
15
15
  const core_1 = require("@babel/core");
16
16
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
17
17
  const utils_1 = require("@docusaurus/utils");
@@ -78,7 +78,7 @@ exports.extractSiteSourceCodeTranslations = extractSiteSourceCodeTranslations;
78
78
  function logSourceCodeFileTranslationsWarnings(sourceCodeFilesTranslations) {
79
79
  sourceCodeFilesTranslations.forEach(({ sourceCodeFilePath, warnings }) => {
80
80
  if (warnings.length > 0) {
81
- console.warn(`Translation extraction warnings for file path=${sourceCodeFilePath}:\n- ${chalk_1.default.yellow(warnings.join('\n\n- '))}`);
81
+ logger_1.default.warn `Translation extraction warnings for file path=${sourceCodeFilePath}: ${warnings}`;
82
82
  }
83
83
  });
84
84
  }
@@ -200,13 +200,11 @@ function extractSourceCodeAstTranslations(ast, sourceCodeFilePath) {
200
200
  if (!path.get('callee').isIdentifier({ name: 'translate' })) {
201
201
  return;
202
202
  }
203
- // console.log('CallExpression', path.node);
204
203
  const args = path.get('arguments');
205
204
  if (args.length === 1 || args.length === 2) {
206
205
  const firstArgPath = args[0];
207
206
  // evaluation allows translate("x" + "y"); to be considered as translate("xy");
208
207
  const firstArgEvaluated = firstArgPath.evaluate();
209
- // console.log('firstArgEvaluated', firstArgEvaluated);
210
208
  if (firstArgEvaluated.confident &&
211
209
  typeof firstArgEvaluated.value === 'object') {
212
210
  const { message, id, description } = firstArgEvaluated.value;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  const tslib_1 = require("tslib");
10
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
10
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
11
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
12
  const webpack_merge_1 = (0, tslib_1.__importDefault)(require("webpack-merge"));
13
13
  const base_1 = require("./base");
@@ -39,7 +39,7 @@ function createClientConfig(props, minify = true) {
39
39
  apply: (compiler) => {
40
40
  compiler.hooks.done.tap('client:done', (stats) => {
41
41
  if (stats.hasErrors()) {
42
- console.log(chalk_1.default.red('Client bundle compiled with errors therefore further build is impossible.'));
42
+ logger_1.default.error('Client bundle compiled with errors therefore further build is impossible.');
43
43
  process.exit(1);
44
44
  }
45
45
  });
@@ -16,7 +16,7 @@ const terser_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("terser-web
16
16
  const css_minimizer_webpack_plugin_1 = (0, tslib_1.__importDefault)(require("css-minimizer-webpack-plugin"));
17
17
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
18
18
  const crypto_1 = (0, tslib_1.__importDefault)(require("crypto"));
19
- const chalk_1 = (0, tslib_1.__importDefault)(require("chalk"));
19
+ const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
20
20
  const utils_1 = require("@docusaurus/utils");
21
21
  const lodash_1 = require("lodash");
22
22
  // Utility method to get style loaders
@@ -113,7 +113,7 @@ const getCustomizableJSLoader = (jsLoader = 'babel') => ({ isServer, babelOption
113
113
  exports.getCustomizableJSLoader = getCustomizableJSLoader;
114
114
  // TODO remove this before end of 2021?
115
115
  const warnBabelLoaderOnce = (0, lodash_1.memoize)(() => {
116
- console.warn(chalk_1.default.yellow('Docusaurus plans to support multiple JS loader strategies (Babel, esbuild...): "getBabelLoader(isServer)" is now deprecated in favor of "getJSLoader({isServer})".'));
116
+ 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)'}.`;
117
117
  });
118
118
  const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, babelOptions) {
119
119
  warnBabelLoaderOnce();
@@ -121,7 +121,7 @@ const getBabelLoaderDeprecated = function getBabelLoaderDeprecated(isServer, bab
121
121
  };
122
122
  // TODO remove this before end of 2021 ?
123
123
  const warnCacheLoaderOnce = (0, lodash_1.memoize)(() => {
124
- console.warn(chalk_1.default.yellow('Docusaurus uses Webpack 5 and getCacheLoader() usage is now deprecated.'));
124
+ logger_1.default.warn `Docusaurus uses Webpack 5 and code=${'getCacheLoader()'} usage is now deprecated.`;
125
125
  });
126
126
  function getCacheLoaderDeprecated() {
127
127
  warnCacheLoaderOnce();
@@ -188,11 +188,11 @@ function compile(config) {
188
188
  compiler.run((err, stats) => {
189
189
  var _a;
190
190
  if (err) {
191
- console.error(err.stack || err);
191
+ logger_1.default.error(err.stack || err);
192
192
  // @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
193
193
  if (err.details) {
194
194
  // @ts-expect-error: see https://webpack.js.org/api/node/#error-handling
195
- console.error(err.details);
195
+ logger_1.default.error(err.details);
196
196
  }
197
197
  reject(err);
198
198
  }
@@ -203,14 +203,14 @@ function compile(config) {
203
203
  }
204
204
  if (errorsWarnings && (stats === null || stats === void 0 ? void 0 : stats.hasWarnings())) {
205
205
  (_a = errorsWarnings.warnings) === null || _a === void 0 ? void 0 : _a.forEach((warning) => {
206
- console.warn(warning);
206
+ logger_1.default.warn(`${warning}`);
207
207
  });
208
208
  }
209
209
  // Webpack 5 requires calling close() so that persistent caching works
210
210
  // See https://github.com/webpack/webpack.js.org/pull/4775
211
211
  compiler.close((errClose) => {
212
212
  if (errClose) {
213
- console.error(chalk_1.default.red('Error while closing Webpack compiler:', errClose));
213
+ logger_1.default.error(`Error while closing Webpack compiler: ${errClose}`);
214
214
  reject(errClose);
215
215
  }
216
216
  else {
@@ -230,20 +230,22 @@ function validateKeyAndCerts({ cert, key, keyFile, crtFile, }) {
230
230
  encrypted = crypto_1.default.publicEncrypt(cert, Buffer.from('test'));
231
231
  }
232
232
  catch (err) {
233
- throw new Error(`The certificate "${chalk_1.default.yellow(crtFile)}" is invalid.\n${err.message}`);
233
+ throw new Error(`The certificate ${crtFile} is invalid.
234
+ ${err}`);
234
235
  }
235
236
  try {
236
237
  // privateDecrypt will throw an error with an invalid key
237
238
  crypto_1.default.privateDecrypt(key, encrypted);
238
239
  }
239
240
  catch (err) {
240
- throw new Error(`The certificate key "${chalk_1.default.yellow(keyFile)}" is invalid.\n${err.message}`);
241
+ throw new Error(`The certificate key ${keyFile} is invalid.
242
+ ${err}`);
241
243
  }
242
244
  }
243
245
  // Read file and throw an error if it doesn't exist
244
246
  function readEnvFile(file, type) {
245
247
  if (!fs_extra_1.default.existsSync(file)) {
246
- throw new Error(`You specified ${chalk_1.default.cyan(type)} in your env, but the file "${chalk_1.default.yellow(file)}" can't be found.`);
248
+ throw new Error(`You specified ${type} in your env, but the file "${file}" can't be found.`);
247
249
  }
248
250
  return fs_extra_1.default.readFileSync(file);
249
251
  }
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-4291",
4
+ "version": "0.0.0-4297",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -41,19 +41,19 @@
41
41
  "@babel/runtime": "^7.16.3",
42
42
  "@babel/runtime-corejs3": "^7.16.3",
43
43
  "@babel/traverse": "^7.16.3",
44
- "@docusaurus/cssnano-preset": "0.0.0-4291",
45
- "@docusaurus/mdx-loader": "0.0.0-4291",
44
+ "@docusaurus/cssnano-preset": "0.0.0-4297",
45
+ "@docusaurus/logger": "0.0.0-4297",
46
+ "@docusaurus/mdx-loader": "0.0.0-4297",
46
47
  "@docusaurus/react-loadable": "5.5.2",
47
- "@docusaurus/utils": "0.0.0-4291",
48
- "@docusaurus/utils-common": "0.0.0-4291",
49
- "@docusaurus/utils-validation": "0.0.0-4291",
48
+ "@docusaurus/utils": "0.0.0-4297",
49
+ "@docusaurus/utils-common": "0.0.0-4297",
50
+ "@docusaurus/utils-validation": "0.0.0-4297",
50
51
  "@slorber/static-site-generator-webpack-plugin": "^4.0.0",
51
52
  "@svgr/webpack": "^6.0.0",
52
53
  "autoprefixer": "^10.3.5",
53
54
  "babel-loader": "^8.2.2",
54
55
  "babel-plugin-dynamic-import-node": "2.3.0",
55
56
  "boxen": "^5.0.1",
56
- "chalk": "^4.1.2",
57
57
  "chokidar": "^3.5.2",
58
58
  "clean-css": "^5.1.5",
59
59
  "commander": "^5.1.0",
@@ -108,8 +108,8 @@
108
108
  "webpackbar": "^5.0.0-3"
109
109
  },
110
110
  "devDependencies": {
111
- "@docusaurus/module-type-aliases": "0.0.0-4291",
112
- "@docusaurus/types": "0.0.0-4291",
111
+ "@docusaurus/module-type-aliases": "0.0.0-4297",
112
+ "@docusaurus/types": "0.0.0-4297",
113
113
  "@types/copy-webpack-plugin": "^8.0.1",
114
114
  "@types/css-minimizer-webpack-plugin": "^3.0.2",
115
115
  "@types/detect-port": "^1.3.0",
@@ -128,5 +128,5 @@
128
128
  "engines": {
129
129
  "node": ">=14"
130
130
  },
131
- "gitHead": "7097980fb8a57b1950c0714707966eea27f69975"
131
+ "gitHead": "84ae34c33c664bf856f3a92047919a074e087d77"
132
132
  }