@docusaurus/core 2.0.0-beta.15 → 2.0.0-beta.16
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 +136 -0
- package/bin/{docusaurus.js → docusaurus.mjs} +62 -40
- package/lib/babel/preset.d.ts +1 -2
- package/lib/babel/preset.js +5 -4
- package/lib/choosePort.js +22 -30
- package/lib/client/App.d.ts +1 -2
- package/lib/client/App.js +13 -8
- package/lib/client/LinksCollector.js +1 -1
- package/lib/client/PendingNavigation.d.ts +4 -4
- package/lib/client/PendingNavigation.js +4 -6
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.d.ts +8 -0
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +15 -10
- package/lib/client/client-lifecycles-dispatcher.d.ts +2 -5
- package/lib/client/client-lifecycles-dispatcher.js +5 -7
- package/lib/client/clientEntry.js +11 -5
- package/lib/client/docusaurus.js +6 -4
- package/lib/client/exports/BrowserOnly.d.ts +1 -2
- package/lib/client/exports/BrowserOnly.js +2 -3
- package/lib/client/exports/ComponentCreator.d.ts +1 -2
- package/lib/client/exports/ComponentCreator.js +7 -6
- package/lib/client/exports/ErrorBoundary.d.ts +2 -2
- package/lib/client/exports/ErrorBoundary.js +1 -2
- package/lib/client/exports/Head.d.ts +2 -3
- package/lib/client/exports/Head.js +3 -4
- package/lib/client/exports/Interpolate.js +9 -12
- package/lib/client/exports/Link.d.ts +11 -5
- package/lib/client/exports/Link.js +13 -7
- package/lib/client/exports/Translate.js +2 -1
- package/lib/client/exports/browserContext.js +3 -2
- package/lib/client/exports/docusaurusContext.js +1 -1
- package/lib/client/exports/isInternalUrl.js +1 -1
- package/lib/client/exports/renderRoutes.d.ts +1 -2
- package/lib/client/exports/renderRoutes.js +1 -2
- package/lib/client/exports/router.d.ts +1 -1
- package/lib/client/exports/router.js +1 -1
- package/lib/client/exports/useDocusaurusContext.d.ts +1 -2
- package/lib/client/exports/useDocusaurusContext.js +1 -2
- package/lib/client/flat.d.ts +1 -2
- package/lib/client/flat.js +1 -2
- package/lib/client/normalizeLocation.d.ts +2 -3
- package/lib/client/normalizeLocation.js +1 -2
- package/lib/client/prefetch.d.ts +1 -2
- package/lib/client/prefetch.js +1 -2
- package/lib/client/preload.d.ts +2 -1
- package/lib/client/preload.js +2 -1
- package/lib/client/serverEntry.js +23 -19
- package/lib/client/theme-fallback/Error/index.d.ts +10 -0
- package/lib/client/theme-fallback/Error/index.js +21 -29
- package/lib/client/theme-fallback/Layout/index.d.ts +10 -0
- package/lib/client/theme-fallback/Layout/index.js +10 -19
- package/lib/client/theme-fallback/Loading/index.d.ts +9 -0
- package/lib/client/theme-fallback/Loading/index.js +46 -114
- package/lib/{server/versions/__tests/index.test.d.ts → client/theme-fallback/NotFound/index.d.ts} +2 -1
- package/lib/client/theme-fallback/NotFound/index.js +9 -16
- package/lib/client/theme-fallback/Root/index.d.ts +10 -0
- package/lib/client/theme-fallback/Root/index.js +2 -5
- package/lib/commands/build.js +33 -34
- package/lib/commands/clear.js +23 -11
- package/lib/commands/deploy.js +12 -11
- package/lib/commands/external.d.ts +2 -2
- package/lib/commands/external.js +1 -1
- package/lib/commands/serve.js +3 -2
- package/lib/commands/start.js +4 -4
- package/lib/commands/swizzle/actions.d.ts +23 -0
- package/lib/commands/swizzle/actions.js +102 -0
- package/lib/commands/swizzle/common.d.ts +33 -0
- package/lib/commands/swizzle/common.js +57 -0
- package/lib/commands/swizzle/components.d.ts +29 -0
- package/lib/commands/swizzle/components.js +165 -0
- package/lib/commands/swizzle/config.d.ts +10 -0
- package/lib/commands/swizzle/config.js +77 -0
- package/lib/commands/swizzle/context.d.ts +8 -0
- package/lib/commands/swizzle/context.js +30 -0
- package/lib/commands/swizzle/index.d.ts +8 -0
- package/lib/commands/swizzle/index.js +115 -0
- package/lib/commands/swizzle/prompts.d.ts +12 -0
- package/lib/commands/swizzle/prompts.js +110 -0
- package/lib/commands/swizzle/tables.d.ts +9 -0
- package/lib/commands/swizzle/tables.js +116 -0
- package/lib/commands/swizzle/themes.d.ts +20 -0
- package/lib/commands/swizzle/themes.js +105 -0
- package/lib/commands/writeHeadingIds.d.ts +1 -1
- package/lib/commands/writeHeadingIds.js +13 -14
- package/lib/commands/writeTranslations.js +10 -7
- package/lib/index.d.ts +10 -9
- package/lib/index.js +20 -19
- package/lib/server/brokenLinks.js +30 -20
- package/lib/server/config.js +1 -1
- package/lib/server/configValidation.d.ts +1 -1
- package/lib/server/configValidation.js +32 -23
- package/lib/server/duplicateRoutes.js +2 -4
- package/lib/server/html-tags/htmlTags.js +1 -2
- package/lib/server/i18n.d.ts +0 -1
- package/lib/server/i18n.js +16 -26
- package/lib/server/index.d.ts +1 -1
- package/lib/server/index.js +17 -15
- package/lib/server/loadSetup.d.ts +1 -2
- package/lib/server/loadSetup.js +2 -2
- package/lib/server/moduleShorthand.js +1 -1
- package/lib/server/plugins/index.js +9 -9
- package/lib/server/plugins/init.d.ts +11 -1
- package/lib/server/plugins/init.js +23 -28
- package/lib/server/plugins/pluginIds.js +4 -3
- package/lib/server/presets/index.d.ts +2 -2
- package/lib/server/presets/index.js +3 -3
- package/lib/server/routes.js +13 -7
- package/lib/server/themes/alias.d.ts +1 -1
- package/lib/server/themes/alias.js +5 -6
- package/lib/server/themes/index.d.ts +2 -2
- package/lib/server/themes/index.js +10 -9
- package/lib/server/translations/translations.js +10 -11
- package/lib/server/translations/translationsExtractor.js +20 -19
- package/lib/server/versions/index.d.ts +2 -3
- package/lib/server/versions/index.js +22 -21
- package/lib/webpack/base.d.ts +2 -2
- package/lib/webpack/base.js +30 -22
- package/lib/webpack/client.d.ts +1 -1
- package/lib/webpack/client.js +7 -4
- package/lib/webpack/plugins/ChunkAssetPlugin.d.ts +12 -2
- package/lib/webpack/plugins/ChunkAssetPlugin.js +17 -10
- package/lib/webpack/plugins/CleanWebpackPlugin.d.ts +5 -5
- package/lib/webpack/plugins/CleanWebpackPlugin.js +5 -4
- package/lib/webpack/server.d.ts +1 -1
- package/lib/webpack/server.js +6 -5
- package/lib/webpack/utils.d.ts +3 -3
- package/lib/webpack/utils.js +17 -37
- package/package.json +56 -56
- package/bin/beforeCli.js +0 -124
- package/lib/commands/swizzle.d.ts +0 -9
- package/lib/commands/swizzle.js +0 -236
- package/lib/server/versions/__tests/index.test.js +0 -26
|
@@ -4,44 +4,36 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import Layout from '@theme/Layout';
|
|
10
9
|
import ErrorBoundary from '@docusaurus/ErrorBoundary';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
width: '100%',
|
|
22
|
-
fontSize: '20px',
|
|
23
|
-
}}>
|
|
10
|
+
function ErrorDisplay({ error, tryAgain }) {
|
|
11
|
+
return (<div style={{
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
height: '50vh',
|
|
17
|
+
width: '100%',
|
|
18
|
+
fontSize: '20px',
|
|
19
|
+
}}>
|
|
24
20
|
<h1>This page crashed.</h1>
|
|
25
21
|
<p>{error.message}</p>
|
|
26
22
|
<button type="button" onClick={tryAgain}>
|
|
27
23
|
Try again
|
|
28
24
|
</button>
|
|
29
|
-
</div>
|
|
30
|
-
);
|
|
25
|
+
</div>);
|
|
31
26
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
export default function Error({ error, tryAgain }) {
|
|
28
|
+
// We wrap the error in its own error boundary because the layout can actually
|
|
29
|
+
// throw too... Only the ErrorDisplay component is simple enough to be
|
|
30
|
+
// considered safe to never throw
|
|
31
|
+
return (<ErrorBoundary
|
|
32
|
+
// Note: we display the original error here, not the error that we
|
|
33
|
+
// captured in this extra error boundary
|
|
34
|
+
fallback={() => <ErrorDisplay error={error} tryAgain={tryAgain}/>}>
|
|
40
35
|
<Layout title="Page Error">
|
|
41
|
-
<ErrorDisplay error={error} tryAgain={tryAgain}
|
|
36
|
+
<ErrorDisplay error={error} tryAgain={tryAgain}/>
|
|
42
37
|
</Layout>
|
|
43
|
-
</ErrorBoundary>
|
|
44
|
-
);
|
|
38
|
+
</ErrorBoundary>);
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
export default Error;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
+
/// <reference types="react" />
|
|
9
|
+
import type { Props } from '@theme/Layout';
|
|
10
|
+
export default function Layout({ children, title, description, }: Props): JSX.Element;
|
|
@@ -4,31 +4,22 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import Head from '@docusaurus/Head';
|
|
10
9
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
11
10
|
import useBaseUrl from '@docusaurus/useBaseUrl';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const faviconUrl = useBaseUrl(favicon);
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
11
|
+
export default function Layout({ children, title, description, }) {
|
|
12
|
+
const context = useDocusaurusContext();
|
|
13
|
+
const { siteConfig } = context;
|
|
14
|
+
const { favicon, tagline, title: defaultTitle } = siteConfig;
|
|
15
|
+
const faviconUrl = useBaseUrl(favicon);
|
|
16
|
+
return (<>
|
|
21
17
|
<Head defaultTitle={`${defaultTitle}${tagline ? ` · ${tagline}` : ''}`}>
|
|
22
18
|
{title && <title>{`${title} · ${tagline}`}</title>}
|
|
23
|
-
{favicon && <link rel="icon" href={faviconUrl}
|
|
24
|
-
{description && <meta name="description" content={description}
|
|
25
|
-
{description && (
|
|
26
|
-
<meta property="og:description" content={description} />
|
|
27
|
-
)}
|
|
19
|
+
{favicon && <link rel="icon" href={faviconUrl}/>}
|
|
20
|
+
{description && <meta name="description" content={description}/>}
|
|
21
|
+
{description && (<meta property="og:description" content={description}/>)}
|
|
28
22
|
</Head>
|
|
29
23
|
{children}
|
|
30
|
-
</>
|
|
31
|
-
);
|
|
24
|
+
</>);
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
export default Layout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
import type { LoadingComponentProps } from 'react-loadable';
|
|
9
|
+
export default function Loading({ error, retry, pastDelay, }: LoadingComponentProps): JSX.Element | null;
|
|
@@ -4,133 +4,65 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import React from 'react';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
maxWidth: '50%',
|
|
30
|
-
width: '100%',
|
|
31
|
-
}}>
|
|
8
|
+
export default function Loading({ error, retry, pastDelay, }) {
|
|
9
|
+
if (error) {
|
|
10
|
+
return (<div style={{
|
|
11
|
+
textAlign: 'center',
|
|
12
|
+
color: '#fff',
|
|
13
|
+
backgroundColor: '#fa383e',
|
|
14
|
+
borderColor: '#fa383e',
|
|
15
|
+
borderStyle: 'solid',
|
|
16
|
+
borderRadius: '0.25rem',
|
|
17
|
+
borderWidth: '1px',
|
|
18
|
+
boxSizing: 'border-box',
|
|
19
|
+
display: 'block',
|
|
20
|
+
padding: '1rem',
|
|
21
|
+
flex: '0 0 50%',
|
|
22
|
+
marginLeft: '25%',
|
|
23
|
+
marginRight: '25%',
|
|
24
|
+
marginTop: '5rem',
|
|
25
|
+
maxWidth: '50%',
|
|
26
|
+
width: '100%',
|
|
27
|
+
}}>
|
|
32
28
|
<p>{error.message}</p>
|
|
33
29
|
<div>
|
|
34
30
|
<button type="button" onClick={retry}>
|
|
35
31
|
Retry
|
|
36
32
|
</button>
|
|
37
33
|
</div>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
width: 128,
|
|
55
|
-
height: 110,
|
|
56
|
-
position: 'absolute',
|
|
57
|
-
top: 'calc(100vh - 64%)',
|
|
58
|
-
}}
|
|
59
|
-
viewBox="0 0 45 45"
|
|
60
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
-
stroke="#61dafb">
|
|
62
|
-
<g
|
|
63
|
-
fill="none"
|
|
64
|
-
fillRule="evenodd"
|
|
65
|
-
transform="translate(1 1)"
|
|
66
|
-
strokeWidth="2">
|
|
34
|
+
</div>);
|
|
35
|
+
}
|
|
36
|
+
if (pastDelay) {
|
|
37
|
+
return (<div style={{
|
|
38
|
+
display: 'flex',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
height: '100vh',
|
|
42
|
+
}}>
|
|
43
|
+
<svg id="loader" style={{
|
|
44
|
+
width: 128,
|
|
45
|
+
height: 110,
|
|
46
|
+
position: 'absolute',
|
|
47
|
+
top: 'calc(100vh - 64%)',
|
|
48
|
+
}} viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#61dafb">
|
|
49
|
+
<g fill="none" fillRule="evenodd" transform="translate(1 1)" strokeWidth="2">
|
|
67
50
|
<circle cx="22" cy="22" r="6" strokeOpacity="0">
|
|
68
|
-
<animate
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
dur="3s"
|
|
72
|
-
values="6;22"
|
|
73
|
-
calcMode="linear"
|
|
74
|
-
repeatCount="indefinite"
|
|
75
|
-
/>
|
|
76
|
-
<animate
|
|
77
|
-
attributeName="stroke-opacity"
|
|
78
|
-
begin="1.5s"
|
|
79
|
-
dur="3s"
|
|
80
|
-
values="1;0"
|
|
81
|
-
calcMode="linear"
|
|
82
|
-
repeatCount="indefinite"
|
|
83
|
-
/>
|
|
84
|
-
<animate
|
|
85
|
-
attributeName="stroke-width"
|
|
86
|
-
begin="1.5s"
|
|
87
|
-
dur="3s"
|
|
88
|
-
values="2;0"
|
|
89
|
-
calcMode="linear"
|
|
90
|
-
repeatCount="indefinite"
|
|
91
|
-
/>
|
|
51
|
+
<animate attributeName="r" begin="1.5s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
|
|
52
|
+
<animate attributeName="stroke-opacity" begin="1.5s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
|
|
53
|
+
<animate attributeName="stroke-width" begin="1.5s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
|
|
92
54
|
</circle>
|
|
93
55
|
<circle cx="22" cy="22" r="6" strokeOpacity="0">
|
|
94
|
-
<animate
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
dur="3s"
|
|
98
|
-
values="6;22"
|
|
99
|
-
calcMode="linear"
|
|
100
|
-
repeatCount="indefinite"
|
|
101
|
-
/>
|
|
102
|
-
<animate
|
|
103
|
-
attributeName="stroke-opacity"
|
|
104
|
-
begin="3s"
|
|
105
|
-
dur="3s"
|
|
106
|
-
values="1;0"
|
|
107
|
-
calcMode="linear"
|
|
108
|
-
repeatCount="indefinite"
|
|
109
|
-
/>
|
|
110
|
-
<animate
|
|
111
|
-
attributeName="stroke-width"
|
|
112
|
-
begin="3s"
|
|
113
|
-
dur="3s"
|
|
114
|
-
values="2;0"
|
|
115
|
-
calcMode="linear"
|
|
116
|
-
repeatCount="indefinite"
|
|
117
|
-
/>
|
|
56
|
+
<animate attributeName="r" begin="3s" dur="3s" values="6;22" calcMode="linear" repeatCount="indefinite"/>
|
|
57
|
+
<animate attributeName="stroke-opacity" begin="3s" dur="3s" values="1;0" calcMode="linear" repeatCount="indefinite"/>
|
|
58
|
+
<animate attributeName="stroke-width" begin="3s" dur="3s" values="2;0" calcMode="linear" repeatCount="indefinite"/>
|
|
118
59
|
</circle>
|
|
119
60
|
<circle cx="22" cy="22" r="8">
|
|
120
|
-
<animate
|
|
121
|
-
attributeName="r"
|
|
122
|
-
begin="0s"
|
|
123
|
-
dur="1.5s"
|
|
124
|
-
values="6;1;2;3;4;5;6"
|
|
125
|
-
calcMode="linear"
|
|
126
|
-
repeatCount="indefinite"
|
|
127
|
-
/>
|
|
61
|
+
<animate attributeName="r" begin="0s" dur="1.5s" values="6;1;2;3;4;5;6" calcMode="linear" repeatCount="indefinite"/>
|
|
128
62
|
</circle>
|
|
129
63
|
</g>
|
|
130
64
|
</svg>
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return null;
|
|
65
|
+
</div>);
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
136
68
|
}
|
|
@@ -4,25 +4,18 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
import React from 'react';
|
|
9
8
|
import Layout from '@theme/Layout';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
height: '50vh',
|
|
20
|
-
fontSize: '20px',
|
|
9
|
+
export default function NotFound() {
|
|
10
|
+
return (<Layout title="Page Not Found">
|
|
11
|
+
<div style={{
|
|
12
|
+
display: 'flex',
|
|
13
|
+
justifyContent: 'center',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
height: '50vh',
|
|
16
|
+
fontSize: '20px',
|
|
21
17
|
}}>
|
|
22
18
|
<h1>Oops, page not found </h1>
|
|
23
19
|
</div>
|
|
24
|
-
</Layout>
|
|
25
|
-
);
|
|
20
|
+
</Layout>);
|
|
26
21
|
}
|
|
27
|
-
|
|
28
|
-
export default NotFound;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
export default function Root({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): ReactNode;
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
// Wrapper at the very top of the app, that is applied constantly
|
|
9
8
|
// and does not depend on current route (unlike the layout)
|
|
10
9
|
//
|
|
@@ -12,8 +11,6 @@
|
|
|
12
11
|
// and these providers won't reset state when we navigate
|
|
13
12
|
//
|
|
14
13
|
// See https://github.com/facebook/docusaurus/issues/3919
|
|
15
|
-
function Root({children}) {
|
|
16
|
-
|
|
14
|
+
export default function Root({ children }) {
|
|
15
|
+
return children;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
export default Root;
|
package/lib/commands/build.js
CHANGED
|
@@ -41,9 +41,9 @@ forceTerminate = true) {
|
|
|
41
41
|
isLastLocale,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
catch (
|
|
44
|
+
catch (err) {
|
|
45
45
|
logger_1.default.error `Unable to build website for locale name=${locale}.`;
|
|
46
|
-
throw
|
|
46
|
+
throw err;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
const context = await (0, server_1.loadContext)(siteDir, {
|
|
@@ -58,25 +58,24 @@ forceTerminate = true) {
|
|
|
58
58
|
if (cliOptions.locale) {
|
|
59
59
|
return tryToBuildLocale({ locale: cliOptions.locale, isLastLocale: true });
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
|
|
64
|
-
}
|
|
65
|
-
// We need the default locale to always be the 1st in the list
|
|
66
|
-
// If we build it last, it would "erase" the localized sites built in sub-folders
|
|
67
|
-
const orderedLocales = [
|
|
68
|
-
i18n.defaultLocale,
|
|
69
|
-
...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
|
|
70
|
-
];
|
|
71
|
-
const results = await (0, utils_2.mapAsyncSequential)(orderedLocales, (locale) => {
|
|
72
|
-
const isLastLocale = orderedLocales.indexOf(locale) === orderedLocales.length - 1;
|
|
73
|
-
return tryToBuildLocale({ locale, isLastLocale });
|
|
74
|
-
});
|
|
75
|
-
return results[0];
|
|
61
|
+
if (i18n.locales.length > 1) {
|
|
62
|
+
logger_1.default.info `Website will be built for all these locales: ${i18n.locales}`;
|
|
76
63
|
}
|
|
64
|
+
// We need the default locale to always be the 1st in the list. If we build it
|
|
65
|
+
// last, it would "erase" the localized sites built in sub-folders
|
|
66
|
+
const orderedLocales = [
|
|
67
|
+
i18n.defaultLocale,
|
|
68
|
+
...i18n.locales.filter((locale) => locale !== i18n.defaultLocale),
|
|
69
|
+
];
|
|
70
|
+
const results = await (0, utils_2.mapAsyncSequential)(orderedLocales, (locale) => {
|
|
71
|
+
const isLastLocale = orderedLocales.indexOf(locale) === orderedLocales.length - 1;
|
|
72
|
+
return tryToBuildLocale({ locale, isLastLocale });
|
|
73
|
+
});
|
|
74
|
+
return results[0];
|
|
77
75
|
}
|
|
78
76
|
exports.default = build;
|
|
79
77
|
async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLastLocale, }) {
|
|
78
|
+
var _a;
|
|
80
79
|
process.env.BABEL_ENV = 'production';
|
|
81
80
|
process.env.NODE_ENV = 'production';
|
|
82
81
|
logger_1.default.info `name=${`[${locale}]`} Creating an optimized production build...`;
|
|
@@ -89,11 +88,12 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
89
88
|
// Apply user webpack config.
|
|
90
89
|
const { outDir, generatedFilesDir, plugins, siteConfig: { baseUrl, onBrokenLinks, staticDirectories }, routes, } = props;
|
|
91
90
|
const clientManifestPath = path_1.default.join(generatedFilesDir, 'client-manifest.json');
|
|
92
|
-
let clientConfig = (0, webpack_merge_1.default)((0, client_1.default)(props, cliOptions.minify), {
|
|
91
|
+
let clientConfig = (0, webpack_merge_1.default)(await (0, client_1.default)(props, cliOptions.minify), {
|
|
93
92
|
plugins: [
|
|
94
93
|
// Remove/clean build folders before building bundles.
|
|
95
94
|
new CleanWebpackPlugin_1.default({ verbose: false }),
|
|
96
|
-
// Visualize size of webpack output files with an interactive zoomable
|
|
95
|
+
// Visualize size of webpack output files with an interactive zoomable
|
|
96
|
+
// tree map.
|
|
97
97
|
cliOptions.bundleAnalyzer && new webpack_bundle_analyzer_1.BundleAnalyzerPlugin(),
|
|
98
98
|
// Generate client manifests file that will be used for server bundle.
|
|
99
99
|
new react_loadable_ssr_addon_v5_slorber_1.default({
|
|
@@ -102,22 +102,24 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
102
102
|
].filter(Boolean),
|
|
103
103
|
});
|
|
104
104
|
const allCollectedLinks = {};
|
|
105
|
-
let serverConfig = (0, server_2.default)({
|
|
105
|
+
let serverConfig = await (0, server_2.default)({
|
|
106
106
|
props,
|
|
107
107
|
onLinksCollected: (staticPagePath, links) => {
|
|
108
108
|
allCollectedLinks[staticPagePath] = links;
|
|
109
109
|
},
|
|
110
110
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
if (staticDirectories.length > 0) {
|
|
112
|
+
await Promise.all(staticDirectories.map((dir) => fs_extra_1.default.ensureDir(dir)));
|
|
113
|
+
serverConfig = (0, webpack_merge_1.default)(serverConfig, {
|
|
114
|
+
plugins: [
|
|
115
|
+
new copy_webpack_plugin_1.default({
|
|
116
|
+
patterns: staticDirectories
|
|
117
|
+
.map((dir) => path_1.default.resolve(siteDir, dir))
|
|
118
|
+
.map((dir) => ({ from: dir, to: outDir })),
|
|
119
|
+
}),
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
121
123
|
// Plugin Lifecycle - configureWebpack and configurePostCss.
|
|
122
124
|
plugins.forEach((plugin) => {
|
|
123
125
|
var _a, _b;
|
|
@@ -140,9 +142,7 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
140
142
|
// Run webpack to build JS bundle (client) and static html files (server).
|
|
141
143
|
await (0, utils_1.compile)([clientConfig, serverConfig]);
|
|
142
144
|
// Remove server.bundle.js because it is not needed.
|
|
143
|
-
if (serverConfig.output
|
|
144
|
-
serverConfig.output.filename &&
|
|
145
|
-
typeof serverConfig.output.filename === 'string') {
|
|
145
|
+
if (typeof ((_a = serverConfig.output) === null || _a === void 0 ? void 0 : _a.filename) === 'string') {
|
|
146
146
|
const serverBundle = path_1.default.join(outDir, serverConfig.output.filename);
|
|
147
147
|
if (await fs_extra_1.default.pathExists(serverBundle)) {
|
|
148
148
|
await fs_extra_1.default.unlink(serverBundle);
|
|
@@ -153,7 +153,6 @@ async function buildLocale({ siteDir, locale, cliOptions, forceTerminate, isLast
|
|
|
153
153
|
if (!plugin.postBuild) {
|
|
154
154
|
return;
|
|
155
155
|
}
|
|
156
|
-
// The plugin may reference `this`. We manually bind it again to prevent any bugs.
|
|
157
156
|
await plugin.postBuild({ ...props, content: plugin.content });
|
|
158
157
|
}));
|
|
159
158
|
await (0, brokenLinks_1.handleBrokenLinks)({
|
package/lib/commands/clear.js
CHANGED
|
@@ -11,21 +11,33 @@ const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
|
11
11
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
12
|
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
|
-
async function removePath(
|
|
14
|
+
async function removePath(entry) {
|
|
15
|
+
if (!(await fs_extra_1.default.pathExists(entry.path))) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
15
18
|
try {
|
|
16
|
-
fs_extra_1.default.remove(
|
|
17
|
-
logger_1.default.success `Removed the path=${
|
|
19
|
+
await fs_extra_1.default.remove(entry.path);
|
|
20
|
+
logger_1.default.success `Removed the ${entry.description} at path=${entry.path}.`;
|
|
18
21
|
}
|
|
19
|
-
catch (
|
|
20
|
-
logger_1.default.error `Could not remove path=${
|
|
21
|
-
|
|
22
|
+
catch (err) {
|
|
23
|
+
logger_1.default.error `Could not remove the ${entry.description} at path=${entry.path}.`;
|
|
24
|
+
logger_1.default.error(err);
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
async function clear(siteDir) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const generatedFolder = {
|
|
29
|
+
path: path_1.default.join(siteDir, utils_1.GENERATED_FILES_DIR_NAME),
|
|
30
|
+
description: 'generated folder',
|
|
31
|
+
};
|
|
32
|
+
const buildFolder = {
|
|
33
|
+
path: path_1.default.join(siteDir, utils_1.DEFAULT_BUILD_DIR_NAME),
|
|
34
|
+
description: 'build output folder',
|
|
35
|
+
};
|
|
36
|
+
// In Yarn PnP, cache is stored in `.yarn/.cache` because n_m doesn't exist
|
|
37
|
+
const cacheFolders = ['node_modules', '.yarn'].map((p) => ({
|
|
38
|
+
path: path_1.default.join(siteDir, p, '.cache'),
|
|
39
|
+
description: 'Webpack persistent cache folder',
|
|
40
|
+
}));
|
|
41
|
+
return Promise.all([generatedFolder, buildFolder, ...cacheFolders].map(removePath));
|
|
30
42
|
}
|
|
31
43
|
exports.default = clear;
|
package/lib/commands/deploy.js
CHANGED
|
@@ -28,9 +28,9 @@ function shellExecLog(cmd) {
|
|
|
28
28
|
logger_1.default.info `code=${obfuscateGitPass(cmd)} subdue=${`code: ${result.code}`}`;
|
|
29
29
|
return result;
|
|
30
30
|
}
|
|
31
|
-
catch (
|
|
31
|
+
catch (err) {
|
|
32
32
|
logger_1.default.error `code=${obfuscateGitPass(cmd)}`;
|
|
33
|
-
throw
|
|
33
|
+
throw err;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
function buildSshUrl(githubHost, organizationName, projectName, githubPort) {
|
|
@@ -56,7 +56,7 @@ function hasSSHProtocol(sourceRepoUrl) {
|
|
|
56
56
|
}
|
|
57
57
|
catch {
|
|
58
58
|
// Fails when there isn't a protocol
|
|
59
|
-
return /^([\w-]+@)?[\w.-]+:[\w./_-]
|
|
59
|
+
return /^(?:[\w-]+@)?[\w.-]+:[\w./_-]+/.test(sourceRepoUrl); // git@github.com:facebook/docusaurus.git
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
exports.hasSSHProtocol = hasSSHProtocol;
|
|
@@ -114,8 +114,8 @@ This behavior can have SEO impacts and create relative link issues.
|
|
|
114
114
|
shelljs_1.default.echo('Skipping deploy on a pull request.');
|
|
115
115
|
shelljs_1.default.exit(0);
|
|
116
116
|
}
|
|
117
|
-
// github.io indicates organization repos that deploy via default branch.
|
|
118
|
-
// Organization deploys looks like:
|
|
117
|
+
// github.io indicates organization repos that deploy via default branch.
|
|
118
|
+
// All others use gh-pages. Organization deploys looks like:
|
|
119
119
|
// - Git repo: https://github.com/<organization>/<organization>.github.io
|
|
120
120
|
// - Site url: https://<organization>.github.io
|
|
121
121
|
const isGitHubPagesOrganizationDeploy = projectName.includes('.github.io');
|
|
@@ -169,8 +169,9 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
169
169
|
try {
|
|
170
170
|
await fs_extra_1.default.copy(fromPath, toPath);
|
|
171
171
|
}
|
|
172
|
-
catch (
|
|
173
|
-
|
|
172
|
+
catch (err) {
|
|
173
|
+
logger_1.default.error `Copying build assets from path=${fromPath} to path=${toPath} failed.`;
|
|
174
|
+
throw err;
|
|
174
175
|
}
|
|
175
176
|
shellExecLog('git add --all');
|
|
176
177
|
const commitMessage = process.env.CUSTOM_COMMIT_MESSAGE ||
|
|
@@ -196,13 +197,13 @@ You can also set the deploymentBranch property in docusaurus.config.js .`);
|
|
|
196
197
|
}
|
|
197
198
|
};
|
|
198
199
|
if (!cliOptions.skipBuild) {
|
|
199
|
-
// Build
|
|
200
|
+
// Build site, then push to deploymentBranch branch of specified repo.
|
|
200
201
|
try {
|
|
201
202
|
await runDeploy(await (0, build_1.default)(siteDir, cliOptions, false));
|
|
202
203
|
}
|
|
203
|
-
catch (
|
|
204
|
-
logger_1.default.error(
|
|
205
|
-
|
|
204
|
+
catch (err) {
|
|
205
|
+
logger_1.default.error('Deployment of the build output failed.');
|
|
206
|
+
throw err;
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
else {
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
export default function externalCommand(cli:
|
|
7
|
+
import type { CommanderStatic } from 'commander';
|
|
8
|
+
export default function externalCommand(cli: CommanderStatic, siteDir: string): Promise<void>;
|
package/lib/commands/external.js
CHANGED
|
@@ -11,7 +11,7 @@ const server_1 = require("../server");
|
|
|
11
11
|
const init_1 = (0, tslib_1.__importDefault)(require("../server/plugins/init"));
|
|
12
12
|
async function externalCommand(cli, siteDir) {
|
|
13
13
|
const context = await (0, server_1.loadContext)(siteDir);
|
|
14
|
-
const pluginConfigs = (0, server_1.loadPluginConfigs)(context);
|
|
14
|
+
const pluginConfigs = await (0, server_1.loadPluginConfigs)(context);
|
|
15
15
|
const plugins = await (0, init_1.default)({ pluginConfigs, context });
|
|
16
16
|
// Plugin Lifecycle - extendCli.
|
|
17
17
|
plugins.forEach((plugin) => {
|