@docusaurus/core 2.3.1 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/beforeCli.mjs +15 -5
- package/bin/docusaurus.mjs +6 -0
- package/lib/client/BaseUrlIssueBanner/index.js +6 -4
- package/lib/client/BaseUrlIssueBanner/styles.module.css +1 -1
- package/lib/client/theme-fallback/Error/index.js +20 -5
- package/lib/commands/build.js +7 -2
- package/lib/commands/start.js +4 -2
- package/package.json +10 -10
package/bin/beforeCli.mjs
CHANGED
|
@@ -104,10 +104,20 @@ export default async function beforeCli() {
|
|
|
104
104
|
.filter((p) => p.startsWith('@docusaurus'))
|
|
105
105
|
.map((p) => p.concat('@latest'))
|
|
106
106
|
.join(' ');
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
|
|
108
|
+
const getUpgradeCommand = async () => {
|
|
109
|
+
const isYarnUsed = await fs.pathExists(path.resolve('yarn.lock'));
|
|
110
|
+
if (!isYarnUsed) {
|
|
111
|
+
return `npm i ${siteDocusaurusPackagesForUpdate}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const isYarnClassicUsed = !(await fs.pathExists(
|
|
115
|
+
path.resolve('.yarnrc.yml'),
|
|
116
|
+
));
|
|
117
|
+
return isYarnClassicUsed
|
|
118
|
+
? `yarn upgrade ${siteDocusaurusPackagesForUpdate}`
|
|
119
|
+
: `yarn up ${siteDocusaurusPackagesForUpdate}`;
|
|
120
|
+
};
|
|
111
121
|
|
|
112
122
|
/** @type {import('boxen').Options} */
|
|
113
123
|
const boxenOptions = {
|
|
@@ -124,7 +134,7 @@ export default async function beforeCli() {
|
|
|
124
134
|
)} → ${logger.green(`${notifier.update.latest}`)}
|
|
125
135
|
|
|
126
136
|
To upgrade Docusaurus packages with the latest version, run the following command:
|
|
127
|
-
${logger.code(
|
|
137
|
+
${logger.code(await getUpgradeCommand())}`,
|
|
128
138
|
boxenOptions,
|
|
129
139
|
);
|
|
130
140
|
|
package/bin/docusaurus.mjs
CHANGED
|
@@ -24,6 +24,12 @@ import {
|
|
|
24
24
|
} from '../lib/index.js';
|
|
25
25
|
import beforeCli from './beforeCli.mjs';
|
|
26
26
|
|
|
27
|
+
// Env variables are initialized to dev, but can be overridden by each command
|
|
28
|
+
// For example, "docusaurus build" overrides them to "production"
|
|
29
|
+
// See also https://github.com/facebook/docusaurus/issues/8599
|
|
30
|
+
process.env.BABEL_ENV ??= 'development';
|
|
31
|
+
process.env.NODE_ENV ??= 'development';
|
|
32
|
+
|
|
27
33
|
await beforeCli();
|
|
28
34
|
|
|
29
35
|
cli.version(DOCUSAURUS_VERSION).usage('<command> [options]');
|
|
@@ -11,9 +11,11 @@ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
|
11
11
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
12
12
|
// Double-security: critical CSS will hide the banner if CSS can load!
|
|
13
13
|
import './styles.module.css';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
14
|
+
// __ prefix allows search crawlers (Algolia/DocSearch) to ignore anchors
|
|
15
|
+
// https://github.com/facebook/docusaurus/issues/8883#issuecomment-1516328368
|
|
16
|
+
const BannerContainerId = '__docusaurus-base-url-issue-banner-container';
|
|
17
|
+
const BannerId = '__docusaurus-base-url-issue-banner';
|
|
18
|
+
const SuggestionContainerId = '__docusaurus-base-url-issue-banner-suggestion-container';
|
|
17
19
|
const InsertBannerWindowAttribute = '__DOCUSAURUS_INSERT_BASEURL_BANNER';
|
|
18
20
|
// It is important to not use React to render this banner
|
|
19
21
|
// otherwise Google would index it, even if it's hidden with some critical CSS!
|
|
@@ -24,7 +26,7 @@ function createInlineHtmlBanner(baseUrl) {
|
|
|
24
26
|
return `
|
|
25
27
|
<div id="${BannerId}" style="border: thick solid red; background-color: rgb(255, 230, 179); margin: 20px; padding: 20px; font-size: 20px;">
|
|
26
28
|
<p style="font-weight: bold; font-size: 30px;">Your Docusaurus site did not load properly.</p>
|
|
27
|
-
<p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#
|
|
29
|
+
<p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseUrl" style="font-weight: bold;">baseUrl configuration</a>.</p>
|
|
28
30
|
<p>Current configured baseUrl = <span style="font-weight: bold; color: red;">${baseUrl}</span> ${baseUrl === '/' ? ' (default value)' : ''}</p>
|
|
29
31
|
<p>We suggest trying baseUrl = <span id="${SuggestionContainerId}" style="font-weight: bold; color: green;"></span></p>
|
|
30
32
|
</div>
|
|
@@ -9,24 +9,39 @@
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import Head from '@docusaurus/Head';
|
|
11
11
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
12
|
+
import { getErrorCausalChain } from '@docusaurus/utils-common';
|
|
12
13
|
import Layout from '@theme/Layout';
|
|
13
14
|
function ErrorDisplay({ error, tryAgain }) {
|
|
14
15
|
return (<div style={{
|
|
15
16
|
display: 'flex',
|
|
16
17
|
flexDirection: 'column',
|
|
17
18
|
justifyContent: 'center',
|
|
18
|
-
alignItems: '
|
|
19
|
-
|
|
19
|
+
alignItems: 'flex-start',
|
|
20
|
+
minHeight: '100vh',
|
|
20
21
|
width: '100%',
|
|
22
|
+
maxWidth: '80ch',
|
|
21
23
|
fontSize: '20px',
|
|
24
|
+
margin: '0 auto',
|
|
25
|
+
padding: '1rem',
|
|
26
|
+
}}>
|
|
27
|
+
<h1 style={{ fontSize: '3rem' }}>This page crashed</h1>
|
|
28
|
+
<button type="button" onClick={tryAgain} style={{
|
|
29
|
+
margin: '1rem 0',
|
|
30
|
+
fontSize: '2rem',
|
|
31
|
+
cursor: 'pointer',
|
|
32
|
+
borderRadius: 20,
|
|
33
|
+
padding: '1rem',
|
|
22
34
|
}}>
|
|
23
|
-
<h1>This page crashed.</h1>
|
|
24
|
-
<p>{error.message}</p>
|
|
25
|
-
<button type="button" onClick={tryAgain}>
|
|
26
35
|
Try again
|
|
27
36
|
</button>
|
|
37
|
+
<ErrorBoundaryError error={error}/>
|
|
28
38
|
</div>);
|
|
29
39
|
}
|
|
40
|
+
function ErrorBoundaryError({ error }) {
|
|
41
|
+
const causalChain = getErrorCausalChain(error);
|
|
42
|
+
const fullMessage = causalChain.map((e) => e.message).join('\n\nCause:\n');
|
|
43
|
+
return <p style={{ whiteSpace: 'pre-wrap' }}>{fullMessage}</p>;
|
|
44
|
+
}
|
|
30
45
|
export default function Error({ error, tryAgain }) {
|
|
31
46
|
// We wrap the error in its own error boundary because the layout can actually
|
|
32
47
|
// throw too... Only the ErrorDisplay component is simple enough to be
|
package/lib/commands/build.js
CHANGED
|
@@ -29,6 +29,9 @@ async function build(siteDirParam = '.', cliOptions = {},
|
|
|
29
29
|
// deploy, we have to let deploy finish.
|
|
30
30
|
// See https://github.com/facebook/docusaurus/pull/2496
|
|
31
31
|
forceTerminate = true) {
|
|
32
|
+
process.env.BABEL_ENV = 'production';
|
|
33
|
+
process.env.NODE_ENV = 'production';
|
|
34
|
+
process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
|
|
32
35
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
33
36
|
['SIGINT', 'SIGTERM'].forEach((sig) => {
|
|
34
37
|
process.on(sig, () => process.exit());
|
|
@@ -78,8 +81,10 @@ forceTerminate = true) {
|
|
|
78
81
|
}
|
|
79
82
|
exports.build = build;
|
|
80
83
|
async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
// Temporary workaround to unlock the ability to translate the site config
|
|
85
|
+
// We'll remove it if a better official API can be designed
|
|
86
|
+
// See https://github.com/facebook/docusaurus/issues/4542
|
|
87
|
+
process.env.DOCUSAURUS_CURRENT_LOCALE = locale;
|
|
83
88
|
logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
|
|
84
89
|
const props = await (0, server_1.load)({
|
|
85
90
|
siteDir,
|
package/lib/commands/start.js
CHANGED
|
@@ -26,9 +26,11 @@ const client_1 = tslib_1.__importDefault(require("../webpack/client"));
|
|
|
26
26
|
const utils_2 = require("../webpack/utils");
|
|
27
27
|
const getHostPort_1 = require("../server/getHostPort");
|
|
28
28
|
async function start(siteDirParam = '.', cliOptions = {}) {
|
|
29
|
+
// Temporary workaround to unlock the ability to translate the site config
|
|
30
|
+
// We'll remove it if a better official API can be designed
|
|
31
|
+
// See https://github.com/facebook/docusaurus/issues/4542
|
|
32
|
+
process.env.DOCUSAURUS_CURRENT_LOCALE = cliOptions.locale;
|
|
29
33
|
const siteDir = await fs_extra_1.default.realpath(siteDirParam);
|
|
30
|
-
process.env.NODE_ENV = 'development';
|
|
31
|
-
process.env.BABEL_ENV = 'development';
|
|
32
34
|
logger_1.default.info('Starting the development server...');
|
|
33
35
|
function loadSite() {
|
|
34
36
|
return (0, server_1.load)({
|
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": "2.
|
|
4
|
+
"version": "2.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@babel/runtime": "^7.18.6",
|
|
44
44
|
"@babel/runtime-corejs3": "^7.18.6",
|
|
45
45
|
"@babel/traverse": "^7.18.8",
|
|
46
|
-
"@docusaurus/cssnano-preset": "2.
|
|
47
|
-
"@docusaurus/logger": "2.
|
|
48
|
-
"@docusaurus/mdx-loader": "2.
|
|
46
|
+
"@docusaurus/cssnano-preset": "2.4.1",
|
|
47
|
+
"@docusaurus/logger": "2.4.1",
|
|
48
|
+
"@docusaurus/mdx-loader": "2.4.1",
|
|
49
49
|
"@docusaurus/react-loadable": "5.5.2",
|
|
50
|
-
"@docusaurus/utils": "2.
|
|
51
|
-
"@docusaurus/utils-common": "2.
|
|
52
|
-
"@docusaurus/utils-validation": "2.
|
|
50
|
+
"@docusaurus/utils": "2.4.1",
|
|
51
|
+
"@docusaurus/utils-common": "2.4.1",
|
|
52
|
+
"@docusaurus/utils-validation": "2.4.1",
|
|
53
53
|
"@slorber/static-site-generator-webpack-plugin": "^4.0.7",
|
|
54
54
|
"@svgr/webpack": "^6.2.1",
|
|
55
55
|
"autoprefixer": "^10.4.7",
|
|
@@ -106,8 +106,8 @@
|
|
|
106
106
|
"webpackbar": "^5.0.2"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@docusaurus/module-type-aliases": "2.
|
|
110
|
-
"@docusaurus/types": "2.
|
|
109
|
+
"@docusaurus/module-type-aliases": "2.4.1",
|
|
110
|
+
"@docusaurus/types": "2.4.1",
|
|
111
111
|
"@types/detect-port": "^1.3.2",
|
|
112
112
|
"@types/react-dom": "^18.0.6",
|
|
113
113
|
"@types/react-router-config": "^5.0.6",
|
|
@@ -127,5 +127,5 @@
|
|
|
127
127
|
"engines": {
|
|
128
128
|
"node": ">=16.14"
|
|
129
129
|
},
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "60e657d8ae5a4a9ed1c2d777f9defd882cc12681"
|
|
131
131
|
}
|