@docusaurus/core 2.0.0-beta.8e9b829d9 → 2.0.0-beta.9
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 +29 -7
- package/bin/docusaurus.js +36 -40
- package/lib/.tsbuildinfo +1 -1
- package/lib/babel/preset.js +1 -1
- package/lib/choosePort.js +10 -11
- package/lib/client/.tsbuildinfo +1 -1
- package/lib/client/App.js +8 -22
- package/lib/client/PendingNavigation.d.ts +24 -1
- package/lib/client/PendingNavigation.js +1 -1
- package/lib/client/baseUrlIssueBanner/BaseUrlIssueBanner.js +1 -0
- package/lib/client/docusaurus.js +0 -1
- package/lib/client/exports/BrowserOnly.js +5 -3
- package/lib/client/exports/Link.js +9 -9
- package/lib/client/exports/Translate.d.ts +2 -2
- package/lib/client/exports/Translate.js +10 -10
- package/lib/client/exports/browserContext.d.ts +11 -0
- package/lib/client/exports/browserContext.js +21 -0
- package/lib/client/exports/constants.js +1 -11
- package/lib/client/exports/{context.d.ts → docusaurusContext.d.ts} +5 -3
- package/lib/client/exports/docusaurusContext.js +25 -0
- package/lib/client/exports/useBaseUrl.js +1 -1
- package/lib/client/exports/useDocusaurusContext.js +2 -7
- package/lib/client/exports/useGlobalData.js +1 -5
- package/lib/client/exports/{context.js → useIsBrowser.d.ts} +1 -2
- package/lib/client/exports/useIsBrowser.js +11 -0
- package/lib/client/normalizeLocation.d.ts +1 -3
- package/lib/client/prefetch.js +0 -1
- package/lib/client/serverEntry.js +11 -27
- package/lib/commands/build.js +24 -21
- package/lib/commands/clear.js +2 -2
- package/lib/commands/commandUtils.js +2 -2
- package/lib/commands/deploy.js +24 -14
- package/lib/commands/external.js +4 -4
- package/lib/commands/serve.js +13 -13
- package/lib/commands/start.js +69 -70
- package/lib/commands/swizzle.js +14 -14
- package/lib/commands/writeHeadingIds.d.ts +8 -5
- package/lib/commands/writeHeadingIds.js +32 -31
- package/lib/commands/writeTranslations.js +25 -11
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +4 -1
- package/lib/server/brokenLinks.js +13 -13
- package/lib/server/config.js +4 -4
- package/lib/server/configValidation.js +3 -2
- package/lib/server/duplicateRoutes.js +2 -2
- package/lib/server/html-tags/htmlTags.js +5 -5
- package/lib/server/html-tags/index.js +2 -2
- package/lib/server/i18n.js +4 -4
- package/lib/server/index.js +98 -49
- package/lib/server/loadSetup.js +3 -3
- package/lib/server/plugins/applyRouteTrailingSlash.js +1 -1
- package/lib/server/plugins/index.d.ts +1 -1
- package/lib/server/plugins/index.js +20 -13
- package/lib/server/plugins/init.js +7 -10
- package/lib/server/plugins/pluginIds.js +2 -2
- package/lib/server/presets/index.js +4 -7
- package/lib/server/routes.js +9 -11
- package/lib/server/themes/alias.d.ts +1 -0
- package/lib/server/themes/alias.js +22 -10
- package/lib/server/themes/index.js +5 -7
- package/lib/server/translations/translations.js +9 -9
- package/lib/server/translations/translationsExtractor.d.ts +1 -1
- package/lib/server/translations/translationsExtractor.js +58 -47
- package/lib/server/utils.d.ts +6 -0
- package/lib/server/utils.js +8 -9
- package/lib/server/versions/__fixtures__/dummy-plugin.d.ts +0 -0
- package/lib/server/versions/__tests/index.test.js +5 -5
- package/lib/server/versions/index.js +6 -6
- package/lib/webpack/base.js +12 -13
- package/lib/webpack/client.js +8 -17
- package/lib/webpack/plugins/CleanWebpackPlugin.js +2 -5
- package/lib/webpack/plugins/LogPlugin.js +3 -4
- package/lib/webpack/plugins/WaitPlugin.js +4 -4
- package/lib/webpack/react-dev-utils-webpack5/evalSourceMapMiddleware.d.ts +2 -0
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.d.ts +5 -0
- package/lib/webpack/react-dev-utils-webpack5/formatWebpackMessages.js +1 -1
- package/lib/webpack/react-dev-utils-webpack5/webpackHotDevClient.d.ts +1 -0
- package/lib/webpack/server.js +7 -7
- package/lib/webpack/sharedModuleAliases.js +1 -1
- package/lib/webpack/utils.js +25 -23
- package/package.json +44 -38
- package/tsconfig.client.json +0 -1
- package/tsconfig.json +4 -3
package/bin/beforeCli.js
CHANGED
|
@@ -42,19 +42,41 @@ const notifier = updateNotifier({
|
|
|
42
42
|
// Hacky way to ensure we check for updates on first run
|
|
43
43
|
// Note: the notification will only happen in the 2nd run
|
|
44
44
|
// See https://github.com/yeoman/update-notifier/issues/209
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
try {
|
|
46
|
+
if (
|
|
47
|
+
notifier.config &&
|
|
48
|
+
!notifier.disabled &&
|
|
49
|
+
Date.now() - notifier.config.get('lastUpdateCheck') < 50
|
|
50
|
+
) {
|
|
51
|
+
notifier.config.set('lastUpdateCheck', 0);
|
|
52
|
+
notifier.check();
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
// Do not stop cli if this fails, see https://github.com/facebook/docusaurus/issues/5400
|
|
56
|
+
console.error(e);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// We don't want to display update message for canary releases
|
|
60
|
+
// See https://github.com/facebook/docusaurus/issues/5378
|
|
61
|
+
function ignoreUpdate(update) {
|
|
62
|
+
const isCanaryRelease =
|
|
63
|
+
update && update.current && update.current.startsWith('0.0.0');
|
|
64
|
+
return isCanaryRelease;
|
|
51
65
|
}
|
|
52
66
|
|
|
53
|
-
if (
|
|
67
|
+
if (
|
|
68
|
+
notifier.config &&
|
|
69
|
+
notifier.update &&
|
|
70
|
+
notifier.update.current !== notifier.update.latest
|
|
71
|
+
) {
|
|
54
72
|
// Because notifier clears cached data after reading it, leading to notifier not consistently displaying the update
|
|
55
73
|
// See https://github.com/yeoman/update-notifier/issues/209
|
|
56
74
|
notifier.config.set('update', notifier.update);
|
|
57
75
|
|
|
76
|
+
if (ignoreUpdate(notifier.update)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
58
80
|
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
59
81
|
const sitePkg = require(path.resolve(process.cwd(), 'package.json'));
|
|
60
82
|
const siteDocusaurusPackagesForUpdate = Object.keys({
|
package/bin/docusaurus.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// TODO remove when fixed: https://github.com/Stuk/eslint-plugin-header/issues/39
|
|
4
|
-
/* eslint-disable header/header */
|
|
5
2
|
/**
|
|
6
3
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
4
|
*
|
|
@@ -10,7 +7,7 @@
|
|
|
10
7
|
*/
|
|
11
8
|
|
|
12
9
|
const chalk = require('chalk');
|
|
13
|
-
const
|
|
10
|
+
const fs = require('fs');
|
|
14
11
|
const cli = require('commander');
|
|
15
12
|
const {
|
|
16
13
|
build,
|
|
@@ -26,6 +23,8 @@ const {
|
|
|
26
23
|
|
|
27
24
|
require('./beforeCli');
|
|
28
25
|
|
|
26
|
+
const resolveDir = (dir = '.') => fs.realpathSync(dir);
|
|
27
|
+
|
|
29
28
|
cli.version(require('../package.json').version).usage('<command> [options]');
|
|
30
29
|
|
|
31
30
|
cli
|
|
@@ -51,8 +50,8 @@ cli
|
|
|
51
50
|
'--no-minify',
|
|
52
51
|
'build website without minimizing JS bundles (default: false)',
|
|
53
52
|
)
|
|
54
|
-
.action((siteDir
|
|
55
|
-
build(
|
|
53
|
+
.action((siteDir, {bundleAnalyzer, config, outDir, locale, minify}) => {
|
|
54
|
+
build(resolveDir(siteDir), {
|
|
56
55
|
bundleAnalyzer,
|
|
57
56
|
outDir,
|
|
58
57
|
config,
|
|
@@ -69,14 +68,8 @@ cli
|
|
|
69
68
|
'copy TypeScript theme files when possible (default: false)',
|
|
70
69
|
)
|
|
71
70
|
.option('--danger', 'enable swizzle for internal component of themes')
|
|
72
|
-
.action((themeName, componentName, siteDir
|
|
73
|
-
swizzle(
|
|
74
|
-
path.resolve(siteDir),
|
|
75
|
-
themeName,
|
|
76
|
-
componentName,
|
|
77
|
-
typescript,
|
|
78
|
-
danger,
|
|
79
|
-
);
|
|
71
|
+
.action((themeName, componentName, siteDir, {typescript, danger}) => {
|
|
72
|
+
swizzle(resolveDir(siteDir), themeName, componentName, typescript, danger);
|
|
80
73
|
});
|
|
81
74
|
|
|
82
75
|
cli
|
|
@@ -98,8 +91,8 @@ cli
|
|
|
98
91
|
'--skip-build',
|
|
99
92
|
'skip building website before deploy it (default: false)',
|
|
100
93
|
)
|
|
101
|
-
.action((siteDir
|
|
102
|
-
deploy(
|
|
94
|
+
.action((siteDir, {outDir, skipBuild, config}) => {
|
|
95
|
+
deploy(resolveDir(siteDir), {
|
|
103
96
|
outDir,
|
|
104
97
|
config,
|
|
105
98
|
skipBuild,
|
|
@@ -125,19 +118,17 @@ cli
|
|
|
125
118
|
'--poll [interval]',
|
|
126
119
|
'use polling rather than watching for reload (default: false). Can specify a poll interval in milliseconds',
|
|
127
120
|
)
|
|
128
|
-
.action(
|
|
129
|
-
(siteDir
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
);
|
|
121
|
+
.action((siteDir, {port, host, locale, config, hotOnly, open, poll}) => {
|
|
122
|
+
start(resolveDir(siteDir), {
|
|
123
|
+
port,
|
|
124
|
+
host,
|
|
125
|
+
locale,
|
|
126
|
+
config,
|
|
127
|
+
hotOnly,
|
|
128
|
+
open,
|
|
129
|
+
poll,
|
|
130
|
+
});
|
|
131
|
+
});
|
|
141
132
|
|
|
142
133
|
cli
|
|
143
134
|
.command('serve [siteDir]')
|
|
@@ -155,7 +146,7 @@ cli
|
|
|
155
146
|
.option('-h, --host <host>', 'use specified host (default: localhost)')
|
|
156
147
|
.action(
|
|
157
148
|
(
|
|
158
|
-
siteDir
|
|
149
|
+
siteDir,
|
|
159
150
|
{
|
|
160
151
|
dir = 'build',
|
|
161
152
|
port = 3000,
|
|
@@ -164,7 +155,7 @@ cli
|
|
|
164
155
|
config,
|
|
165
156
|
},
|
|
166
157
|
) => {
|
|
167
|
-
serve(
|
|
158
|
+
serve(resolveDir(siteDir), {
|
|
168
159
|
dir,
|
|
169
160
|
port,
|
|
170
161
|
build: buildSite,
|
|
@@ -177,8 +168,8 @@ cli
|
|
|
177
168
|
cli
|
|
178
169
|
.command('clear [siteDir]')
|
|
179
170
|
.description('Remove build artifacts.')
|
|
180
|
-
.action((siteDir
|
|
181
|
-
clear(
|
|
171
|
+
.action((siteDir) => {
|
|
172
|
+
clear(resolveDir(siteDir));
|
|
182
173
|
});
|
|
183
174
|
|
|
184
175
|
cli
|
|
@@ -202,10 +193,10 @@ cli
|
|
|
202
193
|
)
|
|
203
194
|
.action(
|
|
204
195
|
(
|
|
205
|
-
siteDir
|
|
196
|
+
siteDir,
|
|
206
197
|
{locale = undefined, override = false, messagePrefix = '', config},
|
|
207
198
|
) => {
|
|
208
|
-
writeTranslations(
|
|
199
|
+
writeTranslations(resolveDir(siteDir), {
|
|
209
200
|
locale,
|
|
210
201
|
override,
|
|
211
202
|
config,
|
|
@@ -215,11 +206,16 @@ cli
|
|
|
215
206
|
);
|
|
216
207
|
|
|
217
208
|
cli
|
|
218
|
-
.command('write-heading-ids [contentDir]')
|
|
209
|
+
.command('write-heading-ids [contentDir] [files]')
|
|
219
210
|
.description('Generate heading ids in Markdown content.')
|
|
220
|
-
.
|
|
221
|
-
|
|
222
|
-
|
|
211
|
+
.option(
|
|
212
|
+
'--maintain-case',
|
|
213
|
+
"keep the headings' casing, otherwise make all lowercase (default: false)",
|
|
214
|
+
)
|
|
215
|
+
.option('--overwrite', 'overwrite existing heading IDs (default: false)')
|
|
216
|
+
.action((siteDir, files, options) =>
|
|
217
|
+
writeHeadingIds(resolveDir(siteDir), files, options),
|
|
218
|
+
);
|
|
223
219
|
|
|
224
220
|
cli.arguments('<command>').action((cmd) => {
|
|
225
221
|
cli.outputHelp();
|
|
@@ -242,7 +238,7 @@ function isInternalCommand(command) {
|
|
|
242
238
|
|
|
243
239
|
async function run() {
|
|
244
240
|
if (!isInternalCommand(process.argv.slice(2)[0])) {
|
|
245
|
-
await externalCommand(cli,
|
|
241
|
+
await externalCommand(cli, resolveDir('.'));
|
|
246
242
|
}
|
|
247
243
|
|
|
248
244
|
cli.parse(process.argv);
|